Skip to content

Instantly share code, notes, and snippets.

View kolyadin's full-sized avatar

Aleksey kolyadin

  • Easy Commerce
  • Russia
View GitHub Profile
<?php
class KaCache
{
private $memObject,$name,$lifetime;
private $tags = array();
private $app;
public function __construct(Ka $app)
return $cache->set($cacheKey,'20s',array('manufacture','bike_model'))->call(function() use($mysqli,$resizer) {
$result = $mysqli->queryFile('/bank.sql/moto-front');
$bikes = array();
while ($row = $result->fetch_assoc())
{
$row['pic'] = $resizer->resize($row['pic'],'{"h":120}');
$bikes[] = $row;
}
public static function incrementViews($newsId){
self::checkDataMap();
/** @var $post \popcorn\model\posts\NewsPost */
$post = self::$dataMap->findById($newsId);
$post->setViews($post->getViews()+1);
self::$dataMap->save($post);
}
public function findByHash($userId,$securityHash){
$this->findByHashMemoryStatement->bindValue(':id',$userId);
$this->findByHashMemoryStatement->bindValue(':securityHash',$securityHash);
$this->findByHashMemoryStatement->execute();
$userIdMemory = $this->findByHashMemoryStatement->fetch(\PDO::FETCH_COLUMN);
if ($userIdMemory){
//Сначала проверяем существует ли hash пользователя в кэше (mysql memory)
public function getUsersByCity($cityId, $from = 0, $count = -1){
$sql = <<<SQL
select
user.*
from
pn_users user
join pn_users_info info on (info.id = user.userInfo)
where
info.cityId = :cityId
<?
#print $GLOBALS['trafapril'];
/*
print "=".$HTTP_POST_VARS["pageid1"]."=($rand)";
print "=".$HTTP_POST_VARS["pageid"]."=($rand)";
print "=".$HTTP_POST_VARS["pageid2"]."=($rand)";
print "=$pageid/$subpageid/$page_id/$fold_id/$good_id=<br>";
<?php
/**
* Данное api обеспечивает взаимодействие между мобильными приложениями (iphone,ipad,android) и backend'ом кино
*
* @date 23.07.2013
* @author Колядин Алексей
*/
ini_set('display_errors',1);
ini_set('html_errors',1);
error_reporting(E_ALL);
/**
* @param int $announceLength
* @return null|string
*/
public function getAnnounceFriendly($announceLength = 100){
$announce = trim($this->getAnnounce());
$content = trim($this->getContent());
$output = null;
public static function newMessageSave() {
$recipient = UserFactory::getUser(self::getSlim()->request()->post('recipient'));
$message = new Message();
$message->setSentTime(new \DateTime());
$message->setAuthor(UserFactory::getCurrentUser());
$message->setRecipient($recipient);
$message->setContent(self::getSlim()->request()->post('message'));
$message->setRead(0);
$timestamp = func_get_args()[0];
$month = explode(' ', 'января февраля марта апреля мая июня июля августа сентября октября ноября декабря');
if ((time() - $timestamp) < 60 * 60 * 24) {
$out = 'сегодня, ';
} elseif ((time() - $timestamp) > 60 * 60 * 24 && (time() - $timestamp) < 60 * 60 * 24 * 2) {
$out = 'вчера, ';
} else {
$out = sprintf('%u %s %04u, ',