- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
private function check($data) {
$result = $this->checkData($data);
if ($result === true) return true;
$sm = new SystemMessage();
return $sm->message($result);
}
protected function checkData($data) {
return false;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
private function check($data) {
$result = $this->checkData($data);
if ($result === true) return true;
$sm = new SystemMessage();
return $sm->message($result);
}
protected function checkData($data) {
return false;
}
С видеокурса Михаила Русакова
−4
// Привет коллеги, у меня возникла делема, куда пихать код отправки
// на e-mail сообщения? В модель формы или в контроллере оставить?
// фреймворк Yii, в самой Yii доке, написано, что в контроллерах надо
// оставлять, а вы как делаете?
Привет коллеги, у меня возникла делема, куда пихать код отправки на e-mail сообщения? В модель формы или в контроллере оставить? Фреймворк Yii, в самой Yii доке, написано, что в контроллерах надо оставлять, а вы как делаете?
+1
import std.io;
import std.string;
import calendar.month;
module calendar.date;
namespace Chrono
{
export
struct Date {
Date(int, Month, int);
int day() const
{
return d;
}
Month month() const
{
return m;
}
Int year() const
{
return y;
}
private:
int d;
Month m;
int y;
};
export
std::ostream &operator<<(std::ostream &, const Date &);
export
std::string to_string(const Date &);
}
По мотивам: http://habrahabr.ru/company/infopulse/blog/267781/
зы. https://github.com/isocpp/CppCoreGuidelines/blob/master/talks/Large-Scale-C%2B%2B-With-Modules.pdf
+14
/*
удалено по просьбе правообладателя
*/
Думал я, что меня уже так просто не удивишь, пока не увидел ЭТО!
−1
public interface IApplicationUserManager { }
public class ApplicationUserManager : UserManager<ApplicationUser, long>, IApplicationUserManager
{
private static ApplicationUserManager applicationUserManager;
public static bool IsUserInRole(long userId, string roleName)
{
return applicationUserManager.UserInRole(userId, roleName);
}
public ApplicationUserManager(IAccountService accountService)
: base(new ApplicationUserStore())
{
this.accountService = accountService;
applicationUserManager = this;
}
}
Проверяй, проверяй мои роли полностью...
+2
var date_match=time.split('.');
date_match=new Date(
date_match[1]+'-'+date_match[0]+'-'+/[\w\W]+(\d{4,4})\/(\d{4,4})[\w\W]+/.exec(document.title)[(date_match[1]>6)?1:2]//Gangsta
);
+5
Commission:= Commission/100*StrToInt(Label8.Caption); //Вычисление комиссии
Терминальщики :|
+3
$apiUrl = 'https://www.etxt.ru/api/json/';
$apiPass = '12300f89';
$sign = md5('method=folders.listFolderstoken=d0jjghg196942a9aefghhhh'.md5($apiPass.'api-pass'));
$params = array(
'method' => 'folders.listFolders',
'sign' => $sign,
'token' => 'd083b49cghhjjka9ae9fddghuyhhg'
);
$result = file_get_contents($apiUrl, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params)
)
)));
echo $result;
echo '<br />';
var_dump($params);
echo '<br />';
echo '<br />';
echo 'Trying using CURL';
echo '<br />';
echo '<br />';
$myCurl = curl_init();
curl_setopt_array($myCurl, array(
CURLOPT_URL => $apiUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params)
));
$response = curl_exec($myCurl);
curl_close($myCurl);
echo "Ответ на Ваш запрос: ".$response;
Не работал, потому что API написаны не понятно, нужно в $apiUrl вписывать sign и token. Поддержка выслала мне более универсальный код с функцией ksort! Потому этот код просто под удаление...
+8
// большой кусок кода
$where = '';
if (strlen($data["name"])) {
$where = $where . " AND name = '" . $data["name"] . "'";
}
if (strlen($data["company"])) {
$where = $where . " AND company = '" . $data["company"] . "'";
}
if (strlen($data["status"])) {
$where = $where . " AND status = '" . $data["status"] . "'";
}
// большой кусок кода
Проверка переменных на пустоту...
+2
if(file_exists('./daemon.php') & isset($_GET['stop'])){
rename('./daemon.php', './daemon.php~');
sleep(3);
header('Location: http://'.$_SERVER[HTTP_HOST]);
}elseif(isset($_GET['restart'])){
include('./lib.inc');
@rename('./daemon.php', './daemon.php~');
sleep(3);
rename('./daemon.php~', './daemon.php');
ping('daemon.php');
sleep(3);
header('Location: http://'.$_SERVER[HTTP_HOST]);
}
echo '<a href="/?restart" class="button">Start/Restart</a> ';
if(file_exists('./daemon.php'))
echo '<a href="/?stop" class="button">Stop</a>';
?><br>
<div class="display">-</div>
<script type="text/javascript"><!--
var xd;
setInterval(function(){
xd&&xd.abort();
xd = new XMLHttpRequest();
xd.onreadystatechange = function(){
if(xd.readyState == 4){
document.querySelector(".display").textContent = xd.responseText;
}
}
xd.open('GET', '/display.txt', true);
xd.send();
}, 3000);
//--></script>
daemon.php:
if(date('his')-file_get_contents('./date')<2)
exit;
file_put_contents('./date', date('his'));
include('./lib.inc');
$f=fopen('./lock', 'w+');
flock($f, LOCK_EX);
ping('core.php');
sleep(3);
ping('daemon.php');
usleep(200);
ping('daemon.php');
usleep(200);
flock($f, LOCK_UN);
core.php:
ini_set('display_errors', 'on');
error_reporting(E_ALL);
ini_set('html_errors', 'off');
$xreservedbasedir=__DIR__;
$xreservedtmpbuf=str_repeat('x', 1024 * 3);
function ob_write($buffer){
unset($GLOBALS['xreservedtmpbuf']);
file_put_contents($GLOBALS['xreservedbasedir'].'/display.txt', $buffer, LOCK_EX);
}
ob_start('ob_write');
include('./script.php');
script.php:
echo date("Y.m.d h:i:s"); //любой код, который исполняет демон
lib.inc:
function ping($action){
$h=$_SERVER[HTTP_HOST];
$http=fsockopen($h, 80, $e1, $e2, 1);
if($http){
fwrite($http,
'GET /'.$action.' HTTP/1.1'."\r\n".
'Accept: */*'."\r\n".
'Host: '.$h."\r\n\r\n"
);
fclose($http);
}
}
демон на php? Легко!