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

    +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
    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
    92. 92
    93. 93
    94. 94
    95. 95
    require_once('adodb/adodb.inc.php');
    
    class adoDbConnector
    {
        private static $instance = null;
    	
        public static function getInstance()
        {
    	if (self::$instance == NULL)
    	{
    		self::$instance = new adoDbConnector();
    	}
    		
    	return self::$instance;
        }
    
        private function __construct() { }
    	
        public function __clone()
        {
            trigger_error('No __clone()!', E_USER_ERROR);
        }
    
        public function __wakeup()
        {
            trigger_error('No __wakeup()!', E_USER_ERROR);
    	}
    	
    	public function connect($connectionType, $connectionData)
    	{
    		switch($connectionType)
    		{
                        case 0: 
    			return self::generalConnect($connectionData);
    			break;
    			
                        case 1: 
    			return self::dsnConnect($connectionData);
    			break;
    				
                        case 2: 
    			return self::xmlConnect($connectionData);
    			break;
    				
                        default:
    			throw new Exception('Wrong type of connection!');
    		}
    	}
    	
    	private static function generalConnect($connectionData)
    	{	
    		if(is_array($connectionData))
    		{
    			$conn = &ADONewConnection($connectionData[0]); 
    				
    			$conn->PConnect($connectionData[1], $connectionData[2], 
                                    $connectionData[3], $connectionData[4]);
    				
    			return $conn;
    		}
    		else throw new Exception('Wrong type of connection data, must be an array!');
    	}
    	
    	private static function dsnConnect($connectionData)
    	{		
    		if(is_string($connectionData))
    		{
    			$conn = ADONewConnection($connectionData);
    				
    			return $conn;
    		}
    		else throw new Exception('Wrong type of connection data, must be a string!');
    	}
    	
    	private static function xmlConnect($connectionData)
    	{
    		if(is_string($connectionData) && file_exists($connectionData))
    		{
    			$xml = simplexml_load_file($connectionData);
    			
    			foreach($xml as $x)
    			{
    				$connArr[] = trim($x);
    			}
    			
    			$conn = &ADONewConnection($connArr[0]);
    			
    			$conn->PConnect($connArr[1], $connArr[2], $connArr[3], $connArr[4]);
    				
    			return $conn;
    		}
    		else throw new Exception('Wrong file name or connection type!');
    	}
    		
    }

    Archont12, 29 Марта 2012

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

    +28

    1. 1
    2. 2
    3. 3
    function _spb_similar_similar_video_html(&$item, $key) {
      $item = htmlspecialchars($item, ENT_NOQUOTES);
    }

    brainstorm, 29 Марта 2012

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    class Program implements ProgramProvider {
            
            public static function getInstance() {
                    return new Program();
            }
    }

    Гениальная реализация singleton!

    viktor_poltorak, 29 Марта 2012

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $sCmd='$result=$this->'.$aEvent['method'].'();';
    $this->Hook_Run("action_event_".strtolower($this->sCurrentAction)."_before",array('event'=>$this->sCurrentEvent,'params'=>$this->GetParams()));
    eval($sCmd);
    $this->Hook_Run("action_event_".strtolower($this->sCurrentAction)."_after",array('event'=>$this->sCurrentEvent,'params'=>$this->GetParams()));
    return $result;

    LiveStreet CMS... nuff said...

    nkarakin, 29 Марта 2012

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    do
      {
       $firstDate = ConvertTimeStamp($firstDateSt, "SHORT");
       $lastDate = ConvertTimeStamp($lastDateSt, "SHORT");
       
       $arPeriod = Array(
        "TITLE" => CSchool::GetDiaryPeriod($firstDate, $lastDate),
        "HREF" => $APPLICATION->GetCurPageParam('START_WEEK='.$firstDate.'&END_WEEK='.$lastDate, array("START_WEEK", "END_WEEK"))
       );

    Битрикс...
    do без while? лаконично

    nicksevenfold, 29 Марта 2012

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

    +163

    1. 1
    2. 2
    3. 3
    //fucking designers
    	if ( $page->importantshort ) $page->short = true;
    	if ( $page->importantNOTshort ) $page->short = false;	// так то!

    bot, 29 Марта 2012

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

    +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
    while(true)
    {
    	if ($i==0)
    	{
    		$new_form_name = $form_res[0]['frm_name'] . ' ( Copy )';
    	} else
    	{
    		$new_form_name = $form_res[0]['frm_name'] . ' ( Copy '.$i.' )';
    	}
    	if(!in_array($new_form_name, $formaNames))
    	{
    		break;
    	}
    	$i++;
    }

    Есть имя формы $form_res[0]['frm_name'] , напр "FORMNAME".
    нужно получить новое имя вида "FORMNAME ( Copy 1)"

    iersir, 29 Марта 2012

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

    +151

    1. 1
    $now = date(date('Y-m-d H:i:s'));

    striker, 29 Марта 2012

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

    +162

    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
    if(
           (trim($class->antihacker($_POST['fio']))=='')or
           (trim($class->antihacker($_POST['phone']))=='')or
           (trim($class->antihacker($_POST['email']))=='')or
           (trim($class->antihacker($_POST['adress']))=='')
          ){$error="Указанные поля заполнены неверно!";}
       elseif(!$class->validate_email($_POST['email'])){$error="E-mail указан не корректно!";}
       elseif($_POST['is_company']=='1'){
         if(
           (trim($class->antihacker($_POST['company']))=='')or
           (trim($class->antihacker($_POST['fio_cmp']))=='')or
           (trim($class->antihacker($_POST['email_cmp']))=='')or
           (trim($class->antihacker($_POST['kchet']))=='')or
           (trim($class->antihacker($_POST['rchet']))=='')
          ){$error="Указанные поля заполнены неверно!";}
       }

    анти хакерз...

    Sulik78, 28 Марта 2012

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

    +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
    ///////////////////////////////КОДИТ FIELD////////////////////////////////
    if($opt == 'bags') {
    echo "<h3>Ошибки в фильмах</h3>
    <a href='/admin/index.php?view=components&do=config&id=24&opt=bags&old=0'>Активные ошибки</a>
    <a href='/admin/index.php?view=components&do=config&id=24&opt=bags&old=1'>Исправленные ошибки</a>
    
    <table border=1><tr><td>Дата</td><td>Название фильма</td><td>Добавил ошибку</td><td>Тип ошибки</td><td>Описание</td><td>Статус</td><td>Исправил</td></tr>";
    $old = $_REQUEST['old'];
    if ($old==1) {$result=$inDB->query("SELECT * from cms_multimedia_bags WHERE `fixed`='1' ORDER by date DESC");}
    else         {$result=$inDB->query("SELECT * from cms_multimedia_bags WHERE `fixed`<>'1' ORDER by date DESC");}
    
    while($row=$inDB->fetch_assoc($result)) {
    if ($row['admin']=='') {$row['admin']="Неисправлена";}
    if ($row['fixed']==1) {$fix="<center><a href='/admin/index.php?view=components&do=config&id=24&opt=fix_bag&fixed=0&bag_id=$row[id]' title='Исправлена'><img src=/admin/images/actions/button_check.png></a>";$table_color="";$fix_date="($row[fix_date])";}
    if ($row['fixed']<>1) {$fix="<center><a href='/admin/index.php?view=components&do=config&id=24&opt=fix_bag&fixed=1&bag_id=$row[id]' title='Не исправлена'><img src=/admin/images/actions/stop.png></a>";$table_color="<font color=red>";$fix_date="";}
    
    if ($row['multimedia_group']==2) {$tip='add_films';}
    if ($row['multimedia_group']==3) {$tip='add_serials';}
    
    if ($row['type']==1) {$row['type']='Не скачивается';}
    if ($row['type']==2) {$row['type']='Не просматривается';}
    if ($row['type']==3) {$row['type']='Ошибка в описании фильма';}
    if ($row['type']==4) {$row['type']='Неверный постер';}
    if ($inUser->id==275) {$del="(<a href='/admin/index.php?view=components&do=config&id=24&opt=del_bag&bag_id=$row[id]'>x</a>)";}
    
    $result1=$inDB->query("SELECT * from cms_multimedia_names WHERE `id`='$row[film_id]'");
    $film_row=$inDB->fetch_assoc($result1);
    $result2=$inDB->query("SELECT * from cms_users WHERE `id`='$row[user_id]'");
    $user_row=$inDB->fetch_assoc($result2);
    echo "<tr><td>$table_color$row[date]</td><td><a href='/admin/index.php?view=components&do=config&id=24&opt=$tip&cat_group=$row[multimedia_group]&file_id=$row[file_id]'>" . $film_row['video_name_rus'] . "</a>(<a href='/multimedia/$row[multimedia_group]/$row[film_id]/$row[file_id]' target='_blank'>на сайте</a>)</td><td><a href='/users/$user_row[nickname]'>$user_row[nickname]</a>($row[ip])</td><td>$table_color" . $row['type'] . "</td><td>$table_color" . $row['description'] . "</td><td>$fix $del<td>$row[admin] $fix_date</td></tr>";
    }
    echo "</table>";
    
    }
    if($opt == 'fix_bag') {
    $bag_id = $_REQUEST['bag_id'];
    $fixed = $_REQUEST['fixed'];
    $date=date("Y-m-d H:i:s");
    
    if ($fixed==1) {$inDB->query("UPDATE cms_multimedia_bags SET `fixed`='$fixed', `fix_date`='$date', `admin`='$inUser->nickname' WHERE id=$bag_id");}
    else          {$inDB->query("UPDATE cms_multimedia_bags SET `fixed`='$fixed', `fix_date`='$date', `admin`='' WHERE id=$bag_id");}
    $inCore->redirect('/admin/index.php?view=components&do=config&id='.$_REQUEST['id'].'&opt=bags');
    }
    if($opt == 'del_bag') {
    $bag_id = $_REQUEST['bag_id'];
    $inDB->query("DELETE from cms_multimedia_bags WHERE id=$bag_id");
    $inCore->redirect('/admin/index.php?view=components&do=config&id='.$_REQUEST['id'].'&opt=bags');
    }
    
    ///////////////////////////////КОНЕЦ КОДА FIELD/////////////////////////

    =) Наш заказчик нанял, нового специалиста php, который якобы "помогает" нам дорабатывать проект=

    onzone, 28 Марта 2012

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