- 1
- 2
- 3
- 4
//проверка на одномерность массива
function mp_array_is_simple($array) {
return count($array, COUNT_NORMAL)===count($array, COUNT_RECURSIVE);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 6
−16
//проверка на одномерность массива
function mp_array_is_simple($array) {
return count($array, COUNT_NORMAL)===count($array, COUNT_RECURSIVE);
}
Портальная система Жираф. Проверка на одномерность массива.
−20
if(!$guest = ['id'=>0, "uname"=>"гость", "pass"=>"nopass", "reg_time"=>0, "last_time"=>time()]){ mpre("Ошибка создания пользователя");
}elseif(!$sess = array('id'=>0, 'uid'=>$guest['id'], "refer"=>0, 'last_time'=>time(), 'count'=>0, 'count_time'=>0, 'cnull'=>0, 'sess'=>($_COOKIE["sess"] ?: md5("{$_SERVER['REMOTE_ADDR']}:".microtime())), 'ref'=>mpquot(mpidn(urldecode($_SERVER['HTTP_REFERER']))), 'ip'=>mpquot($_SERVER['REMOTE_ADDR']), 'agent'=>mpquot($_SERVER['HTTP_USER_AGENT']), 'url'=>mpquot(urldecode($_SERVER['REQUEST_URI'])))){ pre("Ошибка создания сессии");
}
try{
if($conf['db']['type'] == "sqlite"){
$conf['db']['conn'] = new PDO("{$conf['db']['type']}:". mpopendir($conf['db']['name']));
$conf['db']['conn']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conf['db']['conn']->exec('PRAGMA foreign_keys=ON');
}else{
$conf['db']['conn'] = new PDO("{$conf['db']['type']}:host={$conf['db']['host']};dbname={$conf['db']['name']};charset=UTF8", $conf['db']['login'], $conf['db']['pass'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC));
$conf['db']['conn']->exec("set names utf8"); # Prior to PHP 5.3.6, the charset option was ignored
}// return $conf['db']['conn'];
}catch(Exception $e){
pre("Ошибка подключения к базе данных");
} if((!array_key_exists('null', $_GET) && !empty($conf['db']['error'])) || !tables()){
exit(inc('include/install.php'));
} $_REQUEST += $_GET += mpgt($_SERVER['REQUEST_URI']);
if(!$_POST && !get($_COOKIE, "sess")){// print_r("Сессия выключена");
}elseif(!$sess = call_user_func(function($sess) use($conf, $guest){
setcookie("sess", $sess['sess'], 0, "/");
if(!$_sess = ql($sql = "SELECT * FROM {$conf['db']['prefix']}sess WHERE `ip`='{$sess['ip']}' AND last_time>=".(time()-86400)." AND `agent`=\"{$sess['agent']}\" AND ". ($_COOKIE["sess"] ? "sess=\"{$sess['sess']}\"" : "uid=". $guest['id'])." ORDER BY id DESC", 0)){
qw($sql = "INSERT INTO {$conf['db']['prefix']}sess (`". implode("`, `", array_keys(array_diff_key($sess, array_flip(['id'])))). "`) VALUES ('". implode("', '", array_values(array_diff_key($sess, array_flip(['id'])))). "')");
$sess = ['id'=>($conf['db']['conn']->lastInsertId())] + $sess; return $sess;
}else{ return $_sess; }
}, $sess)){ pre("Ошибка создания сессии");
}elseif(array_key_exists('null', $_REQUEST)){ mpre("Отключено обновление сессии для ресурсов");
}else{
qw("UPDATE {$conf['db']['prefix']}sess SET count_time = count_time+".time()."-last_time, last_time=".time().", ".(isset($_GET['null']) ? 'cnull=cnull' : 'count=count')."+1, sess=\"". mpquot($sess['sess']). "\" WHERE id=". (int)$sess['id']);
}
Портальная система Жираф.
https://github.com/mpak2/mpak.su, любой файл.
−42
$('body').append('<div class="block-slidebar"></div>');
$('.block-slidebar').html($('.mobile-sidebar').html());
$('.mobile-sidebar').remove();
−1
<?php
global $userinfo;
...
$a_query = "select id,name,company,email,phone,url,type from user where login='" .
$_SESSION["se_login"] . "' and passwd='" .
$_SESSION["se_passwd"] . "' and status=1";
$a_res = mysql_query($a_query);
...
list($userinfo['id'],$userinfo['name'],$userinfo['company'],$userinfo['email'],$userinfo['phone'],$userinfo['url'],$userinfo['type']) = mysql_fetch_row($a_res);
...
−1
<?php
global $userinfo;
global $smarty;
global $cl;
$userinfo['id'] = 0;
$userinfo['name'] = '';
$userinfo['email'] = '';
$userinfo['phone'] = '';
$userinfo['url'] = '';
$userinfo['company'] = '';
$userinfo['type'] = '';
$flogin = def_var('flogin','');
$fpasswd = def_var('fpasswd','');
$fremember = def_var('fremember',0);
if ($fpasswd) {
$fpasswd = md5($fpasswd);
$_SESSION["se_login"] = $flogin;
$_SESSION["se_passwd"] = $fpasswd;
} elseif (isset($_COOKIE["co_login"]) && isset($_COOKIE["co_passwd"])) {
$_SESSION["se_login"] = $_COOKIE['co_login'];
$_SESSION["se_passwd"] = $_COOKIE['co_passwd'];
}
$auth_msg = '';
if (isset($_SESSION["se_login"]) && isset($_SESSION["se_passwd"])) {
$a_query = "select id,name,company,email,phone,url,type from user where login='" .
$_SESSION["se_login"] . "' and passwd='" .
$_SESSION["se_passwd"] . "' and status=1";
$a_res = mysql_query($a_query);
if (mysql_num_rows($a_res) > 0) {
$ip_res = mysql_query("select ip from ipban where ip='".$_SERVER['REMOTE_ADDR']."'");
if (!mysql_num_rows($ip_res)) {
if ($fremember == 1) {
setcookie("co_login",$_SESSION["se_login"],time()+60*60*24*10000,"/", $_SERVER['SERVER_NAME']);
setcookie("co_passwd",$_SESSION["se_passwd"],time()+60*60*24*10000,"/", $_SERVER['SERVER_NAME']);
}
list($userinfo['id'],$userinfo['name'],$userinfo['company'],$userinfo['email'],$userinfo['phone'],
$userinfo['url'],$userinfo['type']) =
mysql_fetch_row($a_res);
mysql_query("update user set last_ip = '".$_SERVER['REMOTE_ADDR']."' where id=".$userinfo['id']);
} else {
$auth_msg = $cl['authorization_error'];
}
} else {
unset($_SESSION["se_login"]);
unset($_SESSION["se_passwd"]);
$auth_msg = $cl['authorization_error'];
}
}
if (isset($smarty)) {
$smarty->assign('auth_msg',$auth_msg);
}
?>
Типо авторизация
−35
Function GetLongFromData(InDay As Integer, InMonth As Integer, InYear As Integer) As Integer
If InYear Mod 4 = 0 Then N = 1 Else N = 0
If InMonth = 1 Then temp = InDay
If InMonth = 2 Then temp = InDay + 31
If InMonth = 3 Then temp = InDay + 31 + 28 + N
If InMonth = 4 Then temp = InDay + 31 + 28 + 31 + N
If InMonth = 5 Then temp = InDay + 31 + 28 + 31 + 30 + N
If InMonth = 6 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + N
If InMonth = 7 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + 30 + N
If InMonth = 8 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + N
If InMonth = 9 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + N
If InMonth = 10 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + N
If InMonth = 11 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + N
If InMonth = 12 Then temp = InDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + N
GetLongFromData = temp
End Function
Функция, принимающая дату и возвращающая номер дня в году.