- 1
- 2
- 3
- 4
- 5
if ($_SESSION['free'] <= 0) {
if ($_SESSION['free'] > 0) {
$_SESSION['free'] --;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+174
if ($_SESSION['free'] <= 0) {
if ($_SESSION['free'] > 0) {
$_SESSION['free'] --;
}
}
Нашел в один из онлине казино.
+164
if($_SESSION['use_test_xml'] && false) {
if(!responseTestXml('chekin_'.$_GET['userid'].'_'.( ($_GET['placeid']) ? $_GET['placeid'] : $_GET['eventid'] ).'.xml')) {
responseTestXml('err.xml',array('message'=>'Unxpected situation. Please use these users: 12345,54321 and places|events: 1-9.'));
}
} else {
...
плеать...
+161
/**
* @param array $config
* @return App_Ldap
*/
private final function __construct(array $config)
{
if (!empty($config['host'])) {
$this->_host = $config['host'];
$dnTemp = explode('.', $this->_host);
$dnTemp = array_map(function($value)
{
return 'dc=' . $value;
}, $dnTemp);
$this->_dn = implode(',', $dnTemp);
} else {
throw new Exception('I need LDAP host');
}
if (!empty($config['user'])) {
$this->_user = $config['user'];
} else {
throw new Exception('I need LDAP login');
}
if (!empty($config['pass'])) {
$this->_pass = $config['pass'];
} else {
throw new Exception('I need LDAP pass');
}
return $this;
}
+155
function otherString($str,$style)
{
$str=trim($str);
switch($style)
{
case 1: $str=strip_tags($str); $str=str_replace("\n",'<br />',$str); break;
case 2: break;
case 3: $str=strip_tags($str); $str=str_replace("\n",'',$str); $str=str_replace('<br />',"\n",$str); break;
case 4: $str=ereg_replace('(mailto:|mailto|http://|http:/|http:|http|ftp://|ftp:/|ftp:|ftp)','',$str);break;
case 5: $str=stripslashes($str); break;
case 6: $str=stripslashes($str); $str=strip_tags($str); break;
case 7: $str=strip_tags($str); break;
}
return $str;
}
web-based cms
+162
public function title_url_formatted($len = 70)
{
return Core_String::title_to_url(Core_String::unicode_truncate($this->title, 70));
}
писал не я, если что)
+166
switch( $task ) {
case "userDetails":
case "userdetails":
userEdit( $option, $uid, _UE_UPDATE );
break;
case "saveUserEdit":
case "saveuseredit":
$oldignoreuserabort = ignore_user_abort(true);
userSave( $option, (int) cbGetParam( $_POST, 'id', 0 ) );
break;
case "userProfile":
case "userprofile":
//header("Location:http://google.com");
userProfile($option, $_CB_framework->myId(), _UE_UPDATE);
break;
case "usersList":
case "userslist":
usersList( $_CB_framework->myId() );
break;
case "userAvatar":
case "useravatar":
userAvatar($option, $uid, _UE_UPDATE);
break;
case "lostPassword":
case "lostpassword":
lostPassForm( $option );
break;
case "sendNewPass":
case "sendnewpass":
$oldignoreuserabort = ignore_user_abort(true);
sendNewPass( $option );
break;
case "registers":
registerForm( $option, isset( $ueConfig['emailpass'] ) ? $ueConfig['emailpass'] : '0' );
break;
case "saveregisters":
$oldignoreuserabort = ignore_user_abort(true);
saveRegistration( $option );
break;
case "login":
$oldignoreuserabort = ignore_user_abort(true);
login();
break;
case "logout":
$oldignoreuserabort = ignore_user_abort(true);
logout();
break;
case "confirm":
$oldignoreuserabort = ignore_user_abort(true);
confirm( cbGetParam( $_GET, 'confirmcode', '1' ) ); // mambo 4.5.3h braindead: does intval of octal from hex in cbGetParam...
break;
case "moderateImages":
case "moderateimages":
$oldignoreuserabort = ignore_user_abort(true);
moderateImages($option);
break;
case "moderateReports":
case "moderatereports":
$oldignoreuserabort = ignore_user_abort(true);
moderateReports($option);
break;
case "moderateBans":
case "moderatebans":
$oldignoreuserabort = ignore_user_abort(true);
moderateBans($option,$act,$uid);
break;
case "approveImage":
case "approveimage":
$oldignoreuserabort = ignore_user_abort(true);
approveImage();
break;
case "reportUser":
case "reportuser":
$oldignoreuserabort = ignore_user_abort(true);
reportUser($option,$form,$uid);
break;
case "processReports":
case "processreports":
$oldignoreuserabort = ignore_user_abort(true);
processReports();
break;
...
Это модуль для Joomla, который называется Community Builder. Никогда, никогда его не используйте. Говнище редкое!
+161
session_start();
$Time = $_SESSION['Time'];
$Time--;
if($Time<0) $Time=0;
$Hour=(int)($Time/3600);
$Min=(int)(($Time-$Hour*3600)/60);
$Sec=$Time-($Hour*3600+$Min*60);
$Str=sprintf("%02d:%02d:%02d",$Hour,$Min,$Sec);
$_SESSION['Time']=$Time;
echo "{'Time':$Time,'sss':'$Str'}";
// jquery
function show()
{
$.post('TimeStr.php',
{'ids':'1'},
function(data){
$("#content").html(data['sss']);
if(data['Time']=='0')
{
$("#AnswerBtn").attr('disabled','disabled');
document.getElementById('NotSaveAnswer').style.display='';
}
},
"json");
}
$(document).ready(function(){
show();
setInterval('show()',1000);
});
Выводит текущее время на сайт используя jquery и php O_O
+163
$result = $db->query("SELECT w.wine_name as wine_name,(SELECT wine_type FROM wine_type WHERE wine_id_type = w.wine_type) as wine_type,
(SELECT variety FROM grape_variety WHERE variety_id = (SELECT variety_id FROM wine_variety WHERE wine_id = w.wine_id)) AS wine_variety,
w.year as wine_year, (SELECT winery_name FROM winery WHERE winery_id = w.winery_id) as winery,
(SELECT region_name FROM region WHERE region_id = (SELECT region_id FROM winery WHERE winery_id = w.winery_id)) as winery_region,
(SELECT cost FROM inventory WHERE wine_id = w.wine_id) as wine_cost,
(SELECT on_hand FROM inventory WHERE wine_id = w.wine_id) as wine_quantity
FROM wine w
WHERE w.wine_id = '$id'");
достаём данные из базы для страницы редактирования ...
+163
// ����� �������� � �������
if (!function_exists('indexOf')) {
function indexOf($needle, $haystack) {
for($i = 0; $i < count($haystack); $i++) {
if ($haystack[$i] == $needle) {
return true;
}
}
return false;
}
}
По просьбе трудящихся... (#7616)
Кто угадает, что это за функция?
Ответ: это велосипедная конструкция-заменитель in_array
+156
<?php
include_once "database.php";
$db = NewPDO();
$search = $db->prepare("SELECT w.wine_name as wine_name, w.year as wine_year, gv.variety as wine_variety, wn.winery_name as winery_name,r.region_name as region_name
FROM wine w
JOIN wine_variety wv ON w.wine_id = wv.wine_id
JOIN grape_variety gv ON wv.variety_id = gv.variety_id
JOIN winery wn ON w.winery_id = wn.winery_id JOIN region r ON wn.region_id = r.region_id
WHERE w.wine_name LIKE :in_wine_name AND wn.winery_name LIKE :in_winery_name AND r.region_name LIKE :in_region_name
ORDER BY w.wine_name ASC , w.year ASC , gv.variety ASC");
$wine_name = '%'.htmlspecialchars($_GET["wine"]).'%';
$winery_name = '%'.htmlspecialchars($_GET["winery"]).'%';
$region = '%'.htmlspecialchars($_GET["region"]).'%';
$search->bindValue(':in_wine_name',$wine_name,PDO::PARAM_STR);
$search->bindValue(':in_winery_name',$winery_name,PDO::PARAM_STR);
$search->bindValue(':in_region_name',$region,PDO::PARAM_STR);
$search->execute();
echo "<table>";
if ($search->columnCount() > 0)
{
echo "<tr align=\"center\">
<th>
Wine
</th>
<th>
Year
</th>
<th>
Variety
</th>
<th>
Winery
</th>
<th>
Region
</th>
</tr>";
while($row = $search->fetch())
{
echo "<tr align=\"left\">
<td width=\"80\">
".$row["wine_name"]."
</td>
<td width=\"50\">
".$row["wine_year"]."
</td>
<td width=\"90\">
".$row["wine_variety"]."
</td>
<td width=\"230\">
".$row["winery_name"]."
</td>
<td>
".$row["region_name"]."
</td>
</tr>";
}
echo "<tr>
<td colspan=\"5\">
".$search->rowCount()." records found matching your criteria.
</td>
</tr>";
}
else
{
echo "<tr><td>No records match your search criteria</td></tr>";
}
echo "</table>";
?>
Вот такой вот полнотекстовый поиск с выводом результата