public function queue_mails($args) { $cid = (int) $args['cid']; $tid = (int) $args['tid']; $pid = (int) $args['pid']; $type = $args['type']; if ($type == 'new_topic') { $subject = \CODOF\Util::get_opt('topic_notify_subject'); $message = \CODOF\Util::get_opt('topic_notify_message'); } else { $subject = \CODOF\Util::get_opt('post_notify_subject'); $message = \CODOF\Util::get_opt('post_notify_message'); } $mail = new \CODOF\Forum\Notification\Mail(); $me = CODOF\User\User::get(); $mails = array(); $offset = 0; while ($data = $this->getData($cid, $tid, $pid, $offset)) { foreach ($data as $info) { //do not send email to the user making the post if ($me->id == $info['id'] || $info['mail'] == null) { continue; } $user = array("id" => $me->id, "username" => $me->username); $post = array("omessage" => $info['omessage'], "imessage" => $info['imessage'], "url" => \CODOF\Forum\Forum::getPostURL($tid, $info['title'], $pid), "id" => $info['id'], "username" => $info['username'], "title" => $info['title'], "category" => $info['cat_name']); $mail->user = $user; $mail->post = $post; $mails[] = array("to_address" => $info['mail'], "mail_subject" => html_entity_decode($mail->replace_tokens($subject), ENT_NOQUOTES, "UTF-8"), "body" => html_entity_decode($mail->replace_tokens($message), ENT_QUOTES, "UTF-8")); } \DB::table(PREFIX . 'codo_mail_queue')->insert($mails); $offset += 400; } }
public function get_topics($catid, $page) { $topic = new \CODOF\Forum\Topic($this->db); $topics = array(); $cid = (int) $catid; $num_pages = 'not_passed'; if (isset($_GET['get_page_count']) && $_GET['get_page_count'] == 'yes') { $num_pages = 'calc_count'; } $new_topics = array(); $new_replies = array(); if (isset($_GET['str']) && $_GET['str'] != "") { $user = \CODOF\User\User::get(); if (!$user->can('use search')) { exit('permission denied'); } $search = new \CODOF\Search\Search(); $search->str = $_GET['str']; $search->num_results = \CODOF\Util::get_opt("num_posts_cat_topics"); $search->from = ($page - 1) * $search->num_results; if ($num_pages == 'calc_count') { $search->count_rows = true; } $cats = (int) $_GET['catid']; $search->cats = $cats; $search->match_titles = $_GET['match_titles']; $search->order = $_GET['order']; $search->sort = $_GET['sort']; $search->time_within = $_GET['search_within']; $res = $search->search(); if ($num_pages == 'calc_count') { $num_pages = $search->get_total_count(); } $_topics = $topic->gen_topic_arr_all_topics($res, $search); $tids = array(); foreach ($topics as $_topic) { $tids[] = $_topic['topic_id']; } //var_dump($topics); } else { //$num_pages = $topic->get_num_pages( // $topic->get_num_topics($cid), \CODOF\Util::get_opt("num_posts_cat_topics") //); $num_pages = 'not_passed'; $topics = $topic->get_topics($cid, $page); $tids = array(); foreach ($topics as $_topic) { $tids[] = $_topic['topic_id']; } if (\CODOF\User\CurrentUser\CurrentUser::loggedIn()) { $tracker = new \CODOF\Forum\Tracker($this->db); $topic->new_topic_ids = $tracker->get_new_topic_ids($cid, $tids); $topic->new_replies = $tracker->get_new_reply_counts($tids); } $topic->tags = $topic->getAllTags($tids); $_topics = $topic->gen_topic_arr($topics, $cid); } return array("topics" => $_topics, "new_topics" => $topic->new_topic_ids, "page_no" => $page, "num_pages" => $num_pages); }
public function getReplies($from = 0) { $num_posts = \CODOF\Util::get_opt("num_posts_cat_topics"); $qry = 'SELECT p.post_id, p.omessage AS message, p.post_created, u.id, ' . 'u.name as name, u.avatar, c.cat_id, c.cat_img, c.cat_alias, ' . 't.topic_id, t.uid, t.title, t.no_posts, t.no_views, ' . 't.last_post_time, t.last_post_uid, t.topic_status,' . 't.last_post_name AS last_post_name, t.topic_created ' . 'FROM ' . PREFIX . 'codo_posts AS p ' . 'LEFT JOIN ' . PREFIX . 'codo_topics AS t ON (t.topic_id=p.topic_id) ' . 'LEFT JOIN ' . PREFIX . 'codo_users AS u ON u.id=p.uid ' . 'LEFT JOIN codo_categories AS c ON c.cat_id=t.cat_id ' . 'WHERE ' . $this->postInModeration('p') . ' AND ' . $this->getPermissionConditions('moderate posts') . ' ORDER BY p.post_created DESC'; // LIMIT ' . $num_posts . ' OFFSET ' . $from; $res = $this->db->query($qry); return $this->format($res->fetchAll()); }
public function get_all_topics($from = 0) { $_topics = array(); //$t = microtime(true); $num_posts = \CODOF\Util::get_opt("num_posts_all_topics"); $qry = 'SELECT p.post_id, p.omessage AS message, p.post_created, u.id, ' . 'u.name as name, u.avatar, c.cat_id, c.cat_img, c.cat_alias, ' . 't.topic_id, t.uid, t.title, t.no_posts, t.no_views, ' . 't.last_post_time, t.last_post_uid, last_post_id, t.topic_status, ' . 't.last_post_name AS last_post_name, t.topic_created ' . 'FROM codo_topics AS t ' . 'LEFT JOIN codo_posts AS p ON (t.post_id=p.post_id AND p.post_status=1)' . 'LEFT JOIN codo_users AS u ON u.id=p.uid ' . 'LEFT JOIN codo_categories AS c ON c.cat_id=t.cat_id ' . 'WHERE ( t.topic_status=' . Forum::APPROVED . ' OR t.topic_status=' . Forum::STICKY . ') ' . 'AND ' . $this->getViewTopicPermissionConditions() . 'ORDER BY t.topic_status DESC, t.last_post_time DESC ' . 'LIMIT ' . $num_posts . ' OFFSET ' . $from; $ans = $this->db->query($qry); if ($ans) { $_topics = $ans->fetchAll(); } return $_topics; }
/** * * Gets information of posts of given topic id paginated * * @param type $tid * @param type $from * @return type */ public function get_posts($tid, $from = 0) { //$tid is converted to integer so its safe //show oldest first $posts = array(); $num_posts = \CODOF\Util::get_opt("num_posts_per_topic"); $from *= $num_posts; $qry = "SELECT u.id, r.rid, u.name AS name, u.avatar, u.no_posts, " . "u.signature, p.post_id, p.omessage AS message,p.imessage, " . "p.post_created, p.post_modified, p.reputation " . "FROM codo_posts AS p " . "LEFT JOIN codo_users AS u ON u.id=p.uid " . "LEFT JOIN codo_user_roles AS r ON r.uid=p.uid AND r.is_primary=1 " . "WHERE p.topic_id={$tid} AND p.post_status=1 ORDER BY post_created " . "LIMIT " . $num_posts . " OFFSET " . $from; $res = $this->db->query($qry); if ($res) { $posts = $this->gen_posts_arr($res->fetchAll()); } return $posts; }
public function req_pass() { $errors = array(); $token = uniqid() . '&' . (time() + 3600); $mail = new \CODOF\Forum\Notification\Mail(); //update the user's password with the generated password $user = \CODOF\User\User::getByMailOrUsername($_GET['ident'], $_GET['ident']); $gen = false; if (!$user) { $errors[] = _t("User does not exist with the given username/mail"); } else { $old_token = $user->token; if ($old_token != null) { $parts = explode("&", $old_token); $expiry = (int) $parts[1]; if ($expiry > time()) { $gen = true; } } else { $gen = true; } } if (empty($errors) && $gen) { \DB::table(PREFIX . 'codo_users')->where('id', $user->id)->update(array('token' => $token)); $body = \CODOF\Util::get_opt('password_reset_message'); $sub = \CODOF\Util::get_opt('password_reset_subject'); $mail->user = array("token" => $token, "link" => RURI . 'user/reset'); $message = $mail->replace_tokens($body); $subject = $mail->replace_tokens($sub); $mail->to = $user->mail; $mail->subject = $subject; $mail->message = $message; $mail->send_mail(); if (!$mail->sent) { $errors[] = $mail->error; } } $resp = array("status" => "success", "msg" => _t("E-mail sent successfully")); if (!empty($errors)) { $resp = array("status" => "fail", "msg" => $errors); } echo json_encode($resp); }
/** * Constraints defined for username * @param type $username */ public function username($username) { $username_len = strlen($username); $min_username_len = \CODOF\Util::get_opt('register_username_min'); $errors = array(); if ($username_len < $min_username_len) { $errors[] = _t("username cannot be less than {$min_username_len} characters!"); } if (preg_match('/^[A-Za-z0-9_-]+$/', $username) === 0) { $errors[] = _t("username can have only letters digits and underscores"); } if (\CODOF\User\User::usernameExists($username)) { $errors[] = _t("user already exists"); } $this->errors = array_merge($errors, $this->errors); if (empty($errors)) { \CODOF\Hook::call('on_username_ok'); return TRUE; //passed } \CODOF\Hook::call('on_username_fail'); return FALSE; //Fail }
public function can_down($pid, $to_id) { $user = \CODOF\User\User::get(); $res = \DB::table(PREFIX . 'codo_daily_rep_log')->select('rep_count', 'start_rep_time')->where('uid', '=', $user->id)->first(); if (!$res) { $res['rep_count'] = 0; $res['start_rep_time'] = time(); \DB::table(PREFIX . 'codo_daily_rep_log')->insert(array("uid" => $user->id, "rep_count" => 0, "start_rep_time" => time())); } $max_rep_allowed = \CODOF\Util::get_opt('max_rep_per_day'); //RULE 1: User can give max X rep per day $one_day = 24 * 60 * 60; $within_one_day = time() - $res['start_rep_time'] < $one_day; $this->max_rep_count_reached = $res['rep_count'] == $max_rep_allowed; $this->rule1 = !($this->max_rep_count_reached && $within_one_day); //RULE 2: User must have X reputation points or Y posts to increment reputation $rep_to_inc = \CODOF\Util::get_opt('rep_req_to_dec'); $posts_to_inc = \CODOF\Util::get_opt('posts_req_to_dec'); $this->rule2 = $user->reputation >= $rep_to_inc && $user->no_posts >= $posts_to_inc; //RULE 3: Reputation cannot be given/taken to same user more N times // until X hours have passed $rep_times_same_user = \CODOF\Util::get_opt('rep_times_same_user'); $rep_hours_same_user = \CODOF\Util::get_opt('rep_hours_same_user'); $rep_seconds_same_user = $rep_hours_same_user * 60; $rows = \DB::table(PREFIX . 'codo_reputation')->where('from_id', '=', $user->id)->where('to_id', '=', $to_id)->where('post_id', '=', $pid)->where('rep_time', '>', time() - $rep_seconds_same_user)->select('points')->get(); $numbers_of_reps = count($rows); $this->rule3 = $numbers_of_reps < $rep_times_same_user; //RULE 4: User cannot give reputation to the same post more than once $has_rep = \DB::table(PREFIX . 'codo_reputation')->where('from_id', '=', $user->id)->where('post_id', '=', $pid)->where('points', '=', 1)->get(); $this->rule4 = !$has_rep; $this->rule5 = $user->id != $to_id; return $this->rule1 && $this->rule2 && $this->rule3 && $this->rule4 && $this->rule5 && $user->can('rep up'); }
function smarty_modifier_get_opt($option) { return \CODOF\Util::get_opt($option); }
public function replace_tokens($text) { preg_match_all("/\\[(.*?)\\]/", $text, $tkns); $tokens = $tkns[1]; //we use str_replace which anyway replaces all occurences $ids = array_unique($tokens); foreach ($ids as $id) { $fields = explode(":", $id); switch ($fields[0]) { //user related case 'user': $value = $this->user[$fields[1]]; break; //any config from codo_config table //any config from codo_config table case 'option': $value = \CODOF\Util::get_opt($fields[1]); break; case 'this': $value = $this->curr[$fields[1]]; break; case 'post': $value = $this->post[$fields[1]]; break; default: $value = ''; } $text = str_replace("[{$id}]", $value, $text); } return $text; }
public function getTaggedTopics($tag, $from) { $new_topic_ids = array(); $new_replies = array(); $topic = new \CODOF\Forum\Topic($this->db); $topic->ajax = true; $topics = $topic->getTaggedTopics($tag, $from); $tids = array(); foreach ($topics as $one_topic) { $tids[] = $one_topic['topic_id']; } if (\CODOF\User\CurrentUser\CurrentUser::loggedIn()) { $tracker = new \CODOF\Forum\Tracker($this->db); //0.76 = 3 queries $new_topic_ids = $tracker->get_all_new_topic_ids($tids); $new_replies = $tracker->get_new_reply_counts($tids); } //echo json_encode( return array("topics" => $topics, "tags" => $topic->getAllTags($tids), "new_topic_ids" => $new_topic_ids, "find_topics_tagged" => _t("find topics tagged"), "new_replies" => $new_replies, "new" => _t("new"), "new_topic" => _t("new topic"), "new_replies_txt" => _t("new replies"), "RURI" => RURI, "DURI" => DURI, "CAT_IMGS" => CAT_IMGS, "CURR_THEME" => CURR_THEME, "reply_txt" => _t("replies"), "views_txt" => _t("views"), "recent_txt" => _t('recent by'), "num_posts" => \CODOF\Util::get_opt('num_posts_all_topics')); //); }
public static function load($tpl, $css_files = array(), $js_files = array()) { \CODOF\Util::inc_global_views(); //This sets all variables which will be used by the theme require CURR_THEME_PATH . 'theme.php'; $page = array(); \CODOF\Hook::call('before_site_head'); \CODOF\Hook::call('tpl_before_' . str_replace("/", "_", $tpl)); $asset = new \CODOF\Asset\Stream(); $page["head"]["css"] = $asset->dumpCSS(); //\CODOF\Theme\Js::sort_js(); $page["head"]["js"] = $asset->dumpJS('head'); $page["body"]["js"] = $asset->dumpJS('body'); $page["defer"] = json_encode($asset->deferred()); //after all modification its time for smarty to display the mod data $smarty = Single::get_instance(); $site_title = \CODOF\Util::get_opt('site_title'); $sub_title = \CODOF\Store::get('sub_title'); $smarty->assign('site_title', $site_title); $smarty->assign('sub_title', $sub_title); $smarty->assign('home_title', \CODOF\Store::get('home_title', _t('All topics'))); $smarty->assign('site_url', \CODOF\Util::get_opt('site_url')); $smarty->assign('logged_in', \CODOF\User\CurrentUser\CurrentUser::loggedIn()); $smarty->assign('login_url', \CODOF\User\User::getLoginUrl()); $smarty->assign('logout_url', \CODOF\User\User::getLogoutUrl()); $smarty->assign('register_url', \CODOF\User\User::getRegisterUrl()); $smarty->assign('profile_url', \CODOF\User\User::getProfileUrl()); $smarty->assign('page', $page); $smarty->assign('CSRF_token', \CODOF\Access\CSRF::get_token()); $smarty->assign('php_time_now', time()); $category = new \CODOF\Forum\Category(); $canCreateTopicInAtleastOneCategory = $category->canCreateTopicInAtleastOne(); $smarty->assign('canCreateTopicInAtleastOneCategory', $canCreateTopicInAtleastOneCategory); $page = \CODOF\Store::get('rel:canonical_page', isset($_GET['u']) ? $_GET['u'] : ''); $smarty->assign('canonical', rtrim(RURI, '/') . strip_tags($page)); if (\CODOF\Store::has('rel:prev')) { $smarty->assign('rel_prev', \CODOF\Store::get('rel:prev')); } if (\CODOF\Store::has('rel:next')) { $smarty->assign('rel_next', \CODOF\Store::get('rel:next')); } if (\CODOF\Store::has('meta:robots')) { $smarty->assign('meta_robots', \CODOF\Store::get('meta:robots')); } $og = array("type" => \CODOF\Store::get('og:type', 'website'), "title" => \CODOF\Store::get('og:title', $sub_title . ' | ' . $site_title)); if (\CODOF\Store::has('og:url')) { $og['url'] = \CODOF\Store::get('og:url'); } if (\CODOF\Store::has('og:desc')) { $og['desc'] = \CODOF\Store::get('og:desc'); } else { $og['desc'] = \CODOF\Util::get_opt('site_description'); } if (\CODOF\Store::has('og:image')) { $og['image'] = \CODOF\Store::get('og:image'); } $smarty->assign('og', $og); if (\CODOF\Store::has('article:published')) { $smarty->assign('article_published', \CODOF\Store::get('article:published')); } if (\CODOF\Store::has('article:modified')) { $smarty->assign('article_modified', \CODOF\Store::get('article:modified')); } $I = \CODOF\User\User::get(); //current user details $smarty->assign('I', $I); $smarty->assign('can_moderate_posts', $I->can('moderate posts')); if (\CODOF\User\CurrentUser\CurrentUser::loggedIn()) { $notifier = new \CODOF\Forum\Notification\Notifier(); $smarty->assign('unread_notifications', $notifier->getNoOfUnread()); } $html = $smarty->fetch("{$tpl}.tpl"); require_once SYSPATH . 'Ext/simplehtmldom/simple_html_dom.php'; $dom = new \simple_html_dom(); $dom->load($html, true, false); //let plugins modify html \CODOF\Hook::call('tpl_after_' . str_replace("/", "_", $tpl), $dom); \CODOF\Hook::call('after_site_head', $dom); echo $dom->save(); }
public function sendDigest() { $smarty = \CODOF\Smarty\Single::get_instance(SYSPATH . 'CODOF/Forum/Notification/Digest/', true); $user = \CODOF\User\User::get(); $smarty->assign('site_title', \CODOF\Util::get_opt('site_title')); $smarty->assign('brand_img', \CODOF\Util::get_opt('brand_img')); $smarty->assign('username', $user->username); $date = date('Y-F-j-S', time()); list($year, $month, $day, $ordinal) = explode("-", $date); $dayInfo = array("year" => $year, "month" => $month, "day" => $day, "ordinal" => $ordinal); $smarty->assign('dayInfo', $dayInfo); $smarty->assign('statistics_img', 'http://i.imgur.com/7sBa4Ow.png'); //RAW $smarty->assign('create_new_img', 'http://i.imgur.com/E0MhBwI.png'); //RAW $notifier = new \CODOF\Forum\Notification\Notifier(); $events = $notifier->get(TRUE, 0, 'asc'); //get all unread notifications $sortedEvents = $this->sort($events); $smarty->assign('events', $sortedEvents); $smarty->assign('new_posts', $this->newPosts . " "); $smarty->assign('new_topics', $this->newTopics . " "); if (empty($events)) { $smarty->assign('nothing_new', true); } else { $smarty->assign('nothing_new', false); } $frequency = $user->prefers('notification_frequency'); $html = $smarty->fetch("{$frequency}.tpl"); $text = $smarty->fetch("{$frequency}Text.tpl"); $this->daily = $html; $this->dailyText = $text; $mailer = new \CODOF\Forum\Notification\Mail(); $mailer->setHTML($mailer->replace_tokens($this->dailyText)); $mailer->to = $user->mail; $mailer->subject = _t('Daily digest - ') . \CODOF\Util::get_opt('site_title'); $mailer->message = $this->daily; $mailer->send_mail(); }
public function upload() { if (!isset($_FILES)) { return; } $errors = array(); $file_info = array(); if (is_array($_FILES['file']['name'])) { $images = \CODOF\Util::re_array_files($_FILES['file']); } else { $images = array($_FILES['file']); } foreach ($images as $image) { if (!\CODOF\File\Upload::valid($image) or !\CODOF\File\Upload::not_empty($image) or !\CODOF\File\Upload::size($image, (int) \CODOF\Util::get_opt('forum_attachments_size')) or !\CODOF\File\Upload::type($image, explode(",", \CODOF\Util::get_opt('forum_attachments_exts')))) { $errors[] = "Error While uploading the image."; } else { $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)); $file_info[] = \CODOF\File\Upload::save($image, uniqid() . "." . $ext, DATA_PATH . \CODOF\Util::get_opt('forum_attachments_path'), 0777); } } echo json_encode($file_info); }
public static function do_upload($image, $path) { self::$error = true; if (!self::valid($image)) { return 'File is not valid'; } if (!self::not_empty($image)) { return 'File is empty'; } if (!self::size($image, (int) \CODOF\Util::get_opt('forum_attachments_size'))) { return 'File size too large'; } $types = explode(",", \CODOF\Util::get_opt('forum_attachments_exts')); if (self::$supportBmp) { //add support for bmp array_merge($types, 'bmp'); } else { $types = array_diff($types, array('bmp')); } if (!self::type($image, $types)) { return 'File extension type not supported'; } self::$error = false; \CODOF\Hook::call('on_file_upload', array($image, $path)); $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)); return self::save($image, uniqid() . "." . $ext, DATA_PATH . $path, 0777); }
<?php /* * @CODOLICENSE */ $smarty = \CODOF\Smarty\Single::get_instance(); $db = \DB::getPDO(); CODOF\Util::get_config($db); $reg_req_admin = \CODOF\Util::get_opt('reg_req_admin'); if (isset($_POST['action']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $action = $_POST['action']; if ($action == 'approve') { \DB::table(PREFIX . 'codo_users')->whereIn('id', $_POST['ids'])->update(array('user_status' => 1)); \DB::table(PREFIX . 'codo_user_roles')->whereIn('uid', $_POST['ids'])->update(array('rid' => ROLE_USER)); } else { foreach ($_POST['ids'] as $id) { $user = CODOF\User\User::get((int) $id); $user->deleteAccount(); } } } $qry = "SELECT id,username,mail,created,user_status FROM " . PREFIX . "codo_users WHERE user_status=2 OR user_status=0 AND username<>'anonymous'"; $obj = $db->query($qry); $res = $obj->fetchAll(); $users = array(); foreach ($res as $user) { $users[] = array('id' => $user['id'], 'username' => $user['username'], 'mail' => $user['mail'], 'created' => CODOF\Time::get_pretty_time($user['created']), 'confirmed' => (int) $user['user_status'] == 2 ? 'yes' : 'no'); } $smarty->assign('reg_req_admin', $reg_req_admin); $smarty->assign('users', $users); $content = $smarty->fetch('moderation/approve_users.tpl');
private function assign_editor_vars() { $this->smarty->assign('max_file_size', \CODOF\Util::get_opt('forum_attachments_size')); $this->smarty->assign('allowed_file_mimetypes', \CODOF\Util::get_opt('forum_attachments_mimetypes')); $this->smarty->assign('forum_attachments_parallel', \CODOF\Util::get_opt('forum_attachments_parallel')); $this->smarty->assign('forum_attachments_multiple', \CODOF\Util::get_opt('forum_attachments_multiple')); $this->smarty->assign('forum_attachments_max', \CODOF\Util::get_opt('forum_attachments_max')); $this->smarty->assign('forum_smileys', json_encode(\CODOF\Util::get_smileys($this->db))); $this->smarty->assign('reply_min_chars', \CODOF\Util::get_opt('reply_min_chars')); }
public function confirm() { $this->view = 'user/confirm'; $action = array(); if (empty($_GET['user']) || empty($_GET['token'])) { $action['result'] = 'VAR_NOT_PASSED'; //$action['text'] = 'We are missing variables. Please double check your email.'; } else { //cleanup the variables $username = $_GET['user']; $token = $_GET['token']; //check if the key is in the database $qry = "SELECT username FROM " . PREFIX . "codo_signups WHERE username=:username AND token=:token LIMIT 1 OFFSET 0"; $stmt = $this->db->prepare($qry); $result = $stmt->execute(array("username" => $username, "token" => $token)); if ($result) { //get the confirm info $res = $stmt->fetch(); $reg_req_admin = \CODOF\Util::get_opt('reg_req_admin'); $user_status = 1; if ($reg_req_admin == 'yes') { $user_status = 2; } //confirm the email and update the users database $qry = "UPDATE " . PREFIX . "codo_users SET user_status={$user_status} WHERE username=:username"; $stmt = $this->db->prepare($qry); $stmt->execute(array("username" => $username)); if ($reg_req_admin == 'no') { $user = \CODOF\User\User::getByUsername($username); $qry = "UPDATE " . PREFIX . "codo_user_roles SET rid=:rid WHERE uid=" . $user->id; $stmt = $this->db->prepare($qry); $stmt->execute(array("rid" => ROLE_USER)); } //delete the signup rows associated with the selected username $qry = "DELETE FROM " . PREFIX . "codo_signups WHERE username = '******'username'] . "'"; $this->db->query($qry); $action['result'] = 'SUCCESS'; } else { $action['result'] = 'VAR_NOT_FOUND'; } } \CODOF\Store::set('sub_title', _t('Confirm user')); $this->smarty->assign('result', $action['result']); }
/** * * Get different possible errors before registering an user * @return Array errors */ public function get_errors() { $constraints = new \CODOF\Constraints\User(); $constraints->username($this->username); $constraints->password($this->password); $constraints->mail($this->mail); $errors = $constraints->get_errors(); if (\CODOF\Util::get_opt('captcha') == "enabled") { require_once ABSPATH . 'sys/Ext/recaptcha/recaptchalib.php'; $privatekey = \CODOF\Util::get_opt("captcha_private_key"); // your secret key $secret = $privatekey; // empty response $response = null; // check secret key $reCaptcha = new \ReCaptcha($secret); if ($_POST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); } if (!($response != null && $response->success)) { $errors[] = _t("capcha entered was wrong"); } } return $errors; }
<?php /* * @CODOLICENSE */ $smarty = \CODOF\Smarty\Single::get_instance(); $db = \DB::getPDO(); \CODOF\Util::get_config($db); define('CODOF_VERSION', str_replace(".php", "", \CODOF\Util::get_opt('version'))); class upgrader { public static $latest_version = "1.0"; public static $base_url = "https://codoforum.com/"; static function is_required() { if (version_compare(CODOF_VERSION, upgrader::$latest_version) == -1) { return true; } return false; } static function check_writable() { $paths = array("index.php", "admin/index.php", "admin", "sys", "sys/CODOF/Util.php", "sites"); foreach ($paths as $path) { if (!is_writable(ABSPATH . $path)) { echo "#> Error-Path not writable: " . ABSPATH . $path . "<br>\n"; return false; } echo "3.1> Files seem writable :) <br>"; return true; }
/** * Gets the register url for the user * @return string */ public static function getRegisterUrl() { if (\CODOF\Plugin::is_active('sso')) { return \CODOF\Util::get_opt('sso_register_user_path'); } return RURI . 'user/register'; }
/* * @CODOLICENSE */ //Limonade -> 230 ms //display & routing if (get_magic_quotes_gpc()) { $gpc = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); array_walk_recursive($gpc, function (&$value) { $value = stripslashes($value); }); } use CODOF\Util; use CODOF\Access\Request; $db = \DB::getPDO(); Util::get_config($db); \Constants::post_boot('themes/' . Util::get_opt('theme') . "/"); CODOF\Smarty\Single::get_instance(); //-------------------------server static files -------------------------------- dispatch_get('Ajax/history/posts', function () { if (Request::valid($_GET['_token'])) { $post = new \CODOF\Forum\Post(); $post->getHistory($_GET['pid']); } }); dispatch_get('Ajax/reputation/:pid/up', function ($pid) { if (Request::valid($_GET['_token'])) { $rep = new \CODOF\Forum\Reputation(); $rep->up($pid); } }); dispatch_get('Ajax/reputation/:pid/down', function ($pid) {