- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
public static function getById( $id )
{
$model = new self;
$data = $model->load();
foreach( $data AS $item ){
if( $item->id == $id ){
return $item;
}
}
return null;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+41
public static function getById( $id )
{
$model = new self;
$data = $model->load();
foreach( $data AS $item ){
if( $item->id == $id ){
return $item;
}
}
return null;
}
Нашел в текущем проекте.
+142
if ($options->get('registrationSetup', 'requireDob')) {
// dob required
Без ДОБ-а не пущу.
+54
public function accuire($array = array()) {
return $this->acquire($array);
}
public function acquire($array = array()) {
Spell-master
+39
<?php
set_time_limit(86400);
$begin = new DateTime($_GET["min_date"]);
$end = new DateTime($_GET["max_date"]);
$begincp = clone $begin;
$begincp_2 = clone $begin;
$dt_diff = $begin->diff($end);
$dt_diff = (int) $dt_diff->format("%a");
for($i = 1; $i <= $dt_diff; $i++)
{
$begincp_2->modify("+1 day");
$q = mysql_query("SELECT * FROM `skud_stat` WHERE
`arrival` >= '".$begincp->getTimestamp()."' AND
`arrival` < '".$begincp_2->getTimestamp()."'
ORDER BY `name`");
while($data = mysql_fetch_array($q))
{
$workers[$data["name"]][] = $data;
}
/* Сортировку */
//uksort($workers, "strnatcasecmp");
//ksort($workers);
$coun = 0;
$begincp->modify("+1 day");
}
/* быстрая сортировка */
uksort($workers, "strnatcasecmp");
?>
<table class="table table-striped table-hover table-condensed skud-chart">
<thead></thead>
<tr>
<th style="text-align: left">Имя</th>
<?php
$begin = new DateTime($_GET["min_date"]);
$end = new DateTime($_GET["max_date"]);
$bgcp = clone $begin;
$dt_diff = $begin->diff($end);
$dt_diff = (int) $dt_diff->format("%a");
for($i = 1; $i <= $dt_diff; $i++)
{
?>
<th><?=date("d.m.Y", $bgcp->getTimestamp());?></th>
<?php
$bgcp->modify("+1 day");
}
?>
</tr>
<?php
foreach($workers as $worker => $arr)
{
$begin_copy = clone $begin;
$begin_copy2 = clone $begin;
?>
<tr>
<td class="b"><?=$worker?></td>
<?php
for($i = 1; $i <= $dt_diff; $i++)
{
$begin_copy2->modify("+1 day");
foreach($arr as $day)
{
if($day["arrival"] > $begin_copy->getTimestamp() && $day["leaving"] < $begin_copy2->getTimestamp())
{
/* 28800 - рабочее время (8 часов)
27000 - как погрешность (7 часов 30 минут)
*/
?>
<td><?=date("H:i", $day["arrival"]);?> / <?=date("H:i", $day["leaving"]);?> / <?php if($day["worktime"] < 27000) { ?><b class="notenough"><?php } ?><?=date("H:i", $day["worktime"]);?><?php if($day["worktime"] < 21600) { ?></b><?php } ?></td>
<?php
$success_day = true;
}
else
{
?>
<!--<td>-</td>-->
<?php
}
}
if(!$success_day)
{
?>
<td class="naw">-</td>
<?php
}
unset($success_day);
//if($begin_copy->getTimestamp())
Корпоративная Статистика (!). Читаю из базы и строю отчёт.
+40
<?php
if($_POST["phones_csv_load"]) {
if(is_uploaded_file($_FILES["phones_csv"]["tmp_name"])) {
if (($handle = fopen($_FILES["phones_csv"]["tmp_name"], "r")) !== FALSE) {
$linecount = (exec('perl -pe \'s/\r\n|\n|\r/\n/g\' ' . escapeshellarg($_FILES["phones_csv"]["tmp_name"]) . ' | wc -l')) - 1;
for($i = 0; $i <= $linecount; $i++) {
$data = str_getcsv(iconv("cp1251", "utf8", stream_get_line($handle, 8000, "\n")), "\t");
$datetime = explode(" ", $data[28]);
$datetime["date"] = explode(".", $datetime[0]);
$datetime["time"] = explode(":", $datetime[1]);
$datetime["unix_time"] = mktime($datetime["time"][0], $datetime["time"][1], 0, $datetime["date"][1], $datetime["date"][0], "20".$datetime["date"][2]);
$datetime["unix_time_ar"] = mktime($datetime["time"][0], $datetime["time"][1], 0, 0, 0, 0);
$datetime["unix_day"] = mktime(0, 0, 0, $datetime["date"][1], $datetime["date"][0], "20".$datetime["date"][2]);
sort($fullmassive[$datetime["unix_day"]][$data[20]][] = array($data[17]." ".$data[18], $datetime["unix_time"], $data[20], $datetime["unix_day"], $datetime["unix_time_ar"], "inout" => checkInOut($data[3]), md5($data[20]." ".$data[18].$datetime["unix_time"].$datetime["unix_time"]), date("d.m.Y H:i", $datetime["unix_time"]), date("H:i", $datetime["unix_time_ar"])), SORT_NATURAL);
}
foreach($fullmassive as $fullmassive_day) {
foreach($fullmassive_day as $fullmassive_employee) {
usort($fullmassive_employee, 'invenDescSort');
$employee["uid"] = $fullmassive_employee[0][2];
$employee["in"] = $fullmassive_employee[0][1];
$employee["in_date"] = $fullmassive_employee[0][3];
$employee["in_time"] = $fullmassive_employee[0][4];
$employee["out"] = end($fullmassive_employee)[1];
$employee["out_date"] = mktime(0, 0, 0, date("n", end($fullmassive_employee)[1]), date("j", end($fullmassive_employee)[1]), date("Y", end($fullmassive_employee)[1]));
$employee["out_time"] = mktime(date("H", end($fullmassive_employee)[1]), date("i", end($fullmassive_employee)[1]), 0, 0, 0, 0);
$employee["name"] = $fullmassive_employee[0][0];
if($employee["in"] >= end($fullmassive_employee)[1]) $employee["in"] = mktime(10, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
else if(end($fullmassive_employee)[1] <= $employee["in"]) $employee["out"] = mktime(18, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
else
{
if(mktime(date("H", $employee["in"]), 0, 0, 0, 0, 0) < mktime(12, 0, 0, 0, 0, 0)) {
$employee["out"] = mktime(18, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
}
else {
$employee["in"] = mktime(10, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
}
}
if($employee["in_time"] >= end($fullmassive_employee)[4]) $employee["in_time"] = mktime(10, 0, 0, date("n", $employee["in_time"]), date("j", $employee["in_time"]), date("Y", $employee["in_time"]));
else if(end($fullmassive_employee)[4] <= $employee["in_time"]) $employee["out_time"] = mktime(18, 0, 0, date("n", $employee["in_time"]), date("j", $employee["in_time"]), date("Y", $employee["in_time"]));
$employee["worktime"] = $employee["out"] - $employee["in"];
mysql_query("INSERT INTO `skud_stat` SET `name` = '".$employee["name"]."',
`uid` = '".$employee["uid"]."',
`arrival` = '".$employee["in"]."',
`arrival_date` = '".$employee["in_date"]."',
`arrival_time` = '".$employee["in_time"]."',
`leaving` = '".$employee["out"]."',
`leaving_date` = '".$employee["out_date"]."',
`leaving_time` = '".$employee["out_time"]."',
`worktime` = '".($employee["worktime"])."'");
}
}
fclose($handle);
}
}
}
?>
Корпоративная Статистика (!). Читаю из CSV
+48
$title = get_the_title();
if ( $title == "Portfolio") $data['sl_portfolio_style'] = "2 Columns Portfolio";
if ( $title == "3 Columns Portfolio") $data['sl_portfolio_style'] = "3 Columns Portfolio";
if ( $title == "4 Columns Portfolio") $data['sl_portfolio_style'] = "4 Columns Portfolio";
if ( $title == "6 Columns Portfolio") $data['sl_portfolio_style'] = "6 Columns Portfolio";
if ( $title == "Portfolio") query_posts( '&post_type=portfolio-type&posts_per_page=4&paged=' . $paged );
if ( $title == "4 Columns Portfolio") query_posts( '&post_type=portfolio-type&posts_per_page=8&paged=' . $paged );
if ( $title == "6 Columns Portfolio") query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
if ( $title == "3 Columns Portfolio") query_posts( '&post_type=portfolio-type&posts_per_page=6&paged=' . $paged );
if ( $title == "Portfolio Right Sidebar") $data['sl_portfolio_style'] = "Portfolio with Sidebar";
if ( $title == "Portfolio Right Sidebar") $data['portfolio_sidebar_position'] = "Right Sidebar";
if ( $title == "Portfolio Left Sidebar") $data['sl_portfolio_style'] = "Portfolio with Sidebar";
if ( $title == "Portfolio Left Sidebar") $data['portfolio_sidebar_position'] = "Left Sidebar";
if ( $title == "Portfolio Left Sidebar") query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
if ( $title == "Portfolio Right Sidebar") query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
"switch - case" - Не не слышал!
И это в покупной теме для wordpress на тимфоресте.
Стоимость темы - 45 уе...
+67
class IntegerUtils
{
public static function isInteger($value)
{
return preg_match('/[0-9]+/', $value);
}
}
Must have класс, который должен быть у каждого в его библиотеке "велоприседов". Поистине краткий, лаконичный, гениальный. Даешь 100% говнокод!
+57
for($i=0;$i<count($data_cor);$i++)
{
if(($data_cor[$i]['status'] == 1) && (($data_cor[$i]['number_packet'] == "9999998") || ($data_cor[$i]['number_packet'] == $iNumber)))
{ $_MY_LOG_counter_2 ++;
foreach($data_cor[$i] as $key=>$value)
$data_cor[$i][$key] = str_replace(";","",str_replace("\n","",str_replace("\r\n","",$value)));
$d .= "\$Заявка\r\n";
$d .= $data_cor[$i]['guid']. ";".$data_cor[$i]['number_1c']. ";".$data_cor[$i]['date_request']. ";".$data_cor[$i]['number_request'].";"
.$data_cor[$i]['contractor']. ";".$data_cor[$i]['contractor_doc'].";".$data_cor[$i]['general_request_id'].";".$data_cor[$i]['date_dispatch'].";"
.$data_cor[$i]['type_dispatch']. ";".$data_cor[$i]['g_contactor_id'].";".$data_cor[$i]['address']. ";"
.$data_cor[$i]['station_name']. ";".$data_cor[$i]['station_code']. ";".$data_cor[$i]['status']. ";"
.$data_cor[$i]['transport_id']. ";".$data_cor[$i]['contact_person'].";".$data_cor[$i]['phone_number']. ";"
.$data_cor[$i]['station_guid']. ";".$data_cor[$i]['guid_cont_4']. ";".$data_cor[$i]['transport_type']. ";"
.$data_cor[$i]['trailer']. ";".$data_cor[$i]['driver']. ";".$data_cor[$i]['driver_reserve']. ";"
.$data_cor[$i]['address_delivery'].";".$data_cor[$i]['comment'];
$d .= "\r\n";
if(count($data_cor['products']>0))
{
$d .= "#Товары\r\n";
foreach($data_cor[$i]['products'] as $p)
$d .= $p['guid'].";".$p['ob'].";".$p['get'].";".$p['doc_guid']."\r\n";
$d .= "#Состояния\r\n";
foreach($data_cor[$i]['statuses'] as $s)
$d .= $s['status'].";".$s['date'].";".$s['user'].";".$s['type'].";".$s['guid']."\r\n";
}
}
}
CSV заказывали?
Ах да, выгружаться могут разные данные, поэтому рядом лежат еще 4 говнофункции, отличающихся от этой только ключами массива.
+50
if(!empty($filter['features']) && !empty($filter['features'])) ...
Simpla CMS /api/Products.php
+47
function executeNewsRightRelated(sfWebRequest $request)
{
$siteId = $request->getParameter('site')->id;
$tNewsList = $this->object->News;
$newsList = array();
foreach ($tNewsList as $news) {
$ids = array();
foreach ($news->Sites as $idModel) {
$ids[] = $idModel->id;
}
if (in_array($siteId, $ids)) {
$newsList[] = $news;
}
}
$this->newsList = $newsList;
}