/** * @param string $date * @param int $value * @return bool */ public function setValue($date, $value) { $stmt = Database::get()->prepare('INSERT INTO luckyNumbers (date, value) VALUES (:date, :value) ON DUPLICATE KEY UPDATE value=:value'); $stmt->bindParam(':date', $date, PDO::PARAM_STR); $stmt->bindParam(':value', $value, PDO::PARAM_INT); return $stmt->execute(); }
/** * Updates bells * @param array $value * @return bool */ public function set($value) { $stmt = Database::get()->prepare('UPDATE bells SET value=:value LIMIT 1'); $stmt->bindValue(':value', json_encode($value)); $stmt->execute(); return $stmt->rowCount() > 0; }
public function delete($class) { $stmt = Database::get()->prepare('DELETE FROM timetables WHERE class=:class'); $stmt->bindParam(':class', $class); $stmt->execute(); return $stmt->rowCount() > 0; }
/** * @param string $name * @param string $value * @return bool True if success */ public function setValue($name, $value) { $stmt = Database::get()->prepare('INSERT INTO settings (name, value) VALUES (:name, :value) ON DUPLICATE KEY UPDATE value=:value'); $stmt->bindParam(':name', $name, PDO::PARAM_STR); $stmt->bindParam(':value', $value, PDO::PARAM_STR); return $stmt->execute(); }
/** * @param int $pageId * @param int $limit * @return array */ public static function getStatistics($pageId, $limit) { $stmt = Database::get()->prepare('SELECT date, version, count(*) AS uniqueVisits, sum(count) AS visits FROM statistics WHERE pageId=:pageId GROUP BY date, version ORDER BY date DESC, version DESC LIMIT :limit'); $stmt->bindParam(':pageId', $pageId, \PDO::PARAM_INT); $stmt->bindParam(':limit', $limit, \PDO::PARAM_INT); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_CLASS, 'pjanczyk\\lo1olkusz\\Model\\Statistic'); }
public function run() { Database::init(Config::getInstance()->getDatabaseConfig()); $url = self::URL; $dom = SimpleHtmlDom::fromUrl($url); if ($dom === false) { echo "cannot get {$url}\n"; return; } $this->updateLuckyNumbers($dom); $this->updateReplacements($dom); echo "done\n"; }
/** * @param string $class * @param string $date * @param int $value * @return bool */ public function setValue($class, $date, $value) { $stmt = Database::get()->prepare('INSERT INTO replacements (class, date, value) VALUES (:class, :date, :value) ON DUPLICATE KEY UPDATE value=:value'); $stmt->bindParam(':class', $class, PDO::PARAM_STR); $stmt->bindParam(':date', $date, PDO::PARAM_STR); $stmt->bindValue(':value', json_encode($value), PDO::PARAM_STR); return $stmt->execute(); }
* (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL | E_STRICT); require 'autoloader.php'; require 'config.php'; use pjanczyk\lo1olkusz\Auth; use pjanczyk\lo1olkusz\Database; use pjanczyk\lo1olkusz\Router; use pjanczyk\lo1olkusz\Config; date_default_timezone_set('Europe/Warsaw'); session_start(); Database::init(Config::getInstance()->getDatabaseConfig()); Auth::$disableSSL = true; Auth::init(); $route = ['' => 'HomeController', 'contact' => 'ContactController', 'download' => 'DownloadController', 'dashboard' => ['' => 'Dashboard\\HomeController', 'login' => 'Dashboard\\LoginController', 'replacements' => 'Dashboard\\ReplacementController', 'lucky-numbers' => 'Dashboard\\LuckyNumberController', 'settings' => 'Dashboard\\SettingController', 'timetables' => 'Dashboard\\TimetableController', 'cron' => 'Dashboard\\CronController'], 'api' => 'ApiController']; $path = isset($_GET['p']) ? $_GET['p'] : ''; Router::newInstance()->setNamespace('pjanczyk\\lo1olkusz\\Controller\\')->setControllerMap($route)->setErrorCallback(function () { header('HTTP/1.0 404 Not Found'); include '404.html'; exit; })->route($path);