- 1
alert.tag = (int)([[request URL] retain]);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−118
alert.tag = (int)([[request URL] retain]);
без комментариев
+150
// Блок кэширования
// Директива CASH_STATUS определяет количество секунд хранения кэша
// 0 - кэширование отключено,
$_CONFIG["CASH_STATUS"]=0;
Из конфигурационного файла самописной CMS системы
+151
<?
if (!file_exists("count.txt")) {
$fp = fopen("count.txt","w");
fwrite($fp,0);
fclose($fp);
}
$fp = fopen("count.txt","r");
$count = fread($fp,10);
fclose($fp);
$visitor = $_COOKIE['visitor'];
if (!isset($visitor)) {
setcookie("visitor", "yes");
$count++;
$fp = fopen("count.txt","w");
fwrite($fp,$count);
fclose($fp);
}
$string = strlen($count);
for ($search=0;$search<$string;$search++) {
$digit = substr($count,$search,1);
$count_graphic .= "<img src=\"img/$digit.gif\">";
}
?>
+127
<input type="checkbox" value="Зеленый" id="color_id_008000" name="color_variant"/>
<label style="white-space: nowrap;" for="color_id_008000">Зеленый</label>
и причем в коде больше эти id не где не используются, но самое страшное то что на одной странице такого маразма 2200 строк.
+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);
}
Контейнер, контейнер, контейнер...
+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
+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(), удаляет ключи... =((
+149
.......
<title><?php
$title = '';
if (isset($GLOBALS['row_item'])){
if (isset($GLOBALS['row_item']['shop_items_catalog_seo_title']) && $GLOBALS['row_item']['shop_items_catalog_seo_title'] != '')
$title = $GLOBALS['row_item']['shop_items_catalog_seo_title'];
else if (isset($GLOBALS['row_item']['shop_items_catalog_name']) && $GLOBALS['row_item']['shop_items_catalog_name'] != '')
$title = $GLOBALS['row_item']['shop_items_catalog_name'];
else if (isset($GLOBALS['row_item']['information_items_seo_title']) && $GLOBALS['row_item']['information_items_seo_title'] != '')
$title = $GLOBALS['row_item']['information_items_seo_title'];
else if (isset($GLOBALS['row_item']['information_items_name']) && $GLOBALS['row_item']['information_items_name'] != '')
$title = $GLOBALS['row_item']['information_items_name'];
}
if ($title == '' && isset($GLOBALS['row_group'])){
if (isset($GLOBALS['row_group']['shop_groups_seo_title']) && $GLOBALS['row_group']['shop_groups_seo_title'] != '')
$title = $GLOBALS['row_group']['shop_groups_seo_title'];
else if (isset($GLOBALS['row_group']['shop_groups_name']) && $GLOBALS['row_group']['shop_groups_name'] != '')
$title = $GLOBALS['row_group']['shop_groups_name'];
}
if ($title == '') $title = $GLOBALS['structure']['structure_menu_name'];
echo $title;
?></title>
<meta name='yandex-verification' content='67f83a51d573cbe2' />
<meta name="verify-v1" content="9K3tCfbm1l144UKH3+ep25FUgP8cgoAyfn7KrUE8bds=" >
<meta name="msvalidate.01" content="AC482BDBAADDEF50AC995A8963801724" />
<?php
if ((CURRENT_STRUCTURE_ID != 42) || !preg_match('/page-(\d+)\/?$/',$_SERVER['REDIRECT_URL'],$match) || $match[1] == '1'){
echo '<meta name="description" content="';
$kernel->show_description();
echo "\">\n";
echo '<meta name="keywords" content="';
$kernel->show_keywords();
echo "\">\n";
;
}
?>
......
<?php
if (class_exists('shop'))
{
$shop = & singleton('shop');
$shop_id = 1;
// $shop->ShowShop($shop_id, 'МагазинГруппыТоваровНаГлавной1');// - на память
// добудем корневые группы товаров
$rs_main = $shop->GetGroups($shop_id, 0);
//прикинем сколько должно быть категорий в колонке для равномерного распределения по 3-м колонкам
$count_in_col_tbl = ceil(mysql_num_rows($rs_main)/3);
//пробьем урл магаза
$structure = & singleton ('Structure');
$shop_url = '/'.$structure->GetStructurePath(42);
$i = 0;
while($row = mysql_fetch_assoc($rs_main)){
//добудем список категорий конкретной категории
$rs = $shop->GetGroups($shop_id, $row['shop_groups_id']);
//пробьем урл категории
$path = $shop_url.$row['shop_groups_path'].'/';
if (mysql_num_rows($rs)){
// список каждой категории
echo '<h1><a href="#" class="false">'.$row['shop_groups_name'].'</a></h1><ul>';
//соберем ссылки на подкатегории дочних корневой категории
while($row = mysql_fetch_assoc($rs))
echo '<li><a href="'.$path.$row['shop_groups_path'].'/">'.$row['shop_groups_name'].'</a></li>';
echo '</ul>';
}else{
echo '<h1><a href="'.$path.'">'.$row['shop_groups_name'].'</a></h1>';
}
$i++;
if ($count_in_col_tbl == $i){//а не начать ли новую колонку?
$i = 0;
echo '</td><td width="33%" valign="top">';
}
}
}
?>
......
Человек писал для HostCMS.... Можно судить о профессионализме человека...
+127
Lab1
s x(2,2)=1
s x(2,2,9)=0
s y(3,6,7)=3
s y(3,6,8)=4
s y(3,6,7,8,4)=5
s y(3,6,7,8,9)=6
m x(2,2)=y(3,6,7,8)
d Out("x(2,2)")
Out(l)
i $d(l)#10{
i l
w l_" =",?15,@l,!
i $d(@l)\10{
f {
s c=$q(@l,1)
q:c=""
d Out(c)
k @c
}
}
q
}
Вот так в Cache Object Script можно вывести ветку многомерного массива....
+131
struct tm lpstTimeRecordRet;
struct tm lpstTimeRecord;
lpstTimeRecordRet = *localtime_r ( &potiUnixTime, &lpstTimeRecord);
*фейс палм*