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; } }
function smarty_function_match_option($params) { $user = CODOF\User\User::get(); $preference = $user->prefers($params['key']); if ($preference && $preference == $params['value']) { echo 'selected'; } }
function smarty_function_match_switch($params) { $user = CODOF\User\User::get(); $preference = $user->prefers($params['key']); if ($preference && $preference == $params['value']) { echo 'codo_switch_on'; } else { echo 'codo_switch_off'; } }
* @CODOLICENSE */ $smarty = \CODOF\Smarty\Single::get_instance(); $db = \DB::getPDO(); define('HOUR', 3600); define('DAY', HOUR * 24); define('MONTH', DAY * 30); $smarty->assign('msg', ''); $query = "SELECT * FROM " . PREFIX . "codo_config"; if (isset($_GET['t'])) { $smarty->assign('msg', 'The user has been banned successfully'); } if (isset($_POST['ban_uid']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $uid = $_POST['ban_uid']; $type = $_POST['ban_type']; $user = CODOF\User\User::get(); $by = $user->username; $on = time(); $reason = $_POST['ban_reason']; $mul = array("hour" => HOUR, "day" => DAY, "month" => MONTH, "forever" => 0); $seconds = floor((int) $_POST['ban_expires'] * $mul[$_POST['ban_expires_type']]); if ($seconds == 0) { $till = 0; } else { $till = time() + (int) $seconds; } $values = array("uid" => $uid, "ban_type" => $type, "ban_by" => $by, "ban_on" => $on, "ban_reason" => $reason, "ban_expires" => $till); $ban = new CODOF\User\Ban($db); $ban->values = $values; if (isset($_POST['id'])) { $ban->update_ban($_POST['id']);
$reg->mail = $_POST['a_email']; $reg->password = $_POST['a_password']; $reg->user_status = 1; $errors = $reg->register_user(); $msg = implode('<br>', $errors); } //$msg = $errors[0]; $err = 1; $smarty->assign("msg", $msg); } } } //DELETE if (isset($_POST['delete_type']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $msg = ""; $user = CODOF\User\User::get((int) $_POST['delete_id']); if ($user == false) { $_POST['delete_type'] = 'error'; $msg .= "User does not exist.<br>"; } else { if ($user->hasRoleId(ROLE_ADMIN) || $user->mail == 'anonymous@localhost') { $_POST['delete_type'] = 'error'; $msg .= "User with admin role/anonynous user cannot be deleted."; } } $smarty->assign('msg', $msg); if ($_POST['delete_type'] == 'ban_and_keep') { $user->banAccount(); } else { if ($_POST['delete_type'] == 'ban_and_delete') { $user->banAccount();
<?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');
function smarty_modifier_get_preference($key) { $user = CODOF\User\User::get(); return $user->prefers($key); }