- 1
<?php echo ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) ? "top: 35px;" : ""); ?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
<?php echo ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) ? "top: 35px;" : ""); ?>
Постоянно натыкаюсь, разбирая старые проекты. Народ просто не знал, про CC в осле.
+171.5
$now = mktime(date("G"), date("i"), date("s"), date("m") , date("d"), date("Y"));
получение текущего времени :)
читайте доки, юзернеймы.
+157
function ru_title() {
global $locale, $lang, $settings;
define("DIVIDER", $locale['title-00']);
$title = "";
if (stristr($_SERVER['REQUEST_URI'],"news")){
$title = $locale['title-16'];
if (isset($_GET['readmore'])){
$result = dbquery("SELECT * FROM ".DB_PREFIX."news WHERE news_id='".$_GET['readmore']."'");
if (dbrows($result) != 0) {
$data = dbarray($result);
$title = $data["news_subject"].DIVIDER.$title;
}
}
}
elseif (stristr($_SERVER['REQUEST_URI'],"contact")){
$title = $locale['title-01'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"edit_profile")){
$title = $locale['title-02'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"lostpassword")){
$title = $locale['title-03'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"messages")){
$title = $locale['title-04'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"photogallery")){
$title = $locale['title-05'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"profile")){
$title = $locale['title-06'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"register")){
$title = $locale['title-07'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"search")){
$title = $locale['title-08'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"submit")){
$title = $locale['title-09'];
}
elseif (stristr($_SERVER['REQUEST_URI'],"downloads")){
if ($_SERVER['PHP_SELF'] !== "/infusions/mod_downloads/downloads.php"){ // Sky edition
$title = $lang['downloads_000'];
if (isset($_GET['cat_id'])){
$result = dbquery("SELECT * FROM ".DB_PREFIX."download_cats WHERE download_cat_id='".$_GET['cat_id']."'");
if (dbrows($result) != 0) {
$data = dbarray($result);
$title = $data["download_cat_name"].DIVIDER.$title;
}
}
}
}
return $title.(($title == "") ? ("") : (DIVIDER));
}
Споcоб реализации динамических заголовков для одной популярной CMS
+158
//============================================================================================================================================
function isadekvat($ps_user){
global $conn1,$zright;
$pb1=1;
$rs_2=mysql_query("select STATUS from tbl_user where CODE=".$ps_user,$conn1);
$rs=mysql_fetch_array($rs_2);
$ps1=$rs['STATUS'];
mysql_free_result($rs_2);
$rs_2=mysql_query("select * from tbl_user_status where CODE=".$ps1,$conn1);
$rs=mysql_fetch_array($rs_2);
if ($rs['DO_MODER']==1){
if ($zright['DO_MODERATOR']==1 || $zright['DO_SET']==1){
$pb1=1;
}else{
$pb1=0;
}
}
if ($rs['DO_MODERATOR']==1 || $rs['DO_SET']==1){
if ($zright['DO_SET']==1){
$pb1=1;
}else{
$pb1=0;
}
}
mysql_free_result($rs_2);
return $pb1;
}
//============================================================================================================================================
Проверка пользователя на адекватность
Magneto
+162.2
$buuuu = $buf;
if (!strstr($buf, 'No ch') && $buf!='') {
$nline = unserialize($buf);
foreach ($nline as $key=>$val) {
foreach ($val as $key1=>$val1) {
foreach ($val1 as $key2=>$val2) {
foreach ($val2 as $key3=>$val3) {
foreach ($val3 as $key4=>$val4) {
foreach ($val4 as $key5=>$val5) {
$key2 = str_replace($arepl, ' ', $key2);
$key2 = str_replace(' .', ' ', $key2);
$key2 = trim(ereg_replace(" +", ' ', $key2));
$oline[$key][$key1][$key2][$key3][$key4][$key5] = $val5;
}
}
}
}
}
}
$toline = serialize($oline);
$fw = fopen('ch.txt', 'w') ;
fwrite($fw, $toline);
fclose($fw);
foreach($oline as $key=>$val) {
foreach($val as $key1=>$val1) {
foreach($val1 as $key2=>$val2) {
foreach($val2 as $key3=>$val3) {
foreach($val3 as $key4=>$val4) {
foreach($val4 as $key5=>$val5) {
if ($key5>$last_ch_time) {
$last_ch_time = $key5;
}
}
}
}
}
}
}
}
названия переменных рулят!
+159
if ($_POST["type"] == "2") {
echo '<form name=fm method=post>'.
'<select class="f" name="per" onChange="mclick(\'/history.php?type=2&per=\'+document.fm.per.value)">'.
'<option value="2"'; if ($per == "2") { print "selected"; }; echo '>'.$lng['history'][14].''.
'<option value="5"'; if ($per == "5") { print "selected"; }; echo '>'.$lng['history'][15].''.
'<option value="7"'; if ($per == "7") { print "selected"; }; echo '>'.$lng['history'][16].''.
'<option value="14"'; if ($per == "14") { print "selected"; }; echo '>'.$lng['history'][17].''.
'<option value="30"'; if ($per == "30") { print "selected"; }; echo '>'.$lng['history'][18].''.
'<option value="365"'; if ($per == "365") { print "selected"; }; echo '>'.$lng['history'][19].''.
'<option value="1000"'; if ($per == "1000") { print "selected"; }; echo '>'.$lng['history'][20].''.
'</select>'.
'</form>';
}
убейте меня
+154.9
$res = & $mdb2->query ( " SELECT * FROM manage WHERE parsed = 0 AND timestamp = DATE_FORMAT(now(), '%Y-%m-%d'); ");
while ( $row = $res->fetchRow ()) {
…
try {
…
} catch (Exception $e) {
…
}
if (empty($e)) $res = & $mdb2->query ( «UPDATE `user_control`.`manage` SET `parsed` = 1 WHERE `manage`.`ti_uid` ='».$row['ti_uid']."' LIMIT 1; ");
}
$res
+157.1
if ($_GET['logout']) {
$user_key = '';
} else {
WAP::checkLogin();
$user_key = WAP::getUserKey();
if (!$user_key) {
# TODO FIX HUGE FUCKING SECURITY HOLE
$qs = $_SERVER['QUERY_STRING'];
if (trim($qs)) {
$user_row = getUserRowByUserID($qs);
if ($user_row) {
$user_key = $user_row['UsKey'];
if (Config::get('wap_sessions.enabled')) {
Session::setUserKey($user_key);
} else {
$_GET['cid'] = $qs;
}
}
}
}
}
Комментарии в тексте программы оставлены без изменений :)
+131
List<int> arr = new List<int>();
List<int> tmpArr = new List<int>();
for (int i = 0; i < arr.Count; i++)
{
if (arr[i] > 100)
{
}
else
tmpArr.Add(arr[i]);
}
arr = tmpArr;
Удаляем плохие элементы со списка или кто создал дурацкий for???
+154.9
$url = URL::uri('chatsW.php', $params);
$chatters_link=new HAW_link('chat rooms', $url);
$url = URL::uri('browseW.php', $params);
$people_link =new HAW_link('people', $url);
$url = URL::uri('recentW.php', $params);
$photos_link =new HAW_link('photos', $url);
$url = URL::uri('find_area_codeW.php', $params);
$find_by_areacode_link =new HAW_link('search by US area code', $url);
$url = URL::uri('inboxW.php', $params);
$messages_link =new HAW_link('messages' . $message_count_text, $url);
$url = URL::uri('whatsnewW.php', $params);
$whatsnew_link =new HAW_link('what\'s new', $url);
$url = URL::uri('invites_mainW.php', $params);
$invites_link =new HAW_link('invites' . $invite_count_text, $url);
$url = URL::uri('friendsW.php', $params);
$my_friends_link=new HAW_link('my friends', $url);
$url = URL::uri('phone_bookW.php', $params);
$phone_book_link=new HAW_link('my phone book', $url);
$url = URL::uri('chatterW.php', $params);
$my_chatter_link=new HAW_link('my chatter', $url);
$url = URL::uri('my_profileW.php', $params);
$my_profile_link=new HAW_link('my profile', $url);
$url = URL::uri('settingsW.php', $params);
$settings_link =new HAW_link('settings', $url);
$url = URL::uri('logout.php', $params);
$logout_link=new HAW_link("log out", $url);
$wapPage->add_link($people_link);
$wapPage->add_link($photos_link);
$wapPage->add_link($find_by_areacode_link);
$wapPage->add_link($chatters_link);
$wapPage->add_link($messages_link);
$wapPage->add_link($whatsnew_link);
$wapPage->add_link($invites_link);
$wapPage->add_link($my_friends_link);
$wapPage->add_link($phone_book_link);
$wapPage->add_link($my_chatter_link);
$wapPage->add_link($my_profile_link);
$wapPage->add_link($settings_link);
$wapPage->add_link($logout_link);