- 1
- 2
- 3
- 4
if (!defined(DIRECTORY_SEPARATOR)) {
$sep = (substr(strtolower(PHP_OS),0,3) == 'win') ? '\\' : '/';
define('DIRECTORY_SEPARATOR', $sep);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+145
if (!defined(DIRECTORY_SEPARATOR)) {
$sep = (substr(strtolower(PHP_OS),0,3) == 'win') ? '\\' : '/';
define('DIRECTORY_SEPARATOR', $sep);
}
Даже если и так, то может быть и MAC OS'овский разделитель учтём???
Я-то думал обычный slash - решение всех проблем, или на МАКАХ подавляющее
число хостингов что ли?
+157
// (c) Template Optimizer
// (c) Template Compiler
// skin/news.tpl
/*<?php
die ('<br /><br />Template Parser: <b>Access locked</b>');
?>*/
$value0 = '
';
if ( $this->get_tpl_tag ('USER.ACCESS') == '1' )
{
$value0 .= '
';
$this->set_tpl_tag ('ACTION', 'new_add');
$value0 .= '
';
$this->set_tpl_tag ('SUBMIT', 'Добавить');
$value0 .= '
';
$this->set_tpl_tag ('CAPTION', 'Добавить новость');
$value0 .= '
' . $this->file_include ('content.tpl') . '
';
}
$value0 .= '
';
$this->open_local (array ('NEW'));
if ( is_array ($this->get_tpl_tag ('NEWS')) )
foreach ( $this->get_tpl_tag ('NEWS') as $this->tags['NEW'] )
{
$value0 .= '
<table class="news" width="100%">
<tr>
<th>
<h2>' . $this->get_tpl_tag ('NEW.TITLE') . '</h2>
</th>
<th align="right">
<span class="gensmall">' . $this->get_tpl_tag ('NEW.TIME') . ' </span>
';
if ( $this->get_tpl_tag ('USER.ACCESS') == '1' )
{
$value0 .= '
<a href="admin.php?action=new_edit&new=' . $this->get_tpl_tag ('NEW.ID') . '"><img src="' . $this->root_dir . '/images/rename.gif" alt="Редактировать" title="Редактировать" style="vertical-align: middle; border: none;" /></a>
<a href="admin.php?action=new_delete&new=' . $this->get_tpl_tag ('NEW.ID') . '" onclick="return confirm (\'Удалить новость за ' . $this->get_tpl_tag ('NEW.TIME') . '?\');"><img src="' . $this->root_dir . '/images/delete.gif" alt="Удалить" title="Удалить" style="vertical-align: middle; border: none;" />
';
}
$value0 .= '
</th>
</tr>
<tr>
<td colspan="2">
' . $this->get_tpl_tag ('NEW.BODY') . '
</td>
</tr>
</table>
';
}
$this->close_local();
$value0 .= '
';
$this->set_tpl_tag ('_ALIGN_', 'LEFT');
$value0 .= '
' . $this->file_include ('pagebar.tpl');
Вот такой "говнокод" выдает мой шаблонизатор после компилирования шаблона.
В данном примере это блок новостей.
+111
procedure TForm1.Timer1Timer(Sender: TObject);
function UpTime(sf:string):boolean;
var time:string;
t:textfile;
begin
if form1.MaskEdit5.Text<>'' then
if Findmas_u(255,0,sf)<0 then
begin UpTime:=false;exit;end;
if not FileExists(sf) then
begin UpTime:=false;exit;end;
time:=DateUpdating_u(sf);
if time<>'' then
begin
try
assignfile(t,ExtractFilePath(form1.MaskEdit1.Text)+ChangeFileExt(ExtractFileName(sf),'.tim'));
rewrite(t);
writeln(t,time);
closefile(t);
except UpTime:=false;exit;end;
end;
UpTime:=true;
end;
var x,y,i1,i2,i3,xf,yf:integer;
sf,id,ff:string;
b:boolean;
begin
form1.Timer1.Enabled:=not form1.Timer1.Enabled;
try
form1.ProgressBar1.Position:=0;
application.ProcessMessages;
masopt_u(254,x,y);
if form1.MaskEdit1.Text='' then
form1.BitBtn3.Click else
if (DateUpdating_u(form1.MaskEdit1.Text)<>DateUpdatingMas_u(254))or(y>0) then
begin
if form1.MaskEdit3.Text<>'' then
if form1.CheckBox1.Checked then
sf:=TJ7PassAutentikR_u(form1.MaskEdit3.Text,form1.MaskEdit2.Text) else
sf:=TJ7PassAutentik_u(form1.MaskEdit3.Text,form1.MaskEdit2.Text) else
sf:=form1.MaskEdit2.Text;
if not OpenOneNu_u(form1.MaskEdit1.Text,'read:PSQL-Srv'+booltostr(form1.RadioButton2.Checked),3) then
begin
DeleteFile(ChangeFileExt(form1.MaskEdit1.Text,'.tmp'));
form1.RichEdit1.Lines.Add('('+datetostr(date)+' '+timetostr(time)+') Превышен интервал времени доступа.');
OpenOneNu_u(form1.MaskEdit1.Text,'read:PSQL-Srv'+booltostr(form1.RadioButton2.Checked),3);
end;
i1:=TJ7ReadMas_u(254,form1.MaskEdit1.Text,sf);
CloseOneNu_u(form1.MaskEdit1.Text,'read:PSQL-Srv'+booltostr(form1.RadioButton2.Checked));
if (i1<>0)and(i1<>11) then
begin
form1.RichEdit1.Lines.Add('('+datetostr(date)+' '+timetostr(time)+') Ошибка чтения команд, код: '+inttostr(i1)+'.');
closemas_u(254);
initmas_u(254,2,0);
TJ7CreateMas_u(254,form1.MaskEdit1.Text,sf,false,false,false,false,false);
closemas_u(254);
form1.Timer1.Enabled:=not form1.Timer1.Enabled;
exit;
end;
masopt_u(254,x,y);id:='';
if not form1.RadioButton1.Checked then
begin
for i1:=0 to y-1 do
if (masr_u(254,1,i1)<>'') then
if ((form1.RadioButton2.Checked)and(ord(masr_u(254,1,i1)[1])mod 2=0))or
((form1.RadioButton3.Checked)and(ord(masr_u(254,1,i1)[1])mod 2<>0))then
begin id:=masr_u(254,1,i1);break;end;
end else id:=masr_u(254,1,0);
if (id='')or(y=0) then
begin
if RTime_u(strtodatetime(DateUpdatingMas_u(254)),date+time)<1200 then
closemas_u(254);
form1.Timer1.Enabled:=not form1.Timer1.Enabled;
exit;
end;
if y>0 then form1.StaticText13.Caption:='в обработке';
application.ProcessMessages;
form1.RichEdit1.Lines.Add('('+datetostr(date)+' '+timetostr(time)+'/Старт):'+id);
if form1.CheckBox3.Checked then
begin
masopt_u(255,xf,yf);
ff:=ExtractFilePath(form1.MaskEdit1.Text)+id+'.tj7';
masw_u(255,0,yf,ff);
end;
application.ProcessMessages;
if form1.MaskEdit6.Text<>'' then
PsevdoSQL_u(form1.MaskEdit6.Text);
for i1:=0 to y-1 do
if masr_u(254,1,i1)=id then
begin
if form1.CheckBox3.Checked then
begin
i2:=pos('TId',masr_u(254,0,i1));
if i2>0 then
masw_u(254,0,i1,copy(masr_u(254,0,i1),1,i2-1)+id+copy(masr_u(254,0,i1),i2+3,255));
end;
// *** И дальше в том же духе
Автор сего поделия, кусок которого приведён выше (привёл бы полностью, но там 160 строк), называет ЭТО "сервером распределённых вычислений" и "самой прогрессивной СУБД в мире, которая лучше всех этих ваших ораклов. При этом автор вроде как и не школьник...
+145
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
int Sum (int x, int y)
{
cout << "Принято " << x << " и " << y << "\n";
return (x+y);
}
int Frac (int x, int y)
{
cout << "Принято " << x << " и " << y << "\n";
return 0;
}
int Diff (int x, int y)
{
cout << "Принято " << x << " и " << y << "\n";
return (x-y);
}
int Multiplic (int x, int y)
{
cout << "Принято " << x << " и " << y << "\n";
return (x*y);
}
void Exiting ()
{
cout << "\nДля выхода из приложения нажмите любую клавишу...";
_getch();
}
void Call ()
{
cout << "\nВведите 2 числа через пробел и нажмите Enter: ";
}
int main()
{
setlocale(LC_ALL,"RUS");
int a,b,c,k;
cout << "Данный калькулятор может выполнять операции только над целыми числами.\n(c) 2010 - Конфиденциальность. All Rights Reserved.\n";
cout << "\nВыберите, что вы хотите сделать с числами: \n1-Сложить, 2-Вычесть, 3-Умножить, 4-Разделить \n"; cin >> k;
switch (k)
{
case 1: int Sum(); break;
case 2: int Diff(); break;
case 3: int Multiplic(); break;
case 4: int Frac(); break;
default: cout << "Вариант не выбран! \n"; return 1;
}
if (k==1){
Call();
cin >> a;
cin >> b;
c=Sum(a,b);
cout << "\nРЕЗУЛЬТАТ: " << c;
cout << "\n";
Exiting ();
return 0;
}
if (k==2){
Call();
cin >> a;
cin >> b;
c=Diff(a,b);
cout << "\nРЕЗУЛЬТАТ: " << c;
cout << "\n";
Exiting ();
return 0;
}
if (k==3){
Call();
cin >> a;
cin >> b;
c=Multiplic(a,b);
cout << "\nРЕЗУЛЬТАТ: " << c;
cout << "\n";
Exiting ();
return 0;
}
if (k==4){
Call();
cin >> a;
cin >> b;
if (b==0){
cout << "\nДеление на 0 невозможно!\n";
Exiting ();
return 0;
}
Frac(a,b);
cout << "\nРЕЗУЛЬТАТ: " << (float) a/b;
cout << "\n";
Exiting ();
return 0;
}
}
я только учусь языку C++.
и это один из первых моих кодов)
это примитивный калькулятор
возможно спецы вдоволь поржут с такого кода.. :))
+164
$tr = "<tr>";
$td = "<td>";
$_tr = "</tr>";
$_td = "</td>";
$table = "<table>";
$_table = "</table>";
echo ("<table border='1'>");
while ($myrow = mysql_fetch_array ($result))
{
printf ("%s",$tr);
foreach ($myrow as $value)
{
printf ("%s%s%s",$td,$value,$_td);
};
printf ("%s",$_tr);
};
echo ("</table>");
+144
<?
class db // mysql funkciju klase
{
var $id = '';
function connect() // prisijungimas prie mysql serverio
{
$this->id = mysql_connect($this->host, $this->user, $this->pass);
if ( !$this->id || !mysql_select_db($this->db, $this->id) ) {
die ("mysql connect failed: " . mysql_error());
return false;
}
else {
return $this->id;
}
}
function query ($query, $silent = 0) // duotos uzklausos vykdymas
{
$this->result = '';
if ($this->result = mysql_query($query)) { //var_dump($query);
return $this->result;}
else
if ($silent == 0)
die("mysql query failed: " . mysql_error());
else
die("Atsiprasome, jusu uzklausos negalejome apdoroti");
}
function fetch ($result) // rezultato grazinimas pagal uzklausa. grazinamas masyvas
{
$this->row = '';
if ($this->row = mysql_fetch_array($result)) { //var_dump($this->row);
return $this->row;}
}
function fetchrow ($result) {
$this->row = '';
if ($this->row = mysql_fetch_row($result))
return $this->row;
}
function num($result) // suskaiciuoja kiek yra eiluciu rezultate
{
$this->num = '';
if ($this->num = mysql_num_rows($result))
return $this->num;
}
function last($result) {
$this->last = '';
if ($this->last = mysql_insert_id($this->id))
return $this->last;
}
function close() {
mysql_close();
return true;
}
}
?>
(предыдущие серии в http://govnokod.ru/3526, http://govnokod.ru/3525, http://govnokod.ru/3524 и http://govnokod.ru/3522)
класс, то ли аффтарописный, то ли из ынтырнета с его комментами.
кому лень обращать внимание на код:
1. обьявление полей host, user, pass я не нашел, зато нашел обращение к ним
2. функции возвращают что-то в нормальных условиях, иначе не возвращают совсем ничего
3. в 20й строке $silent = 0, но запрос умирает при любом значении
4. метод num() даже в нормальной ситуации может не вернуть ничего
5. close() успешен в любом случае
+160
<?$APPLICATION->IncludeFile(
$APPLICATION->GetTemplatePath("include_areas/contacts.php"),
Array(),
Array("MODE"=>"html")
);?> </div>
Вот так индусские проггеры из Bitrix показывают контакты сайта.
+169
function focusOut(id) {
var e = document.getElementById(id);
i = document.createElement('input');
i.type = 'radio';
i.name = e.name;
i.style.display = 'none';
document.body.appendChild(i);
i.click();
}
Снимаем выделение с радио-кнопки.
+168.4
if (count($_SESSION["cart"]["discs"])==0)
{
$poryadochek="yes";
} else {
$poryadochek="no";
}
Verbose programming.
+929.1
page_t* make_page()
{
page_t* p = new page_t;
// заполнение
return p;
delete(p);
}
я в шоке... не знаю что хотел сказать аффтар (недоступен)... не могу даже прокомментировать ЭТО %)