- 1
- 2
- 3
a=5; l=0;
.....
l= (l>a) ? 0 : l++;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
a=5; l=0;
.....
l= (l>a) ? 0 : l++;
Писал вчера свою задумку и были там вот эти строки... Я долго не мог вкурить, почему же у меня l все время рвано 0 ...)
+156
function makeFriendlyURL($pre, $suff, $alias) {
$Alias = explode('/',$alias);
$alias = array_pop($Alias);
$dir = implode('/', $Alias);
unset($Alias);
return ($dir != '' ? "$dir/" : '') . $pre . $alias . $suff;
}
Член класса DocumentParser в CMF MODX.
+156
<?php
$obj = json_decode("http://export.yandex.ru/inflect.xml?name="."Максим"."+"."Крикун"."&format=json");
$rp = $obj->1;
echo ($rp);
?>
Друг в скайпе киданул
+156
string Delimiter(string Text, int Index, const char* Delimiter) {
int n = 0, find = 0;
for (int i = 0; i <= Index; i++) {
find = Text.find(Delimiter, n);
if (i == Index) {
return Text.substr(n, find - n);
}
n = find + 1;
}
return "";
}
+156
exec(" cd $dir; ls -al|grep '^d';",$file_all);
//die(" cd $dir; ls -al|grep '^d';");
$filelist_date = array();
for($i=0;$i<count($file_all);$i++) {
$file_all[$i] = preg_replace('/\s+/','|',$file_all[$i]);
$file_all[$i] = explode('|',$file_all[$i],9);
if(!empty($file_all[$i][8])) $file_all[$i][8] = str_replace('|',' ',$file_all[$i][8]);
//print_r($file_all[$i]); echo "\n\n";
if($file_all[$i][8] == '.' || $file_all[$i][8] == '..') continue;
$k = strtotime($file_all[$i][5]." ".$file_all[$i][6]." ".$file_all[$i][7]);
$filelist_date[$k] = $file_all[$i][8];
}
krsort($filelist_date);
$filelist = array_values($filelist_date);
этот кусок кода выполняет начитку директорий фото галерей
+156
<?php
if(!isset($legal_include)) { header("HTTP/1.0 404 Not Found"); die(); }
if(!isset($_POST['login']) OR !isset($_POST['password']) OR !isset($_POST['password_retype'])) {
text(gic('tpl/register_form.html'));
} else {
$_POST = postget();
$error = array();
if(strlen($_POST['login']) < 4 OR empty($_POST['login'])) {
array_push($error, 'len_login');
} else {
if(preg_match('/^[a-z0-9]+$/', $_POST['login'])) {
if(check_avalaibility($_POST['login']) != true) {
array_push($error, 'login_used');
}
} else {
array_push($error, 'inc_login');
}
}
if(strlen($_POST['password']) < 4 OR empty($_POST['password'])) {
array_push($error, 'len_passwd');
} else {
if($_POST['password'] != $_POST['password_retype']) {
array_push($error, 'inc_passwds');
}
}
if(count($error) > 0) {
$fields = array('inc_login' => language($_SESSION['lang'], 'inc_login'),
'len_login' => language($_SESSION['lang'], 'len_login'),
'len_passwd' => language($_SESSION['lang'], 'len_passwd'),
'login_used' => language($_SESSION['lang'], 'login_used'),
'inc_passwds' => language($_SESSION['lang'], 'inc_passwds'));
$text = language($_SESSION['lang'], 'have_errs').'<ul>';
foreach($error as $value) {
$text .= '<li>'.$fields[$value].'</li>';
}
$text .= '</ul>';
error($text, 'text');
sendback('?register');
} else {
$SQL = 'INSERT INTO `'.pr.'users` (`login`, `password`, `levels`) VALUES (\''.$_POST['login'].'\', \''.md5($_POST['password']).'\', 1)';
mysql_query($SQL);
$_SESSION['logined'] = true;
$_SESSION['levels'] = 1;
$_SESSION['name'] = $_POST['login'];
}
}
function check_avalaibility($username) {
$SQL = 'SELECT `login` FROM `'.pr.'users` WHERE `login` = \''.$username.'\'';
$result = mysql_query($SQL);
if(mysql_num_rows($result) > 0) {
return false;
} else {
return true;
}
}
?>
why so serious?
+156
case "delete":
$id=$_GET['id'];
if(!isset($id)){
// no id? GTFO
header('Location: index.php?go=manage_costumes&act=view');
exit();
}else{
// id exists
...
)))
+156
f (isset(self::$_namespaceLocks[$this->_namespace])) {
/*
@see Zend_Session_Exception
/
require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception('This session/namespace has been marked as read-only.');
}
if ($name === '') {
/*
* @see Zend_Session_Exception
/
require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception("The '$name' key must be a non-empty string");
}
if (parent::$_writable === false) {
/*
* @see Zend_Session_Exception
*/
require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);
}
+156
//Redirect Using JAVASCRIPT
function redirect_to($url){
echo '<script type="text/javascript">
window.location = "'.$url.'"
</script>';
exit("Javascript is turned off, <a href='$url'>click here to go to requested page</a>");
}
Может в кучу надо было?http://forum.antichat.ru/threadnav19997-48-10.html
+156
$WeightF=floor($Weight);
if ($WeightF<$Weight) {$WeightF=$WeightF+1;}
ненуачо, ceil же для слабаков