- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
public virtual Type GetFields() {
//Must be overridden!!!
return null;
}
public virtual Enum[] GetCompareFields() {
//Must be overridden!!!
return null;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+151
public virtual Type GetFields() {
//Must be overridden!!!
return null;
}
public virtual Enum[] GetCompareFields() {
//Must be overridden!!!
return null;
}
Про абстракиные методы нам ещё не рассказывали :-D
+123
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct pl
{
int speed;
double time;
}player;
int cni;//countries number
static double disti;//distance of road
class stack
{
public:
stack(int i)
{
ael=new int[i];
sp=0;
};
int pop(void);
void push(int el);
int sp;
private:
int *ael;
};
class country : public stack
{
public:
country();
void setinfo();
char name[25];
int pn;
int sp;
player *cpl;
player *bpl;
void getname(char *name);
player* findbestplayer();
void sortplayers();
~country();
};
country::country():stack(cni)
{
};
void country::setinfo()
{
static char nm[255];
printf("Enter country name\n");
gets(nm);
strcpy(name,nm);
printf("Country name: %s\n",name);
static char pnc[25];
printf("Enter number of players: ");
gets(pnc);
pn=atoi(pnc);
cpl=new player[pn];
for(int i2=0;i2<pn;i2++)
{
int spd;
static char spdc[10];
printf("Enter speed of player %d:",i2+1);
gets(spdc);
spd=atoi(spdc);
cpl[i2].speed=spd;
cpl[i2].time=disti/spd;
printf("Player time %f\n",cpl[i2].time);
};
return;
};
country::~country()
{
delete []cpl;
delete []bpl;
};
player* country::findbestplayer()
{
int bpl2=0;
for(int i3=1;i3<pn;i3++)
{
if(cpl[i3].time<cpl[bpl2].time){
bpl2=i3;
};
*bpl=cpl[bpl2];
return &cpl[bpl2];
};
};
int getspeed(struct pl pll);
void sort(country *cnt);
int main(int argc,char *argv[])
{
static char cn[10];
static char dist[10];
printf("Enter distance\n");
+131.3
function key_check($key) {
if ($key == '') { return ''; }
$key = preg_replace("/[^\w\xB2-\xB4\xBF-\xFF\xA5\xA8\xAA\xAF\xB8\xBA\s]/", "", $key );
if ($key =='_SERVER' OR $key =='_SESSION' OR $key =='_FILES' OR $key =='_REQUEST' OR $key =='GLOBALS') die("<h3>Error variable ".basename(__FILE__)." ".__LINE__."</h3>");
else return $key;
}
function str_check($str_val) {
if ($str_val == '') { return ''; }
if(preg_match("/<[^>]*script*\"?[^>]*>/i", $str_val)
or preg_match("/<[^>]*object*\"?[^>]*>/i", $str_val)
or preg_match("/<[^>]*applet*\"?[^>]*>/i", $str_val)
or preg_match("/<[^>]*form*\"?[^>]*>/i" , $str_val)
or preg_match("/&#\d+;{0,1}/i" , $str_val) ){
die("<h3>ERROR ".basename(__FILE__)." ".__LINE__."</h3>");
}
$str_val = str_replace( "&" , '&' , $str_val );
$str_val = str_replace( "<!--" , '<!--' , $str_val );
$str_val = str_replace( "-->" , '-->' , $str_val );
$str_val = str_replace( ">" , '>' , $str_val );
$str_val = str_replace( "<" , '<' , $str_val );
$str_val = str_replace( "\"" , '"' , $str_val );
$str_val = str_replace( "\r" , null , $str_val );
$str_val = str_notsqlatacs($str_val);
if (!get_magic_quotes_gpc()){$str_val=addslashes($str_val);}
return $str_val;
}
function str_notsqlatacs($str_val) {
$searcharray =array('/drop/i','/delete/i','/union/i','/char/i','/benchmark/i','/expression/i','/alert/i','/replace/i','/write/i','/document/i','/window/i','/script/i','/user_pass/i','/unescape/i','/eval/i','/form/i','/applet/i','/object/i','/user_login/i','/setTimeout/i','/onerror/i');
$replacearray=array('drop','delete','union','char','benchmark','Expression','Alert','Replace','Write','Document','Window','Script','User_pass','Unescape','Eval','Form','Applet','Object','User_login','/SetTimeout/i','/Onerror/i');//
$str_val=preg_replace($searcharray, $replacearray, $str_val);
return $str_val;
}
Фрагмент файла ./php/wojs.php "портального движка" WebCodePortalSystem версии 5.2. И вот так вся CMSка - два с половиной мегабайта говна.
+158.4
<?php
//...
if (!count($error)) {
if(strpos($msg,'samp.ucoz')) $msg = htmlSpecialChars('>>>>>>>>>>>{ Я ДАЛБОЁБ }<<<<<<<<<<<<<');
if(strpos(strtoupper($msg),'GAMES.SHOP777')) $msg = htmlSpecialChars('>>>>>>>>>>>{ Я ДАЛБОЁБ }<<<<<<<<<<<<<');
$DB->query("INSERT INTO `guestbook` (`user_id`,`user_name`,`msg`,`add_date`,`ip`) VALUES ('$user_id','$user_name','$msg',NOW(),'$ip')");
header("Location: guestbook.php"); exit;
}
//...
?>
Защита от спама :))
Не, ну а чё, задолбали!
+142.5
$out="<table valign=top>";
for($k = 0; $k <= 6; $k += 1){
$sql="SELECT * FROM user_news1 ORDER BY date DESC LIMIT ".$k.",1";
$query=mysql_query($sql);
$out.="<tr>";
while ($res=mysql_fetch_assoc($query)){
$out.="<td style='vertical-align:top'>
<div class=newsblock>
<div class=newsdate>".date("d.m.Y G:i",strtotime($res['date']))."</div>
<div class=newschapter><a href='/news/".$res['id'].".html'>".$res['header']."</a></div>
".($res['photo']!= '' ? " <a href='/news/".$res['id']."'><img src=/".str_replace(".", "_small.", $res['photo'])." class=imgnews border=0 align=left></a> " : "")."
<div>".$res['announce']."</div></td>";
}
$out.="</tr>";
}
$out.="</table>";
echo $out;
Вот как надо новости выводить:)
+142.4
public enum Month
{
Января = 1,
Февраля = 2,
Марта = 3,
Апреля = 4,
Мая = 5,
Июня = 6,
Июля = 7,
Августа = 8,
Сентября = 9,
Октября = 10,
Ноября = 11,
Декабря = 12
}
// Использование
m_date.Text = t.Day + " " + ((Month) t.Month) + " " + t.Year;
Одноразовый енум
+140
int seek_substring_KMP (char s[], char q[])
{
int i, j, N, M;
N = strlen(s);
M = strlen(q);
int *d =(int*)malloc(M*sizeof(int)); /* динамический массив длины М*/
/* Вычисление префикс-функции */
i=0;
j=-1;
d[0]=-1;
while(i<M-1)
{
while((j>=0) && (q[j]!=q[i]))
j = d[j];
i++;
j++;
if(q[i]==q[j])
d[i]=d[j];
else
d[i]= j;
}
/* поиск */
for(i=0,j=0;(i<N)&&(j<M); i++,j++)
while((j>=0)&&(q[j]!=s[i]))
j=d[j];
free (d); /* освобождение памяти массива d */
if (j==M)
return i-j;
else /* i==N */
return -1;
}
Алгоритм Кнута — Морриса — Пратта. Жуже сложно реализвовать(
+143
(12:30:38) * Joins: skimer ([email protected])
(12:38:37) * Joins: snaky ([email protected])
(12:39:30) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality- vS b0rm 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:39:32) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality- vS b0rm 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:42:12) * Joins: gErayke ([email protected])
(12:43:09) * Quits: snaky ([email protected]) (Quit: snaky)
(12:43:48) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:48:14) * Quits: z1Pp0- ([email protected]) (Quit: z1Pp0-)
(12:51:26) * TheDimmy /Y\ ???? ?? ???????: Tuc-Tuc*. /Y\ ?????: 12:51:40 /Y\
(12:51:45) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:53:57) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:53:58) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:54:23) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:59:41) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
(12:59:41) * Viktor-S http://radio.XF.lv:8000/listen.pls RADIO EFIR 1x1 duality vS b0rm. 150 LS NA KANU!!!!!!!!!!!!! V EFIRE Viktor-S !!!!!!!!!!!!!!!!!!!!
da
+153
#! /bin/sh
if [ ! -d $4 ]
then
echo Creating $4
mkdir "$4"
fi
export url1="\/$2/src\/\d{1,30}\.[^ ]{1,3}"
export url2="\/$2\/"/"http\:\/\/$1\/$2\/"
#echo $url1 $url2
echo Entering $4
cd "$4" && rm -f $3.html && wget http://$1/$2/res/$3.html -O $3.html && cat $3.html |pcregrep -o -e "$url1" |sed s/$url2/g|uniq >get.txt && wget -nc -i get.txt --referer="http://$1/$2" -U "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)"
rm -f get.txt
echo Done!
запуск сприпт сайт борда #_темы куда_сохранять
+143.5
hideVoting = (disabled || getVisitor().isAnonymous()) ? true : false;