Esempio n. 1
0
 public final function __construct($attach, $module = "temp")
 {
     if (!is_array($attach) || empty($attach) || !$this->isUploadFile($attach["tmp_name"]) || trim($attach["name"]) == "" || $attach["size"] == 0) {
         $this->_attach = array();
         $this->_errorCode = -1;
         return false;
     } else {
         $attach["type"] = $this->checkDirType($module);
         $attach["size"] = intval($attach["size"]);
         $attach["name"] = trim($attach["name"]);
         $attach["thumb"] = "";
         $attach["ext"] = StringUtil::getFileExt($attach["name"]);
         $attach["name"] = StringUtil::ihtmlSpecialChars($attach["name"], ENT_QUOTES);
         if (90 < strlen($attach["name"])) {
             $attach["name"] = StringUtil::cutStr($attach["name"], 80, "") . "." . $attach["ext"];
         }
         $attach["isimage"] = $this->isImageExt($attach["ext"]);
         $attach["attachdir"] = $this->getTargetDir($attach["type"]);
         $attach["attachname"] = $this->getTargetFileName() . "." . $attach["ext"];
         $attach["attachment"] = $attach["attachdir"] . $attach["attachname"];
         $attach["target"] = FileUtil::getAttachUrl() . "/" . $attach["type"] . "/" . $attach["attachment"];
         $this->_attach =& $attach;
         $this->_errorCode = 0;
         return true;
     }
 }
Esempio n. 2
0
function geturl()
{
    $phpself = getscripturl();
    $isHTTPS = isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off" ? true : false;
    $url = StringUtil::ihtmlSpecialChars("http" . ($isHTTPS ? "s" : "") . "://" . $_SERVER["HTTP_HOST"] . $phpself);
    return $url;
}
Esempio n. 3
0
 private function handleCredits()
 {
     $criteria = array("condition" => "`enable` = 1", "order" => "`cid` ASC", "limit" => 5);
     $record = Credit::model()->fetchAll($criteria);
     if (!empty($record)) {
         $index = 1;
         foreach ($record as $credit) {
             $this->_setting["extcredits"][$index] = $credit;
             $this->_setting["creditremind"] && ($this->_setting["creditnames"][] = str_replace("'", "\\'", StringUtil::ihtmlSpecialChars($credit["cid"] . "|" . $credit["name"])));
             $index++;
         }
     }
     $this->_setting["creditnames"] = $this->_setting["creditremind"] ? @implode(",", $this->_setting["creditnames"]) : "";
 }
Esempio n. 4
0
 public function actionIndex()
 {
     $op = EnvUtil::getRequest("op");
     $id = intval(EnvUtil::getRequest("id"));
     if (EnvUtil::submitCheck("formhash")) {
         if ($op == "edit") {
             $dayNew = $_POST["weekdaynew"] != -1 ? -1 : $_POST["daynew"];
             if (strpos($_POST["minutenew"], ",") !== false) {
                 $minuteNew = explode(",", $_POST["minutenew"]);
                 foreach ($minuteNew as $key => $val) {
                     $minuteNew[$key] = $val = intval($val);
                     if ($val < 0 || 59 < $val) {
                         unset($minuteNew[$key]);
                     }
                 }
                 $minuteNew = array_slice(array_unique($minuteNew), 0, 12);
                 $minuteNew = implode("\t", $minuteNew);
             } else {
                 $minuteNew = intval($_POST["minutenew"]);
                 $minuteNew = 0 <= $minuteNew && $minuteNew < 60 ? $minuteNew : "";
             }
             $cronfile = $this->getRealCronFile($_POST["type"], $_POST["filenamenew"], $_POST["module"]);
             if (preg_match("/[\\\\\\/\\:\\*\\?\"\\<\\>\\|]+/", $_POST["filenamenew"])) {
                 $this->error(Ibos::lang("Crons filename illegal"));
             } elseif (!is_readable($cronfile)) {
                 $this->error(Ibos::lang("Crons filename invalid", "", array("{cronfile}" => $cronfile)));
             } else {
                 if ($_POST["weekdaynew"] == -1 && $dayNew == -1 && $_POST["hournew"] == -1 && $minuteNew === "") {
                     $this->error(Ibos::lang("Crons time invalid"));
                 }
             }
             $data = array("weekday" => $_POST["weekdaynew"], "day" => $dayNew, "hour" => $_POST["hournew"], "minute" => $minuteNew, "filename" => trim($_POST["filenamenew"]));
             $id && Cron::model()->modify($id, $data);
             Ibos::app()->cron->run($id);
         } elseif ($op == "delete") {
             if (!empty($_POST["delete"])) {
                 $ids = StringUtil::iImplode($_POST["delete"]);
                 Cron::model()->deleteAll(sprintf("cronid IN (%s) AND type='user'", $ids));
             }
         } else {
             if (isset($_POST["namenew"]) && !empty($_POST["namenew"])) {
                 foreach ($_POST["namenew"] as $id => $name) {
                     $newCron = array("name" => StringUtil::filterCleanHtml($_POST["namenew"][$id]), "available" => isset($_POST["availablenew"][$id]) ? 1 : 0);
                     if (isset($_POST["availablenew"][$id]) && empty($_POST["availablenew"][$id])) {
                         $newCron["nextrun"] = "0";
                     }
                     Cron::model()->modify($id, $newCron);
                 }
             }
             if (!empty($_POST["newname"])) {
                 $data = array("name" => StringUtil::ihtmlSpecialChars($_POST["newname"]), "type" => "user", "available" => "0", "weekday" => "-1", "day" => "-1", "hour" => "-1", "minute" => "", "nextrun" => TIMESTAMP);
                 Cron::model()->add($data);
             }
             $list = Cron::model()->fetchAll(array("select" => "cronid,filename,type,module"));
             foreach ($list as $cron) {
                 $cronFile = $this->getRealCronFile($cron["type"], $cron["filename"], $cron["module"]);
                 if (!file_exists($cronFile)) {
                     Cron::model()->modify($cron["cronid"], array("available" => 0, "nextrun" => 0));
                 }
             }
             CacheUtil::update("setting");
         }
         $this->success(Ibos::lang("Crons succeed"), $this->createUrl("cron/index"));
     } else {
         if ($op && in_array($op, array("edit", "run"))) {
             $cron = Cron::model()->fetchByPk($id);
             if (!$cron) {
                 $this->error("Cron not found");
             }
             $cron["filename"] = str_replace(array("..", "/", "\\"), array("", "", ""), $cron["filename"]);
             if ($op == "edit") {
                 $this->render("edit", array("cron" => $cron));
             } elseif ($op == "run") {
                 $file = $this->getRealCronFile($cron["type"], $cron["filename"], $cron["module"]);
                 if (!file_exists($file)) {
                     $this->error(Ibos::lang("Crons run invalid", "", array("{cronfile}" => $file)));
                 } else {
                     Ibos::app()->cron->run($cron["cronid"]);
                     $this->success(Ibos::lang("Crons run succeed"), $this->createUrl("cron/index"));
                 }
             }
         } else {
             $list = Cron::model()->fetchAll(array("order" => "type desc"));
             $this->handleCronList($list);
             $this->render("index", array("list" => $list));
         }
     }
 }
Esempio n. 5
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);
 }
Esempio n. 6
0
 public static function referer($default = "")
 {
     $referer = Ibos::app()->setting->get("referer");
     $default = empty($default) ? Ibos::app()->urlManager->createUrl("main/default/index") : $default;
     $referer = !empty($_GET["referer"]) ? $_GET["referer"] : (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $default);
     $loginPage = Ibos::app()->urlManager->createUrl("user/default/login");
     if (strpos($referer, $loginPage)) {
         $referer = $default;
     }
     $referer = StringUtil::ihtmlSpecialChars($referer, ENT_QUOTES);
     $referer = strip_tags(str_replace("&amp;", "&", $referer));
     Ibos::app()->setting->set("referer", $referer);
     return $referer;
 }