Beispiel #1
0
 public function display()
 {
     $strTag = utf8_strtolower($this->patharray[0]);
     if (!strlen($strTag)) {
         redirect($this->controller_path_plain . $this->SID);
     }
     $arrArticleIDs = $this->pdh->get('articles', 'articles_for_tag', array($strTag));
     $arrArticleIDs = $this->pdh->sort($arrArticleIDs, 'articles', 'date', 'desc');
     $intStart = $this->in->get('start', 0);
     $arrLimitedIDs = $this->pdh->limit($arrArticleIDs, $intStart, $this->user->data['user_nlimit']);
     //Articles to template
     foreach ($arrLimitedIDs as $intArticleID) {
         $userlink = '<a href="' . $this->routing->build('user', $this->pdh->geth('articles', 'user_id', array($intArticleID)), 'u' . $this->pdh->get('articles', 'user_id', array($intArticleID))) . '">' . $this->pdh->geth('articles', 'user_id', array($intArticleID)) . '</a>';
         //Content dependet from list_type
         //1 = until readmore
         //2 = Headlines only
         //3 = only first 600 characters
         $strText = $this->pdh->get('articles', 'text', array($intArticleID));
         $arrContent = preg_split('#<hr(.*)id="system-readmore"(.*)\\/>#iU', xhtml_entity_decode($strText));
         $strText = $this->bbcode->parse_shorttags($arrContent[0]);
         $strPath = $this->pdh->get('articles', 'path', array($intArticleID));
         $intCategoryID = $this->pdh->get('articles', 'category', array($intArticleID));
         //Replace Image Gallery
         $arrGalleryObjects = array();
         preg_match_all('#<p(.*)class="system-gallery"(.*) data-sort="(.*)" data-folder="(.*)">(.*)</p>#iU', $strText, $arrGalleryObjects, PREG_PATTERN_ORDER);
         if (count($arrGalleryObjects[0])) {
             include_once $this->root_path . 'core/gallery.class.php';
             foreach ($arrGalleryObjects[4] as $key => $val) {
                 $objGallery = registry::register('gallery');
                 $strGalleryContent = $objGallery->create($val, (int) $arrGalleryObjects[3][$key], $this->server_path . $strPath, 1);
                 $strText = str_replace($arrGalleryObjects[0][$key], $strGalleryContent, $strText);
             }
         }
         //Replace Raidloot
         $arrRaidlootObjects = array();
         preg_match_all('#<p(.*)class="system-raidloot"(.*) data-id="(.*)"(.*) data-chars="(.*)">(.*)</p>#iU', $strText, $arrRaidlootObjects, PREG_PATTERN_ORDER);
         if (count($arrRaidlootObjects[0])) {
             include_once $this->root_path . 'core/gallery.class.php';
             foreach ($arrRaidlootObjects[3] as $key => $val) {
                 $objGallery = registry::register('gallery');
                 $withChars = $arrRaidlootObjects[5][$key] == "true" ? true : false;
                 $strRaidlootContent = $objGallery->raidloot((int) $val, $withChars);
                 $strText = str_replace($arrRaidlootObjects[0][$key], $strRaidlootContent, $strText);
             }
         }
         $this->comments->SetVars(array('attach_id' => $intArticleID, 'page' => 'articles'));
         $intCommentsCount = $this->comments->Count();
         //Tags
         $arrTags = $this->pdh->get('articles', 'tags', array($intArticleID));
         $this->tpl->assign_block_vars('article_row', array('ARTICLE_CONTENT' => $strText, 'ARTICLE_TITLE' => $this->pdh->get('articles', 'title', array($intArticleID)), 'ARTICLE_SUBMITTED' => sprintf($this->user->lang('news_submitter'), $userlink, $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, true)), 'ARTICLE_DATE' => $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, false, true), 'ARTICLE_PATH' => $this->controller_path . $this->pdh->get('articles', 'path', array($intArticleID)), 'ARTICLE_SOCIAL_BUTTONS' => $arrCategory['social_share_buttons'] ? $this->social->createSocialButtons($this->env->link . $this->pdh->get('articles', 'path', array($intArticleID)), strip_tags($this->pdh->get('articles', 'title', array($intArticleID)))) : '', 'PERMALINK' => $this->pdh->get('articles', 'permalink', array($intArticleID)), 'S_TAGS' => count($arrTags) && $arrTags[0] != "" ? true : false, 'ARTICLE_CUTTED_CONTENT' => truncate($strText, 600, '...', false, true), 'S_READMORE' => isset($arrContent[1]) ? true : false, 'COMMENTS_COUNTER' => $intCommentsCount == 1 ? $intCommentsCount . ' ' . $this->user->lang('comment') : $intCommentsCount . ' ' . $this->user->lang('comments'), 'S_COMMENTS' => $this->pdh->get('articles', 'comments', array($intArticleID)) ? true : false, 'S_FEATURED' => $this->pdh->get('articles', 'featured', array($intArticleID))));
         if (count($arrTags) && $arrTags[0] != "") {
             foreach ($arrTags as $tag) {
                 $this->tpl->assign_block_vars('article_row.tag_row', array('TAG' => $tag, 'U_TAG' => $this->routing->build('tag', $tag)));
             }
         }
     }
     $this->tpl->assign_vars(array('TAG' => sanitize($strTag), 'PAGINATION' => generate_pagination($this->strPath . $this->SID, count($arrArticleIDs), $this->user->data['user_nlimit'], $intStart, 'start')));
     $this->tpl->add_meta('<link rel="canonical" href="' . $this->env->link . $this->routing->build('tag', $tag, false, false, true) . '" />');
     $this->core->set_vars(array('page_title' => $this->user->lang("tag") . ': ' . sanitize($strTag), 'template_file' => 'tag.html', 'display' => true));
 }
function altText($text)
{
    if (strlen($text) > 100) {
        $text = truncate($text, 100);
    }
    return str_replace("<br />", "\n", str_replace("'", "&#39;", str_replace("\"", "&#34;", charReplace($text))));
}
 public function __construct()
 {
     gateKeeper();
     $guid = getInput("guid");
     $title = getInput("blog_title");
     $description = getInput("description");
     $access_id = getInput("access_id");
     $container_guid = getInput("container_guid");
     $owner_guid = getLoggedInUserGuid();
     if ($guid) {
         $blog = getEntity($guid);
     } else {
         $blog = new Blog();
     }
     $blog->title = $title;
     $blog->description = $description;
     $blog->access_id = $access_id;
     $blog->owner_guid = $owner_guid;
     $blog->status = "published";
     $blog->container_guid = $container_guid;
     $blog->save();
     new Activity(getLoggedInUserGuid(), "blog:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $blog->getURL(), $blog->title, truncate($blog->description)), "", $access_id);
     new SystemMessage("Your blog has been published");
     forward("blogs/all_blogs");
 }
Beispiel #4
0
 protected function generateMetaDescription()
 {
     sfProjectConfiguration::getActive()->loadHelpers('StringFunc');
     $result = '';
     switch ($this->getCurrentPageType()) {
         case self::ARTICLE_PAGE:
             //pealkiri. Sisu (250 chars)
             if ($this->getRoute()->getObject()->getMetadescription()) {
                 return $this->getRoute()->getObject()->getMetadescription();
             }
             $content = truncate(strip_tags($this->getRoute()->getObject()->getTitle() . '. ' . $this->getRoute()->getObject()->getContent()), 250, '');
             break;
         case self::CATEGORY_PAGE:
             // category name, products
             if ($this->getRoute()->getCategoryObject()->getMetaDescription()) {
                 return $this->getRoute()->getCategoryObject()->getMetaDescription();
             }
             $content = implode(',', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject()));
             break;
         case self::PRODUCT_PAGE:
             //toote nimi (kategooriad) - toode kirjelduse esimesed tähemärgid
             $content = $this->getRoute()->getProductObject()->getName() . ' (' . implode(', ', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject())) . ') ' . $this->getRoute()->getProductObject()->getDescription();
             break;
     }
     $result = truncate(strip_tags($content), 250, '');
     return $result;
 }
Beispiel #5
0
function main_form($x, $y, $data)
{
    global $pdf;
    global $_TITLE, $_LMARGIN, $_BMARGIN;
    $balance = $data['balance'] < 0 ? -$data['balance'] : $data['balance'];
    $font_size = 14;
    $lineh = 25;
    $x += $_LMARGIN;
    $y += $_BMARGIN;
    $y += 275;
    $pdf->addtext($x, $y, $font_size, $data['d_name']);
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, trim($data['d_zip'] . ' ' . $data['d_city'] . ' ' . $data['d_address']));
    $y -= $lineh;
    //    for($i=0; $i<26; $i++)
    //    {
    //	    $pdf->addtext($x+$i*14.6,$y,$font_size,$_ACCOUNT[$i]);
    //    }
    $pdf->addtext($x, $y, $font_size, bankaccount($data['id'], $data['account']));
    $y -= $lineh;
    $pdf->addtext($x + 220, $y, $font_size, sprintf('%.2f', $balance));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, trans('$a dollars $b cents', to_words(floor($balance)), to_words(round(($balance - floor($balance)) * 100))));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, truncate($data['customername']));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, truncate(trim($data['zip'] . ' ' . $data['city'] . ' ' . $data['address'])));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, $_TITLE);
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, trans('Customer ID: $a', sprintf('%04d', $data['id'])));
}
Beispiel #6
0
 static function urlize($url, $truncate = false)
 {
     if (preg_match('/^(http|https|ftp:\\/\\/([^\\s"\']+))/i', $url, $match)) {
         $url = "<a href='{$url}'>" . ($truncate ? truncate($url, $truncate) : $url) . '</a>';
     }
     return $url;
 }
 function getContentArticle($article, $wordwrap = 0)
 {
     if ($wordwrap > 0) {
         $content = strip_tags($article->content);
         return truncate($content, $wordwrap, '...');
     } else {
         return $article->content;
     }
 }
Beispiel #8
0
function __NLStreamCopy(NLStream $in, NLStream $out)
{
    truncate($out, 0);
    fseek($in->_imp_data, 0, SEEK_SET);
    fseek($out->_imp_data, 0, SEEK_SET);
    $len = __NLStreamCopyAtOffset($in->_imp_data, $out->_imp_data);
    fseek($in->_imp_data, 0, SEEK_SET);
    fseek($out->_imp_data, 0, SEEK_SET);
}
 function test_truncate_with_options_hash()
 {
     $this->assertEqual("This is a string that wil[...]", truncate("This is a string that will go longer then the default truncate length of 30", array("omission" => "[...]")));
     $this->assertEqual("Hello W...", truncate("Hello World!", array("length" => 10)));
     $this->assertEqual("Hello[...]", truncate("Hello World!", array("omission" => "[...]", "length" => 10)));
     $this->assertEqual("Hello[...]", truncate("Hello Big World!", array("omission" => "[...]", "length" => 13, "separator" => ' ')));
     $this->assertEqual("Hello Big[...]", truncate("Hello Big World!", array("omission" => "[...]", "length" => 14, "separator" => ' ')));
     $this->assertEqual("Hello Big[...]", truncate("Hello Big World!", array("omission" => "[...]", "length" => 15, "separator" => ' ')));
 }
Beispiel #10
0
 public function pingback_ping($args)
 {
     $config = Config::current();
     $linked_from = str_replace('&amp;', '&', $args[0]);
     $linked_to = str_replace('&amp;', '&', $args[1]);
     $cleaned_url = str_replace(array("http://www.", "http://"), "", $config->url);
     if ($linked_to == $linked_from) {
         return new IXR_ERROR(0, __("The from and to URLs cannot be the same."));
     }
     if (!substr_count($linked_to, $cleaned_url)) {
         return new IXR_Error(0, __("There doesn't seem to be a valid link in your request."));
     }
     if (preg_match("/url=([^&#]+)/", $linked_to, $url)) {
         $post = new Post(array("url" => $url[1]));
     } else {
         $post = MainController::current()->post_from_url(null, str_replace(rtrim($config->url, "/"), "/", $linked_to), true);
     }
     if (!$post) {
         return new IXR_Error(33, __("I can't find a post from that URL."));
     }
     # Wait for the "from" server to publish
     sleep(1);
     $from = parse_url($linked_from);
     if (empty($from["host"])) {
         return false;
     }
     if (empty($from["scheme"]) or $from["scheme"] != "http") {
         $linked_from = "http://" . $linked_from;
     }
     # Grab the page that linked here.
     $content = get_remote($linked_from);
     # Get the title of the page.
     preg_match("/<title>([^<]+)<\\/title>/i", $content, $title);
     $title = $title[1];
     if (empty($title)) {
         return new IXR_Error(32, __("There isn't a title on that page."));
     }
     $content = strip_tags($content, "<a>");
     $url = preg_quote($linked_to, "/");
     if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
         $url = str_replace("&", "&amp;", preg_quote($linked_to, "/"));
         if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
             $url = str_replace("&", "&#038;", preg_quote($linked_to, "/"));
             if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
                 return false;
             }
         }
     }
     $context[1] = truncate($context[1], 100, "...", true);
     $excerpt = strip_tags(str_replace($context[0], $context[1], $content));
     $match = preg_quote($context[1], "/");
     $excerpt = preg_replace("/.*?\\s(.{0,100}{$match}.{0,100})\\s.*/s", "\\1", $excerpt);
     $excerpt = "[...] " . trim(normalize($excerpt)) . " [...]";
     Trigger::current()->call("pingback", $post, $linked_to, $linked_from, $title, $excerpt);
     return _f("Pingback from %s to %s registered!", array($linked_from, $linked_to));
 }
 public function __construct($data = NULL)
 {
     gateKeeper();
     $logged_in_user = getLoggedInUser();
     if (!$data) {
         // Get the comment body
         $comment_body = getInput("comment");
         // Get container url
         $container_guid = getInput("guid");
     } else {
         $comment_body = $data['comment_body'];
         $container_guid = $data['container_guid'];
     }
     $container = getEntity($container_guid);
     $container_owner_guid = $container->owner_guid;
     if ($container_owner_guid) {
         $container_owner = getEntity($container_owner_guid);
     }
     $url = $container->getURL();
     if (!$url) {
         $url = getSiteURL();
     }
     // Create the comment
     CommentsPlugin::createComment($container_guid, $comment_body);
     if ($container_owner_guid) {
         if ($container_owner_guid != getLoggedInUserGuid()) {
             $params = array("to" => array($container_owner->full_name, $container_owner->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
             switch ($logged_in_user->getSetting("notify_when_comment")) {
                 case "email":
                     sendEmail($params);
                     break;
                 case "none":
                     break;
                 case "site":
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
                 case "both":
                     sendEmail($params);
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
             }
         }
     }
     runHook("add:comment:after");
     if (getLoggedInUserGuid() != $container_owner_guid && $container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container_owner->getURL(), $container_owner->full_name, $container->getURL(), translate($container->type), truncate($comment_body)));
     } elseif (!$container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment:own", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container->getURL(), $container->title, translate($container->type), truncate($comment_body)));
     }
     // Return to container page.
     forward();
 }
 public function __construct()
 {
     gateKeeper();
     $email_users = array();
     $container_guid = getInput("container_guid");
     $topic = getEntity($container_guid);
     $category_guid = $topic->container_guid;
     $category = getEntity($category_guid);
     $description = getInput("comment");
     $comment = new Forumcomment();
     $comment->description = $description;
     $comment->container_guid = $container_guid;
     $comment->category_guid = $category_guid;
     $comment->owner_guid = getLoggedInUserGuid();
     $comment->save();
     new SystemMessage("Your comment has been posted.");
     new Activity(getLoggedInUserGuid(), "forum:comment:posted", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, truncate($comment->description)), $container_guid, $category->access_id);
     $all_comments = getEntities(array("type" => "Forumcomment", "metadata_name" => "container_guid", "metadata_value" => $container_guid));
     $notify_users = array($topic->owner_guid);
     $container_owner_guid = $topic->owner_guid;
     $container_owner = getEntity($container_owner_guid);
     if ($container_owner->notify_when_forum_comment_topic_i_own == "email" || $container_owner->notify_when_forum_comment_topic_i_own == "both") {
         $email_users[] = $container_guid;
     }
     foreach ($all_comments as $comment) {
         $user_guid = $comment->owner_guid;
         $user = getEntity($user_guid);
         switch ($user->notify_when_forum_comment_topic_i_own) {
             case "both":
                 $notify_users[] = $comment->owner_guid;
                 $email_users[] = $comment->owner_guid;
                 break;
             case "email":
                 $email_users[] = $comment->owner_guid;
                 break;
             case "site":
                 $notify_users[] = $comment->owner_guid;
                 break;
             case "none":
                 break;
         }
     }
     $notify_users = array_unique($notify_users);
     foreach ($notify_users as $user_guid) {
         notifyUser("forumcomment", $container_guid, getLoggedInUserGuid(), $user_guid);
     }
     foreach ($email_users as $user) {
         $params = array("to" => array($user->full_name, $user->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
         sendEmail($params);
     }
     forward();
 }
Beispiel #13
0
function save_note($id, $title, $body)
{
    if ($body == "" && $title == "") {
        $title = "Empty note";
    }
    if (($title == "" || $title == "Empty note") && $body != "") {
        $title = truncate(strip_tags($body), 30);
    }
    $db = new db();
    $result = $db->update("notes", array("title" => $title, "body" => $body), "id = :id", array(":id" => $id));
    $result = array("id" => $id, "title" => $title, "body" => $body);
    return $result;
}
Beispiel #14
0
function formatTeaser($r)
{
    $teaser = '';
    if (array_key_exists('highlight', $r)) {
        $teaser = trim(preg_replace('/\\s+/', ' ', preg_replace('/^\\*{2,}.*?\\n/', '', $r['highlight']['description'][0])));
    } elseif (array_key_exists('description', $r['_source'])) {
        $teaser = truncate(trim(preg_replace('/\\s+/', ' ', preg_replace('/^\\*{2,}.*/m', '', $r['_source']['description']))));
    }
    if ($teaser == '') {
        $teaser = 'No data.';
    }
    return strip_tags($teaser);
}
function smarty_function_ajax_input($params, &$smarty)
{
    $id = $params['id'];
    $class = $params['class'];
    $value = $params['value'];
    $default = $params['default'];
    $display = $params['display'];
    $mode = $params['mode'];
    $noclear = $params['noclear'];
    $truncate = (int) $params['truncate'];
    $permission = $params['permission'];
    $callSave = isset($params['file']) ? "saveField(this, " . $params['file'] . ")" : "saveField(this)";
    $trucated = truncate($value, $truncate);
    if ($mode == 'edit') {
        $edit = 1;
    } elseif ($mode == 'show') {
        $edit = 0;
    } else {
        $edit = $value ? 0 : 1;
    }
    if (!$display) {
        $display = 'block';
    }
    if (!$permission) {
        $output .= '<div id="show-' . $id . '" class="' . $class . '" style="display:' . $display . '">';
        $output .= $trucated ? $trucated : $default;
        $output .= "</div>";
        return $output;
    } else {
        $class .= " editable";
    }
    $output = '';
    $output .= '<div id="show-' . $id . '" class="' . $class . '" style="display:' . ($edit ? 'none' : $display) . '" onClick="editaCampo(' . "'" . $id . "'" . ');">';
    $output .= $edit ? $default : $trucated;
    $output .= "</div>";
    // TODO: escape value
    $output .= '<input class="' . $class . '" id="input-' . $id . '" value="' . ($value ? $value : $default) . '" ';
    if (!$value && !$noclear) {
        $output .= " onFocus=\"limpaCampo('{$id}');\"";
    }
    $output .= " onChange=\"mudado['{$id}']=1; editing['{$id}'] = false;\" onBlur=\"{$callSave}\" style=\"display:" . ($edit ? $display : 'none') . "\">";
    $output .= "<img id=\"error-{$id}\" class=\"gUpErrorImg\" style=\"display: none\" src=\"styles/estudiolivre/errorImg.png\" onMouseover=\"tooltip(errorMsg_{$id});\" onMouseout=\"nd();\"> ";
    $output .= '<script language="JavaScript">';
    $output .= '  display["' . $id . '"] = "' . $display . '";errorMsg_' . $id . ' = "";';
    if ($truncate) {
        $output .= '  truncations["' . $id . '"] = "' . $truncate . '";';
    }
    $output .= '</script>';
    return $output;
}
function smarty_function_recentposts($params, &$bBlog)
{
    $crit['num'] = isset($params['num']) ? $params['num'] : 5;
    $crit['mode'] = isset($params['mode']) ? $params['mode'] : "br";
    $crit['sep'] = isset($params['sep']) ? $params['sep'] : "<br />";
    $crit['titlelen'] = isset($params['titlelen']) ? $params['titlelen'] : 30;
    $crit['skip'] = isset($params['skip']) ? $params['skip'] : 0;
    $linkcode = '';
    $ph = $bBlog->_ph;
    $posts = $ph->get_posts($crit);
    if ($mode == "list") {
        $linkcode .= "<ul>";
    }
    $i = 0;
    if (is_array($posts)) {
        /* <a([^<]*)?href=(\"|')?([a-zA-Z]*://[a-zA-Z0-9]*\.[a-zA-Z0-9]*\.[a-zA-Z]*([^>]*)?)(\"|')?([^>]*)?>([^<]*)</a> */
        // This should match any protocol, any port, any URL, any title. URL's like www.yest.com are supported, and should be treated as HTTP by browsers.
        $regex = "#<a([^<]*)?href=(\"|')?(([a-zA-Z]*://)?[a-zA-Z0-9]*\\.[a-zA-Z0-9]*\\.[a-zA-Z]*(:[0-9]*)?([^>\"\\']*)?)(\"|')?([^>]*)?>([^<]*)</a>#i";
        foreach ($posts as $post) {
            if ($post['title'] === 'No posts found') {
                $linkcode .= '<strong>' . $post['title'] . '</strong>';
                continue;
            }
            $title = $post["title"];
            $fulltitle = $title;
            //wont be cut off
            if (preg_match($regex, $title, $matches) == 1) {
                $title = $matches[9];
            }
            $i++;
            if ($mode == "list") {
                $linkcode .= "<li>";
            }
            // we using arrays in the template and objects in the core..
            $url = $post['permalink'];
            $title = truncate($title, $titlelen, '...', FALSE);
            $linkcode .= "<a href='{$url}' title='{$fulltitle}'>{$title}</a>";
            if ($mode == "br" && $num > $i) {
                $linkcode .= $sep;
            }
            if ($mode == "list") {
                $linkcode .= "</li>";
            }
        }
    }
    if ($mode == "list") {
        $linkcode .= "</ul>";
    }
    return $linkcode;
}
Beispiel #17
0
function sendpmmail($uid, $pm)
{
    global $config, $check, $data;
    $tempsql = $data->select_query("users", "WHERE id='{$uid}'", "id, uname, allowemail, newpm, email");
    $temp = $data->fetch_array($tempsql);
    if ($temp['allowemail'] && $temp['newpm']) {
        $email = $data->select_fetch_one_row("emails", "WHERE type='newpm'");
        $link = $config['siteaddress'] . "index.php?page=pmmain&action=readpm&id={$pm['id']}";
        $cmscoutTags = array("!#uname#!", "!#postuname#!", "!#title#!", "!#type#!", "!#link#!", "!#extract#!", "!#website#!");
        $replacements = array($temp['uname'], $check['uname'], $pm['subject'], "personal message", $link, truncate($pm['text'], 300), $config['troopname']);
        $emailContent = str_replace($cmscoutTags, $replacements, $email['email']);
        sendMail($temp['email'], $temp['uname'], $config['emailPrefix'] . $email['subject'], $emailContent);
    }
}
function custom_excerpt($length = "750", $readMore = true)
{
    // character length
    $excerpt_length = $length;
    $content = get_the_content();
    $content = preg_replace('/<img[^>]+./', '', $content);
    // preg_replace("/<img[^>]+\>/i", "(image) ", $content);
    $excerpt = truncate($content, $excerpt_length, '...', false, true);
    if ($readMore) {
        $excerptHTML = '<p class="post-excerpt">' . $excerpt . '&nbsp;<a href="' . get_permalink() . '">Read Post</a></p>';
    } else {
        $excerptHTML = '<p class="post-excerpt">' . $excerpt . '</p>';
    }
    echo strlen($excerpt) > 100 ? $excerptHTML : '';
}
Beispiel #19
0
function vimeo($atts, $content = null)
{
    extract(shortcode_atts(array('id' => ''), $atts));
    $VideoInfo = getVimeoInfo($id);
    $thumbnail = $VideoInfo['thumbnail_large'];
    $title = $VideoInfo['title'];
    $url = $VideoInfo['url'];
    return '<dl class="gallery-item">
			<dt class="gallery-icon vimeo">
				<a href="' . $url . '" title="' . $title . '" rel="prettyPhoto">
					<img width="300" height="200" src="' . $thumbnail . '" alt="' . $title . '" />
				</a>
			</dt>
			<dd class="gallery-caption" style="opacity: 1; ">
				' . truncate($title, 20) . '
			</dd>
		</dl>';
}
Beispiel #20
0
 function article()
 {
     $uri = $this->uri->rsegment(3);
     if (is_numeric($uri) && $uri != 0) {
         $query = $this->db->get_where('blog', array('id' => $uri));
         $query2 = $this->db->get('catblog');
         $this->load->view('newarticle', array('cats' => $query2->result(), 'data' => $query->row_array()));
         return;
     }
     if (isset($_POST['title']) == false) {
         $data = array('title' => '', 'textpost' => '', 'catid' => -1, 'url' => '', 'keywords' => "  ", 'mainpage' => 0);
         $query = $this->db->get('catblog');
         $this->load->view('newarticle', array('cats' => $query->result(), 'data' => $data));
     } else {
         if (isset($_POST['title']) && isset($_POST['catid']) && isset($_POST['text'])) {
             $perm = $this->userauth->default_permision;
             $catid = $this->input->post('catid');
             if (!isset($_POST['admin']) && !isset($_POST['user'])) {
                 $query = $this->db->get_where('catblog', array('id' => $this->input->post('catid')));
                 if ($query->num_rows > 0) {
                     $row = $query->row();
                     $perm = $row->permissions;
                 }
             } else {
                 $perm = $this->_post_perm();
             }
             $data = array('title' => $this->input->post('title'), 'textpost' => $this->input->post('text'), 'permissions' => $perm, 'catid' => $catid, 'author' => $this->session->userdata('userid'), 'url' => isset($_POST['url']) && !empty($_POST['url']) ? $this->input->post('url') : date("Y_m_d_h_m"), 'keywords' => isset($_POST['keywords']) && !empty($_POST['keywords']) ? $this->input->post('keywords') : "  ", 'shorttext' => truncate($this->input->post('text'), 200), 'datepost' => date("Y-m-d"), 'mainpage' => isset($_POST['mainpage']) ? $this->input->post('mainpage') : 0);
             if (isset($_POST['article_id'])) {
                 $this->db->where('id', $this->input->post('article_id'));
                 if ($this->db->update('blog', $data) == 1) {
                     echo 'Added';
                 } else {
                     echo 'error';
                 }
             } else {
                 if ($this->db->insert('blog', $data) == 1) {
                     echo 'Added';
                 } else {
                     echo 'error';
                 }
             }
         }
     }
 }
Beispiel #21
0
 static function read_more($text, $string = null)
 {
     if (!substr_count($text, "e51b2b9a58824dd068d8777ec6e97e4d")) {
         return $text;
     }
     if (Route::current()->action == "view") {
         return preg_replace('/(<p>)?<a class="read_more" href="([^"]+)">e51b2b9a58824dd068d8777ec6e97e4d<\\/a>\\(\\(\\(more(\\((.+)\\))?\\)\\)\\)(<\\/p>(\\n\\n<\\/p>(\\n\\n)?)?)?/', "", $text);
     }
     preg_match_all("/e51b2b9a58824dd068d8777ec6e97e4d(\\(\\(\\(more(\\((.+)\\))?\\)\\)\\))/", preg_replace("/<[^>]+>/", "", $text), $more, PREG_OFFSET_CAPTURE);
     $body = truncate($text, $more[1][0][1], "", true, true, true);
     $body .= @$more[3][0];
     if (!empty($more[2][0])) {
         $string = $more[2][0];
     } elseif (!isset($string) or $string instanceof Post) {
         # If it's called from anywhere but Twig the post will be passed as a second argument.
         $string = __("Read More &raquo;", "theme");
     }
     return str_replace("e51b2b9a58824dd068d8777ec6e97e4d", $string, $body);
 }
function generate_device_popup_header($device, $vars = array())
{
    global $config;
    humanize_device($device);
    if ($device['os'] == "ios") {
        formatCiscoHardware($device, TRUE);
    }
    // FIXME or generic function for more than just IOS? [and/or do this at poll time]
    $contents = '
<table class="table table-striped table-bordered table-rounded table-condensed">
  <tr class="' . $device['html_row_class'] . '" style="font-size: 10pt;">
    <td class="state-marker"></td>
    <td width="40" style="padding: 10px; text-align: center; vertical-align: middle;">' . get_device_icon($device) . '</td>
    <td width="200"><a href="#" class="' . $class . '" style="font-size: 15px; font-weight: bold;">' . escape_html($device['hostname']) . '</a><br />' . escape_html(truncate($device['location'], 64, '')) . '</td>
    <td>' . escape_html($device['hardware']) . ' <br /> ' . $device['os_text'] . ' ' . escape_html($device['version']) . '</td>
    <td>' . deviceUptime($device, 'short') . '<br />' . escape_html($device['sysName']) . '
  </tr>
</table>
';
    return $contents;
}
 public function __construct($data = array())
 {
     gateKeeper();
     $guid = getInput("guid");
     if (!$guid) {
         $guid = $data['guid'];
     }
     $user = getLoggedInUser();
     $status = getInput("status");
     if (!$status) {
         $status = $data['status'];
     } else {
         Security::checkForEmptyFields(array("status"));
     }
     if ($guid == $user->guid) {
         if (strpos($status, "&lt;img") == false || strpos($status, "<img") == false) {
             $user->profile_status = $status;
             $user->save();
         }
     }
     $status = display("output/editor", array("value" => $status));
     $s = new Profilestatus();
     $s->description = $status;
     $s->owner_guid = getLoggedInUserGuid();
     $s->container_guid = $guid;
     $s->owner_full_name = getLoggedInUser()->full_name;
     $s->owner_icon = getLoggedInUser()->icon;
     $s->save();
     $owner = getEntity($guid);
     if ($guid == $user->guid) {
         new Activity($guid, "activity:status:update:self", array($user->getURL(), $user->full_name, truncate($status)));
     } else {
         new Activity($user->guid, "activity:status:update:friend", array($user->getURL(), $user->full_name, $owner->getURL(), $owner->full_name, truncate($status)));
     }
     forward();
 }
Beispiel #24
0
 public function product()
 {
     $this->load_language('product/manufacturer');
     $this->load->model('catalog/manufacturer');
     $this->load->model('catalog/product');
     $this->load->model('tool/image');
     if (isset($this->request->get['manufacturer_id'])) {
         $manufacturer_id = $this->request->get['manufacturer_id'];
     } else {
         $manufacturer_id = 0;
     }
     if (isset($this->request->get['sort'])) {
         $sort = $this->request->get['sort'];
     } else {
         $sort = 'p.sort_order';
     }
     if (isset($this->request->get['order'])) {
         $order = $this->request->get['order'];
     } else {
         $order = 'ASC';
     }
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     if (isset($this->request->get['limit'])) {
         $limit = $this->request->get['limit'];
     } else {
         $limit = $this->config->get('config_catalog_limit');
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
     $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id);
     if ($manufacturer_info) {
         $this->document->setTitle($manufacturer_info['name']);
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator'));
         $this->data['heading_title'] = $manufacturer_info['name'];
         $this->data['compare'] = $this->url->link('product/compare');
         $this->data['products'] = array();
         $data = array('filter_manufacturer_id' => $manufacturer_id, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit);
         $product_total = $this->model_catalog_product->getTotalProducts($data);
         $results = $this->model_catalog_product->getProducts($data);
         foreach ($results as $result) {
             if ($result['image']) {
                 $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
             } else {
                 $image = false;
             }
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = false;
             }
             if ((double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_tax')) {
                 $tax = $this->currency->format((double) $result['special'] ? $result['special'] : $result['price']);
             } else {
                 $tax = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => truncate(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 200) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'rating' => $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', $url . '&manufacturer_id=' . $result['manufacturer_id'] . '&product_id=' . $result['product_id']));
         }
         $url = '';
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['sorts'] = array();
         $this->data['sorts'][] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.sort_order&order=ASC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=pd.name&order=ASC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=pd.name&order=DESC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.price&order=ASC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.price&order=DESC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=rating&order=DESC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=rating&order=ASC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_model_asc'), 'value' => 'p.model-ASC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.model&order=ASC' . $url));
         $this->data['sorts'][] = array('text' => $this->language->get('text_model_desc'), 'value' => 'p.model-DESC', 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.model&order=DESC' . $url));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         $this->data['limits'] = array();
         $this->data['limits'][] = array('text' => $this->config->get('config_catalog_limit'), 'value' => $this->config->get('config_catalog_limit'), 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&limit=' . $this->config->get('config_catalog_limit')));
         $this->data['limits'][] = array('text' => 25, 'value' => 25, 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&limit=25'));
         $this->data['limits'][] = array('text' => 50, 'value' => 50, 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&limit=50'));
         $this->data['limits'][] = array('text' => 75, 'value' => 75, 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&limit=75'));
         $this->data['limits'][] = array('text' => 100, 'value' => 100, 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&limit=100'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $pagination = new Pagination();
         $pagination->total = $product_total;
         $pagination->page = $page;
         $pagination->limit = $limit;
         $pagination->text = $this->language->get('text_pagination');
         $pagination->url = $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&page={page}');
         $this->data['pagination'] = $pagination->render();
         $this->data['sort'] = $sort;
         $this->data['order'] = $order;
         $this->data['limit'] = $limit;
         $this->data['continue'] = $this->url->link('common/home');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/manufacturer_info.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/product/manufacturer_info.tpl';
         } else {
             $this->template = 'default/template/product/manufacturer_info.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->response->setOutput($this->render());
     } else {
         $url = '';
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/category', $url), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($this->language->get('text_error'));
         $this->data['heading_title'] = $this->language->get('text_error');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = $this->url->link('common/home');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this->template = 'default/template/error/not_found.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->response->setOutput($this->render());
     }
 }
Beispiel #25
0
if ($device['ignore'] == '1') {
    $class = 'bg-warning';
    if ($device['status'] == '1') {
        $class = 'bg-success';
    }
}
if ($device['disabled'] == '1') {
    $class = 'bg-info';
}
$type = strtolower($device['os']);
if ($device['os'] == 'ios') {
    formatCiscoHardware($device, true);
}
$device['os_text'] = $config['os'][$device['os']]['text'];
echo '  <tr>
          <td class="' . $class . ' "></td>
          <td>' . $image . '</td>
          <td><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>';
echo '<td>';
if ($port_count) {
    echo ' <img src="images/icons/port.png" align=absmiddle /> ' . $port_count;
}
echo '<br />';
if ($sensor_count) {
    echo ' <img src="images/icons/sensors.png" align=absmiddle /> ' . $sensor_count;
}
echo '</td>';
echo '    <td>' . $device['hardware'] . ' ' . $device['features'] . '</td>';
echo '    <td>' . formatUptime($device['uptime'], 'short') . ' <br />';
echo '    ' . truncate($device['location'], 32, '') . '</td>';
echo ' </tr>';
Beispiel #26
0
    foreach (dbFetchRows($sql) as $interface) {
        if (port_permitted($interface['port_id'])) {
            echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n       <strong>" . generate_device_link($interface, shorthost($interface['hostname'])) . "</strong><br />\n       <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />\n       <strong>" . generate_port_link($interface, makeshortif($interface['ifDescr'])) . "</strong><br />\n       <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n      </div>";
        }
    }
}
$sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'";
foreach (dbFetchRows($sql) as $service) {
    if (device_permitted($service['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n      <strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />\n      <strong>" . $service['service_type'] . "</strong><br />\n      <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n      </center></div>";
    }
}
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id";
foreach (dbFetchRows($sql) as $peer) {
    if (device_permitted($peer['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n      <strong>" . generate_device_link($peer, shorthost($peer['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />\n      <strong>" . $peer['bgpPeerIdentifier'] . "</strong><br />\n      <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n      </div>";
    }
}
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
    $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'";
    foreach (dbFetchRows($sql) as $device) {
        if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
            echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>\n        <strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n        <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />\n        <span class=body-date-1>" . formatUptime($device['attrib_value']) . "</span>\n        </div>";
        }
    }
}
echo "\n\n        <div style='clear: both;'>{$errorboxes}</div> <div style='margin: 0px; clear: both;'>\n\n<h3>Recent Syslog Messages</h3>\n\n";
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
echo "<table cellspacing=0 cellpadding=2 width=100%>";
foreach (dbFetchRows($sql) as $entry) {
    include "includes/print-syslog.inc.php";
Beispiel #27
0
function ws_display_list($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $images, $color, $style;
    $html = '';
    $js = '';
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // Find the "tab" we're on
    $tab = $_SESSION['ona'][$form['form_id']]['tab'];
    // Build js to refresh this list
    $refresh = "xajax_window_submit('{$window_name}', xajax.getFormValues('{$form['form_id']}'), 'display_list');";
    // If this is the display_host screen that called, add refresh for DNS records too
    if ($form['content_id'] == 'display_host_list_interfaces') {
        $refresh .= "xajax_window_submit('list_records', xajax.getFormValues('list_records_filter_form'), 'display_list');";
    }
    // If it's not a new query, load the previous query from the session
    // into $form and save the current page and filter in the session.
    // Also find/set the "page" we're viewing
    $page = 1;
    if ($form['page'] and is_numeric($form['page'])) {
        $form = array_merge($form, (array) $_SESSION['ona'][$form['form_id']][$tab]['q']);
        $_SESSION['ona'][$form['form_id']][$tab]['page'] = $page = $form['page'];
        $_SESSION['ona'][$form['form_id']][$tab]['filter'] = $form['filter'];
    }
    // Calculate the SQL query offset (based on the page being displayed)
    $offset = $conf['search_results_per_page'] * ($page - 1);
    if ($offset == 0) {
        $offset = -1;
    }
    // Search results go in here
    $results = array();
    $count = 0;
    // Start building the "where" clause for the sql query to find the interfaces to display
    $where = "";
    $and = "";
    // HOST ID
    if ($form['host_id']) {
        $where .= $and . "host_id = " . $onadb->qstr($form['host_id']) . " OR id in (select interface_id from interface_clusters where host_id = " . $onadb->qstr($form['host_id']) . ")";
        $and = " AND ";
    }
    // Do the SQL Query
    $filter = '';
    if ($form['filter']) {
        $form['filter'] = ip_mangle($form['filter']);
        $filter = $and . ' ip_addr LIKE ' . $onadb->qstr('%' . $form['filter'] . '%');
    }
    list($status, $rows, $results) = db_get_records($onadb, 'interfaces', $where . $filter, "ip_addr ASC", $conf['search_results_per_page'], $offset);
    // If we got less than serach_results_per_page, add the current offset to it
    // so that if we're on the last page $rows still has the right number in it.
    if ($rows > 0 and $rows < $conf['search_results_per_page']) {
        $rows += $conf['search_results_per_page'] * ($page - 1);
    }
    // Re-Count only "internal" interfaces, not nat interfaces
    list($status, $rows, $records) = db_get_records($onadb, 'interfaces', 'nat_interface_id = \'0\' and ' . $where . $filter, "", 0);
    $count = $rows;
    $html .= <<<EOL
        <!-- Interface List -->
        <table id="{$form['form_id']}_interface_list" class="list-box" cellspacing="0" border="0" cellpadding="0">

            <!-- Table Header -->
            <tr>

                <td colspan="2" class="list-header" align="center" style="{$style['borderR']};">Interface</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Subnet</td>
                <td class="list-header" align="center" style="{$style['borderR']};">MAC</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Name</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Description</td>
                <td class="list-header" align="center" style="{$style['borderR']};">Last Response</td>
                <td class="list-header" align="center">&nbsp;</td>
            </tr>
EOL;
    // Loop and display each record
    foreach ($results as $record) {
        // Get additional info about each host record //
        // Check if this interface has an external NAT
        unset($extnatint, $extnatdisplay, $extnatdisplay, $extnatsubdisplay);
        if ($record['nat_interface_id'] > 0) {
            list($status, $rows, $extnatint) = ona_get_interface_record(array('id' => $record['nat_interface_id']));
            // GDO: get the subnet object of the NATing interface, display it in both Interface and Subnet columns
            list($status, $rows, $extnatintsub) = ona_get_subnet_record(array('id' => $extnatint['subnet_id']));
            $extnatint['ip_addr'] = ip_mangle($extnatint['ip_addr'], 'dotted');
            //$extnatdisplay = "<span title='Interface is NATed to {$extnatint['ip_addr']}'> &nbsp;&nbsp;=> &nbsp;{$extnatint['ip_addr']}</span>";
            $extnatdisplay = "<span title='Interface is NATed to {$extnatint['ip_addr']} (on {$extnatintsub['name']})'> &nbsp;&nbsp;=> &nbsp;{$extnatint['ip_addr']}</span>";
            $extnatsubdisplay = " => <a title=\"View NATed subnet. ID: {$extnatintsub['id']}\"\n                                            class=\"nav\"\n                                            onClick=\"xajax_window_submit('work_space', 'xajax_window_submit(\\'display_subnet\\', \\'subnet_id=>{$extnatintsub['id']}\\', \\'display\\')');\"\n                                         >{$extnatintsub['name']}</a>";
        }
        // Check if this interface is an external NAT for another interface
        list($isnatstatus, $isnatrows, $isnat) = db_get_records($onadb, 'interfaces', "nat_interface_id = {$record['id']}", '', 0);
        // If the current interface is external NAT for another, dont display it in the list.
        if ($isnatrows > 0) {
            continue;
        }
        list($status, $intclusterrows, $intcluster) = db_get_records($onadb, 'interface_clusters', "interface_id = {$record['id']}");
        // Grab some info from the associated subnet record
        list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $record['subnet_id']));
        $record['ip_mask'] = $subnet['ip_mask'];
        $record['subnet_id'] = $subnet['id'];
        $record['subnet_description'] = $subnet['name'];
        // Convert IP and Netmask to a presentable format
        $record['ip_addr'] = ip_mangle($record['ip_addr'], 'dotted');
        $record['ip_mask'] = ip_mangle($record['ip_mask'], 'dotted');
        $record['ip_mask_cidr'] = ip_mangle($record['ip_mask'], 'cidr');
        if ($record['mac_addr']) {
            $record['mac_addr'] = mac_mangle($record['mac_addr']);
        }
        $record['description_short'] = truncate($record['description'], 40);
        // Escape data for display in html
        foreach (array_keys($record) as $key) {
            $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
        }
        // Format the date and colorize if its older than 2 months
        if ($record['last_response']) {
            $record['last_response_fmt'] = date($conf['date_format'], strtotime($record['last_response']));
            if (strtotime($record['last_response']) < strtotime('-2 month')) {
                $record['last_response_fmt'] = "<span style=\"color: red;\">" . $record['last_response_fmt'] . "</style>";
            }
        }
        $html .= <<<EOL
            <tr onMouseOver="this.className='row-highlight'" onMouseOut="this.className='row-normal'">

                <td nowrap="true" class="list-row" style="padding: 0px;" width="16px">
EOL;
        // Display cluster related information
        $clusterhtml = '&nbsp;';
        $clusterstyle = '';
        $clusterscript = '';
        if ($intclusterrows > 0) {
            $clusterstyle = 'font-weight: bold';
            $clusterscript = "onMouseOver=\"wwTT(this, event,\n                        'id', 'tt_interface_cluster_list_{$record['id']}',\n                        'type', 'velcro',\n                        'styleClass', 'wwTT_niceTitle',\n                        'direction', 'south',\n                        'javascript', 'xajax_window_submit(\\'tooltips\\', \\'tooltip=>interface_cluster_list,id=>tt_interface_cluster_list_{$record['id']},interface_id=>{$record['id']}\\');'\n                        );\"";
            $clusterhtml .= <<<EOL
                    <img src="{$images}/silk/sitemap.png" border="0" {$clusterscript} />
EOL;
        }
        $html .= $clusterhtml;
        $html .= <<<EOL
                </td>

                <td class="list-row">
EOL;
        // MP: Disabling the display_interface link. I dont think this will be needed
        if (1 < 0) {
            $html .= <<<EOL
                    <a title="View interface. ID: {$record['id']}"
                       class="nav"
                       onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_interface\\',\\'interface_id=>{$record['id']}\\', \\'display\\')');">
                        {$record['ip_addr']}
                        </a>
EOL;
        } else {
            $html .= "<span style='{$clusterstyle}' {$clusterscript}>{$record['ip_addr']}</span>";
        }
        $html .= <<<EOL
                    <span style="{$clusterstyle}" title="{$record['ip_mask']}">/{$record['ip_mask_cidr']}</span> {$extnatdisplay}
                </td>

                <td class="list-row" align="left">
                    <a title="View subnet. ID: {$subnet['id']}"
                       class="nav"
                       onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_subnet\\', \\'subnet_id=>{$subnet['id']}\\', \\'display\\')');"
                    >{$record['subnet_description']}</a> {$extnatsubdisplay}
                </td>

                <td class="list-row" align="right">
                    {$record['mac_addr']}&nbsp;
                </td>

                <td class="list-row" align="left">
                    {$record['name']}&nbsp;
                </td>

                <td class="list-row" align="left" title="{$record['description']}">
                    {$record['description_short']}&nbsp;
                </td>

                <td class="list-row" align="left" title="{$record['last_response']}">
                    {$record['last_response_fmt']}&nbsp;
                </td>

                <td class="list-row" align="right">
                    <form id="{$form['form_id']}_list_interface_{$record['id']}"
                        ><input type="hidden" name="interface_id" value="{$record['id']}"
                        ><input type="hidden" name="js" value="{$refresh}"
                    ></form>&nbsp;
EOL;
        if (auth('interface_modify')) {
            $html .= <<<EOL

                    <a title="Interface Menu"
                       id="int_menu_button_{$record['id']}"
                       class="act"
                       onmouseover="wwTT(this, event,
                                            'id', 'tt_quick_interface_menu_{$record['id']}',
                                            'type', 'velcro',
                                            'delay', 0,
                                            'styleClass', 'wwTT_int_menu',
                                            'lifetime', 1000,
                                            'direction', 'west',
                                            'javascript', 'xajax_window_submit(\\'tooltips\\', \\'tooltip=>quick_interface_menu,id=>tt_quick_interface_menu_{$record['id']},interface_id=>{$record['id']},ip_addr=>{$record['ip_addr']},orig_host=>{$record['host_id']},form_id=>{$form['form_id']}_list_interface_{$record['id']},subnet_id=>{$subnet['id']},natip=>{$record['nat_interface_id']}\\');'
                                           );"
                    ><img src="{$images}/silk/add.png" border="0"></a>&nbsp;
EOL;
        }
        if (auth('interface_modify')) {
            $html .= <<<EOL

                    <a title="Edit interface. ID: {$record['id']}"
                       class="act"
                       onClick="xajax_window_submit('edit_interface', xajax.getFormValues('{$form['form_id']}_list_interface_{$record['id']}'), 'editor');"
                    ><img src="{$images}/silk/page_edit.png" border="0"></a>&nbsp;
EOL;
        }
        if (auth('interface_del')) {
            $html .= <<<EOL

                    <a title="Delete interface"
                       class="act"
                       onClick="xajax_window_submit('edit_interface', xajax.getFormValues('{$form['form_id']}_list_interface_{$record['id']}'), 'delete');"
                    ><img src="{$images}/silk/delete.png" border="0"></a>&nbsp;
EOL;
        }
        $html .= <<<EOL
                </td>

            </tr>
EOL;
    }
    if ($count == 0 and $form['host_id'] and !$form['filter']) {
        $html .= <<<EOL
     <tr><td colspan="99" align="center" style="color: red;">Please add an interface to this host, or delete the host</td></tr>
EOL;
    }
    $html .= <<<EOL
    </table>
EOL;
    // Build page links if there are any
    $html .= get_page_links($page, $conf['search_results_per_page'], $count, $window_name, $form['form_id']);
    // Insert the new html into the content div specified
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $response->addAssign("{$form['form_id']}_{$tab}_count", "innerHTML", "({$count})");
    $response->addAssign($form['content_id'], "innerHTML", $html);
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
Beispiel #28
0
    generate_front_box('service-down', generate_device_link($service, shorthost($service['hostname'])) . '<br />
    <span class=service-down>Service Down</span>
    ' . $service['service_type'] . '<br />
    <span class=body-date-1>' . truncate($interface['ifAlias'], 20) . '</span>');
    ++$count_boxes;
}
// BGP neighbour down boxes
if (isset($config['enable_bgp']) && $config['enable_bgp']) {
    if (is_admin() === true || is_read() === true) {
        $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT " . $config['front_page_down_box_limit'];
    } else {
        $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND  bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT " . $config['front_page_down_box_limit'];
    }
    foreach (dbFetchRows($sql) as $peer) {
        generate_front_box('bgp-down', generate_device_link($peer, shorthost($peer['hostname'])) . "<br />\n    <span class=bgp-down>BGP Down</span>\n    <span class='" . (strstr($peer['bgpPeerIdentifier'], ':') ? 'front-page-bgp-small' : 'front-page-bgp-normal') . "'>" . $peer['bgpPeerIdentifier'] . '</span><br />
    <span class=body-date-1>AS' . truncate($peer['bgpPeerRemoteAs'] . ' ' . $peer['astext'], 14, '') . '</span>');
        ++$count_boxes;
    }
}
// Device rebooted boxes
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) {
    if (is_admin() === true || is_read() === true) {
        $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
    } else {
        $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
    }
    foreach (dbFetchRows($sql) as $device) {
        generate_front_box('device-rebooted', generate_device_link($device, shorthost($device['hostname'])) . '<br />
      <span class=device-rebooted>Device Rebooted</span><br />
      <span class=body-date-1>' . formatUptime($device['uptime'], 'short') . '</span>');
        ++$count_boxes;
/**
 * admin contents list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_contents_list()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define access variables */
    $table_new = TABLE_NEW;
    if (TABLE_PARAMETER == 'comments') {
        $articles_total = Redaxscript\Db::forTablePrefix('articles')->count();
        $articles_comments_disable = Redaxscript\Db::forTablePrefix('articles')->where('comments', 0)->count();
        if ($articles_total == $articles_comments_disable) {
            $table_new = 0;
        }
    }
    /* switch table */
    switch (TABLE_PARAMETER) {
        case 'categories':
            $wording_single = 'category';
            $wording_parent = 'category_parent';
            break;
        case 'articles':
            $wording_single = 'article';
            $wording_parent = 'category';
            break;
        case 'extras':
            $wording_single = 'extra';
            break;
        case 'comments':
            $wording_single = 'comment';
            $wording_parent = 'article';
            break;
    }
    /* query contents */
    $result = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->orderByAsc('rank')->findArray();
    $num_rows = count($result);
    /* collect listing output */
    $output .= '<h2 class="title_content">' . l(TABLE_PARAMETER) . '</h2>';
    $output .= '<div class="wrapper_button_admin">';
    if ($table_new == 1) {
        $output .= anchor_element('internal', '', 'button_admin button_plus_admin', l($wording_single . '_new'), 'admin/new/' . TABLE_PARAMETER);
    }
    if (TABLE_EDIT == 1 && $num_rows) {
        $output .= anchor_element('internal', '', 'button_admin button_sort_admin', l('sort'), 'admin/sort/' . TABLE_PARAMETER . '/' . TOKEN);
    }
    $output .= '</div><div class="wrapper_table_admin"><table class="table table_admin">';
    /* collect thead */
    $output .= '<thead><tr><th class="s3o6 column_first">' . l('title') . '</th><th class="';
    if (TABLE_PARAMETER != 'extras') {
        $output .= 's1o6';
    } else {
        $output .= 's3o6';
    }
    $output .= ' column_second">';
    if (TABLE_PARAMETER == 'comments') {
        $output .= l('identifier');
    } else {
        $output .= l('alias');
    }
    $output .= '</th>';
    if (TABLE_PARAMETER != 'extras') {
        $output .= '<th class="column_third">' . l($wording_parent) . '</th>';
    }
    $output .= '<th class="column_move column_last">' . l('rank') . '</th></tr></thead>';
    /* collect tfoot */
    $output .= '<tfoot><tr><td class="column_first">' . l('title') . '</td><td class="column_second">';
    if (TABLE_PARAMETER == 'comments') {
        $output .= l('identifier');
    } else {
        $output .= l('alias');
    }
    $output .= '</td>';
    if (TABLE_PARAMETER != 'extras') {
        $output .= '<td class="column_third">' . l($wording_parent) . '</td>';
    }
    $output .= '<td class="column_move column_last">' . l('rank') . '</td></tr></tfoot>';
    if ($result == '' || $num_rows == '') {
        $error = l($wording_single . '_no') . l('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            foreach ($result as $r) {
                $access = $r['access'];
                /* access granted */
                if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* prepare name */
                    if (TABLE_PARAMETER == 'comments') {
                        $name = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...');
                    } else {
                        $name = $title;
                    }
                    /* build class string */
                    if ($status == 1) {
                        $class_status = '';
                    } else {
                        $class_status = 'row_disabled';
                    }
                    /* build route */
                    if (TABLE_PARAMETER != 'extras' && $status == 1) {
                        if (TABLE_PARAMETER == 'categories' && $parent == 0 || TABLE_PARAMETER == 'articles' && $category == 0) {
                            $route = $alias;
                        } else {
                            $route = build_route(TABLE_PARAMETER, $id);
                        }
                    } else {
                        $route = '';
                    }
                    /* collect tbody output */
                    if (TABLE_PARAMETER == 'categories') {
                        if ($before != $parent) {
                            $output .= '<tbody><tr class="row_group"><td colspan="4">';
                            if ($parent) {
                                $output .= Redaxscript\Db::forTablePrefix('categories')->where('id', $parent)->findOne()->title;
                            } else {
                                $output .= l('none');
                            }
                            $output .= '</td></tr>';
                        }
                        $before = $parent;
                    }
                    if (TABLE_PARAMETER == 'articles') {
                        if ($before != $category) {
                            $output .= '<tbody><tr class="row_group"><td colspan="4">';
                            if ($category) {
                                $output .= Redaxscript\Db::forTablePrefix('categories')->where('id', $category)->findOne()->title;
                            } else {
                                $output .= l('uncategorized');
                            }
                            $output .= '</td></tr>';
                        }
                        $before = $category;
                    }
                    if (TABLE_PARAMETER == 'comments') {
                        if ($before != $article) {
                            $output .= '<tbody><tr class="row_group"><td colspan="4">';
                            if ($article) {
                                $output .= Redaxscript\Db::forTablePrefix('articles')->where('id', $article)->findOne()->title;
                            } else {
                                $output .= l('none');
                            }
                            $output .= '</td></tr>';
                        }
                        $before = $article;
                    }
                    /* collect table row */
                    $output .= '<tr';
                    if ($alias) {
                        $output .= ' id="' . $alias . '"';
                    }
                    if ($class_status) {
                        $output .= ' class="' . $class_status . '"';
                    }
                    $output .= '><td class="column_first">';
                    if ($language) {
                        $output .= '<span class="icon_flag language_' . $language . '" title="' . l($language) . '">' . $language . '</span>';
                    }
                    if ($status == 1) {
                        $output .= anchor_element('internal', '', 'link_view', $name, $route);
                    } else {
                        $output .= $name;
                    }
                    /* collect control output */
                    $output .= admin_control('contents', TABLE_PARAMETER, $id, $alias, $status, TABLE_NEW, TABLE_EDIT, TABLE_DELETE);
                    /* collect alias and id output */
                    $output .= '</td><td class="column_second">';
                    if (TABLE_PARAMETER == 'comments') {
                        $output .= $id;
                    } else {
                        $output .= $alias;
                    }
                    $output .= '</td>';
                    /* collect parent output */
                    if (TABLE_PARAMETER != 'extras') {
                        $output .= '<td class="column_third">';
                        if (TABLE_PARAMETER == 'categories') {
                            if ($parent) {
                                $parent_title = Redaxscript\Db::forTablePrefix('categories')->where('id', $parent)->findOne()->title;
                                $output .= anchor_element('internal', '', 'link_parent', $parent_title, 'admin/edit/categories/' . $parent);
                            } else {
                                $output .= l('none');
                            }
                        }
                        if (TABLE_PARAMETER == 'articles') {
                            if ($category) {
                                $category_title = Redaxscript\Db::forTablePrefix('categories')->where('id', $category)->findOne()->title;
                                $output .= anchor_element('internal', '', 'link_parent', $category_title, 'admin/edit/categories/' . $category);
                            } else {
                                $output .= l('uncategorized');
                            }
                        }
                        if (TABLE_PARAMETER == 'comments') {
                            if ($article) {
                                $article_title = Redaxscript\Db::forTablePrefix('articles')->where('id', $article)->findOne()->title;
                                $output .= anchor_element('internal', '', 'link_parent', $article_title, 'admin/edit/articles/' . $article);
                            } else {
                                $output .= l('none');
                            }
                        }
                        $output .= '</td>';
                    }
                    $output .= '<td class="column_move column_last">';
                    /* collect control output */
                    if (TABLE_EDIT == 1) {
                        $rank_desc = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->max('rank');
                        if ($rank > 1) {
                            $output .= anchor_element('internal', '', 'move_up', l('up'), 'admin/up/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN);
                        } else {
                            $output .= '<span class="move_up">' . l('up') . '</span>';
                        }
                        if ($rank < $rank_desc) {
                            $output .= anchor_element('internal', '', 'move_down', l('down'), 'admin/down/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN);
                        } else {
                            $output .= '<span class="move_down">' . l('down') . '</span>';
                        }
                        $output .= '</td>';
                    }
                    $output .= '</tr>';
                    /* collect tbody output */
                    if (TABLE_PARAMETER == 'categories') {
                        if ($before != $parent) {
                            $output .= '</tbody>';
                        }
                    }
                    if (TABLE_PARAMETER == 'articles') {
                        if ($before != $category) {
                            $output .= '</tbody>';
                        }
                    }
                    if (TABLE_PARAMETER == 'comments') {
                        if ($before != $article) {
                            $output .= '</tbody>';
                        }
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="4">' . $error . '</td></tr></tbody>';
    }
    $output .= '</table></div>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
Beispiel #30
0
function wpgrade_better_excerpt($text = '')
{
    global $post;
    $raw_excerpt = '';
    //if the post has a manual excerpt ignore the content given
    if ($text == '' && function_exists('has_excerpt') && has_excerpt()) {
        $text = get_the_excerpt();
        $raw_excerpt = $text;
        $text = strip_shortcodes($text);
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]&gt;', $text);
        // Removes any JavaScript in posts (between <script> and </script> tags)
        $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
        // Enable formatting in excerpts - Add HTML tags that you want to be parsed in excerpts
        $allowed_tags = '<p><a><strong><i><br><h1><h2><h3><h4><h5><h6><blockquote><ul><li><ol>';
        $text = strip_tags($text, $allowed_tags);
        //		$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        //		$text .= $excerpt_more;
    } else {
        if (empty($text)) {
            //need to grab the content
            $text = get_the_content();
        }
        $raw_excerpt = $text;
        $text = strip_shortcodes($text);
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]&gt;', $text);
        // Removes any JavaScript in posts (between <script> and </script> tags)
        $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
        // Enable formatting in excerpts - Add HTML tags that you want to be parsed in excerpts
        $allowed_tags = '<p><a><em><strong><i><br><h1><h2><h3><h4><h5><h6><blockquote><ul><li><ol><iframe><embed><object><script>';
        $text = strip_tags($text, $allowed_tags);
        // Set custom excerpt length - number of characters to be shown in excerpts
        if (wpgrade::option('blog_excerpt_length')) {
            $excerpt_length = absint(wpgrade::option('blog_excerpt_length'));
        } else {
            $excerpt_length = 180;
        }
        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        $options = array('ending' => $excerpt_more, 'exact' => false, 'html' => true);
        $text = truncate($text, $excerpt_length, $options);
    }
    // IMPORTANT! Prevents tags cutoff by excerpt (i.e. unclosed tags) from breaking formatting
    $text = force_balance_tags($text);
    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}