コード例 #1
0
ファイル: Redis.php プロジェクト: rjha/webgloo
 private function init()
 {
     $dsn = Config::getInstance()->get_value("redis.dsn");
     $dsn = "redis://" . $dsn;
     $timeout = Config::getInstance()->get_value("redis.timeout");
     $this->connx = new \redisent\Redis($dsn, $timeout);
 }
コード例 #2
0
ファイル: Comment.php プロジェクト: rjha/sc
 static function getPaged($start, $direction, $limit, $filters)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //sanitize input
     settype($start, "integer");
     settype($limit, "integer");
     $direction = $mysqli->real_escape_string($direction);
     $sql = " select a.*,l.name as user_name from sc_comment a,sc_login l ";
     $q = new MySQL\Query($mysqli);
     $q->setAlias("com\\indigloo\\sc\\model\\Comment", "a");
     //raw condition
     $q->addCondition("l.id = a.login_id");
     $q->filter($filters);
     $sql .= $q->get();
     $sql .= $q->getPagination($start, $direction, "a.id", $limit);
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug("sql => {$sql} \n");
     }
     $rows = MySQL\Helper::fetchRows($mysqli, $sql);
     //reverse rows for 'before' direction
     if ($direction == 'before') {
         $results = array_reverse($rows);
         return $results;
     }
     return $rows;
 }
コード例 #3
0
ファイル: Category.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     $seoKey = Util::getArrayKey($params, "category_id");
     $collectionDao = new \com\indigloo\sc\dao\Collection();
     $zmember = $collectionDao->uizmemberOnSeoKey(Nest::ui_category(), $seoKey);
     if (is_null($zmember) || !isset($zmember["ui_code"])) {
         $controller = new \com\indigloo\sc\controller\Http404();
         $controller->process();
         exit;
     }
     $code = $zmember["ui_code"];
     $catName = $zmember["name"];
     $postDao = new \com\indigloo\sc\dao\Post();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPagedOnCategory($paginator, $code);
     $pageHeader = $catName;
     $pageBaseUrl = "/category/{$seoKey}";
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $catName);
     $metaKeywords = SeoData::getMetaKeywords($catName);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $catName);
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
コード例 #4
0
ファイル: Popular.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $redis = new redis\Activity();
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $zsetKey = Nest::score("post", "likes");
     $members = $redis->getPagedZSet($zsetKey, $paginator);
     //first one is id, second one is score
     $count = 0;
     $scores = array();
     $ids = array();
     for ($i = 1; $i < sizeof($members); $i++) {
         if ($i % 2 == 0) {
             array_push($scores, $members[$i - 1]);
         } else {
             $itemId = $members[$i - 1];
             $postId = PseudoId::decode($itemId);
             array_push($ids, $postId);
         }
     }
     //get post rows using ids
     $postDao = new \com\indigloo\sc\dao\Post();
     $postDBRows = $postDao->getOnSearchIds($ids);
     $pageHeader = 'Most popular';
     $pageBaseUrl = '/pub/popular';
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, "popular items");
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, "popular items");
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
コード例 #5
0
ファイル: Asset.php プロジェクト: rjha/sc
 static function version($path)
 {
     $link = '';
     $fname = $path;
     // let the error bubble up
     // it is better to die than serve wrong file!
     $scheme = Config::getInstance()->get_value("asset.version.scheme", "timestamp");
     if (\strcasecmp($scheme, "timestamp") == 0) {
         $fname = self::getTimeStampName($path);
     }
     if (\strcasecmp($scheme, "cdn") == 0) {
         $fname = self::getCdnName($path);
     }
     $parts = \pathinfo($path);
     if (\strcasecmp($parts["extension"], "css") == 0) {
         $tmpl = '<link rel="stylesheet" type="text/css" href="{fname}" >';
         $link = \str_replace("{fname}", $fname, $tmpl);
     }
     if (\strcasecmp($parts["extension"], "js") == 0) {
         $tmpl = '<script type="text/javascript" src="{fname}"></script>';
         $link = \str_replace("{fname}", $fname, $tmpl);
     }
     //return css or js link
     return $link;
 }
コード例 #6
0
ファイル: Search.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     $token = Url::tryQueryParam("gt");
     if (empty($token)) {
         header("Location: / ");
     }
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPosts($token, $paginator);
     $template = NULL;
     $searchTitle = NULL;
     if (sizeof($ids) > 0) {
         $pageHeader = "{$token}";
         $pageBaseUrl = "/search/site";
         $template = APP_WEB_DIR . '/view/search.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $groupIds = $sphinx->getGroups($token, 0, 25);
     $groupDao = new \com\indigloo\sc\dao\Group();
     $groupDBRows = $groupDao->getOnSearchIds($groupIds);
     $sphinx->close();
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $token);
     $metaKeywords = SeoData::getMetaKeywords($token);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $token);
     include $template;
 }
コード例 #7
0
ファイル: RedisSession.php プロジェクト: rjha/webgloo
 function destroy($sessionId)
 {
     if (Config::getInstance()->is_debug()) {
         $message = sprintf("session_destroy : %s ", $sessionId);
         Logger::getInstance()->debug($message);
     }
     $key = $this->makeKey($sessionId);
     $this->redis->del($key);
 }
コード例 #8
0
ファイル: site-worker.php プロジェクト: rjha/sc
function remove_mysql_sessions()
{
    //clean sessions inactive for half an hour
    $mysql_session = new \com\indigloo\core\MySQLSession();
    $mysql_session->open(null, null);
    //7 days * 24 HR /Day * 3600 seconds/Hour
    $lifetime = Config::getInstance()->get_value("session.lifetime", 3600);
    $mysql_session->gc($lifetime);
    $mysql_session->close();
}
コード例 #9
0
ファイル: Mail.php プロジェクト: rjha/sc
 static function newAccountMail($name, $email)
 {
     $templates = \com\indigloo\sc\html\Mail::getNewAccount($name);
     $text = $templates["text"];
     $html = $templates["html"];
     $subject = Config::getInstance()->get_value("new.account.subject");
     $from = Config::getInstance()->get_value("default.mail.address");
     $fromName = Config::getInstance()->get_value("default.mail.name");
     $tos = array($email);
     $code = \com\indigloo\mail\SendGrid::sendViaWeb($tos, $from, $fromName, $subject, $text, $html);
     return $code;
 }
コード例 #10
0
ファイル: PDOWrapper.php プロジェクト: rjha/webgloo
 static function getHandle()
 {
     $host = Config::getInstance()->get_value("mysql.host");
     $dbname = Config::getInstance()->get_value("mysql.database");
     $dsn = sprintf("mysql:host=%s;dbname=%s", $host, $dbname);
     $user = Config::getInstance()->get_value("mysql.user");
     $password = Config::getInstance()->get_value("mysql.password");
     $dbh = new \PDO($dsn, $user, $password);
     //throw exceptions
     $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     $dbh->setAttribute(\PDO::ATTR_AUTOCOMMIT, FALSE);
     return $dbh;
 }
コード例 #11
0
ファイル: Logger.php プロジェクト: rjha/webgloo
 private function __construct()
 {
     $logfile = Config::getInstance()->log_location();
     if (!file_exists($logfile)) {
         //create the file
         $this->fhandle = fopen($logfile, "x+");
     } else {
         $this->fhandle = fopen($logfile, "a+");
     }
     $this->sysLevel = Config::getInstance()->log_level();
     $this->priority = $this->level_to_priority($this->sysLevel);
     $this->isDebug = Config::getInstance()->is_debug();
 }
コード例 #12
0
ファイル: Helper.php プロジェクト: rjha/webgloo
 static function executeSQL($mysqli, $sql)
 {
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug("execute SQL >> " . $sql);
     }
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->execute();
         $stmt->close();
     } else {
         throw new DBException($mysqli->error, $mysqli->errno);
     }
 }
コード例 #13
0
ファイル: Mail.php プロジェクト: rjha/sc
 static function getResetPassword($name, $email, $token)
 {
     $view = new \stdClass();
     $view->name = $name;
     $url = Config::getInstance()->get_value("reset.password.url");
     $view->url = sprintf($url, urlencode($email), $token);
     $template = '/fragments/mail/text/reset-password.tmpl';
     $text = Template::render($template, $view);
     $template = '/fragments/mail/html/reset-password.tmpl';
     $html = Template::render($template, $view);
     $data = array('text' => $text, 'html' => $html);
     return $data;
 }
コード例 #14
0
ファイル: Connection.php プロジェクト: rjha/webgloo
 private function initDataBase()
 {
     $this->mysqli = new \mysqli(Config::getInstance()->get_value("mysql.host"), Config::getInstance()->get_value("mysql.user"), Config::getInstance()->get_value("mysql.password"), Config::getInstance()->get_value("mysql.database"));
     if (mysqli_connect_errno()) {
         trigger_error(mysqli_connect_error(), E_USER_ERROR);
         exit(1);
     }
     $this->connxId = spl_object_hash($this->mysqli);
     if (Config::getInstance()->is_debug()) {
         $message = '>> mysql created connection_id ::' . $this->connxId;
         Logger::getInstance()->debug($message);
     }
 }
コード例 #15
0
ファイル: PostProcessor.php プロジェクト: rjha/sc
 function process($feedObj, $templates = array())
 {
     $html = '';
     $keys = array("subject", "subjectId", "title", "objectId");
     $flag = $this->checkKeys($feedObj, $keys);
     $view = array();
     if (empty($templates)) {
         $templates = array(AppConstants::LIKE_VERB => "/fragments/feed/image/post.tmpl", AppConstants::COMMENT_VERB => "/fragments/feed/image/comment.tmpl", AppConstants::POST_VERB => "/fragments/feed/image/post.tmpl", AppConstants::FOLLOW_VERB => NULL);
     }
     if ($flag) {
         // extra processing for comments
         // @imp: activity row for comment stores
         // post_id as object_id and not item_id
         if (strcmp($feedObj->verb, AppConstants::COMMENT_VERB) == 0) {
             if (property_exists($feedObj, 'content')) {
                 $view['content'] = $feedObj->content;
             }
             $feedObj->objectId = PseudoId::encode($feedObj->objectId);
         }
         $view['subject'] = $feedObj->subject;
         $view['object'] = $feedObj->title;
         $pubId = PseudoId::encode($feedObj->subjectId);
         $view['subjectUrl'] = sprintf("%s/pub/user/%s", Url::base(), $pubId);
         $view['objectUrl'] = sprintf("%s/item/%s", Url::base(), $feedObj->objectId);
         $view['hasImage'] = false;
         //image for feed
         if (property_exists($feedObj, 'srcImage')) {
             if (!empty($feedObj->srcImage)) {
                 $srcImage = $feedObj->srcImage;
                 $m_bucket = \parse_url($srcImage, \PHP_URL_HOST);
                 // aws s3 bucket mapping for cloud front
                 // host is a CNAME mapped to amazon s3 bucket
                 // format is store.bucket.mapto=<mapped-bucket>
                 $mapKey = sprintf("s3.%s.mapto", $m_bucket);
                 $bucket = Config::getInstance()->get_value($mapKey, $m_bucket);
                 $view['srcImage'] = str_replace($m_bucket, $bucket, $srcImage);
                 $view['nameImage'] = $feedObj->nameImage;
                 $view['hasImage'] = true;
             }
         }
         $view['verb'] = $this->getVerb($feedObj->verb);
         if (isset($templates[$feedObj->verb])) {
             $template = $templates[$feedObj->verb];
         } else {
             trigger_error("invalid feed template", E_USER_ERROR);
         }
         $html = Template::render($template, $view);
     }
     return $html;
 }
コード例 #16
0
ファイル: SphinxQL.php プロジェクト: rjha/sc
 function __construct()
 {
     //create connection
     $user = Config::getInstance()->get_value("mysql.user");
     $password = Config::getInstance()->get_value("mysql.password");
     $host = Config::getInstance()->get_value("mysql.host");
     $port = Config::getInstance()->get_value("mysql.sphinx.port");
     $connx = new \mysqli($host, $user, $password, "", $port);
     if ($connx->connect_errno) {
         trigger_error($connx->connect_error, E_USER_ERROR);
         exit;
     }
     $this->connx = $connx;
 }
コード例 #17
0
ファイル: Url.php プロジェクト: rjha/webgloo
 static function base()
 {
     $host = NULL;
     $sapi_type = php_sapi_name();
     //running from cli sapi?
     if (substr($sapi_type, 0, 3) == "cli" && !isset($_SERVER["HTTP_HOST"])) {
         //read from config file
         $host = Config::getInstance()->get_value("www.host.name");
         if (empty($host)) {
             trigger_error("www.host.name key not found in config.", E_USER_ERROR);
         }
     } else {
         $host = $_SERVER["HTTP_HOST"];
     }
     return 'http://' . $host;
 }
コード例 #18
0
ファイル: Lists.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $plistId = Util::getArrayKey($params, "list_id");
     $listId = PseudoId::decode($plistId);
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     //@todo input check
     // people can type all sort of input garbage
     settype($listId, "int");
     $listDao = new \com\indigloo\sc\dao\Lists();
     $listDBRow = $listDao->getOnId($listId);
     if (empty($listDBRow)) {
         //not found
         $controller = new \com\indigloo\sc\controller\Http404();
         $controller->process();
         exit;
     }
     $listName = $listDBRow["name"];
     $listPubUrl = sprintf("%s/pub/list/%d/%s", Url::base(), $plistId, $listDBRow["seo_name"]);
     //get items from sc_list_item table
     $model = new \com\indigloo\sc\model\ListItem();
     $filter = new Filter($model);
     $filter->add($model::LIST_ID, Filter::EQ, $listId);
     $pageSize = Config::getInstance()->get_value("user.page.items");
     $filters = array();
     array_push($filters, $filter);
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $itemDBRows = $listDao->getPagedItems($paginator, $filters);
     $loginId = $listDBRow["login_id"];
     $userDao = new \com\indigloo\sc\dao\User();
     $userDBRow = $userDao->getOnLoginId($loginId);
     $template = APP_WEB_DIR . '/view/list/pub.php';
     //page variables
     $pageBaseUrl = $listPubUrl;
     $pageTitle = sprintf("page %d of %s", $gpage, $listDBRow["name"]);
     $description = Util::abbreviate($listDBRow["description"], 160);
     $metaDescription = SeoData::thisOrHomeDescription($description);
     $metaKeywords = SeoData::getHomeMetaKeywords();
     include $template;
 }
コード例 #19
0
ファイル: ItemsMap.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPaged($paginator);
     $pageHeader = '';
     $pageBaseUrl = $options["path"];
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, "recent items");
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, "recent items");
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
コード例 #20
0
ファイル: S3Store.php プロジェクト: rjha/webgloo
 function persist($prefix, $name, $sBlobData, $headers = array())
 {
     //create a unique name for s3 store
     $storeName = \com\indigloo\media\FileStore::getHashedName($name);
     $storeName = $prefix . $storeName;
     $bucket = Config::getInstance()->get_value("aws.bucket");
     $awsKey = Config::getInstance()->get_value("aws.key");
     $awsSecret = Config::getInstance()->get_value("aws.secret");
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug(" s3 bucket is => {$bucket}");
         Logger::getInstance()->debug(" original name => {$name}");
         Logger::getInstance()->debug(" file path is => {$storeName} ");
     }
     $s3 = new \S3($awsKey, $awsSecret, false);
     $metaHeaders = array();
     //$input, $bucket, $uri, $acl , $metaHeaders, $requestHeaders
     $s3->putObject($sBlobData, $bucket, $storeName, \S3::ACL_PUBLIC_READ, $metaHeaders, $headers);
     return $storeName;
 }
コード例 #21
0
ファイル: Editor.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     //post featured filter
     $filters = array();
     $model = new \com\indigloo\sc\model\Post();
     $filter = new Filter($model);
     $filter->add($model::FEATURED, Filter::EQ, TRUE);
     array_push($filters, $filter);
     $limit = Config::getInstance()->get_value("search.page.items");
     // fetch top N rows from sc_post that match our filter
     // this relies on the default sorting in mysql#Posts::getPosts() method
     $postDBRows = $postDao->getPosts($limit, $filters);
     $pageHeader = 'Editor\'s Pick';
     $pageTitle = "items on 3mik selected by our editors ";
     $metaDescription = SeoData::getHomeMetaDescription();
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $view = APP_WEB_DIR . '/view/tiles.php';
     include $view;
 }
コード例 #22
0
ファイル: FileStore.php プロジェクト: rjha/webgloo
 function persist($prefix, $name, $sBlobData, $headers = array())
 {
     $storeName = self::getHashedName($name);
     $storeName = $prefix . $storeName;
     $fp = NULL;
     //system.upload.path has a trailing slash
     $path = Config::getInstance()->get_value('system.upload.path') . $storeName;
     if (!file_exists(dirname($path))) {
         mkdir(dirname($path), 0755, true);
     }
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug(" file name = {$name}");
         Logger::getInstance()->debug(" storage path is => {$path} ");
     }
     //open file in write mode
     $fp = fopen($path, 'w');
     fwrite($fp, $sBlobData);
     fclose($fp);
     return $storeName;
 }
コード例 #23
0
ファイル: Location.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     // our router discards the query part from a URL so the
     // routing works with the query part as well (like /router/url?q1=x&q2=y
     $token = Util::getArrayKey($params, "location");
     if (is_null($token)) {
         header("Location: / ");
     }
     //search sphinx index
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPosts($token, $paginator);
     $sphinx->close();
     $template = NULL;
     $searchTitle = NULL;
     if (sizeof($ids) > 0) {
         $pageHeader = "{$token}";
         $pageBaseUrl = "/search/location/{$token}";
         $template = APP_WEB_DIR . '/view/tiles-page.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No Results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $token);
     $metaKeywords = SeoData::getMetaKeywords($token);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $token);
     include $template;
 }
コード例 #24
0
ファイル: Group.php プロジェクト: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $token = Util::getArrayKey($params, "name");
     // group controller is invoked via the fixed links
     // (as opposed to users typing in search box)
     // so we (exact) match this token against post_groups index.
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPostByGroup($token, $paginator);
     $sphinx->close();
     $template = NULL;
     $searchTitle = NULL;
     $groupName = \com\indigloo\util\StringUtil::convertKeyToName($token);
     if (sizeof($ids) > 0) {
         $pageHeader = "{$groupName}";
         $pageBaseUrl = "/group/{$token}";
         $template = APP_WEB_DIR . '/view/tiles-page.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $groupName);
     $metaKeywords = SeoData::getMetaKeywords($groupName);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $groupName);
     include $template;
 }
コード例 #25
0
ファイル: Web.php プロジェクト: rjha/webgloo
 function end()
 {
     //do not create a new instance
     $mysql = \com\indigloo\mysql\Connection::getInstance(false);
     if (!is_null($mysql)) {
         $mysql->closeHandle();
     }
     if (Config::getInstance()->is_debug()) {
         Logger::getInstance()->debug('web >> end >> hash is:: ' . spl_object_hash(self::$instance));
     }
 }
コード例 #26
0
ファイル: FormPipe.php プロジェクト: rjha/webgloo
 public function process($fieldName)
 {
     $maxSize = Config::getInstance()->max_file_size();
     if (empty($maxSize) || is_null($maxSize)) {
         trigger_error('file maxsize is not set in config file', E_USER_ERROR);
     }
     if (!isset($_FILES[$fieldName]) || empty($_FILES[$fieldName]['name'])) {
         // error when files are required on web form
         if ($this->isRequired) {
             $this->addError(self::ERROR_FIELD_MISSING);
         } else {
             $this->isEmpty = true;
         }
         return;
     }
     // form field is set
     $fdata = $_FILES[$fieldName];
     /* check for all possible error codes */
     switch ($fdata['error']) {
         case UPLOAD_ERR_INI_SIZE:
             // image size > php.ini setting
             $this->addError(self::ERROR_INI_SIZE);
             break;
         case UPLOAD_ERR_PARTIAL:
             // partial upload
             $this->addError(self::ERROR_PARTIAL);
             break;
         case UPLOAD_ERR_NO_FILE:
             // no file selected for upload
             if ($this->isRequired) {
                 $this->addError(self::ERROR_NO_FILE);
             }
             break;
         case UPLOAD_ERR_FORM_SIZE:
             // file too large vis-a-vis hidden form field
             // Users can fake this one
             $this->addError(self::ERROR_FILE_SIZE . $maxSize);
             break;
         case UPLOAD_ERR_OK:
             //check for file data size
             if ($fdata['size'] > $maxSize) {
                 // file size too large
                 $this->addError(self::ERROR_FILE_SIZE . $maxSize);
             }
             break;
         default:
             // unknown error
             $this->addError(self::ERROR_UNKNOWN);
     }
     if (sizeof($this->errors) > 0) {
         return;
     }
     $fname = basename($fdata['name']);
     $this->mediaData->originalName = strlen($fname) > 255 ? md5($fname) : $fname;
     $ftmp = $fdata['tmp_name'];
     $oTempFile = fopen($ftmp, "rb");
     $size = filesize($ftmp);
     $this->mediaData->size = $size;
     $this->fileData = fread($oTempFile, $size);
     //get mime using finfo.
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime = finfo_buffer($finfo, $this->fileData);
     $this->mediaData->mime = $mime === FALSE ? "application/octet-stream" : $mime;
     return;
 }
コード例 #27
0
ファイル: index.php プロジェクト: rjha/sc
if ($pos !== false) {
    //remove the part after ? from Url
    // routing does not depends on query parameters
    $requestURI = substr($originalURI, 0, $pos);
    $qpart = substr($originalURI, $pos + 1);
}
$route = $router->getRoute($requestURI);
if (is_null($route)) {
    //No valid route for this path
    $message = sprintf("No route for path %s", $requestURI);
    Logger::getInstance()->error($message);
    $controller = new \com\indigloo\sc\controller\Http404();
    $controller->process();
    exit;
} else {
    $controllerName = $route["action"];
    //add path and query
    $options = array();
    $options["path"] = $requestURI;
    $options["query"] = $qpart;
    $route["options"] = $options;
    if (Config::getInstance()->is_debug()) {
        $message = sprintf("controller %s :: path is %s  ", $controllerName, $requestURI);
        Logger::getInstance()->debug($message);
        Logger::getInstance()->dump($route);
    }
    $controller = new $controllerName();
    $controller->process($route["params"], $route["options"]);
}
$e_time = microtime(true);
printf(" \n <!-- Request %s took %f milliseconds --> \n", $originalURI, ($e_time - $s_time) * 1000);
コード例 #28
0
ファイル: Home.php プロジェクト: rjha/sc
 function loadNextPage($gpage)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $qparams = Url::getRequestQueryParams();
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPaged($paginator);
     $pageHeader = '';
     $pageBaseUrl = '/';
     $pageTitle = SeoData::getHomePageTitleWithNumber($gpage);
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getHomeMetaDescriptionWithNumber($gpage);
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
コード例 #29
0
ファイル: login.php プロジェクト: rjha/sc
$gSessionAction = Url::tryQueryParam("g_session_action");
if (!empty($gSessionAction)) {
    $gWeb->store("global.session.action", $gSessionAction);
}
$fUrl = Url::current();
$sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true));
$stoken = Util::getMD5GUID();
$gWeb->store("mik_state_token", $stoken);
//Facebook OAuth2
$fbAppId = Config::getInstance()->get_value("facebook.app.id");
$host = Url::base();
$fbCallback = $host . "/callback/fb2.php";
$fbDialogUrl = "https://www.facebook.com/dialog/oauth?client_id=" . $fbAppId;
$fbDialogUrl .= "&redirect_uri=" . urlencode($fbCallback) . "&scope=email&state=" . $stoken;
//Google OAuth2
$googleClientId = Config::getInstance()->get_value("google.client.id");
$googleCallback = $host . "/callback/google2.php";
$googleAuthUrl = "https://accounts.google.com/o/oauth2/auth?scope=";
//space delimited scope
$googleScope = "https://www.googleapis.com/auth/userinfo.email";
$googleScope = $googleScope . Constants::SPACE . "https://www.googleapis.com/auth/userinfo.profile";
$googleAuthUrl .= urlencode($googleScope);
$googleAuthUrl .= "&client_id=" . $googleClientId;
$googleAuthUrl .= "&state=" . $stoken;
$googleAuthUrl .= "&response_type=code";
$googleAuthUrl .= "&redirect_uri=" . urlencode($googleCallback);
?>

<!DOCTYPE html>
<html>
コード例 #30
0
ファイル: Post.php プロジェクト: rjha/sc
 static function convertImageJsonObj($jsonObj)
 {
     $view = array();
     if (strcmp($jsonObj->store, "s3") == 0 || strcmp($jsonObj->store, "local") == 0) {
         $view["name"] = $jsonObj->originalName;
         $prefix = $jsonObj->store == 's3' ? 'http://' : Url::base() . '/';
         $fileName = NULL;
         //@imp: if thumbnail is not available then fallback on original image
         if (property_exists($jsonObj, "thumbnailName")) {
             $view["tname"] = $jsonObj->thumbnailName;
             $fileName = $jsonObj->thumbnail;
         } else {
             $view["tname"] = $jsonObj->originalName;
             $fileName = $jsonObj->storeName;
         }
         // aws s3 bucket mapping for cloud front
         $m_bucket = $jsonObj->bucket;
         // format is store.bucket.mapto=<mapped-bucket>
         $mapKey = sprintf("%s.%s.mapto", $jsonObj->store, $m_bucket);
         $bucket = Config::getInstance()->get_value($mapKey, $m_bucket);
         $view["source"] = $prefix . $bucket . '/' . $jsonObj->storeName;
         $view["thumbnail"] = $prefix . $bucket . '/' . $fileName;
         $view["width"] = $jsonObj->width;
         $view["height"] = $jsonObj->height;
         //@todo add thumbnail width and height to image json data
     } else {
         $view["name"] = "placeholder";
         $view["tname"] = "placeholder";
         $view["source"] = UIConstants::PH1_PIC;
         $view["thumbnail"] = UIConstants::PH1_PIC;
         $view["width"] = 48;
         $view["height"] = 48;
         $view["twidth"] = 40;
         $view["theight"] = 40;
     }
     return $view;
 }