/** * Get the last update price. * * Has a cache. * * @param string $format DateTime format. * @return string Formatted date. */ function last_price_date($format = 'd/m/Y H:i') { static $lastdate = null; if ($lastdate === null) { $lastdate = query_value("SELECT MAX(price_date) AS lastdate FROM {$GLOBALS[T]('price')}", 'lastdate'); } $d = DateTime::createFromFormat('Y-m-d H:i:s', $lastdate); return $d->format($format); }
if (is_command($text, '/start')) { // Exists? $exists = query_row(sprintf("SELECT 1 FROM {$T('spotter')} " . "WHERE spotter_chat_ID = %d", $update['message']['chat']['id'])); // Insert if not exists $exists || insert_row('spotter', [new DBCol('spotter_chat_id', $update['message']['chat']['id'], 'd'), new DBCol('spotter_datetime', 'NOW()', '-')]); apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => "Benvenuto sul bot di <b>Spotted Unito</b>\n\n" . "Con questo bot, potrai inviare i tuoi appelli o confessioni anonimamente, a tutti coloro che seguono questo bot.\n" . "Per inviare uno spot, non ti resta altro che scrivere (indifferente se maiuscolo o minuscolo) <code>spotted messaggio</code>, dove al posto di <code>messaggio</code> dovrete scrivere" . " il testo desiderato. (Es. <code>spotted Un saluto a tutti!</code>)\n\nNB: attualmente non sono supportate le emoticon", 'parse_mode' => "HTML", 'disable_web_page_preview' => true]); apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => "Un messaggio di conferma apparirà successivamente. Da quel momento, il messaggio, appena " . "i moderatori avranno verificato che non contenga parole inappropriate (bestemmie, minacce, offese, ecc...), verrà pubblicato." . "\n\nIn caso di necessità, premere su /help , oppure inviare un messaggio con <code>/help messaggio</code>.", 'parse_mode' => "HTML", 'disable_web_page_preview' => true]); } elseif (stripos($text, 'spotted') === 0) { $spotted = ltrim(str_ireplace('spotted', '', $text)); if (strlen($spotted) === 0) { apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => _("Il comando <code>spotted</code> è esatto. Tuttavia, per inviare uno spot, deve essere seguito da un messaggio.\n" . "Es. Spotted Chi da l'esame al posto mio domani?"), 'parse_mode' => 'HTML']); } else { $spotted = str_truncate($spotted, 1000, '...'); insert_row('spotted', [new DBCol('spotted_datetime', 'NOW()', '-'), new DBCol('spotted_message', $spotted, 's'), new DBCol('spotted_chat_id', $update['message']['chat']['id'], 'd'), new DBCol('spotted_approved', 0, '-')]); refresh_admin_keyboard($update['message']['chat']['id'], $spotted, $first_name, $last_name, $username); $spotters = query_value("SELECT COUNT(*) as count FROM {$T('spotter')}", 'count'); apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => sprintf(_("Il messaggio\n<code>" . $spotted . "</code>\ne' stato acquisito ed ora è in coda di moderazione per esser mandato a <b>%d</b> persone.\n"), $spotters), 'parse_mode' => 'HTML']); } } elseif (is_command($text, 'Pubblica')) { $spotted_ID = (int) trim(str_replace('Pubblica', '', $text)); if ($spotted_ID) { query(sprintf("UPDATE {$T('spotted')} " . "SET " . "spotted_approved = 1 " . "WHERE " . "spotted_ID = %d", $spotted_ID)); $spotters = query_results("SELECT spotter_ID FROM {$T('spotter')}", 'Spotter'); $fifo_rows = []; foreach ($spotters as $spotter) { $fifo_rows[] = [$spotted_ID, $spotter->spotter_ID]; } insert_values('fifo', ['spotted_ID' => 'd', 'spotter_ID' => 'd'], $fifo_rows); } refresh_admin_keyboard($update['message']['chat']['id'], "Messaggio pubblicato"); } elseif (is_command($text, 'Elimina')) {
<h1 class="hide-on-small-only"><?php echo HTML::a(URL, SITE_NAME, SITE_DESCRIPTION, 'orange-text'); ?> </h1> <h5 class="hide-on-med-and-up"><?php echo HTML::a(URL, SITE_NAME, SITE_DESCRIPTION, 'orange-text'); ?> </h5> <noscript> <p><?php _e("È necessario abilitare JavaScript. Tranquillo, viene utilizzato escusivamente software libero."); ?> </p> </noscript> <p><?php printf(_("Confronta velocemente i prezzi fra %s stazioni di rifornimento."), HTML::tag('b', query_value("SELECT COUNT(*) as count FROM {$T('station')}", 'count'), HTML::property('class', 'station-counter'))); ?> </p> <p class="last-update"><?php printf(_("Ultimo aggiornamento: %s."), "<time datetime=\"{$last_price_rfc3339}\">{$last_price_text}</time>"); ?> </p> <div class="divider"></div> <div class="section"> <a class="btn blue waves-effect waves-white" href="<?php echo URL; ?> /about.php" title="<?php _esc_attr(_("Maggiori informazioni")); ?> "><?php
// And now a lot of example doing the same thing in multiple way. /********************************************************************************** * First require your configuration file to start the framework. That's it! * Note: the page obviusly dies here if you have not configured you database access. **********************************************************************************/ require 'load.php'; // You can use `query` for a pure standard `mysqli` result. $results = query('SELECT NOW() AS miao'); while ($row = $results->fetch_object()) { printf("The database says that now it's '%s'", $row->miao); } // You can use `query_results` for an array of objects $results = query_results('SELECT NOW() AS miao'); foreach ($results as $result) { printf("The database says that now it's '%s'", $row->miao); } // You can use `query_result` for an object with only the first row $row = query_row('SELECT NOW() AS miao'); printf("The database says that now it's '%s'", $row->miao); // You can use `query_value` for only a single field from a single row: $miao = query_value('SELECT NOW() AS miao', 'miao'); printf("The database says that now it's '%s'", $miao); /* * Note that the last parameter of `query_results`, `query_row`, and `query_value` * can be a custom class name. To to something as this: * * @see MyClass.php */ require 'MyClass.php'; $row = query_row('SELECT NOW() AS miao', 'MyClass'); printf("The database says that now it's the year <b>%d</b> and the day is <b>%d</b>! " . "Time: %s. That is a clean PHP DateTime object retrieved with one line query!", $row->miao->format('Y'), $row->miao->format('d'), $row->miao->format('H:i'));
function zayav_spisok($v) { $filter = zayavFilter($v); $filter = _filterJs('ZAYAV', $filter); define('ZAYAV_PAGE1', $filter['page'] == 1); $page = $filter['page']; $limit = $filter['limit']; $cond = "`ws_id`=" . WS_ID . " AND !`deleted`"; $nomer = 0; if ($filter['find']) { $engRus = _engRusChar($filter['find']); $cond .= " AND (`find` LIKE '%" . $filter['find'] . "%'" . ($engRus ? " OR `find` LIKE '%" . $engRus . "%'" : '') . ")"; $reg = '/(' . $filter['find'] . ')/i'; if ($engRus) { $regEngRus = '/(' . $engRus . ')/i'; } if (ZAYAV_PAGE1 && _num($filter['find'])) { $nomer = intval($filter['find']); } } else { if ($filter['client_id']) { $cond .= " AND `client_id`=" . $filter['client_id']; } if ($filter['status']) { $cond .= " AND `status`=" . $filter['status']; } } $sql = "SELECT COUNT(*) FROM `zayav` WHERE " . $cond; $all = query_value($sql); $zayav = array(); if ($nomer) { $sql = "SELECT * FROM `zayav` WHERE `ws_id`=" . WS_ID . " AND `nomer`=" . $nomer; if ($r = query_assoc($sql)) { $all++; $limit--; $r['nomer_find'] = 1; $zayav[$r['id']] = $r; } } if (!$all) { return array('all' => 0, 'result' => 'Заявок не найдено' . $filter['clear'], 'spisok' => $filter['js'] . '<div class="_empty">Заявок не найдено</div>', 'filter' => $filter); } $send = array('all' => $all, 'result' => 'Показан' . _end($all, 'а', 'о') . ' ' . $all . ' заяв' . _end($all, 'ка', 'ки', 'ок') . $filter['clear'], 'spisok' => $filter['js'], 'filter' => $filter); $sql = "SELECT\n\t *,\n\t '' `note`\n\t\t\tFROM `zayav`\n\t\t\tWHERE " . $cond . "\n\t\t\tORDER BY `" . ($filter['sort'] == 2 ? 'status_dtime' : 'dtime_add') . "` " . ($filter['desc'] ? 'ASC' : 'DESC') . "\n\t\t\tLIMIT " . _startLimit($filter); $q = query($sql); while ($r = mysql_fetch_assoc($q)) { if ($nomer == $r['nomer']) { continue; } $zayav[$r['id']] = $r; } if (!$filter['client_id']) { $zayav = _clientValToList($zayav); } //Заметки $sql = "SELECT\n\t\t\t\t`table_id`,\n\t\t\t\t`txt`\n\t\t\tFROM `vk_comment`\n\t\t\tWHERE `table_name`='zayav'\n\t\t\t AND `table_id` IN (" . implode(',', array_keys($zayav)) . ")\n\t\t\t AND `status`\n\t\t\tORDER BY `id` ASC"; $q = query($sql); while ($r = mysql_fetch_assoc($q)) { $zayav[$r['table_id']]['note'] = $r['txt']; } foreach ($zayav as $id => $r) { $diff = round($r['accrual_sum'] - $r['income_sum'], 2); $send['spisok'] .= '<div class="zayav_unit" id="u' . $id . '"' . _zayavStatus($r['status'], 'bg') . '" val="' . $id . '">' . '<h2' . (isset($r['nomer_find']) ? ' class="finded"' : '') . '>#' . $r['nomer'] . '</h2>' . '<a class="name">' . $r['name'] . '</a>' . '<table class="utab">' . (!$filter['client_id'] ? '<tr><td class="label">Клиент:<td>' . $r['client_go'] : '') . '<tr><td class="label">Дата подачи:' . '<td>' . FullData($r['dtime_add'], 1) . ($r['status'] == 2 ? '<b class="date-ready' . _tooltip('Дата выполнения', -47) . FullData($r['status_dtime'], 1, 1) . '</b>' : '') . (round($r['accrual_sum'], 2) || round($r['income_sum'], 2) ? '<div class="balans' . ($diff ? ' diff' : '') . '">' . '<span class="acc' . _tooltip('Начислено', -39) . round($r['accrual_sum'], 2) . '</span>/' . '<span class="opl' . _tooltip($diff ? ($diff > 0 ? 'Недо' : 'Пере') . 'плата ' . abs($diff) . ' руб.' : 'Оплачено', -17, 'l') . round($r['income_sum'], 2) . '</span>' . '</div>' : '') . '</table>' . '<div class="note">' . @$r['note'] . '</div>' . '</div>'; } $send['spisok'] .= _next($filter + array('type' => 2, 'all' => $all)); return $send; }