- 1
- 2
- 3
- 4
public function &entityFactory() {
$entityObject = new stdClass();
return $entityObject;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+161
public function &entityFactory() {
$entityObject = new stdClass();
return $entityObject;
}
+169
/*
=====================================================
Данный код защищен авторскими правами
=====================================================
Файл: index.php
-----------------------------------------------------
Версия: 1
-----------------------------------------------------
Назначение: минимальные необходимые настройки
=====================================================
*/
if(!defined('SIGELENGINE')){die();}
#[cache configuration flag]
final class _config
{
private $config = array();
function __construct()
{
$this->set();
}
private function set()
{
$this->config['db']['use_buffer'] = 0;
$this->config['db']['show_errors'] = 1;
$this->config['db']['host'] = "...";
$this->config['db']['port'] = "...";
$this->config['db']['name'] = "...";
$this->config['db']['user'] = "...";
$this->config['db']['pass'] = "...";
$this->config['mail']['mailbox'] = array("...", "...", "...");
$this->config['defaults']['mod'] = "controller";
$this->config['defaults']['skin'] = "index";
$this->config['defaults']['debug'] = 0;
#[dynamic configuration]
}
function get()
{
return $this->config;
}
}
+157
// если пользователь зашел на www.site.ru,
// удаляем его куки и перенаправляем с www.site.ru на site.ru
// (чтобы куку всегда ставить только на домене третьего уровня)
if (stristr($_SERVER["HTTP_HOST"], 'www.site.ru')) {
setcookie("cookie1", "", time() - 3600);
setcookie("cookie1", "", time() - 3600);
header("Location: http://site.ru/" . $query_string);
die();
}
Нашел в очень старых скриптах. Комменты сохранены.
Доменное имя сайта изменено, названия кук изменены, любые совпадения являются случайными.
+158
<?
$thePrice = $iblockelem[ "PROPERTIES" ][ "PRICE" ][ "VALUE" ];
$thePrice_s = '';
if(strlen(trim($thePrice))>3)
{
$priceArray = str_split($thePrice);
$priceArray = array_reverse($priceArray);
for($i = 1; $i <= count($priceArray); $i++)
{
$thePrice_s.=$priceArray[$i-1];
if(($i%3)==0)
$thePrice_s.=' ';
}
$thePrice = str_split($thePrice_s);
}
echo rtrim(ltrim(implode(array_reverse($thePrice))))
?>
<?=number_format($thePrice,0,"."," ")?>
+170
public function getAvailabelWebsites() {
return $this->_w();
}
public function getAvailavelWebsites() {
return $this->_w();
}
Модуль LightCheckout для Magento за скромные $169.00 .
К сожалению, слово "available" так и не смогли написать правильно:)
+162
if (is_dir($mainDir))
{
if ($dh = opendir($mainDir))
{
while (($file = readdir($dh)) !== false)
{
if ( ($file!='.') && ($file!='..') ) $regions.=$file.',';
}
closedir($dh);
}
}
$regions = substr($regions, 0, -1);
$arrRegions = explode(",", $regions);
сразу пихать в массив файлы не судьба! надо изврат с строками
+164
$rsAnswers = CFormAnswer::GetList( $QUESTION_ID, $by="s_id", $order="desc", $arFilter, $is_filtered );
$z = 0;
while ($arAnswer = $rsAnswers->Fetch())
{
$z = 1;
}
if ($z == 1) {
Когда там накопилось 100500 элементов сайт ВНЕЗАПНО начал лагать...
+154
<?php
$temp='Исходная строка';
$search='Поисковый запрос';
$result=str_ireplace($search, $temp);
if ($result!=$temp)return true;
else
return false;
?>
Вот так я проверял на наличие подстроки в строке! *ROFL*
+166
<?php
$count = 0;
foreach($mainResult2 as $r) $count++;
if ($count > 0) echo '...';
?>
проверка не пустой ли массив(объект?).
+164
<?php
include "dbconfig.php";
$db = mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname",$db);
$mysqlsite = mysql_query("SELECT * FROM site WHERE id='1'");
$site = mysql_fetch_array($mysqlsite);
$titlesite = $site['title'];
$titlesite = iconv("CP1251", "UTF-8", "$titlesite");
$descriptionsite = $site['description'];
$descriptionsite = iconv("CP1251", "UTF-8", "$descriptionsite");
$keywordssite = $site['keywords'];
$keywordssite = iconv("CP1251", "UTF-8", "$keywordssite");
$contsite = $site['cont'];
$contsite = iconv("CP1251", "UTF-8", "$contsite");
?>
"CMS" Хостинг провайдера ultrahost.com.ua D