Пример #1
0
 public function actionEdit()
 {
     if (EnvUtil::getRequest("formhash")) {
         $id = intval(EnvUtil::getRequest("id"));
         $name = StringUtil::filterStr(EnvUtil::getRequest("name"));
         $url = StringUtil::filterStr(EnvUtil::getRequest("url"));
         $icon = StringUtil::filterStr(EnvUtil::getRequest("quicknavimg"));
         if (!empty($icon)) {
             FileUtil::copyToDir($icon, $this->_iconPath);
             $info = pathinfo($icon);
             $saveName = $info["basename"];
         } else {
             $saveName = StringUtil::random(16) . ".png";
             $val = EnvUtil::getRequest("fontvalue");
             $this->createColorImg($saveName, $val);
         }
         $data = array("name" => $name, "url" => $url, "description" => "", "icon" => $saveName);
         MenuCommon::model()->modify($id, $data);
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("quicknav/index"));
     } else {
         $op = EnvUtil::getRequest("op");
         if (empty($op)) {
             $id = intval(EnvUtil::getRequest("id"));
             $menu = MenuCommon::model()->fetchByPk($id);
             if (empty($menu)) {
                 $this->error(Ibos::lang("Quicknav not fount tip"), $this->createUrl("quicknav/index"));
             }
             $menu["icon"] = FileUtil::fileName($this->_iconPath . $menu["icon"]);
             $this->render("edit", array("menu" => $menu));
         } else {
             $this->{$op}();
         }
     }
 }
Пример #2
0
 public function handleSetting($event)
 {
     $settings = Setting::model()->fetchAllSetting();
     $this->_setting =& $settings;
     $this->handleCredits();
     $this->handleCreditsFormula();
     $this->_setting["verhash"] = StringUtil::random(3);
     Syscache::model()->modify("setting", $settings);
 }
Пример #3
0
 protected function beforeSave()
 {
     $viewExtFields = StringUtil::filterStr($_POST["viewextfields"]);
     $sumFields = StringUtil::filterStr($_POST["sumfields"]);
     $flowConditions = array("flowquerytype" => $_POST["flow_query_type"], "beginuser" => StringUtil::getId($_POST["begin_user"]), "runname" => StringUtil::filterCleanHtml($_POST["run_name"]), "flowstatus" => $_POST["flow_status"], "time1" => $_POST["time1"], "time2" => $_POST["time2"], "time3" => $_POST["time3"], "time4" => $_POST["time4"], "attachname" => StringUtil::filterCleanHtml($_POST["attach_name"]));
     $groupbyFields = array("field" => $_POST["group_field"], "order" => $_POST["group_sort"]);
     $name = StringUtil::filterCleanHtml($_POST["tplname"]);
     $sid = intval(EnvUtil::getRequest("sid"));
     $data = array("flowid" => $this->flowid, "uid" => $this->uid, "tplname" => $this->tplNameExists($name, $sid) ? $name . StringUtil::random(3) : $name, "viewextfields" => $viewExtFields, "sumfields" => $sumFields, "flowconditions" => serialize($flowConditions), "groupbyfields" => serialize($groupbyFields), "condformula" => $_POST["condformula"]);
     return $data;
 }
Пример #4
0
 public function actionAdd()
 {
     MainUtil::checkLicenseLimit();
     if (EnvUtil::submitCheck("userSubmit")) {
         $origPass = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
         $_POST["salt"] = StringUtil::random(6);
         $_POST["password"] = !empty($origPass) ? md5(md5($origPass) . $_POST["salt"]) : "";
         $_POST["createtime"] = TIMESTAMP;
         $_POST["guid"] = StringUtil::createGuid();
         $this->dealWithSpecialParams();
         $data = User::model()->create();
         $newId = User::model()->add($data, true);
         if ($newId) {
             UserCount::model()->add(array("uid" => $newId));
             $ip = Ibos::app()->setting->get("clientip");
             UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
             UserProfile::model()->add(array("uid" => $newId));
             if (!empty($_POST["auxiliarydept"])) {
                 $deptIds = StringUtil::getId($_POST["auxiliarydept"]);
                 $this->handleAuxiliaryDept($newId, $deptIds, $_POST["deptid"]);
             }
             if (!empty($_POST["auxiliarypos"])) {
                 $posIds = StringUtil::getId($_POST["auxiliarypos"]);
                 $this->handleAuxiliaryPosition($newId, $posIds, $_POST["positionid"]);
             }
             $newUser = User::model()->fetchByPk($newId);
             $users = UserUtil::loadUser();
             $users[$newId] = UserUtil::wrapUserInfo($newUser);
             User::model()->makeCache($users);
             OrgUtil::update();
             OrgUtil::hookSyncUser($newId, $origPass, 1);
             $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("user/index"));
         } else {
             $this->error(Ibos::lang("Add user failed"), $this->createUrl("user/index"));
         }
     } else {
         $deptid = "";
         $manager = "";
         $account = Ibos::app()->setting->get("setting/account");
         if ($account["mixed"]) {
             $preg = "[0-9]+[A-Za-z]+|[A-Za-z]+[0-9]+";
         } else {
             $preg = "^[A-Za-z0-9\\!\\@\\#\$\\%\\^\\&\\*\\.\\~]{" . $account["minlength"] . ",32}\$";
         }
         if ($deptid = EnvUtil::getRequest("deptid")) {
             $deptid = StringUtil::wrapId(EnvUtil::getRequest("deptid"), "d");
             $manager = StringUtil::wrapId(Department::model()->fetchManagerByDeptid(EnvUtil::getRequest("deptid")), "u");
         }
         $this->setPageTitle(Ibos::lang("Add user"));
         $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("User manager"), "url" => $this->createUrl("user/index")), array("name" => Ibos::lang("Add user"))));
         $this->render("add", array("deptid" => $deptid, "manager" => $manager, "passwordLength" => $account["minlength"], "preg" => $preg));
     }
 }
Пример #5
0
 public function create($ip, $uid)
 {
     $this->isNew = true;
     $this->var = $this->newGuest;
     $this->setKey("sid", StringUtil::random(6));
     $this->setKey("uid", $uid);
     $this->setKey("ip", $ip);
     if ($uid) {
         $this->setKey("invisible", UserUtil::getUserProfile("invisible"));
     }
     $this->setKey("lastactivity", time());
     $this->sid = $this->var["sid"];
     return $this->var;
 }
Пример #6
0
 private function setCommonBg($src)
 {
     $bgPath = "data/home/";
     $random = StringUtil::random(16);
     $bgBig = $random . "_big.jpg";
     $bgMiddle = $random . "_middle.jpg";
     $bgSmall = $random . "_small.jpg";
     FileUtil::createFile($bgPath . $bgBig, "");
     FileUtil::createFile($bgPath . $bgMiddle, "");
     FileUtil::createFile($bgPath . $bgSmall, "");
     Ibos::import("ext.ThinkImage.ThinkImage", true);
     $imgObj = new ThinkImage(THINKIMAGE_GD);
     $imgObj->open($src)->thumb(1000, 300, 1)->save($bgPath . $bgBig);
     $imgObj->open($src)->thumb(520, 156, 1)->save($bgPath . $bgMiddle);
     $imgObj->open($src)->thumb(400, 120, 1)->save($bgPath . $bgSmall);
     $data = array("desc" => "", "status" => 0, "system" => 0, "image" => $random);
     $addRes = BgTemplate::model()->add($data);
     return $addRes;
 }
Пример #7
0
 public function actionBackup()
 {
     $formSubmit = EnvUtil::submitCheck("dbSubmit");
     $type = $msg = $url = "";
     $param = array();
     if ($formSubmit) {
         $status = DatabaseUtil::databaseBackup();
         extract($status);
         $this->{$type}($msg, $url, $param);
     } else {
         $data = array();
         $tablePrefix = Ibos::app()->setting->get("config/db/tableprefix");
         if (EnvUtil::getRequest("setup") == "1") {
             $status = DatabaseUtil::databaseBackup();
             extract($status);
             $this->{$type}($msg, $url, $param);
         }
         $data["defaultFileName"] = date("Y-m-d") . "_" . StringUtil::random(8);
         $data["tables"] = DatabaseUtil::getTablelist($tablePrefix);
         $this->render("backup", $data);
     }
 }
Пример #8
0
 public function handleInitInput($event)
 {
     if (isset($_GET["GLOBALS"]) || isset($_POST["GLOBALS"]) || isset($_COOKIE["GLOBALS"]) || isset($_FILES["GLOBALS"])) {
         throw new RequestException(Ibos::lang("Parameters error", "error"));
     }
     $global = Ibos::app()->setting->toArray();
     $config = $global["config"];
     $preLength = strlen($global["config"]["cookie"]["cookiepre"]);
     foreach ($_COOKIE as $key => $value) {
         if (substr($key, 0, $preLength) == $config["cookie"]["cookiepre"]) {
             $global["cookie"][substr($key, $preLength)] = $value;
         }
     }
     $global["sid"] = $global["cookie"]["sid"] = isset($global["cookie"]["sid"]) ? StringUtil::ihtmlSpecialChars($global["cookie"]["sid"]) : "";
     if (empty($global["cookie"]["saltkey"])) {
         $global["cookie"]["saltkey"] = StringUtil::random(8);
         MainUtil::setCookie("saltkey", $global["cookie"]["saltkey"], 86400 * 30, 1, 1);
     }
     $global["authkey"] = md5($global["config"]["security"]["authkey"] . $global["cookie"]["saltkey"]);
     Ibos::app()->setting->copyFrom($global);
 }
Пример #9
0
 protected function getTargetFileName()
 {
     return date("His") . strtolower(StringUtil::random(16));
 }
Пример #10
0
 /**
  * 新增用户
  * @param array $userData
  * @return int insertId
  */
 static function add($userData)
 {
     $salt = StringUtil::random(10);
     // 初始化
     $db = DatabaseFactory::open();
     $result = $db->createCommand("\n\t\t\tINSERT INTO `g_user` (username,mobile,password,salt)\n\t\t\t\tVALUES (:username,:mobile,:password,:salt)\n\t\t")->execute(array(':username' => $userData['username'], ':mobile' => $userData['mobile'], ':password' => self::encodePassword($userData['password'], $salt), ':salt' => $salt));
     if ($result) {
         $userId = $db->getInsertId();
         $redis = self::getRedis();
         $redis->connect($userId)->del(sprintf(self::$REDIS_KEYS['getById'], $userId));
         $redis->connect($userData['username'])->del(sprintf(self::$REDIS_KEYS['getByUsername'], $userData['username']));
         $redis->connect($userData['mobile'])->del(sprintf(self::$REDIS_KEYS['getByMobile'], $userData['mobile']));
         return $userId;
     } else {
         return false;
     }
 }
Пример #11
0
 /**
  * Tests the random string generator.
  */
 public function testRandom()
 {
     for ($i = 1; $i <= 32; $i++) {
         $random = StringUtil::random($i);
         $this->assertEquals($i, strlen($random));
         $this->assertRegExp('~^[a-z0-9]+$~i', $random);
     }
 }
Пример #12
0
 private function addUser()
 {
     if (Ibos::app()->request->isAjaxRequest) {
         $fields = array("username", "password", "realname", "mobile", "deptid", "positionid", "email");
         if (empty($_POST["username"]) || empty($_POST["password"])) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Username or password not empty")));
         }
         foreach ($fields as $field) {
             if (isset($_POST[$field]) && !empty($_POST[$field])) {
                 $_POST[$field] = StringUtil::filterDangerTag($_POST[$field]);
             }
         }
         $salt = StringUtil::random(6);
         $userData = array("salt" => $salt, "username" => $_POST["username"], "password" => !empty($_POST["password"]) ? md5(md5($_POST["password"]) . $salt) : "", "realname" => $_POST["realname"], "mobile" => $_POST["mobile"], "createtime" => TIMESTAMP, "deptid" => intval($_POST["deptid"]), "positionid" => intval($_POST["positionid"]), "email" => $_POST["email"]);
         $newId = User::model()->add($userData, true);
         if ($newId) {
             UserCount::model()->add(array("uid" => $newId));
             $ip = Ibos::app()->setting->get("clientip");
             UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
             UserProfile::model()->add(array("uid" => $newId));
             $newUser = User::model()->fetchByPk($newId);
             $users = UserUtil::loadUser();
             $users[$newId] = UserUtil::wrapUserInfo($newUser);
             User::model()->makeCache($users);
             OrgUtil::update();
             $res["isSuccess"] = true;
         } else {
             $res["isSuccess"] = false;
             $res["msg"] = Ibos::lang("Add user failed");
         }
         $this->ajaxReturn($res);
     }
 }
Пример #13
0
 private function processingTempFile($urlParam)
 {
     $file = PATH_ROOT . "/data/update/IBOS " . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/updatelist.tmp";
     $authKey = Ibos::app()->setting->get("config/security/authkey");
     @unlink($file);
     @unlink(PATH_ROOT . "/data/update.php");
     Cache::model()->deleteByPk("upgrade_step");
     Cache::model()->deleteByPk("upgrade_run");
     Setting::model()->updateSettingValueByKey("upgrade", "");
     CacheUtil::update();
     $randomStr = StringUtil::random(6);
     $oldUpdateDir = "/data/update/";
     $newUpdateDir = "/data/update-" . $randomStr . "/";
     $oldBackDir = "/data/back/";
     $newBackDir = "/data/back-" . $randomStr . "/";
     FileUtil::copyDir(PATH_ROOT . $oldUpdateDir, PATH_ROOT . $newUpdateDir);
     FileUtil::copyDir(PATH_ROOT . $oldBackDir, PATH_ROOT . $newBackDir);
     FileUtil::clearDirs(PATH_ROOT . $oldUpdateDir);
     FileUtil::clearDirs(PATH_ROOT . $oldBackDir);
     $data["step"] = 5;
     $data["data"]["msg"] = Ibos::lang("Upgrade successful", "", array("{version}" => "IBOS" . VERSION . " " . VERSION_DATE, "{saveUpdateDir}" => $newUpdateDir, "{saveBackDir}" => $newBackDir));
     $this->render("upgradeSuccess", $data);
 }
Пример #14
0
 protected function sendVerify($operation, $data)
 {
     $session = new CHttpSession();
     $session->open();
     if ($operation == "email") {
         $val = StringUtil::random(8);
     } elseif ($operation == "mobile") {
         $val = StringUtil::random(5, 1);
     }
     $verifyVal = md5($val);
     $verifyName = $operation;
     $session[$verifyName] = $verifyVal;
     $session["verifyData"] = $data;
     $res = $this->makeVerify($operation, $data, $val);
     $session->close();
     return $res;
 }
Пример #15
0
									<th><?php 
echo $lang['Volume'];
?>
</th>
									<th><?php 
echo $lang['Operation'];
?>
</th>
								</tr>
							</thead>
							<?php 
foreach ($list['exportLog'] as $key => $value) {
    ?>
								<?php 
    $info = $value[1];
    $random = StringUtil::random(5);
    $info['method'] = $info['type'] != 'zip' ? $info['method'] == 'multivol' ? $lang['DBMultivol'] : $lang['DBShell'] : '';
    $info['volume'] = count($value);
    ?>
								<tbody>
									<tr>
										<td>
											<label class="checkbox">
												<input type="checkbox" data-check='key' value="<?php 
    echo $key;
    ?>
"  name="key[<?php 
    echo $key;
    ?>
]">
											</label>
Пример #16
0
 $checkCId = strcmp($imCfg["id"], $cid) == 0;
 $properties = array("company_id" => $cid, "company_token" => $imCfg["token"], "app_id" => $imCfg["appid"], "client_ip" => EnvUtil::getClientIp());
 $api = new BQQApi($properties);
 $status = $api->getVerifyStatus(array("open_id" => $openId, "hashskey" => $hashskey));
 if ($status["ret"] == 0) {
     $config = @(include PATH_ROOT . "/system/config/config.php");
     if (empty($config)) {
         throw new Exception(Ibos::Lang("Config not found", "error"));
     } else {
         define("IN_MOBILE", EnvUtil::checkInMobile());
         $global = array("clientip" => EnvUtil::getClientIp(), "config" => $config, "timestamp" => time());
         Ibos::app()->setting->copyFrom($global);
         handleloadsyscache();
         $saltkey = MainUtil::getCookie("saltkey");
         if (empty($saltkey)) {
             $saltkey = StringUtil::random(8);
             MainUtil::setCookie("saltkey", $saltkey, 86400 * 30, 1, 1);
         }
         $curUser = User::model()->fetchByUid($uid);
         $identity = new ICUserIdentity($curUser["username"], $curUser["password"]);
         $identity->setId($uid);
         $identity->setPersistentStates($curUser);
         $ip = Ibos::app()->setting->get("clientip");
         foreach ($_COOKIE as $k => $v) {
             $cookiePath = $config["cookie"]["cookiepath"];
             $cookieDomain = $config["cookie"]["cookiedomain"];
             $secure = $_SERVER["SERVER_PORT"] == 443 ? 1 : 0;
             @setcookie($k, "", time() - 86400, $cookiePath, $cookieDomain, $secure, false);
         }
         $account = Ibos::app()->setting->get("setting/account");
         $user = Ibos::app()->user;
Пример #17
0
 public function actionAdd()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $data = $this->getPostData();
         $data["flowconditions"] = serialize($data["flowconditions"]);
         $data["groupbyfields"] = serialize($data["groupbyfields"]);
         $data["createtime"] = TIMESTAMP;
         if (FlowQueryTpl::model()->checkTplNameExists($data["tplname"])) {
             $data["tplname"] .= StringUtil::random(3);
         }
         $newID = FlowQueryTpl::model()->add($data, true);
         $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("query/search", array("id" => $newID)));
     }
 }