Beispiel #1
0
 static function render()
 {
     $gWeb = Web::getInstance();
     $messages = $gWeb->find(Constants::FORM_MESSAGES, true);
     $errors = $gWeb->find(Constants::FORM_ERRORS, true);
     if (sizeof($errors) > 0) {
         printf("<div class=\"alert\">");
         printf("<a class=\"close\" data-dismiss=\"alert\" href=\"#\">x</a>");
         printf("<ul>");
         foreach ($errors as $error) {
             printf("<li>  %s </li>", $error);
         }
         printf("</ul>");
         printf("</div>");
     }
     if (sizeof($messages) > 0) {
         printf("<div class=\"alert alert-success\">");
         printf("<a class=\"close\" data-dismiss=\"alert\" href=\"#\">x</a>");
         printf("<ul>");
         foreach ($messages as $message) {
             printf("<li>  %s </li>", $message);
         }
         printf("</ul>");
         printf("</div>");
     }
 }
Beispiel #2
0
Datei: Login.php Projekt: rjha/sc
 private static function completeSessionAction($loginId, $name, $provider)
 {
     $message = NULL;
     $action = NULL;
     try {
         $gWeb = \com\indigloo\core\Web::getInstance();
         $gSessionAction = $gWeb->find("global.session.action");
         if (empty($gSessionAction)) {
             return;
         }
         // base64_decode action
         $action = base64_decode($gSessionAction);
         if ($action === FALSE) {
             return;
         }
         //json_decode session action
         $actionObj = json_decode($action);
         $endPoint = $actionObj->endPoint;
         $params = $actionObj->params;
         $variables = get_object_vars($params);
         // associated array of name value pairs
         // undefines properties are returned as NULL
         //
         // @warning: the foreach value reference is maintained
         // after the loop. variable scope in PHP is at function level
         // so do not be too cute here and do not use $name => $value
         // inside loop as that conflicts with function argument "name"
         //
         // see if one of the parameters has "value" {loginId}
         // update this parameter value to actual loginId
         foreach ($variables as $prop => $value) {
             if ($params->{$prop} == "{loginId}") {
                 $params->{$prop} = $loginId;
             }
         }
         //inject loginId, name and provider into params
         $params->loginId = $loginId;
         $params->name = $name;
         $params->provider = $provider;
         //Facade for session action endpoint
         $facade = new \com\indigloo\sc\command\Facade();
         $response = $facade->execute($endPoint, $params);
         $message = $response["message"];
         if ($response["code"] == 200) {
             // success
             // set overlay message
             $gWeb->store("global.overlay.message", $message);
         } else {
             $message = sprintf("session action response code : %d", $response["code"]);
             throw new \Exception($message);
         }
     } catch (\Exception $ex) {
         $message = sprintf("session action %s failed \n ", $action);
         Logger::getInstance()->error($ex->getMessage());
     }
 }
Beispiel #3
0
 static function messageHtml()
 {
     $gWeb = Web::getInstance();
     $messages = $gWeb->find(Constants::PAGE_MESSAGES, true);
     if (is_array($messages) && sizeof($messages) > 0) {
         printf("<ul>");
         foreach ($messages as $message) {
             printf("<li>  %s </li>", $message);
         }
         printf("</ul>");
     }
 }
Beispiel #4
0
Datei: Site.php Projekt: rjha/sc
 static function formMessage()
 {
     $html = NULL;
     $template = '/fragments/ui/form-message.tmpl';
     $view = new \stdClass();
     $gWeb = \com\indigloo\core\Web::getInstance();
     $messages = $gWeb->find(Constants::FORM_MESSAGES, true);
     $errors = $gWeb->find(Constants::FORM_ERRORS, true);
     $view->messages = is_null($messages) ? array() : $messages;
     $view->errors = is_null($errors) ? array() : $errors;
     $html = Template::render($template, $view);
     return $html;
 }
Beispiel #5
0
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;
?>
Beispiel #6
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;
 }