Ejemplo n.º 1
1
 public function delete()
 {
     $appHouseAds = AppHouseAdUtil::getAppHouseAdsByCid($this->id);
     foreach ($appHouseAds as $appHouseAd) {
         $appHouseAd->delete();
     }
     if (!empty($this->imageLink)) {
         if (extension_loaded('curl') && !@dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
             $s3 = new S3(HouseAd::$HOUSEAD_AWS_KEY, HouseAd::$HOUSEAD_AWS_SECRET);
             $s3->deleteObject(HouseAd::$HOUSEAD_BUCKET, basename($this->imageLink));
         }
     }
     parent::delete();
     CacheUtil::invalidateCustom($this->id);
 }
Ejemplo n.º 2
0
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $cache = new CacheUtil();
     //      if there were failed tests hand off to CacheUtil
     if (!empty($this->failedTests)) {
         $cache->createCache($this->failedTests, $_SERVER['argv']);
     } else {
         //          delete cache file if all tests passed
         $cache->deleteCache($_SERVER['argv']);
     }
 }
Ejemplo n.º 3
0
 public function testCreateAndReadCache()
 {
     $cache = new CacheUtil();
     $test1 = new RerunRandomTest();
     $test2 = new RerunRandomTest();
     $failedTestsToWrite = array(array('testMethodName' => $test1->getName(), 'testClassName' => get_class($test1)), array('testMethodName' => $test2->getName(), 'testClassName' => get_class($test2)));
     $cmdOptions = array('phpunit', 'testName');
     $cache->createCache($failedTestsToWrite, $cmdOptions);
     $key = $cache->generateKey($cmdOptions);
     $failedTestsFromFile = $cache->readCache($key);
     $this->assertEquals($failedTestsToWrite, $failedTestsFromFile, 'Test written to file differ from those read from file');
 }
Ejemplo n.º 4
0
 public function fetchAllCache($cacheNames)
 {
     $cacheNames = is_array($cacheNames) ? $cacheNames : array($cacheNames);
     $data = CacheUtil::get($cacheNames);
     if (is_array($data) && in_array(false, $data, true) || !$data) {
         $data = false;
     }
     $newArray = $data !== false ? array_diff($cacheNames, array_keys($data)) : $cacheNames;
     if (empty($newArray)) {
         foreach ($data as &$cache) {
             $isSerialized = $cache == serialize(false) || @unserialize($cache) !== false;
             $cache = $isSerialized ? unserialize($cache) : $cache;
         }
         return $data;
     } else {
         $cacheNames = $newArray;
     }
     $caches = $this->fetchAll(sprintf("FIND_IN_SET(name,'%s')", implode(",", $cacheNames)));
     if ($caches) {
         foreach ($caches as $sysCache) {
             $data[$sysCache["name"]] = $sysCache["type"] ? unserialize($sysCache["value"]) : $sysCache["value"];
             CacheUtil::set($sysCache["name"], $data[$sysCache["name"]]);
         }
         foreach ($cacheNames as $name) {
             if ($data[$name] === null) {
                 $data[$name] = null;
                 CacheUtil::rm($name);
             }
         }
     }
     return $data;
 }
Ejemplo n.º 5
0
 public function actionParam()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $data = array("sealfrom" => $_POST["seal_from"]);
         $workRemindBefore = intval($_POST["work_remind_before"]);
         $unitBefore = $_POST["unit_before"];
         if (!empty($workRemindBefore)) {
             $workRemindBefore .= $unitBefore;
             $data["wfremindbefore"] = $workRemindBefore;
         }
         $workRemindAfter = $_POST["work_remind_after"];
         $unitAfter = $_POST["unit_after"];
         if (!empty($workRemindAfter)) {
             $workRemindAfter .= $unitAfter;
             $data["wfremindafter"] = $workRemindAfter;
         }
         foreach ($data as $key => $value) {
             Setting::model()->updateSettingValueByKey($key, $value);
         }
         CacheUtil::update("setting");
         $this->success(Ibos::lang("Operation succeed", "message"));
     } else {
         $keys = "wfremindbefore,wfremindafter,sealfrom";
         $values = Setting::model()->fetchSettingValueByKeys($keys);
         $param = array();
         foreach ($values as $key => $value) {
             if ($key == "wfremindbefore" || $key == "wfremindafter") {
                 $param[$key . "desc"] = substr($value, 0, -1);
                 $param[$key . "unit"] = substr($value, -1, 1);
             }
             $param[$key] = $value;
         }
         $this->render("param", array("param" => $param));
     }
 }
Ejemplo n.º 6
0
 public function actionRule()
 {
     $formSubmit = EnvUtil::submitCheck("creditRuleSubmit");
     if ($formSubmit) {
         $cycles = $_POST["cycles"];
         $credits = $_POST["credits"];
         $rewardNums = $_POST["rewardnums"];
         $rulesParam = array();
         foreach ($cycles as $ruleId => $cycle) {
             $rulesParam[$ruleId]["cycletype"] = $cycle;
         }
         foreach ($credits as $ruleId => $credit) {
             foreach ($credit as $extcreditOffset => $creditValue) {
                 $rulesParam[$ruleId]["extcredits" . $extcreditOffset] = $creditValue;
             }
         }
         foreach ($rewardNums as $ruleId => $rewardNum) {
             $rulesParam[$ruleId]["rewardnum"] = $rewardNum;
         }
         foreach ($rulesParam as $ruleId => $updateValue) {
             CreditRule::model()->modify($ruleId, $updateValue);
         }
         CacheUtil::update(array("creditRule"));
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $rules = CreditRule::model()->fetchAll();
         $credits = Credit::model()->fetchAll();
         $data = array("rules" => $rules, "credits" => $credits);
         $this->render("rule", $data);
     }
 }
Ejemplo n.º 7
0
 public function actionUpdate()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $fieldArr = array("reporttypemanage" => "", "stampenable" => 0, "stampdetails" => "", "pointsystem" => 5, "autoreview" => 0, "autoreviewstamp" => 1);
         foreach ($_POST as $key => $value) {
             if (in_array($key, array_keys($fieldArr))) {
                 $fieldArr[$key] = $value;
             }
         }
         $stampStr = "";
         if (!empty($fieldArr["stampdetails"])) {
             foreach ($fieldArr["stampdetails"] as $score => $stampId) {
                 $stampId = empty($stampId) ? 0 : $stampId;
                 $stampStr .= $stampId . ":" . $score . ",";
             }
         }
         $fieldArr["stampdetails"] = rtrim($stampStr, ",");
         $apprise = EnvUtil::getRequest("apprise");
         if (empty($_POST["stampdetails"][$apprise])) {
             $fieldArr["autoreview"] = 0;
         } else {
             $fieldArr["autoreviewstamp"] = $_POST["stampdetails"][$apprise];
         }
         Setting::model()->modify("reportconfig", array("svalue" => serialize($fieldArr)));
         CacheUtil::update("setting");
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
     }
 }
Ejemplo n.º 8
0
 public function actionIndex()
 {
     $unit = Setting::model()->fetchSettingValueByKey("unit");
     $formSubmit = EnvUtil::submitCheck("unitSubmit");
     if ($formSubmit) {
         $postData = array();
         if (!empty($_FILES["logo"]["name"])) {
             !empty($unit["logourl"]) && FileUtil::deleteFile($unit["logourl"]);
             $postData["logourl"] = $this->imgUpload("logo");
         } elseif (!empty($_POST["logourl"])) {
             $postData["logourl"] = $_POST["logourl"];
         } else {
             $postData["logourl"] = "";
         }
         $keys = array("phone", "fullname", "shortname", "fax", "zipcode", "address", "adminemail", "systemurl");
         foreach ($keys as $key) {
             if (isset($_POST[$key])) {
                 $postData[$key] = StringUtil::filterCleanHtml($_POST[$key]);
             } else {
                 $postData[$key] = "";
             }
         }
         Setting::model()->updateSettingValueByKey("unit", $postData);
         CacheUtil::update(array("setting"));
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $license = Setting::model()->fetchSettingValueByKey("license");
         $data = array("unit" => unserialize($unit), "license" => $license);
         $this->render("index", $data);
     }
 }
Ejemplo n.º 9
0
 public function actionAdd()
 {
     $flowId = intval(EnvUtil::getRequest("flowid"));
     $flow = new ICFlowType($flowId);
     if (EnvUtil::submitCheck("formhash")) {
         $this->checkFlowAccess($flowId, 1, $this->createUrl("new/add"));
         $this->beforeAdd($_POST, $flow);
         $run = array("name" => $_POST["name"], "flowid" => $flowId, "beginuser" => $this->uid, "begintime" => TIMESTAMP);
         $runId = FlowRun::model()->add($run, true);
         $runProcess = array("runid" => $runId, "processid" => 1, "uid" => $this->uid, "flag" => FlowConst::PRCS_UN_RECEIVE, "flowprocess" => 1, "createtime" => TIMESTAMP);
         FlowRunProcess::model()->add($runProcess);
         if (strstr($flow->autoname, "{N}")) {
             FlowType::model()->updateCounters(array("autonum" => 1), sprintf("flowid = %d", $flowId));
             CacheUtil::rm("flowtype_" . $flowId);
         }
         $runData = array("runid" => $runId, "name" => $_POST["name"], "beginuser" => $this->uid, "begin" => TIMESTAMP);
         $this->handleRunData($flow, $runData);
         $param = array("flowid" => $flowId, "runid" => $runId, "processid" => 1, "flowprocess" => 1, "fromnew" => 1);
         $jumpUrl = $this->createUrl("form/index", array("key" => WfCommonUtil::param($param)));
         $this->ajaxReturn(array("isSuccess" => true, "jumpUrl" => $jumpUrl));
     } else {
         $this->checkFlowAccess($flowId, 1);
         if (!empty($flow->autoname)) {
             $runName = WfNewUtil::replaceAutoName($flow, $this->uid);
         } else {
             $runName = sprintf("%s (%s)", $flow->name, date("Y-m-d H:i:s"));
         }
         $data = array("flow" => $flow->toArray(), "runName" => $runName, "lang" => Ibos::getLangSources());
         $this->renderPartial("add", $data);
     }
 }
Ejemplo n.º 10
0
 public static function getSourceInfo($table, $rowId, $forApi = false, $moduleName = "weibo")
 {
     static $_forApi = "0";
     $_forApi == "0" && ($_forApi = intval($forApi));
     $key = $_forApi ? $table . $rowId . "_api" : $table . $rowId;
     $info = CacheUtil::get("source_info_" . $key);
     if ($info) {
         return $info;
     }
     switch ($table) {
         case "feed":
             $info = self::getInfoFromFeed($table, $rowId, $_forApi);
             break;
         case "comment":
             $info = self::getInfoFromComment($table, $rowId, $_forApi);
             break;
         default:
             $table = ucfirst($table);
             $model = $table::model();
             if (method_exists($model, "getSourceInfo")) {
                 $info = $model->getSourceInfo($rowId, $_forApi);
             }
             unset($model);
             break;
     }
     $info["source_table"] = $table;
     $info["source_id"] = $rowId;
     CacheUtil::set("source_info_" . $key, $info);
     return $info;
 }
Ejemplo n.º 11
0
 public function actionEdit()
 {
     if (EnvUtil::submitCheck("emailSubmit")) {
         $setting = array();
         foreach ($this->_fields as $field) {
             if (array_key_exists($field, $_POST)) {
                 $setting[$field] = intval($_POST[$field]);
             } else {
                 $setting[$field] = 0;
             }
         }
         $roles = array();
         if (isset($_POST["role"])) {
             foreach ($_POST["role"] as $role) {
                 if (!empty($role["positionid"]) && !empty($role["size"])) {
                     $positionId = StringUtil::getId($role["positionid"]);
                     $roles[implode(",", $positionId)] = intval($role["size"]);
                 }
             }
         }
         $setting["emailroleallocation"] = serialize($roles);
         foreach ($setting as $key => $value) {
             Setting::model()->updateSettingValueByKey($key, $value);
         }
         CacheUtil::update("setting");
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
     }
 }
Ejemplo n.º 12
0
 public function actionSetup()
 {
     $formSubmit = EnvUtil::submitCheck("formhash");
     if ($formSubmit) {
         $data =& $_POST;
         foreach (array("sendemail", "sendsms", "sendmessage") as $field) {
             if (!empty($data[$field])) {
                 $ids = array_keys($data[$field]);
                 $idstr = implode(",", $ids);
                 Notify::model()->updateAll(array($field => 1), sprintf("FIND_IN_SET(id,'%s')", $idstr));
                 Notify::model()->updateAll(array($field => 0), sprintf("NOT FIND_IN_SET(id,'%s')", $idstr));
             } else {
                 Notify::model()->updateAll(array($field => 0));
             }
         }
         CacheUtil::update("NotifyNode");
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $nodeList = Notify::model()->getNodeList();
         foreach ($nodeList as &$node) {
             $node["moduleName"] = Module::model()->fetchNameByModule($node["module"]);
         }
         $this->render("setup", array("nodeList" => $nodeList));
     }
 }
Ejemplo n.º 13
0
 public function actionSetup()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $_POST["wbpostfrequency"] = 5 < intval($_POST["wbpostfrequency"]) ? $_POST["wbpostfrequency"] : 5;
         $_POST["wbnums"] = 140 <= intval($_POST["wbnums"]) ? $_POST["wbnums"] : 140;
         $wbwatermark = isset($_POST["wbwatermark"]) ? 1 : 0;
         $wbwcenabled = isset($_POST["wbwcenabled"]) ? 1 : 0;
         $postType = array("image" => 0, "topic" => 0, "praise" => 0);
         if (isset($_POST["wbposttype"])) {
             foreach ($postType as $key => &$val) {
                 if (isset($_POST["wbposttype"][$key])) {
                     $val = 1;
                 }
             }
         }
         if (isset($_POST["wbmovements"])) {
         } else {
             $_POST["wbmovements"] = array();
         }
         $data = array("wbnums" => $_POST["wbnums"], "wbpostfrequency" => $_POST["wbpostfrequency"], "wbposttype" => $postType, "wbwatermark" => $wbwatermark, "wbwcenabled" => $wbwcenabled, "wbmovement" => $_POST["wbmovements"]);
         foreach ($data as $key => $value) {
             Setting::model()->updateSettingValueByKey($key, $value);
         }
         CacheUtil::update("setting");
         $this->success(Ibos::lang("Operation succeed", "message"));
     } else {
         $data = array("config" => WbCommonUtil::getSetting(), "movementModule" => WbCommonUtil::getMovementModules());
         $this->render("setup", $data);
     }
 }
Ejemplo n.º 14
0
 public function parse($isUpdate = false)
 {
     Ibos::import("application.extensions.simple_html_dom", true);
     if ($isUpdate) {
         $model = preg_replace("/\\s+data-id\\s?=\\s?\"?\\d+\"?/i", "", $this->printmodel);
         $max = 0;
     } else {
         $model = $this->printmodel;
         $max = intval($this->itemmax);
     }
     $elements = array();
     $doc = new simple_html_dom();
     $doc->load($model, true, true, CHARSET);
     $items = $doc->find("ic");
     $config = $this->getItemConfig();
     if (!empty($items) && !empty($config)) {
         $this->refactor($items, $config, $max, $elements);
     }
     $html = $doc->save();
     $this->_cache = $elements;
     CacheUtil::set("form_" . $this->ID, $elements);
     $form["printmodelshort"] = $html;
     if ($max != $this->itemmax) {
         $form["itemmax"] = $max;
     }
     $doc->clear();
     FlowFormType::model()->modify($this->ID, $form);
 }
Ejemplo n.º 15
0
 public function actionEdit()
 {
     if (Ibos::app()->request->getIsAjaxRequest()) {
         if (EnvUtil::getRequest("op") === "structure") {
             $curId = EnvUtil::getRequest("curid");
             $objId = EnvUtil::getRequest("objid");
             $status = $this->setStructure($curId, $objId);
             $this->ajaxReturn(array("IsSuccess" => $status), "json");
         }
         $deptId = EnvUtil::getRequest("deptid");
         if ($deptId == 0) {
             $keys = array("phone", "fullname", "shortname", "fax", "zipcode", "address", "adminemail");
             $postData = array();
             foreach ($_POST as $key => $value) {
                 if (in_array($key, $keys)) {
                     $postData[$key] = $value;
                 }
             }
             Setting::model()->updateSettingValueByKey("unit", $postData);
             $editStatus = true;
             CacheUtil::update(array("setting"));
         } else {
             $this->dealWithBranch();
             $this->dealWithSpecialParams();
             $data = Department::model()->create();
             $editStatus = Department::model()->modify($data["deptid"], $data);
             $editStatus && OrgUtil::update();
         }
         $this->ajaxReturn(array("IsSuccess" => !!$editStatus), "json");
     }
 }
Ejemplo n.º 16
0
 public function actionIndex()
 {
     $types = EnvUtil::getRequest("updatetype");
     $data = array();
     if (EnvUtil::submitCheck("formhash")) {
         $type = implode(",", $types);
         if (!empty($type)) {
             $this->redirect($this->createUrl("update/index", array("doupdate" => 1, "updatetype" => $type)));
         }
     }
     if (Ibos::app()->request->getIsAjaxRequest()) {
         $op = EnvUtil::getRequest("op");
         if (LOCAL) {
             @set_time_limit(0);
         }
         if ($op == "data") {
             CacheUtil::update();
         }
         if ($op == "static") {
             LOCAL && Ibos::app()->assetManager->republicAll();
             OrgUtil::update();
         }
         if ($op == "module") {
             ModuleUtil::updateConfig();
         }
         Ibos::app()->cache->clear();
         $this->ajaxReturn(array("isSuccess" => true));
     }
     if (EnvUtil::getRequest("doupdate") == 1) {
         $type = explode(",", trim($types, ","));
         $data["doUpdate"] = true;
         foreach ($type as $index => $act) {
             if (!empty($act)) {
                 if (in_array("data", $type)) {
                     unset($type[$index]);
                     $data["typedesc"] = Ibos::lang("Update") . Ibos::lang("Data cache");
                     $data["op"] = "data";
                     break;
                 }
                 if (in_array("static", $type)) {
                     unset($type[$index]);
                     $data["typedesc"] = Ibos::lang("Update") . Ibos::lang("Static cache");
                     $data["op"] = "static";
                     break;
                 }
                 if (in_array("module", $type)) {
                     $data["typedesc"] = Ibos::lang("Update") . Ibos::lang("Module setting");
                     $data["op"] = "module";
                     unset($type[$index]);
                     break;
                 }
             }
         }
         $data["next"] = $this->createUrl("update/index", array("doupdate" => intval(!empty($type)), "updatetype" => implode(",", $type)));
     } else {
         $data["doUpdate"] = false;
     }
     $this->render("index", $data);
 }
Ejemplo n.º 17
0
 public function actionIndex()
 {
     $type = EnvUtil::getRequest("type");
     $allowType = array("rtx", "qq");
     if (!in_array($type, $allowType)) {
         $type = "rtx";
     }
     $diff = array_diff($allowType, array($type));
     $value = Setting::model()->fetchSettingValueByKey("im");
     $im = unserialize($value);
     $formSubmit = EnvUtil::submitCheck("imSubmit");
     if ($formSubmit) {
         $type = $_POST["type"];
         if ($type == "rtx") {
             $keys = array("open", "server", "appport", "sdkport", "push", "sso", "reverselanding", "syncuser");
         } elseif ($type == "qq") {
             $keys = array("open", "id", "token", "appid", "appsecret", "push", "sso", "syncuser", "syncorg", "showunread", "refresh_token", "time", "expires_in");
         }
         $updateList = array();
         foreach ($keys as $key) {
             if (isset($_POST[$key])) {
                 $updateList[$key] = $_POST[$key];
             } else {
                 $updateList[$key] = 0;
             }
         }
         if ($updateList["open"] == "1") {
             $this->checkImUnique($diff);
             $correct = MessageUtil::getIsImBinding($type, $updateList);
             if ($correct !== true) {
                 $updateList["open"] = 0;
             } elseif ($type == "qq") {
                 $updateList["checkpass"] = 1;
             }
         } else {
             if ($type == "qq") {
                 $updateList["checkpass"] = 0;
             }
             $correct = true;
         }
         $im[$type] = $updateList;
         Setting::model()->updateSettingValueByKey("im", $im);
         CacheUtil::update(array("setting"));
         if ($correct === true) {
             $this->success(Ibos::lang("Save succeed", "message"));
         } else {
             $updateList["open"] = 0;
             if (is_array($correct)) {
                 $msg = isset($correct[ICIM::ERROR_INIT]) ? implode(",", $correct[ICIM::ERROR_INIT]) : Ibos::lang("Unknown error", "error");
             } else {
                 $msg = Ibos::lang("Unknown error", "error");
             }
             $this->error(Ibos::lang("Binding error", "", array("{err}" => $msg)));
         }
     } else {
         $data = array("type" => $type, "im" => $im[$type]);
         $this->render($type, $data);
     }
 }
Ejemplo n.º 18
0
 public function actionSwitchstatus()
 {
     if (Ibos::app()->getRequest()->getIsAjaxRequest()) {
         $val = EnvUtil::getRequest("val");
         $result = Setting::model()->updateSettingValueByKey("appclosed", (int) $val);
         CacheUtil::update(array("setting"));
         return $this->ajaxReturn(array("IsSuccess" => $result), "json");
     }
 }
Ejemplo n.º 19
0
 public static function getLogTableId()
 {
     $tableId = CacheUtil::get("logtableid");
     if ($tableId === false) {
         $tableId = Ibos::app()->db->createCommand()->select("svalue")->from("{{setting}}")->where("skey = 'logtableid'")->queryScalar();
         CacheUtil::set("logtableid", intval($tableId));
     }
     return $tableId;
 }
Ejemplo n.º 20
0
 public function getNodeList()
 {
     $list = CacheUtil::get("notifyNode");
     if (!$list) {
         $list = $this->fetchAllSortByPk("node", array("order" => "`module` DESC"));
         CacheUtil::set("notifyNode", $list);
     }
     return $list;
 }
Ejemplo n.º 21
0
 public static function getPurv($posId)
 {
     $access = CacheUtil::get("purv_" . $posId);
     if (!$access) {
         $access = Ibos::app()->getAuthManager()->getItemChildren($posId);
         CacheUtil::set("purv_" . $posId, array_flip(array_map("strtolower", array_keys($access))));
     }
     return $access;
 }
Ejemplo n.º 22
0
 public function fetchAllEnabledModule()
 {
     $module = CacheUtil::get("module");
     if ($module == false) {
         $criteria = array("condition" => "`disabled` = 0", "order" => "`sort` ASC");
         $module = $this->fetchAllSortByPk("module", $criteria);
         CacheUtil::set("module", $module);
     }
     return $module;
 }
Ejemplo n.º 23
0
 public function deleteWeiboJoinTopic($feedId)
 {
     $del["feedid"] = $feedId;
     $topicId = $this->getDbConnection()->createCommand()->select("topicid")->from("{{feed_topic_link}}")->where("feedid = " . intval($feedId))->queryScalar();
     if ($topicId) {
         FeedTopicLink::model()->deleteAllByAttributes($del);
         $this->updateCounters(array("count" => 1), "topicid = " . intval($topicId));
         $recommend = $this->getDbConnection()->createCommand()->select("recommend")->from($this->tableName())->where("topicid = " . $topicId)->queryScalar();
         if ($recommend == 1) {
             CacheUtil::rm("feed_topic_recommend");
         }
     }
 }
Ejemplo n.º 24
0
 /**
  * Initialise.
  *
  * Runs at plugin init time.
  *
  * @return void
  */
 public function initialize(GenericEvent $event)
 {
     // register namespace
     // Because the standard kernel classloader already has Doctrine registered as a namespace
     // we have to add a new loader onto the spl stack.
     $autoloader = new UniversalClassLoader();
     $autoloader->register();
     $autoloader->registerNamespaces(array('DoctrineProxy' => 'ztemp/doctrinemodels'));
     $container = $event->getDispatcher()->getContainer();
     $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
     $dbConfig = array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'driver' => 'pdo_' . $config['dbdriver']);
     $r = new \ReflectionClass('Doctrine\\Common\\Cache\\' . $container['dbcache.type'] . 'Cache');
     $dbCache = $r->newInstance();
     $ORMConfig = new \Doctrine\ORM\Configuration();
     $container->set('doctrine.configuration', $ORMConfig);
     $ORMConfig->setMetadataCacheImpl($dbCache);
     // create proxy cache dir
     \CacheUtil::createLocalDir('doctrinemodels');
     // setup annotations base
     include_once \ZLOADER_PATH . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
     // setup annotation reader
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
     $container->set('doctrine.annotationreader', $cacheReader);
     // setup annotation driver
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
     $container->set('doctrine.annotationdriver', $annotationDriver);
     // setup driver chains
     $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $container->set('doctrine.driverchain', $driverChain);
     // configure Doctrine ORM
     $ORMConfig->setMetadataDriverImpl($annotationDriver);
     $ORMConfig->setQueryCacheImpl($dbCache);
     $ORMConfig->setProxyDir(\CacheUtil::getLocalDir('doctrinemodels'));
     $ORMConfig->setProxyNamespace('DoctrineProxy');
     if (isset($container['log.enabled']) && $container['log.enabled']) {
         $ORMConfig->setSQLLogger(new \Zikula\Core\Doctrine\Logger\ZikulaSqlLogger());
     }
     // setup doctrine eventmanager
     $dispatcher = new \Doctrine\Common\EventManager();
     $container->set('doctrine.eventmanager', $dispatcher);
     // setup MySQL specific listener (storage engine and encoding)
     if ($config['dbdriver'] == 'mysql') {
         $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
         $dispatcher->addEventSubscriber($mysqlSessionInit);
     }
     // setup the doctrine entitymanager
     $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $dispatcher);
     $container->set('doctrine.entitymanager', $entityManager);
 }
Ejemplo n.º 25
0
 public function actionEdit()
 {
     $votethumbenable = 0;
     if (isset($_POST["votethumbenable"])) {
         $votethumbenable = $_POST["votethumbenable"];
     }
     $width = empty($_POST["votethumbwidth"]) ? 0 : $_POST["votethumbwidth"];
     $height = empty($_POST["votethumbheight"]) ? 0 : $_POST["votethumbheight"];
     $votethumbewh = $width . "," . $height;
     Setting::model()->modify("votethumbenable", array("svalue" => $votethumbenable));
     Setting::model()->modify("votethumbwh", array("svalue" => $votethumbewh));
     CacheUtil::update("setting");
     $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
 }
Ejemplo n.º 26
0
 private function processCmdCache($cmd, $name, $ttl = 0)
 {
     $ret = "";
     switch ($cmd) {
         case "set":
             $ret = CacheUtil::set("process_lock_" . $name, TIMESTAMP, $ttl);
             break;
         case "get":
             $ret = CacheUtil::get("process_lock_" . $name);
             break;
         case "rm":
             $ret = CacheUtil::rm("process_lock_" . $name);
     }
     return $ret;
 }
Ejemplo n.º 27
0
 /**
  * Class constructor.
  *
  * @param string  $feed_url       The URL to the feed (optional).
  * @param integer $cache_duration The duration (in seconds) that the feed contents will be retained in cache.
  */
 public function __construct($feed_url = null, $cache_duration = null, $cache_dir = null)
 {
     parent::__construct();
     if (isset($cache_dir)) {
         $this->set_cache_location($cache_dir);
     } else {
         $this->set_cache_location(CacheUtil::getLocalDir('feeds'));
     }
     if (isset($cache_duration)) {
         $this->set_cache_duration($cache_duration);
     }
     if (isset($feed_url)) {
         $this->set_feed_url($feed_url);
     }
 }
Ejemplo n.º 28
0
 public static function ipBanned($onlineip)
 {
     CacheUtil::load("ipbanned");
     $ipBanned = Ibos::app()->setting->get("cache/ipbanned");
     if (empty($ipBanned)) {
         return false;
     } else {
         if ($ipBanned["expiration"] < TIMESTAMP) {
             CacheUtil::update("ipbanned");
             CacheUtil::load("ipbanned", true);
             $ipBanned = Ibos::app()->setting->get("cache/ipbanned");
         }
         return preg_match("/^(" . $ipBanned["regexp"] . ")\$/", $onlineip);
     }
     return preg_match("/^(" . $ipBanned["regexp"] . ")\$/", $onlineip);
 }
Ejemplo n.º 29
0
 public function actionStatus()
 {
     $moduleStatus = EnvUtil::getRequest("type");
     $module = EnvUtil::getRequest("module");
     if (Ibos::app()->getRequest()->getIsAjaxRequest()) {
         $status = 0;
         if ($moduleStatus == "disabled") {
             $status = 1;
         }
         $changeStatus = Module::model()->modify($module, array("disabled" => $status));
         Nav::model()->updateAll(array("disabled" => $status), "module = :module", array(":module" => $module));
         CacheUtil::update(array("setting", "nav"));
         ModuleUtil::updateConfig($module);
         $this->ajaxReturn(array("IsSuccess" => $changeStatus), "json");
     }
 }
Ejemplo n.º 30
0
 public function actionIndex()
 {
     $formSubmit = EnvUtil::submitCheck("dateSetupSubmit");
     if ($formSubmit) {
         $data = array("dateformat" => $_POST["dateFormat"], "timeformat" => $_POST["timeFormat"], "dateconvert" => $_POST["dateConvert"], "timeoffset" => $_POST["timeOffset"]);
         foreach ($data as $sKey => $sValue) {
             Setting::model()->updateSettingValueByKey($sKey, $sValue);
         }
         CacheUtil::update(array("setting"));
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $date = Setting::model()->fetchSettingValueByKeys("dateformat,dateconvert,timeformat,timeoffset");
         $data = array("timeZone" => Ibos::getLangSource("dashboard.timeZone"), "date" => $date);
         $this->render("index", $data);
     }
 }