- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
if (USE_MAIN) {
$templ = 'main';
....
} elseif (!USE_MAIN) {
$used = USE_MAIN ? 1 : 0;
$templ = 'default';
....
}
......
if ( !$used ) $templ = 'default';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+164.9
if (USE_MAIN) {
$templ = 'main';
....
} elseif (!USE_MAIN) {
$used = USE_MAIN ? 1 : 0;
$templ = 'default';
....
}
......
if ( !$used ) $templ = 'default';
Вычищая один проект помимо всего прочего встретил такое чудо
+148.3
// Prevent any possible XSS attacks via $_GET.
foreach ($_GET as $check_url) {
if (!is_array($check_url)) {
$check_url = str_replace("\"", "", $check_url);
if ((eregi("<[^>]*script*\"?[^>]*>", $check_url)) || (eregi("<[^>]*object*\"?[^>]*>", $check_url)) ||
(eregi("<[^>]*iframe*\"?[^>]*>", $check_url)) || (eregi("<[^>]*applet*\"?[^>]*>", $check_url)) ||
(eregi("<[^>]*meta*\"?[^>]*>", $check_url)) || (eregi("<[^>]*style*\"?[^>]*>", $check_url)) ||
(eregi("<[^>]*form*\"?[^>]*>", $check_url)) || (eregi("\([^>]*\"?[^)]*\)", $check_url)) ||
(eregi("\"", $check_url))) {
die ();
}
}
}
PHP-Fusion Content Management System (C)
// напалмом по воробьям...
+148
[root@v6704 ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@v6704 ~]# cd /var/www/vhosts/i-tech.me/subdomains/store/httpdocs/
[root@v6704 httpdocs]# ls
access dblist i2 installer license.txt settings.xml showmucontent.php update.xml
ajaxhandler.php domxml-php4-to-php5.php includes install.js login setupguide.htm sitemap.php www.tar.gz
backup dumper.php index.php install.log published shop system
data help install.css kernel readme.txt showdblist.php temp
[root@v6704 httpdocs]# rm -Rf *.*
[root@v6704 httpdocs]# ls
access backup data dblist help i2 includes installer kernel login published shop system temp
[root@v6704 httpdocs]# rm -Rf *
[root@v6704 httpdocs]# ls
[root@v6704 httpdocs]#
[root@v6704 ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@v6704 ~]# cd /var/www/vhosts/i-tech.me/subdomains/store/httpdocs/
−856.5
select sum(all_.allscores) as allscores, sum(all_.matched) as matched, all_.id, all_.title, cc.name, cc.id as cmpId
from
(select SE.assid as id, SE.allcurrent as allscores, SE.matched, SE.title-- SE.name -- ,SE.title,SE.cmpId
FROM
(select allb.assid, sum(allb.allcurrent) as allcurrent, sum(allb.match_cnt) as matched, allb.title -- ,cc.name,cc.id as cmpId, -- , aa.id
from
(select * from
(SELECT assa.title, IFNULL(allcur.allcurrent,0) as allcurrent, assa.id as assid , IFNULL(SUM( res.weight),0) AS match_cnt
FROM
ass_assignment assa LEFT JOIN
(SELECT DISTINCT pss.cv_i
....
ёбаные лесенки...
+140.8
class vector_ptd //pointed vector - вектор заданный 2 точками, т.е. привязанный к опр.месту в пространстве
{
...
/*vector operator =(point& _p)
{
vector _v;
_v.vx=_p.x;
_v.vy=_p.y;
_v.vz=_p.z;
return _v;
}*/
...
};
vector vectorp(point& _p)
{
vector _v;
_v.vx=_p.x;
_v.vy=_p.y;
_v.vz=_p.z;
return _v;
}
Класс, реализующий вектор в трёхмерном пространстве (для трассировщика лучей). Автор не осилил оператор присваивания и тихо закомментил его, сделав вместо него функцию преобразования.
+145
<?php
require_once('global.php');
$id = $_GET['id'];
if( !$lore_system->db->id_exists( $id, 'lore_articles') )
{
$lore_system->te->assign('error_message', 'invalid_article');
$lore_system->te->display('error_message.tpl');
exit;
}
if( !$lore_db_interface->article_is_published( $id ) )
{
$lore_system->te->assign('error_message', 'article_not_published');
$lore_system->te->display('error_message.tpl');
exit;
}
$action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : 'article';
switch( $action )
{
case 'print':
$article = $lore_db_interface->get_article_info( $id );
$article['comments'] = $lore_db_interface->get_article_comments( $id );
$lore_system->te->assign('category_path', $lore_db_interface->get_category_path( $article['category_id'] ));
$lore_system->te->assign('article', $article);
$lore_system->te->display('article_print.tpl');
break;
case 'article':
if( !@in_array( $id, $lore_user_session->session_vars['viewed_articles'] ) )
{
$lore_db_interface->increment_article_views( $id );
$lore_user_session->session_vars['viewed_articles'][] = $id;
}
$article = $lore_db_interface->get_article_info( $id );
$article['comments'] = $lore_db_interface->get_article_comments( $id );
$article['num_comments'] = count($article['comments']);
$article['attachments'] = $lore_db_interface->get_article_attachments( $id );
$article['allow_comments'] = $lore_db_interface->can_comment_on_article( $id );
$article['related_articles'] = $lore_db_interface->get_related_articles( $id );
if( $lore_user_session->has_article_write_permission( $id ) )
{
$article['display_edit_link'] = true;
}
if( $lore_system->settings['enable_glossary_popups'] )
{
$glossary_terms = $lore_db_interface->get_glossary_terms();
if( count($glossary_terms) )
{
$term_html = array();
$html_tags = array();
$term_c = 0;
// strip out HTML tags first
@preg_match_all("/<[^>]+>/", $article['content'], $matches);
for( $i = 1; $i < count($matches[0]); $i++ )
{
// save html tag for later
$html_tags[$i] = $matches[0][$i];
// parse in placeholder
$article['content'] = str_replace( $matches[0][$i], "{{h$i}}", $article['content']);
}
foreach( $glossary_terms AS $term )
{
// Add "i" (NOT case sensitive) modifier to regular expression if necessary
$case = ( $term['case_sensitive'] ) ? '' : 'i';
$term['definition'] = ereg_replace("[\n\r]", '', $term['definition']);
$lore_system->te->assign('term', htmlspecialchars(str_replace("'", "\\'", $term['term'])) );
+133.7
public class ImageRotator {
public static BufferedImage rotate(BufferedImage originalImage, int angle) {
BufferedImage image = null;
switch (angle) {
case 90:
case -270:
image = ImageRotator.rotate90Right(originalImage);
break;
case 270:
case -90:
image = ImageRotator.rotate90Left(originalImage);
break;
case 180:
case -180:
image = ImageRotator.rotate180(originalImage);
break;
default:
image = originalImage;
break;
}
return image;
}
private static BufferedImage rotate90Left(BufferedImage bi) {
int width = bi.getWidth();
int height = bi.getHeight();
BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
biFlip.setRGB(height - 1 - j, width - 1 - i, bi.getRGB(i, j));
}
}
return biFlip;
}
private static BufferedImage rotate90Right(BufferedImage bi) {
int width = bi.getWidth();
int height = bi.getHeight();
BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
biFlip.setRGB(j, i, bi.getRGB(i, j));
}
}
return biFlip;
}
private static BufferedImage rotate180(BufferedImage bi) {
int width = bi.getWidth();
int height = bi.getHeight();
BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
biFlip.setRGB(i, j, bi.getRGB(width - 1 - i, height - 1 - j));
}
}
return biFlip;
}
}
Есть в Java для работы с изображениями такой класс как AphineTransform, но в после 3 часов активного взаимодействия с ним добился только того что изображение после болшого кол-ва поворотов привращалось в точку. Поэтому из себя была выдавлена эта заглушка...
+140.1
<?php
//Данные на базу
$lnk = mysql_connect('localhost', 'mysql_user', 'mysql_password')
or die ('Not connected : ' . mysql_error());
mysql_select_db('primecms_db', $lnk) or die ('Can\'t primecms_db foo : ' . mysql_error());
class insert{
var $pid, $alias, $text, $position, $status, $create_time, $modify_time;
}
function con_in($alias, $text_en, $text_ru, $text_descr){
$res = new insert;
$res->pid=1;
$res->alias=addslashes($alias);
$res->text='<p>'.addslashes($text_en).'</p>\r\n<p>'.addslashes($text_ru).'</p>\r\n<p>'.addslashes($text_descr).'</p>';
$res->position=0;
$res->status=1;
$res->create_time=time();
$res->modify_time=time();
return $res;
}
if ($_POST['send']){
$con = con_in($_POST['alias'],$_POST['text_en'],$_POST['text_ru'],$_POST['text_descr']);
mysql_query("INSERT INTO e118_glossary_items (`id`, `pid`, `alias`, `text`, `position`, `status`, `create_time`, `modify_time`) VALUES (".$con->pid.",'".$con->alias."','".$con->text."',".$con->position.",".$con->status.",".$con->create_time.",".$con->modify_time.")");
}
?>
<form name="" action="" method="post">
Alias<input name="alias" size=30 type="text" value=""><br />
text_en<input name="text_en" size=30 type="text" value=""><br />
text_ru<input name="text_ru" size=30 type="text" value=""><br />
text decr<textarea name="text_descr" rows=7 cols=50 wrap="off"></textarea><br />
<input type="submit" value="Send" name="send"><br />
</form>
не забываем править
//Данные на базу
+154
script language="Javascript" type="text/javascript">
function GetActivePoll()
{
var tmp =1;
if (tmp == 1)
{
...
}
}
С одного известного сайта...
+154.7
function ruslat ($string) # Задаём функцию перекодировки кириллицы в транслит.
{
$string = ereg_replace("ж","zh",$string);
$string = ereg_replace("ё","yo",$string);
$string = ereg_replace("й","i",$string);
$string = ereg_replace("ю","yu",$string);
$string = ereg_replace("ь","'",$string);
$string = ereg_replace("ч","ch",$string);
$string = ereg_replace("щ","sh",$string);
$string = ereg_replace("ц","c",$string);
$string = ereg_replace("у","u",$string);
$string = ereg_replace("к","k",$string);
$string = ereg_replace("е","e",$string);
$string = ereg_replace("н","n",$string);
$string = ereg_replace("г","g",$string);
$string = ereg_replace("ш","sh",$string);
$string = ereg_replace("з","z",$string);
$string = ereg_replace("х","h",$string);
$string = ereg_replace("ъ","''",$string);
$string = ereg_replace("ф","f",$string);
$string = ereg_replace("ы","y",$string);
$string = ereg_replace("в","v",$string);
$string = ereg_replace("а","a",$string);
$string = ereg_replace("п","p",$string);
$string = ereg_replace("р","r",$string);
$string = ereg_replace("о","o",$string);
$string = ereg_replace("л","l",$string);
$string = ereg_replace("д","d",$string);
$string = ereg_replace("э","yе",$string);
$string = ereg_replace("я","jа",$string);
$string = ereg_replace("с","s",$string);
$string = ereg_replace("м","m",$string);
$string = ereg_replace("и","i",$string);
$string = ereg_replace("т","t",$string);
$string = ereg_replace("б","b",$string);
$string = ereg_replace("Ё","yo",$string);
$string = ereg_replace("Й","I",$string);
$string = ereg_replace("Ю","YU",$string);
$string = ereg_replace("Ч","CH",$string);
$string = ereg_replace("Ь","'",$string);
$string = ereg_replace("Щ","SH'",$string);
$string = ereg_replace("Ц","C",$string);
$string = ereg_replace("У","U",$string);
$string = ereg_replace("К","K",$string);
$string = ereg_replace("Е","E",$string);
$string = ereg_replace("Н","N",$string);
$string = ereg_replace("Г","G",$string);
$string = ereg_replace("Ш","SH",$string);
$string = ereg_replace("З","Z",$string);
$string = ereg_replace("Х","H",$string);
$string = ereg_replace("Ъ","''",$string);
$string = ereg_replace("Ф","F",$string);
$string = ereg_replace("Ы","Y",$string);
$string = ereg_replace("В","V",$string);
$string = ereg_replace("А","A",$string);
$string = ereg_replace("П","P",$string);
$string = ereg_replace("Р","R",$string);
$string = ereg_replace("О","O",$string);
$string = ereg_replace("Л","L",$string);
$string = ereg_replace("Д","D",$string);
$string = ereg_replace("Ж","Zh",$string);
$string = ereg_replace("Э","Ye",$string);
$string = ereg_replace("Я","Ja",$string);
$string = ereg_replace("С","S",$string);
$string = ereg_replace("М","M",$string);
$string = ereg_replace("И","I",$string);
$string = ereg_replace("Т","T",$string);
$string = ereg_replace("Б","B",$string);
return $string;
}
Privat Dle Graber 8, я под столом, strtr нынче не в моде, хотя весь скрипт один сплошной говнокод.