- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
$a="Я";$b="учу";$c="php";
echo "$a $b $c";
if ($avt == 'Да') { echo 'Да'; }
if ($avt == 'Нет') { echo 'Нет'; }
if($avt == TRUE) {
echo "оляля"
}
else{
echo "не оляля"
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151
$a="Я";$b="учу";$c="php";
echo "$a $b $c";
if ($avt == 'Да') { echo 'Да'; }
if ($avt == 'Нет') { echo 'Нет'; }
if($avt == TRUE) {
echo "оляля"
}
else{
echo "не оляля"
}
http://skripters.biz/forum/topic_42181
//Вот они откуда беруться
+146
<p class="info">
<span>Дата начала: <b><?=$custom_fields['Дата начала'][0];?></b></span>
<span>Продолжительность: <b><?=$custom_fields['Продолжительность'][0];?></b></span>
<span>Стоимость: <b><?=$custom_fields['Стоимость'][0];?></b></span>
</p>
Сумрачный германский тургайский гений.
+159
public function Container($container) {
$this->remote_container = $container;
if (!$this->ContainerExists($this->remote_container)) trigger_error("Контейнер <b>{$this->remote_container}</b> не существует!",E_USER_ERROR);
$this->container = $this->connection->get_container($container);
}
Контейнер, контейнер, контейнер...
+162
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// Если к нам идёт Ajax запрос, то ловим его
echo 'Это ajax запрос!';
exit;
}
//Если это не ajax запрос
echo 'Это не ajax запрос!';
http://ruseller.com/lessons.php?rub=37&id=1028
+149
//Функция обработки ошибок PHP
set_error_handler('error_php');
function error_php($errno, $errstr, $errfile, $errline)
{
if (!error_reporting())
{
return;
}
switch ($errno)
{
case E_WARNING:
case E_USER_WARNING:
$errfile = str_replace(getcwd(), '', $errfile);
require(ROOT_DIR.'/messages/errors/error_php.php');
exit;
break;
}
}
class mysql_db {
private $db;
function __construct() { //Метод вызываемый автоматически для присоединения к MySQL и выбора БД.
$this->db=mysql_pconnect(MySQL_Host, MySQL_User, MySQL_Pass) or mysql_err('Не удалось соединиться с MySql.','Проверьте настройки параметров - MySql_Host, MySql_User, MySql_Pass в файле config.php');
@mysql_select_db(MySQL_DB,$this->db) or $this->mysql_err('Не удалось выбрать БД.','#'.mysql_errno().': '.mysql_error());
@mysql_query('SET NAMES '.$this->str_sql(MySQL_Character), $this->db) or mysql_err('Не удается установить кодировку.','#'.mysql_errno().': '.mysql_error());
}
private function str_sql ($sql) {
return mysql_real_escape_string($sql);
}
private function mysql_err($txt,$error) {
require(ROOT_DIR.'/messages/errors/error_db.php');
exit;
}
public function query($sql) {
$result=mysql_query($sql) or $this->mysql_err('Не удается выполнить запрос к БД.','#'.mysql_errno().': '.mysql_error().'<br />--------------------------<br />SQL: '.$sql);
return $result;
}
public function count_rows($table,$where='') { //Метод подсчета количества строк в таблице.
if($where!='') { $where=' WHERE '.$where; }
$result=$this->query('SELECT COUNT(1) FROM `'.$table.'`'.$where);
return mysql_result($result,0);
}
public function inc($table,$data,$where='',$inc=1) {
if($where!='') { $where=' WHERE '.$where; }
$inc=(int)$inc;
$query='`'.$data.'`=`'.$data.'`+'.$inc;
$query='UPDATE `'.$table.'` SET '.$query.' '.$where;
$this->query($query);
return mysql_affected_rows();
}
public function dec($table,$data,$where='',$dec=1) {
if($where!='') { $where=' WHERE '.$where; }
$dec=(int)$dec;
$query='`'.$data.'`=`'.$data.'`-'.$dec;
$query='UPDATE `'.$table.'` SET '.$query.' '.$where;
$this->query($query);
return mysql_affected_rows();
}
public function insert_id() { //ID добавленной записи.
$int=mysql_result($this->query('SELECT LAST_INSERT_ID()'),0);
return $int;
}
public function select($table,$data='*',$where='') { //Метод запроса данных в таблице.
if($where!='') { $where=' WHERE '.$where; }
$query='SELECT '.$data.' FROM `'.$table.'` '.$where;
$result=$this->query($query);
return $result;
}
public function insert($tabl,$data) {
foreach ($data as $key=>$val) {
$k[]='`'.$key.'`';
$v[]='\''.$this->str_sql($val).'\'';
}
$k=implode(",",$k);
$v=implode(",",$v);
$query='INSERT INTO `'.$tabl.'` ('.$k.') VALUE ('.$v.')';
$this->query($query);
return mysql_affected_rows();
}
public function update($table,$data,$where='') { //Метод обновления данных в таблице.
if($where!='') { $where=' WHERE '.$where; }
foreach ($data as $key=>$val) {
$query[]='`'.$key.'`=\''.$this->str_sql($val).'\'';
}
$query=implode(',',$query);
$query='UPDATE `'.$table.'` SET '.$query.' '.$where;
$this->query($query);
Класс для работы с MySQl
+146
//Функция обработки ошибок PHP
set_error_handler('error_php');
function error_php($errno, $errstr, $errfile, $errline)
{
if (!error_reporting())
{
return;
}
switch ($errno)
{
case E_WARNING:
case E_USER_WARNING:
$errfile = str_replace(getcwd(), '', $errfile);
require(ROOT_DIR.'/messages/errors/error_php.php');
exit;
break;
}
}
class mysql_db {
private $db;
function __construct() { //Метод вызываемый автоматически для присоединения к MySQL и выбора БД.
$this->db=mysql_pconnect(MySQL_Host, MySQL_User, MySQL_Pass) or mysql_err('Не удалось соединиться с MySql.','Проверьте настройки параметров - MySql_Host, MySql_User, MySql_Pass в файле config.php');
@mysql_select_db(MySQL_DB,$this->db) or $this->mysql_err('Не удалось выбрать БД.','#'.mysql_errno().': '.mysql_error());
@mysql_query('SET NAMES '.$this->str_sql(MySQL_Character), $this->db) or mysql_err('Не удается установить кодировку.','#'.mysql_errno().': '.mysql_error());
}
private function str_sql ($sql) {
return mysql_real_escape_string($sql);
}
private function mysql_err($txt,$error) {
require(ROOT_DIR.'/messages/errors/error_db.php');
exit;
}
public function query($sql) {
$result=mysql_query($sql) or $this->mysql_err('Не удается выполнить запрос к БД.','#'.mysql_errno().': '.mysql_error().'<br />--------------------------<br />SQL: '.$sql);
return $result;
}
public function count_rows($table,$where='') { //Метод подсчета количества строк в таблице.
if($where!='') { $where=' WHERE '.$where; }
$result=$this->query('SELECT COUNT(1) FROM `'.$table.'`'.$where);
return mysql_result($result,0);
}
public function inc($table,$data,$where='',$inc=1) {
if($where!='') { $where=' WHERE '.$where; }
$inc=(int)$inc;
$query='`'.$data.'`=`'.$data.'`+'.$inc;
$query='UPDATE `'.$table.'` SET '.$query.' '.$where;
$this->query($query);
return mysql_affected_rows();
}
public function dec($table,$data,$where='',$dec=1) {
if($where!='') { $where=' WHERE '.$where; }
$dec=(int)$dec;
$query='`'.$data.'`=`'.$data.'`-'.$dec;
$query='UPDATE `'.$table.'` SET '.$query.' '.$where;
$this->query($query);
return mysql_affected_rows();
}
public function insert_id() { //ID добавленной записи.
$int=mysql_result($this->query('SELECT LAST_INSERT_ID()'),0);
return $int;
}
public function select($table,$data='*',$where='') { //Метод запроса данных в таблице.
if($where!='') { $where=' WHERE '.$where; }
$query='SELECT '.$data.' FROM `'.$table.'` '.$where;
$result=$this->query($query);
return $result;
}
public function insert($tabl,$data) {
foreach ($data as $key=>$val) {
$k[]='`'.$key.'`';
$v[]='\''.$this->str_sql($val).'\'';
}
$k=implode(",",$k);
$v=implode(",",$v);
$query='INSERT INTO `'.$tabl.'` ('.$k.') VALUE ('.$v.')';
$this->query($query);
return mysql_affected_rows();
}
public function update($table,$data,$where='') { //Метод обновления данных в таблице.
if($where!='') { $where=' WHERE '.$where; }
foreach ($data as $key=>$val) {
$query[]='`'.$key.'`=\''.$this->str_sql($val).'\'';
}
$query=implode(',',$query);
$query='UPDATE `'.$table.'` SET '.$query.' '.$where;
$this->query($query);
Класс для работы с MySQl
+160
$rcn = 0;
foreach ($cites as $cite)
{
$rcn++;
}
if ($rcn == 0)
{
// we banned or network error!
}
Проверка не пустоты массива. Пpосто лень читать мануал(& Google too)! Главное что работает!
+164
/////////////Название ссылок (меню и тд) ////////////////
$file=str_replace('{text_about}',$sph_messages["text_about"],$file); // О нас
$file=str_replace('{text_main}',$sph_messages["text_main"],$file); //
$file=str_replace('{text_news}',$sph_messages["text_news"],$file);
$file=str_replace('{text_web}',$sph_messages["text_web"],$file);
$file=str_replace('{text_pog_gorod}',$sph_messages["text_pog_gorod"],$file);
$file=str_replace('{text_catigor}',$sph_messages["text_catigor"],$file);
$file=str_replace('{text_logo}',$sph_messages["text_logo"],$file);
$file=str_replace('{text_searc}',$sph_messages["text_searc"],$file);
$file=str_replace('{text_img}',$sph_messages["text_img"],$file);
$file=str_replace('{text_add}',$sph_messages["text_add"],$file);
$file=str_replace('{text_help}',$sph_messages["text_help"],$file);
$file=str_replace('{text_search_all}',$sph_messages["text_search_all"],$file);
$file=str_replace('{text_feedback}',$sph_messages["text_feedback"],$file);
$file=str_replace('{text_send}',$sph_messages["text_send"],$file);
$file=str_replace('{text_start}',$sph_messages["text_start"],$file);
$file=str_replace('{text_reg_mail}',$sph_messages["text_reg_mail"],$file);
$file=str_replace('{text_kurs}',$sph_messages["text_kurs"],$file);
$file=str_replace('{text_mail}',$sph_messages["text_mail"],$file);
$file=str_replace('{text_pass}',$sph_messages["text_pass"],$file);
$file=str_replace('{text_lang}',$sph_messages["text_lang"],$file);
$file=str_replace('{text_zapomnit}',$sph_messages["text_zapomnit"],$file);
$file=str_replace('{text_vhod}',$sph_messages["text_vhod"],$file);
$file=str_replace('{text_pogoda}',$sph_messages["text_pogoda"],$file);
$file=str_replace('{text_friend}',$sph_messages["text_friend"],$file);
$file=str_replace('{text_music}',$sph_messages["text_music"],$file);
$file=str_replace('{text_foto}',$sph_messages["text_foto"],$file);
$file=str_replace('{text_video}',$sph_messages["text_video"],$file);
$file=str_replace('{text_search_ras}',$sph_messages["text_search_ras"],$file);
$file=str_replace('{text_add_code}',$sph_messages["text_add_code"],$file);
$file=str_replace('{text_add_des}',$sph_messages["text_add_des"],$file);
$file=str_replace('{text_add_url}',$sph_messages["text_add_url"],$file);
$file=str_replace('{text_add_name}',$sph_messages["text_add_name"],$file);
$file=str_replace('{text_add_ost}',$sph_messages["text_add_ost"],$file);
$file=str_replace('{text_add_znak}',$sph_messages["text_add_znak"],$file);
//////////КАТЕГОРИИ////////
$file=str_replace('{cat}',$sph_messages["cat"],$file);
$file=str_replace('{cat_all}',$sph_messages["cat_all"],$file);
$file=str_replace('{cat_avto}',$sph_messages["cat_avto"],$file);
$file=str_replace('{cat_web}',$sph_messages["cat_web"],$file);
$file=str_replace('{cat_znakom}',$sph_messages["cat_znakom"],$file);
$file=str_replace('{cat_games}',$sph_messages["cat_games"],$file);
$file=str_replace('{cat_komp}',$sph_messages["cat_komp"],$file);
$file=str_replace('{cat_story}',$sph_messages["cat_story"],$file);
$file=str_replace('{cat_soft}',$sph_messages["cat_soft"],$file);
$file=str_replace('{cat_music}',$sph_messages["cat_music"],$file);
$file=str_replace('{cat_sport}',$sph_messages["cat_sport"],$file);
$file=str_replace('{cat_dom}',$sph_messages["cat_dom"],$file);
$file=str_replace('{cat_business}',$sph_messages["cat_business"],$file);
$file=str_replace('{cat_zarabotok}',$sph_messages["cat_zarabotok"],$file);
и так еще over9000 cтрок
мои глаза...
+158
if( !( $users['align'] > 1 AND $users['align'] < 3 ) ) die();
+154
foreach($files as $k => $obj){
foreach($obj as $key => $val){
$temp[$val['file_sort']]=$key;
}
ksort($temp);
foreach($temp as $key => $val){
$temp2[$val]=$obj[$val];
}
$files[$k]=$temp2;
}
не осилил usort(), удаляет ключи... =((