Example #1
0
File: Category.php Project: 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;
 }
Example #2
0
function detect_bad_utf8($mysqli, $flag = false)
{
    $sql = "select max(id) as total from sc_post ";
    $row = MySQL\Helper::fetchRow($mysqli, $sql);
    $total = $row["total"];
    $pageSize = 50;
    $pages = ceil($total / $pageSize);
    $count = 0;
    while ($count <= $pages) {
        $start = $count * $pageSize + 1;
        $end = $start + ($pageSize - 1);
        $sql = " select pseudo_id,title,description from sc_post where  (id <= {end}) and (id >= {start} ) ";
        $sql = str_replace(array("{end}", "{start}"), array(0 => $end, 1 => $start), $sql);
        $rows = MySQL\Helper::fetchRows($mysqli, $sql);
        printf("processing row between %d and %d \n", $start, $end);
        foreach ($rows as $row) {
            $description = $row['description'];
            if (!Util::isUtf8($description)) {
                printf("Bad utf-8 for item - %s \n", $row['pseudo_id']);
                if ($flag) {
                    $clean_description = Util::filterBadUtf8($description);
                    $clean_title = Util::filterBadUtf8($row['title']);
                    update_clean_utf8($mysqli, $row['pseudo_id'], $clean_title, $clean_description);
                }
            }
        }
        sleep(1);
        $count++;
    }
}
Example #3
0
File: Util.php Project: rjha/sc
 static function convertDBTime($original)
 {
     if (CoreUtil::tryEmpty($original)) {
         return "";
     }
     $format = "%e %b, %Y";
     $dt = strftime($format, strtotime($original));
     return $dt;
 }
Example #4
0
File: Login.php Project: rjha/sc
 function create($firstName, $lastName, $email, $password)
 {
     $provider = \com\indigloo\sc\auth\Login::MIK;
     if (Util::tryEmpty($firstName) || Util::tryEmpty($lastName)) {
         throw new UIException(array("User name is missing!"));
     }
     $userName = $firstName . ' ' . $lastName;
     $remoteIp = \com\indigloo\Url::getRemoteIp();
     mysql\Login::create($provider, $userName, $firstName, $lastName, $email, $password, $remoteIp);
 }
Example #5
0
File: Table.php Project: rjha/sc
 function filter($filter, $alias)
 {
     $columns = $this->getColumns();
     $column = Util::tryArrayKey($columns, $filter->name);
     if (is_null($column)) {
         $message = sprintf("No column %s in model", $filter->name);
         trigger_error($message, E_USER_ERROR);
     }
     //find condition for this column using model
     $sql = $this->getValue($alias, $column, $filter->condition, $filter->value);
     return $sql;
 }
Example #6
0
function detect_bad($itemId, $createdOn, $image)
{
    global $number;
    $id = $image->id;
    $storeName = $image->storeName;
    $thumbnail = $image->thumbnail;
    if (Util::contains($storeName, "?") || Util::contains($storeName, "&") || Util::contains($thumbnail, "?") || Util::contains($thumbnail, "&")) {
        $url = "http://media1.3mik.com/" . $storeName;
        $code = get_http_code($url);
        printf("%d :: suspected : item %s on %s \n\t image %s \n\t thumbnail %s \n\t code = %s \n\n", $number, $itemId, $createdOn, $storeName, $thumbnail, $code);
        sleep(2);
        $number++;
    }
}
Example #7
0
File: image.php Project: rjha/sc
function check_image_name($name)
{
    $allowed = array("jpg", "jpeg", "png", "gif");
    $extension = Util::getFileExtension($name);
    if (!empty($extension)) {
        $extension = strtolower($extension);
    }
    if (empty($extension) || !in_array($extension, $allowed)) {
        $message = sprintf("error uploading %s : only JPG, JPEG, GIF, or PNG allowed", $name);
        $data = array("code" => 500, "error" => $message);
        echo json_encode($data);
        exit;
    }
}
Example #8
0
 function filter($filters)
 {
     if (is_null($filters) || empty($filters)) {
         return;
     }
     foreach ($filters as $filter) {
         $model = $filter->model;
         $alias = Util::tryArrayKey($this->amap, get_class($model));
         $value = $filter->value;
         //sanitize input
         $value = $this->mysqli->real_escape_string($value);
         $filter->sanitize($value);
         $condition = $model->filter($filter, $alias);
         $this->addCondition($condition);
     }
 }
Example #9
0
File: Post.php Project: rjha/sc
 /**
  * @error if links json is empty or spaces in DB column
  * @error if links json evaluates to NULL by json_decode
  * @error if links json is valid but not an array
  * @return an array of strings (links)
  *
  */
 function getLinkDataOnId($postId)
 {
     $row = mysql\Post::getLinkDataOnId($postId);
     $json = $row['json'];
     $links = NULL;
     if (!Util::tryEmpty($json)) {
         $links = json_decode($json);
     }
     if (is_null($links) || !is_array($links)) {
         $message = sprintf("Post %d has Bad json [ %s ] ", $postId, $json);
         Logger::getInstance()->error($message);
         $links = NULL;
     }
     $data = array('links' => $links, 'version' => $row['version']);
     return $data;
 }
Example #10
0
File: Mail.php Project: rjha/sc
 /**
  * @return code - returned from sendgrid mail wrapper. 
  * A non zero code indicate failure, zero means success 
  *
  */
 static function sendActivityMail($name, $email, $feedText, $feedHtml)
 {
     $templates = \com\indigloo\sc\html\Mail::getActivity($name, $feedText, $feedHtml);
     //get new text and html now.
     $text = $templates["text"];
     $html = $templates["html"];
     // According to mail chimp research - mail  subject
     // should be 50 chars or less
     // However we need to send long post titles in subject.
     $subject = Util::abbreviate("3mik.com - " . $feedText, 100);
     $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;
 }
Example #11
0
File: Lists.php Project: 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;
 }
Example #12
0
 static function render($rows, $options)
 {
     $name = Util::getArrayKey($options, 'name');
     $default = Util::tryArrayKey($options, 'default');
     $showEmpty = Util::tryArrayKey($options, 'empty');
     if (!is_null($showEmpty) && $showEmpty) {
         array_unshift($rows, array('ui_code' => '', 'name' => '--'));
     }
     $buffer = '';
     $option = '<option value="{ui_code}" {flag}> {name}</option>';
     foreach ($rows as $row) {
         $flag = !is_null($default) && $row['ui_code'] == $default ? 'selected' : '';
         $str = str_replace(array("{ui_code}", "{name}", "{flag}"), array($row['ui_code'], $row['name'], $flag), $option);
         $buffer = $buffer . $str;
     }
     $buffer = '<select name="' . $name . '"> ' . $buffer . ' </select>';
     return $buffer;
 }
Example #13
0
File: Mail.php Project: rjha/sc
 function addResetPassword($name, $email)
 {
     //3mik user account exists with this email?
     $row = mysql\User::has3mikEmail($email);
     $count = $row["count"];
     if ($count <= 0) {
         $message = "Sorry! We could not find any 3mik account with this email.";
         throw new UIException(array($message));
     }
     //is a request already pending for this email?
     $row = mysql\Mail::isPending($email);
     $count = $row["count"];
     if ($count > 0) {
         $message = "Your request is already pending. Please try after 20 minutes.";
         throw new UIException(array($message));
     }
     $token = Util::getMD5GUID();
     mysql\Mail::add($name, $email, $token, AppConstants::RESET_PASSWORD_MAIL);
 }
Example #14
0
 function getDBParams()
 {
     $start = 1;
     $direction = "before";
     if (isset($this->qparams["gpa"]) && !Util::tryEmpty($this->qparams["gpa"])) {
         $direction = "after";
         $start = $this->qparams["gpa"];
     }
     if (isset($this->qparams["gpb"]) && !Util::tryEmpty($this->qparams["gpb"])) {
         $direction = "before";
         $start = $this->qparams["gpb"];
     }
     //this should not happen!
     if (Util::tryEmpty($start) || Util::tryEmpty($direction)) {
         trigger_error("paginator is missing [start | direction ] parameter", E_USER_ERROR);
     }
     $start = $this->convert ? base_convert($start, 36, 10) : $start;
     settype($start, "integer");
     return array("start" => $start, "direction" => $direction);
 }
Example #15
0
 static function render($options, $default)
 {
     $tab = Url::tryQueryParam("tab", $default);
     if (Util::tryEmpty($tab)) {
         $tab = $default;
     }
     if (!array_key_exists($tab, $options)) {
         $tab = $default;
     }
     $buffer = '';
     $item = '<li class="%s"> <a href="%s">%s</a></li>';
     foreach ($options as $key => $value) {
         $pageURI = Url::addQueryParameters($_SERVER['REQUEST_URI'], array("tab" => $key));
         $class = $tab == $key ? 'active' : '';
         $strItem = sprintf($item, $class, $pageURI, $value);
         $buffer .= $strItem;
     }
     $buffer = '<ul class="nav nav-tabs">' . $buffer . '</ul>';
     $data = array("buffer" => $buffer, "active" => $tab);
     return $data;
 }
Example #16
0
 function createAbsoluteUrl($url, $base)
 {
     //check input
     if (empty($url) || empty($base)) {
         return NULL;
     }
     // php parse_url will go berserk with space in front
     // just try parse_url on " http://www.3mik.com/item/1"
     $url = trim($url);
     $base = trim($base);
     $scheme = \parse_url($url, PHP_URL_SCHEME);
     if (!empty($scheme)) {
         return $url;
     }
     // Urls only containing query or anchor
     if (Util::startsWith($url, "#") || Util::startsWith($url, "?")) {
         return $base . $url;
     }
     // Parse base URL and convert to local variables: $scheme, $host, $path
     $pieces = \parse_url($base);
     $scheme = isset($pieces["scheme"]) ? $pieces["scheme"] : "";
     $host = isset($pieces["host"]) ? $pieces["host"] : "";
     // If no path, use /
     $path = isset($pieces["path"]) ? $pieces["path"] : "/";
     // Remove non-directory element from path
     $path = preg_replace('#/[^/]*$#', '', $path);
     // Destroy path if relative url points to root
     if (Util::startsWith($url, '/')) {
         $path = '';
     }
     // Dirty absolute URL
     $abs = "{$host}{$path}/{$url}";
     // Replace '//' or '/./' or '/foo/../' with '/'
     $re = array('#(/\\.?/)#', '#/(?!\\.\\.)[^/]+/\\.\\./#');
     for ($n = 1; $n > 0; $abs = preg_replace($re, '/', $abs, -1, $n)) {
     }
     // Absolute URL is ready!
     return $scheme . '://' . $abs;
 }
Example #17
0
File: Location.php Project: 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;
 }
Example #18
0
File: Site.php Project: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $siteId = Util::tryArrayKey($params, "site_id");
     $cname = Url::tryQueryParam("cname");
     if (empty($siteId) || empty($cname)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $siteDao = new \com\indigloo\sc\dao\Site();
     $postDBRows = $siteDao->getPostsOnId($siteId, 50);
     $pageHeader = $cname;
     $pageTitle = SeoData::getHomePageTitle();
     $metaDescription = SeoData::getHomeMetaDescription();
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $file = APP_WEB_DIR . '/view/tiles.php';
     include $file;
 }
Example #19
0
File: Group.php Project: 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;
 }
Example #20
0
File: create.php Project: rjha/sc
use com\indigloo\exception\DBException;
use com\indigloo\sc\mysql;
use com\indigloo\sc\auth\Login;
use com\indigloo\Url;
use com\indigloo\Util;
use com\indigloo\Logger;
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("edit-form", $_POST);
        $fhandler->addRule("name", "Name", array('required' => 1));
        $fvalues = $fhandler->getValues();
        $name = $fvalues["name"];
        if (!Util::isAlphaNumeric($name)) {
            $fhandler->addError("Bad name : only letters and numbers are allowed!");
        }
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $loginId = Login::getLoginIdInSession();
        $listDao = new \com\indigloo\sc\dao\Lists();
        $listDao->createNew($loginId, $name, $fvalues["description"]);
        $message = sprintf("success! new list created");
        $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);
Example #21
0
File: Post.php Project: rjha/sc
 static function getImageOrDefault($json)
 {
     $images = json_decode($json);
     $imgv = array();
     if (!empty($images) && sizeof($images) > 0) {
         //work with image #1
         $image = $images[0];
         $imgv = self::convertImageJsonObj($image);
         $td = Util::foldXY($image->width, $image->height, 40, 40);
         $imgv["twidth"] = $td["width"];
         $imgv["theight"] = $td["height"];
     } else {
         $imgv["name"] = "placeholder";
         $imgv["tname"] = "placeholder";
         $imgv["source"] = UIConstants::PH1_PIC;
         $imgv["thumbnail"] = UIConstants::PH1_PIC;
         $imgv["width"] = 48;
         $imgv["height"] = 48;
         $imgv["twidth"] = 40;
         $imgv["theight"] = 40;
     }
     return $imgv;
 }
Example #22
0
File: login.php Project: rjha/sc
use com\indigloo\ui\form\Message as FormMessage;
$gWeb = \com\indigloo\core\Web::getInstance();
//do we already have a login?
if (\com\indigloo\sc\auth\Login::hasSession()) {
    header("Location: / ");
}
$qUrl = Url::tryBase64QueryParam("q", "/user/dashboard/index.php");
$fUrl = Url::current();
// should login do some action?
$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);
Example #23
0
File: Login.php Project: rjha/sc
 static function isOwner($loginId)
 {
     //false on NULL or empty
     if (Util::tryEmpty($loginId)) {
         return false;
     }
     $flag = false;
     if (isset($_SESSION) && isset($_SESSION[self::TOKEN]) && isset($_SESSION[self::LOGIN_ID]) && $_SESSION[self::LOGIN_ID] == $loginId) {
         $flag = true;
     }
     return $flag;
 }
Example #24
0
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Util;
use com\indigloo\sc\auth\Login;
use com\indigloo\sc\ui\Constants as UIConstants;
set_exception_handler('webgloo_ajax_exception_handler');
//use login is required for bookmarking
if (!Login::hasSession()) {
    $message = array("code" => 401, "message" => "Authentication failure: You need to login!");
    $html = json_encode($message);
    echo $html;
    exit;
}
$params = new \stdClass();
$login = Login::getLoginInSession();
$params->loginId = $login->id;
$params->name = $login->name;
$params->action = Util::tryArrayKey($_POST, "action");
$params->followerId = Util::tryArrayKey($_POST, "followerId");
$params->followingId = Util::tryArrayKey($_POST, "followingId");
//use login is required for bookmarking
if ($params->followerId == $params->followingId) {
    $message = array("code" => 200, "message" => "No need to follow yourself!");
    $html = json_encode($message);
    echo $html;
    exit;
}
$command = new \com\indigloo\sc\command\SocialGraph();
$response = $command->execute($params);
$html = json_encode($response);
echo $html;
Example #25
0
File: featured.php Project: rjha/sc
use com\indigloo\Constants;
use com\indigloo\sc\util\Nest;
use com\indigloo\Util;
use com\indigloo\Url;
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);
        $fvalues = $fhandler->getValues();
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $group_slug = "";
        $slugs = Util::tryArrayKey($fvalues, "g");
        if (!is_null($slugs)) {
            //remove duplicate entries
            $slugs = array_unique($slugs);
            //input - new groups are names / old ones are slugs
            $slugs = array_map(array("\\com\\indigloo\\util\\StringUtil", "convertNameToKey"), $slugs);
            //db slugs are space separated for sphinx indexing
            $group_slug = implode(Constants::SPACE, $slugs);
        }
        $collectionDao = new \com\indigloo\sc\dao\Collection();
        $collectionDao->glset(Nest::fgroups(), $group_slug);
        //success
        $gWeb->store(Constants::FORM_MESSAGES, array("featured groups list updated!"));
        header("Location: " . $fUrl);
    } catch (UIException $ex) {
        $gWeb->store(Constants::STICKY_MAP, $fvalues);
Example #26
0
File: contact.php Project: rjha/sc
//sc/site/contact.php
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\sc\auth\Login;
use com\indigloo\ui\form\Sticky;
use com\indigloo\Constants;
use com\indigloo\ui\form\Message as FormMessage;
$gWeb = \com\indigloo\core\Web::getInstance();
$sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true));
$qUrl = Url::tryBase64QueryParam("q", "/");
$fUrl = Url::current();
//add security token to form
$formToken = Util::getBase36GUID();
$gWeb->store("form.token", $formToken);
?>

<!DOCTYPE html>
<html>

       <head>
        <title> 3mik.com - contact us </title>
        <?php 
include APP_WEB_DIR . '/inc/meta.inc';
?>
        <?php 
echo \com\indigloo\sc\util\Asset::version("/css/bundle.css");
?>
        
Example #27
0
File: users.php Project: rjha/sc
unset($fparams["ft"]);
unset($fparams["gt"]);
//ft urls start with page 1
$fparams["gpage"] = 1;
//create filter Urls
$ftBaseUrl = Url::createUrl("/monitor/users.php", $fparams);
//search clear link
$sparams = $qparams;
unset($sparams["gt"]);
$clearSearchUrl = Url::createUrl("/monitor/users.php", $sparams);
//filters
$filters = array();
$model = new \com\indigloo\sc\model\User();
$ft = Url::tryQueryParam("ft");
$ftname = "";
$gtoken = Util::tryArrayKey($qparams, "gt");
$userId = NULL;
if (empty($ft) && strlen($gtoken) > 5 && strcmp(substr($gtoken, 0, 5), "user:"******"user";
    $userId = substr($gtoken, 5);
    //reset search token
    $gtoken = NULL;
}
if (empty($ft) && !empty($gtoken)) {
    $ft = "name";
}
if (!is_null($ft)) {
    switch ($ft) {
        case "24HR":
            $filter = new Filter($model);
            $filter->add($model::CREATED_ON, Filter::GT, "24 HOUR");
Example #28
0
 $fvalues = array();
 $fUrl = \com\indigloo\Url::tryFormUrl("fUrl");
 try {
     $fhandler = new Form\Handler("web-form-1", $_POST);
     $fvalues = $fhandler->getValues();
     if ($fhandler->hasErrors()) {
         throw new UIException($fhandler->getErrors());
     }
     $gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession();
     $loginId = $gSessionLogin->id;
     // p array would be missing when no checkbox is ticked.
     // that also happens when user de-selects everything
     // for user selections - p array would contain only those
     // keys that user has selected. we have to map the rest of them
     // to false in preferences data.
     $parr = Util::tryArrayKey($fvalues, "p");
     $pdata = array();
     if (is_null($parr)) {
         //user has not selected any checckbox.
         $pdata = array("follow" => false, "comment" => false, "bookmark" => false);
     } else {
         // p array is not empty.
         // user has ticked some checkboxes.
         // set to false the keys that user has not selected.
         $pdata["follow"] = isset($parr["follow"]) ? true : false;
         $pdata["comment"] = isset($parr["comment"]) ? true : false;
         $pdata["bookmark"] = isset($parr["bookmark"]) ? true : false;
     }
     //save data for this loginId
     $pDataObj = json_encode($pdata);
     $preferenceDao = new \com\indigloo\sc\dao\Preference();
Example #29
0
use com\indigloo\Constants;
use com\indigloo\ui\form\Message as FormMessage;
use com\indigloo\sc\auth\Login;
use com\indigloo\exception\UIException;
$gSessionLogin = Login::getLoginInSession();
$loginId = $gSessionLogin->id;
if (strcmp($gSessionLogin->provider, Login::MIK) != 0) {
    $message = "change password only works for 3mik logins!";
    throw new UIException(array($message));
}
$userDao = new \com\indigloo\sc\dao\User();
$userDBRow = $userDao->getonLoginId($loginId);
//tokens for use in next screen
$ftoken = Util::getMD5GUID();
$email = $userDBRow["email"];
$femail = Util::encrypt($email);
$gWeb = \com\indigloo\core\Web::getInstance();
$gWeb->store("change.password.email", $femail);
$gWeb->store("change.password.token", $ftoken);
$title = $userDBRow["email"];
$qUrl = base64_encode(Url::current());
$fUrl = Url::current();
$submitUrl = "/user/account/form/change-password.php";
?>

<!DOCTYPE html>
<html>

       <head>
        <title> Change password - <?php 
echo $title;
Example #30
0
 $mysqli = MySQL\Connection::getInstance()->getHandle();
 $start = $count * 50 + 1;
 $end = $start + 49;
 printf("processing rows between %d and %d \n", $start, $end);
 $sql = " select id,images_json from sc_post 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) {
     //remove malformed utf-8 characters
     $fjson = iconv('UTF-8', 'UTF-8//IGNORE', $row['images_json']);
     $images = json_decode($fjson);
     //printf("code from json_decode is %d \n",json_last_error());
     $data = array();
     if (!empty($images)) {
         foreach ($images as $image) {
             $image->thumbnailName = Util::getThumbnailName($image->originalName);
             //printf("tname is %s \n",$image->thumbnailName);
             array_push($data, $image);
             //update sc_media.thumbnail_name
             updateMedia($mysqli, $image->id, $image->thumbnailName);
         }
         //new mediaVO
         $strMediaVO = json_encode($data);
         //push new mediaVO to sc_post
         updatePost($mysqli, $row['id'], $strMediaVO);
     } else {
         //no images case
         $strMediaVO = '[]';
         updatePost($mysqli, $row['id'], $strMediaVO);
     }
 }