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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $php1 = "<";
    $php2= "?php";
    $php3 = " require_once $";
    $php4 = "_SERVER['DOCUMENT_ROOT'].\"/gen/admin/Debugger.php\"; ?";
    $php5 = "";
    $php6 = ">\r\n";
    $php_debuger = $php1 .$php2 .$php3 .$php4 .$php5 .$php6;

    Даже трудно предположить нахрен так.

    kerberos, 22 Июня 2016

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    $fname=rand(0,10000)."_".$fname;
    while (is_file($upload_path.$fname)) {
        $fname=rand(0,10000)."_".$filename;
    }

    Если вдруг пользователь загрузил файл с одним и тем же именем, то надо ему приделать префикс. НО! Вдруг такой префикс уже был сгенерирован, ГПСЧ, тервер же! Сразу видно автор из ВУЗа.

    carte, 22 Июня 2016

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

    0

    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
    function setLastHandshake ($carID) {
    	$HsList = json_decode(file_get_contents('carconnection.txt'), 1);
    	if ($HsList == "null" || $HsList == null) {
    		$HsList = json_decode("[]");
    	}
    	$carCount = count($HsList);
    	$i = 0;
    	foreach ($HsList as &$row) {
    		if ($row['car'] == $carID) {
    			$row['lastHS'] = (string)time();
    			break;
    		}
    		else {
    		$i++;
    		}
    		if ($i == $carCount) {
    			$HsList[] = array('car' => (string)$carID, 'lastHS' => (string)time());
    		}
    	}
    	if ($HsList == "null" || $HsList == null) {
    		return -1;
    	}
    	$f = fopen('carconnection.txt', 'w');
    	fwrite($f, json_encode($HsList));
    }

    tooyz, 20 Июня 2016

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

    +2

    1. 1
    2. 2
    3. 3
    <input type="hidden" name="lang" value="<?= LANG ?>"/>
    <input type="hidden" name="ID" value=<?= $arResult["ID"] ?>/>
    <input type="hidden" name="LOGIN" value=<?= $arResult["arUser"]["LOGIN"] ?>/>

    Кусок формы редактирования профиля.. Отвлечемся от горячо любимой CMS и сконцентрируемся на сути...

    Кодер так спешил, что решил просто type="text" превратить в хиддены. Бог с ним что это дает юзеру намек на то как сменить логин.
    Но он забыл кавычки. ID проходит через IntVal и это не заметно. А вот к логину при каждом сохранении дописывается "/", юзера не выкидывает. А вот в следующий раз он должен угадать сколько слэшей добавить к логину. Да и логин запретили менять наверное не просто так, а потому что при регистрации туда прописывается мыло, а вот при апдейте юзера уже не трогают это...

    maddocnc, 17 Июня 2016

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

    0

    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
    # https://www.fusionticket.org/ cms для продажи билетов 
    
    // файл includes/classes/class.router.php
    
        if(is_null($action)){
          if (isset($_POST['action'])) {
            $action=$_POST['action'];
          } elseif (isset($_GET['action'])) {
            $action=$_GET['action'];
          } else
            $action=false;
        }
    
        $_REQUEST['action'] = $action;
        $_GET['action']     = $action;
        $_POST['action']    = $action;
        //echo $controller,'-',$module, '-',$action;
    
    //  теперь с class.router.php попадаем сюда includes/template/web/shop.tpl
    
    {if  $smarty.post.action eq 'resendpassword'}
       {$user->forgot_password_f($smarty.post.email)}
    {/if}
    
    {if $smarty.request.action eq 'login' and $smarty.request.type != 'block'}
    	{include file="user_login.tpl"}
    
    {elseif $smarty.request.action eq 'register'}
      {if $smarty.request.register_user}
        {user->register ismember=true data=$smarty.post secure='user_nospam' login=true}
        {assign var='user_data' value=$smarty.post}
        {if $user_errors}
          {include file="user_register.tpl" ManualRegister=true}
        {else}
          {include file="user_activate.tpl"}
        {/if}
      {else}
        {include file="user_register.tpl" ManualRegister=true}
      {/if}
    
    {elseif $smarty.request.action eq 'activate'}
      {include file="user_activate.tpl"}
    
    {elseif $smarty.request.action eq 'resend_activation'}
      {include file="resend_activation.tpl"}
    {elseif $smarty.get.action eq "remove"}
      {$cart->remove_item_f($smarty.get.event_id,$smarty.get.cat_id,$smarty.get.item)}
      {include file="cart_view.tpl"}
    
    {elseif $smarty.request.action eq "addtocart"}
      {if $smarty.post.place}
        {assign var='last_item' value=$cart->add_item_f($smarty.post.event_id, $smarty.post.category_id, $smarty.post.place, $smarty.post.discount, 'mode_web')}
      {else}
        {assign var='last_item' value=$cart->add_item_f($smarty.post.event_id, $smarty.post.category_id, $smarty.post.places, $smarty.post.discount, 'mode_web')}
      {/if}
      {if $last_item}
        {redirect url="index.php?action=view_cart&event_id={$smarty.post.event_id}"}
      {else}
        {include file="event_ordering.tpl"}
      {/if}
    {elseif $smarty.request.action eq "buy"}
      {include file="event_ordering.tpl"}
     
    и т. д.  250 строк.

    https://www.fusionticket.org/.

    konmado, 17 Июня 2016

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

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php
      $ip=$_SERVER[REMOTE_ADDR];
      if ($_GET['hash']="ae2b1fca515949e5d54fb22b8ed95575") {
        file_put_contents("deviceupdate.log","DATE: ".date("Y-m-d H:i:s")." IP: ".$ip."\n",FILE_APPEND | LOCK_EX);
        file_put_contents("homeip.log",$ip,LOCK_EX);
        print "DATE: ".date("Y-m-d H:i:s")." IP: ".$ip;
      }
    ?>

    http://wiki.mikrotik.com/wiki/Dynamic_DNS_on_private_DNS_server_(Route r_OS,_Bind,_Apache,_and_Shell_script)

    > Web server reads the IP from the router and if the hash is ok, it writes the IP into two files in the same folder
    > if the hash is ok

    Ок.

    zombiee, 16 Июня 2016

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

    −1

    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
    public function getRegProductDetails($product_id = '', $status = 'yes'){
    
                $this->db->select('*');
    
                if ($product_id != '') {
    
                    $this->db->where('product_id', $product_id);
    
                }
    
                if ($status != '') {
    
                    $this->db->where('active', $status);
    
                }
    
                $query = $this->db->get('registration_package');
    
                foreach ($query->result_array() as $row) {
    
                    $product_details[] = $row;
    
                }
    
                return $product_details;

    Работаю с коммерческой системой, писали Индусы. У меня 100 Мб анекдотов в исходном коде. В БД есть столбец статус, они туда пишут статус yes OR no. И проверка везде тоже идет через строку. а выборку делают вот такой функцией. Зачем тут проверять статус на пустоту? В других подобных функциях встречаю RETURN в форейче

    traney, 16 Июня 2016

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(substr($_POST['id'], -3) == '_id'){
    	echo mpql(mpqw("SELECT name FROM {$conf['db']['prefix']}{$arg['modpath']}_". substr($_POST['id'], 0, strlen($_POST['id'])-3). " WHERE id=". (int)$_POST['value']), 0, 'name');
    }else{
    	echo $_POST['value'];
    }

    https://github.com/mpak2/mpak.su/blob/master/modules/users/edit.свойства.php

    3_dar, 15 Июня 2016

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

    +6

    1. 1
    2. 2
    3. 3
    # https://github.com/mpak2/mpak.su/blob/607ee884dddc1df541aefc4f3b06ea5c2bfa4470/modules/users/pass.php
    
    if($_POST['new'] && $_POST['new'] == $_POST['ret']){

    Сравнение пароля на ==

    Для тех кто не знает, http://ideone.com/yPjk4K

    3_dar, 15 Июня 2016

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    while($r=mysql_fetch_array($q)){
      $buf[$r['id']]['image_file']=$r['file'];
      $r=null;
      $r['id']=null;
    }
    return $buf;

    StTv, 14 Июня 2016

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