- 1
#define DV_ERR_13 (DV_ERR_BASE + 15)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+125
#define DV_ERR_13 (DV_ERR_BASE + 15)
There, i fixed it!
Нашел в зловонных недрах Video for Windows. Если кому интересно, значение ни разу не 13, а 16.
+147
<?php
class Bot {
public $brouser = 'Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.14912/812; U; ru) Presto/2.4.15';
public $wait_ot = 1;
public $wait_do = 3;
public $log_url = "";
public $sir_e;
private $ch;
private $php_sesid;
private $domen = 'http://rugame.mobi/';
public function __construct($user_agent, $wait_ot, $wait_do, $log_url, $sir_e = 1) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIESESSION, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $this->brouser);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$this->ch = $ch;
if(($sir_e != 1) AND ($sir_e != 0)){
$this->sir_e = $sir_e;
}
if($user_agent != ""){
$this->brouser = $user_agent;
}
if(($wait_ot AND $wait_do) != 0){
$this->wait_ot = $wait_ot;
$this->wait_do = $wait_do;
}
if($log_url != ""){
$this->login($log_url);
}else{
die("Ошибка: в настройках не прописаны ссылка для логина \n");
}
}
private function __go($url){
if($this->php_sesid == 0){
$url = $this->domen.$url;
}
elseif(preg_match_all('#\?(.*)#ismU', $url, $matches) == 0){
$url = $this->domen.$url.'?PHPSESSID='.$this->php_sesid;
} else {
$url = $this->domen.$url.'&PHPSESSID='.$this->php_sesid;
}
sleep(rand($this->wait_ot, $this->wait_do));
curl_setopt($this->ch, CURLOPT_URL, $url);
echo '__go(\' '.$url.' \')<br />';
return curl_exec($this->ch);
}
public function login($log_url) {
do{
preg_match_all('#PHPSESSID=(.*)"#ismU', $this->__go($log_url), $matches);
}while($matches[1][0] == 0);
$this->php_sesid = $matches[1][0];
$this->__go('mgame/');
$this->__go('mx/');
}
public function find_and_execute(){
$actions = array(
///////////////////////////////////
/// Действия в разделе "рудники"///
///////////////////////////////////
'mx/?w_fd=', // Накормить шахтера
'mx/?t_md=', // Заправить технику
'mx/?s_rs=', // Добывать сырьё
'mx/?s_en=', // Взорвать породу
'mx/?s_ip=', // Разведать породу
'mx/?s_in=', // Забрать породу
);
$data = $this->__go('mx/?gt=1');
foreach($actions as $act){
$pattern = str_replace("?", "\?",'#'.$act.'(.*)&PHPSESSID#');
preg_match_all($pattern, $data, $matches);
if($matches[1] != 0){
foreach ($matches[1] as $id_rudnik){
if($act == 'mx/?s_rs='){
list($rudnik, $sir_e) = explode("_", $id_rudnik);
$this->__go($act.$rudnik."_".$this->sir_e);
}else{
$this->__go($act.$id_rudnik);
}
}
}
}
}
}
require ('/config/config.php');
$bot = new Bot($user_agent, $wait_ot, $wait_do, $log_url, $sir_e);
$bot->find_and_execute();
unset($bot);//освободим память (спец. для govnokod.ru)
exit("Я что смог сделал, пока");//пока пока
Моя первая попытка написать класс бота для он-лайн игрушки... Процедура find_and_execute() убивает самого на повал, так как в ней есть что-то запутанное после объявления массива . Но всё работает так как надо, так что я справился с задачей, и результат этому - ГОВНОКОД =D
+120
//запись в журнал расчетов
try
{
ompDataSet.OMP_History.AddOMP_HistoryRow(DateTime.Now, row["N"].ToString(), Convert.ToInt32(row["M"]), PS1I??0, PS1U??0, PS2I??0, PS2U??0, I1 / 1000, U1 / 1000, I2 / 1000, U2 / 1000, KZ, (Zone1.EditValue != null) ? Convert.ToDouble(Zone1.EditValue) : 0, (Zone2.EditValue != null) ? Convert.ToDouble(Zone2.EditValue) : 0, "", PS1_DeviceA.SelectedIndex, PS2_DeviceA.SelectedIndex, (Branch.Count > 0) ? true : false, "", "", "Время откл.: " + OffDT.DateTime.ToString("dd.MM.yyyy HH:mm") + "\n" + Lkz.ToolTip.Replace("\n", ";"));
omp_HistoryTableAdapter.Update(ompDataSet);
ompDataSet.OMP_History.AcceptChanges();
}
catch
{
XtraMessageBox.Show("Не удалось сохранить данные в журнал расчётов!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
try
{
ompDataSet.Result.Clear();
ompDataSet.Result.AddResultRow(((KeyValuePair<string, int>)NumberVL.EditValue).Key, ((KeyValuePair<string, int>)NumberVL.EditValue).Value, PS1I ?? 0, PS1U ?? 0, PS1I ?? 0, PS2U ?? 0, Convert.ToDouble(I0_A.EditValue), Convert.ToDouble(U0_A.EditValue), Convert.ToDouble(I0_B.EditValue), Convert.ToDouble(U0_B.EditValue), Convert.ToDouble(I0_A_Eval.EditValue), Convert.ToDouble(U0_A_Eval.EditValue), Convert.ToDouble(I0_B_Eval.EditValue), Convert.ToDouble(U0_B_Eval.EditValue), Convert.ToDouble(Lkz.EditValue), Convert.ToDouble(Zone1.EditValue), Convert.ToDouble(Zone2.EditValue), (PS1_DeviceA.SelectedIndex == 0) ? "ЛИФП" : "ИМФ", (PS2_DeviceA.SelectedIndex == 0) ? "ЛИФП" : "ИМФ", GetCurrentUserName(), DateTime.Now, Branch.Count, PS1.Text, PS2.Text, Convert.ToDouble(LengthVL.EditValue), UsingForEval[0], UsingForEval[1], UsingForEval[2], UsingForEval[3], OffDT.DateTime);
ompDataSet.Result.AcceptChanges();
}
catch
{}
ZOMG! Что это!?
+962
for (int i = 0; i < 4; i++)
{
if (!UseParam[i])
{
switch (i)
{
case 0:
if (AutoCalc || XtraMessageBox.Show("Неверные показания амперметра " + PS1_DeviceName_A.Text + " " + PS1.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
if (CorrectKm[i] == 0 || CorrectKm[i] == L)
I1 = (CorrectValue[i] ?? 0) * 1000;
else
I1 = GetCorrectElectricValue(CorrectKm[1] ?? 0, "I0_A", row["N"], row["M"]) * 1000;
I0_A.ErrorText = PS1_A.ErrorText = "Показание " + PS1_DeviceName_A.Text + " исключено из расчета";
}
break;
case 1:
if (AutoCalc || XtraMessageBox.Show("Неверные показания вольтметра" + PS1_DeviceName_B.Text + " " + PS1.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
if (CorrectKm[i] == 0 || CorrectKm[i] == L)
U1 = (CorrectValue[i] ?? 0) * 1000;
else
U1 = GetCorrectElectricValue(CorrectKm[0] ?? 0, "U0_A", row["N"], row["M"]) * 1000;
U0_A.ErrorText = PS1_B.ErrorText = "Показание " + PS1_DeviceName_B.Text + " исключено из расчета";
}
break;
case 2:
if (AutoCalc || XtraMessageBox.Show("Неверные показания амперметра" + PS2_DeviceName_A.Text + " " + PS2.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
if (CorrectKm[i] == 0 || CorrectKm[i] == L)
I2 = (CorrectValue[i] ?? 0) * 1000;
else
I2 = GetCorrectElectricValue(CorrectKm[3] ?? 0, "I0_B", row["N"], row["M"]) * 1000;
I0_B.ErrorText = PS2_A.ErrorText = "Показание " + PS2_DeviceName_A.Text + " исключено из расчета";
}
break;
case 3:
if (AutoCalc || XtraMessageBox.Show("Неверные показания вольтметра" + PS2_DeviceName_B.Text + " " + PS2.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
if (CorrectKm[i] == 0 || CorrectKm[i] == L)
U2 = (CorrectValue[i] ?? 0) * 1000;
else
U2 = GetCorrectElectricValue(CorrectKm[2] ?? 0, "U0_B", row["N"], row["M"]) * 1000;
U0_B.ErrorText = PS2_B.ErrorText = "Показание " + PS2_DeviceName_B.Text + " исключено из расчета";
}
break;
}
}
}
Красота
+960
private static void WriteErrLog(string FileName, string errors)
{
try
{
string name = Environment.CurrentDirectory + "\\log\\" + FileName.Replace("80020_", "");
name = name.Replace(".xml", ".txt");
if (File.Exists(name))
name = name.Replace(".txt", "_" + DateTime.Now.ToString("yyyy-MM-dd hh_mm_ss") + ".txt");
using (StreamWriter f = new StreamWriter(name, true, Encoding.GetEncoding(1251)))
{
f.Write(errors);
}
}
catch { }
}
Продолжаем...
+113
private static string GetStringParam(ref string str, string param)
{
string result = "";
if (str.Contains(param))
{
result = str.Substring(str.IndexOf(param) + 1);
str = str.Remove(str.IndexOf(param));
}
return result;
}
И еще
+113
public static string GetShortName(string name, int length)
{
StringBuilder shortname = new StringBuilder(name);
string[] str = new string[] { "ПС", "ОАО" };
for (int i = 0; i < str.Length; i++)
if (shortname.ToString().Length > str[i].Length && shortname.ToString().Substring(0, str[i].Length).ToUpper() == str[i])
shortname.Remove(0, str[i].Length);
str = new string[] { "ТЭЦ", "ГЭС", "ГРЭС" };
for (int i = 0; i < str.Length; i++)
if (shortname.ToString().IndexOf(str[i], StringComparison.CurrentCultureIgnoreCase) > 0)
shortname.Remove(1, shortname.ToString().IndexOf(str[i]) - 1);
return (shortname.Length > length) ? shortname.ToString().Substring(0, length).Trim() : shortname.ToString().Trim();
}
Опять же, из того, что досталось в наследство)
−90
L = InputBox("Введите номер вашего варианта", "Лабораторная работа №2")
Label4.Caption = L
If L > 50 Then
MsgBox "Вы не ввели свой вариант, ввод варианта обязателен для корректной работы программы", vbExclamation, "Ошибка"
L = InputBox("Введите номер вашего варианта", "Лабораторная работа №2")
Label4.Caption = L
End If
If L > 50 Then
MsgBox "Ошибка. Попробуйте запустить приложение снова и выполнить все действия", vbCritical, "Ошибка"
End
End If
Третий раз не спрашиваем...
+87
var
x,y,R:real;
l11,l12,l1,l21,l22,l2,l3,l41,l42,l4,l51,l52,l5,l6,l71,l72,l7:boolean;
begin
x:= StrToFloat(edit1.text);
y:= StrToFloat(edit2.text);
R:=StrToFloat(edit3.text);
l11:=(y<x) and (x*x+y*y<R*R) and (y>0);
l12:=(x*x+y*y<r*r) and (x<0)and (y>0);
l1:=l11 or l12;
l21:=(y>0) and (x*x+y*y<R*R)and (y>x);
l22:= ( x*x+y*y<R*R)and (y>x) and (x<0);
l2:= l21 or l22;
l3:=(y<0) and ( x*x+y*y<R*R)and (y>x);
l41:= (x>0) and ( x*x+y*y<R*R)and (y<x);
l42:= (x<-1) and ( x*x+y*y>R*R)and (y>x);
l4:= l41 or l42;
l51:= (x>1) and ( x*x+y*y>R*R)and (y<x);
l52:= (x>-1) and ( x*x+y*y>R*R)and (y<x);
l5:= l51 or l52;
l6:= (y>0) and ( x*x+y*y<R*R)and (y>x);
l71:= (x>0) and (x*x+y*y>R*R) and (y<0);
l72:= (y<0) and (x*x+y*y>R*R) and (y<x) and (x<0);
l7:= l71 or l72;
if l1= true then
begin
edit4.text:='T принадлежит 1 области';
end
else
begin
edit4.text:='T не принадлежит 1 области';
end;
if l2= true then
begin
edit4.text:='T принадлежит 2 области';
end
else
begin
edit4.text:='T не принадлежит 2 области'
end;
if l3= true then
begin
edit4.text:='T принадлежит 3 области'
end
else
begin
edit4.text:='T не принадлежит 3 области'
end;
if l4= true then
begin
edit4.text:='T принадлежит 4 области'
end
else
begin
edit4.text:='T не принадлежит 4 области'
end;
if l5= true then
begin
edit4.text:='T принадлежит 5 области'
end
else
begin
edit4.text:='T не принадлежит 5 области'
end;
if l6= true then
begin
edit4.text:='T принадлежит 6 области'
end
else
begin
edit4.text:='T не принадлежит 6 области'
end;
if l4= true then
begin
edit4.text:='T принадлежит 7 области'
end
else
begin
edit4.text:='T не принадлежит 7 области'
end;
end;
end.
...
+156
<?
include "config/bd.php";
class watermark1
{
function create_watermark( $main_img_obj, $text, $font, $r = 128, $g = 128, $b = 128, $alpha_level = 0 )
{
$width = imagesx($main_img_obj);
$height = imagesy($main_img_obj);
$angle = -rad2deg(atan2((-$height),($width)));
$text = " ".$text." ";
$c = imagecolorallocatealpha($main_img_obj, $r, $g, $b, $alpha_level);
$size = (($width+$height)/2)*2/strlen($text);
$box = imagettfbbox ( $size, $angle, $font, $text );
$x = $width/2 - abs($box[4] - $box[0])/2;
$y = $height/2 + abs($box[5] - $box[1])/2;
imagettftext($main_img_obj,$size ,$angle, $x, $y, $c, $font, $text);
return $main_img_obj;
}
}
$myrow22 = mysql_query("select * from `content` where id_content=3");
$row22 = mysql_fetch_array($myrow22);
include "includes/head1.php";
include "includes/leftm.php";
$category_id = isset($_GET['category_id']) ? (int)$_GET['category_id'] : 1;
$myrow = mysql_query("SELECT * FROM `gallery` LEFT JOIN `gallery_files` `gf` ON `gallery`.id = gallery_id WHERE category_id = " . $category_id . " ORDER BY `gf`.id");
$items = array();
$photos = array();
while($row = mysql_fetch_array($myrow)) {
$items[ $row['gallery_id']] = $row;
$photos[ $row['gallery_id']][] = $row['filename'];
}
echo '<div id=content>
<p><table width=100% >
<tr>';
$i = 0;
foreach ($items as $id => $item) {
$i++;
echo '<td>';
$photo = array_shift($photos[$id]); // только первая картинка
$photo2='./uploads/text'.$photo;
$watermark = new watermark1();
$type=mime_content_type($photo);
if (($type != 'image/jpeg')and($type != 'image/png'))
{
}
else
{
// определяем расширение переданного файла
switch ($type)
{
case 'image/jpeg':
$img = imagecreatefromjpg("./uploads/resized_$photo");
break;
case 'image/png':
$img = imagecreatefrompng("./uploads/resized_$photo");
break;
}
$im=$watermark->create_watermark($img,”jeka911.wordpress.com”,'./1.ttf',0,0,255,120);
imagejpeg($im,$photo2);
echo '<a href="infokuhni.php?id=' . $item['gallery_id'] . '" ><img src="'. $photo2 . '" /><br/><br/>';
echo '<font face="Georgia, Times New Roman, Times, serif">'; echo $item['title'] . '</font><br/>';
echo '<font face="Times New Roman, Times, serif">Цена: '; echo $item['price'] . ' рублей</font></a><br/><br>';
echo '</td>';
if (!($i % 4)) echo '</tr><tr>';
}
echo '</tr>
</table>
<p></div>';
include "includes/foot.php";
?>