Example #1
0
 public function checkCaptchaAfterUnSuccessfulUsernameLogin(Captcha $captcha, Counter $counter)
 {
     $counter->increaseFailedLoginUsernameCounter();
     if ($counter->getFailedLoginUsernameCounter() >= Counter::CAPTCHA_STATUS_SWITCH_FAILED_LOGIN_USERNAME_ATTEMPTS) {
         $captcha->setCaptchaStatus(true);
     }
     return $captcha->getCaptchaStatus();
 }
 public function actionIndex()
 {
     $model = Counter::model()->find();
     if (empty($model)) {
         $model = new Counter();
     }
     if (!empty($_POST['Counter'])) {
         $model->attributes = $_POST['Counter'];
         $model->year = $_POST['Counter']['year'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Cập nhật thành công.'));
             $this->redirect(PIUrl::createUrl('/admin/counter'));
         }
     }
     $this->render('index', array('model' => $model));
 }
Example #3
0
 public static function getDayTopViewPosts($start = 0, $limit = 10)
 {
     Counter::checkAll(Topic::ENTITY_TYPE);
     $query = Topic::find()->join("user")->join("group")->join("rating")->join("counter");
     $query = $query->order("desc", "[Counter.dayCount]")->where("[Counter.dayCount]>0");
     $results = $query->range($start, $limit);
     return $results;
 }
 public function run()
 {
     //add counter
     $params = count($this->params) ? "/" . implode("/", $this->params) : "";
     $mskTime = date_create()->setTimezone(new DateTimeZone(App::$instance->opt->ca_timezone));
     Counter::create(['origin' => MY_NODE, 'ip' => App::$instance->user->ip, 'request' => $this->controller . "/" . $this->action . urlencode($params), 'type' => ST::isAjaxRequest() ? REQUEST_AJAX : REQUEST_REGULAR, 'created_at' => $mskTime, 'updated_at' => $mskTime]);
     call_user_func_array(array(new $this->controller(), $this->action), $this->params);
 }
Example #5
0
 static function reset()
 {
     Counter::$scenarios = 0;
     Counter::$pareto = 0;
     Counter::$leaf = 0;
     Counter::$start = time() - 1;
     Counter::$counters = [];
 }
Example #6
0
 public static function checkAll($entityType)
 {
     $counters = Counter::find("entityTypeId", $entityType)->all();
     foreach ($counters as $counter) {
         if ($counter->checkCounter()) {
             $counter->save();
         }
     }
 }
 public function product($id)
 {
     $categories = $this->categories->get()->linkNodes()->toTree();
     $product = $this->products->find($id);
     $user = $product->user()->get()->first();
     $page = \Counter::showAndCount('produto', $product->id);
     $banners = $this->banners->all();
     return view('frontend.product', compact('categories', 'product', 'user', 'page', 'banners'));
 }
Example #8
0
/**
 * Функция, предназначенная для сбора различной информации о просмотренных страницах, пользователях,
 * ip-адресах и т.д., с возможностью отображения полученных данных как в Панли управления, так и в Публичной
 * части сайта.
 *
 * @access public
 * @param string $counter_id цифровой идентификатор счетчика
 * и опционально строка show для отображения статистики
 */
function mod_counter($counter_id, $action = '')
{
    $counter_id = preg_replace('/\\D/', '', $counter_id);
    // Если для счетчика установлен id больше 0 и указан параметр show, тогда
    if ($counter_id > 0 && $action == '-show') {
        // Подключаем основной файл с классом, создаем объект, подключаем языковые переменные
        // и обращаемся к методу counterStatisticShow() для вывода информации
        require_once BASE_DIR . '/modules/counter/class.counter.php';
        $counter = new Counter();
        $tpl_dir = BASE_DIR . '/modules/counter/templates/';
        $lang_file = BASE_DIR . '/modules/counter/lang/' . $_SESSION['user_language'] . '.txt';
        $counter->counterStatisticShow($tpl_dir, $lang_file, $counter_id);
    } elseif ($counter_id > 0 && !(empty($_SERVER['REMOTE_ADDR']) && empty($_SERVER['HTTP_CLIENT_IP'])) && !(isset($_COOKIE['counter_' . $counter_id]) && $_COOKIE['counter_' . $counter_id] == '1')) {
        // Подключаем основной файл с классом, создаем объект и добавляем нового пользователя в статистику
        require_once BASE_DIR . '/modules/counter/class.counter.php';
        $counter = new Counter();
        $counter->counterClientNew($counter_id);
    }
}
Example #9
0
 /**
  * Run the database counter seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->command->info('Seeding all activities...');
     $seeds = $this->getSeeds(Activity::distinct('_id')->get());
     foreach ($seeds as $name => $seed) {
         $this->command->info('Seed: ' . $name . ' = ' . $seed);
         $counter = new Counter();
         $counter['_id'] = $name;
         $counter['seq'] = $seed;
         $counter->save();
     }
     $this->command->info('Seeding all entities...');
     $seeds = $this->getSeeds(Entity::distinct('_id')->get());
     foreach ($seeds as $name => $seed) {
         $this->command->info('Seed: ' . $name . ' = ' . $seed);
         $counter = new Counter();
         $counter['_id'] = $name;
         $counter['seq'] = $seed;
         $counter->save();
     }
 }
Example #10
0
 private function _run()
 {
     if ($this->predefinedId) {
         $widgetCounter = $this->predefinedId;
     } else {
         $widgetCounter = Counter::getInstance()->getNext();
     }
     /* update parameters in case of any changes */
     foreach ($this->validParameters as $parameter) {
         if (isset($this->{$parameter})) {
             $this->parameters[$parameter] = $this->{$parameter};
         }
     }
     global $baseUrl;
     $json = file_get_contents("{$baseUrl}/list-api.php?" . http_build_query($this->parameters));
     $response = json_decode($json, true);
     $this->widget = new TListWidget($response, $widgetCounter);
 }
Example #11
0
 /**
  * @static
  * @param SimpleXMLElement $xml
  */
 public static function fromXML(SimpleXMLElement $xml)
 {
     $context = new Context();
     $context->id = (string) $xml['id'];
     $context->status = (string) $xml->status;
     if ($xml->quotaPerDay) {
         $context->quotaPerDay = Counter::fromXML($xml->quotaPerDay);
     }
     if ($xml->quotaPerMonth) {
         $context->quotaPerMonth = Counter::fromXML($xml->quotaPerMonth);
     }
     if ($xml->quotaPerWeek) {
         $context->quotaPerWeek = Counter::fromXML($xml->quotaPerWeek);
     }
     if ($xml->rateLimitPerMinute) {
         $context->rateLimitPerMinute = Counter::fromXML($xml->rateLimitPerMinute);
     }
     if ($xml->rateLimitPerSecond) {
         $context->rateLimitPerSecond = Counter::fromXML($xml->rateLimitPerSecond);
     }
     return $context;
 }
Example #12
0
 public function incrementCounter($id)
 {
     $C = new Counter();
     $newvalue = $C->increment($id);
     echo json_encode(['id' => $id, 'count' => $newvalue]);
 }
Example #13
0
        $nsid = $pageObj->get_namespace();
        $nscolon = $nsid ? $nsname . ":" : "";
        $page_title = $pageObj->get_title(false);
        $page_id = $pageObj->get_id();
    } catch (Exception $e) {
        $wt->error = $e->getMessage() . " (topedits::pageObj)";
        $wt->showPage();
    }
    if (!$page_id || $page_id == 0) {
        $wt->toDie('nosuchpage', $page . " ({$domain})");
    }
    $list = getPageEditsPerUser($dbr, $page_id, $domain, $users, $wi);
    $wt->content = getPageTemplate('resultpage');
    $userprefix = '';
} else {
    $cnt = new Counter($dbr, $user, $domain, true);
    if ($cnt->optin) {
        $wt->content = getPageTemplate('resultns');
        $nscolon = $page_title = "";
        $nsnames = $cnt->getNamespaces();
        $list = getTopEditsByNamespace($dbr, $wi, $ui, $nsnames, $namespace);
    } else {
        $nsnames = $cnt->getNamespaces();
        $wt->content = getPageTemplate('resultns');
        $list = $I18N->msg("nograph", array("variables" => array($cnt->getOptinLinkLocal(), $cnt->getOptinLinkGlobal()))) . "<br /> " . $I18N->msg('nograph2', array("variables" => array($wt->linkOauthHelp)));
    }
    $userprefix = $nsnames["names"][2];
}
$wt->assign('list', $list);
$wt->assign('page', $nscolon . $page_title);
$wt->assign('urlencodedpage', rawurlencode(str_replace(" ", "_", $nscolon . $page_title)));
Example #14
0
 function GetCounterByID($id)
 {
     $m = new Counter();
     if ($id > 0) {
         $m->LoadInfoByID($id);
     }
     return $m;
 }
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<html>
<body>

<?php 
echo "Test for PHP-DAO insert method";
$db = new Counter();
$db->open();
$row = new CRow();
echo "<br> PASSED: new CRow";
$row->addColumn("name", "test");
echo "<br> PASSED: row->addColumn";
$db->insert("person", $row);
echo "<br> PASSED: row->insert";
$rows = new CRows();
echo "<br> PASSED: CRows";
echo "<br> size:";
print $rows->size();
echo "<br> PASSED: rows->size()";
$rows->pushBack($row);
echo "<br> PASSED: rows->pushBack()";
echo "<br> size:";
print $rows->size();
$db->read($rows);
echo "<br>  PASSED: data accessor read";
$it = $rows->createIterator();
echo "<br> PASSED: createIterator";
for ($it->first(); !$it->isDone(); $it->next()) {
    $row_it = $it->currentItem();
    echo "<br> ";
Example #16
0
<?php

class Counter
{
    public static function digitsCount($string)
    {
        $counter = 0;
        foreach (str_split($string) as $value) {
            if ((int) $value || $value == '0') {
                $counter++;
            }
        }
        return $counter;
    }
}
echo Counter::digitsCount('sd02fg3sdfgs2dfgs23dfg');
Example #17
0
        self::$count++;
    }
    // Деструктор же - уменьшает.
    public function __destruct()
    {
        self::$count--;
    }
    // Статическая функция, возвращает счетчик объектов.
    public static function getCount()
    {
        return self::$count;
    }
}
// Создаем 6 объектов.
for ($objs = [], $i = 0; $i < 6; $i++) {
    $objs[] = new Counter();
}
// Статические функции можно вызывать точно так же, как будто
// бы это - обычный метод объекта. При этом $this все равно
// не передается, он просто игнорируется.
echo "Сейчас существует {$objs[0]->getCount()} объектов.<br />";
// Удаляем один объект.
$objs[5] = null;
// Счетчик объектов уменьшится!
echo "А теперь - {$objs[0]->getCount()} объектов.<br />";
// Удаляем все объекты.
$objs = [];
// Другой способ вызова статического метода - с указанием класса.
// Это очень похоже на вызов функции из библиотеки.
echo "Под конец осталось - " . Counter::getCount() . " объектов.<br />";
Example #18
0
   $wgDBPass,
   'toolserver',
   true
);*/
$dbInfo = $fnc->getDBInfo($lang, $wiki);
if (isset($dbInfo['error']) && $wiki != "wikidata") {
    $fnc->toDie($phptemp->getConf('nowiki', $url));
}
$wgDBname = $dbInfo['dbname'];
$wgDBserver = $dbInfo['server'];
$dbr = new Database($wgDBserver, $wgDBPort, $wgDBUser, $wgDBPass, $wgDBname, true);
if ($dbInfo['server'] == 1) {
    $fnc->toDie("In order to both discourage editcountitis and give the English Wikipedia editors a chance to realize what editing is all about and why I created this tool in the first place, I have disabled my edit counters (pcount, simplecount, autoedits) until August 17 2010. Please use this time to reflect on why I made this tool in the first place: To serve curiosity, not to create false judgement descisions about editors. -X! 13 August 2010");
}
$wgNamespaces = $fnc->getNamespaces('enwiki_p');
$cnt = new Counter($name);
$graphArray = array('colors' => array(0 => 'FF5555', 1 => '55FF55', 2 => 'FFFF55', 3 => 'FF55FF', 4 => '5555FF', 5 => '55FFFF', 6 => 'C00000', 7 => '0000C0', 8 => '008800', 9 => '00C0C0', 10 => 'FFAFAF', 11 => '808080', 12 => '00C000', 13 => '404040', 14 => 'C0C000', 15 => 'C000C0', 100 => '75A3D1', 101 => 'A679D2', 102 => '660000', 103 => '000066', 104 => 'FAFFAF', 105 => '408345', 106 => '5c8d20', 107 => 'e1711d', 108 => '94ef2b', 109 => '756a4a', 110 => '6f1dab', 111 => '301e30', 112 => '5c9d96', 113 => 'a8cd8c', 114 => 'f2b3f1', 115 => '9b5828', 118 => '99FFFF', 119 => '99BBFF', 120 => 'FF99FF', 121 => 'CCFFFF', 122 => 'CCFF00', 123 => 'CCFFCC', 200 => '33FF00', 201 => '669900', 202 => '666666', 203 => '999999', 204 => 'FFFFCC', 205 => 'FF00CC', 206 => 'FFFF00', 207 => 'FFCC00', 208 => 'FF0000', 209 => 'FF6600', 446 => '06DCFB', 447 => '892EE4', 460 => '99FF66', 461 => '99CC66', 470 => 'CCCC33', 471 => 'CCFF33', 480 => '6699FF', 481 => '66FFFF', 490 => '995500', 491 => '998800', 710 => 'FFCECE', 711 => 'FFC8F2', 828 => 'F7DE00', 829 => 'BABA21', 866 => 'FFFFFF', 867 => 'FFCCFF', 1198 => 'FF34B3', 1199 => '8B1C62'), 'names' => $wgNamespaces['names'], 'monthly' => $cnt->getMonthTotals(), 'gross' => $cnt->getNamespaceTotals());
$graph = new Graph($graphArray, IPHONE);
$uniqueEdits = $cnt->getUniqueArticles();
if (!$cnt->getExists()) {
    $fnc->toDie($phptemp->getConf('nosuchuser', $cnt->getName()));
}
$phptemp->assign("page", $cnt->getName());
$content->assign("username", $cnt->getName());
$content->assign("usernameurl", rawurlencode($cnt->getName()));
$content->assign("url", $url);
$content->assign("loadwiki", "&wiki={$wiki}&lang={$lang}");
if (count($cnt->getGroupList())) {
    $content->assign("groups", implode(', ', $cnt->getGroupList()));
}
if ($cnt->getLive() > 0) {
Example #19
0
 /**
  * Load AEB Types from counter, to parse (semi) automated edits
  */
 function loadAEBTypes()
 {
     try {
         require_once 'Counter.php';
         $this->AEBTypes = Counter::getAEBTypes();
     } catch (Exception $e) {
         $this->AEBTypes = null;
     }
 }
Example #20
0
?>

 

<!-- // $foo= new Bidule();
// if($foo->getTruc()){
// 	echo 'le truc est vrai';
// } else {
// 	echo "le truc est faux";
// }  -->


	
<ul>
<?php 
$counters = new Counter();
foreach ($counters->all() as $c) {
    ?>
	<li><a href="?id=<?php 
    echo $c->id;
    ?>
&p=show"><?php 
    echo $c->name;
    ?>
</a></li>

<?php 
}
?>
</ul>
<?php 
Example #21
0
 function add()
 {
     if (bff::$isAjax) {
         $this->input->postm(array('id' => TYPE_UINT, 'pass' => TYPE_NOHTML, 'cat' => TYPE_ARRAY_UINT, 'reg' => TYPE_ARRAY_UINT, 'contacts' => TYPE_ARRAY_NOHTML, 'title' => TYPE_NOTAGS, 'descr' => TYPE_NOTAGS, 'info' => TYPE_NOTAGS, 'img' => TYPE_ARRAY_NOHTML, 'imgfav' => TYPE_NOHTML, 'price' => TYPE_NUM, 'price_torg' => TYPE_BOOL, 'price_bart' => TYPE_BOOL, 'video' => TYPE_NOHTML, 'period' => TYPE_UINT, 'captcha' => TYPE_NOTAGS), $p);
         if ($_COOKIE['c4'] != md5($p['captcha'])) {
             $this->ajaxResponse(Errors::WRONGCAPTCHA);
         }
         $nUserID = $this->security->getUserID();
         $isEdit = false;
         if ($p['id'] > 0 && !empty($p['pass'])) {
             $sqlCheck = ' WHERE id = ' . $p['id'] . ' AND status = ' . BBS_STATUS_NEW . ' AND pass = '******'pass']);
             if ($this->security->isMember()) {
                 $sqlCheck .= ' AND user_id = ' . $nUserID;
             }
             $res = $this->db->one_data('SELECT id FROM ' . TABLE_BBS_ITEMS . $sqlCheck);
             if (empty($res)) {
                 $this->ajaxResponse(Errors::ACCESSDENIED);
             }
             $isEdit = true;
         }
         $sBannedByIP = $this->security->checkBan(false, func::getRemoteAddress(), false, true);
         if ($sBannedByIP) {
             $this->errors->set(Errors::ACCESSDENIED);
             //не прошли бан-фильтр
         }
         $this->input->clean_array($p['cat'], array(1 => TYPE_UINT, 2 => TYPE_UINT, 3 => TYPE_UINT, 'type' => TYPE_UINT, 'subtype' => TYPE_UINT));
         $this->input->clean_array($p['reg'], array(1 => TYPE_UINT, 2 => TYPE_UINT, 3 => TYPE_UINT));
         $nCategoryID = $p['cat'][3] ? $p['cat'][3] : ($p['cat'][2] ? $p['cat'][2] : ($p['cat'][1] ? $p['cat'][1] : 0));
         if (!$nCategoryID) {
             $this->errors->set('select:category');
         }
         $p['cat']['type'] = isset($p['cat']['type']) && $p['cat']['type'] > 0 ? abs(intval($p['cat']['type'])) : 0;
         $p['cat']['subtype'] = isset($p['cat']['subtype']) && $p['cat']['subtype'] > 0 ? abs(intval($p['cat']['subtype'])) : 0;
         $aDynpropsData = $this->input->post('dp', TYPE_ARRAY);
         if (!empty($aDynpropsData)) {
             $dp = $this->initDynprops();
             $aDynpropsData = $dp->prepareSaveDataByID($aDynpropsData, $dp->getByID(array_keys($aDynpropsData)), $isEdit ? 'update' : 'insert');
         }
         $sRegionsTitle = '';
         if (!empty($p['reg'])) {
             $aRegions = $this->db->select('SELECT title, numlevel FROM ' . TABLE_BBS_REGIONS . ' WHERE id IN(' . join(',', $p['reg']) . ') ORDER BY numlevel');
             if (!empty($aRegions)) {
                 $aRegions = func::array_transparent($aRegions, 'numlevel', true);
                 $nRegionStart = 1;
                 if (sizeof($aRegions) == 1) {
                     $sRegionsTitle = $aRegions[$nRegionStart]['title'];
                 } else {
                     if (sizeof($aRegions) == 3) {
                         $nRegionStart = 2;
                     }
                     $sRegionsTitle = $aRegions[$nRegionStart]['title'] . ($aRegions[$nRegionStart + 1] ? ', ' . $aRegions[$nRegionStart + 1]['title'] : '');
                 }
             }
         }
         if ($this->errors->no()) {
             if (!isset($p['contacts']['site']) || empty($p['contacts']['site'])) {
                 $p['contacts']['site'] = '';
             }
             $p['contacts']['site'] = str_replace(array('http://', 'https://', 'ftp://'), '', $p['contacts']['site']);
             $adtxtLimit = config::get('bbs_adtxt_limit');
             if (!empty($adtxtLimit)) {
                 $p['descr'] = mb_substr($p['descr'], 0, $adtxtLimit);
             }
             $p['descr'] = func::cleanComment($p['descr']);
             $p['info'] = func::cleanComment($p['info']);
             include_once 'counter.php';
             $word_counter = new Counter();
             $content = $p['descr'];
             if (strlen($content) > 50000) {
                 $keywords = $word_counter->get_keywords(substr($content, 0, 50000));
             } else {
                 $keywords = $word_counter->get_keywords($content);
             }
             $mdescription = substr($content, 0, 250);
             $sqlNOW = $this->db->getNOW();
             $sUID = $this->security->getUID(false, 'post');
             // Превышен лимит бесплатных объявлений с одинаковой контактной информацией. Каждое последующее объявление становится платным.
             $bPayPublication = !$this->checkFreePublicationsLimit($p['cat'][1], $nUserID, $sUID);
             if ($isEdit) {
                 $res = $this->db->execute('UPDATE ' . TABLE_BBS_ITEMS . ' SET
                     user_id = ' . $nUserID . ', 
                     cat1_id = ' . $p['cat'][1] . ', cat2_id = ' . $p['cat'][2] . ',
                     cat_id = ' . $nCategoryID . ', cat_type = ' . $p['cat']['type'] . ', 
                     country_id = ' . $p['reg'][1] . ', region_id = ' . $p['reg'][2] . ', city_id = ' . $p['reg'][3] . ',  
                     img = :img, imgcnt = ' . sizeof($p['img']) . ', imgfav = :imgfav, 
                     price = ' . $p['price'] . ', price_torg = ' . $p['price_torg'] . ', price_bart = ' . $p['price_bart'] . ',   
                     contacts_name = :c_name, contacts_email = :c_email, contacts_phone = :c_phone, contacts_skype = :c_skype, contacts_site = :c_site, video = :video, 
                     title = :title, descr = :descr, descr_regions = :descr_regions, info = :info, mkeywords = :mkeywords, mdescription = :mdescription, modified = ' . $sqlNOW . '
                     ' . (!empty($aDynpropsData) ? $aDynpropsData : '') . '
                     WHERE id = ' . $p['id'] . '              
                 ', array(array(':img', join(',', $p['img']), PDO::PARAM_STR), array(':imgfav', $p['imgfav'], PDO::PARAM_STR), array(':c_name', isset($p['contacts']['name']) ? $p['contacts']['name'] : '', PDO::PARAM_STR), array(':c_email', isset($p['contacts']['email']) ? $p['contacts']['email'] : '', PDO::PARAM_STR), array(':c_phone', isset($p['contacts']['phone']) ? $p['contacts']['phone'] : '', PDO::PARAM_STR), array(':c_skype', isset($p['contacts']['skype']) ? $p['contacts']['skype'] : '', PDO::PARAM_STR), array(':c_site', isset($p['contacts']['site']) ? $p['contacts']['site'] : '', PDO::PARAM_STR), array(':video', $p['video'], PDO::PARAM_STR), array(':title', $p['title'], PDO::PARAM_STR), array(':descr', $p['descr'], PDO::PARAM_STR), array(':descr_regions', $sRegionsTitle, PDO::PARAM_STR), array(':info', $p['info'], PDO::PARAM_STR), array(':mkeywords', $keywords, PDO::PARAM_STR), array(':mdescription', $mdescription, PDO::PARAM_STR)));
                 $this->ajaxResponse(array('res' => $res === 1, 'pp' => $bPayPublication));
             } else {
                 $sPassword = func::generator(6);
                 $this->db->execute('INSERT INTO ' . TABLE_BBS_ITEMS . ' (
                     user_id, uid, status, cat1_id, cat2_id, cat_id, cat_type, cat_subtype,
                     country_id, region_id, city_id,  
                     img, imgcnt, imgfav, 
                     price, price_torg, price_bart,        
                     contacts_name, contacts_email, contacts_phone, contacts_skype, contacts_site, video, pass,
                     title, descr, descr_regions, info, mkeywords, mdescription, created, modified' . (!empty($aDynpropsData['fields']) ? $aDynpropsData['fields'] : '') . ')
                     VALUES (' . $nUserID . ', :uid, ' . BBS_STATUS_NEW . ', ' . $p['cat'][1] . ', ' . $p['cat'][2] . ', ' . $nCategoryID . ', ' . $p['cat']['type'] . ', ' . $p['cat']['subtype'] . ',
                         ' . (isset($p['reg'][1]) ? $p['reg'][1] : 0) . ',' . (isset($p['reg'][2]) ? $p['reg'][2] : 0) . ',' . (isset($p['reg'][3]) ? $p['reg'][3] : 0) . ',
                         :img, ' . sizeof($p['img']) . ', :imgfav,
                         ' . $p['price'] . ', ' . $p['price_torg'] . ', ' . $p['price_bart'] . ',
                         :c_name, :c_email, :c_phone, :c_skype, :c_site, :video, ' . $this->security->encodeBBSEditPass($sPassword) . ',
                         :title, :descr, :descr_regions, :info, :mkeywords, :mdescription, ' . $sqlNOW . ', ' . $sqlNOW . '
                         ' . (!empty($aDynpropsData['values']) ? $aDynpropsData['values'] : '') . '
                     )              
                 ', array(array(':uid', $sUID, PDO::PARAM_STR), array(':img', join(',', $p['img']), PDO::PARAM_STR), array(':imgfav', $p['imgfav'], PDO::PARAM_STR), array(':c_name', isset($p['contacts']['name']) ? $p['contacts']['name'] : '', PDO::PARAM_STR), array(':c_email', isset($p['contacts']['email']) ? $p['contacts']['email'] : '', PDO::PARAM_STR), array(':c_phone', isset($p['contacts']['phone']) ? $p['contacts']['phone'] : '', PDO::PARAM_STR), array(':c_skype', isset($p['contacts']['skype']) ? $p['contacts']['skype'] : '', PDO::PARAM_STR), array(':c_site', isset($p['contacts']['site']) ? $p['contacts']['site'] : '', PDO::PARAM_STR), array(':video', $p['video'], PDO::PARAM_STR), array(':title', $p['title'], PDO::PARAM_STR), array(':descr', $p['descr'], PDO::PARAM_STR), array(':descr_regions', $sRegionsTitle, PDO::PARAM_STR), array(':info', $p['info'], PDO::PARAM_STR), array(':mkeywords', $keywords, PDO::PARAM_STR), array(':mdescription', $mdescription, PDO::PARAM_STR)));
                 $nItemID = $this->db->insert_id(TABLE_BBS_ITEMS, 'id');
                 $aResponse = array();
                 if ($nItemID && $this->errors->no()) {
                     # накручиваем счетчики кол-во объявлений:
                     # у пользователя (владельца объявления)
                     if ($nUserID) {
                         $this->db->execute('UPDATE ' . TABLE_USERS . ' 
                             SET items = items+1 WHERE user_id = ' . $nUserID);
                     } else {
                         $this->grantEditPass($nItemID);
                         // разрешаем редактирование по паролю для текущей сессии
                     }
                     if (sizeof($p['img']) > 0) {
                         $oImages = $this->initImages();
                         foreach ($p['img'] as $sImgFilename) {
                             $oImages->renameImageFileCustom($this->items_images_path, $nItemID, $sImgFilename);
                         }
                     }
                 }
                 $this->security->setSESSION('BBS_ITEM_PUBLISHED_ID', 0);
                 $this->ajaxResponse(array('id' => $nItemID, 'pass' => $sPassword, 'res' => $this->errors->no(), 'pp' => $bPayPublication));
             }
         }
         $this->ajaxResponse(null);
     }
     $aData['cats'] = $this->db->select('SELECT id, title FROM ' . TABLE_BBS_CATEGORIES . ' WHERE numlevel = 1 AND enabled = 1 ORDER BY numleft');
     $aData['regions'] = $this->db->select('SELECT R.id, R.pid, R.title
                                    FROM ' . TABLE_BBS_REGIONS . ' R, ' . TABLE_BBS_REGIONS . ' R2
                                    WHERE R.numlevel IN(1,2) AND R.enabled = 1 AND (R.pid = 0 OR (R.pid = R2.id AND R2.enabled = 1)) ORDER BY R.main DESC, R.num, R.title');
     $aData['regions'] = $this->db->transformRowsToTree($aData['regions'], 'id', 'pid', 'sub');
     $aData['contacts'] = array();
     if ($this->security->isLogined()) {
         //берем контакты пользователя
         $aData['contacts'] = $this->security->getUserInfo('contacts');
         if (!empty($aData['contacts'])) {
             $c = $aData['contacts']['other'];
             unset($aData['contacts']['other']);
             if (is_array($c)) {
                 foreach ($c as $v) {
                     if ($v['type'] == 1) {
                         $aData['contacts']['skype'] = $v['data'];
                         break;
                     }
                 }
             }
         }
     }
     $this->input->clean_array($aData['contacts'], array('name' => TYPE_STR, 'phone' => TYPE_STR, 'email2' => TYPE_STR, 'skype' => TYPE_STR));
     $aConfig = array('add_instruct1', 'add_instruct2', 'add_instruct3', 'add_instruct4', 'adtxt_limit');
     $aConfig[] = 'images_limit' . ($this->security->isMember() ? '_reg' : '');
     $aData['config'] = config::get($aConfig, false, $this->module_name . '_');
     config::set('bbs_instruction', true);
     $this->tplAssign('bbsInstructions', array('i' => $aData['config'], 'cur' => 1));
     $this->includeJS(array('bbs.txt', 'bbs.add'));
     $this->includeJS(array('swfupload/swfupload'), false, true);
     return $this->tplFetchPHP($aData, 'item.add.php');
 }
Example #22
0
<?php

class Counter
{
    private static $count = 0;
    function __construct()
    {
        echo '<b>计数开始!</b><br/><br/>';
    }
    function __destruct()
    {
        echo '<b>计数结束!</b><br/><br/>';
    }
    static function get_count()
    {
        return self::$count;
    }
    static function counts()
    {
        self::$count++;
    }
}
$c = new Counter();
$i = 0;
while ($i < 5) {
    Counter::counts();
    $i = Counter::get_count();
    echo Counter::get_count() . "<br/><br/>";
}
Example #23
0
    'sql-toolserver', 
    $wgDBPort, 
    $wgDBUser, 
    $wgDBPass, 
    'toolserver', 
    true
);*/
$dbInfo = $fnc->getDBInfo($lang, $wiki);
if (isset($dbInfo['error'])) {
    toDie($phptemp->getConf('nowiki', $url));
}
$wgDBname = $dbInfo['dbname'];
$wgDBserver = $dbInfo['server'];
$dbr = new Database($wgDBserver, $wgDBPort, $wgDBUser, $wgDBPass, $wgDBname, true);
$wgNamespaces = $fnc->getNamespaces('enwiki_p');
$cnt = new Counter($name);
$final_array = array('query' => array('count' => array()));
$retUser = $cnt->getName();
$retIP = $cnt->getIP() ? "true" : "false";
$retExists = $cnt->getExists() ? "true" : "false";
$retUID = $cnt->getUID();
$retDeleted = intval($cnt->getDeleted());
$retLive = intval($cnt->getLive());
$retTotal = intval($cnt->getTotal());
$retGroupList = $cnt->getGroupList();
$retGroupList['_element'] = 'g';
//$retUniqueArticles = $cnt->getUniqueArticles();
//$retUniqueArticleCount = number_format( count($retUniqueArticles['total']) );
$retFirstEdit = $cnt->getFirstEdit();
$retAveragePageEdits = $cnt->getAveragePageEdits();
$retMonthTotals = $cnt->getMonthTotals();
Example #24
0
        <legend>Показания счетчика</legend>
        <table  class="table table-striped">
            <thead>
                <tr>	
                    <th>Пользователь</th>
                    <th>Последние показания</th>
                </tr>
            </thead>
            <tbody>
                <?php 
    $join = "INNER JOIN koncentrator_tovarishestvo c ON(user.concetrator = c.name_konc)";
    $users = User::all(array('conditions' => array("is_admin <> ? and id_tovar= ?", 1, $id), 'joins' => $join));
    if (!is_null($users)) {
        foreach ($users as $user) {
            $str = 'sum(reading)';
            $last = Counter::find('first', ['order' => 'date desc', 'conditions' => ['counter =? and concetrator=?', $user->counter, $user->concetrator]]);
            ?>
                        <tr>
                            <td><?php 
            echo $user->fio;
            ?>
</td>
                            <td><div data-toggle="modal" data-target="#squarespaceModal" class="center-block"><?php 
            echo $last->reading;
            ?>
</div></td>
                        </tr>
                        <?php 
        }
    }
    ?>
Example #25
0
################################################################################
$time_start = microtime_float();
$CNT = 200;
$mode = 'mg';
if ('s' == $mode) {
    for ($i = 0; $i < $CNT; $i++) {
        if (mt_rand(0, 1)) {
            $cnt = new Counter('AnySlot', $i);
            echo '<h2>' . $cnt->increment() . '</h2>';
        }
    }
}
if ('g' == $mode) {
    $rez = array();
    for ($i = 1; $i <= $CNT; $i++) {
        $cnt = new Counter('AnySlot', $i);
        $rez[$i] = $cnt->get();
    }
    echo "<hr><pre>";
    var_export($rez);
    echo '</pre><hr>';
}
if ('mg' == $mode) {
    $keys = array_keys(array_fill(1, $CNT, 1));
    echo "<hr><pre>";
    var_export(Counter::mget('AnySlot', $keys));
    //var_export( Counter::mget('AnySlot',$keys, TRUE) );
    echo '</pre><hr>';
}
//;
//$cnt->set_updelim(0);
Example #26
0
$wt->setLimits();
$wt->getPageTemplate("form");
$wi = $wt->wikiInfo;
$lang = $wi->lang;
$wiki = $wi->wiki;
$domain = $wi->domain;
$ui = $wt->getUserInfo();
$user = $ui->user;
$begin = $wt->checkDate($wgRequest->getVal('begin'));
$end = $wt->checkDate($wgRequest->getVal('end'));
//Show form if &article parameter is not set (or empty)
if (!$lang || !$wiki || !$user) {
    $wt->showPage();
}
$dbr = $wt->loadDatabase($lang, $wiki);
$cnt = new Counter($dbr, $user, $domain, true);
//Start doing the DB request
$data = $cnt->calcAutoEditsDB($dbr, $begin, $end);
$list = '';
foreach ($data["tools"] as $toolname => $count) {
    $list .= '
				<tr>
				<td><a href="//en.wikipedia.org/wiki/' . Counter::$AEBTypes[$toolname]["shortcut"] . '">' . $toolname . '</a></td>
				<td class="tdnum" >' . $wt->numFmt($count) . '</td>
				</tr>
			';
}
$wt->content = getPageTemplate("result");
$wt->assign('list', $list);
$wt->assign('username', $user);
$wt->assign('usernameurl', rawurlencode($user));
Example #27
0
    echo file_get_contents($filename);
    exit;
} else {
    include_once DIR_ADDONS . "/price_list/lib/writeexcel/class.writeexcel_workbook.inc.php";
    include_once DIR_ADDONS . "/price_list/lib/writeexcel/class.writeexcel_worksheet.inc.php";
    include_once DIR_ADDONS . '/price_list/core/class.counter.php';
    //include_once DIR_ADDONS . '/price_list/core/class.convert_to_bmp.php'; // FIX ME! We do not need it until resolve the compability problem.
    //$bmp = new ConvertToBMP();
    if (isset($selected_fields['image'])) {
        unset($selected_fields['image']);
        //// FIX ME! The image compability problem
    }
    $col = 'A';
    $row = 1;
    $width = array();
    $counter = new Counter(100, '.');
    $workbook =& new writeexcel_workbook($filename);
    $worksheet =& $workbook->addworksheet(fn_get_lang_var('price_list'));
    $field_heading =& $workbook->addformat(array(bold => FIELD_HEADING_BOLD, size => FIELD_HEADING_FONT_SIZE, font => FIELD_HEADING_FONT_FAMILY, align => FIELD_HEADING_ALIGN));
    $category_heading =& $workbook->addformat(array(bold => CATEGORY_HEADING_BOLD, size => CATEGORY_HEADING_FONT_SIZE, font => CATEGORY_HEADING_FONT_FAMILY, merge => CATEGORY_HEADING_MERGE, bg_color => CATEGORY_HEADING_BG_COLOR, color => CATEGORY_HEADING_FONT_COLOR, align => CATEGORY_HEADING_ALIGN));
    $field_simple =& $workbook->addformat(array(bold => FIELD_BOLD, size => FIELD_FONT_SIZE, font => FIELD_FONT_FAMILY, bottom => FIELD_BOTTOM_BORDER, bottom_color => FIELD_BOTTOM_BORDER_COLOR, align => FIELD_ALIGN, text_wrap => FIELD_TEXT_WRAP, num_format => FIELD_NUM_FORMAT));
    $field_simple_odd =& $workbook->addformat(array(bold => FIELD_BOLD, size => FIELD_FONT_SIZE, font => FIELD_FONT_FAMILY, bottom => FIELD_BOTTOM_BORDER, bottom_color => FIELD_BOTTOM_BORDER_COLOR, align => FIELD_ALIGN, text_wrap => FIELD_TEXT_WRAP, num_format => FIELD_NUM_FORMAT, bg_color => FIELD_BG_COLOR));
    if (Registry::get('addons.price_list.group_by_category') == "Y") {
        // Display products according to the categories names.
        fn_echo(fn_get_lang_var('generating_xls') . '<br />');
        // Group the products by categories
        // Prepare XLS data
        $categories = fn_get_plain_categories_tree(0, false);
        foreach ($categories as $category) {
            if ($category['product_count'] == 0) {
                continue;
Example #28
0
 function __construct($id, $width, $height, $data)
 {
     $this->data = $data;
     $this->id = $id;
     $counter = new Counter(array($width, $height));
     $counter->event = array($this, 'element');
     $counter->tick_all();
 }
Example #29
0
<?php

echo '<hr>memory_get_usage: ' . memory_get_usage() / 1024 . 'Κα<br>';
require './config/Counter.php';
require './src/class.counter.php';
require './src/class.memstore.php';
require './src/class.redis.php';
function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
################################################################################
$time_start = microtime_float();
$cnt = new Counter('AnySlot', 22);
//$cnt->set_updelim(0);
echo '<h2>$cnt->get() = ' . $cnt->get() . '</h2>';
//echo '<h2>$cnt->del() = '.(int)$cnt->del().'</h2>';
echo '<h2>$cnt->increment() = ' . $cnt->increment() . '</h2>';
//echo '<h2>'.$cnt->get().'</h2>';
//echo $cnt->set(11);
echo '<hr>memory get: ' . memory_get_usage() / 1024 . 'Κα<br>';
echo '<hr>memory peak: ' . memory_get_peak_usage() / 1024 . 'Κα<br>';
echo '<hr>time: ' . (microtime_float() - $time_start) * 1000 . ' ms<br>';
Example #30
0
define('TABLE_CELLSPACING', 0);
// Min column width in percent
$min_width = array('product' => 50, 'product_code' => 13, 'image' => 10);
error_reporting(E_ERROR);
ini_set('display_errors', '1');
set_time_limit(0);
fn_price_list_timer();
// Start timer;
$filename = fn_get_cache_path() . 'price_list/price_list_' . CART_LANGUAGE . '.pdf';
// Must be unique for each pdf mode.
if (Storage::instance('assets')->isExist($filename)) {
    Storage::instance('assets')->get($filename);
    exit;
} else {
    include_once Registry::get('config.dir.addons') . '/price_list/core/class.counter.php';
    $counter = new Counter(100, '.');
    $selected_fields = Registry::get('addons.price_list.price_list_fields');
    $max_perc = 100;
    $field_count = count($selected_fields);
    // First step. Check for the min width.
    $perc = intval($max_perc / $field_count);
    foreach ($selected_fields as $field_name => $active) {
        if (isset($min_width[$field_name])) {
            if ($min_width[$field_name] > $perc) {
                $max_perc -= $min_width[$field_name];
                $field_count--;
            }
        }
    }
    // Second step. Set up the new width values.
    $perc = intval($max_perc / $field_count);