public static function get_formated_content()
 {
     $post = get_post();
     $content = get_the_content();
     //Apply "the_content" filter : formats shortcodes etc... :
     $content = apply_filters('the_content', $content);
     $content = str_replace(']]>', ']]>', $content);
     $allowed_tags = '<br/><br><p><div><h1><h2><h3><h4><h5><h6><a><span><sup><sub><img><i><em><strong><b><ul><ol><li><blockquote><pre>';
     /**
      * Filter allowed HTML tags for a given post.
      *
      * @param string 	$allowed_tags   A string containing the concatenated list of default allowed HTML tags.
      * @param WP_Post 	$post 			The post object.
      */
     $allowed_tags = apply_filters('wpak_post_content_allowed_tags', $allowed_tags, $post);
     $content = strip_tags($content, $allowed_tags);
     /**
      * Filter a single post content.
      *
      * To override (replace) this default formatting completely, use
      * "wpak_posts_list_post_content" and "wpak_page_content" filters.
      *
      * @param string 	$content   	The post content.
      * @param WP_Post 	$post 		The post object.
      */
     $content = apply_filters('wpak_post_content_format', $content, $post);
     return $content;
 }
function formatField($input)
{
    $input = strip_tags($input);
    $input = str_replace(";", ":", $input);
    $input = mysql_real_escape_string($input);
    return trim($input);
}
Example #3
0
 /**
  *
  */
 function show_list()
 {
     global $_GET;
     if ($_GET['phrase']) {
         $where .= sprintf('AND proverb LIKE \'%%%1$s%%\' ', $this->db->quote($_GET['phrase'], null, false));
     }
     $cols = 'proverb, meaning';
     $from = 'FROM proverb WHERE prv_type = 1 ' . $where . 'ORDER BY proverb ASC';
     $rows = $this->db->get_rows_paged($cols, $from);
     if ($this->db->num_rows > 0) {
         $ret .= '<p>' . $this->db->get_page_nav() . '</p>' . LF;
         $ret .= '<dl>';
         foreach ($rows as $row) {
             $ret .= '<dt>' . $row['proverb'] . '</dt>' . LF;
             $ret .= '<dd>' . LF;
             $ret .= nl2br(strip_tags($row['meaning'])) . LF;
             $ret .= '</dd>' . LF;
         }
         $ret .= '</dl>' . LF;
         $ret .= '<p>' . $this->db->get_page_nav() . '</p>' . LF;
     } else {
         $ret .= '<p>' . $this->msg['na'] . '</p>' . LF;
     }
     return $ret;
 }
Example #4
0
 /**
  * Register user.
  * @param array $data User details provided during the registration process.
  */
 public function register($data)
 {
     $user = $data['userData'];
     //validate provided data
     $errors = $this->validateUser($data);
     if (count($errors) == 0) {
         //no validation errors
         //generate email confirmation key
         $key = $this->_generateKey();
         MAIL_CONFIRMATION_REQUIRED === true ? $confirmed = 'N' : ($confirmed = 'Y');
         //insert new user to database
         $this->db->insert('as_users', array("email" => $user['email'], "username" => strip_tags($user['username']), "password" => $this->hashPassword($user['password']), "confirmed" => $confirmed, "confirmation_key" => $key, "register_date" => date("Y-m-d")));
         $userId = $this->db->lastInsertId();
         $this->db->insert('as_user_details', array('user_id' => $userId));
         //send confirmation email if needed
         if (MAIL_CONFIRMATION_REQUIRED) {
             $this->mailer->confirmationEmail($user['email'], $key);
             $msg = Lang::get('success_registration_with_confirm');
         } else {
             $msg = Lang::get('success_registration_no_confirm');
         }
         //prepare and output success message
         $result = array("status" => "success", "msg" => $msg);
         echo json_encode($result);
     } else {
         //there are validation errors
         //prepare result
         $result = array("status" => "error", "errors" => $errors);
         //output result
         echo json_encode($result);
     }
 }
 /**
  * The update callback for the widget control options.  This method is used to sanitize and/or
  * validate the options before saving them into the database.
  *
  * @since  0.6.0
  * @access public
  * @param  array  $new_instance
  * @param  array  $old_instance
  * @return array
  */
 function update($new_instance, $old_instance)
 {
     /* Strip tags. */
     $instance['title'] = strip_tags($new_instance['title']);
     /* Return sanitized options. */
     return $instance;
 }
 public function __construct($text)
 {
     $this->text = $text;
     $text = (string) $text;
     // преобразуем в строковое значение
     $text = strip_tags($text);
     // убираем HTML-теги
     $text = str_replace(array("\n", "\r"), " ", $text);
     // убираем перевод каретки
     $text = preg_replace("/\\s+/", ' ', $text);
     // удаляем повторяющие пробелы
     $text = trim($text);
     // убираем пробелы в начале и конце строки
     $text = mb_strtolower($text, 'utf-8');
     // переводим строку в нижний регистр
     $text = strtr($text, array('а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'e', 'ж' => 'j', 'з' => 'z', 'и' => 'y', 'і' => 'i', 'ї' => 'і', 'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shch', 'ы' => 'y', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', 'ъ' => '', 'ь' => ''));
     // в данном случае язык
     //будет укр.(изначально скрипт для русского яз.) поэтому некоторые буквы заменены или удалены, а именно ('и'=>'i')
     $text = preg_replace("/[^0-9a-z-_ ]/i", "", $text);
     // очищаем строку от недопустимых символов
     $text = str_replace(" ", "_", $text);
     // заменяем пробелы нижним подчеркиванием
     $text = str_replace("-", "_", $text);
     //заменяет минус на нижнее подчеркивание
     $this->translit = $text;
 }
Example #7
0
 function StripTags($out)
 {
     $out = strip_tags($out);
     $out = trim(preg_replace("~[\\s]+~", " ", $out));
     $out = str_ireplace("&#8230;", "", $out);
     return $out;
 }
Example #8
0
 public function pdt($txn)
 {
     $params = array('at' => $this->atPaypal, 'tx' => $txn, 'cmd' => '_notify-synch');
     $content = '';
     foreach ($params as $key => $val) {
         $content .= '&' . $key . '=' . urlencode($val);
     }
     $c = curl_init();
     curl_setopt($c, CURLOPT_URL, $this->paypalEndpoint);
     curl_setopt($c, CURLOPT_VERBOSE, TRUE);
     curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($c, CURLOPT_POST, 1);
     curl_setopt($c, CURLOPT_POSTFIELDS, $content);
     $response = curl_exec($c);
     if (!$response) {
         echo "FAILED: " . curl_error($c) . "(" . curl_errno($c) . ")";
         curl_close($c);
         return false;
     } else {
         $str = urldecode($response);
         $res = explode("\n", strip_tags($str));
         $result = array();
         foreach ($res as $val) {
             $r = explode("=", $val);
             if (count($r) > 1) {
                 $result[$r[0]] = $r[1];
             }
         }
         curl_close($c);
         return $result;
     }
 }
Example #9
0
function sanitizeString($_db, $str)
{
    $str = strip_tags($str);
    $str = htmlentities($str);
    $str = stripslashes($str);
    return mysqli_real_escape_string($_db, $str);
}
 public static function getRecordDataById($type, $id)
 {
     $sql = 'SELECT c.id, c.name, c.ctime, c.description, cv.view AS viewid, c.owner
     FROM {collectio}n c
     LEFT OUTER JOIN {collection_view} cv ON cv.collection = c.id
     WHERE id = ? ORDER BY cv.displayorder asc LIMIT 1;';
     $record = get_record_sql($sql, array($id));
     if (!$record) {
         return false;
     }
     $record->name = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->name));
     $record->description = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->description));
     //  Created by
     if (intval($record->owner) > 0) {
         $record->createdby = get_record('usr', 'id', $record->owner);
         $record->createdbyname = display_name($record->createdby);
     }
     // Get all views included in that collection
     $sql = 'SELECT v.id, v.title
     FROM {view} v
     LEFT OUTER JOIN {collection_view} cv ON cv.view = v.id
     WHERE cv.collection = ?';
     $views = recordset_to_array(get_recordset_sql($sql, array($id)));
     if ($views) {
         $record_views = array();
         foreach ($views as $view) {
             if (isset($view->id)) {
                 $record_views[$view->id] = $view->title;
             }
         }
         $record->views = $record_views;
     }
     return $record;
 }
Example #11
0
 function init(&$DIALOG)
 {
     global $WPRO_SESS, $EDITOR;
     $DIALOG->headContent->add('<link rel="stylesheet" href="core/plugins/wproCore_spellchecker/dialog.css" type="text/css" />');
     $DIALOG->headContent->add('<script type="text/javascript" src="core/plugins/wproCore_spellchecker/dialog_src.js"></script>');
     $DIALOG->headContent->add('<script type="text/javascript" src="core/js/wproCookies.js"></script>');
     $DIALOG->title = str_replace('...', '', $DIALOG->langEngine->get('editor', 'spelling'));
     $DIALOG->bodyInclude = WPRO_DIR . 'core/plugins/wproCore_spellchecker/dialog.tpl.php';
     require_once WPRO_DIR . 'conf/spellchecker.inc.php';
     require_once WPRO_DIR . 'core/plugins/wproCore_spellchecker/config.inc.php';
     // language
     if (!empty($EDITOR->htmlLang)) {
         $dictionary = $DIALOG->EDITOR->htmlLang;
     } else {
         $dictionary = $DIALOG->EDITOR->lang;
     }
     $DIALOG->template->assign('dictionary', $dictionary);
     //$DIALOG->template->assign('SPELLCHECKER_API', $SPELLCHECKER_API);
     $sid = $WPRO_SESS->sessionId;
     $wpsname = $WPRO_SESS->sessionName;
     $DIALOG->template->assign('sid', $WPRO_SESS->sessionId);
     $DIALOG->template->assign('wpsname', $WPRO_SESS->sessionName);
     //if ($SPELLCHECKER_API=='http') {
     //$authstring = '<input type="hidden" name="wpsid" value="'.base64_encode($EDITOR->_sessionId).'" />';
     //$DIALOG->template->assign('authenticationstring', $DIALOG->EDITOR->_jsEncode($authstring));
     //	$DIALOG->template->assign('spellcheckerURL', WPRO_CENTRAL_SPELLCHECKER_URL);
     //} else {
     $DIALOG->template->assign('spellcheckerURL', $EDITOR->editorLink('core/plugins/wproCore_spellchecker/checkSpelling.php?' . $wpsname . '=' . $sid . ($EDITOR->appendToQueryStrings ? '&' . $EDITOR->appendToQueryStrings : '') . ($EDITOR->appendSid ? strip_tags(defined('SID') ? '&' . SID : '') : '')));
     //}
     $DIALOG->options = array(array('onclick' => 'dialog.doFormSubmit()', 'type' => 'button', 'name' => 'ok', 'disabled' => 'disabled', 'value' => $DIALOG->langEngine->get('core', 'apply')), array('onclick' => 'dialog.close()', 'type' => 'button', 'name' => 'cancel', 'value' => $DIALOG->langEngine->get('core', 'cancel')));
 }
Example #12
0
 /**
  * Sanitize widget form values as they are saved.
  *
  * @see WP_Widget::update()
  *
  * @since 1.0
  *
  * @param array $new_instance Values just sent to be saved.
  * @param array $old_instance Previously saved values from database.
  *
  * @return array Updated safe values to be saved.
  */
 public function update($new_instance, $old_instance)
 {
     $instance = array();
     $new_instance = (array) $new_instance;
     if (!empty($new_instance['title'])) {
         $instance['title'] = strip_tags($new_instance['title']);
     }
     foreach (array('share', 'show_faces') as $bool_option) {
         if (isset($new_instance[$bool_option])) {
             $new_instance[$bool_option] = true;
         } else {
             $new_instance[$bool_option] = false;
         }
     }
     if (!class_exists('Facebook_Like_Button')) {
         require_once dirname(dirname(__FILE__)) . '/class-facebook-like-button.php';
     }
     $like_button = Facebook_Like_Button::fromArray($new_instance);
     if ($like_button) {
         if (!class_exists('Facebook_Like_Button_Settings')) {
             require_once dirname(dirname(dirname(__FILE__))) . '/admin/settings-like-button.php';
         }
         return array_merge($instance, Facebook_Like_Button_Settings::html_data_to_options($like_button->toHTMLDataArray()));
     }
     return $instance;
 }
 /**
  * Create a new job instance.
  *
  * @return void
  */
 public function __construct($keywords)
 {
     $this->username = \Request::server('PHP_AUTH_USER', 'sampleuser');
     $keywords = strip_tags(str_replace("'", " ", $keywords));
     $keywords = strtolower($keywords);
     $this->keywords = $keywords;
 }
Example #14
0
function clear_string($cl_str)
{
    $cl_str = strip_tags($cl_str);
    $cl_str = mysql_real_escape_string($cl_str);
    $cl_str = trim($cl_str);
    return $cl_str;
}
Example #15
0
 public function getKeywords($generateIfEmpty = true, $data = null)
 {
     $keywords = parent::getKeywords();
     if (!$generateIfEmpty) {
         return $keywords;
     }
     if ($keywords == null && $data != null) {
         $preg = '/<h[123456].*?>(.*?)<\\/h[123456]>/i';
         $content = str_replace("\n", "", str_replace("\r", "", $data));
         $pregCount = preg_match_all($preg, $content, $headers);
         $keywords = '';
         for ($i = 0; $i < $pregCount; $i++) {
             if ($keywords != '') {
                 $keywords .= ', ';
             }
             $item = trim(strip_tags($headers[0][$i]));
             if ($item == '') {
                 continue;
             }
             $keywords .= $item;
             if (mb_strlen($keywords) > 200) {
                 break;
             }
         }
     }
     if ($keywords == null && isset(Yii::app()->domain)) {
         $keywords = Yii::app()->domain->model->keywords;
     }
     return str_replace('@', '[at]', $keywords);
 }
Example #16
0
/**
 *
 * @param string $string
 * @param int $word_limit
 * @param string $ending
 * @return string
 */
function clean_text($string, $word_limit = 0, $ending = ' ...')
{
    //remove wp shortcodes
    $string = \strip_shortcodes($string);
    //adds a space before every tag open so we don't get heading/paragraphs glued together when we strip tags
    $string = str_replace('<', ' <', $string);
    //strip tags
    $string = strip_tags($string);
    //convert space entities to normal spaces to help out some users
    $string = str_replace('&nbsp;', ' ', $string);
    //convert to html entities
    $string = htmlspecialchars($string);
    //convert space entities to regular spaces so we can remove double spaces - all other hmtl entities should be fine
    $string = str_replace('&nbsp;', ' ', $string);
    //removes double spaces, tabs or line breaks, and trim the result
    $string = trim(mb_ereg_replace('\\s+', ' ', $string));
    //limit
    if ($word_limit) {
        $words = explode(' ', $string);
        if (count($words) > $word_limit) {
            array_splice($words, $word_limit);
            $string = implode(' ', $words) . $ending;
        }
    }
    return $string;
}
Example #17
0
 /**
  * Mail form contact site admin
  * @param senderName string senderName
  * @param senderEmail string senderEmail
  * @param senderSubject string senderSubject
  * @param senderMessage string senderMessage
  * @param email string config Email address
  * @param subject string header subject
  * @return bool
  **/
 public function contactform($senderName, $senderEmail, $senderSubject, $senderMessage)
 {
     $this->debug->append("STA " . __METHOD__, 4);
     if (preg_match('/[^a-z_\\.\\!\\?\\-0-9\\s ]/i', $senderName)) {
         $this->setErrorMessage($this->getErrorMsg('E0024'));
         return false;
     }
     if (empty($senderEmail) || !filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) {
         $this->setErrorMessage($this->getErrorMsg('E0023'));
         return false;
     }
     if (preg_match('/[^a-z_\\.\\!\\?\\-0-9\\s ]/i', $senderSubject)) {
         $this->setErrorMessage($this->getErrorMsg('E0034'));
         return false;
     }
     if (strlen(strip_tags($senderMessage)) < strlen($senderMessage)) {
         $this->setErrorMessage($this->getErrorMsg('E0024'));
         return false;
     }
     $aData['senderName'] = $senderName;
     $aData['senderEmail'] = $senderEmail;
     $aData['senderSubject'] = $senderSubject;
     $aData['senderMessage'] = $senderMessage;
     $aData['email'] = $this->setting->getValue('website_email', '*****@*****.**');
     $aData['subject'] = 'Contact Form';
     if ($this->sendMail('contactform/body', $aData)) {
         return true;
     } else {
         $this->setErrorMessage('Unable to send email');
         return false;
     }
     return false;
 }
 private function _genericReplacements()
 {
     $this->_doc_content = strip_tags($this->_doc_content);
     $this->_doc_content = ltrim(rtrim($this->_doc_content));
     $this->_doc_content = mb_strtolower($this->_doc_content, $this->_charset);
     // Remove dots between chars (for things like urls)
     $this->_doc_content = $this->_my_preg_replace("/([a-z]{1})[\\.]+([a-z]{1})/", "\$1\$2", $this->_doc_content);
     // ? Remove all html entities
     // $this->_doc_content = $this->_my_preg_replace("/&[#|a-z|0-9]+;/", " ", $this->_doc_content);
     // Decode all html entities
     $this->_doc_content = html_entity_decode($this->_doc_content, ENT_COMPAT, $this->_charset);
     // Replace multiple spaces chars with just one space
     $this->_doc_content = $this->_my_preg_replace("/[\\s|\t|\n|\r]+/", " ", $this->_doc_content);
     // Remove dots, dashes and spaces between digits
     $this->_doc_content = $this->_my_preg_replace("/([0-9]{1})[\\.|\\s|\\-]+([0-9]{1})/", "\$1\$2", $this->_doc_content);
     // Remove spaces after sentences and replace multiple dots with just one dot
     $this->_doc_content = $this->_my_preg_replace("/[\\.]+ /", ".", $this->_doc_content);
     // The same for sentences ending with question marks
     $this->_doc_content = $this->_my_preg_replace("/[\\?]+ /", ".", $this->_doc_content);
     // The same for "!"
     $this->_doc_content = $this->_my_preg_replace("/[\\!]+ /", ".", $this->_doc_content);
     // Remove all non-alphanumeric characters except for spaces and dots
     //        $this->_doc_content = $this->_my_preg_replace("/[^a-z|&#1072;-&#1103;|^\.|^\d|^\s|^@]+/i", "", $this->_doc_content);
     return $this;
 }
/**
 * Smarty strip_tags modifier plugin
 *
 * Type:    modifier
 * Name:    strip_tags
 * Purpose: strip html tags from text
 * @link    http://www.smarty.net/manual/en/language.modifier.strip.tags.php
 *          strip_tags (Smarty online manual)
 *
 * @author  Monte Ohrt <monte at="" ohrt="" dot="" com="">
 * @author  Jordon Mears <jordoncm at="" gmail="" dot="" com="">
 *
 * @version 2.0
 *
 * @param   string
 * @param   boolean optional
 * @param   string optional
 * @return  string
 */
function smarty_modifier_stripTags($string)
{
    switch (func_num_args()) {
        case 1:
            $replace_with_space = true;
            break;
        case 2:
            $arg = func_get_arg(1);
            if ($arg === 1 || $arg === true || $arg === '1' || $arg === 'true') {
                // for full legacy support || $arg === 'false' should be included
                $replace_with_space = true;
                $allowable_tags = '';
            } elseif ($arg === 0 || $arg === false || $arg === '0' || $arg === 'false') {
                // for full legacy support || $arg === 'false' should be removed
                $replace_with_space = false;
                $allowable_tags = '';
            } else {
                $replace_with_space = true;
                $allowable_tags = $arg;
            }
            break;
        case 3:
            $replace_with_space = func_get_arg(1);
            $allowable_tags = func_get_arg(2);
            break;
    }
    if ($replace_with_space) {
        $string = preg_replace('!(<[^>]*?>)!', '$1 ', $string);
    }
    $string = strip_tags($string, $allowable_tags);
    if ($replace_with_space) {
        $string = preg_replace('!(<[^>]*?>) !', '$1', $string);
    }
    return $string;
}
Example #20
0
 public function viewthread_modoption()
 {
     global $_G;
     if (!$_G['adminid']) {
         return false;
     }
     $usergroupsfeedlist = unserialize($_G['setting']['qqgroup_usergroup_feed_list']);
     if (empty($usergroupsfeedlist) || !in_array($_G['groupid'], $usergroupsfeedlist)) {
         if (self::$util->isfounder($_G['member']) == false) {
             return false;
         }
     }
     $tid = $_G['tid'];
     $title = urlencode(trim($_G['forum_thread']['subject']));
     $post = C::t('forum_post')->fetch_all_by_tid_position($_G['fotum_thread']['posttableid'], $_G['tid'], 1);
     include_once libfile('function/discuzcode');
     $content = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", '', trim($post[0]['message']));
     $content = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", '', $content);
     $content = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", '', $content);
     $content = preg_replace("/\\[hide[=]?(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", '', $content);
     $content = strip_tags(discuzcode($content, 0, 0, 0));
     $content = preg_replace('%\\[attach\\].*\\[/attach\\]%im', '', $content);
     $content = str_replace('&nbsp;', ' ', $content);
     $content = urlencode(cutstr($content, 50, ''));
     include template('qqgroup:push');
     return trim($return);
 }
Example #21
0
    public function meta_box()
    {
        add_action('add_meta_boxes', function () {
            // css id, title, cb func, page, priority, cb func arug
            add_meta_box("address", "Address", "address", "mjs_testimonial");
        });
        function address($post)
        {
            $meta_biography = get_post_meta($post->ID, 'mjs_address', true);
            ?>

        <p>

            <label for="gsize">Address</label>

            <input class="widefat" type="text" name="mjs_address" id="address" value="<?php 
            echo $meta_biography;
            ?>
" />

        </p>

        <?php 
        }
        add_action('save_post', function ($id) {
            if (isset($_POST['mjs_address'])) {
                update_post_meta($id, 'mjs_address', strip_tags($_POST['mjs_address']));
            }
        });
    }
Example #22
0
 public function updateDescription()
 {
     if ($this->content == null) {
         return;
     }
     $this->description = str_limit(strip_tags($this->content), 200);
 }
 function fetchTagIntoArray($tag = "<img>")
 {
     $this->tag = $tag;
     $data = $this->strip_text($this->source);
     $data = ">" . $data;
     //echo $data."END_HTML";
     $striped_data = strip_tags($data, $this->tag);
     $this->outputTagArray = explode("><", $striped_data);
     $my_array = $this->outputTagArray;
     $count = 0;
     $stat = false;
     foreach ($my_array as $main_key => $main_value) {
         $my_space_array[$main_key] = explode(" ", $main_value);
         foreach ($my_space_array[$main_key] as $sub_key => $sub_value) {
             $my_pre_fetched_tag_array = explode("=", $sub_value);
             // check for null attributes ...
             //echo $main_key.": ".$my_pre_fetched_tag_array[1]."</br>";
             if ($my_pre_fetched_tag_array[1] != '""' && $my_pre_fetched_tag_array[1] != NULL) {
                 $my_tag_array[$count][$my_pre_fetched_tag_array[0]] = $my_pre_fetched_tag_array[1];
                 $stat = true;
             }
         }
         if ($stat) {
             $count++;
             $stat = false;
         }
     }
     $this->outputTagArray = $my_tag_array;
     return $this->outputTagArray;
 }
 public function actionView()
 {
     $radioId = Yii::app()->request->getParam("id", 0);
     $radioName = WapRadioModel::model()->findByPk($radioId)->name;
     $albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id");
     $radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1');
     $album = WapAlbumModel::model()->published()->findByPk($albumId);
     if (!$album) {
         $this->forward("/site/error", true);
     }
     $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId);
     $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId);
     $phone = yii::app()->user->getState('msisdn');
     $errorCode = 'success';
     $errorDescription = '';
     $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
     ///meta tag
     $AlbumDetail = AlbumModel::model()->findByPk($albumId);
     $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id;
     $ArtistInfo = ArtistModel::model()->findByPk($artistId);
     $this->itemName = $AlbumDetail->name;
     $this->artist = $ArtistInfo->name;
     $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1');
     $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name));
     $this->description = strip_tags($AlbumDetail->description);
     //get other radio
     $parent_id = Yii::app()->params['horoscope']['parent_id'];
     $radioListOther = WapRadioModel::model()->getHoroscopes($parent_id);
     $this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar));
 }
 public function save($curpass, $passwd)
 {
     $rcmail = rcmail::get_instance();
     $Socket = new HTTPSocket();
     $da_user = $_SESSION['username'];
     $da_curpass = $curpass;
     $da_newpass = $passwd;
     $da_host = $rcmail->config->get('password_directadmin_host');
     $da_port = $rcmail->config->get('password_directadmin_port');
     if (strpos($da_user, '@') === false) {
         return array('code' => PASSWORD_ERROR, 'message' => 'Change the SYSTEM user password through control panel!');
     }
     $da_host = str_replace('%h', $_SESSION['imap_host'], $da_host);
     $da_host = str_replace('%d', $rcmail->user->get_username('domain'), $da_host);
     $Socket->connect($da_host, $da_port);
     $Socket->set_method('POST');
     $Socket->query('/CMD_CHANGE_EMAIL_PASSWORD', array('email' => $da_user, 'oldpassword' => $da_curpass, 'password1' => $da_newpass, 'password2' => $da_newpass, 'api' => '1'));
     $response = $Socket->fetch_parsed_body();
     //DEBUG
     //rcube::console("Password Plugin: [USER: $da_user] [HOST: $da_host] - Response: [SOCKET: ".$Socket->result_status_code."] [DA ERROR: ".strip_tags($response['error'])."] [TEXT: ".$response[text]."]");
     if ($Socket->result_status_code != 200) {
         return array('code' => PASSWORD_CONNECT_ERROR, 'message' => $Socket->error[0]);
     } elseif ($response['error'] == 1) {
         return array('code' => PASSWORD_ERROR, 'message' => strip_tags($response['text']));
     } else {
         return PASSWORD_SUCCESS;
     }
 }
 public function get_info($base)
 {
     $sitename = $this->sitename($base);
     $c = new Crawler($base);
     $c->go_to('id="listing"');
     $list = array();
     while ($line = $c->readline()) {
         if (Crawler::is_there($line, 'class="chico_')) {
             if (!Crawler::is_there($line, ' href="')) {
                 $line = $c->readline();
             }
             $chp = Crawler::extract($line, 'href="', '"');
             $ifx = Crawler::cutfromlast1($chp, '/');
             $ifx = str_replace('chapter-', '', $ifx);
             $ifx = str_replace('.html', '', $ifx);
             $list[] = array('url' => $sitename . $chp, 'infix' => $ifx, 'desc' => strip_tags(Crawler::extract($line, '">', '</td>')));
         } else {
             if (Crawler::is_there($line, '</table>')) {
                 break;
             }
         }
     }
     $c->close();
     return array_reverse($list);
 }
/**
 * 修复http响应拆分漏洞(php < 5.4 ?)。暂时按照360网站安全检测的建议方案进行修正,虽然感觉strip_tags并非必须。
 * @link http://thread.gmane.org/gmane.comp.php.devel/70584
 * @link https://bugs.php.net/bug.php?id=60227
 * @author Horse Luke
 * @version 0.1 build 20131021
 */
function fix_http_header_inject($str)
{
    if (empty($str)) {
        return $str;
    }
    return trim(strip_tags(preg_replace('/( |\\t|\\r|\\n|\')/', '', $str)));
}
/**
 * http://www.php.net/manual/en/function.phpinfo.php
 * code at adspeed dot com
 * 09-Dec-2005 11:31
 * This function parses the phpinfo output to get details about a PHP module.
 */
function ckeditor_parse_php_info()
{
    ob_start();
    phpinfo(INFO_MODULES);
    $s = ob_get_contents();
    ob_end_clean();
    $s = strip_tags($s, '<h2><th><td>');
    $s = preg_replace('/<th[^>]*>([^<]+)<\\/th>/', "<info>\\1</info>", $s);
    $s = preg_replace('/<td[^>]*>([^<]+)<\\/td>/', "<info>\\1</info>", $s);
    $vTmp = preg_split('/(<h2>[^<]+<\\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
    $vModules = array();
    for ($i = 1; $i < count($vTmp); $i++) {
        if (preg_match('/<h2>([^<]+)<\\/h2>/', $vTmp[$i], $vMat)) {
            $vName = trim($vMat[1]);
            $vTmp2 = explode("\n", $vTmp[$i + 1]);
            foreach ($vTmp2 as $vOne) {
                $vPat = '<info>([^<]+)<\\/info>';
                $vPat3 = "/{$vPat}\\s*{$vPat}\\s*{$vPat}/";
                $vPat2 = "/{$vPat}\\s*{$vPat}/";
                if (preg_match($vPat3, $vOne, $vMat)) {
                    // 3cols
                    $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]), trim($vMat[3]));
                } elseif (preg_match($vPat2, $vOne, $vMat)) {
                    // 2cols
                    $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
                }
            }
        }
    }
    return $vModules;
}
 public function getPosition($from = 1, $count = 1)
 {
     $console = Console::getInstance();
     $console->operationStart('Collecting search results');
     $this->pageNumber = ceil($from / $this->positionsPerPage);
     if ($count < 1 || $count > 10) {
         $console->operationEnd();
         $console - error('Count must be in 1-10. ' . $count . ' is setted');
         return false;
     }
     $sites = array();
     $position = 1;
     do {
         $console->operationStep();
         $pageResults = $this->getPageResults();
         foreach ($pageResults as $pr) {
             $sitesCount = count($sites);
             $domain = ($domain = String::rebuildUrl($pr->url, false, false, true, false)) ? $domain : $pr->url;
             if (IgnoreList::isInList($domain) || $sitesCount && $sites[$sitesCount - 1]->domain == $domain) {
                 continue;
             }
             $site = new Site();
             $site->name = strip_tags($pr->title);
             $site->position = $position++;
             $site->link = $pr->url;
             $site->domain = $domain;
             $sites[] = $site;
         }
         $this->pageNumber++;
     } while ($sitesCount < $count);
     //$this->pageNumber++ * $this->positionsPerPage < $count // old
     $console->operationEnd();
     return array_slice($sites, 0, $count);
 }
 /**
  * clean the comment text field from html, in order to use it as submitted text
  * uses the htmlpurifier library, or a simple strip_tags call, based on the app.yml config file
  *
  * @return String
  * @param  String - the text to be cleaned
  *
  * @author Guglielmo Celata
  * @see    http://htmlpurifier.org/
  **/
 public static function clean($text)
 {
     $allowed_html_tags = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_allowed_tags', array());
     $use_htmlpurifier = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_use_htmlpurifier', false);
     if ($use_htmlpurifier) {
         $htmlpurifier_path = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_htmlpurifier_path', SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR);
         require_once $htmlpurifier_path . 'HTMLPurifier.auto.php';
         $config = HTMLPurifier_Config::createDefault();
         $config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
         $config->set('HTML', 'Allowed', implode(',', array_keys($allowed_html_tags)));
         if (isset($allowed_html_tags['a'])) {
             $config->set('HTML', 'AllowedAttributes', 'a.href');
             $config->set('AutoFormat', 'Linkify', true);
         }
         if (isset($allowed_html_tags['p'])) {
             $config->set('AutoFormat', 'AutoParagraph', true);
         }
         $purifier = new HTMLPurifier($config);
         $clean_text = $purifier->purify($text);
     } else {
         $allowed_html_tags_as_string = "";
         foreach ($allowed_html_tags as $tag) {
             $allowed_html_tags_as_string .= "{$tag}";
         }
         $clean_text = strip_tags($text, $allowed_html_tags_as_string);
     }
     return $clean_text;
 }