protected function _initialize()
 {
     parent::_initialize();
     if (!isModuleInstall('Addons')) {
         $this->error('你还没有安装插件模块,无法使用插件商店!');
     }
 }
예제 #2
0
 /**
  * 初始化站点配置信息
  * @return Arry 配置数组
  */
 protected function initSite()
 {
     $Config = cache("Config");
     self::$Cache['Config'] = $Config;
     $config_siteurl = $Config['siteurl'];
     if (isModuleInstall('Domains')) {
         $parse_url = parse_url($config_siteurl);
         $config_siteurl = (is_ssl() ? 'https://' : 'http://') . "{$_SERVER['HTTP_HOST']}{$parse_url['path']}";
     }
     defined('CONFIG_SITEURL_MODEL') or define('CONFIG_SITEURL_MODEL', $config_siteurl);
     $this->assign("config_siteurl", $config_siteurl);
     $this->assign("Config", $Config);
 }
예제 #3
0
/**
 * 编辑器字段 表单组合处理
 * @param type $field 字段名
 * @param type $value 字段内容
 * @param type $fieldinfo 字段配置
 * @return type
 */
function editor($field, $value, $fieldinfo)
{
    $setting = unserialize($fieldinfo['setting']);
    //是否禁用分页和子标题 基本没用。。。
    $disabled_page = isset($disabled_page) ? $disabled_page : 0;
    //编辑器高度
    $height = $setting['height'];
    if (empty($setting['height'])) {
        $height = 300;
    }
    if (defined('IN_ADMIN') && IN_ADMIN) {
        //是否允许上传
        $allowupload = 1;
        //编辑器类型,简洁型还是标准型
        $toolbar = $setting['toolbar'];
    } else {
        //获取当前登陆会员组id
        $groupid = cookie('groupid');
        if (isModuleInstall('Member')) {
            $Member_group = cache("Member_group");
            //是否允许上传
            $allowupload = $Member_group[$groupid]['allowattachment'] ? 1 : 0;
        } else {
            $allowupload = 0;
        }
        //编辑器类型,简洁型还是标准型
        $toolbar = $setting['mbtoolbar'] ? $setting['mbtoolbar'] : "basic";
    }
    //内容
    if (empty($value)) {
        $value = $setting['defaultvalue'] ? $setting['defaultvalue'] : '<p></p>';
    }
    if ($setting['minlength'] || $fieldinfo['pattern']) {
        $allow_empty = '';
    }
    //模块
    $module = MODULE_NAME;
    $form = \Form::editor($field, $toolbar, $module, $this->catid, $allowupload, $allowupload, '', 10, $height, $disabled_page);
    //javascript
    $this->formJavascript .= "\n            //增加编辑器验证规则\n            jQuery.validator.addMethod('editor{$field}',function(){\n                return " . ($fieldinfo['minlength'] ? "editor{$field}.getContent();" : "true") . "\n            });\n    ";
    //错误提示
    $errortips = $this->fields[$field]['errortips'];
    //20130428 由于没有设置必须输入时,ajax提交会造成获取不到编辑器的值。所以这里强制进行验证,使其触发编辑器的sync()方法
    // if ($minlength){
    //验证规则
    $this->formValidateRules['info[' . $field . ']'] = array("editor{$field}" => "true");
    //验证不通过提示
    $this->formValidateMessages['info[' . $field . ']'] = array("editor{$field}" => $errortips ? $errortips : $fieldinfo['name'] . "不能为空!");
    // }
    return "<div id='{$field}_tip'></div>" . '<script type="text/plain" id="' . $field . '" name="info[' . $field . ']">' . $value . '</script>' . $form;
}
예제 #4
0
 /**
  *  初始化当前登录用户信息
  * @return Boolean 没有登陆返回false,有登陆信息返回User Info
  */
 protected final function initUser()
 {
     //判断模块是否安装
     if (false == isModuleInstall('Member')) {
         return false;
     }
     //当然登陆用户ID
     $userid = service("Passport")->isLogged();
     //获取用户信息
     $userInfo = service("Passport")->getLocalUser((int) $userid);
     if (false == $userInfo) {
         return false;
     }
     self::$Cache['uid'] = (int) $userInfo['userid'];
     self::$Cache['username'] = $userInfo['username'];
     self::$Cache['User'] = $userInfo;
     $this->assign("User", self::$Cache['User']);
     return $userInfo;
 }
예제 #5
0
 /**
  * 禁止非法访问
  */
 private function prohibitAccess()
 {
     if (!in_array(MODULE_NAME, C('MODULE_ALLOW_LIST'))) {
         if (APP_DEBUG) {
             E('该模块没有安装,无法进行访问!');
         } else {
             send_http_status(400);
             exit;
         }
     }
     $config = cache('Config');
     if (MODULE_NAME == 'Admin' && isModuleInstall('Domains') && $config['domainaccess']) {
         $Module_Domains_list = cache('Module_Domains_list');
         $http_host = strtolower($_SERVER['HTTP_HOST']);
         $domain = explode('|', $Module_Domains_list['Admin']);
         if ($Module_Domains_list['Admin'] && !in_array($http_host, $domain)) {
             send_http_status(404);
             exit;
         }
     }
 }
예제 #6
0
 /**
  * 连接
  * @access public
  * @param array $options  配置数组
  * @return object
  */
 public static function connect($options = array())
 {
     //判断模块是否安装
     if (false == isModuleInstall('Member')) {
         return get_instance_of('PassportService');
     }
     //网站配置
     $config = F("Member_Config");
     if ($config['interface']) {
         $type = $config['interface'];
     } else {
         $type = 'Local';
     }
     //附件存储方案
     $type = trim($type);
     $class = 'Passport' . ucwords($type);
     import("Driver.Passport.{$class}", LIB_PATH);
     if (class_exists($class)) {
         $Atta = new $class($options);
     } else {
         throw_exception('无法加载通行证:' . $type);
     }
     return $Atta;
 }
예제 #7
0
/**
 * 多文件上传获取数据处理
 * @param type $field 字段名
 * @param type $value 字段内容
 * @return type
 */
function downfiles($field, $value)
{
    $files = $_POST[$field . '_fileurl'];
    $files_alt = $_POST[$field . '_filename'];
    if (defined("IN_ADMIN") && IN_ADMIN && isModuleInstall('Member')) {
        $groupid = $_POST[$field . '_groupid'];
        $point = $_POST[$field . '_point'];
    } else {
        $groupid = array();
        $point = array();
    }
    $array = $temp = array();
    if (!empty($files)) {
        foreach ($files as $key => $file) {
            $temp['fileurl'] = $file;
            $temp['filename'] = $files_alt[$key];
            $temp['groupid'] = $groupid[$key] ? $groupid[$key] : 0;
            $temp['point'] = $point[$key] ? $point[$key] : 0;
            $array[$key] = $temp;
        }
    }
    $array = serialize($array);
    return $array;
}
 public function public_upgrade_1()
 {
     if (\Libs\System\RBAC::authenticate('upgrade') !== true) {
         $this->errors('您没有该项权限!');
     }
     $data = S('Cloud');
     if (empty($data)) {
         $this->errors('获取不到需要升级的模块信息缓存!');
     }
     $sign = $data['sign'];
     //检查是否安装
     if (!isModuleInstall($data['module'])) {
         $this->errors("没有安装该模块无法升级!");
     }
     $config = $this->Module->config($data['module']);
     if (empty($config)) {
         $this->errors("无法获取模块安装信息!");
     }
     //获取下载地址
     $packageUrl = $this->Cloud->data(array('sign' => $sign, 'version' => $config['version']))->act('get.module.upgrade.package.url');
     if (empty($packageUrl)) {
         $this->errors($this->Cloud->getError());
     }
     //开始下载
     if ($this->CloudDownload->storageFile($packageUrl) !== true) {
         $this->errors($this->CloudDownload->getError());
     }
     $this->success('升级包文件下载完毕!', U('public_upgrade_2', array('package' => $packageUrl)));
 }
예제 #9
0
 /**
  * 信息审核
  * @param type $catid 栏目ID
  * @param type $id 信息ID
  * @param type $status 1为未审核,99为审核通过
  * @return boolean 
  */
 public function check($catid, $id, $status = 99)
 {
     C('TOKEN_ON', false);
     //模型ID
     $this->modelid = getCategory($catid, 'modelid');
     //是否生成HTML
     $sethtml = getCategory($catid, 'sethtml');
     //栏目配置信息
     $setting = $this->categorys[$catid]['setting'];
     $content_ishtml = $setting['content_ishtml'];
     $this->Content = ContentModel::getInstance($this->modelid);
     $r = $this->Content->relation(true)->where(array('id' => $id, 'catid' => $catid))->find();
     $this->Content->dataMerger($r);
     tag('content_check_begin', $r);
     if ($r) {
         if ($this->Content->where(array('id' => $id, 'catid' => $catid))->save(array("status" => $status))) {
             //判断是否前台投稿
             if ($r['sysadd'] == 0 && $status == 99 && isModuleInstall('Member')) {
                 //检查是否已经赠送过积分
                 $integral = M("MemberContent")->where(array("content_id" => $id, "catid" => $catid))->getField("integral");
                 if (!$integral) {
                     if (service("Passport")->user_integral($r['username'], $setting['member_addpoint'])) {
                         M("MemberContent")->where(array("content_id" => $id, "catid" => $catid))->save(array("integral" => 1));
                     }
                 }
             }
             //生成内容页
             if ($content_ishtml && !$r['islink'] && $status == 99) {
                 import('Html');
                 $html = get_instance_of('Html');
                 $html->show($r, 0, 'edit');
                 //生成上下篇
                 $this->related_content($catid, $id);
             }
             //如果是取消审核
             if ($content_ishtml && $status != 99) {
                 //则删除生成静态的文件
                 $this->deleteHtml($catid, $id, $r['inputtime'], $r['prefix'], $r);
                 //删除全站搜索数据
                 $this->search_api($id, $r, "delete");
                 //删除tags
                 D("Tags")->deleteAll($r['id'], $r['catid'], $this->modelid);
             } elseif ($status == 99) {
                 //更新全站搜索数据
                 $this->search_api($id, $r);
                 //更新tags
                 if (strpos($r['tags'], ',') === false) {
                     $tags = explode(' ', $r['tags']);
                 } else {
                     $tags = explode(',', $r['tags']);
                 }
                 $tags = array_unique($tags);
                 D("Tags")->updata($tags, $r['id'], $r['catid'], $this->modelid, array("url" => $r['url'], "title" => $r['title']));
             }
         }
     }
     tag('content_check_end', $r);
     return true;
 }
예제 #10
0
                <a href="{:U('public_preview',array('catid'=>$vo['catid'],'id'=>$vo['id']) )}" target="_blank"><font color="#FF0000">[未审核]</font> - {$vo.title}</a>
                </if>
              <if condition=" $vo['thumb']!='' "> <img src="{$config_siteurl}statics/images/icon/small_img.gif" title="标题图片"> </if>
              <if condition=" $vo['posid'] "> <img src="{$config_siteurl}statics/images/icon/small_elite.gif" title="推荐位"> </if>
              <if condition=" $vo['islink'] "> <img src="{$config_siteurl}statics/images/icon/link.png" title="转向地址"> </if></td>
            <td align="center">{$vo.views}</td>
            <td align="center"><if condition=" $vo['sysadd'] ">{$vo.username}
                <else />
                <font color="#FF0000">{$vo.username}</font><img src="{$config_siteurl}statics/images/icon/contribute.png" title="会员投稿"></if></td>
            <td align="center">{$vo.updatetime|date="Y-m-d H:i:s",###}</td>
            <td align="center">
            <?php 
$op = array();
$op[] = '<a href="javascript:;;" onClick="javascript:openwinx(\'' . U("Content/edit", array("catid" => $vo['catid'], "id" => $vo['id'])) . '\',\'\')">修改</a>';
$op[] = '<a href="' . U("Content/delete", array("catid" => $vo['catid'], "id" => $vo['id'])) . '" class="J_ajax_del" >删除</a>';
if (isModuleInstall('Comments')) {
    $op[] = '<a href="' . U('Comments/Comments/index', array('searchtype' => 2, 'keyword' => 'c-' . $vo['catid'] . '-' . $vo['id'] . '')) . '" target="_blank">评论</a>';
}
echo implode(' | ', $op);
?>
            </td>
          </tr>
        </volist>
      </table>
      <div class="p10"><div class="pages"> {$Page} </div> </div>
     
    </div>
    <div class="btn_wrap">
      <div class="btn_wrap_pd">
        <label class="mr20"><input type="checkbox" class="J_check_all" data-direction="y" data-checklist="J_check_y">全选</label>                
        <button class="btn J_ajax_submit_btn" type="submit" data-action="{:U('Content/listorder',array('catid'=>$catid))}">排序</button>
예제 #11
0
/**
 * URL组装 支持不同URL模式
 * @param string $url URL表达式,格式:'[模块/控制器/操作#锚点@域名]?参数1=值1&参数2=值2...'
 * @param string|array $vars 传入的参数,支持数组和字符串
 * @param string $suffix 伪静态后缀,默认为true表示获取配置值
 * @param boolean $domain 是否显示域名
 * @return string
 */
function U($url = '', $vars = '', $suffix = true, $domain = true)
{
    //网站配置
    $config = cache('Config');
    // 解析URL
    $info = parse_url($url);
    $url = !empty($info['path']) ? $info['path'] : ACTION_NAME;
    if (isset($info['fragment'])) {
        // 解析锚点
        $anchor = $info['fragment'];
        if (false !== strpos($anchor, '?')) {
            // 解析参数
            list($anchor, $info['query']) = explode('?', $anchor, 2);
        }
        if (false !== strpos($anchor, '@')) {
            // 解析域名
            list($anchor, $host) = explode('@', $anchor, 2);
        }
    } elseif (false !== strpos($url, '@')) {
        // 解析域名
        list($url, $host) = explode('@', $info['path'], 2);
    }
    // 解析子域名
    if (isset($host)) {
        $domain = $host . (strpos($host, '.') ? '' : strstr($_SERVER['HTTP_HOST'], '.'));
    } elseif ($domain === true) {
        $siteurl = parse_url($config['siteurl']);
        $domain = $siteurl['host'] ?: $_SERVER['HTTP_HOST'];
        // 开启子域名部署
        if (isModuleInstall('Domains')) {
            $path_list = explode('/', $url);
            if (count($path_list) < 3) {
                array_unshift($path_list, MODULE_NAME);
            }
            //模块对应绑定域名
            $Module_Domains_list = cache('Module_Domains_list');
            if ($Module_Domains_list[$path_list[0]]) {
                $domain = explode('|', $Module_Domains_list[$path_list[0]]);
                $domain = $domain[0];
                $_domain = true;
            }
            // APP_SUB_DOMAIN_NO 表示使用网站地址,不使用其他绑定域名
            if (defined('IN_ADMIN') && IN_ADMIN && !defined('APP_SUB_DOMAIN_NO') && $Module_Domains_list['Admin']) {
                //当在后台,且后台绑定域名,直接以后台域名访问
                $domain = $Module_Domains_list['Admin'];
                $domain = explode('|', $domain);
                $domain = $domain[0];
                //标识这里是后台模块,且后台绑定域名,强制以后台绑定的域名访问其他分组
                $admin_domain = true;
                unset($_domain);
            } elseif (!isset($_domain)) {
                $domain = strtolower($siteurl['host']);
            }
        }
        //端口号处理
        if ($domain) {
            if (isset($siteurl['port']) && $siteurl['port'] && (int) $siteurl['port'] != 80) {
                $domain .= ":{$siteurl['port']}";
            }
        }
    }
    // 解析参数
    if (is_string($vars)) {
        // aaa=1&bbb=2 转换成数组
        parse_str($vars, $vars);
    } elseif (!is_array($vars)) {
        $vars = array();
    }
    if (isset($info['query'])) {
        // 解析地址里面参数 合并到vars
        parse_str($info['query'], $params);
        $vars = array_merge($params, $vars);
    }
    // URL组装
    $depr = C('URL_PATHINFO_DEPR');
    $urlCase = C('URL_CASE_INSENSITIVE');
    if ($url) {
        if (0 === strpos($url, '/')) {
            // 定义路由
            $route = true;
            $url = substr($url, 1);
            if ('/' != $depr) {
                $url = str_replace('/', $depr, $url);
            }
        } else {
            if ('/' != $depr) {
                // 安全替换
                $url = str_replace('/', $depr, $url);
            }
            // 解析模块、控制器和操作
            $url = trim($url, $depr);
            $path = explode($depr, $url);
            $var = array();
            $varModule = C('VAR_MODULE');
            $varController = C('VAR_CONTROLLER');
            $varAction = C('VAR_ACTION');
            $var[$varAction] = !empty($path) ? array_pop($path) : ACTION_NAME;
            $var[$varController] = !empty($path) ? array_pop($path) : CONTROLLER_NAME;
            if ($maps = C('URL_ACTION_MAP')) {
                if (isset($maps[strtolower($var[$varController])])) {
                    $maps = $maps[strtolower($var[$varController])];
                    if ($action = array_search(strtolower($var[$varAction]), $maps)) {
                        $var[$varAction] = $action;
                    }
                }
            }
            if ($maps = C('URL_CONTROLLER_MAP')) {
                if ($controller = array_search(strtolower($var[$varController]), $maps)) {
                    $var[$varController] = $controller;
                }
            }
            if ($urlCase) {
                $var[$varController] = parse_name($var[$varController]);
            }
            $module = '';
            if (!empty($path)) {
                $_module = $var[$varModule] = array_pop($path);
            } else {
                if (C('MULTI_MODULE')) {
                    if (MODULE_NAME != C('DEFAULT_MODULE') || !C('MODULE_ALLOW_LIST')) {
                        $var[$varModule] = MODULE_NAME;
                    }
                }
            }
            if ($maps = C('URL_MODULE_MAP')) {
                if ($_module = array_search(strtolower($var[$varModule]), $maps)) {
                    $var[$varModule] = $_module;
                }
            }
            if (isset($var[$varModule])) {
                $_module = $module = $var[$varModule];
                unset($var[$varModule]);
            }
        }
    }
    $appUrl = __APP__;
    $showModuleName = true;
    //是否显示模块名(g)
    if (in_array(C('URL_MODEL'), array(0, 1, 3))) {
        //如果是绑定BIND_MODULE时处理
        if (defined('BIND_MODULE')) {
            $homeFile = array('index.php', 'api.php', 'install.php', 'admin.php');
            switch ($_module) {
                case 'Api':
                    $appUrl = str_replace($homeFile, 'api.php', __APP__);
                    $showModuleName = false;
                    break;
                case 'Admin':
                    $appUrl = str_replace($homeFile, 'admin.php', __APP__);
                    $showModuleName = false;
                    break;
                case 'Install':
                    $appUrl = str_replace($homeFile, 'install.php', __APP__);
                    $showModuleName = false;
                    break;
                default:
                    $appUrl = str_replace($homeFile, 'index.php', __APP__);
                    break;
            }
        }
        //U方法里的模块等于当前模块时,隐藏
        if ($module == C('DEFAULT_MODULE')) {
            $showModuleName = false;
        }
    }
    if (C('URL_MODEL') == 0) {
        // 普通模式URL转换
        //去除默认参数
        if ($var[C('VAR_MODULE')] == C('DEFAULT_MODULE')) {
            unset($var[C('VAR_MODULE')]);
        }
        if ($var[C('VAR_CONTROLLER')] == C('DEFAULT_CONTROLLER')) {
            unset($var[C('VAR_CONTROLLER')]);
        }
        if ($var[C('VAR_ACTION')] == C('DEFAULT_ACTION')) {
            unset($var[C('VAR_ACTION')]);
        }
        $url = $appUrl;
        //如果$var参数不为空,或者$module也不为空时显示
        if (!empty($var) || $showModuleName && $module) {
            $url .= '?';
            //是否显示模块部分
            if (isset($admin_domain) && $var[$varModule] != 'Admin') {
                //如果后台绑定域名访问,且非Admin模块,都要加上模块标识
                $var[C('VAR_MODULE')] = $module ?: MODULE_NAME;
            } else {
                if ($showModuleName && $module) {
                    $var[C('VAR_MODULE')] = $module;
                }
            }
            //其余参数
            if (!empty($var)) {
                $url .= http_build_query(array_reverse($var));
            }
        }
        if ($urlCase) {
            $url = strtolower($url);
        }
        if (!empty($vars)) {
            $vars = http_build_query($vars);
            $url .= '&' . $vars;
        }
    } else {
        // PATHINFO模式或者兼容URL模式
        if (isset($route)) {
            $url = $appUrl . '/' . rtrim($url, $depr);
        } else {
            $module = defined('BIND_MODULE') ? '' : $module;
            $url = $appUrl . '/' . ($module ? $module . MODULE_PATHINFO_DEPR : '') . implode($depr, array_reverse($var));
        }
        if ($urlCase) {
            $url = strtolower($url);
        }
        if (!empty($vars)) {
            // 添加参数
            foreach ($vars as $var => $val) {
                if ('' !== trim($val)) {
                    $url .= $depr . $var . $depr . urlencode($val);
                }
            }
        }
        if ($suffix) {
            $suffix = $suffix === true ? C('URL_HTML_SUFFIX') : $suffix;
            if ($pos = strpos($suffix, '|')) {
                $suffix = substr($suffix, 0, $pos);
            }
            if ($suffix && '/' != substr($url, -1)) {
                $url .= '.' . ltrim($suffix, '.');
            }
        }
    }
    if (isset($anchor)) {
        $url .= '#' . $anchor;
    }
    if ($domain) {
        $url = (is_ssl() ? 'https://' : 'http://') . $domain . $url;
    }
    return $url;
}
예제 #12
0
파일: ajax.php 프로젝트: sandom123/king400
            <img src="{$vo.icon}" alt="{$vo.modulename}" width="80" height="80">
            <else/>
            <img src="{$config_siteurl}statics/images/modul.png" alt="{$vo.modulename}" width="80" height="80">
            </if>
            </div>
        </td>
        <td valign="top">
            <h3 class="mb5 f12"><if condition=" $vo['address'] "><a target="_blank" href="{$vo.address}">{$vo.modulename}</a><else />{$vo.modulename}</if></h3>
            <div class="mb5"> <span class="mr15">版本:<b>{$vo.version}</b></span> <span>开发者:<if condition=" $vo['author'] "><a target="_blank" href="{$vo.authorsite}">{$vo.author}</a><else />匿名开发者</if></span> <span>适配 ShuipFCMS 最低版本:<if condition=" $vo['adaptation'] ">{$vo.adaptation}<else /><font color="#FF0000">没有标注,可能存在兼容风险</font></if></span> </div>
            <div class="gray"><if condition=" $vo['introduce'] ">{$vo.introduce}<else />没有任何介绍</if></div>
            <div> <span class="mr20"><a href="{$vo.authorsite}" target="_blank">{$vo.authorsite}</a></span> </div>
        </td>
        <td align="center">
          <?php 
$op = array();
if (!isModuleInstall($vo['module'])) {
    $op[] = '<a href="' . U('install', array('sign' => $vo['sign'])) . '" class="btn btn_submit mr5 Js_install">安装</a>';
} else {
    //有安装,检测升级
    if ($vo['upgrade']) {
        $op[] = '<a href="' . U('upgrade', array('sign' => $vo['sign'])) . '" class="btn btn_submit mr5 Js_upgrade" id="upgrade_tips_' . $vo['sign'] . '">升级到最新' . $vo['newVersion'] . '</a>';
    }
}
echo implode('  ', $op);
if ($vo['price']) {
    echo "<br /><font color=\"#FF0000\">价格:" . $vo['price'] . " 元</font>";
}
?>
        </td>
      </tr>
      </volist>
예제 #13
0
 /**
  * 用户积分变更
  * @param type $uid 数字为用户ID,其他为用户名
  * @param type $integral 正数增加积分,负数扣除积分
  * @return int 成功返回当前积分数,失败返回false,-1 表示当前积分不够扣除
  */
 public function userIntegration($uid, $integral)
 {
     if (!isModuleInstall('Member')) {
         return true;
     }
     $map = array();
     if (is_numeric($uid)) {
         $map['userid'] = $uid;
     } else {
         $map['username'] = $uid;
     }
     if (empty($map)) {
         $this->error = '该用户不存在!';
         return false;
     }
     $member = D('Member/Member');
     $info = $member->where($map)->find();
     if (empty($info)) {
         $this->error = '该用户不存在!';
         return false;
     }
     $point = $info['point'] + $integral;
     if ($point < 0) {
         $this->error = '用户积分不足!';
         return false;
     }
     //计算会员组
     $groupid = $member->get_usergroup_bypoint((int) $point);
     //更新
     if (false !== $member->where($map)->save(array("point" => (int) $point, "groupid" => $groupid))) {
         return true;
     }
     $this->error = '积分扣除失败!';
     return false;
 }
예제 #14
0
/**
 * 多文件上传 表单组合处理
 * @param type $field 字段名
 * @param type $value 字段内容
 * @param type $fieldinfo 字段配置
 * @return string
 */
function downfiles($field, $value, $fieldinfo)
{
    //错误提示
    $errortips = $fieldinfo['errortips'];
    if ($fieldinfo['minlength']) {
        //验证规则
        $this->formValidateRules['info[' . $field . ']'] = array("required" => true);
        //验证不通过提示
        $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $fieldinfo['name'] . "不能为空!");
    }
    //扩展配置
    $setting = unserialize($fieldinfo['setting']);
    $list_str = '';
    if ($value) {
        $value = unserialize(html_entity_decode($value, ENT_QUOTES));
        if (defined("IN_ADMIN") && IN_ADMIN && isModuleInstall('Member')) {
            $Member_group = cache("Member_group");
            foreach ($Member_group as $v) {
                if (in_array($v['groupid'], array("1", "7", "8"))) {
                    continue;
                }
                $group[$v['groupid']] = $v['name'];
            }
        }
        if (is_array($value)) {
            foreach ($value as $_k => $_v) {
                if (defined("IN_ADMIN") && IN_ADMIN && isModuleInstall('Member')) {
                    $list_str .= "<div id='multifile{$_k}'><input type='text' name='{$field}_fileurl[]' value='{$_v['fileurl']}' style='width:310px;' class='input'> <input type='text' name='{$field}_filename[]' value='{$_v['filename']}' style='width:160px;' class='input'> 权限:" . \Form::select($group, $_v['groupid'], 'name="' . $field . '_groupid[]"', '游客') . " 点数:<input type='text' name='{$field}_point[]' value='" . $_v['point'] . "' style='width:60px;' class='input'> <a href=\"javascript:remove_div('multifile{$_k}')\">移除</a></div>";
                } else {
                    $list_str .= "<div id='multifile{$_k}'><input type='text' name='{$field}_fileurl[]' value='{$_v['fileurl']}' style='width:310px;' class='input'> <input type='text' name='{$field}_filename[]' value='{$_v['filename']}' style='width:160px;' class='input'> <a href=\"javascript:remove_div('multifile{$_k}')\">移除</a></div>";
                }
            }
        }
    }
    $string = '<input name="info[' . $field . ']" type="hidden" value="1">
		<fieldset class="blue pad-10">
        <legend>文件列表</legend>';
    $string .= $list_str;
    $string .= '<ul id="' . $field . '" class="picList"></ul>
		</fieldset>
		<div class="bk10"></div>
		';
    //模块
    $module = MODULE_NAME;
    //生成上传附件验证
    $authkey = upload_key("{$setting['upload_number']},{$setting['upload_allowext']},{$setting['isselectimage']}");
    //后台允许权限设置
    if (defined("IN_ADMIN") && IN_ADMIN && isModuleInstall('Member')) {
        $Member_group = cache("Member_group");
        foreach ($Member_group as $v) {
            if (in_array($v['groupid'], array("1", "7", "8"))) {
                continue;
            }
            $group[$v['groupid']] = $v['name'];
        }
        $js = '<script type="text/javascript">
function change_multifile_admin(uploadid, returnid) {
    var d = uploadid.iframe.contentWindow;
    var in_content = d.$("#att-status").html().substring(1);
    var in_filename = d.$("#att-name").html().substring(1);
    var str = \'\';
    var contents = in_content.split(\'|\');
    var filenames = in_filename.split(\'|\');
    var group = \'权限:' . \Form::select($group, $id, 'name="\' + returnid + \'_groupid[]"', '游客') . '\';
    $(\'#\' + returnid + \'_tips\').css(\'display\', \'none\');
    if (contents == \'\') return true;
    $.each(contents, function (i, n) {
        var ids = parseInt(Math.random() * 10000 + 10 * i);
        var filename = filenames[i].substr(0, filenames[i].indexOf(\'.\'));
        str += "<li id=\'multifile" + ids + "\'><input type=\'text\' name=\'" + returnid + "_fileurl[]\' value=\'" + n + "\' style=\'width:310px;\' class=\'input\'> <input type=\'text\' name=\'" + returnid + "_filename[]\' value=\'" + filename + "\' style=\'width:160px;\' class=\'input\' onfocus=\\"if(this.value == this.defaultValue) this.value = \'\'\\" onblur=\\"if(this.value.replace(\' \',\'\') == \'\') this.value = this.defaultValue;\\"> "+group+" 点数:<input type=\'text\' name=\'" + returnid + "_point[]\' value=\'0\' style=\'width:60px;\' class=\'input\'> <a href=\\"javascript:remove_div(\'multifile" + ids + "\')\\">移除</a> </li>";
    });
    $(\'#\' + returnid).append(str);
}

function add_multifile_admin(returnid) {
    var ids = parseInt(Math.random() * 10000);
    var group = \'权限:' . \Form::select($group, $id, 'name="\' + returnid + \'_groupid[]"', '游客') . '\';
    var str = "<li id=\'multifile" + ids + "\'><input type=\'text\' name=\'" + returnid + "_fileurl[]\' value=\'\' style=\'width:310px;\' class=\'input\'> <input type=\'text\' name=\'" + returnid + "_filename[]\' value=\'附件说明\' style=\'width:160px;\' class=\'input\'> "+group+"  点数:<input type=\'text\' name=\'" + returnid + "_point[]\' value=\'0\' style=\'width:60px;\' class=\'input\'>  <a href=\\"javascript:remove_div(\'multifile" + ids + "\')\\">移除</a> </li>";
    $(\'#\' + returnid).append(str);
};</script>';
        $string .= $str . "<a herf='javascript:void(0);' class=\"btn\"  onclick=\"javascript:flashupload('{$field}_multifile', '附件上传','{$field}',change_multifile_admin,'{$setting['upload_number']},{$setting['upload_allowext']},{$setting['isselectimage']}','{$module}','{$this->catid}','{$authkey}')\"><span class=\"add\"></span>多文件上传</a>    <a  class=\"btn\" herf='javascript:void(0);'  onclick=\"add_multifile_admin('{$field}')\"><span class=\"add\"></span>添加远程地址</a>{$js}";
    } else {
        $string .= $str . "<a herf='javascript:void(0);'  class=\"btn\" onclick=\"javascript:flashupload('{$field}_multifile', '附件上传','{$field}',change_multifile,'{$setting['upload_number']},{$setting['upload_allowext']},{$setting['isselectimage']}','{$module}','{$this->catid}','{$authkey}')\"><span class=\"add\"></span>多文件上传</a>    <a herf='javascript:void(0);' class=\"btn\" onclick=\"add_multifile('{$field}')\"><span class=\"add\"></span>添加远程地址</a>";
    }
    return $string;
}
예제 #15
0
 public function edit()
 {
     if (IS_POST) {
         $catid = I("post.catid", "", "intval");
         if (empty($catid)) {
             $this->error('请选择需要修改的栏目!');
         }
         $Category = D("Content/Category");
         $status = $Category->editCategory($_POST);
         if ($status) {
             //应用权限设置到子栏目
             if ($_POST['priv_child']) {
                 //子栏目
                 $arrchildid = $Category->where(array('catid' => $catid))->getField('arrchildid');
                 $arrchildid_arr = explode(',', $arrchildid);
                 foreach ($arrchildid_arr as $arr_v) {
                     D("Content/Category_priv")->update_priv($arr_v, $_POST['priv_roleid'], 1);
                 }
             } else {
                 //更新角色栏目权限
                 D("Content/Category_priv")->update_priv($catid, $_POST['priv_roleid'], 1);
                 if (isModuleInstall('Member')) {
                     //更新会员组权限
                     D("Content/Category_priv")->update_priv($catid, $_POST['priv_groupid'], 0);
                 }
             }
             $this->success("更新成功!", U("Category/index"));
         } else {
             $error = $Category->getError();
             $this->error($error ? $error : '栏目修改失败!');
         }
     } else {
         $catid = I('get.catid', 0, 'intval');
         $array = cache("Category");
         foreach ($array as $k => $v) {
             $array[$k] = getCategory($v['catid']);
             if ($v['child'] == "0") {
                 $array[$k]['disabled'] = "disabled";
             } else {
                 $array[$k]['disabled'] = "";
             }
         }
         $data = getCategory($catid);
         $setting = $data['setting'];
         //输出可用模型
         $modelsdata = cache("Model");
         $models = array();
         foreach ($modelsdata as $v) {
             if ($v['disabled'] == 0 && $v['type'] == 0) {
                 $models[] = $v;
             }
         }
         if (!empty($array) && is_array($array)) {
             $this->Tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
             $this->Tree->nbsp = '&nbsp;&nbsp;&nbsp;';
             $this->Tree->init($array);
             $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
             $categorydata = $this->Tree->get_tree(0, $str, $data['parentid']);
         } else {
             $categorydata = '';
         }
         $this->assign("category_php_ruleid", \Form::urlrule('content', 'category', 0, $setting['category_ruleid'], 'name="category_php_ruleid"'));
         $this->assign("category_html_ruleid", \Form::urlrule('content', 'category', 1, $setting['category_ruleid'], 'name="category_html_ruleid"'));
         $this->assign("show_php_ruleid", \Form::urlrule('content', 'show', 0, $setting['show_ruleid'], 'name="show_php_ruleid"'));
         $this->assign("show_html_ruleid", \Form::urlrule('content', 'show', 1, $setting['show_ruleid'], 'name="show_html_ruleid"'));
         $this->assign("tp_category", $this->tp_category);
         $this->assign("tp_list", $this->tp_list);
         $this->assign("tp_show", $this->tp_show);
         $this->assign("tp_comment", $this->tp_comment);
         $this->assign("tp_page", $this->tp_page);
         $this->assign("category", $categorydata);
         $this->assign("models", $models);
         $this->assign("data", $data);
         $this->assign("setting", $setting);
         //栏目扩展字段
         $this->assign('extendList', D("Content/Category")->getExtendField($catid));
         //角色组
         $this->assign("Role_group", M("Role")->order(array("id" => "ASC"))->select());
         $this->assign("big_menu", array(U("Category/index"), "栏目管理"));
         //权限数据
         $this->assign("privs", M("CategoryPriv")->where(array('catid' => $catid))->select());
         if (isModuleInstall('Member')) {
             //会员组
             $this->assign("Member_group", cache("Member_group"));
         }
         if ($data['type'] == 1) {
             //单页栏目
             $this->display("singlepage_edit");
         } else {
             if ($data['type'] == 2) {
                 //外部栏目
                 $this->display("wedit");
             } else {
                 $this->display();
             }
         }
     }
 }
예제 #16
0
 /**
  * 解析行为规则
  * 规则定义  table:$table|field:$field|condition:$condition|rule:$rule[|cycle:$cycle|max:$max][;......]
  * 规则字段解释:table->要操作的数据表,不需要加表前缀;
  *              field->要操作的字段;
  *              condition->操作的条件,目前支持字符串,默认变量{$self}为执行行为的用户
  *              rule->对字段进行的具体操作,目前支持四则混合运算,如:1+score*2/2-3
  *              cycle->执行周期,单位(小时),表示$cycle小时内最多执行$max次
  *              max->单个周期内的最大执行次数($cycle和$max必须同时定义,否则无效)
  * 单个行为后可加 ; 连接其他规则
  * @param string $action 行为id或者name
  * @return boolean|array: false解析出错 , 成功返回规则数组
  */
 protected function parseBehavior($action = null)
 {
     if (empty($action)) {
         return false;
     }
     //参数支持id或者name
     if (is_numeric($action)) {
         $map = array('id' => $action);
     } else {
         $map = array('name' => $action);
     }
     //查询行为信息
     $info = $this->where($map)->find();
     if (empty($info) || $info['status'] != 1) {
         return false;
     }
     //查询规则
     $behaviorRule = M('BehaviorRule');
     $ruleList = $behaviorRule->where(array('behaviorid' => $info['id']))->order(array('listorder' => 'ASC', 'ruleid' => 'ASC'))->getField('ruleid,rule,system,module', true);
     if (empty($ruleList)) {
         return false;
     }
     //解析规则:table:$table|field:$field|condition:$condition|rule:$rule[|cycle:$cycle|max:$max][;......]
     $return = array();
     foreach ($ruleList as $key => $ruleInfo) {
         $rule = $ruleInfo['rule'];
         $return[$key] = array('ruleid' => $key);
         //行为名称
         $return[$key]['tagname'] = $info['name'];
         //行为文件
         if (substr($rule, 0, 8) == 'phpfile:') {
             $rule = explode('|', $rule);
             $phpfile = str_replace('phpfile:', '', $rule[0]);
             $module = $rule[1] ? ucwords(str_replace('module:', '', $rule[1])) : '';
             //规则类型
             $return[$key]['_type'] = 2;
             $return[$key]['module'] = $module;
             //行为名称
             $return[$key]['behavior'] = ucwords($phpfile);
             //如果不为空,表示是某个模块下的扩展行为
             if (empty($module)) {
                 //判断是否系统行为规则
                 if ($ruleInfo['system']) {
                     //如果是系统行为规则,定位到tp目录中的Behavior
                     $return[$key]['class'] = "Behavior\\{$phpfile}";
                 } else {
                     $return[$key]['class'] = "Common\\Behavior\\{$phpfile}";
                 }
             } else {
                 $return[$key]['class'] = "{$module}\\Behavior\\{$phpfile}";
             }
         } elseif (substr($rule, 0, 4) == 'sql:') {
             //sql行为规则
             $rule = explode('|', $rule);
             foreach ($rule as $k => $fields) {
                 $field = empty($fields) ? array() : explode(':', $fields);
                 if (!empty($field)) {
                     $return[$key][$field[0]] = $field[1];
                 }
             }
             //cycle(检查周期)和max(周期内最大执行次数)必须同时存在,否则去掉这两个条件
             if (!array_key_exists('cycle', $return[$key]) || !array_key_exists('max', $return[$key])) {
                 unset($return[$key]['cycle']);
                 unset($return[$key]['max']);
             }
             //规则类型
             $return[$key]['_type'] = 3;
         } elseif (substr($rule, 0, 6) == 'table:') {
             //简单规则条件
             $rule = explode('|', $rule);
             foreach ($rule as $k => $fields) {
                 $field = empty($fields) ? array() : explode(':', $fields);
                 if (!empty($field)) {
                     $return[$key][$field[0]] = $field[1];
                 }
             }
             //cycle(检查周期)和max(周期内最大执行次数)必须同时存在,否则去掉这两个条件
             if (!array_key_exists('cycle', $return[$key]) || !array_key_exists('max', $return[$key])) {
                 unset($return[$key]['cycle']);
                 unset($return[$key]['max']);
             }
             //规则类型
             $return[$key]['_type'] = 1;
         } elseif (substr($rule, 0, 6) == 'addon:') {
             //插件规则
             //检查插件模块是否安装
             if (!isModuleInstall('Addons')) {
                 continue;
             }
             $rule = explode('|', $rule);
             foreach ($rule as $k => $fields) {
                 $field = empty($fields) ? array() : explode(':', $fields);
                 if (!empty($field)) {
                     $return[$key][$field[0]] = $field[1];
                 }
             }
             //cycle(检查周期)和max(周期内最大执行次数)必须同时存在,否则去掉这两个条件
             if (!array_key_exists('cycle', $return[$key]) || !array_key_exists('max', $return[$key])) {
                 unset($return[$key]['cycle']);
                 unset($return[$key]['max']);
             }
             //规则类型
             $return[$key]['_type'] = 4;
         }
     }
     return $return;
 }
예제 #17
0
 /**
 * 评论标签
 * 标签:<comment></comment>
 * 作用:评论标签
 * 用法示例:<comment action="get_comment" catid="$catid" id="$id"> .. HTML ..</comment>
 * 参数说明:
 * 	基本参数
 * 		@action		调用方法(必填)
 * 		@catid		栏目id(必填),列表页,内容页可以使用 $catid 获取当前栏目。
 * 	公用参数:
 * 		@cache		数据缓存时间,单位秒
 * 		@return		返回值变量名称,默认data
 * 	#当action为get_comment时,获取评论总数
 * 	#用法示例:<comment action="get_comment" catid="$catid" id="$id"> .. HTML ..</comment>
 * 	独有参数:
 * 		@id				信息ID
 * 	#当action为lists时,获取评论数据列表
 * 	#用法示例:<comment action="lists" catid="$catid" id="$id"> .. HTML ..</comment>
 * 	独有参数:
 * 		@id		信息ID
 * 		@hot		排序方式{0:最新}
 * 		@date		时间格式 Y-m-d H:i:s A
 * 		@where                          sql语句的where部分
 *    #当action为bang时,获取评论排行榜
 * 	#用法示例:<comment action="bang" num="10"> .. HTML ..</comment>
 * 	独有参数:
 * 		@num		返回信息数
  +----------------------------------------------------------
 * @param string $attr 标签属性
 * @param string $content  标签内容
 */
 public function _comment($tag, $content)
 {
     if (!isModuleInstall('Comments')) {
         return false;
     }
     /* 属性列表 */
     $num = (int) $tag['num'];
     //每页显示总数
     $return = empty($tag['return']) ? "data" : $tag['return'];
     //数据返回变量
     $action = $tag['action'];
     //方法
     $parseStr = '<?php';
     $parseStr .= ' $comment_tag = \\Think\\Think::instance("\\Comments\\TagLib\\Comments");';
     $parseStr .= ' if(method_exists($comment_tag, "' . $action . '")){';
     $parseStr .= ' $' . $return . ' = $comment_tag->' . $action . '(' . self::arr_to_html($tag) . ');';
     $parseStr .= ' }';
     $parseStr .= ' ?>';
     $parseStr .= $this->tpl->parse($content);
     return $parseStr;
 }
예제 #18
0
 /**
  * 信息审核
  * @param type $catid 栏目ID
  * @param type $id 信息ID
  * @param type $status 1为未审核,99为审核通过
  * @return boolean 
  */
 public function check($catid = '', $id = '', $status = 99)
 {
     if (empty($catid) && empty($id)) {
         if (!empty($this->data)) {
             $data = $this->data;
             $catid = $data['catid'];
             $id = $data['id'];
             //模型ID
             $this->modelid = getCategory($catid, 'modelid');
             // 重置数据
             $this->data = array();
         } else {
             $this->error = L('_DATA_TYPE_INVALID_');
             return false;
         }
     } else {
         if (is_array($catid)) {
             $data = $catid;
             $catid = $data['catid'];
             $id = $data['id'];
             //模型ID
             $this->modelid = getCategory($catid, 'modelid');
         } else {
             //模型ID
             $this->modelid = getCategory($catid, 'modelid');
             $data = ContentModel::getInstance($this->modelid)->relation(true)->where(array('id' => $id, 'catid' => $catid))->find();
         }
     }
     ContentModel::getInstance($this->modelid)->dataMerger($data);
     C('TOKEN_ON', false);
     //是否生成HTML
     $sethtml = getCategory($catid, 'sethtml');
     //栏目配置信息
     $setting = getCategory($catid, 'setting');
     $content_ishtml = $setting['content_ishtml'];
     $model = ContentModel::getInstance($this->modelid);
     tag('content_check_begin', $data);
     $data['status'] = $status;
     if ($data) {
         if ($model->where(array('id' => $id, 'catid' => $catid))->save(array('status' => $status)) !== false) {
             //判断是否前台投稿
             if ($data['sysadd'] == 0 && $status == 99 && isModuleInstall('Member')) {
                 //检查是否已经赠送过积分
                 $integral = M('MemberContent')->where(array('content_id' => $id, 'catid' => $catid))->getField('integral');
                 if (!$integral) {
                     if (service('Passport')->userIntegration($data['username'], $setting['member_addpoint'])) {
                         M('MemberContent')->where(array('content_id' => $id, 'catid' => $catid))->save(array('integral' => 1));
                     }
                 }
             }
             //生成内容页
             if ($content_ishtml && !$data['islink'] && $status == 99) {
                 $this->Html->data($data)->show();
                 //生成上下篇
                 $this->relatedContent($catid, $id);
             }
             //如果是取消审核
             if ($content_ishtml && $status != 99) {
                 //则删除生成静态的文件
                 $this->data($data)->deleteHtml();
                 //删除tags
                 D('Content/Tags')->deleteAll($data['id'], $data['catid'], $this->modelid);
             } elseif ($status == 99) {
                 //更新tags
                 if (strpos($data['tags'], ',') === false) {
                     $tags = explode(' ', $data['tags']);
                 } else {
                     $tags = explode(',', $data['tags']);
                 }
                 $tags = array_unique($tags);
                 D('Content/Tags')->updata($tags, $data['id'], $data['catid'], $this->modelid, array('url' => $data['url'], 'title' => $data['title']));
             }
         }
     }
     tag('content_check_end', $data);
     return true;
 }