Exemplo n.º 1
0
Arquivo: Search.php Projeto: 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;
 }
Exemplo n.º 2
0
Arquivo: Popular.php Projeto: 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;
 }
Exemplo n.º 3
0
Arquivo: Bookmark.php Projeto: rjha/sc
 function execute($params)
 {
     $action = $params->action;
     $itemId = intval($params->itemId);
     $loginId = intval($params->loginId);
     $name = $params->name;
     if (empty($action) || empty($itemId) || empty($loginId) || empty($name)) {
         $message = "Bad input: missing required parameters.";
         $response = array("code" => 500, "message" => $message);
         return $response;
     }
     $bookmarkDao = new \com\indigloo\sc\dao\Bookmark();
     $postDao = new \com\indigloo\sc\dao\Post();
     $postId = PseudoId::decode($itemId);
     $postDBRow = $postDao->getOnId($postId);
     $title = $postDBRow["title"];
     $ownerId = $postDBRow["login_id"];
     $code = 200;
     switch ($action) {
         case UIConstants::LIKE_POST:
             $bookmarkDao->like($ownerId, $loginId, $name, $itemId, $title);
             $message = sprintf(" Success! Like for item %s done.", $title);
             break;
         default:
             break;
     }
     $response = array("code" => $code, "message" => $message);
     return $response;
 }
Exemplo n.º 4
0
Arquivo: Category.php Projeto: 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;
 }
Exemplo n.º 5
0
Arquivo: ItemsMap.php Projeto: 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;
 }
Exemplo n.º 6
0
Arquivo: Site.php Projeto: rjha/sc
 function process($postId)
 {
     //get links
     $postDao = new \com\indigloo\sc\dao\Post();
     $linkData = $postDao->getLinkDataOnId($postId);
     $links = $linkData["links"];
     if (is_null($links)) {
         return;
     }
     $version = $linkData["version"];
     //clean tmp post-site table
     mysql\Site::deleteTmpPSData($postId);
     foreach ($links as $link) {
         $page = $this->processUrl($link);
         if (empty($page) || empty($page["canonicalUrl"]) || empty($page["hash"]) || empty($page["host"])) {
             $message = "URL_PROC_ERROR :: [%s] of post [%d] is missing required data \n\n";
             $message = sprintf($message, $link, $postId);
             Logger::getInstance()->error($message);
             //write to bad.url log file
             $fhandle = NULL;
             $logfile = Config::getInstance()->get_value("bad.url.log");
             if (!file_exists($logfile)) {
                 //create the file
                 $fhandle = fopen($logfile, "x+");
             } else {
                 $fhandle = fopen($logfile, "a+");
             }
             fwrite($fhandle, $message);
             fclose($fhandle);
             // process next URL
             // there are pros and cons of continuing on bad url vs. bailing out
             // however URL processing is intensive job and it is better to examine
             // bad URL in leisure because we may not have a solution for processing
             // bad urls immediately
             continue;
         }
         $siteId = $this->getOrCreate($page["hash"], $page["host"], $page["canonicalUrl"]);
         if (!is_null($siteId)) {
             mysql\Site::addTmpPSData($postId, $siteId);
         } else {
             trigger_error("URL_PROC_ERROR :: Null site.id for {$link}", E_USER_ERROR);
         }
     }
     //Add new post+site data and update tracker
     mysql\Site::updateTracker($postId, $version);
 }
Exemplo n.º 7
0
Arquivo: Random.php Projeto: rjha/sc
 function process($params, $options)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $total = $postDao->getTotalCount();
     $rows1 = $postDao->getRandom(25);
     $ids = array();
     for ($i = 1; $i <= 25; $i++) {
         $ids[] = mt_rand(1, $total - 1);
     }
     $rows2 = $postDao->getOnSearchIds($ids);
     $postDBRows = array_merge($rows1, $rows2);
     $pageHeader = '<a href="/surprise/me">Try again?</a>';
     $pageTitle = SeoData::getHomePageTitle();
     $metaDescription = SeoData::getHomeMetaDescription();
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $file = APP_WEB_DIR . '/view/tiles.php';
     include $file;
 }
Exemplo n.º 8
0
Arquivo: Editor.php Projeto: 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;
 }
Exemplo n.º 9
0
Arquivo: Location.php Projeto: 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;
 }
Exemplo n.º 10
0
Arquivo: Group.php Projeto: 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;
 }
Exemplo n.º 11
0
Arquivo: thanks.php Projeto: rjha/sc
<?php

include 'sc-app.inc';
include APP_CLASS_LOADER;
//pull one random image
$postDao = new \com\indigloo\sc\dao\Post();
$rows = $postDao->getRandom(5);
$tileHtml = '';
if (sizeof($rows) > 0) {
    $tileHtml = \com\indigloo\sc\html\Post::getTile($rows[0]);
}
?>

<!DOCTYPE html>
<html>

       <head>
       <title> Thanks for visiting 3mik </title>
        <?php 
echo \com\indigloo\sc\util\Asset::version("/css/bundle.css");
?>

    </head>

    <body>
        <?php 
include APP_WEB_DIR . '/inc/toolbar.inc';
?>

        <div class="container mh800">
            <div class="row">  
Exemplo n.º 12
0
Arquivo: Home.php Projeto: 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;
 }
Exemplo n.º 13
0
function comment_to_activity($mysqli)
{
    $sql = "select max(id) as total from sc_comment";
    $row = MySQL\Helper::fetchRow($mysqli, $sql);
    $total = $row["total"];
    $pageSize = 50;
    $pages = ceil($total / $pageSize);
    $count = 0;
    $userDao = new \com\indigloo\sc\dao\User();
    $activityDao = new \com\indigloo\sc\dao\Activity();
    $postDao = new \com\indigloo\sc\dao\Post();
    while ($count <= $pages) {
        $start = $count * $pageSize + 1;
        $end = $start + ($pageSize - 1);
        $sql = " select *  from sc_comment where  (id <= {end}) and (id >= {start} ) ";
        $sql = str_replace(array("{end}", "{start}"), array(0 => $end, 1 => $start), $sql);
        $rows = MySQL\Helper::fetchRows($mysqli, $sql);
        foreach ($rows as $row) {
            $postId = $row['post_id'];
            $postDBRow = $postDao->getOnId($postId);
            $subjectId = $row['login_id'];
            $userDBRow = $userDao->getOnLoginId($subjectId);
            $subject = $userDBRow['name'];
            $ownerId = $postDBRow['login_id'];
            $object = $row['title'];
            $object = Util::filterBadUtf8($object);
            $content = $row['description'];
            $content = Util::filterBadUtf8($content);
            $verb = AppConstants::COMMENT_VERB;
            $objectId = $postId;
            $activityDao->addRow($ownerId, $subjectId, $objectId, $subject, $object, $verb, $content);
        }
        flush();
        sleep(1);
        $count++;
    }
}
Exemplo n.º 14
0
     $fhandler = new Form\Handler("edit-form", $_POST);
     $fhandler->addRule("link", "item URL", array('required' => 1));
     $fhandler->addRule("list_id", "list id", array('required' => 1));
     $fvalues = $fhandler->getValues();
     $link = $fvalues["link"];
     if ($fhandler->hasErrors()) {
         throw new UIException($fhandler->getErrors());
     }
     $loginId = Login::getLoginIdInSession();
     $listDao = new \com\indigloo\sc\dao\Lists();
     $itemId = AppUtil::getItemIdInUrl($link);
     if (is_null($itemId)) {
         $message = "invalid item URL : please add a valid item URL ";
         throw new UIException(array($message));
     }
     $postDao = new \com\indigloo\sc\dao\Post();
     if (!$postDao->exists($itemId)) {
         $message = sprintf("item {%s} does not exists", $itemId);
         throw new UIException(array($message));
     }
     $listDao->addItem($loginId, $fvalues["list_id"], $itemId);
     $message = sprintf("success! item added to list ");
     $gWeb->store(Constants::FORM_MESSAGES, array($message));
     header("Location: " . $fUrl);
 } catch (UIException $ex) {
     $gWeb->store(Constants::STICKY_MAP, $fvalues);
     $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
     header("Location: " . $fUrl);
     exit(1);
 } catch (DBException $ex) {
     Logger::getInstance()->error($ex->getMessage());
Exemplo n.º 15
0
Arquivo: posts.php Projeto: rjha/sc
            $filter->add($model::CREATED_ON, Filter::GT, "24 HOUR");
            array_push($filters, $filter);
            $ftname = "Last 24 hour";
            break;
        case "item":
            $filter = new Filter($model);
            $filter->add($model::ITEM_ID, Filter::EQ, $itemId);
            array_push($filters, $filter);
            $ftname = "Item:" . $itemId;
            break;
        default:
            break;
    }
}
$postDBRows = array();
$postDao = new \com\indigloo\sc\dao\Post();
$pageSize = Config::getInstance()->get_value("user.page.items");
$total = 0;
if (empty($ft) && !empty($gtoken)) {
    $sphinx = new \com\indigloo\sc\search\SphinxQL();
    $total = $sphinx->getPostsCount($gtoken);
    $paginator = new Pagination($qparams, $pageSize);
    $ids = $sphinx->getPagedPosts($gtoken, $paginator);
    $sphinx->close();
    if (sizeof($ids) > 0) {
        $postDBRows = $postDao->getOnSearchIds($ids);
    }
    $ftname = $gtoken;
} else {
    $total = $postDao->getTotalCount($filters);
    $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
Exemplo n.º 16
0
Arquivo: Lists.php Projeto: rjha/sc
 function addItem($loginId, $listId, $itemId)
 {
     // transpose of defaults list
     // 1 => favorites, 2 => wishlist etc.
     $transpose = array_flip($this->defaults);
     if (array_key_exists($listId, $transpose)) {
         //create new list with dl_bit set to 1
         $name = $transpose[$listId];
         $listId = $this->create($loginId, $name, $itemId, 1);
         return $listId;
     }
     // list ownership check is required
     // when we do not pass the loginId to backend
     // someone assuming a "fake" loginId is a problem
     // that data layer cannot solve!
     $this->isOwner($loginId, $listId);
     $postId = PseudoId::decode($itemId);
     $row = $this->getOnId($listId);
     $dbItemsJson = $row["items_json"];
     $dbItems = json_decode($dbItemsJson);
     $dbItemIds = array();
     foreach ($dbItems as $dbItem) {
         array_push($dbItemIds, $dbItem->id);
     }
     // update items_json summary only if
     // #1 - the number of items < 4
     // #2 - we have not seen this item earlier
     if (sizeof($dbItemIds) < 4 && !in_array($itemId, $dbItemIds)) {
         //get item row
         $postDao = new \com\indigloo\sc\dao\Post();
         $imgv = $postDao->tryImageOnId($postId);
         if (!is_null($imgv)) {
             $json = new \stdClass();
             $json->id = $itemId;
             $json->thumbnail = $imgv["thumbnail"];
             array_push($dbItems, $json);
         }
     }
     $itemsJson = json_encode($dbItems);
     $itemsJson = Util::formSafeJson($itemsJson);
     mysql\Lists::addItem($listId, $itemsJson, $postId);
     return $listId;
 }
Exemplo n.º 17
0
Arquivo: select.php Projeto: rjha/sc
use com\indigloo\sc\auth\Login;
$gSessionLogin = Login::getLoginInSession();
$loginId = $gSessionLogin->id;
$loginName = $gSessionLogin->name;
if (is_null($loginId)) {
    trigger_error("Error : NULL login_id on user dashboard", E_USER_ERROR);
}
$qparams = Url::getRequestQueryParams();
$itemId = Util::getArrayKey($qparams, "item_id");
$qUrl = base64_encode("/item/" . $itemId);
$fUrl = Url::current();
$listDao = new \com\indigloo\sc\dao\Lists();
$listRows = $listDao->getOnLoginId($loginId);
$listHtml = \com\indigloo\sc\html\Lists::getSelectPopup($listRows, $itemId, $qUrl);
//get widget html
$postDao = new \com\indigloo\sc\dao\Post();
$itemRow = $postDao->getOnItemId($itemId);
?>


<!DOCTYPE html>
<html>

    <head>
        <title> Save item - <?php 
echo $loginName;
?>
  </title>
        <?php 
include APP_WEB_DIR . '/inc/meta.inc';
?>
Exemplo n.º 18
0
Arquivo: User.php Projeto: rjha/sc
 private function processItems($params, $options)
 {
     $pubUserId = Util::getArrayKey($params, "login_id");
     $loginId = PseudoId::decode($pubUserId);
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $userDao = new \com\indigloo\sc\dao\User();
     $userDBRow = $userDao->getOnLoginId($loginId);
     $this->isValidUser($userDBRow);
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $postDao = new \com\indigloo\sc\dao\Post();
     //create filter
     $model = new \com\indigloo\sc\model\Post();
     $filters = array();
     $filter = new Filter($model);
     $filter->add($model::LOGIN_ID, Filter::EQ, $loginId);
     array_push($filters, $filter);
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPaged($paginator, $filters);
     $template = APP_WEB_DIR . '/view/user/items.php';
     //page variables
     $pageBaseUrl = "/pub/user/" . $pubUserId;
     $pageTitle = sprintf("page %d of items by %s", $gpage, $userDBRow["name"]);
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getHomeMetaDescription();
     include $template;
 }
Exemplo n.º 19
0
Arquivo: tag.php Projeto: rjha/sc
use com\indigloo\sc\util\Nest;
use com\indigloo\sc\Constants as AppConstants;
use com\indigloo\exception\DBException;
set_exception_handler("webgloo_ajax_exception_handler");
//Admin login is required
if (!Login::isAdmin()) {
    $message = array("code" => 401, "message" => "Authentication failure! Admin credentials missing.");
    $html = json_encode($message);
    echo $html;
    exit;
}
$postId = Util::getArrayKey($_POST, "postId");
// Action from UI is ADD | REMOVE
// see com\indigloo\sc\ui\Constants file
$action = Util::getArrayKey($_POST, "action");
$postDao = new \com\indigloo\sc\dao\Post();
$message = NULL;
try {
    switch ($action) {
        case UIConstants::FEATURE_POST:
            $postDao->feature($postId);
            $message = sprintf("success! item %s added to featured posts", $postId);
            break;
        case UIConstants::UNFEATURE_POST:
            $postDao->unfeature($postId);
            $message = sprintf("success! item %s removed from featured posts", $postId);
            break;
        default:
            trigger_error("Unknown UI action", E_USER_ERROR);
    }
} catch (DBException $ex) {
Exemplo n.º 20
0
Arquivo: delete.php Projeto: rjha/sc
include APP_WEB_DIR . '/inc/header.inc';
include APP_WEB_DIR . '/inc/role/user.inc';
use com\indigloo\Url;
use com\indigloo\Logger;
use com\indigloo\sc\auth\Login;
use com\indigloo\Constants;
use com\indigloo\ui\form\Sticky;
use com\indigloo\ui\form\Message as FormMessage;
use com\indigloo\sc\util\PseudoId;
$sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true));
//q is part of URL and base64 encoded
$qUrl = Url::tryBase64QueryParam("q", "/");
$fUrl = Url::current();
$itemId = Url::getQueryParam("id");
$postId = PseudoId::decode($itemId);
$postDao = new \com\indigloo\sc\dao\Post();
$postDBRow = $postDao->getOnId($postId);
if (!(Login::isOwner($postDBRow['login_id']) || Login::isAdmin())) {
    header("Location: /site/error/403.html");
    exit;
}
?>

<!DOCTYPE html>
<html>

       <head>
        <title>3mik.com - Delete a post</title>
        <?php 
include APP_WEB_DIR . '/inc/meta.inc';
?>
Exemplo n.º 21
0
Arquivo: new.php Projeto: rjha/sc
if (isset($_POST['save']) && $_POST['save'] == 'Save') {
    $gWeb = \com\indigloo\core\Web::getInstance();
    $fvalues = array();
    $fUrl = \com\indigloo\Url::tryFormUrl("fUrl");
    try {
        $fhandler = new Form\Handler('web-form-1', $_POST);
        $fhandler->addRule('links_json', 'links_json', array('rawData' => 1));
        $fhandler->addRule('images_json', 'images_json', array('rawData' => 1));
        $fhandler->addRule('group_names', 'Tags', array('maxlength' => 64, 'rawData' => 1));
        //check security token
        $fhandler->checkToken("token", $gWeb->find("form.token", true));
        $fvalues = $fhandler->getValues();
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $groupDao = new \com\indigloo\sc\dao\Group();
        $group_names = $fvalues['group_names'];
        $group_slug = $groupDao->nameToSlug($group_names);
        $postDao = new com\indigloo\sc\dao\Post();
        $title = Util::abbreviate($fvalues['description'], 128);
        $itemId = $postDao->create($title, $fvalues['description'], $gSessionLogin->id, $gSessionLogin->name, $_POST['links_json'], $_POST['images_json'], $group_slug, $fvalues['category']);
        //success - always go to item details
        $location = "/item/" . $itemId;
        header("Location: /qa/thanks.php?q=" . base64_encode($location));
    } catch (UIException $ex) {
        $gWeb->store(Constants::STICKY_MAP, $fvalues);
        $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
        header("Location: " . $fUrl);
        exit(1);
    }
}
Exemplo n.º 22
0
Arquivo: posts.php Projeto: rjha/sc
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\Configuration as Config;
use com\indigloo\ui\Filter;
use com\indigloo\sc\redis;
use com\indigloo\sc\util\Nest;
use com\indigloo\sc\util\PseudoId;
$qparams = Url::getRequestQueryParams();
$redis = new redis\Activity();
$tab = isset($qparams["tab"]) ? $qparams["tab"] : 1;
settype($tab, "integer");
$sortVariable = "likes";
$pageSize = 25;
$paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
$baseURI = "/monitor/analytic/posts.php";
$postDao = new \com\indigloo\sc\dao\Post();
switch ($tab) {
    case 1:
        $sortVariable = "likes";
        break;
    case 2:
        $sortVariable = "comments";
        break;
    default:
        $sortVariable = "likes";
}
$zsetKey = Nest::score("post", $sortVariable);
$members = $redis->getPagedZSet($zsetKey, $paginator);
$count = 0;
$scores = array();
$ids = array();
Exemplo n.º 23
0
Arquivo: edit.php Projeto: rjha/sc
use com\indigloo\exception\UIException;
if (isset($_POST['save']) && $_POST['save'] == 'Save') {
    $gWeb = \com\indigloo\core\Web::getInstance();
    $fvalues = array();
    $fUrl = \com\indigloo\Url::tryFormUrl("fUrl");
    try {
        $fhandler = new Form\Handler('web-form-1', $_POST);
        $fhandler->addRule('links_json', 'links_json', array('rawData' => 1));
        $fhandler->addRule('images_json', 'images_json', array('rawData' => 1));
        $fhandler->addRule('group_names', 'Tags', array('maxlength' => 64, 'rawData' => 1));
        $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1));
        $fvalues = $fhandler->getValues();
        $qUrl = base64_decode($fvalues['qUrl']);
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $groupDao = new \com\indigloo\sc\dao\Group();
        $group_names = $fvalues['group_names'];
        $group_slug = $groupDao->nameToSlug($group_names);
        $postDao = new com\indigloo\sc\dao\Post();
        $title = Util::abbreviate($fvalues['description'], 128);
        $postDao->update($fvalues['post_id'], $title, $fvalues['description'], $_POST['links_json'], $_POST['images_json'], $group_slug, $fvalues['category']);
        //success
        header("Location: " . $qUrl);
    } catch (UIException $ex) {
        $gWeb->store(Constants::STICKY_MAP, $fvalues);
        $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
        header("Location: " . $fUrl);
        exit(1);
    }
}
Exemplo n.º 24
0
Arquivo: Activity.php Projeto: rjha/sc
 function getCommentFeed($row)
 {
     // @imp: activity row for comment stores
     // post_id as object_id and not item_id
     $postId = $row["object_id"];
     $postDao = new \com\indigloo\sc\dao\Post();
     $image = $postDao->getImageOnId($postId);
     $feedVO = new \stdClass();
     $feedVO->ownerId = $row["owner_id"];
     $feedVO->subject = $row["subject"];
     $feedVO->subjectId = $row["subject_id"];
     $feedVO->object = "post";
     $feedVO->objectId = $row["object_id"];
     $feedVO->title = $row["object"];
     $feedVO->content = $row["content"];
     $feedVO->verb = $row["verb"];
     $feedVO->srcImage = $image["thumbnail"];
     $feedVO->nameImage = $image["name"];
     $feed = json_encode($feedVO);
     if ($feed === FALSE || $feed == 'null' || $feed == 'NULL') {
         //encoding went wrong
         $message = sprintf("problem with encoding activity row %d ", $row["id"]);
         trigger_error($message, E_USER_ERROR);
     }
     return $feed;
 }
Exemplo n.º 25
0
Arquivo: delete.php Projeto: rjha/sc
use com\indigloo\Constants;
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\exception\UIException;
use com\indigloo\sc\util\PseudoId;
if (isset($_POST['delete']) && $_POST['delete'] == 'Delete') {
    $gWeb = \com\indigloo\core\Web::getInstance();
    $fvalues = array();
    $fUrl = \com\indigloo\Url::tryFormUrl("fUrl");
    try {
        $fhandler = new Form\Handler('web-form-1', $_POST);
        $fhandler->addRule('post_id', 'post_id', array('required' => 1));
        $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1));
        $fvalues = $fhandler->getValues();
        // q is part of URL and base64 encoded
        // we need to decode it to use it for redirection
        $qUrl = base64_decode($fvalues['qUrl']);
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $postDao = new com\indigloo\sc\dao\Post();
        $postDao->delete($fvalues['post_id']);
        //success
        header("location: " . $qUrl);
    } catch (UIException $ex) {
        $gWeb->store(Constants::STICKY_MAP, $fvalues);
        $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
        header("Location: " . $fUrl);
        exit(1);
    }
}
Exemplo n.º 26
0
Arquivo: index.php Projeto: rjha/sc
$pubId = PseudoId::encode($loginId);
$homeUrl = Url::base();
$pubUrl = $homeUrl . "/pub/user/" . $pubId;
//data:1:user
$userDao = new \com\indigloo\sc\dao\User();
$userDBRow = $userDao->getOnLoginId($loginId);
$loginName = $gSessionLogin->name;
if (is_null($loginId)) {
    trigger_error("Error : NULL login_id on user dashboard", E_USER_ERROR);
}
$analyticDao = new \com\indigloo\sc\dao\Analytic();
$counters = $analyticDao->getUserCounters($loginId);
$activityDao = new \com\indigloo\sc\dao\Activity();
$feedDataObj = $activityDao->getUserFeeds($loginId, 20);
//suggestions are editor picks right now
$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);
// pick 12 posts from editor picks
$postDBRows = $postDao->getPosts(12, $filters);
$dashItemHelp = \com\indigloo\sc\html\Site::getDashItemHelp($counters["post_count"]);
$params = array("q" => base64_encode(Url::current()));
$linkInvitation = Url::createUrl("/user/invite.php", $params);
?>


<!DOCTYPE html>
Exemplo n.º 27
0
Arquivo: Post.php Projeto: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $itemId = Util::getArrayKey($params, "item_id");
     if ($itemId < 1200) {
         //@todo remove permanent redirect
         $redirectUrl = "/item/" . PseudoId::encode($itemId);
         header("HTTP/1.1 301 Moved Permanently");
         header("Location: " . $redirectUrl);
         exit;
     }
     $postDao = new \com\indigloo\sc\dao\Post();
     $postId = PseudoId::decode($itemId);
     $postDBRow = $postDao->getOnId($postId);
     if (empty($postDBRow)) {
         //not found
         $controller = new \com\indigloo\sc\controller\Http404();
         $controller->process();
         exit;
     }
     $options = array();
     $options["group"] = true;
     $postView = \com\indigloo\sc\html\Post::createPostView($postDBRow, $options);
     // links is separate from postView for historical reasons
     $linksJson = $postDBRow['links_json'];
     $dblinks = json_decode($linksJson);
     $links = array();
     foreach ($dblinks as $link) {
         $link = Url::addHttp($link);
         array_push($links, $link);
     }
     /* data for facebook/google+ dialogs */
     $itemObj = new \stdClass();
     $itemObj->appId = Config::getInstance()->get_value("facebook.app.id");
     $itemObj->host = Url::base();
     /* google+ cannot redirect to local box */
     $itemObj->netHost = "http://www.3mik.com";
     $itemObj->callback = $itemObj->host . "/callback/fb-share.php";
     if ($postView->hasImage) {
         /* use original image for og snippets, smaller images may be ignored */
         /* facebook and google+ dialogs need absolute URL */
         $itemObj->picture = $postView->srcImage;
     } else {
         $itemObj->picture = $itemObj->host . "/css/asset/sc/logo.png";
     }
     //do not urlencode - as we use this value as canonical url
     $itemObj->link = $itemObj->host . "/item/" . $itemId;
     $itemObj->netLink = $itemObj->netHost . "/item/" . $itemId;
     // title in DB is 128 chars long.
     // here on page we want to use a 70 char title.
     // also used in item images alt text
     // item description should be 160 chars.
     $itemObj->title = Util::abbreviate($postView->title, 70);
     $itemObj->title = sprintf("item %s - %s", $itemId, $itemObj->title);
     $itemObj->description = Util::abbreviate($postView->description, 160);
     $itemObj->description = sprintf("item %s - %s by user %s", $itemId, $itemObj->description, $postView->userName);
     $strItemObj = json_encode($itemObj);
     //make the item json string form safe
     $strItemObj = Util::formSafeJson($strItemObj);
     /* likes data */
     $bookmarkDao = new \com\indigloo\sc\dao\Bookmark();
     $likeDBRows = $bookmarkDao->getLikeOnItemId($itemId);
     $gWeb = \com\indigloo\core\Web::getInstance();
     /* sticky is used by comment form */
     $sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true));
     $gRegistrationPopup = false;
     $loginIdInSession = \com\indigloo\sc\auth\Login::tryLoginIdInSession();
     //show registration popup
     if (is_null($loginIdInSession)) {
         $register_popup = $gWeb->find("sc:browser:registration:popup");
         $register_popup = is_null($register_popup) ? false : $register_popup;
         if (!$register_popup) {
             $gRegistrationPopup = true;
             $gWeb->store("sc:browser:registration:popup", true);
         }
     }
     $group_slug = $postDBRow["group_slug"];
     $groupDao = new \com\indigloo\sc\dao\Group();
     $group_names = $groupDao->tokenizeSlug($group_slug, ",", true);
     $pageTitle = $itemObj->title;
     $metaKeywords = SeoData::getMetaKeywords($group_names);
     $pageUrl = Url::base() . Url::current();
     $file = APP_WEB_DIR . '/view/item.php';
     include $file;
 }
Exemplo n.º 28
0
Arquivo: Group.php Projeto: rjha/sc
 function process($postId)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $postDBRow = $postDao->getonId($postId);
     $group_slug = $postDBRow['group_slug'];
     $version = $postDBRow['version'];
     $catCode = $postDBRow['cat_code'];
     $loginId = $postDBRow['login_id'];
     mysql\Group::process($postId, $loginId, $version, $catCode, $group_slug);
 }
Exemplo n.º 29
0
Arquivo: posts.php Projeto: rjha/sc
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\Configuration as Config;
use com\indigloo\sc\auth\Login;
use com\indigloo\Constants;
use com\indigloo\ui\form\Message as FormMessage;
use com\indigloo\ui\form\Sticky;
use com\indigloo\ui\Filter;
$gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession();
$loginId = $gSessionLogin->id;
$loginName = $gSessionLogin->name;
if (is_null($loginId)) {
    trigger_error("Error : NULL login_id on user dashboard", E_USER_ERROR);
}
$sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true));
$postDao = new \com\indigloo\sc\dao\Post();
$qparams = Url::getRequestQueryParams();
//filters
$filters = array();
//Always add login_id filter for user dashboard
$model = new \com\indigloo\sc\model\Post();
$filter = new Filter($model);
$filter->add($model::LOGIN_ID, Filter::EQ, $loginId);
array_push($filters, $filter);
$postDBRows = array();
$pageSize = Config::getInstance()->get_value("user.page.items");
$paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
$postDBRows = $postDao->getPaged($paginator, $filters);
$baseURI = "/user/dashboard/posts.php";
?>