private function handleCreditsFormula()
 {
     if (!DashboardUtil::checkFormulaCredits($this->_setting["creditsformula"])) {
         $this->_setting["creditsformula"] = "\$user['extcredits1']";
     } else {
         $this->_setting["creditsformula"] = preg_replace("/(extcredits[1-5])/", "\$user['']", $this->_setting["creditsformula"]);
     }
 }
Beispiel #2
0
 public function actionIndex()
 {
     $formSubmit = EnvUtil::submitCheck("stampSubmit");
     $stampPath = Stamp::STAMP_PATH;
     if ($formSubmit) {
         if (isset($_POST["stamps"])) {
             foreach ($_POST["stamps"] as $id => $stamp) {
                 if (FileUtil::fileExists($stamp["stamp"])) {
                     Stamp::model()->delImg($id, "stamp");
                     $stamp["stamp"] = DashboardUtil::moveTempFile($stamp["stamp"], $stampPath);
                 }
                 if (FileUtil::fileExists($stamp["icon"])) {
                     Stamp::model()->delImg($id, "icon");
                     $stamp["icon"] = DashboardUtil::moveTempFile($stamp["icon"], $stampPath);
                 }
                 Stamp::model()->modify($id, $stamp);
             }
         }
         if (isset($_POST["newstamps"])) {
             foreach ($_POST["newstamps"] as $value) {
                 if (!empty($value["stamp"])) {
                     $value["stamp"] = DashboardUtil::moveTempFile($value["stamp"], $stampPath);
                 }
                 if (!empty($value["icon"])) {
                     $value["icon"] = DashboardUtil::moveTempFile($value["icon"], $stampPath);
                 }
                 Stamp::model()->add($value);
             }
         }
         if (!empty($_POST["removeId"])) {
             $removeIds = explode(",", trim($_POST["removeId"], ","));
             Stamp::model()->deleteByIds($removeIds);
         }
         clearstatcache();
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         if (EnvUtil::getRequest("op") === "upload") {
             $fakeUrl = $this->imgUpload("stamp");
             $realUrl = FileUtil::fileName($fakeUrl);
             return $this->ajaxReturn(array("fakeUrl" => $fakeUrl, "url" => $realUrl));
         }
         $data = array("stampUrl" => $stampPath, "list" => Stamp::model()->fetchAll(), "maxSort" => Stamp::model()->getMaxSort());
         $this->render("index", $data);
     }
 }
Beispiel #3
0
 public function actionFormula()
 {
     $formSubmit = EnvUtil::submitCheck("creditSetupSubmit");
     if ($formSubmit) {
         $formula = $_POST["creditsFormula"];
         $formulaCheckCorrect = DashboardUtil::checkFormulaCredits($formula);
         if ($formulaCheckCorrect) {
             Setting::model()->updateSettingValueByKey("creditsformula", $formula);
         } else {
             $this->error(Ibos::lang("Credits formula invalid"));
         }
         $formulaExp = $_POST["creditsFormulaExp"];
         Setting::model()->updateSettingValueByKey("creditsformulaexp", $formulaExp);
         CacheUtil::update(array("setting"));
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $credits = Credit::model()->fetchAll();
         $data = array("data" => $credits, "creditsFormula" => Setting::model()->fetchSettingValueByKey("creditsformula"), "creditFormulaExp" => Setting::model()->fetchSettingValueByKey("creditsformulaexp"));
         $this->render("formula", $data);
     }
 }
Beispiel #4
0
 public function actionIndex()
 {
     $formSubmit = EnvUtil::submitCheck("loginSubmit");
     $bgPath = LoginTemplate::BG_PATH;
     if ($formSubmit) {
         if (isset($_POST["bgs"])) {
             foreach ($_POST["bgs"] as $id => $bg) {
                 if (FileUtil::fileExists($bg["image"])) {
                     LoginTemplate::model()->delImg($id);
                     $bg["image"] = DashboardUtil::moveTempFile($bg["image"], $bgPath);
                 }
                 $bg["disabled"] = isset($bg["disabled"]) ? 0 : 1;
                 LoginTemplate::model()->modify($id, $bg);
             }
         }
         if (isset($_POST["newbgs"])) {
             foreach ($_POST["newbgs"] as $value) {
                 if (!empty($value["image"])) {
                     $value["image"] = DashboardUtil::moveTempFile($value["image"], $bgPath);
                 }
                 LoginTemplate::model()->add($value);
             }
         }
         if (!empty($_POST["removeId"])) {
             $removeIds = explode(",", trim($_POST["removeId"], ","));
             LoginTemplate::model()->deleteByIds($removeIds, $bgPath);
         }
         clearstatcache();
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         if (EnvUtil::getRequest("op") === "upload") {
             $fakeUrl = $this->imgUpload("bg");
             $realUrl = FileUtil::fileName($fakeUrl);
             return $this->ajaxReturn(array("fakeUrl" => $fakeUrl, "url" => $realUrl));
         }
         $data = array("list" => LoginTemplate::model()->fetchAll(), "bgpath" => $bgPath);
         $this->render("index", $data);
     }
 }
Beispiel #5
0
 public function actionIndex()
 {
     $formSubmit = EnvUtil::submitCheck("userGroupSubmit");
     if ($formSubmit) {
         $groups = $_POST["groups"];
         $newGroups = isset($_POST["newgroups"]) ? $_POST["newgroups"] : array();
         $groupNewAdd = DashboardUtil::arrayFlipKeys($newGroups);
         foreach ($groupNewAdd as $k => $v) {
             if (!$v["title"]) {
                 unset($groupNewAdd[$k]);
             } elseif (!$v["creditshigher"]) {
                 $this->error(Ibos::lang("Usergroups update creditshigher invalid"));
             }
         }
         $groupNewKeys = array_keys($groups);
         $maxGroupId = max($groupNewKeys);
         foreach ($groupNewAdd as $k => $v) {
             $groups[$k + $maxGroupId + 1] = $v;
         }
         $orderArray = array();
         if (is_array($groups)) {
             foreach ($groups as $id => $group) {
                 if ($id == 0 && (!$group["title"] || $group["creditshigher"] == "")) {
                     unset($groups[$id]);
                 } else {
                     $orderArray[$group["creditshigher"]] = $id;
                 }
             }
         }
         if (empty($orderArray) || 0 <= min(array_flip($orderArray))) {
             $this->error(Ibos::lang("Usergroups update credits invalid"));
         }
         ksort($orderArray);
         $rangeArray = array();
         $lowerLimit = array_keys($orderArray);
         for ($i = 0; $i < count($lowerLimit); $i++) {
             $rangeArray[$orderArray[$lowerLimit[$i]]] = array("creditshigher" => isset($lowerLimit[$i - 1]) ? $lowerLimit[$i] : -999999999, "creditslower" => isset($lowerLimit[$i + 1]) ? $lowerLimit[$i + 1] : 999999999);
         }
         foreach ($groups as $id => $group) {
             $creditshigherNew = $rangeArray[$id]["creditshigher"];
             $creditslowerNew = $rangeArray[$id]["creditslower"];
             if ($creditshigherNew == $creditslowerNew) {
                 $this->error(Ibos::lang("Usergroups update credits duplicate"));
             }
             if (in_array($id, $groupNewKeys)) {
                 UserGroup::model()->modify($id, array("title" => $group["title"], "creditshigher" => $creditshigherNew, "creditslower" => $creditslowerNew));
             } else {
                 if ($group["title"] && $group["creditshigher"] != "") {
                     $data = array("title" => $group["title"], "creditshigher" => $creditshigherNew, "creditslower" => $creditslowerNew);
                     UserGroup::model()->add($data);
                 }
             }
         }
         $removeId = $_POST["removeId"];
         if (!empty($removeId)) {
             UserGroup::model()->deleteById($removeId);
         }
         CacheUtil::update(array("UserGroup"));
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $groups = UserGroup::model()->fetchAll(array("order" => "creditshigher"));
         $data = array("data" => $groups);
         $this->render("index", $data);
     }
 }
Beispiel #6
0
 public function actionIndex()
 {
     $operation = EnvUtil::getRequest("op");
     switch ($operation) {
         case "thumbpreview":
         case "waterpreview":
             $temp = Ibos::engine()->IO()->file()->getTempPath() . "/watermark_temp.jpg";
             if (LOCAL) {
                 if (is_file($temp)) {
                     @unlink($temp);
                 }
             }
             $quality = EnvUtil::getRequest("quality");
             $source = PATH_ROOT . "/static/image/watermark_preview.jpg";
             if ($operation == "waterpreview") {
                 $trans = EnvUtil::getRequest("trans");
                 $type = EnvUtil::getRequest("type");
                 $val = EnvUtil::getRequest("val");
                 $pos = EnvUtil::getRequest("pos");
                 if ($type == "image") {
                     $sInfo = ImageUtil::getImageInfo($source);
                     $wInfo = ImageUtil::getImageInfo($val);
                     if ($sInfo["width"] < $wInfo["width"] || $sInfo["height"] < $wInfo["height"]) {
                         Ibos::import("ext.ThinkImage.ThinkImage", true);
                         $imgObj = new ThinkImage(THINKIMAGE_GD);
                         $imgObj->open($val)->thumb(260, 77, 1)->save($val);
                     }
                     ImageUtil::water($source, $val, $temp, $pos, $trans, $quality);
                 } else {
                     $hexColor = EnvUtil::getRequest("textcolor");
                     $size = EnvUtil::getRequest("size");
                     $fontPath = EnvUtil::getRequest("fontpath");
                     $rgb = ConvertUtil::hexColorToRGB($hexColor);
                     ImageUtil::waterMarkString($val, $size, $source, $temp, $pos, $quality, $rgb, self::TTF_FONT_PATH . $fontPath);
                 }
                 $image = $temp;
             }
             if (!LOCAL) {
                 if (Ibos::engine()->IO()->file()->createFile($temp, file_get_contents($image))) {
                     $image = FileUtil::fileName($temp);
                 }
             }
             $data = array("image" => $image, "sourceSize" => ConvertUtil::sizeCount(FileUtil::fileSize($source)), "thumbSize" => ConvertUtil::sizeCount(FileUtil::fileSize($image)), "ratio" => sprintf("%2.1f", FileUtil::fileSize($image) / FileUtil::fileSize($source) * 100) . "%");
             $this->render("imagePreview", $data);
             exit;
             break;
         case "upload":
             return $this->imgUpload("watermark", true);
             break;
     }
     $formSubmit = EnvUtil::submitCheck("uploadSubmit");
     $uploadKeys = "attachdir,attachurl,thumbquality,attachsize,filetype";
     $waterMarkkeys = "watermarkminwidth,watermarkminheight,watermarktype,watermarkposition,watermarktrans,watermarkquality,watermarkimg,watermarkstatus,watermarktext,watermarkfontpath";
     if ($formSubmit) {
         $keys = $uploadKeys . "," . $waterMarkkeys;
         $keyField = explode(",", $keys);
         foreach ($_POST as $key => $value) {
             if (in_array($key, $keyField)) {
                 Setting::model()->updateSettingValueByKey($key, $value);
             } elseif ($key == "watermarkstatus") {
                 Setting::model()->updateSettingValueByKey("watermarkstatus", 0);
             }
         }
         CacheUtil::update(array("setting"));
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $upload = Setting::model()->fetchSettingValueByKeys($uploadKeys);
         $waterMark = Setting::model()->fetchSettingValueByKeys($waterMarkkeys);
         $fontPath = DashboardUtil::getFontPathlist(self::TTF_FONT_PATH);
         $data = array("upload" => $upload, "waterMark" => $waterMark, "fontPath" => $fontPath);
         $this->render("index", $data);
     }
 }