function logout() { foreach ($_SESSION as $k => $v) { unset($_SESSION[$k]); } return info_page('Logout'); }
function test_info_page() { ob_start(); info_page('hello kitty'); $out1 = ob_get_contents(); ob_end_clean(); $this->assertTrue(strpos($out1, '系统消息')); $this->assertTrue(strpos($out1, 'hello kitty')); }
function index() { if (!is_login()) { info_page("<a href='/?c=weibo&a=login'>请用已授权的微博帐号登入</a>"); exit; } $data['title'] = $data['top_title'] = '首页'; $data['url'] = get_channel_url(); render($data, 'web', 'ban'); }
function index() { if (is_installed()) { return info_page(__('INSTALL_FINISHED')); } elseif (intval(v('do')) == 1) { db_init(); } else { $data['title'] = $data['top_title'] = __('INSTALL_PAGE_TITLE'); return render($data, 'web', 'fullwidth'); } }
function index() { if (is_installed()) { return info_page('API Server 已初始化完成,<a href="?c=guest">请使用管理账号登入</a>'); } elseif (intval(v('do')) == 1) { db_init(); } else { $data['title'] = $data['top_title'] = 'TeamToy安装页面'; return render($data, 'web', 'fullwidth'); } }
function plugin_mycss_save() { $css = z(t(v('css'))); $sql = "REPLACE INTO `css` ( `uid` , `css` ) VALUES ( '" . intval(uid()) . "' , '" . s($css) . "' )"; run_sql($sql); $location = '?c=plugin&a=mycss'; if (db_errno() != 0) { return info_page('数据保存失败,请稍后重试。<a href="' . $location . '">点击返回</a>'); } else { header("Location:" . $location); } }
function plugin_mycss_save() { $css = z(t(v('css'))); $sql = "REPLACE INTO `css` ( `uid` , `css` ) VALUES ( '" . intval(uid()) . "' , '" . s($css) . "' )"; run_sql($sql); $location = '?c=plugin&a=mycss'; if (db_errno() != 0) { return info_page(__('PL_CSS_MODIFIER_DATE_UPDATE_ERROR', $location)); } else { header("Location:" . $location); } }
function check_login() { $not_check = array(); $not_check = apply_filter('CTRL_PLUGIN_LOGIN_FILTER', $not_check); if (strtolower(g('c')) == 'plugin' && in_array(g('a'), $not_check)) { // for some plugin no need to login // not check } else { if (!is_login()) { return info_page(__('NEED_LOGIN')); } } }
function check_login() { $not_check = array(); $not_check = apply_filter('CTRL_PLUGIN_LOGIN_FILTER', $not_check); if (strtolower(g('c')) == 'plugin' && in_array(g('a'), $not_check)) { // for some plugin no need to login // not check } else { if (!is_login()) { return info_page('您访问的页面需要先<a href="?c=guest">登入</a>'); } } }
function add() { $number = intval(v('number')); if ($number < 1) { info_page(_text('system_input_right_no')); } if (intval($this->invite->get_invite_limit()) && intval($this->invite->get_invite_limit()) < $number) { info_page(_text('invite_buy_over_limit')); } if ($this->invite->buy($number)) { info_page(_text('invite_buy_success'), '/invite/myinvite'); } else { info_page(_text('invite_buy_money_limit')); } }
function db_init() { $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12); $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql')); // 更换变量 $sql_contents = str_replace('{password}', md5($password), $sql_contents); $sqls = split_sql_file($sql_contents); foreach ($sqls as $sql) { run_sql($sql); } if (db_errno() == 0) { info_page(__('DATABASE_INIT_FINISHED', $password)); exit; } else { info_page(db_error()); exit; } }
function update() { $fid = intval(v('fid')); if ($fid < 1) { info_page('错误的form参数'); } $uid = format_uid(); $data = array(); $data['name'] = z(v('name')); $data['title'] = z(v('title')); $data['subtitle'] = z(v('subtitle')); $data['item_name'] = z(v('item_name')); $data['is_main_app'] = z(v('is_main_app')); $this->db->where('id', $fid); $this->db->where('uid', $uid); $this->db->update('w2_form', $data); header('Location: /design/build/' . $fid); }
function db_init() { $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12); $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql')); // 更换变量 $sql_contents = str_replace('{password}', md5($password), $sql_contents); $sqls = split_sql_file($sql_contents); foreach ($sqls as $sql) { run_sql($sql); } if (db_errno() == 0) { info_page('数据库初始化成功,请使用【member@teamtoy.net】和【' . $password . '】<a href="/" target="new">登入并添加用户</a>'); exit; } else { info_page(db_error()); exit; } }
function native() { // $args = func_get_args(); $folder = array_shift($args); $GLOBALS['app'] = $folder; $action = array_shift($args); if ($action == '') { $action = 'index'; } $GLOBALS['action'] = $action; $code_file = APPPATH . 'app/' . basename($folder) . '/controller/' . basename($action) . '.php'; if (file_exists($code_file)) { //check_app( $folder ); @(include_once $code_file); } else { info_page('您访问的应用尚不存在,请联系管理员'); } //print_r( $args ); //if() }
function save() { check_login(); $mail = z(v('email')); if (strpos(_sess('u2_email'), '@') !== false) { info_page('你使用是正确的email'); } if (strpos($mail, '@') === false) { info_page('请填写正确的email'); } $sql = "select count(*) from u2_user where LCASE(u2_email) = '" . strtolower($mail) . "' "; if (lazy_get_var($sql)) { info_page('该email已经有人使用了,请重新填写'); } $this->load->database(); $data['u2_email'] = $mail; $uid = format_uid(); $this->db->where('id', $uid); $this->db->update('u2_user', $data); $this->load->library('session'); $this->session->set_userdata('u2_email', $mail); info_page('补充E-mail信息成功,以后请用email登陆.', '/', '返回首页'); }
include_once dirname(__FILE__) . '/function.php'; if (!is_login()) { info_page('请登录后查看'); } $uid = format_uid(); $folder = z(array_shift($args)); $cid = intval(array_shift($args)); $mid = app_config('mid', $folder); $bind = app_config('bind', $folder); if (!isset($mid)) { info_page('没有此表!'); } if ($bind['price'] == '' || $bind['price'] <= '0') { info_page('价格错误!'); } foreach ($bind as $k => $v) { $selected[] = " `{$v}` as {$k} "; } $com = lazy_get_line("SELECT " . join(',', $selected) . " FROM `app_content_{$mid}` WHERE `id` = '" . intval($cid) . "'"); $cnum = get_count(); if ($cnum == '0') { info_page('没有此件物品!'); } $num = lazy_get_var("SELECT COUNT(*) FROM `app_shopcart` WHERE `cid` = '" . intval($cid) . "' AND `uid` = '" . intval($uid) . "'"); if ($num != '0') { lazy_run_sql("UPDATE `app_shopcart` SET `num` = `num`+1 WHERE `cid` = '" . intval($cid) . "' AND `uid` = '" . intval($uid) . "'"); } else { lazy_run_sql("INSERT INTO `app_shopcart` ( `uid`, `cid`, `name`, `desp`, `num`, `money`, `date`, `folder` ) VALUES ( '" . intval($uid) . "' , '" . intval($cid) . "' , " . s($com['title']) . " , " . s($com['desp']) . " , '1' , " . s($com['price']) . " , '" . date('Y-m-d H:i:s') . "' , " . s($folder) . " )"); } header('Location: /app/native/' . $GLOBALS['app']);
include_once dirname(__FILE__) . '/function.php'; $data['ci_top_title'] = '添加Feed'; if (!is_login()) { info_page('请登录后查看'); } if (!is_admin()) { info_page('你没有权限进行操作!'); } $feed_id = intval(array_shift($args)); if ($feed_id != '0') { $feed = lazy_get_var("SELECT `feed` FROM `app_feed_recommend` WHERE `id` = '" . $feed_id . "' LIMIT 1"); } else { $feed = v('fblog'); if (!$feed || $feed == 'http://') { info_page('你提交的博客地址错误'); } if (strpos($feed, 'http://') === false) { $feed = 'http://' . $feed; } } $CI =& get_instance(); $CI->load->library('simplepie'); MakeDir(ROOT . 'static/data/cache'); $CI->simplepie->set_cache_location(ROOT . 'static/data/cache'); $CI->simplepie->set_feed_url($feed); $CI->simplepie->init(); $data['ftitle'] = $CI->simplepie->get_title(); //标题 $flink = $CI->simplepie->get_link(); //连接地址
function cate_do_action($action, $cid, $name = NULL) { if ($action == '1') { $this->db->select('*')->from('u2_cate')->where('id', $cid); $cinfo = lazy_get_line(); $this->db->select('count(*)')->from('u2_cate')->where('u2_cate_num <', $cinfo['u2_cate_num'] . '9999')->where('u2_cate_num >', $cinfo['u2_cate_num'] . '0000'); $count = lazy_get_var(); if ($count) { info_page(_text('admin_data_cate_del_error')); die; } $this->db->where('u2_cate', $cid); $this->db->delete('u2_content'); $this->db->where('u2_cate_id', $cid); $this->db->delete('u2_meta_field'); $this->db->where('id', $cid); $this->db->delete('u2_cate'); } elseif ($action == '2') { $this->db->where('id', $cid); $data['u2_cate_desc'] = $name; $this->db->update('u2_cate', $data); } elseif ($action == '0') { if ($cid != '0') { $this->db->select('*')->from('u2_cate')->where('id', $cid); $cinfo = lazy_get_line(); $father_num = $cinfo['u2_cate_num']; } else { $father_num = NULL; } $this->db->select('*')->from('u2_cate')->where('u2_cate_num <', $father_num . '9999')->where('u2_cate_num >', $father_num . '0000')->orderby('u2_cate_num', 'DESC')->limit(1); $now = lazy_get_line(); if (!isset($now['u2_cate_num']) || strlen($now['u2_cate_num']) == strlen($father_num)) { $data['u2_cate_num'] = $father_num . '0001'; } else { $temp = substr($now['u2_cate_num'], -4) + 1; //$temp = str_replace( $father_num , '' ,$now['u2_cate_num']) + 1; $data['u2_cate_num'] = $father_num . str_pad($temp, 4, "0", STR_PAD_LEFT); } $data['u2_cate_desc'] = $name; $this->db->insert('u2_cate', $data); } }
function uploaded() { if (!is_admin()) { return info_page(__('ADMIN_ONLY_LOGIN')); } if ($_FILES['pfile']['error'] != 0) { return info_page(__('PLUGIN_UPLOAD_FILE_ERROR_RETRY')); } $tmp_name = $_FILES['pfile']['tmp_name']; $tname = uid() . '-' . time(); $plug_path = c('plugin_path') . DS . $tname; if (@mkdir($plug_path)) { include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php'; $zip = new dUnzip2($tmp_name); $zip->debug = false; $zip->unzipAll($plug_path); @chmod($plug_path, 0755); $info_file = $plug_path . DS . 'app.php'; if (file_exists($info_file)) { if ($info = get_plugin_info(file_get_contents($info_file))) { if (isset($info['folder_name'])) { $folder_name = $info['folder_name']; } if (strlen($folder_name) < 1) { $folder_name = reset(explode('.', basename($_FILES['pfile']['name']))); } if (strlen($folder_name) > 0) { if (file_exists(c('plugin_path') . DS . $folder_name)) { @rename(c('plugin_path') . DS . $folder_name . DS . 'app.php', c('plugin_path') . DS . $folder_name . DS . 'app.bak.php'); @rename(c('plugin_path') . DS . $folder_name, c('plugin_path') . DS . $folder_name . '_' . uid() . '_' . time()); } rename($plug_path, c('plugin_path') . DS . $folder_name); header("Location: ?c=pluglist"); return true; } else { return info_page(__('PLUGIN_GET_NAME_ERROR_RETRY', $tname)); } } } else { // clear dir } return info_page(__('PLUGIN_PACKAGE_FORMAT_ERROR')); } else { return info_page(__('PLUGIN_CREATE_FOLDER_ERROR')); } }
<?php include_once dirname(__FILE__) . '/function.php'; $data['ci_top_title'] = '添加分类'; if (!is_login()) { info_page('请登录后查看'); } if (!is_admin()) { info_page('你没有权限进行操作!'); } $tname = trim(z(v('tname'))); if (empty($tname)) { info_page('分类名称不能为空!'); } $config_data['titles'] = app_config('titles'); $config_data['titles'][] = $tname; save_app_config($config_data); info_page('添加成功!', '/app/native/' . $GLOBALS['app'] . '/feed', '点击这里返回!');
public function logout() { foreach ($_SESSION as $k => $v) { unset($_SESSION[$k]); } return info_page('<a href="/">成功退出,点击返回首页</a>'); }
function contact() { return info_page("Sina Weibo - <a href='http://weibo.com/easy' target='_blank'>@Easy</a> | Twitter - @Easychen", "Follow Me"); }
$uid = format_uid(); $insert_feed = "INSERT INTO `app_feed` (`feed`, `tid`, `uid`, `title`, `time`, `img`, `state`) VALUES"; $insert_feed .= "(" . s($feed) . ", '" . intval($tid) . "', '" . intval($uid) . "', " . s($title) . ", '" . date('Y-m-d H:i:s') . "', '" . $img . "' , '" . $status . "')"; lazy_run_sql($insert_feed); $fid = lazy_last_id(); //add feed item $CI =& get_instance(); $CI->load->library('simplepie'); //MakeDir(ROOT.'static/data/cache'); //$CI->simplepie->set_cache_location(ROOT.'static/data/cache'); $CI->simplepie->set_feed_url($feed); $CI->simplepie->init(); $items = $CI->simplepie->get_items(); $values = array(); foreach ($items as $k => $v) { $title = $v->get_title(); // 标题 $desp = $v->get_content(); // 内容 $link = $v->get_link(); //连接 $date = date('Y-m-d H:i:s', strtotime($v->get_date())); $unistring = md5($link) . $date; $values[] = "('" . intval($tid) . "', '" . intval($fid) . "', " . s($title) . ", " . s($desp) . ", '" . $date . "' , '" . $link . "', '" . $status . "', " . s($unistring) . ", '" . intval($uid) . "')"; } $sql_insert_item = "INSERT INTO `app_feed_item` (`tid`, `fid`, `title`, `desp`, `time`, `link`, `state`, `unistring`, `admin_uid`) VALUES " . join(',', $values) . ""; //echo $sql_insert_item; lazy_run_sql($sql_insert_item); info_page("Feed成功保存!", "/app/native/" . $GLOBALS['app'] . "/feed/", "返回管理"); ?>
} $id = intval(array_shift($args)); $wid = intval(array_shift($args)); $uid = format_uid(); $order = lazy_get_line("SELECT * FROM `app_shoporder` WHERE `id` = '" . intval($id) . "' AND `enter` = '0' LIMIT 1"); if (!$order) { info_page('您没有此条订单'); } if ($uid != $order['uid']) { info_page('您没有权限进行此次操作!'); } $ware = unserialize($order['ware']); if (!in_array($ware[$wid], $ware)) { info_page('参数错误!'); } unset($ware[$wid]); $money_sum = 0; foreach ($ware as $k => $v) { $money_sum = $money_sum + $v['num'] * $v['money']; } $money_end = $money_sum * ($agio / 100); //应付 $stint = $money_sum - $money_end; //节省 if (!isset($ware) || empty($ware)) { lazy_run_sql("DELETE FROM `app_shoporder` WHERE `id` = '" . intval($id) . "'"); info_page('订单中没有商品了,订单已被删除!', '/app/native/' . $GLOBALS['app'], '反回购物车!'); } $ware = serialize($ware); lazy_run_sql("UPDATE `app_shoporder` SET `ware` = " . s($ware) . " , `money` = '" . $money_end . "' , `stint` = '" . $stint . "' WHERE `id` = '" . intval($id) . "'"); header('Location: /app/native/' . $GLOBALS['app'] . '/order_modify/' . $id);
function save($folder = NULL) { check_login(); $key = v('input_name'); $type = v('type'); if (!is_admin()) { $this->check_upload($folder, $key); } $file = $_FILES['u2_file']; if ($file['error'] == 2 || c('max_file_size') > 0 && $file['size'] > c('max_file_size')) { info_page('您上传的文件超过系统允许的范围(' . intval(intval(c('max_file_size')) / 1024) . 'k),请重新选择文件'); exit; } if (!isset($file['size']) || !($file['size'] > 0)) { info_page('错误的文件'); } $end = $ext = end(explode('.', strtolower($file['name']))); if ($type == 'pic' || $type == 'multi-pic') { $file_info = getimagesize($file['tmp_name']); $ext = $file_info['mime']; $allow_list = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); } elseif ($type == 'file') { $allow_list = explode('|', c('web_site_upload_file_type')); } else { info_page('错误的上传类型'); } if (!in_array($ext, $allow_list)) { info_page('您上传的文件类型不被允许,请重新选择文件'); exit; } $time = date("y/m/d H_i_s"); $paths = explode(' ', $time); $file_dir = ROOT . 'static/data/hash/content_attachment/' . $folder . '/' . $paths[0] . '/'; $web_dir = 'static/data/hash/content_attachment/' . $folder . '/' . $paths[0] . '/'; $file_name = 'file_' . $paths[1] . rand(1, 100000000) . '.' . $end; MakeDir($file_dir); if (move_uploaded_file($file['tmp_name'], $file_dir . $file_name)) { $upload_url = '/' . $web_dir . $file_name; $this->show_js($key, $upload_url, $type); } else { info_page('上传的文件不成功,请稍后再试'); exit; } }
<?php include_once dirname(__FILE__) . '/function.php'; // clear data $type = intval(v('type')); $url = z(v('url')); $desp = n(v('desp')); if ($type < 1 || strlen($url) < 1) { info_page('分享格式不正确'); } $data = array(); $data['type'] = $type; $data['link'] = $url; $data['time'] = date("Y-m-d H:i:s"); $data['desp'] = $desp; switch ($type) { case VIDEO: $info = parse_url($url); $data['video_domain'] = $info['host']; $cnname = '视频'; break; case MUSIC: $data['music_url'] = $url; $cnname = '音乐'; break; case WEBPAGE: $cnname = '网页'; break; } $data['uid'] = format_uid(); global $CI;
foreach (app_config('titles') as $k => $v) { $t**s[$k] = $k; $titles[$k] = $v; } $data['t**s'] = $t**s; unset($titles[1]); $data['fselect'] = $titles; $view = array_shift($args); if ($view == 'add') { $data['view'] = 'add'; } //分类ID $tnum = intval($view); if ($tnum != '0') { if (!in_array($tnum, $t**s)) { info_page('错误的分类'); } $where = "AND `tid` = '" . intval($tnum) . "'"; $data['tnum'] = $tnum; } //待处理 $waiting = lazy_get_data("SELECT * FROM `app_feed_recommend` ORDER BY `timeline` DESC LIMIT 30 "); if ($waiting) { $data['content'] = $content = $waiting; foreach ($content as $k => $v) { $uids[] = $v['uid']; $times[$v['id']] = time2Units($v['timeline']); } $data['unames'] = get_name_by_uids($uids); $data['waiting'] = $waiting; $data['times'] = $times;
<?php if (!is_login()) { info_page('请登录后查看'); } include_once dirname(__FILE__) . '/function.php'; $data = array(); $tab_type = 'items'; $data['ci_top_title'] = '物品'; $data['tab_type'] = $tab_type; $data['tab_array'] = $tab_array; $page = array_shift($args); $page = intval($page) < 1 ? 1 : intval($page); $limit = '48'; $start = ($page - 1) * $limit; $uid = format_uid(); $items = lazy_get_data("select sql_calc_found_rows * from `global_user_items` where `uid` = '{$uid}' and `count` > 0 LIMIT {$start} , {$limit} "); $all = get_count(); $base = '/app/native/ihome/items'; $page_all = ceil($all / $limit); $data['pager'] = get_pager($page, $page_all, $base); $data['list'] = array(); if ($items) { foreach ($items as $v) { $iid[] = $v['iid']; $count[$v['iid']] = $v['count']; } $items_info = lazy_get_data("select * from `global_items` where `id` IN(" . join(',', $iid) . ") "); if ($items_info) { foreach ($items_info as $v) { $v['count'] = $count[$v['id']];
<?php include_once dirname(__FILE__) . '/function.php'; if (!is_login()) { info_page('请登录后查看'); } $fid = intval(array_shift($args)); $tab_type = array_shift($args); $tab_type = !$tab_type ? 'basic' : $tab_type; $fid = $fid < 1 ? 1 : $fid; $data = array(); $data['forum'] = lazy_get_line("SELECT * from `app_iforum_status` where `id` = '{$fid}' and `is_active` = '1' limit 1"); if (!$data['forum']) { info_page('错误的论坛id'); } $data['fid'] = $fid; $data['ci_top_title'] = '修改论坛'; $data['cates'] = iforum_get_cates($fid); $data['tab_type'] = $tab_type; $data['tab_array'] = array('basic' => '基础设置', 'cates' => '分类设置'); layout($data, 'default', 'app');
<?php include_once dirname(__FILE__) . '/function.php'; if (!is_login()) { info_page('请登录后查看'); } if (!is_admin()) { info_page('你没有权限进行操作!'); } $wid = intval(array_shift($args)); if (!isset($wid) || $wid < 1) { info_page("ID错误!"); } $wnum = lazy_get_var("SELECT * FROM `app_feed_recommend` WHERE `id` = '" . intval($wid) . "'"); if (!$wnum) { info_page("没有此条记录"); } lazy_run_sql("DELETE FROM `app_feed_recommend` WHERE `id` = '" . intval($wid) . "' LIMIT 1"); header('Location:/app/native/' . $GLOBALS['app'] . '/feed'); ?>