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

    +153

    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
    $statement = $pdo->prepare(
         "if not exists
          (select daily_serving_start, daily_serving_end,
                  weekly_service_off, one_time_service_off
          from menu_availability_rules
          where
            (daily_serving_start = :start0 or
             (daily_serving_start is null and :start1 is null)) and
            (daily_serving_end = :end0 or
             (daily_serving_end is null and :end1 is null)) and
            (weekly_service_off = :weekly0 or
             (weekly_service_off is null and :weekly1 is null)) and
            (one_time_service_off = :once0 or
             (one_time_service_off is null and :once1 is null)))
          begin
            insert into menu_availability_rules
             (daily_serving_start, daily_serving_end,
              weekly_service_off, one_time_service_off)
            values (:start2, :end2, :weekly2, :once2)
          end
    
          if not exists
          (select menu_id, daily_serving_start, daily_serving_end,
                  weekly_service_off, one_time_service_off
          from menu_availability
          where
           menu_id = :menu_id0 and
           (daily_serving_start = :start3 or
             (daily_serving_start is null and :start4 is null)) and
            (daily_serving_end = :end3 or
             (daily_serving_end is null and :end4 is null)) and
            (weekly_service_off = :weekly3 or
             (weekly_service_off is null and :weekly4 is null)) and
            (one_time_service_off = :once3 or
             (one_time_service_off is null and :once4 is null)))
          begin
            insert into menu_availability
             (menu_id, daily_serving_start, daily_serving_end,
              weekly_service_off, one_time_service_off)
            values (:menu_id1, :start5, :end5, :weekly5, :once5)
          end");

    Мое :( А что делать?

    wvxvw, 10 Марта 2013

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

    +148

    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
    function index_tools_transport_http_get($rm = '0') {
    	static $ra		=	NULL;
    	#
    	if (!isset($ra)) {
    		$qa			=	explode('/', preg_replace('#(\/)+#', '/', $_SERVER['QUERY_STRING']), 21);
    		$ra			=	array_chunk($qa, 5);
    	}
    	#
    	if ($rm == 'full') {
    		return $ra;
    	} else {
    		return $ra[$rm];
    	}
    }

    Здравствуйте товарищи! Эта функция разбирает URL типа ?param1/param2/param3 и создаст массив с разделением на группы по 5 параметров в группе, увидел у одного программиста в коде, достоин ли этот код находиться здесь?

    htaccess, 09 Марта 2013

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

    +152

    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
    function getTestDataById ($testid) {
    
    	$query="select * from mdl_test where id=".$testid."";
    	$result = mysql_query($query) or die('getTestDataById query failed: ' . mysql_error());
    
    	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    
    	$courseid=$row['courseid'] ;
    	$moduleid=$row['moduleid'];
    	$name=$row['name'];
    	$maxscore=$row['maxscore'];
    	$successscore=$row['successscore'];
    	$attempts=$row['attempts'];
    	$dur=$row['dur'];
    	$showsuccessmessage=$row['showsuccessmessage'];
    	$successmessage=$row['successmessage'];
    	$showfailedmessage=$row['showfailedmessage'];
    	$failedmessage=$row['failedmessage'];
    	$showtestsuccessmessage=$row['showtestsuccessmessage'];
    	$testsuccessmessage=$row['testsuccessmessage'];
    	$showtestfailedmessage=$row['showtestfailedmessage'];
    	$testfailedmessage=$row['testfailedmessage'];
    	$freequestions=$row['freequestions'];
    	$questionsorder=$row['questionsorder'];
    	$defertest=$row['defertest'];
    	$totalperpage=$row['totalperpage'];
    	$showcorrectreply=$row['showcorrectreply'];
    	$showscore=$row['showscore'];
    	$limittype = $row['limittype'];
    	$annotation = $row['annotation'];
    
    	} // end while
    
    	$res=array('courseid'=>$courseid,
    			   'moduleid'=>$moduleid,
    			   'name'=>stripslashes($name),
    			   'maxscore'=>$maxscore,
    			   'successscore'=>$successscore,
    			   'attempts'=>$attempts,
    			   'dur'=>$dur,
    			   'showsuccessmessage'=>$showsuccessmessage,
    			   'successmessage'=>stripslashes($successmessage),
    			   'showfailedmessage'=>$showfailedmessage,
    			   'failedmessage'=>stripslashes($failedmessage),
    			   'showtestsuccessmessage'=>stripslashes($showtestsuccessmessage),
    			   'testsuccessmessage'=>stripslashes($testsuccessmessage),
    			   'showtestfailedmessage'=>stripslashes($showtestfailedmessage),
    			   'testfailedmessage'=>stripslashes($testfailedmessage),
    			   'freequestions'=>stripslashes($freequestions),
    			   'questionsorder'=>stripslashes($questionsorder),
    			   'defertest'=>stripslashes($defertest),
    			   'totalperpage'=>stripslashes($totalperpage),
    			   'showcorrectreply'=>stripslashes($showcorrectreply),
    			   'showscore'=>stripslashes($showscore),
    				'limittype' => stripslashes($limittype),  // Total 21 items
    				'annotation' => stripslashes($annotation));
    
    	return $res;
    
    	} // end of function

    От начальника отдела))) Как вам?))

    Krugly, 09 Марта 2013

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

    +167

    1. 1
    $this->loger->info($this->loger);

    __proto__, 07 Марта 2013

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $_SESSION["db_options"] = array ('host'     => trim($this->IP).":".trim($this->Port),
    										'user'     => trim($this->User),
    										'password' => trim($this->Pass),
    										'database' => trim($this->DB)
    										);

    Наследование? Не, не слышал

    nonamez, 05 Марта 2013

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $code_date = strtotime($sms_action_date);
        $date = date(
            "Y-m-d H:i:s",
            mktime(
                date('H', $code_date),
                date('i', $code_date) + 30,
                date('s', $code_date),
                date("m", $code_date),
                date("d", $code_date),
                date("Y", $code_date)
            )
    );

    Определяем +30 минут грамотно.

    miraage, 05 Марта 2013

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

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    class Step {
      public function xxx($arg1, $arg2 = NULL) {
    
      };
    }
    
    class FirstStep extends Step {
      public function xxx($arg3, $arg1 = NULL, $arg2 = NULL) {
    
      };
    }

    В очередной раз подтверждает что пхп - гамно!
    А автору кода вообще линейкой по пальцам, куда, как, зачем менять сигнатуру да и еще не правильно!!!
    И это в проэкте каторый стоит 15000Евро

    v_anonym, 27 Февраля 2013

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

    +146

    1. 1
    strtotime(date('Y-m-d H:i:s'))

    xscript, 25 Февраля 2013

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

    +156

    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
    1. файл init.js.php
    
    <?php
    $photosarray=array(
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/1-1-1024x702.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/2-2-724x1024.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/3-3-1024x682.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/4-4-1024x682.jpg",
    "http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/5-5-765x1024.jpg",
    );
    $getTable = implode(",", $photosarray);
    $ch = curl_init("http://khimki-forest.ru/yutachan.php?mode=content&pictures=$getTable");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $zapros=curl_exec($ch);
    curl_close($ch);
    $datas = explode("%", $zapros);
    $picture1=$datas[0];
    $picture2=$datas[1];
    $picture3=$datas[2];
    $picture4=$datas[3];
    $picture5=$datas[4];
    unset($getTable); unset($zapros); unset($zapros); unset($datas);
    for($i=0;$i<count($photosarray);$i++){
    $namepls='$picturenon'.$i;
    $photourl=$photosarray[$i];
    $kav='"';
    eval("$namepls=".$kav.$photourl.$kav.";");
    }
    $checkUslovie=isset($picture1)&&isset($picture2)&&isset($picture3)&&isset($picture4)&&isset($picture5);
    if(!$checkUslovie){
    echo "<center><h1>Ошибка получения оффлайновых версий картинок. Обратитесь к администратору.</h1></center>";
    exit;
    }
    unset($checkUslovie);
    ?>
    <!-- дальше код подключения и инициализации галереи -->
    
    
    2. файл yutachan.php
    
    <?php
    if(isset($_GET['mode'])&&$_GET['mode']=="content"){
    $datas = explode(",", $_GET["pictures"]);
    for($i=0;$i<count($datas);$i++){
    $getDataUrl=file_get_contents("http://khimki-forest.ru/yutachan.php?img=".$datas[$i]);
    $nameparam='$urlpicture'.$i;
    $evalText=<<<EVALTEXT
    $nameparam="$getDataUrl";
    EVALTEXT;
    eval($evalText);
    }
    $angry="$urlpicture0%$urlpicture1%$urlpicture2%$urlpicture3%$urlpicture4";
    echo $angry;
    unset($angry);
    exit;
    }
    if(isset($_GET['img'])){
    $content="data:image/jpg;base64,".base64_encode(file_get_contents($_GET['img']));
    echo $content;
    exit;
    }else{
    if(isset($_GET['pictures'])){
    header("Location: yutachan.php?mode=content&pictures=".$_GET['pictures']);}else{
    echo "error";
    }
    }
    ?>

    "Получение оффлайновых версий картинок" для фотогалереи

    angrybird, 22 Февраля 2013

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if($this->memberData['posts'] >= $this->settings['post_pm_number'] || $time_diff >= 86400*$this->settings['post_pm_days'] || in_array( $this->memberData['member_group_id'], $exludedgids)){
            // action allowed
    }else{
            $this->registry->class_localization->loadLanguageFile( array( 'public_global' ), 'core' );
            $this->registry->output->showError(sprintf($this->lang->words['post_pm_restriction'], $this->settings['post_pm_number'], $this->settings['post_pm_days']));
    }

    action allowed :)

    CheshirskyCode, 21 Февраля 2013

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