public function indexAction() { $pf = NULL; if (preg_match('#^(.+)/profile/(.+)$#i', $this->reqs->uri, $regs)) { $uname = $regs[2]; try { $this->initdb(); $_profile = Core_Dao::factory(array('name' => 'user_profile')); $user = $_profile->getList(array('uname' => $uname)); if (isset($user[0]['id'])) { $des = str_split($uname); $path = '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'] . '/' . $uname; if (!file_exists(SYS_ROOT . $path . "/w100.png")) { $path = '/data/user'; } $pf = $user[0]; $pf['photo_path'] = $path; $pf['content'] = Core_Util_Format::richEditFilter($pf['content']); } } catch (Exception $e) { // } } if ($pf === NULL) { $this->view->message = Core_Message::get('error', 'Profile not found'); } else { $this->view->profile = $pf; $this->view->content = $this->view->render('profile/index'); unset($pf, $this->view->profile); } $this->response('layout'); }
protected function __construct() { if (isset($_SESSION['sid'])) { $sid = trim($_SESSION['sid']); } else { if (isset($_COOKIE['sid'])) { $sid = trim($_COOKIE['sid']); } else { $sid = NULL; } } if (!is_null($sid)) { try { $_session = Core_Dao::factory(array('name' => 'user_session')); $rs = $_session->getById($sid); } catch (Exception $e) { $rs = NULL; } if (isset($rs['id'])) { $this->sid = $rs['id']; $this->uid = $rs['uid']; $this->uname = $rs['uname']; //$this->roles = $rs->roles; } } }
public function indexAction() { try { if ($this->session->uid != "0") { $_user = Core_Dao::factory(array('name' => 'user')); $this->view->user = $_user->getById($this->session->uid); $des = str_split($this->session->uname); $path = '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'] . '/' . $this->session->uname; if (!file_exists(SYS_ROOT . $path . "/w100.png")) { $path = '/data/user'; } $this->view->user['photo_path'] = $path; $this->view->content = $this->view->render('manage/index'); } else { throw new Exception('Access Denied'); } } catch (Exception $e) { $this->view->message = Core_Message::get('error', $e->getMessage()); } unset($this->session); $this->response('layout'); }
public function init() { $this->initdb(); if (!isset($this->reqs->uname)) { die('TODO EXCEPTION:' . __FILE__ . ':' . __LINE__); } $uid = Core_User::name2id($this->reqs->uname); // Profile $dbup = Core_Dao::factory(array('name' => 'user_profile')); $item = $dbup->getByID($uid); if (!isset($item['id'])) { die('TODO EXCEPTION:' . __FILE__ . ':' . __LINE__); } $this->user = new Core_Object(); $this->user->profile = $item; // Products $dbua = Core_Dao::factory(array('name' => 'user_apps')); $where = array('uid' => $uid, 'isfrontend' => 1); $items = $dbua->getList($where, array(), 100); if (count($items) == 0) { die('TODO EXCEPTION:' . __FILE__ . ':' . __LINE__); } $this->user->apps = $items; }
public function emaildoAction() { $vars = get_object_vars($this->reqs); if (!User_Model_Account_EmailValidate::isValid($vars, $msg)) { $this->view->message = Core_Message::get('error', $msg); return $this->emailAction(); } try { if ($this->session->uid != "0") { $_user = Core_Dao::factory(array('name' => 'user')); $user = $_user->getById($this->session->uid); if (isset($user['pass']) && md5($vars['pass']) == $user['pass']) { $set = array('email' => $vars['email']); $where = array('id' => $this->session->uid); $_user->update($set, $where); $this->view->message = Core_Message::get('success', 'Success'); } else { $this->view->message = Core_Message::get('error', 'Password do not match'); } } } catch (Exception $e) { $this->view->message = Core_Message::get('error', 'Unknown'); } $this->emailAction(); }
public function getCount($where) { $db = $this->getAdapter(); $select = $db->select(); $cols = $this->_getCols(); $select->from($this->_name, 'count(*) as count'); Core_Dao::buildSelectWhere($select, $where); try { $rs = $db->fetchRow($select); } catch (Exception $e) { throw $e; } return (int) $rs['count']; }
public function testAction() { $conf = (require SYS_ROOT . "/conf/cm.{$this->reqs->instance}.inc.php"); $conf = $conf[$this->reqs->method]; foreach ($conf['views'] as $v) { $datax = $v['data']['datax']; $db = Core_Dao::factory(array('name' => $datax)); $rs = $db->getList(); $this->view->{$v['name']} = $this->view->render($v['view'], array($v['data']['output'] => $rs)); unset($db, $rs); } $this->response('list'); }
<?php $acturl = "/{$this->inst}/{$this->act}/?"; $p = isset($reqs->p) ? intval($reqs->p) : 1; $pagerurl = $acturl; $db = Core_Dao::factory(array('name' => 'data_entry')); $dbterm = Core_Dao::factory(array('name' => 'taxonomy_term_user')); $where = array(); $limit = 10; $type = isset($reqs->type) ? $reqs->type : NULL; if ($type === NULL) { $where['in.type'] = $params['query_set']['types']; } else { $where['type'] = $type; $pagerurl .= "&type={$type}"; } if (isset($reqs->params['cat'])) { $where['cat'] = intval($reqs->params['cat']); $pagerurl .= "&cat={$reqs->params['cat']}"; } if (isset($reqs->params['term'])) { $where['like.terms'] = "%{$reqs->params['term']}%"; $pagerurl .= "&term={$reqs->params['term']}"; } $order = array('published DESC'); if (isset($reqs->q)) { $where['like.title'] = "%{$reqs->q}%"; $pagerurl .= "&q={$reqs->q}"; } $feed = $db->getList($where, $order, $limit, ($p - 1) * $limit); $count = $db->getCount($where);
public function photodoAction() { $vars = get_object_vars($this->reqs); $_user = Core_Dao::factory(array('name' => 'user')); $_image = new Core_Util_Image(); $status = true; $profile = null; try { if ($this->session->uid != "0") { $profile = $_user->getById($this->session->uid); } } catch (Exception $e) { // } if ($profile === null) { $msg = Core_Message::get('error', 'Unknown error'); } else { $file_tmp = $_FILES['attachment']['tmp_name']; $file_name = $_FILES['attachment']['name']; $file_size = $_FILES['attachment']['size']; $file_mime = $_FILES['attachment']['type']; $file_ext = substr(strrchr(strtolower($file_name), '.'), 1); if (!in_array($file_ext, array('png', 'jpg', 'jpeg', 'gif'))) { $msg = Core_Message::get('error', 'You must upload a JPG, GIF, or PNG file'); } else { if (is_uploaded_file($file_tmp)) { $des = str_split($profile['uname']); $des_dir = SYS_ROOT . '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2']; $des_dir .= '/' . $profile['uname']; Core_Util_Directory::mkdir($des_dir); $file_size_stored = @filesize($file_tmp); if ($file_size_stored > 1000000) { @unlink($file_tmp); $max_size = 1000000 / 1000; $msg = Core_Message::get('error', "File size must less than {$max_size} Kb"); $status = false; } elseif ($file_size_stored != $file_size) { @unlink($file_tmp); $msg = Core_Message::get('error', 'Unknown error'); $status = false; } if ($status && ($imginfo = @getimagesize($file_tmp))) { if (!$imginfo[2]) { @unlink($file_tmp); $msg = Core_Message::get('error', 'Invalid image'); $status = false; } } $_image->resampimagejpg(100, 100, $file_tmp, $des_dir . '/w100.png', true); $_image->resampimagejpg(40, 40, $file_tmp, $des_dir . '/w40.png', false); } } } if (isset($msg)) { $this->view->message = $msg; } else { $this->view->message = Core_Message::get('success', 'Success'); } $this->photoAction(); }
public function debugAction() { try { if (isset($GLOBALS['config']['database2'])) { $dbsrc = Zend_Db::factory($GLOBALS['config']['database2']['adapter'], $GLOBALS['config']['database2']['params']); } else { throw new Exception('Can not connect to db-server'); } } catch (Exception $e) { $e->getMessage(); } $dbentry = Core_Dao::factory(array('name' => 'data_entry')); $dbtermuser = Core_Dao::factory(array('name' => 'taxonomy_term_user')); $db = $dbentry->getAdapter(); $rs = $dbsrc->query("SELECT a.*,u.username from kit_node a,kit_user u WHERE a.userid = u.userid ORDER BY nodeid LIMIT 99999")->fetchAll(); foreach ($rs as $val) { $uid = Core_User::name2id($val['username']); $set = array('id' => $val['nodeid'], 'uid' => $uid, 'uname' => $val['username'], 'cat' => $val['treeid'], 'type' => $val['module'], 'status' => $val['status'], 'title' => $val['title'], 'terms' => $val['terms'], 'created' => $val['created'], 'updated' => $val['modified'], 'published' => $val['created']); $dbentry->insert($set); } $rs = $dbsrc->query("SELECT * from kit_node_revision ORDER BY nodeid LIMIT 99999")->fetchAll(); $counter = 0; foreach ($rs as $val) { $str = @mb_convert_encoding($val['body'], 'UTF-8', mb_detect_encoding($val['body'], "auto", TRUE)); if ($str === FALSE || $str === NULL || $str == "") { $counter++; } if (strlen(time($str)) < 10) { $counter++; } $set = array('summary' => $val['summary'], 'content' => $str); try { $dbentry->update($set, array('id' => $val['nodeid'])); } catch (Exception $e) { $counter++; } } echo $counter; $dbtype = Core_Dao::factory(array('name' => 'data_type')); $rs = $dbsrc->query("SELECT * from kit_system_module ORDER BY moduleid LIMIT 99999")->fetchAll(); foreach ($rs as $val) { $title = @mb_convert_encoding($val['name'], 'UTF-8', mb_detect_encoding($val['name'], "auto", TRUE)); $description = @mb_convert_encoding($val['description'], 'UTF-8', mb_detect_encoding($val['description'], "auto", TRUE)); $set = array('id' => $val['submodule'], 'title' => $title, 'summary' => $description, 'created' => $val['created'], 'updated' => $val['modified'], 'isfrontend' => $val['isfrontend'], 'isbackend' => $val['isbackend'], 'isenabled' => $val['isenabled'], 'isuserenabled' => $val['isuserenabled'], 'isrequired' => $val['isrequired']); $dbtype->insert($set); } $rs = $dbsrc->query("SELECT a.*,u.username from kit_node_tree a,kit_user u WHERE a.userid = u.userid ORDER BY treeid LIMIT 99999")->fetchAll(); $counter = 0; foreach ($rs as $val) { $str = @mb_convert_encoding($val['name'], 'UTF-8', mb_detect_encoding($val['name'], "auto", TRUE)); $uid = Core_User::name2id($val['username']); $set = array('id' => $val['treeid'], 'uid' => $uid, 'pid' => $val['parentid'], 'title' => $str, 'created' => $val['created'], 'updated' => $val['modified'], 'weight' => $val['ordering'], 'app' => $val['module']); try { $dbtermuser->insert($set); } catch (Exception $e) { $counter++; } } echo $counter; $dbuser = Core_Dao::factory(array('name' => 'user')); $dbuserp = Core_Dao::factory(array('name' => 'user_profile')); $rs = $dbsrc->query("SELECT * from kit_user ORDER BY userid LIMIT 99999")->fetchAll(); foreach ($rs as $val) { $name = @mb_convert_encoding($val['name'], 'UTF-8', mb_detect_encoding($val['name'], "auto", TRUE)); $content = @mb_convert_encoding($val['aboutme'], 'UTF-8', mb_detect_encoding($val['aboutme'], "auto", TRUE)); $home_name = @mb_convert_encoding($val['home_name'], 'UTF-8', mb_detect_encoding($val['home_name'], "auto", TRUE)); $uid = Core_User::name2id($val['username']); $set = array('id' => $uid, 'uname' => $val['username'], 'pass' => $val['password'], 'email' => $val['email'], 'name' => $name, 'created' => $val['created'], 'updated' => $val['modified']); $dbuser->insert($set); $set = array('id' => $uid, 'gender' => $val['gender'], 'birthday' => $val['birthday'], 'name' => $name, 'address' => $val['address'], 'content' => $content, 'uname' => $val['username'], 'home_name' => $home_name, 'created' => $val['created'], 'updated' => $val['modified']); $dbuserp->insert($set); } $dbusera = Core_Dao::factory(array('name' => 'user_apps')); $rs = $dbsrc->query("SELECT a.*,u.username from kit_user_module a,kit_user u WHERE a.userid = u.userid ORDER BY id LIMIT 99999")->fetchAll(); foreach ($rs as $val) { $uid = Core_User::name2id($val['username']); $set = array('id' => $val['id'], 'uid' => $uid, 'app' => $val['submodule'], 'title' => $val['name'], 'isfrontend' => $val['isfrontend'], 'isbackend' => $val['isbackend'], 'isenabled' => $val['isenabled'], 'created' => $val['created'], 'updated' => $val['modified']); $dbusera->insert($set); } }
public function up($params) { try { $_user = Core_Dao::factory(array('name' => 'user')); $where = array('uname' => $params['uname']); $rs = $_user->getList($where, array(), 1); if (isset($rs[0]['uname'])) { throw new Exception('This ID is not available, please use another one'); } $pass = md5($params['pass']); $user = array('uname' => $params['uname'], 'email' => $params['email'], 'pass' => $pass); $_user->insert($user); } catch (Exception $e) { throw $e; } }
<?php $table = isset($params['data_base']) ? $params['data_base'] : 'data_type'; $db = Core_Dao::factory(array('name' => $table)); $where = array(); $where['in.id'] = $params['query_set']['types']; $order = array('weight DESC'); $feed = $db->getList($where, $order, 99); ?> <div class="sideblock"> <h3>Content</h3> <ul> <li><a class="<?php if (!isset($reqs->type)) { echo 'current'; } ?> " href="/<?php echo $reqs->inst; ?> /<?php echo $reqs->method; ?> /">所有</a></li> <?php foreach ($feed as $entry) { $class = isset($reqs->type) && $reqs->type == $entry['id'] ? "current" : ""; ?> <li><a class="<?php echo $class; ?>