- 1
- 2
- 3
if( is_numeric((int)$_GET['id1']) && is_numeric((int)$_GET['id2']) && is_numeric((int)$_GET['id3']) ){
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+158
if( is_numeric((int)$_GET['id1']) && is_numeric((int)$_GET['id2']) && is_numeric((int)$_GET['id3']) ){
}
Капитан очевидность)
+155
<?php
$valid = false;
if (!isset($month))
{
$valid = true;
$month = date('m');
}
if (!isset($year))
$year = date('Y');
if ($month == '12')
$next_year = $year + 1;
else
$next_year = $year;
$Month_r = array(
"1" => "Январь",
"2" => "Февраль",
"3" => "Март",
"4" => "Апрель",
"5" => "Май",
"6" => "Июнь",
"7" => "Июль",
"8" => "Август",
"9" => "Сентябрь",
"10" => "Октябрь",
"11" => "Ноябрь",
"12" => "Декабрь");
$first_of_month = mktime(0, 0, 0, $month, 1, $year);
// Массив имен всех дней в неделю
$day_headings = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$maxdays = date('t', $first_of_month);
$date_info = getdate($first_of_month);
$month = $date_info['mon'];
$year = $date_info['year'];
// Вычитаем один день с первого дня месяца,
//чтобы получить в конец прошлого месяца
$timestamp_last_month = $first_of_month - (24 * 60 * 60);
$last_month = date("m", $timestamp_last_month);
// Проверяем, что если месяц декабрь,
//на следующий месяц равен 1, а не 13
if ($month == '12')
$next_month = '1';
else
$next_month = $month + 1;
$calendar = "
<div class=\"block-on-center\">
<table cellpadding=\"0\" cellspacing=\"0\" class=\"calendar\">
<tr style='background: #933692;' height='40px'>
<td colspan='7' class='navi'>" . $Month_r[$month] . " " . $year . "
<a style='margin-left: 10px; color: #ffffff;' href='/calendar/" . $quest->id . "/" . $next_month . "/" . $next_year . "'>>></a>
</td>
</tr>
<tr class='calendar-row'>
<td class='calendar-day-head'>Пн</td>
<td class='calendar-day-head'>Вт</td>
<td class='calendar-day-head'>Ср</td>
<td class='calendar-day-head'>Чт</td>
<td class='calendar-day-head'>Пт</td>
<td class='calendar-day-head'>Сб</td>
<td class='calendar-day-head'>Вс</td>
</tr>
<tr class='calendar-row'>";
$class = "";
$weekday = $date_info['wday'];
$weekday = $weekday - 1;
if ($weekday == -1)
$weekday = 6;
$day = 1;
for ($i = 0; $i < $weekday; $i++)
{
$calendar .= "<td class=\"calendar-day-np\"> </td>";
}
$blocks = '';
while ($day <= $maxdays)
{
// если суббота, выволдим новую колонку.
if ($weekday == 7)
{
$calendar .= "</tr><tr>";
$weekday = 0;
}
$days = array('0' => 'Воскресенье', '1' => 'Понедельник', '2' => 'Вторник', '3' => 'Среда', '4' => 'Четверг', '5' => 'Пятница', '6' => 'Суббота');
$linkDate = mktime(0, 0, 0, $month, $day, $year);
$day_an = date("w", $linkDate);
// проверяем, если распечатанная дата является сегодняшней датой.
//если так, используем другой класс css, чтобы выделить её
Вьюшка календарика, сам сайт на Kohana.
+154
switch($step) {
case 0:
setup_config_display_header();
?>
<p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
<ol>
<li><?php _e( 'Database name' ); ?></li>
<li><?php _e( 'Database username' ); ?></li>
<li><?php _e( 'Database password' ); ?></li>
<li><?php _e( 'Database host' ); ?></li>
<li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
</ol>
<p><strong><?php _e( "If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
<p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…" ); ?></p>
<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p>
<?php
break;
case 1:
setup_config_display_header();
//...
case 2:
foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
$$key = trim( wp_unslash( $_POST[ $key ] ) );
$tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
if ( empty( $prefix ) )
wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
// Validate $prefix: it can only contain letters, numbers and underscores.
if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) );
// Test the db connection.
/**#@+
* @ignore
*/
define('DB_NAME', $dbname);
define('DB_USER', $uname);
define('DB_PASSWORD', $pwd);
define('DB_HOST', $dbhost);
/**#@-*/
// We'll fail here if the values are no good.
require_wp_db();
// еще двести строк свитча с html, обработкой данных прямо на лету и даже небольшим количеством инлайн-js
Захотел я подцепиться к внутреннему api установки вордпресса, чтобы эту самую установку делать через конфиг-файлы и композер. В результате проще оказалось имитировать окружение веб-сервера, заполнять всякие $_GET-$_POST и просто подключать нужный файл. А как они сами с этим адом работают - для меня остается загадкой
Целиком https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/setup-config.php и https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/install.php
+159
if (!isset($_SESSION[$_SESSION['tab_name']]['FILE_ATTRIBUTES'][$request['itemId']][$request['itemFieldId']])) {
$_SESSION[$_SESSION['tab_name']]['FILE_ATTRIBUTES'][$request['itemId']][$request['itemFieldId']] = $request['itemFieldId'];
} else {
unset($_SESSION[$_SESSION['tab_name']]['FILE_ATTRIBUTES'][$request['itemId']][$request['itemFieldId']]);
}
И это часный проект где программисту платять большие деньги.
А еще у автора более 5 лет опыта
А сам сок, такого дерьма в проекте более 1000 обращений.
+154
foreach ($params as $param) {
$param_type = (isset($param['type']) ? $param['type'] : 's');
$param_value = (isset($param['value']) ? $param['value'] : $param);
// <...>
}
Угадайте, что произошло, когда значение параметра оказалось равным 'type'?
+153
if(!empty($this->aActions))
$sMenuItems = htmlspecialcharsbx(CAdminPopup::PhpToJavaScript($this->aActions));
?>
<tr class="adm-list-table-row<?=(isset($this->aFeatures["footer"]) && $this->aFeatures["footer"] == true? ' footer':'')?><?=$this->bEditMode?' adm-table-row-active' : ''?>"<?=($sMenuItems <> ""? ' oncontextmenu="return '.$sMenuItems.';"':'');?><?=($sDefAction <> ""? ' ondblclick="'.$sDefAction.'"'.(!empty($sDefTitle)? ' title="'.GetMessage("admin_lib_list_double_click").' '.$sDefTitle.'"':''):'')?>>
<?
if(count($this->pList->arActions)>0 || $this->pList->bCanBeEdited):
$check_id = RandString(5);
?>
<td class="adm-list-table-cell adm-list-table-checkbox adm-list-table-checkbox-hover<?=$this->bReadOnly? ' adm-list-table-checkbox-disabled':''?>"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="ID[]" id="<?=$this->table_id."_".$this->id."_".$check_id;?>" value="<?=$this->id?>" autocomplete="off" title="<?=GetMessage("admin_lib_list_check")?>"<?=$this->bReadOnly? ' disabled="disabled"':''?><?=$this->bEditMode ? ' checked="checked" disabled="disabled"' : ''?> /><label class="adm-designed-checkbox-label adm-checkbox" for="<?=$this->table_id."_".$this->id."_".$check_id;?>"></label></td>
<?
endif;
if($this->pList->bShowActions):
if(!empty($this->aActions)):
?>
<td class="adm-list-table-cell adm-list-table-popup-block" onclick="BX.adminList.ShowMenu(this.firstChild, this.parentNode.oncontextmenu(), this.parentNode);"><div class="adm-list-table-popup" title="<?=GetMessage("admin_lib_list_actions_title")?>"></div></td>
<?
else:
?>
<td class="adm-list-table-cell"></td>
<?
endif;
endif;
bitrix
Лапша PHP кода, с подливкой из HTML. Присутствуют специи из альтернативного синтаксиса оператора if для шаблонов
+157
for ($j=1; $j<8; $j++) {
$up = "";
$down = "";
for ($i=1; $i<7; $i++) {
if (($i==4)&&($j==4)) {
$up = $up.'<td class="simp" colspan="2" rowspan="4">Военная<br>Подготовка</td>';
continue;
}
if (($i==4)&&($j>3)&&($j<6)) {
continue;
}
$x = $i*2-1;
$y = $j*2-1;
if (($table[$x][$y]==$table[$x][$y+1])&&($table[$x+1][$y+1]==$table[$x+1][$y])&&($table[$x+1][$y+1]==$table[$x][$y])) {
$up = $up.str_replace("<br><br>","","<td title='".$table[$x][$y]['description']."' class='simp' colspan='2' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>");
}
else {
$cnt = 0;
if ($table[$x][$y]==$s) $cnt++;
if ($table[$x][$y+1]==$s) $cnt++;
if ($table[$x+1][$y]==$s) $cnt++;
if ($table[$x+1][$y+1]==$s) $cnt++;
if ($cnt==3) {
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
else {
if ($table[$x][$y]==$table[$x][$y+1]) { // Левые совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
if ($table[$x+1][$y]==$table[$x+1][$y+1]) {
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
}
else {
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
} else {
if ($table[$x+1][$y]==$table[$x+1][$y+1]) { // Правые совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
}
else {
if ($table[$x][$y]==$table[$x+1][$y]) { // Верхние совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm' colspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
if ($table[$x][$y+1]==$table[$x+1][$y+1]) {
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
}
else {
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
}
else {
if ($table[$x][$y+1]==$table[$x+1][$y+1]) { // Нижние совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
}
else {
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
...
Рендер расписания занятий из базы данных в табличку на HTML
+155
global $strError, $MESS, $HTTP_GET_VARS, $arrFORM_FILTER;
global $find_date_create_1, $find_date_create_2, $lAdmin;
$str = "";
CheckFilterDates($find_date_create_1, $find_date_create_2, $date1_wrong, $date2_wrong, $date2_less);
if ($date1_wrong=="Y") $str.= GetMessage("FORM_WRONG_DATE_CREATE_FROM")."<br>";
if ($date2_wrong=="Y") $str.= GetMessage("FORM_WRONG_DATE_CREATE_TO")."<br>";
if ($date2_less=="Y") $str.= GetMessage("FORM_FROM_TILL_DATE_CREATE")."<br>";
bitrix
- использование HTTP_GET_VARS уже давно deprecated
- магические переменные find_date_create_1, find_date_create_2, да и lAdmin тоже не понятно что
- зачем-то используются символы Y и N вместо true и false или 1 и 0
+163
/**
* @param $data
*/
protected function echo_string($data)
{
echo $data;
}
Хитрый ход
+144
<?endif;?>
<?endforeach;?>
<?foreach($arResult["SHOW_PROPERTIES"] as $code=>$arProperty):
битрикс, что ты делаешь. ахах прекрати