Beispiel #1
0
 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;
 }
Beispiel #2
0
function process_groups($mysqli)
{
    //process groups
    $sql = " select post_id from sc_site_tracker where group_flag = 0 order by id desc limit 50";
    $rows = MySQL\Helper::fetchRows($mysqli, $sql);
    $groupDao = new \com\indigloo\sc\dao\Group();
    foreach ($rows as $row) {
        $postId = $row["post_id"];
        $groupDao->process($postId);
    }
}
Beispiel #3
0
 function spewFeatured($params, $options)
 {
     $collectionDao = new \com\indigloo\sc\dao\Collection();
     $groupDao = new \com\indigloo\sc\dao\Group();
     $row = $collectionDao->glget(Nest::fgroups());
     $feature_slug = empty($row) ? "" : $row["t_value"];
     $groups = $groupDao->slugToGroupsMap($feature_slug);
     $title = "Featured groups";
     $file = APP_WEB_DIR . "/view/group/cards.php";
     include $file;
 }
Beispiel #4
0
<?php

include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\sc\util\Nest;
//public data
//do not put user role check here
set_exception_handler('webgloo_ajax_exception_handler');
$groupDao = new \com\indigloo\sc\dao\Group();
$collectionDao = new \com\indigloo\sc\dao\Collection();
$row = $collectionDao->glget(Nest::fgroups());
$feature_slug = empty($row) ? "" : $row["t_value"];
$fgroups = $groupDao->slugToGroupsMap($feature_slug);
$html = \com\indigloo\sc\html\Group::getCloud($fgroups);
echo $html;
Beispiel #5
0
Datei: all.php Projekt: rjha/sc
<?php

include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
include APP_WEB_DIR . '/inc/role/user.inc';
use com\indigloo\Url;
use com\indigloo\ui\Pagination;
use com\indigloo\sc\auth\Login;
use com\indigloo\ui\Filter;
$qparams = Url::getRequestQueryParams();
$login = Login::getLoginInSession();
$loginId = $login->id;
$groupDao = new \com\indigloo\sc\dao\Group();
$filters = array();
$model = new \com\indigloo\sc\model\Group();
$filter = new Filter($model);
$filter->add($model::LOGIN_ID, Filter::EQ, $loginId);
array_push($filters, $filter);
$pageSize = 100;
$paginator = new Pagination($qparams, $pageSize);
$groups = $groupDao->getPagedUserGroups($paginator, $filters);
$startId = NULL;
$endId = NULL;
if (sizeof($groups) > 0) {
    $startId = $groups[0]['id'];
    $endId = $groups[sizeof($groups) - 1]['id'];
}
$pageBaseUrl = "/group/user/all.php";
$title = sprintf("%s's groups", $login->name);
$hasNavigation = false;
include APP_WEB_DIR . "/view/group/cards-page.php";
Beispiel #6
0
Datei: new.php Projekt: rjha/sc
<?php

include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
//public data
//do not put user role check here
set_exception_handler('webgloo_ajax_exception_handler');
$groupDao = new \com\indigloo\sc\dao\Group();
$limit = 43;
$navGroups = $groupDao->getLatest($limit);
$html = \com\indigloo\sc\html\Group::getCloud($navGroups);
echo $html;
Beispiel #7
0
Datei: edit.php Projekt: rjha/sc
$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(1);
}
$loginId = Login::getLoginIdInSession();
$strImagesJson = $sticky->get('images_json', $postDBRow['images_json']);
$strLinksJson = $sticky->get('links_json', $postDBRow['links_json']);
//@imp: we are enclosing the JSON string in single quotes
//so the single quotes in string from DB should be escaped
$strImagesJson = Util::formSafeJson($strImagesJson);
$strLinksJson = Util::formSafeJson($strLinksJson);
$groupDao = new \com\indigloo\sc\dao\Group();
$group_names = $groupDao->tokenizeSlug($postDBRow['group_slug'], ",", true);
?>

<!DOCTYPE html>
<html>

       <head>
        <title> 3mik.com - Share your find, need and knowledge</title>
        
        <?php 
include APP_WEB_DIR . '/inc/meta.inc';
?>
        <?php 
echo \com\indigloo\sc\util\Asset::version("/css/bundle.css");
?>
Beispiel #8
0
Datei: Post.php Projekt: 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;
 }
Beispiel #9
0
Datei: all.php Projekt: rjha/sc
<?php

include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Url;
use com\indigloo\ui\Pagination;
use com\indigloo\sc\auth\Login;
use com\indigloo\ui\Filter;
$qparams = Url::getRequestQueryParams();
$filters = array();
$groupDao = new \com\indigloo\sc\dao\Group();
$pageSize = 100;
$paginator = new Pagination($qparams, $pageSize);
$groups = $groupDao->getPaged($paginator, $filters);
$startId = NULL;
$endId = NULL;
if (sizeof($groups) > 0) {
    $startId = $groups[0]['id'];
    $endId = $groups[sizeof($groups) - 1]['id'];
}
$pageBaseUrl = "/group/all.php";
$title = "All groups";
$file = APP_WEB_DIR . "/view/group/cards-page.php";
include $file;
Beispiel #10
0
Datei: edit.php Projekt: 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);
    }
}