/**
  * Returns all the settings for the specified domain.
  *
  * @param string $domain
  *           Domain name
  * @throws PDOException
  * @return array Array of SystemSetting objects
  */
 public function getAllDomain($domain)
 {
     try {
         return AppUtils::dbToArray($this->db->system_setting()->where("domain=?", $domain)->order("settingKey"));
     } catch (PDOException $e) {
         throw $e;
     }
 }
 private function _getUIconfig($custom)
 {
     $moduleList = array();
     foreach (AppbymeUIDiyModel::getModules() as $module) {
         if (!$custom && $module['type'] == AppbymeUIDiyModel::MODULE_TYPE_CUSTOM) {
             $module['componentList'] = array();
         }
         $moduleList[] = AppUtils::filterModule($module);
     }
     return array('navigation' => AppbymeUIDiyModel::getNavigationInfo(), 'moduleList' => $moduleList);
 }
 private function _getModuleconfig($moduleId)
 {
     $module = array('padding' => '');
     foreach (AppbymeUIDiyModel::getModules() as $tmpModule) {
         if ($tmpModule['id'] == $moduleId) {
             $module = AppUtils::filterModule($tmpModule);
             break;
         }
     }
     return array('module' => $module);
 }
Example #4
0
 /**
  * Call
  *
  * This method will check the HTTP request headers for previous
  * authentication. If the request has already authenticated, the next
  * middleware is called. Otherwise, a 401 Authentication Required response is
  * returned to the client.
  */
 public function call()
 {
     $reqURI = $this->app->request()->getResourceUri();
     if ($reqURI == '/login' || $reqURI == '/logout') {
         $this->next->call();
     } else {
         if (AppUtils::isLoggedIn()) {
             $this->next->call();
         } else {
             $res = $this->app->response();
             $res->status(401);
         }
     }
 }
 /**
  * Prepares the environment before running a test.
  */
 public static function setUpBeforeClass()
 {
     self::$pdo = new ForumServicePDO();
     self::$userPDO = new UserServicePDO();
     AppUtils::setTestMode(true);
     AppUtils::setLoginValid(SELF::USER_ID, "sysuser");
     // Create a user for forum testing
     // Not sure how else to do this
     $newUser = array('id' => SELF::USER_ID, 'firstName' => 'forumUserFirstName', 'lastName' => 'forumUserLastName', 'organization' => 'testOrganization', 'email' => '*****@*****.**', 'password' => 'forumUser1234', 'sysuser' => 1, 'enabled' => 1);
     // Create Users for forum test
     $retUser = self::$userPDO->create($newUser);
     PHPUnit_Framework_Assert::assertEquals($retUser['id'], SELF::USER_ID);
     $newUser['id'] = SELF::USER_ID2;
     $retUser = self::$userPDO->create($newUser);
     PHPUnit_Framework_Assert::assertEquals($retUser['id'], SELF::USER_ID2);
 }
 /**
  * Prepares the environment before running a test.
  */
 public static function setUpBeforeClass()
 {
     // fwrite(STDOUT, __METHOD__ . "\n");
     self::$forumPDO = new ForumServicePDO();
     self::$postPDO = new ForumPostServicePDO();
     self::$userPDO = new UserServicePDO();
     AppUtils::setTestMode(true);
     AppUtils::setLoginValid(SELF::USER_ID, "sysuser");
     // Create a user for forum testing
     // Not sure how else to do this
     $newUser = array('id' => SELF::USER_ID, 'firstName' => 'forumUserFirstName', 'lastName' => 'forumUserLastName', 'organization' => 'testOrganization', 'email' => '*****@*****.**', 'password' => 'forumUser1234', 'sysuser' => 1, 'enabled' => 1);
     // Create Users for forum test
     $retUser = self::$userPDO->create($newUser);
     PHPUnit_Framework_Assert::assertEquals($retUser['id'], SELF::USER_ID);
     // Create a Forum
     self::$forumId = self::$forumPDO->createForum('TestForum.1', 'TestForum.1 Description', SELF::USER_ID);
     PHPUnit_Framework_Assert::assertNotNull(self::$forumId);
 }
Example #7
0
<?php
error_reporting(E_ALL ^ E_WARNING);

define('PAPRIKA_LIBRARY_PATH', realpath('library'));
define('PAPRIKA_CUSTOM_PATH', realpath('custom'));
define('ROOT_PATH', dirname(__FILE__));

require(PAPRIKA_LIBRARY_PATH.'/AppUtils.php');

AppUtils::getInstance()->import();
//

?>
 public function DanhSachGameServices()
 {
     $gname = null;
     if (isset($_POST["gname"]) && $_POST["gname"] != "") {
         $gname = "game_name like '%" . $_POST["gname"] . "%'";
     }
     $this->registry->db->connect();
     $sqlselect = "game_id,game_name,game_content,game_url,game_difficulty,game_physical,game_number_min,game_number_max,\n            image_url,game_time,DATE_FORMAT(created_time, '%d/%m/%Y'),DATE_FORMAT(updated_time, '%d/%m/%Y'),\n            game_price,ticket_code,game_seq,game_promotions,game_name_vn,game_content_vn,game_promotions_vn";
     $order = "game_seq";
     $this->registry->db->select('tbl_game_info', $sqlselect, $gname, $order);
     $result = $this->registry->db->getResult();
     $numRow = $this->registry->db->getNumRow();
     $this->registry->db->disconnect();
     $lResult = array();
     $lList = array();
     $appUtil = new AppUtils();
     if ($numRow == 1) {
         $o = array();
         $o["gid"] = $result["game_id"];
         $o["gname"] = $result["game_name"];
         $o["gprice"] = $result["game_price"];
         $o["gcontent"] = $result["game_content"];
         $o["gdiff"] = $appUtil->cDoKhoGame($result["game_difficulty"]);
         $o["gnumber"] = $appUtil->cSoNguoiChoi($result['game_number_min'], $result['game_number_max']);
         $o["gtime"] = $appUtil->cThoiGianChoiGame($result['game_time']);
         $o["gcode"] = $result["ticket_code"];
         $o["gurl"] = $result["game_url"];
         $o["gimageurl"] = $result["image_url"];
         $o["gpromotions"] = $result["game_promotions"];
         $o["gnamevn"] = $result["game_name_vn"];
         $o["gcontentvn"] = $result["game_content_vn"];
         $o["gpromotionsvn"] = $result["game_promotions_vn"];
         array_push($lResult, $o);
     } else {
         foreach ($result as $value) {
             $o = array();
             $o["gid"] = $value["game_id"];
             $o["gname"] = $value["game_name"];
             $o["gprice"] = $value["game_price"];
             $o["gcontent"] = $value["game_content"];
             $o["gdiff"] = $appUtil->cDoKhoGame($value["game_difficulty"]);
             $o["gnumber"] = $appUtil->cSoNguoiChoi($value['game_number_min'], $value['game_number_max']);
             $o["gtime"] = $appUtil->cThoiGianChoiGame($value['game_time']);
             $o["gcode"] = $value["ticket_code"];
             $o["gurl"] = $value["game_url"];
             $o["gimageurl"] = $value["image_url"];
             $o["gpromotions"] = $value["game_promotions"];
             $o["gnamevn"] = $value["game_name_vn"];
             $o["gcontentvn"] = $value["game_content_vn"];
             $o["gpromotionsvn"] = $value["game_promotions_vn"];
             array_push($lResult, $o);
         }
     }
     $lList["total"] = count($lList);
     $lList["rows"] = $lResult;
     echo json_encode($lList);
 }
Example #9
0
 /**
  * logout by destroying the session
  */
 public static function logout()
 {
     if (!self::$testMode) {
         // This is handled by cascading delete in database schema
         // This way if the GC deletes the session the event subscriptions will
         // be cleaned up
         // $userId = self::getUserId();
         // if (isset($userId))
         // {
         // // Unsubscribe from all events
         // $pdo = new EventServicePDO();
         // $pdo->unsubscribeForUser($userId);
         // }
         /*
          * NO_ZEBRA_SESSION $_SESSION = array(); // destroy all of the session
          * variables session_destroy();
          */
         $link = mysqliConnect();
         $session = new Zebra_Session($link, SESSION_HASH, SESSION_LIFETIME_SECONDS);
         $session->stop();
         self::$xactSession = NULL;
     }
 }
Example #10
0
 /**
  *
  * @see EventServicePDO::unsubscribe()
  */
 public static function unsubscribe($userId, $topic)
 {
     try {
         $pdo = new EventServicePDO();
         $pdo->unsubscribe($userId, $topic);
         AppUtils::sendResponse(array("success" => true, "message" => "User {$userId} unsubscribed from topic {$topic}"));
     } catch (PDOException $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error unsubscribing to events user {$userId} topic {$topic}", $e->getMessage());
     }
 }
Example #11
0
 /**
  * @return AppUtils
  */
 public static function getInstance() {
     if (!self::$instance) {
         self::$instance = new AppUtils();
     }
     return self::$instance;
 }
Example #12
0
 /**
  * Create a new forum file node using the specified object values
  *
  * @param mixed $node
  *           Forum File Node object
  * @throws PDOException
  * @return mixed new Forum File Node object with GUID assigned by server
  */
 public function createFileNode($node)
 {
     try {
         if (!isset($node['id']) || strlen($node['id']) < 2) {
             $node['id'] = AppUtils::guid();
         }
         $this->db->forum_file_node()->insert((array) $node);
         // AppUtils::logDebug(
         // "Created file node with ID: {" . $node['id'] . "} and parentId {" .
         // $node['parentId'] . "}");
         return $node;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #13
0
 /**
  *
  * @see SettingsServicePDO::getDomains()
  */
 public static function getDomains()
 {
     try {
         $pdo = new SettingsServicePDO();
         $result = $pdo->getDomains();
         AppUtils::sendResponse($result);
     } catch (PDOException $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error getting all setting domains", $e->getMessage());
     }
 }
Example #14
0
 /**
  *
  * @see ForumServicePDO::deleteForum()
  */
 public static function deleteForum($id)
 {
     $app = \Slim\Slim::getInstance();
     $params = array('forumId' => $id, 'changeType' => ForumEvent::DELETE);
     try {
         $pdo = new ForumServicePDO();
         $pdo->deleteForum($id);
         AppUtils::sendEvent(ForumEvent::DOMAIN, $id, ForumEvent::CHANGE, "Forum deleted: " . $id, $params);
         $app->response()->status(204);
         // NO DOCUMENT STATUS CODE FOR SUCCESS
     } catch (Exception $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error deleting forum with ID: " . $id, $e->getMessage());
     }
 }
Example #15
0
 public static function getEvents($id)
 {
     AppUtils::sendResponse(AppUtils::getEvents());
 }
 /**
  *
  * @see ForumServicePDO::getForumsForUser()
  */
 public static function getForumsForUser()
 {
     try {
         $pdo = new ForumServicePDO();
         $userId = AppUtils::getUserId();
         $forums = $pdo->getForumsForUser($userId);
         AppUtils::sendResponse($forums);
     } catch (PDOException $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error getting forums for user {$userId}", $e->getMessage());
     }
 }
Example #17
0
 public function actionIndex()
 {
     $newsModules = AppbymePoralModule::getModuleList();
     $forumList = ForumUtils::getForumListForHtml();
     $navInfo = AppbymeUIDiyModel::getNavigationInfo(true);
     $tempModules = AppbymeUIDiyModel::getModules(true);
     // 初始化默认配置
     if (empty($navInfo) || empty($navInfo['navItemList']) || empty($tempModules)) {
         $navInfo = AppbymeUIDiyModel::initNavigation();
         $tempModules = AppbymeUIDiyModel::initModules();
     }
     // 必须存在发现导航
     $hasDiscoverNavItem = false;
     foreach ($navInfo['navItemList'] as $navItem) {
         if ($navItem['moduleId'] == AppbymeUIDiyModel::MODULE_ID_DISCOVER) {
             $hasDiscoverNavItem = true;
             break;
         }
     }
     !$hasDiscoverNavItem && array_unshift($navInfo['navItemList'], AppbymeUIDiyModel::initNavItemDiscover());
     // 必须存在发现和快发模块
     $isFindDiscover = $isFindFastpost = false;
     $discoverModule = AppbymeUIDiyModel::initDiscoverModule();
     $fastpostModule = AppbymeUIDiyModel::initFastpostModule();
     $modules = array();
     foreach ($tempModules as $module) {
         switch ($module['id']) {
             case AppbymeUIDiyModel::MODULE_ID_DISCOVER:
                 if (!$isFindDiscover) {
                     $isFindDiscover = true;
                     $discoverModule = $module;
                 }
                 break;
             case AppbymeUIDiyModel::MODULE_ID_FASTPOST:
                 if (!$isFindFastpost) {
                     $isFindFastpost = true;
                     $fastpostModule = $module;
                 }
                 break;
             default:
                 $modules[] = $module;
                 break;
         }
     }
     array_unshift($modules, $discoverModule, $fastpostModule);
     // 检测浏览器信息
     $mobileDetect = new Mobile_Detect();
     $browserInfo = $mobileDetect->version('Chrome');
     $this->renderPartial('index', array('navInfo' => $navInfo, 'modules' => $modules, 'newsModules' => $newsModules, 'forumList' => $forumList, 'browserInfo' => $browserInfo, 'appLevel' => AppUtils::getAppLevel(), 'topicTypeSortInfos' => $this->_getTopicTypeSortInfos()));
 }
Example #18
0
 /**
  * Uploads the file specified via HTTP POST
  * This code is based on the PHP examples
  */
 public static function upload()
 {
     $app = \Slim\Slim::getInstance();
     $forumId = $_POST['forumId'];
     $folderId = $_POST['id'];
     $fileName = $_FILES["file"]["name"];
     $tempFileName = $_FILES["file"]["tmp_name"];
     $contentType = $_FILES["file"]["type"];
     // Check for errors
     if ($_FILES['file']['error'] > 0) {
         $errorMsg = 'Upload Error: ';
         // Print a message based upon the error.
         switch ($_FILES['file']['error']) {
             case 1:
                 $errorMsg = $errorMsg . 'The file exceeds the upload_max_filesize setting in php.ini.';
                 break;
             case 2:
                 $errorMsg = $errorMsg . 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.';
                 break;
             case 3:
                 $errorMsg = $errorMsg . 'The file was only partially uploaded.';
                 break;
             case 4:
                 $errorMsg = $errorMsg . 'No file was uploaded.';
                 break;
             case 6:
                 $errorMsg = $errorMsg . 'No temporary folder was available.';
                 break;
             case 7:
                 $errorMsg = $errorMsg . 'Unable to write to the disk.';
                 break;
             case 8:
                 $errorMsg = $errorMsg . 'File upload stopped.';
                 break;
             default:
                 $errorMsg = $errorMsg . 'A system error occurred.';
                 break;
         }
         // End of switch.
         AppUtils::sendError(500, "File Upload Error", $errorMsg);
     } else {
         try {
             $fileNode = array('id' => '', 'forumId' => $forumId, 'parentId' => $folderId, 'name' => $fileName, 'contentType' => $contentType);
             $pdo = new ForumServicePDO();
             $fileNode = $pdo->createFileNode((array) $fileNode);
             $fileId = $fileNode['id'];
             move_uploaded_file($tempFileName, FORUM_UPLOAD_DIR . $fileId);
             $fileNode['changeType'] = ForumEvent::CREATE;
             AppUtils::sendEvent(ForumEvent::DOMAIN, $forumId, ForumEvent::NODE_CHANGE, "Node created: " . $fileNode['name'], $fileNode);
             AppUtils::sendResponse($fileNode);
         } catch (Exception $e) {
             AppUtils::logError($e, __METHOD__);
             AppUtils::sendError($e->getCode(), "Error creating file node for {$fileName}", $e->getMessage());
         }
     }
     // Delete the file if it still exists:
     if (file_exists($_FILES['file']['tmp_name']) && is_file($_FILES['file']['tmp_name'])) {
         unlink($_FILES['file']['tmp_name']);
     }
 }
Example #19
0
<?php
error_reporting(E_ALL ^ E_WARNING);

define('PAPRIKA_LIBRARY_PATH', realpath('library'));
define('PAPRIKA_CUSTOM_PATH', realpath('custom'));
define('ROOT_PATH', dirname(__FILE__));

require(PAPRIKA_LIBRARY_PATH.'/AppUtils.php');

AppUtils::getInstance()->siteMap();

?>
 /**
  * Logs out current user and sends a response of Logged Out
  * until something else more useful should be returned.
  */
 public static function logout()
 {
     AppUtils::logout();
     AppUtils::sendResponse('Logged Out');
 }
Example #21
0
 /**
  *
  * @see ForumPostServicePDO::purgeForumPost()
  */
 public static function purgeForumPost($forumId)
 {
     $app = \Slim\Slim::getInstance();
     try {
         $pdo = new ForumPostServicePDO();
         $pdo->purgeForumPost($forumId);
         $app->response()->status(204);
         // NO DOCUMENT STATUS CODE FOR SUCCESS
     } catch (Exception $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error purging post for forum {$forumId}", $e->getMessage());
     }
 }
Example #22
0
 public function popTopicEvents($userId, $topic)
 {
     try {
         $events = AppUtils::dbToArray($this->db->event_queue()->where("userId=? AND topic=?", $userId, $topic));
         $pdo = getPDO();
         $sql = "DELETE FROM event_queue WHERE `userId` = :userId AND `topic` = :topic";
         $stmt = $pdo->prepare($sql);
         $stmt->bindParam(':userId', $userId, PDO::PARAM_STR);
         $stmt->bindParam(':topic', $topic, PDO::PARAM_STR);
         $stmt->execute();
         return $events;
     } catch (PDOException $e) {
         throw $e;
     }
 }
 /**
  * Returns all post entries for the specified forum
  *
  * @throws PDOException
  * @return array Array of Post Template objects
  */
 public function getPostTemplates()
 {
     try {
         return AppUtils::dbToArray($this->db->post_template()->where("category=?", 'General')->order('name asc'));
     } catch (PDOException $e) {
         throw $e;
     }
 }
Example #24
0
 /**
  * Returns all user settings for the specified user and domain
  *
  * @param string $userId
  *           User ID
  * @param string $domain
  *           Specific domain of settings i.e. workspace or the settings for a
  *           specific module
  * @throws PDOException
  * @return array array of UserSetting objects
  */
 public function getUserSettingsForDomain($userId, $domain)
 {
     try {
         return AppUtils::dbToArray($this->db->user_settings()->where("userId=? AND domain=?", $userId, $domain));
     } catch (PDOException $e) {
         throw $e;
     }
 }
Example #25
0
 /**
  *
  * @see ForumServicePDO::deleteFileNode()
  */
 public static function deleteFileNode($forumId, $id)
 {
     $app = \Slim\Slim::getInstance();
     try {
         $pdo = new ForumServicePDO();
         $pdo->deleteFileNode($id);
         $eventParams = array();
         $eventParams['id'] = $id;
         $eventParams['changeType'] = ForumEvent::DELETE;
         AppUtils::sendEvent(ForumEvent::DOMAIN, $forumId, ForumEvent::NODE_CHANGE, "Node deleted id: " . $id, $eventParams);
         $app->response()->setStatus(204);
         // NO DOCUMENT STATUS CODE FOR
         // SUCCESS
     } catch (Exception $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error deleting file node with ID {$id}", $e->getMessage());
     }
 }