function __set($key, $value) { if (isset($this->filters[$key]) and !$this->is_filter[$this->filters[$key]]($value)) { message(App::$lang_common['Bad request'] . ' Passed parameter is invalid'); } parent::__set($key, $value); }
function SaveConfig() { global $config, $langmessage; $possible = $this->variables; foreach ($possible as $key => $curr_possible) { if ($curr_possible == 'boolean') { if (isset($_POST[$key]) && $_POST[$key] == 'true') { $config[$key] = true; } else { $config[$key] = false; } } elseif ($curr_possible == 'integer') { if (isset($_POST[$key]) && is_numeric($_POST[$key])) { $config[$key] = $_POST[$key]; } } elseif (isset($_POST[$key])) { $config[$key] = $_POST[$key]; } } $config['history_limit'] = min($config['history_limit'], gp_backup_limit); if (!admin_tools::SaveConfig()) { message($langmessage['OOPS']); return false; } if (isset($_GET['gpreq']) && $_GET['gpreq'] == 'json') { message($langmessage['SAVED'] . ' ' . $langmessage['REFRESH']); } else { message($langmessage['SAVED']); } }
public function fieldsFormSubmit($rid = 0) { global $_GPC, $_W; $id = intval($_GPC['reply_id']); $credit = intval($_GPC['credit']); $insert = array('rid' => $rid, 'start_time' => strtotime($_GPC['start_time']), 'end_time' => strtotime($_GPC['end_time']), 'awardrules' => $_GPC['awardrules'], 'awardinfo' => $_GPC['awardinfo'], 'days' => $_GPC['days'], 'credit' => $credit); if (!empty($_FILES['thumb']['tmp_name'])) { file_delete($_GPC['thumb_old']); $upload = file_upload($_FILES['thumb']); if (is_error($upload)) { message($upload['message'], '', 'error'); } $insert['thumb'] = $upload['path']; } else { $tmp_file = array(name => "registration_top.jpg", tmp_name => "{$_SERVER['DOCUMENT_ROOT']}/source/modules/cgtsignin/template/style/images/registration_top.jpg"); $upload = file_upload($tmp_file); if (is_error($upload)) { message($upload['message'], '', 'error'); } $insert['thumb'] = $upload['path']; } if (empty($id)) { pdo_insert($this->tablename, $insert); } else { pdo_update($this->tablename, $insert, array('id' => $id)); } }
function sendnewpassword($email) { $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . $email . "' LIMIT 1;", 'users', true); if (empty($ExistMail['email'])) { message('That address is not found !', 'Error'); } else { $Caracters = "aazertyuiopqsdfghjklmwxcvbn���AZERTYUIOPQSDFGHJKLMWXCVBN���1234567890"; $Count = strlen($Caracters); $NewPass = ""; $Taille = 6; srand((double) microtime() * 1000000); for ($i = 0; $i < $Taille; $i++) { $CaracterBoucle = rand(0, $Count - 1); $NewPass = $NewPass . substr($Caracters, $CaracterBoucle, 1); } $Title = "Rogue Universe : Nytt l�senord"; $Body = "H�r �r ditt nya l�senord : "; $Body .= $NewPass; mail($email, $Title, $Body); $NewPassSql = md5($NewPass); $QryPassChange = "UPDATE game_users SET "; $QryPassChange .= "`password` ='" . $NewPassSql . "' "; $QryPassChange .= "WHERE `email`='" . $email . "' LIMIT 1;"; doquery($QryPassChange, 'users'); } }
function doInsert() { if (isset($_POST['save'])) { $NAME = $_POST['subjectname']; $DESCRIPTION = $_POST['description']; $SECTOR = $_POST['sector']; $DOMAIN = $_POST['domain']; $subject = new subject(); $subject->name = $NAME; $subject->description = $DESCRIPTION; $subject->sector_id = $SECTOR; $subject->domain_id = $DOMAIN; } if ($NAME == "") { message('Subject Name is required!', "error"); redirect('index.php?view=add'); } elseif ($DESCRIPTION == "") { message('Description is required!', "error"); redirect('index.php?view=add'); } elseif ($SECTOR == "") { message('Sector ID is required!', "error"); redirect('index.php?view=add'); } elseif ($DOMAIN == "") { message('Domain ID is required!', "error"); redirect('index.php?view=add'); } else { $subject->create(); message('New subject addedd successfully!', "success"); redirect('index.php?view=list'); } }
public function settingsDisplay($settings) { // 声明为全局才可以访问到. global $_W, $_GPC; if (checksubmit()) { // $_GPC 可以用来获取 Cookies,表单中以及地址栏参数 $data = $_GPC['data']; // message() 方法用于提示用户操作提示 empty($data['name']) && message('请填写便利店名称'); empty($data['logo']) && message('请填写便利店 LOGO'); empty($data['linkman']) && message('请填写便利店联系人'); empty($data['phone']) && message('请填写便利店联系电话'); empty($data['address']) && message('请填写便利店地址'); empty($data['description']) && message('请填写便利店介绍'); //字段验证, 并获得正确的数据$dat if (!$this->saveSettings($data)) { message('保存信息失败', '', 'error'); } else { message('保存信息成功', '', 'success'); } } // 模板中需要用到 "tpl" 表单控件函数的话, 记得一定要调用此方法. load()->func('tpl'); //这里来展示设置项表单 include $this->template('setting'); }
function process_form() { global $phpcid, $vars, $phpcdb, $phpc_script; verify_token(); if (empty($vars['user_name'])) { return message(__('You must specify a user name')); } if (empty($vars['password1'])) { return message(__('You must specify a password')); } if (empty($vars['password2']) || $vars['password1'] != $vars['password2']) { return message(__('Your passwords did not match')); } $make_admin = empty($vars['make_admin']) ? 0 : 1; $passwd = md5($vars['password1']); if ($phpcdb->get_user_by_name($vars["user_name"])) { return message(__('User already exists.')); } $uid = $phpcdb->create_user($vars["user_name"], $passwd, $make_admin); if (!empty($vars['groups'])) { foreach ($vars['groups'] as $gid) { $phpcdb->user_add_group($uid, $gid); } } return message(__('Added user.')); }
/** * 支付完成后更改业务状态 */ public function payResult($params) { /* * $params 结构 * * weid 公众号id 兼容低版本 * uniacid 公众号id * result 支付是否成功 failed/success * type 支付类型 credit 积分支付 alipay 支付宝支付 wechat 微信支付 delivery 货到付款 * tid 订单号 * user 用户id * fee 支付金额 * * 注意:货到付款会直接返回支付失败,请在订单中记录货到付款的订单。然后发货后收取货款 */ $fee = intval($params['fee']); $data = array('status' => $params['result'] == 'success' ? 1 : 0); //如果是微信支付,需要记录transaction_id。 if ($params['type'] == 'wechat') { $data['transid'] = $params['tag']['transaction_id']; } //此处更改业务方面的记录,例如把订单状态更改为已付款 //pdo_update('shopping_order', $data, array('id' => $params['tid'])); //如果消息是用户直接返回(非通知),则提示一个付款成功 if ($params['from'] == 'return') { if ($params['type'] == 'credit') { message('支付成功!', $this->createMobileUrl('index1'), 'success'); } elseif ($params['type'] == 'delivery') { message('请您在收到货物时付清货款!', $this->createMobileUrl('index1'), 'success'); } else { message('支付成功!', '../../' . $this->createMobileUrl('index1'), 'success'); } } }
/** * This file is part of XNova:Legacies * * @license http://www.gnu.org/licenses/gpl-3.0.txt * @see http://www.xnova-ng.org/ * * Copyright (c) 2009-2010, XNova Support Team <http://www.xnova-ng.org> * All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * --> NOTICE <-- * This file is part of the core development branch, changing its contents will * make you unable to use the automatic updates manager. Please refer to the * documentation for further information about customizing XNova. * */ function sendnewpassword($mail) { $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . $mail . "' LIMIT 1;", 'users', true); if (empty($ExistMail['email'])) { message('L\'adresse n\'existe pas !', 'Erreur'); } else { //Caractere qui seront contenus dans le nouveau mot de passe $Caracters = "aazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890"; $Count = strlen($Caracters); $NewPass = ""; $Taille = 6; srand((double) microtime() * 1000000); for ($i = 0; $i < $Taille; $i++) { $CaracterBoucle = rand(0, $Count - 1); $NewPass = $NewPass . substr($Caracters, $CaracterBoucle, 1); } //Et un nouveau mot de passe tout chaud ^^ //On va maintenant l'envoyer au destinataire $Title = "XNova : Nouveau mot de passe"; $Body = "Voici votre nouveau mot de passe : "; $Body .= $NewPass; mail($mail, $Title, $Body); //Email envoy�, maintenant place au changement dans la BDD $NewPassSql = md5($NewPass); $QryPassChange = "UPDATE {{table}} SET "; $QryPassChange .= "`password` ='" . $NewPassSql . "' "; $QryPassChange .= "WHERE `email`='" . $mail . "' LIMIT 1;"; doquery($QryPassChange, 'users'); } }
function process_form() { global $vars, $phpcdb, $phpc_script; verify_token(); $cid = $phpcdb->create_calendar(); foreach (get_config_options() as $item) { $name = $item[0]; $type = $item[2]; if ($type == PHPC_CHECK) { if (isset($vars[$name])) { $value = "1"; } else { $value = "0"; } } else { if (isset($vars[$name])) { $value = $vars[$name]; } else { soft_error(__("{$name} was not set.")); } } $phpcdb->create_config($cid, $name, $value); } message(__('Calendar created.')); }
public function deletepost($id) { global $lang_common, $lang_post, $pd; if ($this->user->g_read_board == '0') { message($lang_common['No view'], '403'); } // Fetch some informations about the post, the topic and the forum $cur_post = $this->model->get_info_delete($id); if ($this->config['o_censoring'] == '1') { $cur_post['subject'] = censor_words($cur_post['subject']); } // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = $cur_post['moderators'] != '' ? unserialize($cur_post['moderators']) : array(); $is_admmod = $this->user->g_id == FEATHER_ADMIN || $this->user->g_moderator == '1' && array_key_exists($this->user->username, $mods_array) ? true : false; $is_topic_post = $id == $cur_post['first_post_id'] ? true : false; // Do we have permission to edit this post? if (($this->user->g_delete_posts == '0' || $this->user->g_delete_topics == '0' && $is_topic_post || $cur_post['poster_id'] != $this->user->id || $cur_post['closed'] == '1') && !$is_admmod) { message($lang_common['No permission'], '403'); } if ($is_admmod && $this->user->g_id != FEATHER_ADMIN && in_array($cur_post['poster_id'], get_admin_ids())) { message($lang_common['No permission'], '403'); } // Load the delete.php language file require FEATHER_ROOT . 'lang/' . $this->user->language . '/delete.php'; if ($this->feather->request()->isPost()) { $this->model->handle_deletion($is_topic_post, $id, $cur_post['tid'], $cur_post['fid']); } $page_title = array(feather_escape($this->config['o_board_title']), $lang_delete['Delete post']); define('FEATHER_ACTIVE_PAGE', 'delete'); $this->header->setTitle($page_title)->display(); require FEATHER_ROOT . 'include/parser.php'; $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); $this->feather->render('delete.php', array('lang_common' => $lang_common, 'lang_delete' => $lang_delete, 'cur_post' => $cur_post, 'id' => $id, 'is_topic_post' => $is_topic_post)); $this->footer->display(); }
function error($message, $title) { global $link, $game_config; if ($game_config['debug'] == 1) { echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; echo "<table>" . $this->log . "</table>"; } //else{ //A futuro, se creara una tabla especial, para almacenar //los errores que ocurran. global $user, $xnova_root_path, $phpEx; include $xnova_root_path . 'config.' . $phpEx; if (!$link) { die('mySQL error.'); } mysql_query("rollback"); $query = "INSERT INTO {{table}} SET\r\n\t\t\t\t`error_sender` = '{$user['id']}' ,\r\n\t\t\t\t`error_time` = '" . time() . "' ,\r\n\t\t\t\t`error_type` = '{$title}' ,\r\n\t\t\t\t`error_text` = '" . mysql_escape_string($message) . "';"; $sqlquery = mysql_query(str_replace("{{table}}", $dbsettings["prefix"] . 'errors', $query)) or die('error fatal'); $query = "explain select * from {{table}}"; $q = mysql_fetch_array(mysql_query(str_replace("{{table}}", $dbsettings["prefix"] . 'errors', $query))) or die('error fatal: '); if (!function_exists('message')) { echo "Error, thank you to contact the admin. error:<b>" . $q['rows'] . "</b>"; } else { message("Error, thank you to contact the admin. error:<b>" . $q['rows'] . "</b>", "Error"); } //} die; }
function display_message($message_id) { $message = message($message_id); if (!$message) { return; } $message_title = $message->message_title; $message_description = $message->message_description; ?> <style> #message_box a { color:#888; } </style> <div id="message_box_container" style="position:relative;z-index:1000;position:absolute;left:0px;top:0px;width:100%;height:100%;font-size:14px;background-color:rgba(255,255,255,0.5);"> <div id="message_box" style="width:350px;font-family:Arial,sans-serif;background-color:#fdfdfd;border-width:1px;border-style:solid;border-color:#ddd;padding:5px;margin:auto;margin-top:20%;"> <h1 style="font-size:20pt;margin:0px;"><?php echo $message_title; ?> </h1> <p style="margin-bottom:10px;"><?php echo $message_description; ?> </p> <a href="http://unify.lukebarnard.co.uk">Home</a> - <a id="close_link" href="javascript:return false;" onclick="c = document.getElementById('message_box_container');c.parentNode.removeChild(c);event.preventDefault();">Close this message box</a> <script> document.getElementById("close_link").focus(); </script> </div> </div> <?php }
public function doWebList($ischeck = 1) { global $_GPC, $_W; // AJAX if ($_W['isajax']) { $op = $_GPC['op']; $id = intval($_GPC['id']); $result = array('state' => -1, 'message' => ''); if ($op == 'delete') { $item = $this->item_fetch($id); if ($item['id']) { load()->func('file'); file_delete($item['photo']); pdo_delete('qiyue_canvas', array('id' => $item['id'])); $result['state'] = 0; } } elseif ($op == 'check') { if ($this->item_check($id)) { $result['state'] = 0; } } message($result, '', 'ajax'); } $title = '图片管理'; $result = $this->all_list(array('ischeck' => $ischeck)); include $this->template('manage'); }
function main() { global $G; $db = $G['db']; $tn = TABLE_NAME; message('%s version %s', TITLE, VERSION); message('bwSQLite3 version %s', bwSQLite3::VERSION); message('file name: %s, table name: %s', DB_FILENAME, TABLE_NAME); $query_start_time = microtime(TRUE); message('There are %d rows in the table.', $db->count_recs()); // database operations go here try { foreach ($db->get_recs() as $row) { message('id: %d: The %s says %s.', $row['id'], $row['animal'], $row['sound']); } $id = 3; message('deleting id %d', $id); $db->sql_do("DELETE FROM {$tn} WHERE id = ?", $id); message('after delete: The are %d records in the table', $db->count_recs()); foreach ($db->get_recs() as $row) { message('id: %d: The %s says %s.', $row['id'], $row['animal'], $row['sound']); } $id = 2; message('deleting id %d', $id); $db->delete($id); message('after delete: The are %d records in the table', $db->count_recs()); foreach ($db->get_recs() as $row) { message('id: %d: The %s says %s.', $row['id'], $row['animal'], $row['sound']); } } catch (PDOException $e) { error($e->getMessage()); } $elapsed_time = microtime(TRUE) - $query_start_time; message('elapsed time: %s ms', number_format($elapsed_time * 1000, 2)); }
function main() { global $G; $db = $G['db']; $tn = TABLE_NAME; message('%s version %s', TITLE, VERSION); message('bwSQLite3 version %s', bwSQLite3::VERSION); message('file name: %s, table name: %s', DB_FILENAME, TABLE_NAME); $query_start_time = microtime(TRUE); message('There are %d rows in the table.', $db->count_recs()); // database operations go here try { $db->sql_do("INSERT INTO {$tn} ('animal', 'sound') VALUES (?, ?)", 'horse', 'A horse is a horse, of course, of course, ...'); $horse_id = $db->sql_query_value("SELECT LAST_INSERT_ROWID()"); message('Added id number %d', $horse_id); $bird_id = $db->insert(array('animal' => 'bird', 'sound' => 'Tweet')); message('Added id number %d', $bird_id); message('There are now %d rows in the table', $db->count_recs()); $row = $db->sql_query_row("SELECT * FROM {$tn} WHERE id = ?", $horse_id); message('id: %d: The %s says %s', $row['id'], $row['animal'], $row['sound']); $row = $db->get_rec($bird_id); message('id: %d: The %s says %s', $row['id'], $row['animal'], $row['sound']); } catch (PDOException $e) { error($e->getMessage()); } $elapsed_time = microtime(TRUE) - $query_start_time; message('elapsed time: %s ms', number_format($elapsed_time * 1000, 2)); }
function Check($passed) { $message = gpOutput::SelectText('Sorry, your answer to the verification challenge was incorrect. Please try again.'); if (empty($_POST['asm_1']) || empty($_POST['asm_2']) || empty($_POST['asm_3'])) { message($message . ' (1)'); return false; } $operator_key = $_POST['asm_2']; if (!isset($this->operators[$operator_key])) { message($message . ' (2)'); return false; } switch ($operator_key) { case 1: $result = $_POST['asm_1'] + $_POST['asm_3']; break; case 2: $result = $_POST['asm_1'] - $_POST['asm_3']; break; case 3: $result = $_POST['asm_1'] / $_POST['asm_3']; break; case 4: $result = $_POST['asm_1'] * $_POST['asm_3']; break; } $compare = $_POST['asm_4']; //message('result: '.$result.' vs submitted: '.$compare); if ($compare != $result) { message($message . ' (3)'); return false; } //message('passed'); return $passed; }
function sendnewpassword($mail) { global $lang; $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . $mail . "' LIMIT 1;", 'users', true); if (empty($ExistMail['email'])) { message($lang['mail_not_exist'], "index.php?modo=claveperdida", 2, false, false); } else { $Caracters = "aazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890"; $Count = strlen($Caracters); $NewPass = ""; $Taille = 6; srand((double) microtime() * 1000000); for ($i = 0; $i < $Taille; $i++) { $CaracterBoucle = rand(0, $Count - 1); $NewPass = $NewPass . substr($Caracters, $CaracterBoucle, 1); } $Title = $lang['mail_title']; $Body = $lang['mail_text']; $Body .= $NewPass; mail($mail, $Title, $Body); $NewPassSql = md5($NewPass); $QryPassChange = "UPDATE {{table}} SET "; $QryPassChange .= "`password` ='" . $NewPassSql . "' "; $QryPassChange .= "WHERE `email`='" . $mail . "' LIMIT 1;"; doquery($QryPassChange, 'users'); } }
public function settingsDisplay($settings) { global $_GPC, $_W; if (checksubmit()) { $cfg = array('times' => intval($_GPC['times']), 'start_time' => $_GPC['start_time'], 'end_time' => $_GPC['end_time'], 'credit' => intval($_GPC['credit']), 'rank' => intval($_GPC['rank'])); $start_time = $cfg['start_time']; $start_time = strtotime($start_time); $end_time = $cfg['end_time']; $end_time = strtotime($end_time); if ($start_time >= $end_time) { message('开始时间不得晚于结束时间', 'refresh', 'error'); } elseif ($this->saveSettings($cfg)) { message('保存成功', 'refresh'); } } if (!isset($settings['times'])) { $settings['times'] = '1'; } if (!isset($settings['start_time'])) { $settings['start_time'] = '08:30'; } if (!isset($settings['end_time'])) { $settings['end_time'] = '22:00'; } if (!isset($settings['credit'])) { $settings['credit'] = '1'; } if (!isset($settings['rank'])) { $settings['rank'] = '10'; } include $this->template('setting'); }
public function settingsDisplay($settings) { global $_W, $_GPC; load()->func('tpl'); if (checksubmit()) { load()->func('file'); $r = mkdirs(MB_ROOT . '/cert/' . $_W['uniacid']); if (!empty($_GPC['cert'])) { $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_cert.pem', trim($_GPC['cert'])); $r = $r && $ret; } if (!empty($_GPC['key'])) { $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_key.pem', trim($_GPC['key'])); $r = $r && $ret; } if (!$r) { message('证书保存失败, 请保证 /addons/feng_fightgroups/cert/ 目录可写'); } $dat = array('status' => $_GPC['status'], 'mode' => $_GPC['mode'], 'picmode' => $_GPC['picmode'], 'mchid' => $_GPC['mchid'], 'apikey' => $_GPC['apikey'], 'share_title' => $_GPC['share_title'], 'share_image' => $_GPC['share_image'], 'share_desc' => $_GPC['share_desc'], 'url' => $_GPC['url'], 'pay_suc' => $_GPC['pay_suc'], 'm_pay' => $_GPC['m_pay'], 'm_tuan' => $_GPC['m_tuan'], 'm_cancle' => $_GPC['m_cancle'], 'm_ref' => $_GPC['m_ref'], 'm_send' => $_GPC['m_send'], 'pay_remark' => $_GPC['pay_remark'], 'tuan_remark' => $_GPC['tuan_remark'], 'tuan_suc' => $_GPC['tuan_suc'], 'cancle_remark' => $_GPC['cancle_remark'], 'cancle' => $_GPC['cancle'], 'send_remark' => $_GPC['send_remark'], 'send' => $_GPC['send'], 'ref_remark' => $_GPC['ref_remark'], 'ref' => $_GPC['ref'], 'sname' => $_GPC['sname'], 'slogo' => $_GPC['slogo'], 'copyright' => $_GPC['copyright'], 'content' => htmlspecialchars_decode($_GPC['content'])); if ($this->saveSettings($dat)) { message('保存成功', 'refresh'); } } //这里来展示设置项表单 include $this->template('setting'); }
function error($message, $title) { global $link, $game_config; if ($game_config['debug'] == 1) { echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; echo "<table>" . $this->log . "</table>"; } //else{ //A futuro, se creara una tabla especial, para almacenar //los errores que ocurran. global $user, $xnova_root_path, $phpEx; include $xnova_root_path . 'config.' . $phpEx; if (!$link) { die('mySQL no esta disponible por el momento, sentimos el inconveniente...'); } $query = "INSERT INTO {{table}} SET\n\t\t\t\t`error_sender` = '{$user['id']}' ,\n\t\t\t\t`error_time` = '" . time() . "' ,\n\t\t\t\t`error_type` = '{$title}' ,\n\t\t\t\t`error_text` = '" . mysql_escape_string($message) . "' ,\n\t\t\t\t`error_page` = '" . mysql_escape_string($_SERVER['HTTP_REFERER']) . "';"; $sqlquery = mysql_query(str_replace("{{table}}", $dbsettings["prefix"] . 'errors', $query)) or die('error fatal'); $query = "explain select * from {{table}}"; $q = mysql_fetch_array(mysql_query(str_replace("{{table}}", $dbsettings["prefix"] . 'errors', $query))) or die('error fatal: '); if (!function_exists('message')) { echo "Fehler, bitte den Fehler dem Administrator melden. Fehler n°: <b>" . $q['rows'] . "</b>"; } else { message("Fehler, bitte den Fehler dem Administrator melden. Fehler n°: <b>" . $q['rows'] . "</b>", "Erreur"); } //} die; }
public function _remap($referrer) { $referrer = $referrer === 'index' ? NULL : $referrer; $this->session->set_flashdata('referrer', $referrer); if ($this->uri->segment(3)) { redirect('register/' . $referrer); } if (!$this->session->userdata('logged_in')) { $this->lang->load('login'); if ($this->input->server('REQUEST_METHOD') === 'POST') { $referrer = $this->session->flashdata('referrer'); if (!$this->input->post('username') or !$this->input->post('email')) { message(lang('login.reg_incomplete'), 'register' . ($referrer ? '/' . $referrer : '')); } elseif ($this->user->register($this->input->post('username'), $this->input->post('email'), $referrer)) { message(lang('login.reg_correct')); } else { message($this->user->register_errors, 'register' . ($referrer ? '/' . $referrer : '')); } } else { $data['license'] = $this->load->view('license', '', TRUE); $data['menu'] = $this->load->view('public/menu', '', TRUE); $this->load->view('public/register', $data); } } else { redirect('/'); } }
public function getAccessToken() { global $_W, $_GPC; load()->func('communication'); if (!empty($_W['account']['access_token']) && is_array($_W['account']['access_token']) && !empty($_W['account']['access_token']['token']) && !empty($_W['account']['access_token']['expire']) && $_W['account']['access_token']['expire'] > TIMESTAMP) { return $_W['account']['access_token']['token']; } if (empty($_W['account']['key']) || empty($_W['account']['secret'])) { return error('-1', '未填写公众号的 appid 及 appsecret!'); } $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$_W['account']['key']}&secret={$_W['account']['secret']}"; $content = ihttp_get($url); if (is_error($content)) { message('获取微信公众号授权失败, 请稍后重试!错误详情: ' . $content['message']); } $token = @json_decode($content['content'], true); if (empty($token) || !is_array($token) || empty($token['access_token']) || empty($token['expires_in'])) { $errorinfo = substr($content['meta'], strpos($content['meta'], '{')); $errorinfo = @json_decode($errorinfo, true); message('获取微信公众号授权失败, 请稍后重试! 公众平台返回原始数据为: 错误代码-' . $errorinfo['errcode'] . ',错误信息-' . $errorinfo['errmsg']); } $record = array(); $record['token'] = $token['access_token']; $record['expire'] = TIMESTAMP + $token['expires_in'] - 200; $row = array(); $row['access_token'] = iserializer($record); pdo_update('account_wechats', $row, array('acid' => $_W['account']['acid'])); $_W['account']['access_token'] = $record; return $record['token']; }
public function doWebContent() { $aid = q('get.aid', 0, 'intval'); //文章 $article = Db::table('web_article')->where('siteid', SITEID)->where('aid', $aid)->first(); if (empty($article)) { message('文章不存在', 'back', 'error'); } $article['url'] = web_url('entry/content', ['aid' => $article['aid'], 'cid' => $article['category_cid']], 'article'); //栏目 $category = Db::table('web_category')->where('cid', $article['category_cid'])->first(); $category['url'] = empty($category['cat_linkurl']) ? web_url('entry/category', ['cid' => $category['cid']], 'article') : $category['cat_linkurl']; //模板风格 $template_name = $article['template_name'] ?: $category['template_name']; if (empty($template_name)) { $template_name = Db::table('web')->where('id', $this->webid)->pluck('template_name'); if (empty($template_name)) { $template_name = Db::table('template')->where('is_default', 1)->pluck('name'); } } $path = "theme/{$template_name}/{$this->dir}"; if (is_file($path . '/article.html')) { $tpl = $path . '/article.html'; define('__TEMPLATE__', $path); } else { //模板不存在时使用默认模板 $tpl = 'theme/default/' . $this->dir . '/article.html'; define('__TEMPLATE__', "theme/default/{$this->dir}"); } View::with('hdcms', $article); View::with('category', $category); return View::make($tpl); }
function main() { global $G; message("PHP testing sandbox (%s) version %s", $G['ME'], VERSION); try { $db = new SQLite3(DATABASE); $db->exec('DROP TABLE IF EXISTS t'); $db->exec('CREATE TABLE t (a, b, c)'); message('Table t sucessfully created'); $sth = $db->prepare('INSERT INTO t VALUES (?, ?, ?)'); $sth->bindValue(1, 'a'); $sth->bindValue(2, 'b'); $sth->bindValue(3, 'c'); $sth->execute(); $sth->bindValue(1, 1); $sth->bindValue(2, 2); $sth->bindValue(3, 3); $sth->execute(); $sth->bindValue(1, 'one'); $sth->bindValue(2, 'two'); $sth->bindValue(3, 'three'); $sth->execute(); $sth = $db->prepare('SELECT * FROM t'); $result = $sth->execute(); while ($row = $result->fetchArray(SQLITE3_ASSOC)) { message('%s, %s, %s', $row['a'], $row['b'], $row['c']); } } catch (Exception $e) { message($e->getMessage()); } }
function process_form() { global $phpcid, $vars, $phpcdb, $phpc_script, $phpc_cal; verify_token(); $user = $phpcdb->get_user($vars["uid"]); // Remove existing groups for this calendar foreach ($user->get_groups() as $group) { if ($group["cid"] == $phpcid) { $phpcdb->user_remove_group($vars["uid"], $group["gid"]); } } $valid_groups = array(); foreach ($phpc_cal->get_groups() as $group) { $valid_groups[] = $group["gid"]; } if (!empty($vars["groups"])) { foreach ($vars["groups"] as $gid) { if (!in_array($gid, $valid_groups)) { soft_error("Invalid gid"); } $phpcdb->user_add_group($vars["uid"], $gid); } } return message(__('Groups updated.')); }
public function fillCollection(CollectionInterface $collection) { message('Collection of ' . get_class($collection->first()) . ' (' . get_class($this->getLeftEntity()) . ')' . ' ' . get_class($this) . ' ' . get_class($this->getRightEntity())); /** * Prepare relations on left records. */ message('Left collection has ' . $collection->count() . ' record(s), filling ' . $this->fill); $collection->each(function (Record $record) { $record->setRelation($this->fill, new Collection()); }); /** * Get records from right entity. */ $rightCollection = $this->getRightCollection($this->getRightEntity(), $this->foreignKey, $collection->map($this->primaryKey)->unique()); message('Right collection has ' . $rightCollection->count() . ' record(s)'); /** * Key collection for simpler processing. */ $keyedCollection = $collection->keyBy($this->primaryKey); /** * Set relations on left records. */ $rightCollection->each(function ($rightRecord) use($keyedCollection) { if ($keyedCollection->hasKey($rightRecord->{$this->foreignKey})) { $keyedCollection[$rightRecord->{$this->foreignKey}]->getRelation($this->fill)->push($rightRecord); } }); /** * Fill relations. */ $this->fillCollectionWithRelations($collection); }
public function settingsDisplay($settings) { global $_GPC, $_W; if (checksubmit()) { if (empty($_GPC['sendmail']) || empty($_GPC['senduser']) || empty($_GPC['sendpwd'])) { message('请完整填写邮件配置信息', 'refresh', 'error'); } if ($_GPC['host'] == 'smtp.qq.com' || $_GPC['host'] == 'smtp.gmail.com') { $secure = 'ssl'; $port = '465'; } else { $secure = 'tls'; $port = '25'; } $result = $this->sendmail($_GPC['host'], $secure, $port, $_GPC['sendmail'], $_GPC['senduser'], $_GPC['sendpwd'], $_GPC['sendmail']); $cfg = array('host' => $_GPC['host'], 'secure' => $secure, 'port' => $port, 'sendmail' => $_GPC['sendmail'], 'senduser' => $_GPC['senduser'], 'sendpwd' => $_GPC['sendpwd'], 'status' => $result); if ($result == 1) { $this->saveSettings($cfg); message('邮箱配置成功', 'refresh'); } else { message('邮箱配置信息有误', 'refresh', 'error'); } } include $this->template('setting'); }
function checkaccount() { global $_W; if (empty($_W['uniacid'])) { message('这项功能需要你选择特定公众号才能使用!', url('account/display'), 'info'); } }
/** * @param $method * @param $args * * @return $this */ public function __call($method, $args) { if (method_exists($this->getQuery(), $method)) { /** * First overload Query. */ message(get_class($this) . '->__call(' . $method . ') on query ' . get_class($this->getQuery())); Reflect::method($this->getQuery(), $method, $args); } elseif (method_exists($this->getRightEntity(), $method)) { /** * Then right entity. */ message(get_class($this) . '->__call(' . $method . ') on right entity ' . get_class($this->getRightEntity())); Reflect::method($this->getRightEntity(), $method, $args); } elseif (method_exists($this, 'getMiddleEntity') && method_exists($this->getMiddleEntity(), $method)) { /** * Then middle entity. */ message(get_class($this) . '->__call(' . $method . ') on middle entity ' . get_class($this->getMiddleEntity())); Reflect::method($this->getMiddleEntity(), $method, $args); } else { message(get_class($this) . '->__call(' . $method . ') with right entity ' . get_class($this->getRightEntity())); $this->callWith($method, $args, $this->getRightEntity()); } return $this; }