/**
 * tag的url
 *
 * @param	array	$module
 * @param	string	关键字
 * @return	string	地址
 */
function dr_tag_url($module, $name)
{
    if (!$name) {
        return '?name参数为空';
    }
    $module = is_array($module) ? $module : get_module($module);
    if (!$module) {
        return '?module参数为空';
    }
    // 转换为拼音
    $name = dr_word2pinyin(trim($name));
    if (SITE_MOBILE === TRUE) {
        // 移动端
        return SITE_URL . $module['dirname'] . '/index.php?c=tag&name=' . $name;
    } else {
        // PC端
        $rule = $module['setting']['tag']['url'];
        if ($rule) {
            $url = ltrim(str_replace('{tag}', $name, $rule), '/');
            // 此地址相对于网站根目录时
            if (strpos($rule, '/') === 0) {
                if (!$module['site'][SITE_ID]['domain']) {
                    // 此模块未绑定域名才有效
                    return SITE_URL . $url;
                }
            }
            return $module['url'] . $url;
        } else {
            return $module['url'] . 'index.php?c=tag&name=' . $name;
        }
    }
}
 public function update_tag($keyword)
 {
     $array = explode(',', str_replace(',', ',', $keyword));
     foreach ($array as $name) {
         $name = trim($name);
         if (strlen($name) > 2 && strlen($name) < 30 && !$this->link->where('name', $name)->count_all_results($this->prefix . '_tag')) {
             $this->link->replace($this->prefix . '_tag', array('name' => $name, 'code' => dr_word2pinyin($name), 'hits' => 0));
         }
     }
 }
Exemple #3
0
/**
 * tag的url
 *
 * @param	array	$module
 * @param	string	关键字
 * @return	string	地址
 */
function dr_tag_url($module, $name)
{
    if (!$name) {
        return '?name参数为空';
    }
    if (!$module) {
        return '?module参数为空';
    }
    $name = dr_word2pinyin($name);
    if (SITE_MOBILE === TRUE) {
        // 移动端
        return SITE_URL . $module['dirname'] . '/index.php?c=tag&name=' . $name;
    } else {
        // PC端
        $rule = $module['setting']['tag']['url'];
        $turl = $rule ? str_replace('{tag}', $name, $rule) : 'index.php?c=tag&name=' . $name;
        return ($module['url'] ? $module['url'] : MODULE_URL) . $turl;
    }
}
Exemple #4
0
 /**
  * 批量添加
  *
  * @param	array	$names	��Ŀ����б�
  * @param	array	$data	�������
  * @return	int				�ɹ�����
  */
 public function add_all($names, $data)
 {
     if (!$names) {
         return 0;
     }
     $count = 0;
     $_data = explode(PHP_EOL, $names);
     foreach ($_data as $t) {
         list($name, $dir) = explode('|', $t);
         $data['name'] = trim($name);
         if (!$data['name']) {
             continue;
         }
         if (!$dir) {
             $dir = dr_word2pinyin($data['name']);
         }
         if ($this->dirname_exitsts($dir)) {
             $dir .= rand(0, 99);
         }
         $this->link->insert($this->tablename, array('pid' => (int) $data['pid'], 'pids' => '', 'name' => $data['name'], 'show' => $data['show'], 'thumb' => $data['thumb'], 'letter' => $dir[0], 'dirname' => $dir, 'setting' => dr_array2string($data['setting']), 'pdirname' => '', 'childids' => '', 'displayorder' => 0));
         $id = $this->link->insert_id();
         // 更新至网站导航
         $this->load->model('navigator_model');
         $this->navigator_model->syn_value($data, $id, APP_DIR);
         $count++;
     }
     $this->repair();
     return $count;
 }
 /**
  * 2.3.7 更新程序
  */
 public function index()
 {
     $this->admin_msg('升级完成,请更新全站缓存在刷新页面', '', 1);
     $page = (int) $this->input->get('page');
     if (!$page) {
         $this->admin_msg('正在升级数据...', dr_url('update/index', array('page' => $page + 1)), 2);
     }
     switch ($page) {
         case 1:
             // 升级附件
             $data = $this->db->get('attachment_remote')->result_array();
             foreach ($this->SITE as $sid => $t) {
                 $db = $this->site[$sid];
                 if ($db) {
                     $db->query(trim("\n                        CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix($sid . '_remote') . "` (\n                          `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT,\n                          `url` varchar(255) NOT NULL,\n                          `type` tinyint(2) NOT NULL COMMENT '远程附件类型',\n                          `name` varchar(50) NOT NULL,\n                          `value` text NOT NULL,\n                          `exts` text NOT NULL,\n                          PRIMARY KEY (`id`)\n                        ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='远程附件表';\n                        "));
                     if ($data) {
                         foreach ($data as $c) {
                             $this->db->replace($sid . '_remote', $c);
                         }
                     }
                 }
             }
             $this->admin_msg('正在更新站点的远程附件表结构...', dr_url('update/index', array('page' => $page + 1)), 2);
             break;
         case 2:
             //
             $this->db->db_debug = false;
             $linkage = $this->db->get('linkage')->result_array();
             foreach ($linkage as $t) {
                 $this->db->query('ALTER TABLE `' . $this->db->dbprefix('linkage_data_' . $t['id']) . '` ADD `cname` VARCHAR(255) NOT NULL COMMENT \'别名\' AFTER `name`, ADD INDEX `cname` (`cname`) ;');
                 $r = $this->db->get('linkage_data_' . $t['id'])->result_array();
                 $this->db->update('linkage_data_' . $t['id'], array('cname' => ''));
                 foreach ($r as $c) {
                     if (strlen($c['name']) >= 6) {
                         $c['name'] = str_replace(array('省', '市', '县', '自治', '地区'), '', $c['name']);
                     }
                     $cname = dr_word2pinyin($c['name']);
                     $num = $this->db->where('cname', $cname)->count_all_results('linkage_data_' . $t['id']);
                     $this->db->where('id', $c[id])->update('linkage_data_' . $t['id'], array('cname' => $num ? $cname . $num : $cname));
                 }
             }
             $this->admin_msg('正在更新联动菜单结构...', dr_url('update/index', array('page' => $page + 1)), 2);
             break;
         case 3:
             $this->db->db_debug = false;
             foreach ($this->SITE as $sid => $t) {
                 $db = $this->site[$sid];
                 if ($db) {
                     $data = $db->get($sid . '_form')->result_array();
                     if ($data) {
                         foreach ($data as $t) {
                             $tab = $this->db->dbprefix($sid . '_form_' . $t['table']);
                             $sql = "\n                                CREATE TABLE IF NOT EXISTS `" . $tab . "_data_0` (\n                                  `id` int(10) unsigned NOT NULL,\n                                  UNIQUE KEY `id` (`id`)\n                                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='" . $t['name'] . "表单附表';";
                             $db->query($sql);
                             $db->query('ALTER TABLE `' . $tab . '` ADD `tableid` SMALLINT(6) UNSIGNED NOT NULL COMMENT \'附表id\';');
                         }
                     }
                 }
             }
             $this->admin_msg('正在升级网站表单字段结构和附表结构...', dr_url('update/index', array('page' => $page + 1)), 2);
             break;
         case 4:
             $this->db->db_debug = false;
             $data = $this->db->get('module_form')->result_array();
             if ($data) {
                 foreach ($data as $t) {
                     foreach ($this->SITE as $sid => $a) {
                         $db = $this->site[$sid];
                         if ($db) {
                             $table = $this->db->dbprefix($sid . '_' . $t['module'] . '_form_' . $t['table']);
                             $db->query('ALTER TABLE `' . $table . '` ADD `tableid` SMALLINT(6) UNSIGNED NOT NULL COMMENT \'附表id\';');
                             $sql = "\n                                CREATE TABLE IF NOT EXISTS `" . $table . "_data_0` (\n                                  `id` int(10) unsigned NOT NULL,\n                                  `cid` int(10) unsigned NOT NULL COMMENT '内容id',\n                                  `uid` mediumint(8) unsigned NOT NULL COMMENT '作者id',\n                                  UNIQUE KEY `id` (`id`),\n                                  KEY `cid` (`cid`),\n                                  KEY `uid` (`uid`)\n                                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='" . $t['name'] . "表单附表';";
                             $db->query(trim($sql));
                         }
                     }
                 }
             }
             $this->admin_msg('正在升级模块表单字段结构和附表结构...', dr_url('update/index', array('page' => $page + 1)), 2);
             break;
         default:
             $this->db->db_debug = false;
             $this->db->query("ALTER TABLE `" . $this->db->dbprefix('admin_menu') . "` ADD  `icon` varchar(255) DEFAULT NULL COMMENT '图标标示'");
             $this->admin_msg('升级完成,请更新全站缓存在刷新页面', '', 1);
             break;
     }
 }
 /**
  * 批量添加
  *
  * @param	array	$key
  * @param	array	$data
  * @return	
  */
 public function adds($key, $data)
 {
     if (!$key) {
         return array('error' => lang('187'), 'name' => 'name');
     }
     if (!$data) {
         return array('error' => lang('186'), 'name' => 'name');
     }
     if ($_POST['_all']) {
         $names = explode(PHP_EOL, trim($data['names']));
         if (!$names) {
             return array('error' => lang('186'), 'name' => 'names');
         }
         foreach ($names as $t) {
             $t = trim($t);
             if (!$t) {
                 continue;
             }
             $cname = dr_word2pinyin($t);
             $num = $this->db->where('cname', $cname)->count_all_results('linkage_data_' . $key);
             $this->db->insert('linkage_data_' . $key, array('pid' => (int) $data['pid'], 'name' => $t, 'site' => SITE_ID, 'cname' => $num ? $cname . $num : $cname, 'displayorder' => (int) $data['displayorder']));
         }
     } else {
         $name = $data['name'];
         if (!$name) {
             return array('error' => lang('186'), 'name' => 'name');
         }
         $cname = $data['cname'] ? $data['cname'] : '';
         $this->db->insert('linkage_data_' . $key, array('pid' => (int) $data['pid'], 'name' => $name, 'site' => SITE_ID, 'cname' => $cname, 'displayorder' => (int) $data['displayorder']));
         if (!$cname) {
             $id = $this->db->insert_id();
             $this->db->where('id', $id)->update('linkage_data_' . $key, array('cname' => dr_word2pinyin($name) . '' . $id));
         }
     }
     $this->repair($key);
     return NULL;
 }