/** * 设置验证码 * * @return void */ protected static function setRandCode() { switch (self::$verifyType) { case '1': $str = '1234567890'; break; case '2': $str = 'abcdefghjkmnpqrstuvwxyABCDEFGHJKLMNPQRSTUVWXY'; break; case '3': default: $str = '3456789bcefghjkmpqrtvwxyzBCEFGHJKMPQRTVWXYZ'; break; case '5': $str = '人之初性本善性相近习相远苟不教性乃迁教之道贵以专昔孟母择邻处子不学断机杼窦燕山有义方教五子名俱扬养段算适讲按值美态黄易彪服早班麦削信排台声该击素张密害侯草何树肥继右属市严径螺检左页抗苏显苦英快称坏移约巴材省黑武培著河帝仅针怎植京助升王眼她抓含苗副杂普谈围食射源例致酸旧却充足短划剂宣环落首尺波承粉践府鱼随考刻靠够满夫失包住促枝局菌杆周护岩师举曲春元超负砂封换太模贫减阳扬江析亩木言球朝医校古呢稻宋听唯输滑站另卫字鼓刚写刘微略范供阿块某功套友限项余倒卷创律雨让骨远帮初皮播优占死毒圈伟季训控激找叫云互跟裂粮粒母练塞钢顶策双留误础吸阻故寸盾晚丝女散焊功株亲院冷彻弹错散商视艺灭版烈零室轻血倍缺厘泵察绝富城冲喷壤简否柱李望盘磁雄似困巩益洲脱投送奴侧润盖挥距触星松送获兴独官混纪依未突架宽冬章湿偏纹吃执阀矿寨责熟稳夺硬价努翻奇甲预职评读背协损棉侵灰虽矛厚罗泥辟告卵箱掌氧恩爱停曾溶营终纲孟钱待尽俄缩沙退陈讨奋械载胞幼哪剥迫旋征槽倒握担仍呀鲜吧卡粗介钻逐弱脚怕盐末阴丰编印蜂急拿扩伤飞露核缘游振操央伍域甚迅辉异序免纸夜乡久隶缸夹念兰映沟乙吗儒杀汽磷艰晶插埃燃欢铁补咱芽永瓦倾阵碳演威附牙芽永瓦斜灌欧献顺猪洋腐请透司危括脉宜笑若尾束壮暴企菜穗楚汉愈绿拖牛份染既秋遍锻玉夏疗尖殖井费州访吹荣铜沿替滚客召旱悟刺脑'; break; case '4': case '6': self::$verifyCode = self::_convert(self::$askCode); return true; case '7': //目前只有这些声音文件 $str = '123456789BCEFGHJKMPQRTVWXYZ'; break; } $_tmp = Pw::strlen($str) - 1; $_num = 0; for ($i = 0; $i < self::$verifyLength; $i++) { $_num = mt_rand(0, $_tmp); $_code = Pw::substrs($str, 1, $_num, false); self::$verifyCode .= self::_convert($_code); } }
private static function _getMP3Audio() { self::$_audioVerify = ''; $_len = Pw::strlen(self::$verifyCode); for ($i = 0; $i < $_len; $i++) { $_code = strtoupper(self::$verifyCode[$i]); self::$_audioVerify .= WindFile::read(self::$_audioPath . '/' . $_code . '.mp3', WindFile::READ); } }
public function decorateSaveProperty($property, $moduleid) { if (Pw::strlen($property['html']) > 10000) { return new PwError('DESIGN:html.length.error'); } $property['html_tpl'] = $property['html']; $property['limit'] = 1; return $property; }
/** * 发存修改一个发现数据 * * @access public * @return void */ public function doAddAction() { list($fid, $title, $href, $des, $vieworder) = $this->getInput(array('fid', 'title', 'href', 'des', 'vieworder')); $title = trim($title); $href = trim($href); $des = trim($des); $vieworder = (int) $vieworder; if (empty($title)) { $this->showError("NATIVE:fresh.title.empty"); } if (empty($href)) { $this->showError("NATIVE:fresh.link.empty"); } if (Pw::strlen($title) > 5) { $this->showError("名称不能超过5个字符"); } if (Pw::strlen($des) > 9) { $this->showError("备注不能超过9个字符"); } if ($fid) { $fname = $fid; } else { $maxId = $this->_getDao()->getMaxId(); $fname = count($maxId) ? $maxId['fresh_id'] + 1 : 1; } if (!$fid && !$_FILES) { $this->showError('NATIVE:upload.empty'); } if ($_FILES) { Wind::import('SRV:upload.action.PwFreshUpload'); Wind::import('LIB:upload.PwUpload'); $bhv = new PwFreshUpload(); $bhv->filename = $fname; $upload = new PwUpload($bhv); if ($upload->check() === true) { $result = $upload->execute(); } if ($result !== true) { $this->showError($result->getError()); } if (!($data = $bhv->getAttachInfo())) { $this->showError('upload.fail'); } $img = $data['path'] . $data['filename']; } $data = array('title' => $title, 'href' => $href, 'des' => $des, 'vieworder' => $order); if ($img && $_FILES) { $data['img'] = $img; } if ($fid) { $this->_getDao()->updateFresh($fid, $data); } else { $this->_getDao()->addFresh($data); } $this->showMessage('success'); }
/** * 修改分类名称 * * @param int $id * @param string $name * @return bool|object */ public function editType($id, $name) { if (empty($name)) { return new PwError('USER:attention.type.name.empty'); } if (Pw::strlen($name) > 10) { return new PwError('USER:attention.type.name.length.over'); } return $this->_getDao()->editType($id, array('name' => $name)); }
/** * 后台设置-email设置 */ public function dorunAction() { $password = $this->getInput('mailPassword', 'post'); $config = $this->_getConfig(); $t = Pw::strlen($config['mail.password']); $passwordO = Pw::substrs($config['mail.password'], 1, 0, false) . '********' . Pw::substrs($config['mail.password'], 1, $t - 1, false); $password = $password == $passwordO ? $config['mail.password'] : $password; $config = new PwConfigSet('email'); $config->set('mailOpen', $this->getInput('mailOpen', 'post'))->set('mailMethod', 'smtp')->set('mail.host', $this->getInput('mailHost', 'post'))->set('mail.port', $this->getInput('mailPort', 'post'))->set('mail.from', $this->getInput('mailFrom', 'post'))->set('mail.auth', $this->getInput('mailAuth', 'post'))->set('mail.user', $this->getInput('mailUser', 'post'))->set('mail.password', $password)->flush(); $this->showMessage('ADMIN:success'); }
/** * 通过公告记录组装前台显示效果 * 帖子列表滚动展示标题用 * * @return array */ public function getAnnounceForBbsScroll() { $announces = array(); $announceInfos = $this->_getPwAnnounceDs()->getAnnounceByTimeOrderByVieworder(Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')), 9, 0); foreach ($announceInfos as $value) { $announces[$value['aid']] = $value; $announces[$value['aid']]['start_date'] = Pw::time2str($value['start_date'], 'Y-m-d'); if (Pw::strlen($value['subject']) > 18) { $announces[$value['aid']]['subject'] = Pw::substrs($value['subject'], 18); } } return $announces; }
protected function forceDownload($string, $filename, $ext = 'txt') { $router = Wind::getComponent('router'); $agent = $router->request->getServer('HTTP_USER_AGENT'); if (preg_match("/MSIE/", $agent)) { $filename = urlencode($filename); } $filename .= '.' . $ext; ob_end_clean(); header('Content-Encoding: none'); header("Content-type: application/octet-stream"); header('Content-type: text/html; charset=' . Wekit::app()->charset . ''); header("Accept-Ranges: bytes"); header("Accept-Length: " . Pw::strlen($string)); header("Content-Disposition: attachment; filename=" . $filename); echo $string; @flush(); @ob_flush(); exit; }
protected function _bulidContent($array, &$errcode) { $errcode = array(); $array['content'] = str_replace(array("\r", "\n", "\t"), '', $array['content']); $array['content'] = WindSecurity::escapeHTML($array['content']); if ($array['ifshield']) { $array['subject'] = ''; $array['content'] = '<span style="text-decoration: line-through">此帖已被屏蔽</span>'; } elseif ($array['useubb']) { $ubb = new PwUbbCodeConvertThread(); $array['reminds'] && $ubb->setRemindUser($array['reminds']); $array['pic'] && $ubb->setAttachParser(new PwFreshAttachDisplay($array['pic'])); $array['content'] = PwSimpleUbbCode::convert($array['content'], 140, $ubb); PwSimpleUbbCode::isSubstr() && ($errcode['is_read_all'] = true); } elseif (Pw::strlen($array['content']) > 140) { $errcode['is_read_all'] = true; $array['content'] = Pw::substrs($array['content'], 140); } return $array; }
public function checkTagName($tagName = '') { $tagName = $tagName ? $tagName : $this->_data['tag_name']; if (!$tagName) { return true; } $maxLength = 15; if (($result = $this->isNameHasIllegalChar($tagName)) !== false) { return $result; } if (Pw::strlen($tagName) > $maxLength) { return new PwError('TAG:tagname.length.error', array('{maxlength}' => $maxLength)); } return true; }
protected static function _substrs($message, $length) { $strlen = Pw::strlen($message); if ($strlen > $length) { $message = Pw::substrs($message, $length); $strlen = $length; self::$_isSubstr = true; } return array($message, $strlen); }
/** * 编辑用户信息 */ public function dorunAction() { $userDm = new PwUserInfoDm($this->loginUser->uid); $userDm->setRealname($this->getInput('realname', 'post')); $userDm->setByear($this->getInput('byear', 'post')); $userDm->setBmonth($this->getInput('bmonth', 'post')); $userDm->setBday($this->getInput('bday', 'post')); $userDm->setGender($this->getInput('gender', 'post')); $userDm->setHomepage($this->getInput('homepage', 'post')); $userDm->setProfile($this->getInput('profile', 'post')); list($hometown, $location) = $this->getInput(array('hometown', 'location'), 'post'); /* @var $srv PwAreaService */ $srv = Wekit::load('area.srv.PwAreaService'); $areas = $srv->fetchAreaInfo(array($hometown, $location)); $userDm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : ''); $userDm->setLocation($location, isset($areas[$location]) ? $areas[$location] : ''); //没有禁止签名的时候方可编辑签名 if ($this->loginUser->getPermission('allow_sign')) { $bbsSign = $this->getInput('bbs_sign', 'post'); if (($len = $this->loginUser->getPermission('sign_max_length')) && Pw::strlen($bbsSign) > $len) { //仅在此限制签名字数 $this->showError(array('USER:user.edit.sign.length.over', array('{max}' => $len))); } Wind::import('LIB:ubb.PwUbbCode'); Wind::import('LIB:ubb.config.PwUbbCodeConvertConfig'); $ubb = new PwUbbCodeConvertConfig(); $ubb->isConverImg = $this->loginUser->getPermission('sign_ubb_img') ? true : false; $userDm->setBbsSign($bbsSign)->setSignUseubb($bbsSign != PwUbbCode::convert($bbsSign, $ubb) ? 1 : 0); } $result = $this->_editUser($userDm, PwUser::FETCH_MAIN + PwUser::FETCH_INFO); if ($result instanceof PwError) { $this->showError($result->getError()); } else { $this->loginUser->info = array_merge($this->loginUser->info, $userDm->getData()); $this->showMessage('USER:user.edit.profile.success'); } }
protected function getFileName() { $num = 6; $filename = $this->thumbW . '_' . $this->thumbH . '_'; $str = '0123456789abcdefghjkmnopqrstuvwxyABCDEFGHJKLMNOPQRSTUVWXY'; $len = Pw::strlen($str) - 1; for ($i = 0; $i < $num; $i++) { $_num = mt_rand(0, $len); $filename .= substr($str, $_num, 1); } $filename .= '.' . $this->ext; return $filename; }
/** * 新增分类 * Enter description here ... * @param int $logid * @param string $tagname */ public function addTag($uid, $tagname) { if (Pw::strlen($tagname) < 2) { return new PwError('BBS:like.tagname.is.short'); } if (Pw::strlen($tagname) > 10) { return new PwError('BBS:like.tagname.is.lenth'); } $tagInfos = $this->_getLikeTagDs()->getInfoByUid($uid); foreach ($tagInfos as $info) { if ($tagname == $info['tagname']) { return new PwError('BBS:like.tagname.is.already'); } } Wind::import('SRV:like.dm.PwLikeTagDm'); $dm = new PwLikeTagDm(); $dm->setTagname($tagname)->setUid($uid)->setNumber(0); return $this->_getLikeTagDs()->addInfo($dm); }
private function _buildCode($len = 4) { $str = '123456789'; $_tmp = Pw::strlen($str) - 1; $code = ''; $_num = 0; for ($i = 0; $i < $len; $i++) { $_num = mt_rand(0, $_tmp); $code .= $str[$_num]; } return $code; }
/** * 验证用户名 * * @param string $username 验证的用户名 * @param int $uid 排除的用户ID * @return PwError|boolean */ public static function isUsernameValid($username, $uid = 0) { if (!$username) { return new PwError('USER:user.error.-1'); } $result = self::_getWindid()->checkUserInput($username, 1, '', $uid); if ($result < 1) { return new PwError('WINDID:code.' . $result); } if (false !== ($r = self::isUsernameHasIllegalChar($username))) { return $r; } $len = Pw::strlen($username); $config = Wekit::C('register'); if ($len < $config['security.username.min'] || $len > $config['security.username.max']) { return new PwError('USER:user.error.-2', array('{min}' => $config['security.username.min'], '{max}' => $config['security.username.max'])); } if ($config['security.ban.username']) { $_ban = explode(',', $config['security.ban.username']); foreach ($_ban as $value) { if ($value !== '' && strpos($username, $value) !== false) { return new PwError('USER:user.error.-4'); } } } if (self::checkUsernameExist($username, $uid) === true) { return new PwError('USER:user.error.-5'); } return true; }
/** * 编辑分类 * */ public function doEditTagAction() { $tagid = (int) $this->getInput('tag', 'post'); $tagname = trim($this->getInput('tagname', 'post')); if (Pw::strlen($tagname) < 2) { $this->showError('BBS:like.tagname.is.short'); } if (Pw::strlen($tagname) > 10) { $this->showError('BBS:like.tagname.is.lenth'); } $tags = $this->_getLikeTagService()->getInfoByUid($this->loginUser->uid); $allow = false; foreach ($tags as $tag) { if ($tag['tagid'] == $tagid) { $allow = true; } if ($tag['tagname'] == $tagname) { $this->showError('BBS:like.fail.already.tagname'); } } if (!$allow) { $this->showError('BBS:like.fail'); } Wind::import('SRV:like.dm.PwLikeTagDm'); $dm = new PwLikeTagDm($tagid); $dm->setTagname($tagname); $resource = $this->_getLikeTagService()->updateInfo($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } $this->setOutput(array('id' => $tagid, 'name' => $tagname), 'data'); $this->showMessage('BBS:like.success'); }
/** * do添加分类 * * @return void */ public function doAddTypeAction() { $this->getRequest()->isPost() || $this->showError('operate.fail'); list($typename, $vieworder) = $this->getInput(array('typename', 'vieworder'), 'post'); if (Pw::strlen($typename) > 6) { $this->showError('Link:linkname.len.error'); } $type = $this->_getLinkDs()->getTypeByName($typename); if ($type) { $this->showError('Link:type.exist'); } if (($result = $this->_getLinkDs()->addLinkType($typename, $vieworder)) instanceof PwError) { $this->showError($result->getError()); } $this->showMessage("ADMIN:success"); }
protected function _beforeAdd() { if (!$this->_data['name']) { return new PwError('LINK:require_empty'); } if (!$this->_data['url']) { return new PwError('LINK:require_empty'); } $len = Pw::strlen($this->_data['name']); if ($len < 1 || $len > 15) { return new PwError('LINK:link.lenerror'); } return true; }
public static function bulidGroup($group) { $str = implode('', $group); $str = trim($str); if (Pw::strlen($str) <= 5) { return implode(',', $group); } $i = 0; $t = array(); foreach ($group as $value) { $value = trim($value); $len = Pw::strlen($value); if ($i + $len < 5) { $t[] = $value; } else { $t[] = Pw::substrs($value, 5 - $i, 0, false); break; } $i += $len; } return implode(',', $t) . '...'; }
public function checkContent() { if ($this->_data['content'] === '') { return new PwError('BBS:post.content.empty'); } $len = Pw::strlen($this->_data['content']); $config = Wekit::C('bbs'); if ($this->forum && $this->forum->forumset['minlengthofcontent']) { $config['content.length.min'] = $this->forum->forumset['minlengthofcontent']; } if ($len < $config['content.length.min']) { return new PwError('BBS:post.content.length.less', array('{min}' => $config['content.length.min'])); } if ($len > $config['content.length.max']) { return new PwError('BBS:post.content.length.more', array('{max}' => $config['content.length.max'])); } if ($this->forum && $this->user) { if ((!$this->forum->forumset['allowhide'] || !$this->user->getPermission('allow_thread_extend.hide')) && (PwUbbCode::hasTag($this->_data['content'], 'post') || PwUbbCode::hasTag($this->_data['content'], 'hide'))) { return new PwError('BBS:post.content.hide'); } if ((!$this->forum->forumset['allowsell'] || !$this->user->getPermission('allow_thread_extend.sell')) && PwUbbCode::hasTag($this->_data['content'], 'sell')) { return new PwError('BBS:post.content.sell'); } } return true; }
protected function _bulidContent($content, $ubb, &$errcode) { $errcode = array(); $content = str_replace(array("\r", "\n", "\t"), '', $content); $content = WindSecurity::escapeHTML($content); if ($ubb) { $content = PwSimpleUbbCode::convert($content, 140, new PwUbbCodeConvertThread()); PwSimpleUbbCode::isSubstr() && ($errcode['is_read_all'] = true); } elseif (Pw::strlen($content) > 140) { $errcode['is_read_all'] = true; $content = Pw::substrs($content, 140); } //var_dump($content); //$content = WindSecurity::escapeHTML($content); //$content = preg_replace('/(?<!&|&)#([^#]+?)#/ie', "self::_parseTopic('\\1')", $content); return $content; }
/** * do发消息dialog * * @return void */ public function doAddDialogAction() { // 检测权限 $right = $this->_getMessageService()->checkAddMessageRight($this->loginUser); if ($right instanceof PwError) { $this->showError($right->getError()); } list($username, $content, $code) = $this->getInput(array('username', 'content', 'code'), 'post'); !$content && $this->showError('MESSAGE:content.empty'); if (Pw::strlen($content) > 500) { $this->showError('MESSAGE:content.length.error'); } $result = $this->_getMessageService()->sendMessage($username, $content, $this->loginUser->uid); if ($result instanceof PwError) { $this->showError($result->getError()); } $this->showMessage('success'); }
/** * 编辑帖子阅读页话题 * * @return void */ public function editReadTagAction(){ // 是否登录 if ($this->loginUser->uid < 1) { $this->showError('USER:user.not.login'); } list($tid,$tagnames) = $this->getInput(array('tid','tagnames')); $tagnames = $tagnames ? $tagnames : array(); // 是否有权限 if ($this->_checkAllowEdit($tid) !== true) { $this->showError('TAG:right.tag_allow_edit.error'); } $count = count($tagnames); $count > 5 && $this->showError("Tag:tagnum.exceed"); Wind::import('SRV:tag.dm.PwTagDm'); if ($count == 1) { $dm = new PwTagDm(); $dm->setName($tagnames['0']); if(($result = $dm->beforeUpdate()) instanceof PwError) { $this->showError($result->getError()); } } // 敏感词 $content = implode(' ', $tagnames); $wordFilter = Wekit::load('SRV:word.srv.PwWordFilter'); list($type, $words) = $wordFilter->filterWord($content); if ($type) { $this->showError("WORD:content.error"); } $typeId = $this->_getTagService()->getTypeIdByTypeName($this->defaultType); $dmArray = array(); foreach ((array)$tagnames as $value) { $value = trim($value); if(Pw::strlen($value) > 15) { continue; } $dm = new PwTagDm(); if (($result = $dm->checkTagName($value)) instanceof PwError) { $this->showError($result->getError()); } $dmArray[$value] = $dm->setName($value) ->setTypeId($typeId) ->setParamId($tid) ->setIfHot(1) ->setCreatedTime(Pw::getTime()) ->setCreateUid($this->loginUser->uid) ; } $result = $this->_getTagService()->updateTags($typeId,$tid,$dmArray); if ($result instanceof PwError) { $this->showError($result->getError()); } $this->showMessage('success'); }
public function verifyRealnameAction() { $statu = $this->_checkState(); $realname = trim($this->getInput('realname')); if (!$realname) { $this->showError('请输入真实姓名'); } if (Pw::strlen($realname) > 50) { $this->showError('真实姓名长度不能超过50个字'); } $dm = new App_Verify_Dm(); $dm->setUid($this->loginUser->uid)->setUsername($this->loginUser->username)->setType(App_Verify::VERIFY_REALNAME)->setData(serialize(array('realname' => $realname))); $this->_getService()->addCheck($dm); $this->showMessage('success'); }
/** * 创建数据库 */ public function databaseAction() { $keys = array('dbhost', 'dbuser', 'dbname', 'dbprefix', 'manager', 'manager_pwd', 'manager_ckpwd', 'manager_email', 'dbpw', 'engine'); $input = $this->getInput($keys, 'post'); $force = $this->getInput('force'); $input = array_combine($keys, $input); foreach ($input as $k => $v) { if (!in_array($k, array('dbpw', 'engine')) && empty($v)) { $this->showError("INSTALL:input_empty_{$k}"); } } if ($input['manager_pwd'] !== $input['manager_ckpwd']) { $this->showError('INSTALL:manager_pwd.eque.ckpwd'); } if (!preg_match('/^[\\x7f-\\xff\\dA-Za-z\\.\\_]+$/', $input['manager'])) { $this->showError('INSTALL:founder.name.error'); } $usernameLen = Pw::strlen($input['manager']); $passwordLen = Pw::strlen($input['manager_pwd']); if ($usernameLen < 1 || $usernameLen > 15 || $passwordLen < 1 || $passwordLen > 25) { $this->showError('INSTALL:founder.init.fail'); } if (false === WindValidator::isEmail($input['manager_email'])) { $this->showError('INSTALL:founder.init.email.error'); } list($input['dbhost'], $input['dbport']) = explode(':', $input['dbhost']); $input['dbport'] = !empty($input['dbport']) ? intval($input['dbport']) : 3306; if (!empty($input['engine'])) { $input['engine'] = strtoupper($input['engine']); !in_array($input['engine'], array('MyISAM', 'InnoDB')) && ($input['engine'] = 'MyISAM'); } else { $input['engine'] = 'MyISAM'; } $charset = Wind::getApp()->getResponse()->getCharset(); $charset = str_replace('-', '', strtolower($charset)); if (!in_array($charset, array('gbk', 'utf8', 'big5'))) { $charset = 'utf8'; } // 检测是否安装过了 Wind::import("WIND:db.WindConnection"); $dsn = 'mysql:host=' . $input['dbhost'] . ';port=' . $input['dbport']; try { $pdo = new WindConnection($dsn, $input['dbuser'], $input['dbpw']); $result = $pdo->query("SHOW DATABASES")->fetchAll(); foreach ($result as $v) { if ($v['Database'] == $input['dbname']) { $dbnameExist = true; break; } } if ($dbnameExist) { $result = $pdo->query("SHOW TABLES FROM `{$input['dbname']}`")->rowCount(); empty($result) && ($dbnameExist = false); } } catch (PDOException $e) { $error = $e->getMessage(); $this->showError($error, false); } if ($dbnameExist && !$force) { $this->showError('INSTALL:have_install', true, 'index/database', true); } if (!$dbnameExist) { try { $pdo = new WindConnection($dsn, $input['dbuser'], $input['dbpw']); $pdo->query("CREATE DATABASE IF NOT EXISTS `{$input['dbname']}` DEFAULT CHARACTER SET {$charset}"); } catch (PDOException $e) { $error = $e->getMessage(); $this->showError($error, false); } } $pdo->close(); if (!$this->_checkWriteAble($this->_getDatabaseFile())) { $this->showError('INSTALL:error_777_database'); } if (!$this->_checkWriteAble($this->_getFounderFile())) { $this->showError('INSTALL:error_777_founder'); } $database = array('dsn' => 'mysql:host=' . $input['dbhost'] . ';dbname=' . $input['dbname'] . ';port=' . $input['dbport'], 'user' => $input['dbuser'], 'pwd' => $input['dbpw'], 'charset' => $charset, 'tableprefix' => $input['dbprefix'], 'engine' => $input['engine'], 'founder' => array('manager' => $input['manager'], 'manager_pwd' => $input['manager_pwd'], 'manager_email' => $input['manager_email'])); WindFile::savePhpData($this->_getTempFile(), $database); $arrSQL = array(); foreach ($this->wind_data as $file) { $file = Wind::getRealPath("APPS:install.lang.{$file}", true); if (!WindFile::isFile($file)) { continue; } $content = WindFile::read($file); if (!empty($content)) { $arrSQL = array_merge_recursive($arrSQL, $this->_sqlParser($content, $charset, $input['dbprefix'], $input['engine'])); } } WindFile::savePhpData($this->_getTableSqlFile(), $arrSQL['SQL']); WindFile::write($this->_getTableLogFile(), implode('<wind>', $arrSQL['LOG']['CREATE'])); $this->showMessage('success', false, 'index/table'); }
/** * 检查数据合法性 * * @return boolean|PwError */ private function _checkName($name) { if (!$name) { return new PwError('USER:tag.name.require'); } $len = Pw::strlen($name); //标签名称的长度为1 - 8个字 if ($len > 8 || $len < 1) { return new PwError('USER:tag.name.length.error'); } //标签名称只支持中文、字母、数字、下划线和小数点哦 if (!preg_match('/^[\\x7f-\\xff\\dA-Za-z\\.\\_]+$/', $name)) { return new PwError('USER:tag.name.format.error'); } return true; }
/** * 执行添加公共账号 * lyl */ public function doAddAction() { //判断公共账号所属的主分类是否存在 $configs = Wekit::C()->getValues('native'); $life_fid = isset($configs['forum.life_fid']) && $configs['forum.life_fid'] ? $configs['forum.life_fid'] : 0; Wind::import('SRV:forum.dm.PwForumDm'); $pwForum = Wekit::load('forum.PwForum'); $forumset = array('allowtype' => array('default'), 'typeorder' => array('default' => 0)); if (!$life_fid) { //尚未创建公共账号所属分类,自动创建 $dm = new PwForumDm(); $dm->setParentid(0)->setName('生活服务')->setVieworder(0)->setManager('')->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } else { // var_dump($result); $life_fid = $result; $config = new PwConfigSet('native'); $config->set('forum.life_fid', $life_fid)->flush(); // var_dump($life_fid); } } if ($_FILES['logo']['size'] > 300000) { $this->showError("图片大小不能超过300k", 'native/life/run/', true); } // exit; //添加公共服务版面 $dm_life = new PwForumDm(); list($forumname, $manager, $vieworder, $descrip, $isshow, $url, $address) = $this->getInput(array('forumname', 'manager', 'vieworder', 'descrip', 'isshow', 'url', 'address'), 'post'); if (!$forumname) { $this->showError("商家名称不能为空", 'native/life/run/', true); } if (Pw::strlen($address) > 100) { $this->showError("商家地址不能超过100个汉字", 'native/life/run/', true); } $dm_life->setParentid($life_fid)->setName($forumname)->setVieworder($vieworder)->setManager($manager)->setDescrip($descrip)->setIsshow($isshow)->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm_life)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } $fid = $result; //上传版块logo $dm_life = new PwForumDm($fid); $logo = $this->_uploadImage('logo', $fid); $dm_life->setlogo($logo['path']); if (($result = $pwForum->updateForum($dm_life)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } // Wekit::load('forum.srv.PwForumMiscService')->correctData(); $forumLifeDao = Wekit::loadDao('native.dao.PwForumLifeDao'); if (($result = $forumLifeDao->addForumLife(array('fid' => $fid, 'url' => $url, 'address' => $address))) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } $this->showMessage('success', 'native/life/run', true); }