Exemple #1
0
/**
* Activate account from notification mail @ingroup pages
*/
function activateAccount()
{
    global $auth;
    global $PH;
    $auth->removeUserCookie();
    if ($tuid = get('tuid')) {
        $tuid = asKey($tuid);
        # clean string
        if ($user = $auth->setCurUserByIdentifier($tuid)) {
            $auth->storeUserCookie();
            $PH->messages[] = sprintf(__("Welcome %s. Please adjust your profile and insert a good password to activate your account."), asHtml($user->name));
            global $g_person_fields;
            $PH->show('personEdit', array('person' => $user->id));
            exit;
        }
    }
    $PH->messages[] = __("Sorry, but this activation code is no longer valid. If you already have an account, you could enter your name and use the <b>forgot password link</b> below.");
    $PH->show('loginForm');
}
 public function __construct($str)
 {
     measure_start("blockLink::__construct");
     global $PH;
     global $g_wiki_project;
     $this->str = '';
     # prevent from further processing
     ### id|options|title ###
     if (preg_match("/\\A([^\\|]+)\\|([^|]+)\\|([^|]*)\$/", $str, $matches)) {
         $this->target = asCleanString($matches[1]);
         $this->options = explode(",", preg_replace("/[^a-z,=0-9]/", "", strtolower($matches[2])));
         $this->name = $matches[3];
     } else {
         if (preg_match("/\\A([^\\|]+)\\|([^|]+)\$/", $str, $matches)) {
             //$this->target="#" . asCleanString($matches[1]);
             $this->target = $matches[1];
             $this->name = $matches[2];
         } else {
             $this->name = '';
             $this->target = $str;
         }
     }
     /**
      * urls
      */
     if (preg_match("/\\A([\\w]+)\\:\\/\\/(\\S+)/", $this->target, $matches)) {
         $type = asKey($matches[1]);
         $target = $matches[2];
         ### avoid breaking of url by double encoding of "&"-symbol...
         $target_url = str_replace("&amp;", "&", asHtml($target));
         if ($this->name) {
             $this->html = "<a rel='nofollow' class=extern title='" . asHtml($this->target) . "' href='" . $type . "://" . $target_url . "'>" . asHtml($this->name) . "</a>";
         } else {
             $this->html = "<a  class=extern  title='" . asHtml($this->target) . "' href='" . $type . "://" . $target_url . "'>" . asHtml($this->target) . "</a>";
         }
     } else {
         if (preg_match("/\\A\\#(\\d+)/", $this->target, $matches)) {
             $id = intVal($matches[1]);
             $this->html = FormatBlockLink::renderLinkFromItemId($id, $this->name);
         } else {
             if (preg_match("/\\A([\\w]+)\\:(\\d+)/", $this->target, $matches)) {
                 $type = asKey($matches[1]);
                 $target = asCleanString($matches[2]);
                 switch ($type) {
                     /**
                      * embedding images...
                      */
                     case 'image':
                         measure_start("blockLink::__construct::image");
                         require_once confGet('DIR_STREBER') . './db/class_file.inc.php';
                         if (($item = DbProjectItem::getVisibleById(intVal($target))) && $item->type == ITEM_FILE && ($file = File::getVisibleById(intval($target)))) {
                             $file = $file->getLatest();
                             ### if there are not options ##
                             if (!$this->options && $this->name) {
                                 $this->options = explode(",", preg_replace("/[^a-z,=0-9]/", "", strtolower($this->name)));
                                 $this->name = asHtml($file->name);
                             }
                             $align = '';
                             $max_size = 680;
                             $framed = false;
                             if ($this->options) {
                                 foreach ($this->options as $o) {
                                     if ($o == 'left') {
                                         $align = 'left';
                                     } else {
                                         if ($o == 'right') {
                                             $align = 'right';
                                         } else {
                                             if (preg_match('/maxsize=(\\d*)/', $o, $matches)) {
                                                 $max_size = $matches[1];
                                             } else {
                                                 if ($o == 'framed') {
                                                     $framed = true;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                             if (!($dimensions = $file->getImageDimensions($max_size))) {
                                 $this->html = '<em>' . sprintf(__("Item #%s is not an image"), $file->id) . "</em>";
                                 return;
                             }
                             if ($framed) {
                                 $this->html = "<div class='frame {$align}'>" . "<a href='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id)) . "'>" . "<img class=uploaded title='" . asHtml($file->name) . "'" . " alt='" . asHtml($file->name) . "'" . " src='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id, 'max_size' => $max_size)) . "'" . " height=" . intval($dimensions['new_height']) . " width=" . intval($dimensions['new_width']) . "></a>" . '<span>' . asHtml($this->name) . " (" . "<a href='" . $PH->getUrl('fileView', array('file' => $file->id)) . "'>" . __('Image details') . ")</a>" . '</span>' . "</div>";
                                 if (!$align) {
                                     $this->html .= '<span class=clear>&nbsp;</span>';
                                 }
                             } else {
                                 $this->html = "<a href='" . $PH->getUrl('fileDownloadAsImage', array('file' => $file->id)) . "'>" . "<img class='{$align} uploaded'" . " title='" . asHtml($file->name) . "'" . " alt='" . asHtml($file->name) . "'" . " src='" . $file->getCachedUrl($max_size) . "'" . " height=" . intval($dimensions['new_height']) . " width=" . intval($dimensions['new_width']) . "></a>";
                             }
                         } else {
                             $this->name = __("Unknown File-Id:") . ' ' . $target;
                         }
                         measure_stop("blockLink::__construct::image");
                         break;
                         /**
                          * item
                          */
                     /**
                      * item
                      */
                     case 'item':
                         $this->html = FormatBlockLink::renderLinkFromItemId($target, $this->name);
                         break;
                     default:
                         /**
                          * note, since this message is normally printed after the header,
                          * nobody will read this hint...
                          */
                         new FeedbackHint(sprintf(__('Wiki-format: <b>%s</b> is not a valid link-type'), $type) . " " . sprintf(__("Read more about %s."), $PH->getWikiLink('WikiSyntax')));
                 }
             } else {
                 if (preg_match("/\\Aembed\\:(\\S+)/", $this->target, $matches)) {
                     $t = $matches[1];
                     /**
                      * http://youtu.be/eb0xhLq8oAQ
                      *
                      * <iframe width="560" height="315" src="http://www.youtube-nocookie.com/embed/eb0xhLq8oAQ" frameborder="0" allowfullscreen></iframe>
                      *
                      */
                     if (preg_match("/^http\\:\\/\\/youtu\\.be\\/([A-Za-z0-9_->]*)/", $t, $embed_matches)) {
                         $this->html = "<iframe width=640 height=384 src='http://www.youtube-nocookie.com/embed/{$embed_matches[1]}' frameborder=0 allowfullscreen></iframe>";
                     } else {
                         if (preg_match("/^http\\:\\/\\/vimeo.com\\/(\\d*)/", $t, $embed_matches)) {
                             $this->html = "<iframe src='http://player.vimeo.com/video/{$embed_matches[1]}?badge=0' width=640 height=384 frameborder=0 webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>";
                         }
                     }
                 } else {
                     $this->html = FormatBlockLink::renderLinkFromTargetName($this->target, $this->name);
                 }
             }
         }
     }
     measure_stop("blockLink::__construct");
 }
 /**
  * check if valid cookie is set for a user
  *
  * @return       false, if no valid cookie found (invalid, unknown user, etc.)
  *               $user-object on success
  */
 public function setCurUserByIdentifier($identifier_string)
 {
     log_message("setCurUserByIdentifier()", LOG_MESSAGE_DEBUG);
     require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
     if (!($user = Person::getByIdentifierString(asKey($identifier_string)))) {
         return false;
     }
     if (!$user->can_login) {
         return false;
     }
     ### success ###
     $this->cur_user = $user;
     $this->cur_user->last_login = getGMTString();
     $this->cur_user->ip_address = asCleanString(getServerVar('REMOTE_ADDR'));
     /**
      * create new cookie
      */
     if (confGet('CHECK_IP_ADDRESS')) {
         $this->cur_user->cookie_string = $this->cur_user->calcCookieString();
     }
     $this->cur_user->update(array('last_login', 'cookie_string', 'ip_address'), false);
     log_message("setCurUserByIdentifier()->success", LOG_MESSAGE_DEBUG);
     return $user;
 }