/**
  * @param $text
  * @return string
  */
 public function encrypt($text)
 {
     $encrypted = $this->mcrypt($this->stringFormatter->prepareString($text));
     $result = rtrim(base64_encode($encrypted), '=') . $this->key->getRandomHexadecimalPosition() . $this->IV->getRandomHexadecimalPosition();
     $this->resetCurrentProcess();
     return $result;
 }
 /**
  * @param $encrypted_text
  * @return string
  */
 public function decrypt($encrypted_text)
 {
     $this->IV->setHexadecimalPosition(substr($encrypted_text, -2));
     $this->key->setHexadecimalPosition(substr($encrypted_text, -4, 2));
     $encrypted_text = base64_decode(substr($encrypted_text, 0, -4));
     $decrypted = $this->mdecrypt($encrypted_text);
     $this->resetCurrentProcess();
     return $this->stringFormatter->cleanString($decrypted);
 }
 function OnPreRender()
 {
     /* @var $o_top_level Category */
     $review_item = $this->o_topic->GetReviewItem();
     $s_suggested_title = urlencode(StringFormatter::PlainText(trim($review_item->GetTitle())));
     $s_page = urlencode($_SERVER['REQUEST_URI']);
     $s_subscribe_link = '/play/subscribe.php?type=' . $review_item->GetType() . '&item=' . $review_item->GetId() . '&title=' . $s_suggested_title . '&page=' . $s_page;
     $s_subscribe_title = 'Get an email alert every time there are new comments on this page';
     $this->AddControl('<div class="forumSubscribe"><a href="' . $s_subscribe_link . '" title="' . $s_subscribe_title . '">Subscribe to comments</a></div>');
     if (!$this->authentication_manager->GetUser()->Permissions()->HasPermission(PermissionType::ForumAddMessage())) {
         $add = $this->o_topic->GetCount() ? 'Add your comments' : 'Be the first to add your comments!';
         $this->AddControl('<div class="forumPost"><a href="' . Html::Encode($this->authentication_manager->GetPermissionUrl()) . urlencode('#forumMessageForm') . '">' . $add . '</a></div>');
     }
 }
 /**
  * @return string
  * @param string $s_text
  * @param int $i_trim
  * @param bool $b_add_xhtml_ellipsis
  * @desc Trims multi-word text to the specified number of words; defaults to first word only
  */
 public static function TrimToWord($s_text, $i_trim = 1, $b_add_xhtml_ellipsis = false)
 {
     $s_new_text = '';
     if ($s_text) {
         $a_words = explode(' ', $s_text);
         # split into words
         if ($i_trim >= count($a_words)) {
             $s_new_text = $s_text;
         } else {
             for ($i_count = 0; $i_count < $i_trim; $i_count++) {
                 $s_new_text .= $a_words[$i_count] . ' ';
             }
             if ($b_add_xhtml_ellipsis) {
                 $s_new_text = StringFormatter::AddEllipsis($s_new_text);
             }
         }
     }
     return trim($s_new_text);
 }
示例#5
0
$columnFormats = ['common\\models\\Foo.html' => function ($attribute, $generator) {
    return <<<FORMAT
[
    'format' => 'html',
    'label'=>'FOOFOO',
    'attribute' => 'item_id',
    'value'=> function(\$model){
        return \\yii\\helpers\\Html::a(\$model->bar,['/crud/item/view', 'id' => \$model->link_id]);
    }
]
FORMAT;
}, '.+' => function ($column, $model) {
    if ($column->dbType == 'text' || $column->dbType == 'mediumblob') {
        return false;
    }
}, 'created_at$|updated_at$' => function () {
    return false;
}];
$attributeFormats = ['_json$' => function ($attribute, $generator) {
    $formattter = StringFormatter::className();
    return <<<FORMAT
[
    'format' => 'html',
    #'label'=>'FOOFOO',
    'attribute' => '{$attribute->name}',
    'value'=> {$formattter}::contentJsonToHtml(\$model->{$attribute->name})

]
FORMAT;
}];
\Yii::$container->set('schmunk42\\giiant\\crud\\providers\\CallbackProvider', ['activeFields' => $activeFields, 'columnFormats' => $columnFormats, 'attributeFormats' => $attributeFormats]);
 function SendCommentsSubscriptions(ReviewItem $review_item, ForumMessage $message)
 {
     # get all subscriptions for this item
     if (AuthenticationManager::GetUser()->IsSignedIn() and $review_item->GetId()) {
         $s_person = $this->GetSettings()->GetTable('User');
         $s_sub = $this->GetSettings()->GetTable('EmailSubscription');
         # join to item's table to get the title, regardless of message title
         $s_sql = '';
         switch ($review_item->GetType()) {
             case ContentType::STOOLBALL_MATCH:
                 $matches = $this->GetSettings()->GetTable('Match');
                 $s_sql = "SELECT {$matches}.match_title AS title, {$s_person}.email\n\t\t\t\t\tFROM ({$s_person} INNER JOIN {$s_sub} ON {$s_person}.user_id = {$s_sub}.user_id AND {$s_sub}.item_type = " . ContentType::STOOLBALL_MATCH . ")\n\t\t\t\t\tINNER JOIN {$matches} ON {$s_sub}.item_id = {$matches}.match_id AND {$s_sub}.item_type = " . ContentType::STOOLBALL_MATCH . "\n\t\t\t\t\tWHERE {$s_sub}.item_id = " . Sql::ProtectNumeric($review_item->GetId()) . " AND {$s_person}.user_id <> " . Sql::ProtectNumeric(AuthenticationManager::GetUser()->GetId());
                 break;
         }
         if ($s_sql) {
             # if there's at least one person, build email
             require_once 'Zend/Mail.php';
             $email = new Zend_Mail('UTF-8');
             if ($this->GetEmailAddresses($s_sql, $email)) {
                 $o_filter = new BadLanguageFilter();
                 $s_title = $o_filter->Filter($this->s_review_item_title);
                 unset($o_filter);
                 $s_title = StringFormatter::PlainText($s_title);
                 # send the email
                 $email->addTo($this->GetSettings()->GetSubscriptionEmailTo());
                 $email->setFrom($this->GetSettings()->GetSubscriptionEmailFrom(), $this->GetSettings()->GetSubscriptionEmailFrom());
                 $email->setSubject("Email alert: '" . $s_title . "'");
                 $email->setBodyText($this->GetHeader() . trim(AuthenticationManager::GetUser()->GetName()) . ' has just commented on a page at ' . $this->GetSettings()->GetSiteName() . ' for which you subscribed to an email alert.' . "\n\n" . "The page is called '" . $s_title . "' - here's an excerpt of the new comments:\n\n" . $message->GetExcerpt() . "\n\n" . 'View the new comments at' . "\n" . $review_item->GetNavigateUrl() . '#message' . $message->GetId() . $this->GetFooter());
                 try {
                     $email->send();
                 } catch (Zend_Mail_Transport_Exception $e) {
                     # Do nothing - email not that important so, if it fails, fail silently rather than raising a fatal error
                 }
             }
         }
     }
 }