コード例 #1
0
ファイル: common.php プロジェクト: h3len/Project
 /**
      * 'site_id' => intval($this->input['site_id']),
       'column_id' => intval($this->input['column_id']),
       'name' => urldecode($this->input['name']),
       'update_time' => intval($this->input['update_time']),
       'update_type' => intval($this->input['update_type']),
       'datasource_id' => intval($this->input['datasource_id']),
       'width' => intval($this->input['width']),
       'height' => intval($this->input['height']),
       'line_num' => intval($this->input['line_num']),
       'father_tag' => urldecode($this->input['father_tag']),
       'loop_body' => urldecode($this->input['loop_body']),
       'next_update_time' => TIMENOW+intval($this->input['update_time']),
       'is_support_push' => intval($this->input['is_support_push']),
      * */
 public function insert_block($data)
 {
     if ($data['block_id']) {
         include_once CUR_CONF_PATH . 'lib/block.class.php';
         $block = new block();
         return $block->check_block_relation($data['site_id'], $data['block_id'], $data['page_id'], $data['page_data_id'], $data['expand_name']);
     }
     include_once ROOT_PATH . 'lib/class/publishconfig.class.php';
     $pub_config = new publishconfig();
     include_once CUR_CONF_PATH . 'lib/block.class.php';
     $block = new block();
     include_once CUR_CONF_PATH . 'lib/block_set.class.php';
     $block_set = new block_set();
     include_once ROOT_PATH . 'lib/class/data_source.class.php';
     $data_source = new dataSource();
     $block_data = array('site_id' => $data['site_id'], 'sort_id' => $data['sort_id'], 'name' => $data['name'], 'site_id' => $data['site_id'], 'datasource_id' => $data['datasource_id'], 'width' => $data['width'], 'height' => $data['height'], 'line_num' => $data['line_num'], 'father_tag' => $data['father_tag'], 'loop_body' => $data['loop_body'], 'next_update_time' => $data['update_time'], 'is_support_push' => $data['is_support_push'], 'datasource_argument' => $data['datasource_argument'] ? serialize($data['datasource_argument']) : '');
     //根据栏目id查出站点id
     $insert_id = $block->insert($block_data);
     $block->update(array('group_id' => $insert_id), $insert_id);
     $block->check_block_relation($data['site_id'], $insert_id, $data['page_id'], $data['page_data_id'], $data['content_type'], $data['client_type'], $data['expand_name']);
     $line_data = array('block_id' => $insert_id);
     //根据数据源取对应内容
     $content_data = array();
     if ($data['datasource_id']) {
         $content_data = $data_source->get_content_by_datasource($data['datasource_id'], $data['datasource_argument']);
     }
     $block_set->insert_line($data['line_num'], $line_data);
     if (is_array($content_data) && $content_data) {
         $block_set->insert_content($data['line_num'], $insert_id, $content_data);
     }
     $data['id'] = $insert_id;
     return $data;
 }
コード例 #2
0
ファイル: block_update.php プロジェクト: h3len/Project
 /**
  * update区块(魔力视图)
  */
 public function update()
 {
     $id = intval($this->input['id']);
     if (!$id) {
         $this->errorOutput('更新失败');
     }
     $data = array('name' => urldecode($this->input['name']), 'update_time' => intval($this->input['update_time']), 'update_type' => intval($this->input['update_type']), 'datasource_id' => intval($this->input['datasource_id']), 'width' => intval($this->input['width']), 'height' => intval($this->input['height']), 'line_num' => intval($this->input['line_num']), 'father_tag' => urldecode($this->input['father_tag']), 'loop_body' => urldecode($this->input['loop_body']), 'is_support_push' => intval($this->input['is_support_push']), 'last_update_time' => TIMENOW, 'datasource_argument' => $this->input['datasource_argument'] ? serialize($this->input['datasource_argument']) : '');
     $old_block_data = $this->obj->get_block_first($id);
     $this->obj->update($data, $id);
     $line_data = array('block_id' => $id);
     $this->block_set->insert_line($data['line_num'], $line_data);
     if ($data['datasource_id']) {
         if (!$old_block_data['datasource_id'] || $old_block_data['datasource_id'] != $data['datasource_id']) {
             include_once ROOT_PATH . 'lib/class/data_source.class.php';
             $data_source = new dataSource();
             $content_data = $data_source->get_content_by_datasource($data['datasource_id'], $data['datasource_argument']);
             $new_content_idarr = array();
             foreach ($content_data as $kkk => $vvv) {
                 $vvv['id'] && ($new_content_idarr[] = $vvv['id']);
             }
             //查询出这个区块的现有所有内容id
             $new_content_idstr = implode(',', $new_content_idarr);
             $contentidarr = array();
             if ($new_content_idstr) {
                 $contentidarr = $this->block_set->get_content_by_content_ids($id, $new_content_idstr);
             }
             foreach ($content_data as $kkk => $vvv) {
                 if ($contentidarr[$vvv['id']]) {
                     unset($content_data[$kkk]);
                 }
             }
             if (is_array($content_data) && $content_data) {
                 $this->block_set->insert_content($data['line_num'], $id, $content_data);
             }
         }
     }
     include_once CUR_CONF_PATH . 'lib/cache.class.php';
     $cache = new Cache();
     $cache->initialize(BLOCK_CACHE);
     $cache->delete($id);
     $data = $this->obj->get_block_first($id);
     $datasource_info_data = array();
     $data['site_id'] = intval($this->input['site_id']);
     $data['page_id'] = intval($this->input['page_id']);
     $data['page_data_id'] = intval($this->input['page_data_id']);
     $data['expand_name'] = $this->input['expand_name'];
     $data['datasource_data'] = $datasource['datasource_data'];
     $data['datasource_info_data'] = $datasource_info_data;
     $data['app_data'] = $datasource['app_data'];
     $this->addItem($data);
     $this->output();
 }
コード例 #3
0
 public function auth(&$view = null, $SESSINFO, $auth_datasource, $loginerror = null)
 {
     if (isset($_POST[_USERNAME_NAME_]) && isset($_POST[_PASS_NAME_])) {
         $db = dataSource::getDataSource($this->auth_datasource, 'db_inc');
         $columns = implode(', ', $SESSINFO);
         $str = 'SELECT ' . $columns . ' FROM ' . _DB_PF_ . _USER_TABLE_ . ' WHERE ' . _USERNAME_ . ' = ? AND ' . _PASS_ . ' = ?';
         if (defined('_AUTH_ENC_')) {
             $enc = _AUTH_ENC_;
             $password = $enc($_POST[_PASS_NAME_]);
         } else {
             $password = $_POST[_PASS_NAME_];
         }
         $result = $db->query($str, array($_POST[_USERNAME_NAME_], $password));
         if ($CRD = $result->fetch()) {
             foreach ($SESSINFO as $key) {
                 $_SESSION[_SESS_MY_KEY_][$key] = $CRD[$key];
             }
             $str = "UPDATE " . _DB_PF_ . _USER_TABLE_ . " SET last_login = now() WHERE id = ?";
             $db->update($str, array($CRD['id']));
             $str = "SELECT DATE_FORMAT(last_login, '%Y/%m/%d %k:%i') AS last_login FROM " . _DB_PF_ . _USER_TABLE_ . " WHERE id = ?";
             $LL = $db->query($str, array($CRD['id']))->fetch();
             $_SESSION[_SESS_MY_KEY_]['last_login'] = $LL['last_login'];
             return $_SESSION[_SESS_MY_KEY_][_LANG_NAME_];
         } else {
             $this->showLogin($view, $loginerror[_DEFAULT_LANG_]);
         }
     } else {
         $this->showLogin($view);
     }
 }
コード例 #4
0
 public function auth(&$view = null, $SESSINFO, $auth_datasource)
 {
     if (!$_SERVER['PHP_AUTH_DIGEST']) {
         $headers = getallheaders();
         if ($headers['Authorization']) {
             $_SERVER['PHP_AUTH_DIGEST'] = $headers['Authorization'];
         }
     }
     if ($_SERVER['PHP_AUTH_DIGEST']) {
         // Checking up the content of PHP_AUTH_DIGEST
         $needed_parts = array('nonce' => true, 'nc' => true, 'cnonce' => true, 'qop' => true, 'username' => true, 'uri' => true, 'response' => true);
         $data = array();
         $matches = array();
         preg_match_all('/(\\w+)=("([^"]+)"|([a-zA-Z0-9=.\\/\\_-]+))/', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER);
         foreach ($matches as $m) {
             if ($m[3]) {
                 $data[$m[1]] = $m[3];
             } else {
                 $data[$m[1]] = $m[4];
             }
             unset($needed_parts[$m[1]]);
         }
         if ($needed_parts) {
             $data = array();
         }
         $columns = implode(', ', $SESSINFO);
         $db = dataSource::getDataSource($this->auth_datasource, 'db_inc');
         $str = 'select ' . $columns . ' from ' . _DB_PF_ . _USER_TABLE_ . ' where ' . _USERNAME_ . ' = ?';
         $result = $db->query($str, array($data['username']));
         $db->close();
         if ($CRD = $result->fetch()) {
             $A1 = md5($data['username'] . ':' . _DIGEST_REALM_ . ':' . $CRD[_PASS_]);
             $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
             $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
             if ($data['response'] != $valid_response) {
                 unset($_SERVER['PHP_AUTH_DIGEST']);
             } else {
                 foreach ($SESSINFO as $key) {
                     if ($key == _PASS_) {
                         continue;
                     }
                     $_SESSION[_SESS_MY_KEY_][$key] = $CRD[$key];
                 }
                 return $_SESSION[_SESS_MY_KEY_][_LANG_NAME_];
             }
         }
     }
     $this->print_auth_header();
     showError::haltOnError(_DIGEST_FAILED_TXT_);
     exit;
 }
コード例 #5
0
 public function connectDB()
 {
     $this->db = dataSource::getDataSource('dbConnecter', 'db_inc');
 }