1. PHP / Говнокод #8313

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public function action_delete(){   
            if (ORM::factory($_GET['type'], $_GET['id'])->delete())        
                $arr[0] = array("text" => "ok");
            else
                $arr[0] = array("text" => "no");
                                                   
            echo json_encode($arr);                               
    }

    Метод контролера (kohana), который используется для ajax запросов. Хоть в нем ничего не проверяется, за то этот метод очень функциональный. С помощью GET request можно удалить из БД практически все!

    k1011, 27 Октября 2011

    Комментарии (4)
  2. PHP / Говнокод #8308

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    } else { ?>
    		  <?=$profile[0]->info_height; ?>
    		  <? } ?></dd>
    		  <? /*РОСТ ВЕС*/ ?>
            <?
    		  //Если профиль девушки, то написать про титьки...

    Знакомый программист очень любит открывать и закрывать php код ;)

    Gary, 26 Октября 2011

    Комментарии (170)
  3. PHP / Говнокод #8306

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    <form action="" method=post>
         <input type="text" size="30" name=""><br><br>
         <textarea name="" rows="10" cols="40"></textarea><br> 
         <p style="font:15px sans-serif;color:#0e54a9;margin-top:5px;margin-bottom:-10px;">Антиспам:</p><br> 
         <?php 
          $i=1;
          do
          {
          $num[$i] = mt_rand(0,9);
          echo "<img src='img/".$num[$i].".jpg' border='0' align='bottom' vspace='5px'>";
          $i++;
          }
          while ($i<5);
          $captcha = $num[1].$num[2].$num[3].$num[4];
          ?>
          <br><br>
          <input name="captcha" type="hidden" value="<?php echo $captcha ;?>">
          <input name="pr" style="margin-top:-15px;margin-bottom:5px" type="text" size="9" maxlength="4"><br><br>
          <input type="submit" value="Відправити" name="submit"> 
          <input type="reset" value="Очистити" name="submit">
          </form>

    так мы рисуем капчу

    Sulik78, 26 Октября 2011

    Комментарии (6)
  4. PHP / Говнокод #8305

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    function getTelephoneData()
      {
        preg_match('/\+([\d])\(([\d]{3})\)([\d]{3})-([\d]{2})-([\d]{2})/', $this->getTelephone(), $match);
    
        $telephone_data = array();
        if($match)
          $telephone_data = array('code_country' => $match[1],
                                  'code_city' => $match[2],
                                  'number1' => $match[3],
                                  'number2' => $match[4],
                                  'number3' => $match[5]
                                  );
    
        return $telephone_data;
      }
    
      function getFaxData()
      {
        preg_match('/\+([\d])\(([\d]{3})\)([\d]{3})-([\d]{2})-([\d]{2})/', $this->getFax(), $match);
    
        $telephone_data = array();
        if($match)
        {
          $telephone_data = array(
            'code_country' => $match[1],
            'code_city' => $match[2],
            'number1' => $match[3],
            'number2' => $match[4],
            'number3' => $match[5]
          );
        }
    
        return $telephone_data;
      }
    
      function getMobileTelephoneData()
      {
        $telephone_data = array();
        preg_match('/\+([\d])\(([\d]{3})\)([\d]{3})-([\d]{2})-([\d]{2})/', $this->getMobileTelephone(), $match);
    
        if(count($match))
          $telephone_data = array('code_country' => $match[1],
                                  'code_city' => $match[2],
                                  'number1' => $match[3],
                                  'number2' => $match[4],
                                  'number3' => $match[5]
                                  );
    
        return $telephone_data;
      }

    korchasa, 26 Октября 2011

    Комментарии (3)
  5. PHP / Говнокод #8304

    +147

    1. 1
    //так как в mysql есть ограничение на джойны (61), делаем следующим образом:...

    alexoy, 26 Октября 2011

    Комментарии (6)
  6. PHP / Говнокод #8297

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    <style>
    
    div.adsPayments a {
    
            border: 0px none;
    
            text-decoration: none;
    
    }
    
    div.adsPayments a img {
    
            border: 0px none;
    
            margin: 1px;
    
    }
    
    </style>
    
    <?
    
    echo '<style>';
    
    echo 'table td { padding: 3px 10px 3px 20px; }';
    
    echo 'html, body {font-family: helvetica; font-size: 12px;}';
    
    echo 'a, a:hover {text-decoration: none;cursor: pointer;}';
    
    echo 'td, td b { font-size: 12px; }';
    
    echo '</style>';
    
    ?>
    
    <div class="adsPayments">...

    Видимо css внутри php гораздо более внушительно смотрится..

    antongorodezkiy, 26 Октября 2011

    Комментарии (5)
  7. PHP / Говнокод #8290

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    $bError=true;
    do { 
    	$logistType = $_REQUEST['logistType'];
    	if (!preg_match("|^\d+$|", $logistType)) { break; }
    	if ($_SESSION['cartaddon']['***'] and $logistType>=1 and $logistType<=5) {
    	} elseif (!$_SESSION['cartaddon']['***'] and $logistType>=3 and $logistType<=5) {
    	} else {
    		break;
    	}
    	$_SESSION['cartaddon']['logistType'] = $logistType;
    	$bError = false;
    	$text = $_REQUEST['text'];
    	$text = trim(strip_tags($text));
    	$_SESSION['cartaddon']['pozhelania'] = $text;
    } while (0);

    Проверка если ли ошибки при оформлении заказа
    На месте звездочек - палевное название, так что зацензурил

    ПыСы: код не мой. И спасибо богам за это

    kindofbear, 25 Октября 2011

    Комментарии (23)
  8. PHP / Говнокод #8284

    +176

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    if (strpos($_SERVER[HTTP_REFERER], "chocobo.us")) {
    	echo("Go away kids.");
    	exit;
    }
    
    
    if (strpos($_SERVER[REMOTE_HOST], "midmich.net")) { echo("Dry your eyes son, not everyone can be funny."); }
    if (strpos($_SERVER[REMOTE_HOST], "rima-tde.net")) { echo("spam == permban"); }
    #if ($REMOTE_ADDR == "12.227.136.202") {echo("Cheap sluts need not apply.");exit;}
    if ($REMOTE_ADDR == "129.252.177.248") {die(0);}
    if ($REMOTE_ADDR == "80.190.209.170") {die(0); }
    if ($REMOTE_ADDR == "62.163.74.167") {die(0);}
    if ($REMOTE_ADDR == "69.10.120.117") {echo("bye bye");exit;}
    if ($REMOTE_ADDR == "24.10.146.28") {echo("flooding the queue with nonsense == ban");exit;}
    if ($REMOTE_ADDR == "80.202.184.96") {echo("there is but one qdb.  ripoff artists need not apply.");exit;}
    if ($REMOTE_ADDR == "216.24.104.36") {echo("Blaxthos: yeah so, however many quotes us bash mods reject is how many cocks we suck -- take it easy");exit;}
    if ($REMOTE_ADDR == "217.230.240.250") die("No.");
    if ($REMOTE_ADDR == "134.102.2.100") {exit;}
    if ($REMOTE_ADDR == "217.64.202.205") {echo("you == idiot");exit;}
    if ($REMOTE_ADDR == "64.237.52.210") {exit;}
    if ($REMOTE_ADDR == "155.143.208.237") {exit;}
    if ($REMOTE_ADDR == "82.165.144.86") {exit;}
    if ($REMOTE_ADDR == "141.157.35.222") {echo("Go away.");exit;}
    if ($REMOTE_ADDR == "80.198.19.122") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "192.93.2.12") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "24.235.181.61") {echo("*fuckx* bash.org is for niggers.");exit;}
    if ($REMOTE_ADDR == "213.202.130.44") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "130.194.13.106") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "144.132.68.119") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "81.1.73.247") {echo("your access has been revoked");exit;}
    if ($REMOTE_ADDR == "68.13.143.147") {exit;}
    if ($REMOTE_ADDR == "217.8.141.230") {exit;}
    if ($REMOTE_ADDR == "62.101.198.25") {exit;}
    if ($REMOTE_ADDR == "80.96.109.170") {exit;}
    if ($REMOTE_ADDR == "80.60.182.139") {exit;}
    if ($REMOTE_ADDR == "4.21.108.175") {echo("Flooding the submission queue.  (Banned)");exit;}
    if ($REMOTE_ADDR == "151.188.16.17") {echo("Thanks for your letter.  --Blaxthos (you can all thank Lunch Box Prime (some fuckchop on AIM)");exit;}
    if ($REMOTE_ADDR == "203.217.65.231") {echo("No more.");exit;}
    if ($REMOTE_ADDR == "68.111.156.240") {echo("No more.");exit;}
    if ($REMOTE_ADDR == "82.149.227.249") {echo("No more.");exit;}

    http://webcache.googleusercontent.com/search?q=cache%3Abash.org%2Findex.bak

    Crazy_penguin, 24 Октября 2011

    Комментарии (19)
  9. PHP / Говнокод #8283

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    <script src=scripts.js></script>
    <?
    
        if (isset($remove) && $user1 !="selectuser"):  //to remove user from DB
    	print "Was updated sucsessfully: user '$user1' was removed<br>";
    	print "<font color=red>If You want to reload this page use <u>our 'Reload' button only</u></font>";
    	$query="delete from users where login=\"$user1\"";
            $result=mysql_query($query);     
    
       if (!isset($reloadme) ):
    
    
       //decremet when registered users removed users.txt
    	$file_loc="users.txt";
    	chmod ($file_loc,0755);
    	$newfile = fopen($file_loc, "r");
    	$file_contents = fread($newfile, filesize($file_loc));
            $file_contents=$file_contents-1;   //value contains how many users
    	$newfile = fopen($file_loc, "w+");
    	fwrite($newfile, "$file_contents");
    	fclose($newfile);
    	chmod ($file_loc,0700);       // end of adding data to file
    	endif;
       endif;   //end of reloadme
    //counting of users
    	$file_loc = "users.txt";
    //	chmod ($file_loc,0644);
    	$whattoread = fopen($file_loc, "r");
    	$file_contents = fread($whattoread, filesize($file_loc));
    	fclose($whattoread);
    //	chmod ($file_loc,0755);       // end of adding data to file
    //end of counting
    
    
    
        $query="select * from users order by id";
        $result=mysql_query($query);     // for first while	
        $result1=mysql_query($query);   // for second while
    	print "<table border=1 cellspacing=0 cellpadding=0 bordercolor=#007898><tr><td>";   //external table
    	print "<table border=0 cellspacing=2 cellpadding=2 width=590><tr><td>
    	<form action=$PHP_SELF method=post><select name=\"user1\" class=select1><option value=\"selectuser\"> Select user ";
        while($row=mysql_fetch_object($result)):	
    	print"<option value=\"$row->login\" style=\"background-color:#FFFFFF;\">$row->login";	
    	endwhile;
    	print "</select><br>
    	<input type=hidden name=remove>
    	<input type=hidden name=show>
    	<input type=hidden name=admin_login value=$admin_login_compare>";   // to enter one more time to login.php
    	print "<input type=hidden name=admin_password value=$admin_password_compare>"; // if ($admin_password!=$admin_password_compare) etc....
    	print "<input type=submit value=\"Remove User\" class=button1></form>";
    
    //reload this page
    	print "<form action=$PHP_SELF method=post>
    	<input type=hidden name=show>
    	<input type=hidden name=admin_login value=$admin_login_compare>";   // to enter one more time to login.php
    	print "<input type=hidden name=admin_password value=$admin_password_compare>"; // if ($admin_password!=$admin_password_compare) etc....
    	print "<input type=hidden name=reloadme ><input type=submit value=Reload  class=button1></form>";
    
    
    	print "Counter: $file_contents users
    	</td>";
    
    
    	print "<td>
    	<table border=1 cellspacing=0 cellpadding=4 bordercolor=#007898><tr><td>ID</td><td>Login</td><td>Password</td><td>Email</td><td>Last visit (Y/M/D)</td></tr></tr>";
        while($row=mysql_fetch_object($result1)):	
            print "<tr>";
    	print "<td>$row->id</td>";
    	print "<td><a href=\"javascript:showuserdata('$row->login','$row->address','$row->fax','$row->tel','$row->site')\" title=\"Show about $row->login\">$row->login</td>";
    	print "<td>$row->password </td>";
    	print "<td><a href=\"mailto:$row->email\" title=\"Email to $row->login\">$row->email</td>";
    	print "<td>$row->last_date</td>";
    	print "</tr>";
    	endwhile;
    	print "</table></td></tr></table>";
    	print "	</table>";  //end of external table
    	print "<br>&nbsp; Click user name to view data about him";
    
    	exit;
    
    ?>

    ITdocer, 23 Октября 2011

    Комментарии (4)
  10. PHP / Говнокод #8271

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    $searchCondition1 = ''; 
     $searchCondition2 = ''; 
     $searchCondition3 = ''; 
     $flag = false; 
     $sql = 'SELECT f.flight_id,
                   (SELECT city
                    FROM airports
                    WHERE airport_id = f.from) as _from,
                   (SELECT city
                    FROM airports
                    WHERE airport_id = f.to) as _to,
                    f.flight_date as fdate,
                    f.flight_time,
                    f.distance,
                    p.plain_name as plain
            FROM flight f JOIN planes p
                ON f.plain_id = p.plain_id
            WHERE '; 
     $fields = 0; 
     if($_POST['txtSearch']){ 
         if($_POST['txtFrom'] != ''){ 
             $searchCondition1 = " city = '".$_POST['txtFrom']."'"; 
             $flag = true; // set flag to TRUE
             $fields++; 
         }
         if($_POST['txtTo'] != ''){ // if To field is not empty
             $searchCondition2 = " city = '".$_POST['txtTo']."'"; 
             $flag = true;  // set flag to TRUE
             $fields++; 
         }
         if ($_POST['txtDate'] != ''){ // if Date field is not empty
             $searchCondition3 = " DATE(f.flight_date) = '".$_POST['txtDate']."'";
             $fields++; // and inc 
         }
         if($fields == 0){                             
             echo "<br/><div style=\"color:red\">Please, enter at least one filed to search</div>"; 
         }else{ 
             if($searchCondition1 != '' && $searchCondition2 == ''){ 
             $sql .= " f.from IN (SELECT airport_id
                                        FROM airports
                                        WHERE ".$searchCondition1.")"; 
             }
             if($searchCondition1 == '' && $searchCondition2 != ''){ 
                 $sql .= " f.to IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition2.")"; 
             }                                                              
             if($searchCondition1 != '' && $searchCondition2 != ''){ 
                 $sql .= " f.from IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition1.")
                                 AND f.to IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition2.")"; 
             }
             if($searchCondition3 != ''){ 
                 if($flag){ 
                     $sql .= " AND ".$searchCondition3; 
                 }else{
                     $sql .= $searchCondition3; 
                 }
    
             }
             include_once('database.php'); 
             $db = createPDO();
             $result = $db->query($sql);
             echo '<table>
                  <tr>
                    <th>
                        From
                    </th>
                    <th>
                        To
                    </th>
                    <th>
                        Flight Date
                    </th>
                    <th>
                        Flight Time
                    </th>
                    <th>
                        Distance
                    </th>
                    <th>
                        Plane
                    </th>
                    <th>
                        Action
                    </th>
                </tr>'; // create an HTML table with headers
             while($row = $result->fetch()){...}

    Ищем в табличке в зависимости от заполненных полей в форме

    denis90, 22 Октября 2011

    Комментарии (4)