- 1
facepalm.sql
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−851
facepalm.sql
В таблице платежей несколько полей с цифрами - _amount и _value.
В связаной таблице есть поле PaymentAmount.
Угадайте, какому полю платежа оно соответствует 7:
+174
<?php
function htmlspecialchars($a) {
return htmlspecialchars($a);
return preg_replace('/</','<',htmlspecialchars($a));
echo htmlspecialchars($a);
}
echo htmlspecialchars('<a href="http://">линка</a>'); // мы пришли к тому,
что заменили <a href="http://">линка</a>,
то есть оно выведет прям ссылку,
а мы сделали так,
чтобы оно вывело <a href="http://">линка</a>,
то есть выведит само <a href="http://">линка</a>,
без всяких ссылок, прям как текст.
Внести в функцию изменения,
можно,
но осторожно.
ТОЛЬКО ДЛЯ ЗНОЮЩИХ ПИХХИПИ.
?>
мозготрах
+147
//для краткости порезано
//первый файл
//объявление контрола, который в себе рисует квадратные thumbnailы
class ThumbnailViewer : .... {
...
//внимание!
private:
struct Impl;
Impl *m_impl;
}
//второй файл
//объявление мифической структуры Impl
struct ThumbnailView::Impl
{
...
//а вот это и есть то, что должно рисоваться на экране для каждого thumbnail
class Item : public QGraphicsPixmapItem {
...
}
...
}
что хотел иметь ввиду афтор?
+159
#include <iostream>
class Schotchik { public:
Schotchik();
Schotchik(int znach);
~Schotchik(){}
int vzyat_znachenie()const { return znachenye; }
void vstavit_znachenie(int x) {znachenye = x; }
operator unsigned int();
private: int znachenye; };
Schotchik::Schotchik(): znachenye(0) {}
Schotchik::Schotchik(int novoe_znachenie): znachenye(novoe_znachenie) {}
Schotchik::operator unsigned int () { return ( int (znachenye) ); }
void* main() {
Schotchik ctr(5);
int znachenye = ctr;
std::cout << "znachenye: " << znachenye << std::endl;
return 5 ; }
+151
/*
* Условия для шаблонов и не только ;)
* $content - то что проверям
* $data - то что выводим
*/
function if_set($content, $data) {
return empty($content) ? '' : stripslashes($data);
}
Комментарий больше кода, и автор ещё Вам подмигивает.
+163
function utf_decode($str) {
/*static $table = array("\xD0\x81" => "\xA8", "\xD1\x91" => "\xB8",);
return preg_replace('#([\xD0-\xD1])([\x80-\xBF])#se', 'isset($table["$0"]) ? $table["$0"] : chr(ord("$2")+("$1" == "\xD0" ? 0x30 : 0x70))', $str);*/
return $str;
}
Зря закоментил такая панацея была что вы, что вы...
+168
/*
* Выводим чекбоксы :D
* $name - имя инпута чеки
* $val - тру ор фалсе
*/
function checkbox($name, $val)
{
$checked = !empty($val) ? 'checked ' : false;
return "<input type=\"checkbox\" name=\"" . $name . "\" " . $checked . "/>";
}
Тру от фалсе
+161
/*
* Получаем категории из массива ЭКСПЕРЕМЕНТАЛЬНАЯ ФУНКЦИЯ :D
* $fp - файл
* $content - то что запишем
*/
function save_conf($fp, $content)
{
$file_name = basename($fp);
if(!file_exists($fp))
{
file_put_contents($fp,'');
@chmod(ROOT . $fp, 0666 );
}
if (file_exists($fp) && $content)
{
$fp = fopen($fp, "wb");
$content = "<?php
if (!defined('ACCESS'))
{
header('Location: /');
exit;
}
\n\n".$content."\n";
fwrite($fp, $content);
fclose($fp);
}
}
И как же он тут получит категории остаётся загадкой, и поржать он любит в комментариях смотрю)
* BY Toogle CMS
+163
Файл 1 :
<?php
for ($i=0; $i<10; $i++) // Моё примечение - вонять начинает отсюда
{
include "delstr.php";
include "razdel2.php";
include "gendat.php";
include "dopismain.php";
}
Файл delstr.php:
<?php
$num_stroka = 7; //Удалим 7 строку из файла
$file = file("gendat.php"); // Считываем весь файл в массив
for($i = 0; $i < sizeof($file); $i++)
if($i == $num_stroka) unset($file[$i]);
$fp = fopen("gendat.php", "w");
fputs($fp, implode("", $file));
fclose($fp);
?>
Файл razdel2.php:
<?php
$sl = file('ancorrzd.txt');
$sm = $sl[array_rand($sl, 1)];
$datam = $sm;
$file = fopen ("rzd.txt","w");
$str = "$datam";
fputs ( $file, $str);
fclose ($file);
$dataC = trim(file_get_contents ("rzd.txt"));
$data="\$dataCata='$dataC';";
$file = 'gendat.php';
$array=file( $file );
$array[7]= $data; //строка в которой нужно изменить значение $data
file_put_contents( $file, $array );
?>
Файл gendat.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
ini_set('session.auto_start', '1');
//ini_set('upload_tmp_dir', 'c:\tmp');
set_time_limit(120);
@session_start();
$dataCata='xfgjcfyi';
$txtFile = 'result.txt'; // файл с текстом
$ancorFile = 'ancor.txt'; // файл с заголовками
$tplFile = 'template.txt'; // файл шаблона .dat файлов
$mainTplFile= 'maintemplate.txt'; // Шаблон файла со ссылками
$datDir = "articles/$dataCata"; // директория для .dat файлов
$datExt = 'dat'; // расширение .dat файлов
$mainFile = 'main.dat'; // Файл со ссылками на .dat файлы
$srcCharset = 'cp1251'; // Кодировка исходных файлов
$destCharset = 'cp1251'; // Кодировка файлов на выходе
$scriptCharset = 'utf-8'; // Кодировка скрипта
$blockLength = 4000; // Максимальный размер блока в байтах из файла с текстом
$file = fopen ("engine/menu.php","a");
$str = "<li><a href=\"/$dataCata/\">$dataCata</a></li>";
if ( !$file )
{
echo("Ошибка открытия файла");
}
else
{
fputs ( $file, $str);
}
fclose ($file);
if ($srcCharset == 'utf-8') $blockLength *= 2;
$blockLength = $blockLength % 2 > 0 ? $blockLength+1 : $blockLength;
if ( !is_dir($datDir) ) mkdir($datDir, 0777, true);
$hMain = NULL;
if ( !(@$hMain = fopen($mainFile, 'w+')) ) die("Невозможно создать файл $mainFile<br/>\b");
$hText = fopen($txtFile, 'r');
$ancors = explode("\n", $srcCharset == $scriptCharset ? file_get_contents($ancorFile) : iconv($srcCharset, $scriptCharset, file_get_contents($ancorFile)));
$template = $srcCharset == $scriptCharset ? file_get_contents($tplFile, 'r') : iconv( $srcCharset, $scriptCharset, file_get_contents($tplFile, 'r') ); // читаем шаблон
$content = '';
while ($content = fread($hText, $blockLength)) {
$fname = genName();
if (@$hDat = fopen("$datDir/$fname.$datExt", 'w')) {
$ancor = trim($ancors[rand(0, count($ancors)-1)]);
$content = $srcCharset == $scriptCharset ? trim($content) : iconv($srcCharset, $scriptCharset, trim($content));
// Генерим dat файлы по шаблону
$thisTpl = preg_replace("/(<!--.*?Kan_title.*?-->).*?(<!--.*?Kan_title.*?-->)/uism", "$1\n$ancor\n$2", $template);
$thisTpl = preg_replace("/(<!--.*?Kan_content.*?-->).*?(<!--.*?Kan_content.*?-->)/uism", "$1\n$content\n$2", $thisTpl);
$thisTpl = $scriptCharset == $destCharset ? $thisTpl : iconv( $scriptCharset, $destCharset, $thisTpl );
if (fwrite($hDat, $thisTpl)) {
echo "Файл $dataCata/$fname.$datExt записан<br/>\n";
$html = "
<loc><a href=\"/$dataCata/$fname.html\">$ancor</a></loc>\n";
fwrite($hMain, iconv($scriptCharset, $destCharset, $html));
} else { echo "Ошибка записи в файл $dataCata/$fname.$datExt<br/>\n"; }
} else {
echo "Не могу записать в файл $dataCata/$fname.$datExt<br/>\n";
}
}
// Генерация уникального имени
function genName() {
return substr(md5(uniqid(rand(), true)), 0, rand(7, 13));
}
?>
Человек интересуется, почему цикл выполняется только 1 раз. Ему посоветовали разместить лучше свой код тут, но по-моему, делать это самостоятельно у него желания нет, решил помочь. Пруфлинк - http://forum.searchengines.ru/showthread.php?t=643176
+169
if(!$this->first_name && !$this->last_name && !$this->countryID && !$this->zoneID && !$this->zip && !$this->state && !$this->city && !$this->address_street && !trim(strip_tags($strAddress))){
return '';
}
if(!$this->first_name && !$this->last_name && !$this->countryID && !$this->zoneID && !$this->zip && !$this->state && !$this->city && !$this->address_street && !$this->address_home && !trim(strip_tags($strAddress))){
return '';
}
if(!$this->first_name && !$this->last_name && !$this->countryID && !$this->zoneID && !$this->zip && !$this->state && !$this->city && !$this->address_street && !$this->address_home && !$this->address_houses && !trim(strip_tags($strAddress))){
return '';
}
if(!$this->first_name && !$this->last_name && !$this->countryID && !$this->zoneID && !$this->zip && !$this->state && !$this->city && !$this->address_street && !$this->address_home && !$this->address_houses && !$this->address_houseroom && !trim(strip_tags($strAddress))){
return '';
}
Найдено в одной CMS