- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
/**
* Test to see if the cache storage is available.
*
* @static
* @access public
* @return boolean True on success, false otherwise.
*/
function test()
{
return true;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
/**
* Test to see if the cache storage is available.
*
* @static
* @access public
* @return boolean True on success, false otherwise.
*/
function test()
{
return true;
}
Описание метода в коментах.
Joomfish
+158
elseif( $action == "pingationmod" ) {
echoheader( "options", "pingationMod" );
echo <<<HTML
<form action="{$PHP_SELF}" method="post">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Отправка уведомлений в пинг сервисы</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td style="padding:2px;" height="100" align="center">
HTML;
echo "Вы действительно хотите отправить уведомления в пинг сервисы, на (<b>" . count( $selected_news ). "</b>) $lang[mass_confirm_1]<br><br>
<input class=bbcodes type=submit value=\" $lang[mass_yes] \"> <input type=button class=bbcodes value=\" $lang[mass_no] \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list'\">
<input type=hidden name=action value=\"do_mass_ping\">
<input type=hidden name=user_hash value=\"{$dle_login_hash}\">
<input type=hidden name=mod value=\"massactions\">";
foreach ( $selected_news as $newsid ) {
$newsid = intval($newsid);
echo "<input type=hidden name=selected_news[] value=\"$newsid\">";
}
echo <<<HTML
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div></form>
HTML;
echofooter();
exit();
}elseif( $action == "do_mass_ping" ) {
include ENGINE_DIR .'/inc/include/pingfunction.php';
include ENGINE_DIR .'/data/pingdata.php';
foreach ( $selected_news as $newsid ) {
$newsid = intval($newsid);
$sql_select = "SELECT id, title, date, category, alt_name, flag FROM ".PREFIX ."_post WHERE id=".$newsid;
$sql_result = $db->query( $sql_select );
while ( $row = $db->get_row( $sql_result ) ) {
$row['date'] = strtotime( $row['date'] );
$title = $row['title'];
if( $config['allow_alt_url'] == "yes") {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] .get_url( $row['category'] ) ."/".$row['id'] ."-".$row['alt_name'] .".html";
}else {
$full_link = $config['http_home_url'] .$row['id'] ."-".$row['alt_name'] .".html";
}
}else {
$full_link = $config['http_home_url'] .date( 'Y/m/d/',$row['date'] ) .$row['alt_name'] .".html";
}
}else {
$full_link = $config['http_home_url'] ."index.php?newsid=".$row['id'];
}
}
pingationMod($title, $full_link, 0, $pingdata['service'], $pingdata['zaderjka']);
}
if($pingdata['allow_log']){
saveLog("Массовая отправка уведомлений в пинг сервисы");
}
clear_cache();
msg( "info", "Уведомления успешно отправлены", "Уведомления успешно отправлены в пинг сервисы", $_SESSION['admin_referrer'] );
}
+161
header('Content-Type: text/plain; charset=windows-1251'); // текстовый формат... что бы переносы строки нормально отображались и ширина букв была одинаковая
function CheckDir($s,$step)
{
echo str_repeat('-',$step).basename($s)."\r\n";
$a = glob($s.'/*',GLOB_ONLYDIR);
foreach($a as $v)
{
CheckDir($v,$step+1);
}
}
+167
public function generateGUID ()
{
$GUID = $this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter()."-";
$GUID = $GUID.$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter()."-";
$GUID = $GUID.$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter()."-";
$GUID = $GUID.$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter()."-";
$GUID = $GUID.$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter().$this->generateCharacter();
return $GUID;
}
из класса для работы с paypal. (скачан с оффсайта)
+163
function price_filter_form()
{
// Хуярим неиибически сложную систему фильтрации по цене:
$sql = "
SELECT
Max(c_good.price) AS `max`,
Min(c_good.price) AS `min`,
Count(c_good.price) AS `count`
FROM
c_good
WHERE
c_good.podcat_id = '".mysql_real_escape_string($_GET['id'])."' AND
c_good.onoff = '1' AND c_good.`check` = '1'";
$sql = mysql_query($sql) OR DIE (log_error('sql'));
$price = mysql_fetch_assoc($sql);
#echo ("<pre>");
#print_r($price);
#echo ("</pre>");
if ($price['count'] < '10') // если товаров меньше 10, выводим 1 диапазон цен
{
$price_form = "<option value=\"".$price['min'].":".$price['max']."\">".$price['min']."-".$price['max']."руб.</option>";
}
else
{
// Далее идёт непонятный говнокод, который к удивлению работает
$step = (($price['max']-$price['min'])/11);
$step = ceil($step);
$step_len = strlen($step);
$step = round($step, -($step_len-1));
$first_step = ($price['min']+$step);
$first_step_len = strlen($first_step);
$first_step = (round($first_step, -($first_step_len-2))-1);
#if ($first_step < $price['min']) $first_step = $price['min']+$step;
$price_form = "<option value=\"".$price['min'].":".$first_step."\">".$price['min']."-".$first_step."руб.</option>";
$price_form .= "<option value=\"".($first_step+1).":".($first_step+$step)."\">".($first_step+1)."-".($first_step+$step)."руб.</option>";
#echo $step;
for ($i=1;$i<8;$i++)
{
$price_form .= "<option value=\"".($first_step+($step*$i)+1).":".($first_step+($step*($i+1)))."\">
".($first_step+($step*$i)+1)."-".($first_step+($step*($i+1)))."руб.</option>";
}
$price_form .= "<option value=\"".($first_step+($step*8)+1).":".$price['max']."\">
".($first_step+($step*8)+1)."-".$price['max']."руб.</option>";
}
$price_form = str_replace("\"".$defult_price['1']."\"", "\"".$defult_price['1']."\" selected", $price_form);
return $price_form;
}
?>
вот с таким ГК пришлось столкнуться, после профилирования. Как Вам? Или - это нормально для PHP???
P.S. комментарии сохранены авторские.
+161
elseif(isset($_GET['del']))
{
foreach($_POST as $id=>$a)
{
mysql_query("DELETE FROM `{$prefixbd}$table` WHERE `id`='".intval($id)."'")or die(mysql_error());
@chmod(ret_img($file_path.$id),0777);
@unlink(ret_img($file_path.$id));
@chmod(ret_img($file_path.$id.'_big'),0777);
@unlink(ret_img($file_path.$id.'_big'));
$sql=mysql_query("SELECT FROM `{$prefixbd}{$table}_img` WHERE `prod`='".intval($id)."'")or die(mysql_error());
while($data=mysql_fetch_assoc($sql)){
@chmod(ret_img($file_path.$id.'_'.$data['id'].'_add'),0777);
@unlink(ret_img($file_path.$id.'_'.$data['id'].'_add'));
@chmod(ret_img($file_path.$id.'_big_'.$data['id'].'_add'),0777);
@unlink(ret_img($file_path.$id.'_big_'.$data['id'].'_add'));
mysql_query("DELETE FROM `{$prefixbd}{$table}_img` WHERE `id`='".$data['id']."'");
}
}
Обратите внимание как удаляет файлы)) исходник из некого chrono CMS
+161
...
$tlang->description = "Русский";
$tlang->filename = "russian.php";
$tlang->template_path = 'newtpl'; // Какой идиот придумал хранить настройки шаблонов в языках???
...
Кусок из шоп скрипт... ивправду какого хрена так делать - загадка...
+156
$properties_array = array_keys($this->values);
array_unshift($properties_array, $properties_array[0]);
unset($properties_array[0]);
$properties_values_array = array_values($properties_array);
$values_array = array_values($this->values);
$properties = implode('` ,`', $properties_values_array);
$values = implode(', ', array_fill(0, count($this->values), '?'));
$result = self::$orm->db->prepare('INSERT INTO `' . $this->table . '` (`' . $properties . '`) values (' . $values . ')');
foreach ($values_array as $key => $value) {
$fieldinfo = $this->fields[$properties_values_array[$key]];
$result->bindParam($key + 1, $values_array[$key], $this->correctDataType($fieldinfo['native_type'], $fieldinfo['pdo_type']), $fieldinfo['len']);
}
$result->execute();
Чувствую код плохо пахнет, надо разбирать)) Высоко нагруженный проект ;)
+164
function AuthorizeUser()
{
global $USER;
if ( ( $USER->IsAuthorized() && $USER->GetID() == $this->GetUserID()) || $USER->IsAdmin())
{
return true;
}
else if ($this->AuthorizeByIP())
{
return true;
}
else if (1==2)
{
return true;
}
return false;
}
А вдруг?
+163
<?php
set_time_limit(0);
$d = 0;
$t = 0;
$link = mysql_connect('localhost', 'root', '123456'); // or die(mysql_error());
//mysql_query('SET NAMES `cp1251`') or die(mysql_error());
$dbr = mysql_query('SHOW DATABASES') or die(mysql_error());
while ($dbd = mysql_fetch_assoc($dbr)) {
if ($dbd['Database'] != 'information_schema') {
mysql_select_db($dbd['Database'], $link); // or die(mysql_error());
$tr = mysql_query('SHOW TABLES'); // or die(mysql_error());
$sql = '';
while ($td = mysql_fetch_assoc($tr)) {
$sql .= '`' . $td['Tables_in_' . $dbd['Database']] . '`, ';
++$t;
}
$sql = substr($sql, 0, -2);
mysql_query('REPAIR TABLE ' . $sql . ''); // or die(mysql_error());
++$d;
}
}
echo 'Востановил: ' . $d . ' баз(ы) данных, общие кол-во таблиц: ' . $t;
mysql_close($link);
Делает "REPAIR" всех баз данных.