/** * 获取当前用户信息 * @return bool|mixed */ public function getCurrentUserInfo() { $con = array('id' => $_SESSION['Fei_Userid']); $userInfo = $this->find($con); $userInfo['roleName'] = FeiClass('model_user_role')->getNameById($userInfo['roleId']); return $userInfo; }
function index() { if (isset($_POST['action']) && $_POST['action'] == 'get_rss_content') { $rss = FeiClass(FeiRss); $rss = $rss->loadRss("http://news.qq.com/newsgn/rss_newsgn.xml"); echo 'Title: ', $rss->title; echo 'Description: ', $rss->description; echo 'Link: ', $rss->link; foreach ($rss->item as $item) { $str .= "<tr>\n <td>\n " . $item->title . "\n </td>\n <td>\n " . $item->description . "\n </td>\n <td>\n " . date('Y-m-d H:i:s', $item->timestamp) . "\n </td>\n <td class=\"center\">\n <a href=\"" . $item->link . "\" class=\"button small grey tooltip\" data-gravity=s title=\"Edit\">\n <i class=\"icon-pencil\"></i>\n </a>\n </td>\n <td class=\"center\">\n " . $item->{'content:encoded'} . "\n </td>\n </tr>"; } echo $str; exit; } elseif (isset($_POST['action']) && $_POST['action'] == 'add_rss') { $rss_source = FeiClass(model_rss); $conditions = array('userid' => $_SESSION['Fei_Userid'], 'name' => $this->FeiArgs('name'), 'url' => $this->FeiArgs('url')); $this->__check_istrue($rss_source->create($conditions)); } $rss = FeiClass(FeiRss); $rss->load("http://news.qq.com/newsgn/rss_newsgn.xml"); $this->rss_lists = $rss->getItems(); //dump($this->rss_lists); $rss_source = FeiClass(model_rss); $r_con = array('userid' => $_SESSION['Fei_Userid']); $this->rss_source = $rss_source->findAll($r_con); }
function product() { $product = FeiClass('model_product'); if (isset($_FILES['product_pic']) && !empty($_FILES['product_pic'])) { $upload = FeiClass('FeiUpload'); if ($upload->upload_file($_FILES['product_pic'])) { //Upload Success $conditions = array('name' => $this->FeiArgs('product_name'), 'pic' => $upload->new_name, 'link' => $this->FeiArgs('product_link'), 'description' => $this->FeiArgs('product_desc'), 'userid' => $_SESSION['Fei_Userid']); if ($product->create($conditions)) { $this->jump(FeiUrl('profile', 'product')); } else { $this->error('error', FeiUrl('profile', 'product')); } } else { $this->error($upload->errmsg, FeiUrl('profile', 'product')); } } elseif (isset($_POST['action']) && $_POST['action'] == 'get_product_content') { $conditions = array('userid' => $_SESSION['Fei_Userid']); $products = $product->findAll($conditions); $str = ""; foreach ($products as $p) { $str .= "<div class=\"image\">\n <span class=\"badge\">\n 新\n </span>\n <a href=\"" . $this->PIC . $p['pic'] . "\">\n <img src=\"" . $this->PIC . $p['pic'] . "\" width=\"160\" />\n </a>\n <span>" . $p['name'] . "</span>\n </div>"; } echo $str; exit; } }
/** * 无权限提示跳转 */ public function prompt() { $prompt = $this->prompt; if (is_array($prompt)) { return FeiClass($prompt[0])->{$prompt[1]}(); } else { return call_user_func_array($prompt, array()); } }
/** * 注册视图函数 */ public function addfuncs() { if (is_array($GLOBALS['G_Fei']["view_registered_functions"])) { foreach ($GLOBALS['G_Fei']["view_registered_functions"] as $alias => $func) { if (is_array($func) && !is_object($func[0])) { $func = array(FeiClass($func[0]), $func[1]); } $this->engine->registerPlugin("function", $alias, $func); unset($GLOBALS['G_Fei']["view_registered_functions"][$alias]); } } }
function index() { if ($_SESSION['In_www']) { if (FeiClass('FeiAcl')->get() == 'Fei_Admin') { $this->login = TRUE; } else { $this->login = FALSE; } $this->display('index.html'); exit; } else { //$theme_info = parse_ini_file(APP_PATH.'/themes/you/config.fei',true); //print_r($theme_info); //print_r($GLOBALS['G_Fei']); $this->PATH = "http://wufeifei.grw.name/themes/you/"; //$this->gg = FeiClass('TemplateParse'); $user = FeiClass('model_user'); $url = explode('.', $_SERVER['HTTP_HOST']); $url = $url[0]; if ($user->check_url($url)) { $info = $user->getinfo(); //User Info $this->name = $info['realname']; $this->position = $info['position']; $this->email = $info['email']; $this->address = $info['address']; $this->phone = $info['phone']; $this->qq = $info['qq']; $this->birthday = $info['birthday']; $this->description = $info['description']; //Find Conditions $userid = $info['id']; $conditions = array('userid' => $userid); //Skill Info $skill = FeiClass('model_skill'); $skills = $skill->findAll($conditions); $this->skills = $skills; //Work Info $work = FeiClass('model_work'); $w_c = array('userid' => $userid); $works = $work->findAll($conditions); $this->works = $works; //Education Info $education = FeiClass('model_education'); $educations = $education->findAll($conditions); $this->educations = $educations; $this->display(APP_PATH . '/themes/you/index.html'); } else { echo '你要访问的网站不存在或已关闭!'; } } }
public function maybe($tagid) { $todo = FeiClass('model_todo'); $con = array('tagid' => $tagid, 'userid' => $_SESSION['Fei_Userid']); if ($this->find($con)) { $con2 = array('status' => 3, 'userid' => $_SESSION['Fei_Userid'], 'tags' => $tagid); $num = $todo->findCount($con2); $row = array('maybe' => $num); return $this->update($con, $row); } else { return FALSE; } }
function api() { include_once APP_PATH . '/lib/elFinderConnector.class.php'; include_once APP_PATH . '/lib/elFinder.class.php'; include_once APP_PATH . '/lib/elFinderVolumeDriver.class.php'; include_once APP_PATH . '/lib/elFinderVolumeLocalFileSystem.class.php'; include_once APP_PATH . '/lib/elFinderVolumeMySQL.class.php'; $id = FeiClass('model_yunpan')->index(); $option = array('roots' => array(array('driver' => 'MySQL', 'path' => $id, 'accessControl' => 'access', 'uploadMaxSize' => '10000K', 'acceptedName' => ''))); //print_r($opts);exit; $connector = new elFinderConnector(new elFinder($option)); $connector->run(); }
function branch() { $branch = FeiClass(model_system); $branchs = $branch->findAll('', '', 'branch'); $branchs = explode('|', $branchs[0][branch]); $user = FeiClass(model_user); foreach ($branchs as $k => $v) { $branchs['key' . $k]['zhi'] = $v; $condition = array('branch' => $v); $branchs['key' . $k]['num'] = $user->findCount($condition); unset($branchs[$k]); } //print_r($branchs); $this->branchs = $branchs; }
/** * 供第三方调用的API接口(Chrome Extension、App) * @author Feei(wufeifei@wufeifei.com) */ function index() { $action = $this->FeiArgs('action', NULL, 'POST'); $data = $this->FeiArgs(NULL, NULL, 'POST'); switch ($action) { case 'is_login': if (FeiClass(FeiAcl)->get() == 'Fei_Admin') { $this->__check_istrue(TRUE, '已经登陆'); } else { $this->__check_istrue(FALSE, '登陆失败'); } break; default: # code... break; } }
/** * 魔术函数 通过函数名来调用不同的缓存驱动类 */ public function __call($name, $args) { $driverClass = 'access_driver_' . $name; if (!class_exists($driverClass)) { FeiError('FeiAccess无法找到名为{$name}缓存驱动程序,请检查!'); } extract(array_pop($args)); if ('w' == $method) { // 写数据 $life_time = -1 == $life_time ? '300000000' : $life_time; return FeiClass($driverClass)->set($name, serialize($value), $life_time); } elseif ('c' == $method) { // 清除数据 return FeiClass($driverClass)->del($name); } else { // 读数据 return unserialize(FeiClass($driverClass)->get($name)); } }
function index() { $password = FeiClass('model_password'); $pcate = FeiClass('model_password_cate'); $action = $this->FeiArgs('action', NULL, 'POST'); $data = $this->FeiArgs(NULL, NULL, 'POST'); switch ($action) { case 'add_pwd': $this->__check_istrue($password->add($data)); break; case 'get_password': $id = $data['id']; $passwords = $password->pwds($id); for ($i = 0; $i < count($passwords); $i++) { $password_html .= "\n\t\t\t\t\t\t<tr>\n <td class=\"center\">\n " . $i . "\n </td>\n <td class=\"center\">\n " . $passwords[$i]['title'] . "\n </td>\n <td class=\"center\">\n " . $passwords[$i]['username'] . "\n </td>\n <td class=\"center\">\n \t" . $passwords[$i]['password'] . "\n </td>\n <td class=\"center\">\n " . $passwords[$i]['remark'] . "\n </td>\n <td class=\"center\">\n \t<a onclick=\"Pwd.edit(" . $passwords[$i]['id'] . ")\" class=\"button small grey tooltip\" gravity=\"s\" title=\"修改\"><i class=\"icon-pencil\"></i></a>\n \t<a onclick=\"Pwd.del(" . $passwords[$i]['id'] . ")\" class=\"button small grey tooltip\" gravity=\"s\" title=\"删除\"><i class=\"icon-remove\"></i></a>\n </td>\n </tr>\n\t\t\t\t\t"; } echo $password_html; exit; case 'del_pwd': $this->__check_istrue($password->del($data)); case 'get_info': $this->__check_istrue($info = $password->info($data), $info); case 'edit_pwd': $this->__check_istrue($password->edit($data)); case 'pcates': $pcates = $pcate->pcates(); for ($i = 0; $i < count($pcates); $i++) { $html .= "\n\t\t\t\t\t<div>\n\t <span class=\"badge blue light icon-user-md\">\n\t " . $pcates[$i]['name'] . "\n\t </span>\n\t <!--<div class=\"right inline\" id=\"m_b\">\n\t <a href=\"javascript:void(0)\" class=\"button small grey tooltip\" data-gravity=\"e\" original-title=\"修改\">\n\t <i class=\"icon-pencil\"></i>\n\t </a>\n\t <a href=\"javascript:void(0)\" onclick=\"Todo.del_tag(1)\" class=\"button small grey tooltip\" gravity=\"w\" title=\"删除" . $pcates[$i]['id'] . "\">\n\t <i class=\"icon-remove\"></i>\n\t </a>\n\t </div>-->\n\t </div>\n\t\t\t\t\t"; } echo $html; exit; case 'add_cate': $this->__check_istrue($pcate->add($data)); default: $this->pcates = $pcate->pcates(); break; } }
function __get_tags($todo_tag) { $tags = FeiClass(model_todo_tags); $conditions = array('userid' => $_SESSION['Fei_Userid']); $this->tags = $tags->findAll($conditions); foreach ($this->tags as $tag) { $str .= "<option value=\"" . $tag['tagid'] . "\" " . $this->__check_equally($todo_tag, $tag['tagid']) . ">" . $tag['name'] . "</option>"; } return $str; }
public function __template_Category($params) { $category = FeiClass(model_category); $result = $category->findBy('letter', $params[letter]); $conditions = array('parentid' => $result[catid]); $result = $category->findAll($conditions); return $result; }
function module() { $action = $this->FeiArgs('action', NULL, 'POST'); $data = $this->FeiArgs(NULL, NULL, 'POST'); $category = FeiClass('model_category'); switch ($action) { case 'get_modules': $categorys = $category->topcategory(); for ($i = 0; $i < count($categorys); $i++) { if ($categorys[$i]['ismenu'] == 1) { $ismenu = "<input type=\"checkbox\" checked=\"checked\" name=\"ismenu_" . $categorys[$i]['catid'] . "\"> 已开启"; } else { if ($categorys[$i]['ismenu'] == 0) { $ismenu = "<input type=\"checkbox\" name=\"ismenu_" . $categorys[$i]['catid'] . "\"> 未开通"; } } $html .= "\n <tr>\n <td>" . $i . "</td>\n <td>\n <img src=\"" . $this->STATICS . "img/icons/packs/fugue/16x16/" . $categorys[$i]['ico'] . ".png\" alt=" . $categorys[$i]['catname'] . " height=16 width=16>\n " . $categorys[$i]['catname'] . "\n </td>\n <td>" . $categorys[$i]['remark'] . "</td>\n <td align=\"center\">\n " . $ismenu . "\n </td>\n </tr>"; } echo $html; exit; default: # code... break; } }
/** * 魔术函数,实现对控制器扩展类的自动加载 */ public function __call($name, $args) { if (in_array($name, $GLOBALS['G_Fei']["auto_load_controller"])) { return FeiClass($name)->__input($args); } elseif (!method_exists($this, $name)) { FeiError("方法 {$name}未定义!<br />请检查是否控制器类(" . get_class($this) . ")与数据模型类重名?"); } }
function json_encode($content) { return FeiClass("Services_JSON")->encode($content); }
function check_cate($id) { $pwd_cate = FeiClass('model_password_cate'); $con = array('id' => $id, 'uid' => $_SESSION['Fei_Userid']); return $pwd_cate->find($con) ? TRUE : FALSE; }
function assets() { $assets = FeiClass('model_money_assets'); $action = $this->FeiArgs('action', NULL, 'POST'); switch ($action) { case 'getAll': $this->__check_istrue($asset = $assets->getAll(), $asset); break; case 'add': $this->__check_istrue($assets->add()); break; case 'del': $this->__check_istrue($assets->del()); break; default: } }
function contacter() { $contact = FeiClass('model_relation_contacter'); $about = FeiClass('model_relation_about'); $action = $this->FeiArgs('action', NULL, 'POST'); $data = $this->FeiArgs(NULL, NULL, 'POST'); switch ($action) { case 'add_contacter': if ($data['birthtype'] == 0) { $lunar = FeiClass('FeiLunar'); $m = date('m', $lunar->S2L($data['birtyday'])); $d = date('d', $lunar->S2L($data['birthday'])); $data['birthday'] = date('Y', strtotime($data['birthday'])) . '-' . $m . '-' . $d; } //Get firstchar $data['firstchar'] = strtolower($this->__Get_firstchar($data['name'])); $this->__check_istrue($id = $contact->add($data), $id); case 'getAll': $cs = $contact->getAll(); for ($i = 0; $i < count($cs); $i++) { if ($cs[$i]['avatar'] == 0) { $avatar = $this->STATICS . "images/avatar2.png"; } else { $avatar = $this->PIC . $_SESSION['Fei_Userid'] . "mb.png"; } //lunar if ($cs[$i]['birthtype'] == 0) { $lunar = FeiClass('FeiLunar'); $m = date('m', strtotime($cs[$i]['birthday'])); $d = date('d', strtotime($cs[$i]['birthday'])); } } $char = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); for ($j = 0; $j < count($char); $j++) { $result = $contact->getchar($char[$j]); if (count($result) == 0) { $lis = "<li></li>"; } else { unset($lis); for ($k = 0; $k < count($result); $k++) { $lis .= "<li><a onclick=\"Contacter.getOne(" . $result[$k]['id'] . ")\">" . $result[$k]['name'] . "</a></li>"; } } unset($ws); if (count($result) != 0) { $ws = '(' . count($result) . '位)'; } $html .= "\n <li id=\"" . $char[$j] . "\"><a name=\"" . $char[$j] . "\" class=\"title\">" . $char[$j] . $ws . "</a>\n <ul>\n " . $lis . "\n </ul>\n </li>"; } echo '<ul>' . $html . '</ul>'; exit; case 'getOne': $result = $contact->getOne($data); if ($result['birthday'] == '1970-01-01') { $result['birthday'] = '未填写'; } else { if ($result['birthtype'] == 0) { $lunar = FeiClass('FeiLunar'); $d = date('d', strtotime($result['birthday'])); $m = date('m', strtotime($result['birthday'])); $y = date('y', strtotime($result['birthday'])); $y = $lunar->LYearName($y); $m = $lunar->LMonName(intval($m)); $d = $lunar->LDayName(intval($d)); $result['birthday'] = $y . '年' . $m . '月' . $d . '(农历)'; } else { if ($result['birthtype'] == 1) { $result['birthday'] .= '(公历)'; } } } if ($result['qq'] == 0) { $result['qq'] = '未填写'; } if ($result['mobile'] == 0) { $result['mobile'] = '未填写'; } if ($result['weibo'] == 0) { $result['weibo'] = '未填写'; } if ($result['email'] == 0) { $result['email'] = '未填写'; } if ($result['infantname'] != NULL) { $result['infantname'] = "(" . $result['infantname'] . ")"; } $html .= "\n <a class=\"open-profile-dialog\" onclick=\"Contacter.del(" . $result['id'] . ")\" href=\"javascript:void(0);\">\n <span class=\"icon icon-pencil\"></span>\n 删除联系人\n </a>\n <a class=\"open-profile-dialog\" onclick=\"Contacter.edit(" . $result['id'] . ")\" href=\"javascript:void(0);\">\n <span class=\"icon icon-pencil\"></span>\n 修改信息\n </a>\n <h2>基本信息</h2>\n <section>\n <img class=\"avatar\" src=\"http://www.grw.name/statics/images/avatar2.png\" style=\"position:initial\">\n <table>\n <tbody>\n <tr>\n <th>姓名:</th>\n <td class=\"green\">" . $result['name'] . $result['infantname'] . "</td>\n </tr>\n <tr>\n <th>户籍:</th>\n <td>" . $result['birthplace'] . "</td>\n </tr>\n <tr>\n <th>生日:</th>\n <td>" . $result['birthday'] . "</td>\n </tr>\n <tr>\n <th> QQ:</th>\n <td>" . $result['qq'] . "</td>\n </tr>\n <tr>\n <th>手机:</th>\n <td>" . $result['mobile'] . "</td>\n </tr>\n <tr>\n <th>邮箱:</th>\n <td>" . $result['email'] . "</td>\n </tr>\n </tbody>\n </table>\n </section>\n "; echo $html; exit; case 'getodo': $abouts = $about->getAll($data['id']); for ($i = 0; $i < count($abouts); $i++) { $html .= "<tr>\n <th>" . $abouts[$i]['name'] . "</th>\n <td>\n <i>" . $abouts[$i]['value'] . "</i>\n </td>\n </tr>"; } if (count($abouts) == 0) { $html = "<tr><th>暂无</th></tr>"; } echo "\n <h2>相关事项</h2>\n <a onclick=\"Contacter.open_aa(" . $data['id'] . ")\" href=\"#\">\n <span class=\"icon icon-plus\"></span>\n 添加事项\n </a>\n <section>\n <table>\n <tbody>\n " . $html . "\n </tbody>\n </table>\n </section>\n "; exit; case 'info': $this->__check_istrue($info = $contact->info($data), $info); case 'edit_contacter': //Get firstchar $data['firstchar'] = strtolower($this->__Get_firstchar($data['name'])); $this->__check_istrue($contact->edit($data), $data['cid']); case 'del_contacter': $this->__check_istrue($contact->del($data)); case 'add_about': $this->__check_istrue($about->add($data)); default: $cs = $contact->getAll(); $this->countUser = count($cs); break; } }
/** * 天气接口 * @TODO 移到api.php里 */ function weather() { //weather $AppKey = "bddcda9cbf587887d09a5cdc02d5e3a3"; $cityData = json_decode($this->__Get_city()); $city = $cityData->data->city; $len = $this->utf8_strlen($city); $city = $this->utf8Substr($city, 0, $len - 1); $url = 'http://v.juhe.cn/weather/index?cityname=' . $city . '&key=' . $AppKey; $data = json_decode($this->__Get_content($url), TRUE); if ($data['resultcode'] == 200) { //农历 $lunar = FeiClass('FeiLunar'); $today = date('Y-m-d'); $nl_month = $lunar->LMonName(intval(date("m", $lunar->S2L($today)))); $nl_day = $lunar->LDayName(intval(date("d", $lunar->S2L($today)))); $nl = $nl_month . "月" . $nl_day; //nong li $month = intval(date("m")); $day = intval(date("d")); $td = $month . "月" . $day . "日"; //today $mt = $data['result']['future']['day_' . date("Ymd", strtotime("+1 day"))]; //mingtian $ht = $data['result']['future']['day_' . date("Ymd", strtotime("+2 day"))]; //mingtian switch ($data['result']['today']['weather']) { case '阴转小雨': $w_ico = "8"; break; case '晴': $w_ico = "1"; break; case '阴': $w_ico = "3"; break; case '多云': $w_ico = "5"; break; case '小雨': $w_ico = "11"; break; case '小雨转多云': $w_ico = "8"; break; case '中雨转小雨': $w_ico = '9'; break; case '阵雨': $w_ico = "12"; break; case '雨夹雪': $w_ico = '14'; break; case '小雪': $w_ico = '17'; break; case '中雪': $w_ico = '18'; break; case '大雪': $w_ico = '19'; break; case '暴风雪': $w_ico = '20'; break; case '阵雨转多云': $w_ico = '9'; break; case '暴雨': $w_ico = '13'; break; default: $this->logs->NOTICE($data['result']['today']['weather']); $w_ico = "7"; } $weather = array('status' => 'success', 'td' => $td, 'nl' => $nl, 'weather' => $data['result']['today']['weather'], 'wd' => $data['result']['today']['temperature'], 'ico' => $w_ico, 'week' => $data['result']['today']['week'], 'jy' => $data['result']['today']['dressing_advice'], 'mtd' => $mt['temperature'], 'mtq' => $mt['weather'], 'htd' => $ht['temperature'], 'htq' => $ht['weather']); } else { $weather = array('status' => 'error'); } echo json_encode($weather); exit; }
/** * 私有函数,进行关联查找数据操作 * @param thelinker 关联的描述 * @param run_result 主表执行查找后返回的结果 */ private function do_select($thelinker, $run_result) { if (empty($thelinker['mapkey'])) { $thelinker['mapkey'] = $this->model_obj->pk; } if ('manytomany' == $thelinker['type']) { $do_func = 'findAll'; $midcondition = array($thelinker['mapkey'] => $run_result[$thelinker['mapkey']]); if (!($midresult = FeiClass($thelinker['midclass'])->findAll($midcondition, NULL, $thelinker['fkey']))) { return FALSE; } $tmpkeys = array(); foreach ($midresult as $val) { $tmpkeys[] = "'" . $val[$thelinker['fkey']] . "'"; } if (!empty($thelinker['condition'])) { if (is_array($thelinker['condition'])) { $fcondition = "{$thelinker['fkey']} in (" . join(',', $tmpkeys) . ")"; foreach ($thelinker['condition'] as $tmpkey => $tmpvalue) { $fcondition .= " AND {$tmpkey} = '{$tmpvalue}'"; } } else { $fcondition = "{$thelinker['fkey']} in (" . join(',', $tmpkeys) . ") AND {$thelinker['condition']}"; } } else { $fcondition = "{$thelinker['fkey']} in (" . join(',', $tmpkeys) . ")"; } } else { $do_func = 'hasone' == $thelinker['type'] ? 'find' : 'findAll'; if (!empty($thelinker['condition'])) { if (is_array($thelinker['condition'])) { $fcondition = array($thelinker['fkey'] => $run_result[$thelinker['mapkey']]) + $thelinker['condition']; } else { $fcondition = "{$thelinker['fkey']} = '{$run_result[$thelinker['mapkey']]}' AND {$thelinker['condition']}"; } } else { $fcondition = array($thelinker['fkey'] => $run_result[$thelinker['mapkey']]); } } if (TRUE == $thelinker['countonly']) { $do_func = "findCount"; } return FeiClass($thelinker['fclass'])->{$do_func}($fcondition, $thelinker['sort'], $thelinker['field'], $thelinker['limit']); }