<?php /* * @CODOLICENSE */ $smarty = \CODOF\Smarty\Single::get_instance(); $db = \DB::getPDO(); $query = "SELECT * FROM " . PREFIX . "codo_config"; if (isset($_POST['name']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $interval = $_POST['interval']; if ($_POST['interval'] == null || $_POST['interval'] == '') { $interval = $_POST['e_interval']; } $cron = new \CODOF\Cron\Cron(); $cron->reset($_POST['name'], $_POST['type'], $interval); } $qry = "SELECT * FROM " . PREFIX . "codo_crons"; $obj = $db->query($qry); $res = $obj->fetchAll(); $crons = array(); function get_readable_time($t) { switch ($t) { case 3600: return 'hourly'; case 3600 * 24: return 'daily'; case 3600 * 24 * 7: return 'weekly'; case 3600 * 24 * 30: return 'monthly';
/** * * @param array $data * @return bool */ public function queueNotify($type, $data) { if (!isset($data['actor'])) { $user = \CODOF\User\User::get(); $data["actor"] = array("username" => $user->username, "id" => $user->id, "role" => \CODOF\User\User::getRoleName($user->rid), "avatar" => $user->rawAvatar); } //Insert notification data JSON encoded $nid = \DB::table(PREFIX . 'codo_notify_text')->insertGetId(array("data" => json_encode($data))); //queue notification $qry = "INSERT INTO " . PREFIX . "codo_notify_queue (type, nid) " . " VALUES(:type, :nid)"; $stmt = $this->db->prepare($qry); $created = $stmt->execute(array("type" => $type, "nid" => $nid)); $cron = new \CODOF\Cron\Cron(); $cron->setOnce('notify', 0); return $created; }
$mentioner = new CODOF\Forum\Notification\Mention(); $_mentions = $_GET['mentions']; return $mentioner->getValid($_mentions); }); Request::get('Ajax/mentions/mentionable/:cid', function ($cid) { $mentioner = new CODOF\Forum\Notification\Mention(); return $mentioner->getNotMentionable($cid); }); Request::get('Ajax/mentions/:q/:cid/:tid', function ($q, $cid = 0, $tid = 0) { $mentioner = new CODOF\Forum\Notification\Mention(); return $mentioner->find($q, $cid, $tid); }); dispatch_get('Ajax/cron/run/:name', function ($name) { $user = CODOF\User\User::get(); if (Request::valid($_GET['token']) && $user->hasRoleId(ROLE_ADMIN)) { $cron = new \CODOF\Cron\Cron(); if (!$cron->run($name)) { echo 'Unable to run cron ' . $name . ' because another cron is already running'; } } //exit; }); //-------------PAGES-------------------------- dispatch_get('/page/:id/:url', function ($id, $url) { $pid = (int) $id; $user = \CODOF\User\User::get(); $qry = 'SELECT title, content FROM ' . PREFIX . 'codo_pages p ' . ' LEFT JOIN ' . PREFIX . 'codo_page_roles r ON r.pid=p.id ' . ' WHERE (r.rid IS NULL OR (r.rid IS NOT NULL AND r.rid IN (' . implode($user->rids) . ')))' . ' AND p.id=' . $pid; $res = \DB::getPDO()->query($qry); $row = $res->fetch(); if ($row) { $title = $row['title'];