├── .gitignore ├── MIT.txt ├── Object.php ├── admin.php ├── aggregate.php ├── autoloader.php ├── db ├── .gitignore ├── DBField.php ├── README.txt ├── SQLiteManager.php ├── SQLiteManagerConfig.inc ├── dbinit.php └── feeds.sqlite ├── doxygen.conf ├── functions.php ├── index.php ├── library ├── SimplePie.php └── SimplePie │ ├── Author.php │ ├── Cache.php │ ├── Cache │ ├── Base.php │ ├── DB.php │ ├── File.php │ ├── Memcache.php │ └── MySQL.php │ ├── Caption.php │ ├── Category.php │ ├── Content │ └── Type │ │ └── Sniffer.php │ ├── Copyright.php │ ├── Core.php │ ├── Credit.php │ ├── Decode │ └── HTML │ │ └── Entities.php │ ├── Enclosure.php │ ├── File.php │ ├── HTTP │ └── Parser.php │ ├── IRI.php │ ├── Item.php │ ├── Locator.php │ ├── Misc.php │ ├── Net │ └── IPv6.php │ ├── Parse │ └── Date.php │ ├── Parser.php │ ├── Rating.php │ ├── Registry.php │ ├── Restriction.php │ ├── Sanitize.php │ ├── Source.php │ ├── XML │ └── Declaration │ │ └── Parser.php │ └── gzdecode.php ├── postback.php ├── readme.md ├── smarty ├── Smarty.class.php ├── debug.tpl ├── plugins │ ├── block.php.php │ ├── block.textformat.php │ ├── function.counter.php │ ├── function.cycle.php │ ├── function.fetch.php │ ├── function.html_checkboxes.php │ ├── function.html_image.php │ ├── function.html_options.php │ ├── function.html_radios.php │ ├── function.html_select_date.php │ ├── function.html_select_time.php │ ├── function.html_table.php │ ├── function.mailto.php │ ├── function.math.php │ ├── function.popup.php │ ├── function.popup_init.php │ ├── modifier.capitalize.php │ ├── modifier.date_format.php │ ├── modifier.debug_print_var.php │ ├── modifier.escape.php │ ├── modifier.regex_replace.php │ ├── modifier.replace.php │ ├── modifier.spacify.php │ ├── modifier.truncate.php │ ├── modifiercompiler.cat.php │ ├── modifiercompiler.count_characters.php │ ├── modifiercompiler.count_paragraphs.php │ ├── modifiercompiler.count_sentences.php │ ├── modifiercompiler.count_words.php │ ├── modifiercompiler.default.php │ ├── modifiercompiler.indent.php │ ├── modifiercompiler.lower.php │ ├── modifiercompiler.noprint.php │ ├── modifiercompiler.string_format.php │ ├── modifiercompiler.strip.php │ ├── modifiercompiler.strip_tags.php │ ├── modifiercompiler.upper.php │ ├── modifiercompiler.wordwrap.php │ ├── outputfilter.trimwhitespace.php │ ├── shared.escape_special_chars.php │ ├── shared.make_timestamp.php │ ├── shared.mb_str_replace.php │ └── variablefilter.htmlspecialchars.php └── sysplugins │ ├── smarty_internal_cacheresource_file.php │ ├── smarty_internal_compile_append.php │ ├── smarty_internal_compile_assign.php │ ├── smarty_internal_compile_block.php │ ├── smarty_internal_compile_break.php │ ├── smarty_internal_compile_call.php │ ├── smarty_internal_compile_capture.php │ ├── smarty_internal_compile_config_load.php │ ├── smarty_internal_compile_continue.php │ ├── smarty_internal_compile_debug.php │ ├── smarty_internal_compile_eval.php │ ├── smarty_internal_compile_extends.php │ ├── smarty_internal_compile_for.php │ ├── smarty_internal_compile_foreach.php │ ├── smarty_internal_compile_function.php │ ├── smarty_internal_compile_if.php │ ├── smarty_internal_compile_include.php │ ├── smarty_internal_compile_include_php.php │ ├── smarty_internal_compile_insert.php │ ├── smarty_internal_compile_ldelim.php │ ├── smarty_internal_compile_nocache.php │ ├── smarty_internal_compile_private_block_plugin.php │ ├── smarty_internal_compile_private_function_plugin.php │ ├── smarty_internal_compile_private_modifier.php │ ├── smarty_internal_compile_private_object_block_function.php │ ├── smarty_internal_compile_private_object_function.php │ ├── smarty_internal_compile_private_print_expression.php │ ├── smarty_internal_compile_private_registered_block.php │ ├── smarty_internal_compile_private_registered_function.php │ ├── smarty_internal_compile_private_special_variable.php │ ├── smarty_internal_compile_rdelim.php │ ├── smarty_internal_compile_section.php │ ├── smarty_internal_compile_while.php │ ├── smarty_internal_compilebase.php │ ├── smarty_internal_config.php │ ├── smarty_internal_config_file_compiler.php │ ├── smarty_internal_configfilelexer.php │ ├── smarty_internal_configfileparser.php │ ├── smarty_internal_data.php │ ├── smarty_internal_debug.php │ ├── smarty_internal_filter.php │ ├── smarty_internal_filter_handler.php │ ├── smarty_internal_function_call_handler.php │ ├── smarty_internal_get_include_path.php │ ├── smarty_internal_nocache_insert.php │ ├── smarty_internal_parsetree.php │ ├── smarty_internal_register.php │ ├── smarty_internal_resource_eval.php │ ├── smarty_internal_resource_extends.php │ ├── smarty_internal_resource_file.php │ ├── smarty_internal_resource_php.php │ ├── smarty_internal_resource_registered.php │ ├── smarty_internal_resource_stream.php │ ├── smarty_internal_resource_string.php │ ├── smarty_internal_smartytemplatecompiler.php │ ├── smarty_internal_template.php │ ├── smarty_internal_templatecompilerbase.php │ ├── smarty_internal_templatelexer.php │ ├── smarty_internal_templateparser.php │ ├── smarty_internal_utility.php │ ├── smarty_internal_wrapper.php │ ├── smarty_internal_write_file.php │ └── smarty_security.php ├── templates ├── admin.tpl └── page.tpl └── test.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.xml 3 | *.atom 4 | templates_c 5 | documentation 6 | -------------------------------------------------------------------------------- /MIT.txt: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. -------------------------------------------------------------------------------- /Object.php: -------------------------------------------------------------------------------- 1 | $name; 35 | } elseif(property_exists($this, $name."_")) { 36 | return $this->{$name."_"}; 37 | } else { 38 | $trace = debug_backtrace(); 39 | trigger_error('Undefined property via __get(): '.$name.' on '.get_class($this).' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_NOTICE); 40 | debug_print_backtrace(); 41 | return null; 42 | } 43 | } 44 | 45 | /** 46 | * Fake write only properties 47 | * 48 | * @param STRING $name Name of the property to get. 49 | * @param MIXED $value Value of the property $name (if it existed). 50 | */ 51 | public function __set($name, $value) { 52 | $name .= "_"; 53 | if(property_exists($this, $name)) { 54 | $this->$name = $value; 55 | } else { 56 | $trace = debug_backtrace(); 57 | trigger_error('Undefined property via __set(): '.substr($name, 0, -1).' on '.get_class($this).' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_NOTICE); 58 | debug_print_backtrace(); 59 | } 60 | } 61 | 62 | /** 63 | * Returns a string that's somewhat useful for debugging purposes. 64 | * 65 | * @return STRING Debug string. 66 | */ 67 | public function __toString() { 68 | return "Instance of ".get_class($this); 69 | } 70 | } 71 | ?> -------------------------------------------------------------------------------- /admin.php: -------------------------------------------------------------------------------- 1 | select("feeds"); 12 | $feeds = $db->fetchArray($result); 13 | 14 | $result = $db->select("aggregateFeeds"); 15 | $aggregates = $db->fetchArray($result); 16 | 17 | foreach($feeds as &$feed) { 18 | $result = $db->select("filters", null, ["feedID"=>$feed["ID"]]); 19 | $feed["patterns"] = $db->fetchArray($result); 20 | } 21 | 22 | //DISPLAY 23 | $smarty = new Smarty(); 24 | $smarty->auto_literal = true; 25 | $data = new Smarty_Data(); 26 | $data->assign("fields", $fields); 27 | $data->assign("feeds", $feeds); 28 | $data->assign("aggregates", $aggregates); 29 | $data->assign("base_url", "//".$_SERVER[HTTP_HOST].substr($_SERVER[REQUEST_URI],0,strrpos($_SERVER[REQUEST_URI],"/"))); 30 | $smarty->display("admin.tpl", $data); 31 | ?> -------------------------------------------------------------------------------- /autoloader.php: -------------------------------------------------------------------------------- 1 | path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library'; 68 | } 69 | 70 | /** 71 | * Autoloader 72 | * 73 | * @param string $class The name of the class to attempt to load. 74 | */ 75 | public function autoload($class) 76 | { 77 | // Only load the class if it starts with "SimplePie" 78 | if (strpos($class, 'SimplePie') !== 0) 79 | { 80 | return; 81 | } 82 | 83 | $filename = $this->path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; 84 | include $filename; 85 | } 86 | } -------------------------------------------------------------------------------- /db/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.inc 3 | test.php 4 | -------------------------------------------------------------------------------- /db/README.txt: -------------------------------------------------------------------------------- 1 | Create a file SQLiteManagerConfig.inc in the db/ folder. 2 | 8 | -------------------------------------------------------------------------------- /db/SQLiteManagerConfig.inc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /db/dbinit.php: -------------------------------------------------------------------------------- 1 | createTable("feeds", $fields); 29 | 30 | $fields = []; 31 | $fields[] = new DBField("feeds", DBField::STRING); 32 | $db->createTable("aggregateFeeds", $fields); 33 | 34 | $fields = []; 35 | $fields[] = new DBField("feedID", DBField::NUM, -1, "feeds", "ID"); 36 | $fields[] = new DBField("field", DBField::STRING); 37 | $fields[] = new DBField("regex", DBField::STRING); 38 | $db->createTable("filters", $fields); 39 | 40 | //errorLog 41 | $fields = []; 42 | $fields[] = new DBField("query", DBField::STRING); 43 | $fields[] = new DBField("error", DBField::STRING); 44 | $fields[] = new DBField("date", DBField::NUM); 45 | $db->createTable("errorLog", $fields); 46 | ?> -------------------------------------------------------------------------------- /db/feeds.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bionoren/rssFilter/01e3fbed4135c417f2f3574ada08b83beaf66564/db/feeds.sqlite -------------------------------------------------------------------------------- /library/SimplePie/Author.php: -------------------------------------------------------------------------------- 1 | name = $name; 91 | $this->link = $link; 92 | $this->email = $email; 93 | } 94 | 95 | /** 96 | * String-ified version 97 | * 98 | * @return string 99 | */ 100 | public function __toString() 101 | { 102 | // There is no $this->data here 103 | return md5(serialize($this)); 104 | } 105 | 106 | /** 107 | * Author's name 108 | * 109 | * @return string|null 110 | */ 111 | public function get_name() 112 | { 113 | if ($this->name !== null) 114 | { 115 | return $this->name; 116 | } 117 | else 118 | { 119 | return null; 120 | } 121 | } 122 | 123 | /** 124 | * Author's link 125 | * 126 | * @return string|null 127 | */ 128 | public function get_link() 129 | { 130 | if ($this->link !== null) 131 | { 132 | return $this->link; 133 | } 134 | else 135 | { 136 | return null; 137 | } 138 | } 139 | 140 | /** 141 | * Author's email address 142 | * 143 | * @return string|null 144 | */ 145 | public function get_email() 146 | { 147 | if ($this->email !== null) 148 | { 149 | return $this->email; 150 | } 151 | else 152 | { 153 | return null; 154 | } 155 | } 156 | } 157 | 158 | -------------------------------------------------------------------------------- /library/SimplePie/Cache.php: -------------------------------------------------------------------------------- 1 | 'SimplePie_Cache_MySQL', 66 | 'memcache' => 'SimplePie_Cache_Memcache', 67 | ); 68 | 69 | /** 70 | * Don't call the constructor. Please. 71 | */ 72 | private function __construct() { } 73 | 74 | /** 75 | * Create a new SimplePie_Cache object 76 | * 77 | * @param string $location URL location (scheme is used to determine handler) 78 | * @param string $filename Unique identifier for cache object 79 | * @param string $extension 'spi' or 'spc' 80 | * @return SimplePie_Cache_Base Type of object depends on scheme of `$location` 81 | */ 82 | public static function create($location, $filename, $extension) 83 | { 84 | $type = explode(':', $location, 2); 85 | $type = $type[0]; 86 | if (!empty(self::$handlers[$type])) 87 | { 88 | $class = self::$handlers[$type]; 89 | return new $class($location, $filename, $extension); 90 | } 91 | 92 | return new SimplePie_Cache_File($location, $filename, $extension); 93 | } 94 | 95 | /** 96 | * Register a handler 97 | * 98 | * @param string $type DSN type to register for 99 | * @param string $class Name of handler class. Must implement SimplePie_Cache_Base 100 | */ 101 | public static function register($type, $class) 102 | { 103 | self::$handlers[$type] = $class; 104 | } 105 | 106 | /** 107 | * Parse a URL into an array 108 | * 109 | * @param string $url 110 | * @return array 111 | */ 112 | public static function parse_URL($url) 113 | { 114 | $params = parse_url($url); 115 | $params['extras'] = array(); 116 | if (isset($params['query'])) 117 | { 118 | parse_str($params['query'], $params['extras']); 119 | } 120 | return $params; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /library/SimplePie/Cache/Base.php: -------------------------------------------------------------------------------- 1 | term = $term; 91 | $this->scheme = $scheme; 92 | $this->label = $label; 93 | } 94 | 95 | /** 96 | * String-ified version 97 | * 98 | * @return string 99 | */ 100 | public function __toString() 101 | { 102 | // There is no $this->data here 103 | return md5(serialize($this)); 104 | } 105 | 106 | /** 107 | * Get the category identifier 108 | * 109 | * @return string|null 110 | */ 111 | public function get_term() 112 | { 113 | if ($this->term !== null) 114 | { 115 | return $this->term; 116 | } 117 | else 118 | { 119 | return null; 120 | } 121 | } 122 | 123 | /** 124 | * Get the categorization scheme identifier 125 | * 126 | * @return string|null 127 | */ 128 | public function get_scheme() 129 | { 130 | if ($this->scheme !== null) 131 | { 132 | return $this->scheme; 133 | } 134 | else 135 | { 136 | return null; 137 | } 138 | } 139 | 140 | /** 141 | * Get the human readable label 142 | * 143 | * @return string|null 144 | */ 145 | public function get_label() 146 | { 147 | if ($this->label !== null) 148 | { 149 | return $this->label; 150 | } 151 | else 152 | { 153 | return $this->get_term(); 154 | } 155 | } 156 | } 157 | 158 | -------------------------------------------------------------------------------- /library/SimplePie/Copyright.php: -------------------------------------------------------------------------------- 1 | ` copyright tags as defined in Media RSS 47 | * 48 | * Used by {@see SimplePie_Enclosure::get_copyright()} 49 | * 50 | * This class can be overloaded with {@see SimplePie::set_copyright_class()} 51 | * 52 | * @package SimplePie 53 | * @subpackage API 54 | */ 55 | class SimplePie_Copyright 56 | { 57 | /** 58 | * Copyright URL 59 | * 60 | * @var string 61 | * @see get_url() 62 | */ 63 | var $url; 64 | 65 | /** 66 | * Attribution 67 | * 68 | * @var string 69 | * @see get_attribution() 70 | */ 71 | var $label; 72 | 73 | /** 74 | * Constructor, used to input the data 75 | * 76 | * For documentation on all the parameters, see the corresponding 77 | * properties and their accessors 78 | */ 79 | public function __construct($url = null, $label = null) 80 | { 81 | $this->url = $url; 82 | $this->label = $label; 83 | } 84 | 85 | /** 86 | * String-ified version 87 | * 88 | * @return string 89 | */ 90 | public function __toString() 91 | { 92 | // There is no $this->data here 93 | return md5(serialize($this)); 94 | } 95 | 96 | /** 97 | * Get the copyright URL 98 | * 99 | * @return string|null URL to copyright information 100 | */ 101 | public function get_url() 102 | { 103 | if ($this->url !== null) 104 | { 105 | return $this->url; 106 | } 107 | else 108 | { 109 | return null; 110 | } 111 | } 112 | 113 | /** 114 | * Get the attribution text 115 | * 116 | * @return string|null 117 | */ 118 | public function get_attribution() 119 | { 120 | if ($this->label !== null) 121 | { 122 | return $this->label; 123 | } 124 | else 125 | { 126 | return null; 127 | } 128 | } 129 | } 130 | 131 | -------------------------------------------------------------------------------- /library/SimplePie/Core.php: -------------------------------------------------------------------------------- 1 | ` as defined in Media RSS 47 | * 48 | * Used by {@see SimplePie_Enclosure::get_credit()} and {@see SimplePie_Enclosure::get_credits()} 49 | * 50 | * This class can be overloaded with {@see SimplePie::set_credit_class()} 51 | * 52 | * @package SimplePie 53 | * @subpackage API 54 | */ 55 | class SimplePie_Credit 56 | { 57 | /** 58 | * Credited role 59 | * 60 | * @var string 61 | * @see get_role() 62 | */ 63 | var $role; 64 | 65 | /** 66 | * Organizational scheme 67 | * 68 | * @var string 69 | * @see get_scheme() 70 | */ 71 | var $scheme; 72 | 73 | /** 74 | * Credited name 75 | * 76 | * @var string 77 | * @see get_name() 78 | */ 79 | var $name; 80 | 81 | /** 82 | * Constructor, used to input the data 83 | * 84 | * For documentation on all the parameters, see the corresponding 85 | * properties and their accessors 86 | */ 87 | public function __construct($role = null, $scheme = null, $name = null) 88 | { 89 | $this->role = $role; 90 | $this->scheme = $scheme; 91 | $this->name = $name; 92 | } 93 | 94 | /** 95 | * String-ified version 96 | * 97 | * @return string 98 | */ 99 | public function __toString() 100 | { 101 | // There is no $this->data here 102 | return md5(serialize($this)); 103 | } 104 | 105 | /** 106 | * Get the role of the person receiving credit 107 | * 108 | * @return string|null 109 | */ 110 | public function get_role() 111 | { 112 | if ($this->role !== null) 113 | { 114 | return $this->role; 115 | } 116 | else 117 | { 118 | return null; 119 | } 120 | } 121 | 122 | /** 123 | * Get the organizational scheme 124 | * 125 | * @return string|null 126 | */ 127 | public function get_scheme() 128 | { 129 | if ($this->scheme !== null) 130 | { 131 | return $this->scheme; 132 | } 133 | else 134 | { 135 | return null; 136 | } 137 | } 138 | 139 | /** 140 | * Get the credited person/entity's name 141 | * 142 | * @return string|null 143 | */ 144 | public function get_name() 145 | { 146 | if ($this->name !== null) 147 | { 148 | return $this->name; 149 | } 150 | else 151 | { 152 | return null; 153 | } 154 | } 155 | } 156 | 157 | -------------------------------------------------------------------------------- /library/SimplePie/Rating.php: -------------------------------------------------------------------------------- 1 | ` or `` tags as defined in Media RSS and iTunes RSS respectively 47 | * 48 | * Used by {@see SimplePie_Enclosure::get_rating()} and {@see SimplePie_Enclosure::get_ratings()} 49 | * 50 | * This class can be overloaded with {@see SimplePie::set_rating_class()} 51 | * 52 | * @package SimplePie 53 | * @subpackage API 54 | */ 55 | class SimplePie_Rating 56 | { 57 | /** 58 | * Rating scheme 59 | * 60 | * @var string 61 | * @see get_scheme() 62 | */ 63 | var $scheme; 64 | 65 | /** 66 | * Rating value 67 | * 68 | * @var string 69 | * @see get_value() 70 | */ 71 | var $value; 72 | 73 | /** 74 | * Constructor, used to input the data 75 | * 76 | * For documentation on all the parameters, see the corresponding 77 | * properties and their accessors 78 | */ 79 | public function __construct($scheme = null, $value = null) 80 | { 81 | $this->scheme = $scheme; 82 | $this->value = $value; 83 | } 84 | 85 | /** 86 | * String-ified version 87 | * 88 | * @return string 89 | */ 90 | public function __toString() 91 | { 92 | // There is no $this->data here 93 | return md5(serialize($this)); 94 | } 95 | 96 | /** 97 | * Get the organizational scheme for the rating 98 | * 99 | * @return string|null 100 | */ 101 | public function get_scheme() 102 | { 103 | if ($this->scheme !== null) 104 | { 105 | return $this->scheme; 106 | } 107 | else 108 | { 109 | return null; 110 | } 111 | } 112 | 113 | /** 114 | * Get the value of the rating 115 | * 116 | * @return string|null 117 | */ 118 | public function get_value() 119 | { 120 | if ($this->value !== null) 121 | { 122 | return $this->value; 123 | } 124 | else 125 | { 126 | return null; 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /library/SimplePie/Restriction.php: -------------------------------------------------------------------------------- 1 | ` as defined in Media RSS 47 | * 48 | * Used by {@see SimplePie_Enclosure::get_restriction()} and {@see SimplePie_Enclosure::get_restrictions()} 49 | * 50 | * This class can be overloaded with {@see SimplePie::set_restriction_class()} 51 | * 52 | * @package SimplePie 53 | * @subpackage API 54 | */ 55 | class SimplePie_Restriction 56 | { 57 | /** 58 | * Relationship ('allow'/'deny') 59 | * 60 | * @var string 61 | * @see get_relationship() 62 | */ 63 | var $relationship; 64 | 65 | /** 66 | * Type of restriction 67 | * 68 | * @var string 69 | * @see get_type() 70 | */ 71 | var $type; 72 | 73 | /** 74 | * Restricted values 75 | * 76 | * @var string 77 | * @see get_value() 78 | */ 79 | var $value; 80 | 81 | /** 82 | * Constructor, used to input the data 83 | * 84 | * For documentation on all the parameters, see the corresponding 85 | * properties and their accessors 86 | */ 87 | public function __construct($relationship = null, $type = null, $value = null) 88 | { 89 | $this->relationship = $relationship; 90 | $this->type = $type; 91 | $this->value = $value; 92 | } 93 | 94 | /** 95 | * String-ified version 96 | * 97 | * @return string 98 | */ 99 | public function __toString() 100 | { 101 | // There is no $this->data here 102 | return md5(serialize($this)); 103 | } 104 | 105 | /** 106 | * Get the relationship 107 | * 108 | * @return string|null Either 'allow' or 'deny' 109 | */ 110 | public function get_relationship() 111 | { 112 | if ($this->relationship !== null) 113 | { 114 | return $this->relationship; 115 | } 116 | else 117 | { 118 | return null; 119 | } 120 | } 121 | 122 | /** 123 | * Get the type 124 | * 125 | * @return string|null 126 | */ 127 | public function get_type() 128 | { 129 | if ($this->type !== null) 130 | { 131 | return $this->type; 132 | } 133 | else 134 | { 135 | return null; 136 | } 137 | } 138 | 139 | /** 140 | * Get the list of restricted things 141 | * 142 | * @return string|null 143 | */ 144 | public function get_value() 145 | { 146 | if ($this->value !== null) 147 | { 148 | return $this->value; 149 | } 150 | else 151 | { 152 | return null; 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /postback.php: -------------------------------------------------------------------------------- 1 | enable_cache(false); 17 | $feed->set_feed_url($_REQUEST["feed"]); 18 | $feed->init(); 19 | if($feed->error()) { 20 | throw new InvalidArgumentException($feed->error()); 21 | } 22 | $db->insert("feeds", ["feed"=>$_REQUEST["feed"]]); 23 | } 24 | 25 | if($mode == "addAggregateFeed") { 26 | $urls = explode("\n", $_REQUEST["feeds"]); 27 | 28 | foreach($urls as $url) { 29 | require_once($path."autoloader.php"); 30 | $feed = new SimplePie(); 31 | $feed->enable_cache(false); 32 | $feed->set_feed_url($url); 33 | $feed->init(); 34 | if($feed->error()) { 35 | throw new InvalidArgumentException($feed->error()); 36 | } 37 | } 38 | $db->insert("aggregateFeeds", ["feeds"=>$_REQUEST["feeds"]]); 39 | } 40 | 41 | if($mode == "updateAggregateFeed") { 42 | $urls = explode("\n", $_REQUEST["feeds"]); 43 | 44 | foreach($urls as $url) { 45 | require_once($path."autoloader.php"); 46 | $feed = new SimplePie(); 47 | $feed->enable_cache(false); 48 | $feed->set_feed_url($url); 49 | $feed->init(); 50 | if($feed->error()) { 51 | throw new InvalidArgumentException($feed->error()); 52 | } 53 | } 54 | $id = $_REQUEST["id"]; 55 | $db->update("aggregateFeeds", ["feeds"=>$_REQUEST["feeds"]], ["ID"=>$id]); 56 | } 57 | 58 | if($mode == "addRegex") { 59 | $regex = "/".$_REQUEST["regex"]."/s"; 60 | if($_REQUEST["caseInsensitive"]) { 61 | $regex .= "i"; 62 | } 63 | if(preg_match($regex, "") === false) { 64 | throw new InvalidArgumentException($regex."
".preg_last_error()); 65 | } 66 | 67 | $db->insert("filters", ["feedID"=>$_REQUEST["feedID"], "field"=>$_REQUEST["field"], "regex"=>$regex]); 68 | } 69 | 70 | if($mode == "deleteRegex") { 71 | $db->delete("filters", ["ID"=>$_REQUEST["filterID"]]); 72 | } 73 | 74 | if($mode == "setFeedProperties") { 75 | $anyOrAll = $_REQUEST["anyOrAll"]; 76 | if($anyOrAll != 'all') { 77 | $anyOrAll = 'any'; 78 | } 79 | $blockOrPermit = $_REQUEST["blockOrPermit"]; 80 | if($blockOrPermit != 'permit'){ 81 | $blockOrPermit = 'block'; 82 | } 83 | $db->update("feeds", ["maxItems"=>$_REQUEST["maxItems"]], ["ID"=>$_REQUEST["feedID"]]); 84 | $db->update("feeds", ["anyOrAll"=>$anyOrAll], ["ID"=>$_REQUEST["feedID"]]); 85 | $db->update("feeds", ["blockOrPermit"=>$blockOrPermit], ["ID"=>$_REQUEST["feedID"]]); 86 | } 87 | 88 | header("location:admin.php"); 89 | ?> 90 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | About 2 | ----- 3 | regex filters for various components of rss feeds. Useful for filtering: 4 | * Types of content (videos, audio) 5 | * Ads 6 | * Types of articles (summaries, links to other feeds, categories, etc) 7 | * Anything else you can find in the feed with a regex 8 | 9 | Feed Aggregation (BETA) 10 | * Only show articles if their titles are sufficiently similar or dissimilar (see http://us1.php.net/manual/en/function.similar-text.php) 11 | * Article similarity rating shown after article title 12 | * Useful for only getting major news events or filtering out duplicates across feeds 13 | * URL customizable filter level - easily tweak filter threshold 14 | 15 | Setup 16 | ----- 17 | Put all files in your web server's document directory. 18 | Navigate to admin.php. Here you can add new rss/atom feeds and set up regex filters for them. 19 | Once you've added a feed, you will be provided a URL for your filtered feed. Put this into your RSS reader of choice, and get on with your life. 20 | 21 | Hacking 22 | ------- 23 | Don't see the field you want to filter by? Need something more complex? Check out the filter function in functions.php! 24 | 25 | ***************** 26 | See MIT.txt for licensing info 27 | -------------------------------------------------------------------------------- /smarty/debug.tpl: -------------------------------------------------------------------------------- 1 | {capture name='_smarty_debug' assign=debug_output} 2 | 3 | 4 | 5 | Smarty Debug Console 6 | 86 | 87 | 88 | 89 |

Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}

90 | 91 | {if !empty($template_data)} 92 |

included templates & config files (load time in seconds)

93 | 94 |
95 | {foreach $template_data as $template} 96 | {$template.name} 97 | 98 | (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) 99 | 100 |
101 | {/foreach} 102 |
103 | {/if} 104 | 105 |

assigned template variables

106 | 107 | 108 | {foreach $assigned_vars as $vars} 109 | 110 | 111 | 112 | {/foreach} 113 |
${$vars@key|escape:'html'}{$vars|debug_print_var}
114 | 115 |

assigned config file variables (outer template scope)

116 | 117 | 118 | {foreach $config_vars as $vars} 119 | 120 | 121 | 122 | {/foreach} 123 | 124 |
{$vars@key|escape:'html'}{$vars|debug_print_var}
125 | 126 | 127 | {/capture} 128 | 134 | -------------------------------------------------------------------------------- /smarty/plugins/block.php.php: -------------------------------------------------------------------------------- 1 | allow_php_tag) { 21 | throw new SmartyException("{php} is deprecated, set allow_php_tag = true to enable"); 22 | } 23 | eval($content); 24 | return ''; 25 | } 26 | 27 | ?> -------------------------------------------------------------------------------- /smarty/plugins/block.textformat.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: textformat
14 | * Purpose: format text a certain way with preset styles 15 | * or custom wrap/indent settings
16 | * 17 | * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} 18 | * (Smarty online manual) 19 | * @param array $params parameters 20 | *
 21 |  * Params:   style: string (email)
 22 |  *            indent: integer (0)
 23 |  *            wrap: integer (80)
 24 |  *            wrap_char string ("\n")
 25 |  *            indent_char: string (" ")
 26 |  *            wrap_boundary: boolean (true)
 27 |  * 
28 | * @author Monte Ohrt 29 | * @param string $content contents of the block 30 | * @param object $template template object 31 | * @param boolean &$repeat repeat flag 32 | * @return string content re-formatted 33 | */ 34 | function smarty_block_textformat($params, $content, $template, &$repeat) 35 | { 36 | if (is_null($content)) { 37 | return; 38 | } 39 | 40 | $style = null; 41 | $indent = 0; 42 | $indent_first = 0; 43 | $indent_char = ' '; 44 | $wrap = 80; 45 | $wrap_char = "\n"; 46 | $wrap_cut = false; 47 | $assign = null; 48 | 49 | foreach ($params as $_key => $_val) { 50 | switch ($_key) { 51 | case 'style': 52 | case 'indent_char': 53 | case 'wrap_char': 54 | case 'assign': 55 | $$_key = (string)$_val; 56 | break; 57 | 58 | case 'indent': 59 | case 'indent_first': 60 | case 'wrap': 61 | $$_key = (int)$_val; 62 | break; 63 | 64 | case 'wrap_cut': 65 | $$_key = (bool)$_val; 66 | break; 67 | 68 | default: 69 | trigger_error("textformat: unknown attribute '$_key'"); 70 | } 71 | } 72 | 73 | if ($style == 'email') { 74 | $wrap = 72; 75 | } 76 | // split into paragraphs 77 | $_paragraphs = preg_split('![\r\n][\r\n]!', $content); 78 | $_output = ''; 79 | 80 | for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { 81 | if ($_paragraphs[$_x] == '') { 82 | continue; 83 | } 84 | // convert mult. spaces & special chars to single space 85 | $_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]); 86 | // indent first line 87 | if ($indent_first > 0) { 88 | $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; 89 | } 90 | // wordwrap sentences 91 | $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); 92 | // indent lines 93 | if ($indent > 0) { 94 | $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); 95 | } 96 | } 97 | $_output = implode($wrap_char . $wrap_char, $_paragraphs); 98 | 99 | return $assign ? $template->assign($assign, $_output) : $_output; 100 | } 101 | 102 | ?> -------------------------------------------------------------------------------- /smarty/plugins/function.counter.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: counter
13 | * Purpose: print out a counter value 14 | * @author Monte Ohrt 15 | * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} 16 | * (Smarty online manual) 17 | * @param array parameters 18 | * @param Smarty 19 | * @param object $template template object 20 | * @return string|null 21 | */ 22 | function smarty_function_counter($params, $template) 23 | { 24 | static $counters = array(); 25 | 26 | $name = (isset($params['name'])) ? $params['name'] : 'default'; 27 | if (!isset($counters[$name])) { 28 | $counters[$name] = array( 29 | 'start'=>1, 30 | 'skip'=>1, 31 | 'direction'=>'up', 32 | 'count'=>1 33 | ); 34 | } 35 | $counter =& $counters[$name]; 36 | 37 | if (isset($params['start'])) { 38 | $counter['start'] = $counter['count'] = (int)$params['start']; 39 | } 40 | 41 | if (!empty($params['assign'])) { 42 | $counter['assign'] = $params['assign']; 43 | } 44 | 45 | if (isset($counter['assign'])) { 46 | $template->assign($counter['assign'], $counter['count']); 47 | } 48 | 49 | if (isset($params['print'])) { 50 | $print = (bool)$params['print']; 51 | } else { 52 | $print = empty($counter['assign']); 53 | } 54 | 55 | if ($print) { 56 | $retval = $counter['count']; 57 | } else { 58 | $retval = null; 59 | } 60 | 61 | if (isset($params['skip'])) { 62 | $counter['skip'] = $params['skip']; 63 | } 64 | 65 | if (isset($params['direction'])) { 66 | $counter['direction'] = $params['direction']; 67 | } 68 | 69 | if ($counter['direction'] == "down") 70 | $counter['count'] -= $counter['skip']; 71 | else 72 | $counter['count'] += $counter['skip']; 73 | 74 | return $retval; 75 | 76 | } 77 | 78 | ?> -------------------------------------------------------------------------------- /smarty/plugins/function.cycle.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: cycle
14 | * Date: May 3, 2002
15 | * Purpose: cycle through given values
16 | * Input: 17 | * - name = name of cycle (optional) 18 | * - values = comma separated list of values to cycle, 19 | * or an array of values to cycle 20 | * (this can be left out for subsequent calls) 21 | * - reset = boolean - resets given var to true 22 | * - print = boolean - print var or not. default is true 23 | * - advance = boolean - whether or not to advance the cycle 24 | * - delimiter = the value delimiter, default is "," 25 | * - assign = boolean, assigns to template var instead of 26 | * printed. 27 | * 28 | * Examples:
29 | *
 30 |  * {cycle values="#eeeeee,#d0d0d0d"}
 31 |  * {cycle name=row values="one,two,three" reset=true}
 32 |  * {cycle name=row}
 33 |  * 
34 | * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} 35 | * (Smarty online manual) 36 | * @author Monte Ohrt 37 | * @author credit to Mark Priatel 38 | * @author credit to Gerard 39 | * @author credit to Jason Sweat 40 | * @version 1.3 41 | * @param array 42 | * @param object $template template object 43 | * @return string|null 44 | */ 45 | 46 | function smarty_function_cycle($params, $template) 47 | { 48 | static $cycle_vars; 49 | 50 | $name = (empty($params['name'])) ? 'default' : $params['name']; 51 | $print = (isset($params['print'])) ? (bool)$params['print'] : true; 52 | $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; 53 | $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; 54 | 55 | if (!in_array('values', array_keys($params))) { 56 | if(!isset($cycle_vars[$name]['values'])) { 57 | trigger_error("cycle: missing 'values' parameter"); 58 | return; 59 | } 60 | } else { 61 | if(isset($cycle_vars[$name]['values']) 62 | && $cycle_vars[$name]['values'] != $params['values'] ) { 63 | $cycle_vars[$name]['index'] = 0; 64 | } 65 | $cycle_vars[$name]['values'] = $params['values']; 66 | } 67 | 68 | if (isset($params['delimiter'])) { 69 | $cycle_vars[$name]['delimiter'] = $params['delimiter']; 70 | } elseif (!isset($cycle_vars[$name]['delimiter'])) { 71 | $cycle_vars[$name]['delimiter'] = ','; 72 | } 73 | 74 | if(is_array($cycle_vars[$name]['values'])) { 75 | $cycle_array = $cycle_vars[$name]['values']; 76 | } else { 77 | $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); 78 | } 79 | 80 | if(!isset($cycle_vars[$name]['index']) || $reset ) { 81 | $cycle_vars[$name]['index'] = 0; 82 | } 83 | 84 | if (isset($params['assign'])) { 85 | $print = false; 86 | $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); 87 | } 88 | 89 | if($print) { 90 | $retval = $cycle_array[$cycle_vars[$name]['index']]; 91 | } else { 92 | $retval = null; 93 | } 94 | 95 | if($advance) { 96 | if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { 97 | $cycle_vars[$name]['index'] = 0; 98 | } else { 99 | $cycle_vars[$name]['index']++; 100 | } 101 | } 102 | 103 | return $retval; 104 | } 105 | 106 | ?> -------------------------------------------------------------------------------- /smarty/plugins/function.math.php: -------------------------------------------------------------------------------- 1 | 14 | * Name: math
15 | * Purpose: handle math computations in template
16 | * @link http://smarty.php.net/manual/en/language.function.math.php {math} 17 | * (Smarty online manual) 18 | * @author Monte Ohrt 19 | * @param array $params parameters 20 | * @param object $template template object 21 | * @return string|null 22 | */ 23 | function smarty_function_math($params, $template) 24 | { 25 | // be sure equation parameter is present 26 | if (empty($params['equation'])) { 27 | trigger_error("math: missing equation parameter",E_USER_WARNING); 28 | return; 29 | } 30 | 31 | $equation = $params['equation']; 32 | 33 | // make sure parenthesis are balanced 34 | if (substr_count($equation,"(") != substr_count($equation,")")) { 35 | trigger_error("math: unbalanced parenthesis",E_USER_WARNING); 36 | return; 37 | } 38 | 39 | // match all vars in equation, make sure all are passed 40 | preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match); 41 | $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10', 42 | 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); 43 | 44 | foreach($match[1] as $curr_var) { 45 | if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { 46 | trigger_error("math: function call $curr_var not allowed",E_USER_WARNING); 47 | return; 48 | } 49 | } 50 | 51 | foreach($params as $key => $val) { 52 | if ($key != "equation" && $key != "format" && $key != "assign") { 53 | // make sure value is not empty 54 | if (strlen($val)==0) { 55 | trigger_error("math: parameter $key is empty",E_USER_WARNING); 56 | return; 57 | } 58 | if (!is_numeric($val)) { 59 | trigger_error("math: parameter $key: is not numeric",E_USER_WARNING); 60 | return; 61 | } 62 | $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); 63 | } 64 | } 65 | $smarty_math_result = null; 66 | eval("\$smarty_math_result = ".$equation.";"); 67 | 68 | if (empty($params['format'])) { 69 | if (empty($params['assign'])) { 70 | return $smarty_math_result; 71 | } else { 72 | $template->assign($params['assign'],$smarty_math_result); 73 | } 74 | } else { 75 | if (empty($params['assign'])){ 76 | printf($params['format'],$smarty_math_result); 77 | } else { 78 | $template->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); 79 | } 80 | } 81 | } 82 | 83 | ?> -------------------------------------------------------------------------------- /smarty/plugins/function.popup.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: popup
14 | * Purpose: make text pop up in windows via overlib 15 | * @link http://smarty.php.net/manual/en/language.function.popup.php {popup} 16 | * (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array $params parameters 19 | * @param object $template template object 20 | * @return string 21 | */ 22 | function smarty_function_popup($params, $template) 23 | { 24 | $append = ''; 25 | foreach ($params as $_key=>$_value) { 26 | switch ($_key) { 27 | case 'text': 28 | case 'trigger': 29 | case 'function': 30 | case 'inarray': 31 | $$_key = (string)$_value; 32 | if ($_key == 'function' || $_key == 'inarray') 33 | $append .= ',' . strtoupper($_key) . ",'$_value'"; 34 | break; 35 | 36 | case 'caption': 37 | case 'closetext': 38 | case 'status': 39 | $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'"; 40 | break; 41 | 42 | case 'fgcolor': 43 | case 'bgcolor': 44 | case 'textcolor': 45 | case 'capcolor': 46 | case 'closecolor': 47 | case 'textfont': 48 | case 'captionfont': 49 | case 'closefont': 50 | case 'fgbackground': 51 | case 'bgbackground': 52 | case 'caparray': 53 | case 'capicon': 54 | case 'background': 55 | case 'frame': 56 | $append .= ',' . strtoupper($_key) . ",'$_value'"; 57 | break; 58 | 59 | case 'textsize': 60 | case 'captionsize': 61 | case 'closesize': 62 | case 'width': 63 | case 'height': 64 | case 'border': 65 | case 'offsetx': 66 | case 'offsety': 67 | case 'snapx': 68 | case 'snapy': 69 | case 'fixx': 70 | case 'fixy': 71 | case 'padx': 72 | case 'pady': 73 | case 'timeout': 74 | case 'delay': 75 | $append .= ',' . strtoupper($_key) . ",$_value"; 76 | break; 77 | 78 | case 'sticky': 79 | case 'left': 80 | case 'right': 81 | case 'center': 82 | case 'above': 83 | case 'below': 84 | case 'noclose': 85 | case 'autostatus': 86 | case 'autostatuscap': 87 | case 'fullhtml': 88 | case 'hauto': 89 | case 'vauto': 90 | case 'mouseoff': 91 | case 'followmouse': 92 | case 'closeclick': 93 | case 'wrap': 94 | if ($_value) $append .= ',' . strtoupper($_key); 95 | break; 96 | 97 | default: 98 | trigger_error("[popup] unknown parameter $_key", E_USER_WARNING); 99 | } 100 | } 101 | 102 | if (empty($text) && !isset($inarray) && empty($function)) { 103 | trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required",E_USER_WARNING); 104 | return false; 105 | } 106 | 107 | if (empty($trigger)) { $trigger = "onmouseover"; } 108 | 109 | $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!",'!"!',"![\r\n]!"),array("\'","\'",'\r'),$text).'\''; 110 | $retval .= $append . ');"'; 111 | if ($trigger == 'onmouseover') 112 | $retval .= ' onmouseout="nd();"'; 113 | 114 | 115 | return $retval; 116 | } 117 | 118 | ?> -------------------------------------------------------------------------------- /smarty/plugins/function.popup_init.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: popup_init
14 | * Purpose: initialize overlib 15 | * @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init} 16 | * (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array $params parameters 19 | * @param object $template template object 20 | * @return string 21 | */ 22 | 23 | function smarty_function_popup_init($params, $template) 24 | { 25 | $zindex = 1000; 26 | 27 | if (!empty($params['zindex'])) { 28 | $zindex = $params['zindex']; 29 | } 30 | 31 | if (!empty($params['src'])) { 32 | return '' . "\n" 33 | . '' . "\n"; 34 | } else { 35 | trigger_error("popup_init: missing src parameter",E_USER_WARNING); 36 | } 37 | } 38 | 39 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.capitalize.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: capitalize
14 | * Purpose: capitalize words in the string 15 | * 16 | * @link 17 | * @author Monte Ohrt 18 | * @param string $ 19 | * @return string 20 | */ 21 | function smarty_modifier_capitalize($string, $uc_digits = false) 22 | { 23 | // uppercase with php function ucwords 24 | $upper_string = ucwords($string); 25 | // check for any missed hyphenated words 26 | $upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!ue", "'\\1'.ucfirst('\\2')", $upper_string); 27 | // check uc_digits case 28 | if (!$uc_digits) { 29 | if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) { 30 | foreach($matches[1] as $match) 31 | $upper_string = substr_replace($upper_string, $match[0], $match[1], strlen($match[0])); 32 | } 33 | } 34 | return $upper_string; 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.date_format.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: date_format
14 | * Purpose: format datestamps via strftime
15 | * Input:
16 | * - string: input date string 17 | * - format: strftime format for output 18 | * - default_date: default date if $string is empty 19 | * 20 | * @link http://smarty.php.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) 21 | * @author Monte Ohrt 22 | * @param string $ 23 | * @param string $ 24 | * @param string $ 25 | * @return string |void 26 | * @uses smarty_make_timestamp() 27 | */ 28 | function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '',$formatter='auto') 29 | { 30 | /** 31 | * Include the {@link shared.make_timestamp.php} plugin 32 | */ 33 | require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); 34 | if ($string != '') { 35 | $timestamp = smarty_make_timestamp($string); 36 | } elseif ($default_date != '') { 37 | $timestamp = smarty_make_timestamp($default_date); 38 | } else { 39 | return; 40 | } 41 | if($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) { 42 | if (DS == '\\') { 43 | $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); 44 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); 45 | if (strpos($format, '%e') !== false) { 46 | $_win_from[] = '%e'; 47 | $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); 48 | } 49 | if (strpos($format, '%l') !== false) { 50 | $_win_from[] = '%l'; 51 | $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); 52 | } 53 | $format = str_replace($_win_from, $_win_to, $format); 54 | } 55 | return strftime($format, $timestamp); 56 | } else { 57 | return date($format, $timestamp); 58 | } 59 | } 60 | 61 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.debug_print_var.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: debug_print_var
14 | * Purpose: formats variable contents for display in the console 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php debug_print_var (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array $ |object 19 | * @param integer $ 20 | * @param integer $ 21 | * @return string 22 | */ 23 | function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40) 24 | { 25 | $_replace = array("\n" => '\n', 26 | "\r" => '\r', 27 | "\t" => '\t' 28 | ); 29 | 30 | switch (gettype($var)) { 31 | case 'array' : 32 | $results = 'Array (' . count($var) . ')'; 33 | foreach ($var as $curr_key => $curr_val) { 34 | $results .= '
' . str_repeat(' ', $depth * 2) 35 | . '' . strtr($curr_key, $_replace) . ' => ' 36 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); 37 | $depth--; 38 | } 39 | break; 40 | case 'object' : 41 | $object_vars = get_object_vars($var); 42 | $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; 43 | foreach ($object_vars as $curr_key => $curr_val) { 44 | $results .= '
' . str_repeat(' ', $depth * 2) 45 | . ' ->' . strtr($curr_key, $_replace) . ' = ' 46 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); 47 | $depth--; 48 | } 49 | break; 50 | case 'boolean' : 51 | case 'NULL' : 52 | case 'resource' : 53 | if (true === $var) { 54 | $results = 'true'; 55 | } elseif (false === $var) { 56 | $results = 'false'; 57 | } elseif (null === $var) { 58 | $results = 'null'; 59 | } else { 60 | $results = htmlspecialchars((string) $var); 61 | } 62 | $results = '' . $results . ''; 63 | break; 64 | case 'integer' : 65 | case 'float' : 66 | $results = htmlspecialchars((string) $var); 67 | break; 68 | case 'string' : 69 | $results = strtr($var, $_replace); 70 | if (strlen($var) > $length) { 71 | $results = substr($var, 0, $length - 3) . '...'; 72 | } 73 | $results = htmlspecialchars('"' . $results . '"'); 74 | break; 75 | case 'unknown type' : 76 | default : 77 | $results = strtr((string) $var, $_replace); 78 | if (strlen($results) > $length) { 79 | $results = substr($results, 0, $length - 3) . '...'; 80 | } 81 | $results = htmlspecialchars($results); 82 | } 83 | 84 | return $results; 85 | } 86 | 87 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.escape.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: escape
14 | * Purpose: escape string for output 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string $string input string 19 | * @param string $esc_type escape type 20 | * @param string $char_set character set 21 | * @return string escaped input string 22 | */ 23 | function smarty_modifier_escape($string, $esc_type = 'html', $char_set = SMARTY_RESOURCE_CHAR_SET) 24 | { 25 | switch ($esc_type) { 26 | case 'html': 27 | return htmlspecialchars($string, ENT_QUOTES, $char_set); 28 | 29 | case 'htmlall': 30 | return htmlentities($string, ENT_QUOTES, $char_set); 31 | 32 | case 'url': 33 | return rawurlencode($string); 34 | 35 | case 'urlpathinfo': 36 | return str_replace('%2F', '/', rawurlencode($string)); 37 | 38 | case 'quotes': 39 | // escape unescaped single quotes 40 | return preg_replace("%(? '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', ' '<\/')); 67 | 68 | case 'mail': 69 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); 70 | return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); 71 | 72 | case 'nonstd': 73 | // escape non-standard chars, such as ms document quotes 74 | $_res = ''; 75 | for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { 76 | $_ord = ord(substr($string, $_i, 1)); 77 | // non-standard char, escape it 78 | if ($_ord >= 126) { 79 | $_res .= '&#' . $_ord . ';'; 80 | } else { 81 | $_res .= substr($string, $_i, 1); 82 | } 83 | } 84 | return $_res; 85 | 86 | default: 87 | return $string; 88 | } 89 | } 90 | 91 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.regex_replace.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: regex_replace
14 | * Purpose: regular expression search/replace 15 | * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php 16 | * regex_replace (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param string|array 20 | * @param string|array 21 | * @return string 22 | */ 23 | function smarty_modifier_regex_replace($string, $search, $replace) 24 | { 25 | if(is_array($search)) { 26 | foreach($search as $idx => $s) 27 | $search[$idx] = _smarty_regex_replace_check($s); 28 | } else { 29 | $search = _smarty_regex_replace_check($search); 30 | } 31 | 32 | return preg_replace($search, $replace, $string); 33 | } 34 | 35 | function _smarty_regex_replace_check($search) 36 | { 37 | if (($pos = strpos($search,"\0")) !== false) 38 | $search = substr($search,0,$pos); 39 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { 40 | /* remove eval-modifier from $search */ 41 | $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); 42 | } 43 | return $search; 44 | } 45 | 46 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.replace.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: replace
13 | * Purpose: simple search/replace 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) 16 | * @author Monte Ohrt 17 | * @author Uwe Tews 18 | * @param string $ 19 | * @param string $ 20 | * @param string $ 21 | * @return string 22 | */ 23 | function smarty_modifier_replace($string, $search, $replace) 24 | { 25 | if (function_exists('mb_split')) { 26 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); 27 | return smarty_mb_str_replace($search, $replace, $string); 28 | } 29 | return str_replace($search, $replace, $string); 30 | } 31 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.spacify.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: spacify
13 | * Purpose: add spaces between characters in a string 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) 16 | * @author Monte Ohrt 17 | * @param string $ 18 | * @param string $ 19 | * @return string 20 | */ 21 | function smarty_modifier_spacify($string, $spacify_char = ' ') 22 | { 23 | // mb_ functions available? 24 | if (function_exists('mb_strlen') && mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') { 25 | $strlen = mb_strlen($string); 26 | while ($strlen) { 27 | $array[] = mb_substr($string, 0, 1, "UTF-8"); 28 | $string = mb_substr($string, 1, $strlen, "UTF-8"); 29 | $strlen = mb_strlen($string); 30 | } 31 | return implode($spacify_char, $array); 32 | } else { 33 | return implode($spacify_char, preg_split('//', $string, -1)); 34 | } 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifier.truncate.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: truncate
14 | * Purpose: Truncate a string to a certain length if necessary, 15 | * optionally splitting in the middle of a word, and 16 | * appending the $etc string or inserting $etc into the middle. 17 | * 18 | * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) 19 | * @author Monte Ohrt 20 | * @param string $string input string 21 | * @param integer $length lenght of truncated text 22 | * @param string $etc end string 23 | * @param boolean $break_words truncate at word boundary 24 | * @param boolean $middle truncate in the middle of text 25 | * @return string truncated string 26 | */ 27 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', 28 | $break_words = false, $middle = false) 29 | { 30 | if ($length == 0) 31 | return ''; 32 | 33 | if (is_callable('mb_strlen')) { 34 | if (mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') { 35 | // $string has utf-8 encoding 36 | if (mb_strlen($string) > $length) { 37 | $length -= min($length, mb_strlen($etc)); 38 | if (!$break_words && !$middle) { 39 | $string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($string, 0, $length + 1)); 40 | } 41 | if (!$middle) { 42 | return mb_substr($string, 0, $length) . $etc; 43 | } else { 44 | return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, - $length / 2); 45 | } 46 | } else { 47 | return $string; 48 | } 49 | } 50 | } 51 | // $string has no utf-8 encoding 52 | if (strlen($string) > $length) { 53 | $length -= min($length, strlen($etc)); 54 | if (!$break_words && !$middle) { 55 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); 56 | } 57 | if (!$middle) { 58 | return substr($string, 0, $length) . $etc; 59 | } else { 60 | return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); 61 | } 62 | } else { 63 | return $string; 64 | } 65 | } 66 | 67 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.cat.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: cat
14 | * Date: Feb 24, 2003 15 | * Purpose: catenate a value to a variable 16 | * Input: string to catenate 17 | * Example: {$var|cat:"foo"} 18 | * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat 19 | * (Smarty online manual) 20 | * @author Uwe Tews 21 | * @param array $params parameters 22 | * @return string with compiled code 23 | */ 24 | function smarty_modifiercompiler_cat($params, $compiler) 25 | { 26 | return '('.implode(').(', $params).')'; 27 | } 28 | 29 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.count_characters.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_characteres
14 | * Purpose: count the number of characters in a text 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_count_characters($params, $compiler) 22 | { 23 | // mb_ functions available? 24 | if (function_exists('mb_strlen')) { 25 | // count also spaces? 26 | if (isset($params[1]) && $params[1] == 'true') { 27 | return '((mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? mb_strlen(' . $params[0] . ', SMARTY_RESOURCE_CHAR_SET) : strlen(' . $params[0] . '))'; 28 | } 29 | return '((mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? preg_match_all(\'#[^\s\pZ]#u\', ' . $params[0] . ', $tmp) : preg_match_all(\'/[^\s]/\',' . $params[0] . ', $tmp))'; 30 | } else { 31 | // count also spaces? 32 | if (isset($params[1]) && $params[1] == 'true') { 33 | return 'strlen(' . $params[0] . ')'; 34 | } 35 | return 'preg_match_all(\'/[^\s]/\',' . $params[0] . ', $tmp)'; 36 | } 37 | } 38 | 39 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.count_paragraphs.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_paragraphs
14 | * Purpose: count the number of paragraphs in a text 15 | * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php 16 | * count_paragraphs (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_count_paragraphs($params, $compiler) 22 | { 23 | // count \r or \n characters 24 | return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)'; 25 | } 26 | 27 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.count_sentences.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_sentences 14 | * Purpose: count the number of sentences in a text 15 | * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php 16 | * count_sentences (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_count_sentences($params, $compiler) 22 | { 23 | // find periods with a word before but not after. 24 | return 'preg_match_all(\'/[^\s]\.(?!\w)/\', ' . $params[0] . ', $tmp)'; 25 | } 26 | 27 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.count_words.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_words
14 | * Purpose: count the number of words in a text 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_count_words($params, $compiler) 22 | { 23 | // mb_ functions available? 24 | if (function_exists('mb_strlen')) { 25 | return '((mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? preg_match_all(\'#[\w\pL]+#u\', ' . $params[0] . ', $tmp) : preg_match_all(\'#\w+#\',' . $params[0] . ', $tmp))'; 26 | } else { 27 | return 'str_word_count(' . $params[0] . ')'; 28 | } 29 | } 30 | 31 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.default.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: default
14 | * Purpose: designate default value for empty variables 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.default.php default (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_default ($params, $compiler) 22 | { 23 | $output = $params[0]; 24 | if (!isset($params[1])) { 25 | $params[1] = "''"; 26 | } 27 | for ($i = 1, $cnt = count($params); $i < $cnt; $i++) { 28 | $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $params[$i] . ' : $tmp)'; 29 | } 30 | return $output; 31 | } 32 | 33 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.indent.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: indent
13 | * Purpose: indent lines of text 14 | * @link http://smarty.php.net/manual/en/language.modifier.indent.php 15 | * indent (Smarty online manual) 16 | * @author Uwe Tews 17 | * @param array $params parameters 18 | * @return string with compiled code 19 | */ 20 | 21 | function smarty_modifiercompiler_indent($params, $compiler) 22 | { 23 | if (!isset($params[1])) { 24 | $params[1] = 4; 25 | } 26 | if (!isset($params[2])) { 27 | $params[2] = "' '"; 28 | } 29 | return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')'; 30 | } 31 | 32 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.lower.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: lower
13 | * Purpose: convert string to lowercase 14 | * 15 | * @link http://smarty.php.net/manual/en/language.modifier.lower.php lower (Smarty online manual) 16 | * @author Monte Ohrt 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | 22 | function smarty_modifiercompiler_lower($params, $compiler) 23 | { 24 | if (function_exists('mb_strtolower')) { 25 | return '((mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? mb_strtolower(' . $params[0] . ',SMARTY_RESOURCE_CHAR_SET) : strtolower(' . $params[0] . '))' ; 26 | } else { 27 | return 'strtolower(' . $params[0] . ')'; 28 | } 29 | } 30 | 31 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.noprint.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: noprint
14 | * Purpose: return an empty string 15 | * @author Uwe Tews 16 | * @param array $params parameters 17 | * @return string with compiled code 18 | */ 19 | function smarty_modifiercompiler_noprint($params, $compiler) 20 | { 21 | return "''"; 22 | } 23 | 24 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.string_format.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: string_format
14 | * Purpose: format strings via sprintf 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_string_format($params, $compiler) 22 | { 23 | return 'sprintf(' . $params[1] . ',' . $params[0] . ')'; 24 | } 25 | 26 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.strip.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: strip
14 | * Purpose: Replace all repeated spaces, newlines, tabs 15 | * with a single space or supplied replacement string.
16 | * Example: {$var|strip} {$var|strip:" "} 17 | * Date: September 25th, 2002 18 | * 19 | * @link http://smarty.php.net/manual/en/language.modifier.strip.php strip (Smarty online manual) 20 | * @author Uwe Tews 21 | * @param array $params parameters 22 | * @return string with compiled code 23 | */ 24 | 25 | function smarty_modifiercompiler_strip($params, $compiler) 26 | { 27 | if (!isset($params[1])) { 28 | $params[1] = "' '"; 29 | } 30 | return "preg_replace('!\s+!u', {$params[1]},{$params[0]})"; 31 | } 32 | 33 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.strip_tags.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: strip_tags
14 | * Purpose: strip html tags from text 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | 22 | function smarty_modifiercompiler_strip_tags($params, $compiler) 23 | { 24 | if (!isset($params[1])) { 25 | $params[1] = true; 26 | } 27 | if ($params[1] === true) { 28 | return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; 29 | } else { 30 | return 'strip_tags(' . $params[0] . ')'; 31 | } 32 | } 33 | 34 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.upper.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: lower
14 | * Purpose: convert string to uppercase 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_upper($params, $compiler) 22 | { 23 | if (function_exists('mb_strtoupper')) { 24 | return '((mb_detect_encoding(' . $params[0] . ', \'UTF-8, ISO-8859-1\') === \'UTF-8\') ? mb_strtoupper(' . $params[0] . ',SMARTY_RESOURCE_CHAR_SET) : strtoupper(' . $params[0] . '))' ; 25 | } else { 26 | return 'strtoupper(' . $params[0] . ')'; 27 | } 28 | } 29 | 30 | ?> -------------------------------------------------------------------------------- /smarty/plugins/modifiercompiler.wordwrap.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: wordwrap
14 | * Purpose: wrap a string of text at a given length 15 | * 16 | * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) 17 | * @author Uwe Tews 18 | * @param array $params parameters 19 | * @return string with compiled code 20 | */ 21 | function smarty_modifiercompiler_wordwrap($params, $compiler) 22 | { 23 | if (!isset($params[1])) { 24 | $params[1] = 80; 25 | } 26 | if (!isset($params[2])) { 27 | $params[2] = '"\n"'; 28 | } 29 | if (!isset($params[3])) { 30 | $params[3] = 'false'; 31 | } 32 | return 'wordwrap(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')'; 33 | } 34 | 35 | ?> -------------------------------------------------------------------------------- /smarty/plugins/outputfilter.trimwhitespace.php: -------------------------------------------------------------------------------- 1 | 13 | * Type: outputfilter
14 | * Name: trimwhitespace
15 | * Date: Jan 25, 2003
16 | * Purpose: trim leading white space and blank lines from 17 | * template source after it gets interpreted, cleaning 18 | * up code and saving bandwidth. Does not affect 19 | * <
>
and blocks.
20 | * Install: Drop into the plugin directory, call 21 | * $smarty->load_filter('output','trimwhitespace'); 22 | * from application. 23 | * @author Monte Ohrt 24 | * @author Contributions from Lars Noschinski 25 | * @version 1.3 26 | * @param string $source input string 27 | * @param object &$smarty Smarty object 28 | * @return string filtered output 29 | */ 30 | function smarty_outputfilter_trimwhitespace($source, $smarty) 31 | { 32 | // Pull out the script blocks 33 | preg_match_all("!]*?>.*?!is", $source, $match); 34 | $_script_blocks = $match[0]; 35 | $source = preg_replace("!]*?>.*?!is", 36 | '@@@SMARTY:TRIM:SCRIPT@@@', $source); 37 | 38 | // Pull out the pre blocks 39 | preg_match_all("!]*?>.*?!is", $source, $match); 40 | $_pre_blocks = $match[0]; 41 | $source = preg_replace("!]*?>.*?!is", 42 | '@@@SMARTY:TRIM:PRE@@@', $source); 43 | 44 | // Pull out the textarea blocks 45 | preg_match_all("!]*?>.*?!is", $source, $match); 46 | $_textarea_blocks = $match[0]; 47 | $source = preg_replace("!]*?>.*?!is", 48 | '@@@SMARTY:TRIM:TEXTAREA@@@', $source); 49 | 50 | // remove all leading spaces, tabs and carriage returns NOT 51 | // preceeded by a php close tag. 52 | $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); 53 | 54 | // replace textarea blocks 55 | smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); 56 | 57 | // replace pre blocks 58 | smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); 59 | 60 | // replace script blocks 61 | smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); 62 | 63 | return $source; 64 | } 65 | 66 | function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { 67 | $_len = strlen($search_str); 68 | $_pos = 0; 69 | for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) 70 | if (($_pos=strpos($subject, $search_str, $_pos))!==false) 71 | $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); 72 | else 73 | break; 74 | 75 | } 76 | 77 | ?> -------------------------------------------------------------------------------- /smarty/plugins/shared.escape_special_chars.php: -------------------------------------------------------------------------------- 1 | 13 | * Purpose: used by other smarty functions to escape 14 | * special chars except for already escaped ones 15 | * @author Monte Ohrt 16 | * @param string 17 | * @return string 18 | */ 19 | function smarty_function_escape_special_chars($string) 20 | { 21 | if(!is_array($string)) { 22 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); 23 | $string = htmlspecialchars($string); 24 | $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); 25 | } 26 | return $string; 27 | } 28 | 29 | ?> -------------------------------------------------------------------------------- /smarty/plugins/shared.make_timestamp.php: -------------------------------------------------------------------------------- 1 | 11 | * Purpose: used by other smarty functions to make a timestamp 12 | * from a string. 13 | * @author Monte Ohrt 14 | * @param string $string 15 | * @return string 16 | */ 17 | 18 | function smarty_make_timestamp($string) 19 | { 20 | if(empty($string)) { 21 | // use "now": 22 | return time(); 23 | } elseif ($string instanceof DateTime) { 24 | return $string->getTimestamp(); 25 | } elseif (strlen($string)==14 && ctype_digit($string)) { 26 | // it is mysql timestamp format of YYYYMMDDHHMMSS? 27 | return mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), 28 | substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4)); 29 | } elseif (is_numeric($string)) { 30 | // it is a numeric string, we handle it as timestamp 31 | return (int)$string; 32 | } else { 33 | // strtotime should handle it 34 | $time = strtotime($string); 35 | if ($time == -1 || $time === false) { 36 | // strtotime() was not able to parse $string, use "now": 37 | return time(); 38 | } 39 | return $time; 40 | } 41 | } 42 | 43 | ?> 44 | -------------------------------------------------------------------------------- /smarty/plugins/shared.mb_str_replace.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /smarty/plugins/variablefilter.htmlspecialchars.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_append.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 28 | // the following must be assigned at runtime because it will be overwritten in parent class 29 | $this->required_attributes = array('var', 'value'); 30 | $this->shorttag_order = array('var', 'value'); 31 | $this->optional_attributes = array('scope','index'); 32 | // check and get attributes 33 | $_attr = $this->_get_attributes($args); 34 | // map to compile assign attributes 35 | if (isset($_attr['index'])) { 36 | $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']'; 37 | unset($_attr['index']); 38 | } else { 39 | $_params['smarty_internal_index'] = '[]'; 40 | } 41 | $_new_attr = array(); 42 | foreach ($_attr as $key => $value) { 43 | $_new_attr[] = array($key => $value); 44 | } 45 | // call compile assign 46 | return parent::compile($_new_attr, $compiler, $_params); 47 | } 48 | } 49 | 50 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_assign.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 28 | // the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append 29 | $this->required_attributes = array('var', 'value'); 30 | $this->shorttag_order = array('var', 'value'); 31 | $this->optional_attributes = array('scope'); 32 | $_nocache = 'null'; 33 | $_scope = 'null'; 34 | // check and get attributes 35 | $_attr = $this->_get_attributes($args); 36 | // nocache ? 37 | if ($this->compiler->tag_nocache || $this->compiler->nocache) { 38 | $_nocache = 'true'; 39 | // create nocache var to make it know for further compiling 40 | $compiler->template->tpl_vars[trim($_attr['var'], "'")] = new Smarty_variable(null, true); 41 | } 42 | // scope setup 43 | if (isset($_attr['scope'])) { 44 | $_attr['scope'] = trim($_attr['scope'], "'\""); 45 | if ($_attr['scope'] == 'parent') { 46 | $_scope = Smarty::SCOPE_PARENT; 47 | } elseif ($_attr['scope'] == 'root') { 48 | $_scope = Smarty::SCOPE_ROOT; 49 | } elseif ($_attr['scope'] == 'global') { 50 | $_scope = Smarty::SCOPE_GLOBAL; 51 | } else { 52 | $this->compiler->trigger_template_error('illegal value for "scope" attribute', $this->compiler->lex->taglineno); 53 | } 54 | } 55 | // compiled output 56 | if (isset($parameter['smarty_internal_index'])) { 57 | return "tpl_vars[$_attr[var]]) || !is_array(\$_smarty_tpl->tpl_vars[$_attr[var]]->value)) \$_smarty_tpl->createLocalArrayVariable($_attr[var], $_nocache, $_scope);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];?>"; 58 | } else { 59 | return "tpl_vars[$_attr[var]] = new Smarty_variable($_attr[value], $_nocache, $_scope);?>"; 60 | } 61 | } 62 | } 63 | 64 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_break.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 32 | $this->smarty = $compiler->smarty; 33 | // check and get attributes 34 | $_attr = $this->_get_attributes($args); 35 | 36 | if ($_attr['nocache'] === true) { 37 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 38 | } 39 | 40 | if (isset($_attr['levels'])) { 41 | if (!is_numeric($_attr['levels'])) { 42 | $this->compiler->trigger_template_error('level attribute must be a numeric constant', $this->compiler->lex->taglineno); 43 | } 44 | $_levels = $_attr['levels']; 45 | } else { 46 | $_levels = 1; 47 | } 48 | $level_count = $_levels; 49 | $stack_count = count($compiler->_tag_stack) - 1; 50 | while ($level_count > 0 && $stack_count >= 0) { 51 | if (in_array($compiler->_tag_stack[$stack_count][0], array('for', 'foreach', 'while', 'section'))) { 52 | $level_count--; 53 | } 54 | $stack_count--; 55 | } 56 | if ($level_count != 0) { 57 | $this->compiler->trigger_template_error("cannot break {$_levels} level(s)", $this->compiler->lex->taglineno); 58 | } 59 | // this tag does not return compiled code 60 | $this->compiler->has_code = true; 61 | return ""; 62 | } 63 | } 64 | 65 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_call.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 33 | $this->smarty = $compiler->smarty; 34 | // check and get attributes 35 | $_attr = $this->_get_attributes($args); 36 | // save possible attributes 37 | if (isset($_attr['assign'])) { 38 | // output will be stored in a smarty variable instead of beind displayed 39 | $_assign = $_attr['assign']; 40 | } 41 | $_name = $_attr['name']; 42 | unset($_attr['name'], $_attr['assign'], $_attr['nocache']); 43 | // set flag (compiled code of {function} must be included in cache file 44 | if ($compiler->nocache || $compiler->tag_nocache) { 45 | $_nocache = 'true'; 46 | } else { 47 | $_nocache = 'false'; 48 | } 49 | $_paramsArray = array(); 50 | foreach ($_attr as $_key => $_value) { 51 | if (is_int($_key)) { 52 | $_paramsArray[] = "$_key=>$_value"; 53 | } else { 54 | $_paramsArray[] = "'$_key'=>$_value"; 55 | } 56 | } 57 | if (isset($compiler->template->properties['function'][$_name]['parameter'])) { 58 | foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) { 59 | if (!isset($_attr[$_key])) { 60 | if (is_int($_key)) { 61 | $_paramsArray[] = "$_key=>$_value"; 62 | } else { 63 | $_paramsArray[] = "'$_key'=>$_value"; 64 | } 65 | } 66 | } 67 | } elseif (isset($this->smarty->template_functions[$_name]['parameter'])) { 68 | foreach ($this->smarty->template_functions[$_name]['parameter'] as $_key => $_value) { 69 | if (!isset($_attr[$_key])) { 70 | if (is_int($_key)) { 71 | $_paramsArray[] = "$_key=>$_value"; 72 | } else { 73 | $_paramsArray[] = "'$_key'=>$_value"; 74 | } 75 | } 76 | } 77 | } 78 | //varibale name? 79 | if (!(strpos($_name,'$')===false)) { 80 | $call_cache = $_name; 81 | $call_function = '$tmp = "smarty_template_function_".'.$_name.'; $tmp'; 82 | } else { 83 | $_name = trim($_name, "'\""); 84 | $call_cache = "'{$_name}'"; 85 | $call_function = 'smarty_template_function_'.$_name; 86 | } 87 | 88 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 89 | $_hash = str_replace('-','_',$compiler->template->properties['nocache_hash']); 90 | // was there an assign attribute 91 | if (isset($_assign)) { 92 | if ($compiler->template->caching) { 93 | $_output = "assign({$_assign}, ob_get_clean());?>\n"; 94 | } else { 95 | $_output = "assign({$_assign}, ob_get_clean());?>\n"; 96 | } 97 | } else { 98 | if ($compiler->template->caching) { 99 | $_output = "\n"; 100 | } else { 101 | $_output = "\n"; 102 | } 103 | } 104 | return $_output; 105 | } 106 | } 107 | 108 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_capture.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 30 | // check and get attributes 31 | $_attr = $this->_get_attributes($args); 32 | 33 | $buffer = isset($_attr['name']) ? $_attr['name'] : "'default'"; 34 | $assign = isset($_attr['assign']) ? $_attr['assign'] : null; 35 | $append = isset($_attr['append']) ? $_attr['append'] : null; 36 | 37 | $this->compiler->_capture_stack[] = array($buffer, $assign, $append, $this->compiler->nocache); 38 | // maybe nocache because of nocache variables 39 | $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; 40 | $_output = ""; 41 | 42 | return $_output; 43 | } 44 | } 45 | 46 | /** 47 | * Smarty Internal Plugin Compile Captureclose Class 48 | */ 49 | class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase { 50 | /** 51 | * Compiles code for the {/capture} tag 52 | * 53 | * @param array $args array with attributes from parser 54 | * @param object $compiler compiler object 55 | * @return string compiled code 56 | */ 57 | public function compile($args, $compiler) 58 | { 59 | $this->compiler = $compiler; 60 | // check and get attributes 61 | $_attr = $this->_get_attributes($args); 62 | // must endblock be nocache? 63 | if ($this->compiler->nocache) { 64 | $this->compiler->tag_nocache = true; 65 | } 66 | 67 | list($buffer, $assign, $append, $this->compiler->nocache) = array_pop($this->compiler->_capture_stack); 68 | 69 | $_output = "assign($assign, ob_get_contents());"; 72 | } 73 | if (isset($append)) { 74 | $_output .= " \$_smarty_tpl->append($append, ob_get_contents());"; 75 | } 76 | $_output .= " Smarty::\$_smarty_vars['capture'][$buffer]=ob_get_clean();?>"; 77 | return $_output; 78 | } 79 | } 80 | 81 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_config_load.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 32 | // check and get attributes 33 | $_attr = $this->_get_attributes($args); 34 | 35 | if ($_attr['nocache'] === true) { 36 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 37 | } 38 | 39 | 40 | // save posible attributes 41 | $conf_file = $_attr['file']; 42 | if (isset($_attr['section'])) { 43 | $section = $_attr['section']; 44 | } else { 45 | $section = 'null'; 46 | } 47 | $scope = 'local'; 48 | // scope setup 49 | if (isset($_attr['scope'])) { 50 | $_attr['scope'] = trim($_attr['scope'], "'\""); 51 | if (in_array($_attr['scope'],array('local','parent','root','global'))) { 52 | $scope = $_attr['scope']; 53 | } else { 54 | $this->compiler->trigger_template_error('illegal value for "scope" attribute', $this->compiler->lex->taglineno); 55 | } 56 | } 57 | // create config object 58 | $_output = "smarty, \$_smarty_tpl);"; 59 | $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>"; 60 | return $_output; 61 | } 62 | } 63 | 64 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_continue.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 31 | $this->smarty = $compiler->smarty; 32 | // check and get attributes 33 | $_attr = $this->_get_attributes($args); 34 | 35 | if ($_attr['nocache'] === true) { 36 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 37 | } 38 | 39 | if (isset($_attr['levels'])) { 40 | if (!is_numeric($_attr['levels'])) { 41 | $this->compiler->trigger_template_error('level attribute must be a numeric constant', $this->compiler->lex->taglineno); 42 | } 43 | $_levels = $_attr['levels']; 44 | } else { 45 | $_levels = 1; 46 | } 47 | $level_count = $_levels; 48 | $stack_count = count($compiler->_tag_stack) - 1; 49 | while ($level_count > 0 && $stack_count >= 0) { 50 | if (in_array($compiler->_tag_stack[$stack_count][0], array('for', 'foreach', 'while', 'section'))) { 51 | $level_count--; 52 | } 53 | $stack_count--; 54 | } 55 | if ($level_count != 0) { 56 | $this->compiler->trigger_template_error("cannot continue {$_levels} level(s)", $this->compiler->lex->taglineno); 57 | } 58 | // this tag does not return compiled code 59 | $this->compiler->has_code = true; 60 | return ""; 61 | } 62 | } 63 | 64 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_debug.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 26 | // check and get attributes 27 | $_attr = $this->_get_attributes($args); 28 | 29 | // compile always as nocache 30 | $this->compiler->tag_nocache = true; 31 | 32 | // display debug template 33 | $_output = "smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl); ?>"; 34 | return $_output; 35 | } 36 | } 37 | 38 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_eval.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 30 | $this->required_attributes = array('var'); 31 | $this->optional_attributes = array('assign'); 32 | // check and get attributes 33 | $_attr = $this->_get_attributes($args); 34 | if (isset($_attr['assign'])) { 35 | // output will be stored in a smarty variable instead of beind displayed 36 | $_assign = $_attr['assign']; 37 | } 38 | 39 | // create template object 40 | $_output = "\$_template = new {$compiler->smarty->template_class}('eval:'.".$_attr['var'].", \$_smarty_tpl->smarty, \$_smarty_tpl);"; 41 | //was there an assign attribute? 42 | if (isset($_assign)) { 43 | $_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate());"; 44 | } else { 45 | $_output .= "echo \$_template->getRenderedTemplate();"; 46 | } 47 | return ""; 48 | } 49 | } 50 | 51 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_extends.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 31 | $this->smarty = $compiler->smarty; 32 | $this->_rdl = preg_quote($this->smarty->right_delimiter); 33 | $this->_ldl = preg_quote($this->smarty->left_delimiter); 34 | $filepath = $compiler->template->getTemplateFilepath(); 35 | // check and get attributes 36 | $_attr = $this->_get_attributes($args); 37 | if ($_attr['nocache'] === true) { 38 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 39 | } 40 | 41 | $_smarty_tpl = $compiler->template; 42 | $include_file = null; 43 | if (strpos($_attr['file'],'$_tmp') !== false || strpos($_attr['file'],'$_smarty_tpl') !== false || strpos($_attr['file'],'::') !== false) { 44 | $this->compiler->trigger_template_error('a variable file attribute is illegal', $this->compiler->lex->taglineno); 45 | } 46 | eval('$include_file = ' . $_attr['file'] . ';'); 47 | // create template object 48 | $_template = new $compiler->smarty->template_class($include_file, $this->smarty, $compiler->template); 49 | // save file dependency 50 | if (in_array($_template->resource_type,array('eval','string'))) { 51 | $template_sha1 = sha1($include_file); 52 | } else { 53 | $template_sha1 = sha1($_template->getTemplateFilepath()); 54 | } 55 | if (isset($compiler->template->properties['file_dependency'][$template_sha1])) { 56 | $this->compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"",$compiler->lex->line-1); 57 | } 58 | $compiler->template->properties['file_dependency'][$template_sha1] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp(),$_template->resource_type); 59 | $_content = substr($compiler->template->template_source,$compiler->lex->counter-1); 60 | if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) != 61 | preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) { 62 | $this->compiler->trigger_template_error('unmatched {block} {/block} pairs'); 63 | } 64 | preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE); 65 | $_result_count = count($_result[0]); 66 | $_start = 0; 67 | while ($_start < $_result_count) { 68 | $_end = 0; 69 | $_level = 1; 70 | while ($_level != 0) { 71 | $_end++; 72 | if (!strpos($_result[0][$_start + $_end][0], '/')) { 73 | $_level++; 74 | } else { 75 | $_level--; 76 | } 77 | } 78 | $_block_content = str_replace($this->smarty->left_delimiter . '$smarty.block.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', 79 | substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))); 80 | Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath); 81 | $_start = $_start + $_end + 1; 82 | } 83 | $compiler->template->template_source = $_template->getTemplateSource(); 84 | $compiler->template->template_filepath = $_template->getTemplateFilepath(); 85 | $compiler->abort_and_recompile = true; 86 | return ''; 87 | } 88 | 89 | } 90 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_include_php.php: -------------------------------------------------------------------------------- 1 | smarty->allow_php_tag) { 32 | throw new SmartyException("{include_php} is deprecated, set allow_php_tag = true to enable"); 33 | } 34 | $this->compiler = $compiler; 35 | // check and get attributes 36 | $_attr = $this->_get_attributes($args); 37 | 38 | $_output = 'template; 41 | $_filepath = false; 42 | eval('$_file = ' . $_attr['file'] . ';'); 43 | if (!isset($this->compiler->smarty->security_policy) && file_exists($_file)) { 44 | $_filepath = $_file; 45 | } else { 46 | if (isset($this->compiler->smarty->security_policy)) { 47 | $_dir = $this->compiler->smarty->security_policy->trusted_dir; 48 | } else { 49 | $_dir = $this->compiler->smarty->trusted_dir; 50 | } 51 | if (!empty($_dir)) { 52 | foreach((array)$_dir as $_script_dir) { 53 | if (strpos('/\\', substr($_script_dir, -1)) === false) { 54 | $_script_dir .= DS; 55 | } 56 | if (file_exists($_script_dir . $_file)) { 57 | $_filepath = $_script_dir . $_file; 58 | break; 59 | } 60 | } 61 | } 62 | } 63 | if ($_filepath == false) { 64 | $this->compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", $this->compiler->lex->taglineno); 65 | } 66 | 67 | if (isset($this->compiler->smarty->security_policy)) { 68 | $this->compiler->smarty->security_policy->isTrustedPHPDir($_filepath); 69 | } 70 | 71 | if (isset($_attr['assign'])) { 72 | // output will be stored in a smarty variable instead of being displayed 73 | $_assign = $_attr['assign']; 74 | } 75 | $_once = '_once'; 76 | if (isset($_attr['once'])) { 77 | if ($_attr['once'] == 'false') { 78 | $_once = ''; 79 | } 80 | } 81 | 82 | if (isset($_assign)) { 83 | return "assign({$_assign},ob_get_contents()); ob_end_clean();?>"; 84 | } else { 85 | return "\n"; 86 | } 87 | } 88 | } 89 | 90 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_ldelim.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 27 | $_attr = $this->_get_attributes($args); 28 | if ($_attr['nocache'] === true) { 29 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 30 | } 31 | // this tag does not return compiled code 32 | $this->compiler->has_code = true; 33 | return $this->compiler->smarty->left_delimiter; 34 | } 35 | } 36 | 37 | ?> 38 | -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_nocache.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 27 | $_attr = $this->_get_attributes($args); 28 | if ($_attr['nocache'] === true) { 29 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 30 | } 31 | // enter nocache mode 32 | $this->compiler->nocache = true; 33 | // this tag does not return compiled code 34 | $this->compiler->has_code = false; 35 | return true; 36 | } 37 | } 38 | 39 | /** 40 | * Smarty Internal Plugin Compile Nocacheclose Class 41 | */ 42 | class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase { 43 | /** 44 | * Compiles code for the {/nocache} tag 45 | * 46 | * This tag does not generate compiled output. It only sets a compiler flag 47 | * @param array $args array with attributes from parser 48 | * @param object $compiler compiler object 49 | * @return string compiled code 50 | */ 51 | public function compile($args, $compiler) 52 | { 53 | $this->compiler = $compiler; 54 | $_attr = $this->_get_attributes($args); 55 | // leave nocache mode 56 | $this->compiler->nocache = false; 57 | // this tag does not return compiled code 58 | $this->compiler->has_code = false; 59 | return true; 60 | } 61 | } 62 | 63 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_block_plugin.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 32 | if (strlen($tag) < 6 || substr($tag, -5) != 'close') { 33 | // opening tag of block plugin 34 | // check and get attributes 35 | $_attr = $this->_get_attributes($args); 36 | if ($_attr['nocache'] === true) { 37 | $this->compiler->tag_nocache = true; 38 | } 39 | unset($_attr['nocache']); 40 | // convert attributes into parameter array string 41 | $_paramsArray = array(); 42 | foreach ($_attr as $_key => $_value) { 43 | if (is_int($_key)) { 44 | $_paramsArray[] = "$_key=>$_value"; 45 | } else { 46 | $_paramsArray[] = "'$_key'=>$_value"; 47 | } 48 | } 49 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 50 | 51 | $this->_open_tag($tag, array($_params, $this->compiler->nocache)); 52 | // maybe nocache because of nocache variables or nocache plugin 53 | $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; 54 | // compile code 55 | $output = "smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>"; 56 | } else { 57 | // must endblock be nocache? 58 | if ($this->compiler->nocache) { 59 | $this->compiler->tag_nocache = true; 60 | } 61 | // closing tag of block plugin, restore nocache 62 | list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5)); 63 | // This tag does create output 64 | $this->compiler->has_output = true; 65 | // compile code 66 | if (!isset($parameter['modifier_list'])) { 67 | $mod_pre = $mod_post =''; 68 | } else { 69 | $mod_pre = ' ob_start(); '; 70 | $mod_post = 'echo '.$this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>$parameter['modifier_list'],'value'=>'ob_get_clean()')).';'; 71 | } 72 | $output = "smarty->_tag_stack);?>"; 73 | } 74 | return $output . "\n"; 75 | } 76 | } 77 | 78 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_function_plugin.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 33 | // This tag does create output 34 | $this->compiler->has_output = true; 35 | 36 | // check and get attributes 37 | $_attr = $this->_get_attributes($args); 38 | if ($_attr['nocache'] === true) { 39 | $this->compiler->tag_nocache = true; 40 | } 41 | unset($_attr['nocache']); 42 | // convert attributes into parameter array string 43 | $_paramsArray = array(); 44 | foreach ($_attr as $_key => $_value) { 45 | if (is_int($_key)) { 46 | $_paramsArray[] = "$_key=>$_value"; 47 | } else { 48 | $_paramsArray[] = "'$_key'=>$_value"; 49 | } 50 | } 51 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 52 | // compile code 53 | $output = "\n"; 54 | return $output; 55 | } 56 | } 57 | 58 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_modifier.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 27 | $this->smarty = $this->compiler->smarty; 28 | // check and get attributes 29 | $_attr = $this->_get_attributes($args); 30 | $output = $parameter['value']; 31 | // loop over list of modifiers 32 | foreach ($parameter['modifierlist'] as $single_modifier) { 33 | $modifier = $single_modifier[0]; 34 | $single_modifier[0] = $output; 35 | $params = implode(',', $single_modifier); 36 | // check for registered modifier 37 | if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) { 38 | $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0]; 39 | if (!is_array($function)) { 40 | $output = "{$function}({$params})"; 41 | } else { 42 | if (is_object($function[0])) { 43 | $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')'; 44 | } else { 45 | $output = $function[0] . '::' . $function[1] . '(' . $params . ')'; 46 | } 47 | } 48 | // check for plugin modifiercompiler 49 | } else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) { 50 | $plugin = 'smarty_modifiercompiler_' . $modifier; 51 | $output = $plugin($single_modifier, $compiler); 52 | // check for plugin modifier 53 | } else if ($function = $this->compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) { 54 | $output = "{$function}({$params})"; 55 | // check if trusted PHP function 56 | } else if (is_callable($modifier)) { 57 | // check if modifier allowed 58 | if (!is_object($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedModifier($modifier, $this->compiler)) { 59 | $output = "{$modifier}({$params})"; 60 | } 61 | } else { 62 | $this->compiler->trigger_template_error ("unknown modifier \"" . $modifier . "\"", $this->compiler->lex->taglineno); 63 | } 64 | } 65 | return $output; 66 | } 67 | } 68 | 69 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_object_block_function.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 33 | if (strlen($tag) < 5 || substr($tag, -5) != 'close') { 34 | // opening tag of block plugin 35 | // check and get attributes 36 | $_attr = $this->_get_attributes($args); 37 | if ($_attr['nocache'] === true) { 38 | $this->compiler->tag_nocache = true; 39 | } 40 | unset($_attr['nocache']); 41 | // convert attributes into parameter array string 42 | $_paramsArray = array(); 43 | foreach ($_attr as $_key => $_value) { 44 | if (is_int($_key)) { 45 | $_paramsArray[] = "$_key=>$_value"; 46 | } else { 47 | $_paramsArray[] = "'$_key'=>$_value"; 48 | } 49 | } 50 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 51 | 52 | $this->_open_tag($tag . '->' . $methode, array($_params, $this->compiler->nocache)); 53 | // maybe nocache because of nocache variables or nocache plugin 54 | $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; 55 | // compile code 56 | $output = "smarty->_tag_stack[] = array('{$tag}->{$methode}', {$_params}); \$_block_repeat=true; \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>"; 57 | } else { 58 | $base_tag = substr($tag, 0, -5); 59 | // must endblock be nocache? 60 | if ($this->compiler->nocache) { 61 | $this->compiler->tag_nocache = true; 62 | } 63 | // closing tag of block plugin, restore nocache 64 | list($_params, $this->compiler->nocache) = $this->_close_tag($base_tag . '->' . $methode); 65 | // This tag does create output 66 | $this->compiler->has_output = true; 67 | // compile code 68 | if (!isset($parameter['modifier_list'])) { 69 | $mod_pre = $mod_post =''; 70 | } else { 71 | $mod_pre = ' ob_start(); '; 72 | $mod_post = 'echo '.$this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>$parameter['modifier_list'],'value'=>'ob_get_clean()')).';'; 73 | } 74 | $output = "smarty->registered_objects['{$base_tag}'][0]->{$methode}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post." } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>"; 75 | } 76 | return $output."\n"; 77 | } 78 | } 79 | 80 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_object_function.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 33 | // check and get attributes 34 | $_attr = $this->_get_attributes($args); 35 | if ($_attr['nocache'] === true) { 36 | $this->compiler->tag_nocache = true; 37 | } 38 | unset($_attr['nocache']); 39 | $_assign = null; 40 | if (isset($_attr['assign'])) { 41 | $_assign = $_attr['assign']; 42 | unset($_attr['assign']); 43 | } 44 | // convert attributes into parameter array string 45 | if ($this->compiler->smarty->registered_objects[$tag][2]) { 46 | $_paramsArray = array(); 47 | foreach ($_attr as $_key => $_value) { 48 | if (is_int($_key)) { 49 | $_paramsArray[] = "$_key=>$_value"; 50 | } else { 51 | $_paramsArray[] = "'$_key'=>$_value"; 52 | } 53 | } 54 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 55 | $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params},\$_smarty_tpl)"; 56 | } else { 57 | $_params = implode(",", $_attr); 58 | $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params})"; 59 | } 60 | if (empty($_assign)) { 61 | // This tag does create output 62 | $this->compiler->has_output = true; 63 | $output = "\n"; 64 | } else { 65 | $output = "assign({$_assign},{$return});?>\n"; 66 | } 67 | return $output; 68 | } 69 | } 70 | 71 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_print_expression.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 31 | // check and get attributes 32 | $_attr = $this->_get_attributes($args); 33 | // nocache option 34 | if ($_attr['nocache'] === true) { 35 | $this->compiler->tag_nocache = true; 36 | } 37 | // filter handling 38 | if ($_attr['nofilter'] === true) { 39 | $_filter = 'false'; 40 | } else { 41 | $_filter = 'true'; 42 | } 43 | // compiled output 44 | // compiled output 45 | if (isset($_attr['assign'])) { 46 | // assign output to variable 47 | $output = "assign({$_attr['assign']},{$parameter['value']});?>"; 48 | } else { 49 | // display value 50 | if (!$_attr['nofilter'] && isset($this->compiler->smarty->registered_filters['variable'])) { 51 | $output = "Smarty_Internal_Filter_Handler::runFilter('variable', {$parameter['value']}, \$_smarty_tpl, {$_filter})"; 52 | } else { 53 | $output = $parameter['value']; 54 | } 55 | if (!$_attr['nofilter'] && !empty($this->compiler->smarty->default_modifiers)) { 56 | $modifierlist = array(); 57 | foreach ($this->compiler->smarty->default_modifiers as $key => $single_default_modifier) { 58 | preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array); 59 | for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) { 60 | if ($mod_array[0][$i] != ':') { 61 | $modifierlist[$key][] = $mod_array[0][$i]; 62 | } 63 | } 64 | } 65 | $output = $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $modifierlist, 'value' => $output)); 66 | } 67 | if (!empty($parameter['modifierlist'])) { 68 | $output = $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'], 'value' => $output)); 69 | } 70 | $this->compiler->has_output = true; 71 | $output = ""; 72 | } 73 | return $output; 74 | } 75 | } 76 | 77 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_registered_function.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 31 | // This tag does create output 32 | $this->compiler->has_output = true; 33 | // check and get attributes 34 | $_attr = $this->_get_attributes($args); 35 | if ($_attr['nocache']) { 36 | $this->compiler->tag_nocache = true; 37 | } 38 | unset($_attr['nocache']); 39 | // not cachable? 40 | $this->compiler->tag_nocache = $this->compiler->tag_nocache || !$compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][1]; 41 | // convert attributes into parameter array string 42 | $_paramsArray = array(); 43 | foreach ($_attr as $_key => $_value) { 44 | if (is_int($_key)) { 45 | $_paramsArray[] = "$_key=>$_value"; 46 | } elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][2])) { 47 | $_value = str_replace("'","^#^",$_value); 48 | $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; 49 | } else { 50 | $_paramsArray[] = "'$_key'=>$_value"; 51 | } 52 | } 53 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; 54 | $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][0]; 55 | // compile code 56 | if (!is_array($function)) { 57 | $output = "\n"; 58 | } else if (is_object($function[0])) { 59 | $output = "smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n"; 60 | } else { 61 | $output = "\n"; 62 | } 63 | return $output; 64 | } 65 | } 66 | 67 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_private_special_variable.php: -------------------------------------------------------------------------------- 1 | getVariable('smarty')->value$parameter"; 31 | case 'section': 32 | return "\$_smarty_tpl->getVariable('smarty')->value$parameter"; 33 | case 'capture': 34 | return "Smarty::\$_smarty_vars$parameter"; 35 | case 'now': 36 | return 'time()'; 37 | case 'cookies': 38 | if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) { 39 | $compiler->trigger_template_error("(secure mode) super globals not permitted"); 40 | break; 41 | } 42 | $compiled_ref = '$_COOKIE'; 43 | break; 44 | 45 | case 'get': 46 | case 'post': 47 | case 'env': 48 | case 'server': 49 | case 'session': 50 | case 'request': 51 | if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) { 52 | $compiler->trigger_template_error("(secure mode) super globals not permitted"); 53 | break; 54 | } 55 | $compiled_ref = '$_'.strtoupper($variable); 56 | break; 57 | 58 | case 'template': 59 | return 'basename($_smarty_tpl->getTemplateFilepath())'; 60 | 61 | case 'current_dir': 62 | return 'dirname($_smarty_tpl->getTemplateFilepath())'; 63 | 64 | case 'version': 65 | $_version = Smarty::SMARTY_VERSION; 66 | return "'$_version'"; 67 | 68 | case 'const': 69 | if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) { 70 | $compiler->trigger_template_error("(secure mode) constants not permitted"); 71 | break; 72 | } 73 | return '@' . trim($_index[1], "'"); 74 | 75 | case 'config': 76 | return "\$_smarty_tpl->getConfigVariable($_index[1])"; 77 | case 'ldelim': 78 | $_ldelim = $compiler->smarty->left_delimiter; 79 | return "'$_ldelim'"; 80 | 81 | case 'rdelim': 82 | $_rdelim = $compiler->smarty->right_delimiter; 83 | return "'$_rdelim'"; 84 | 85 | default: 86 | $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid'); 87 | break; 88 | } 89 | if (isset($_index[1])) { 90 | array_shift($_index); 91 | foreach ($_index as $_ind) { 92 | $compiled_ref = $compiled_ref . "[$_ind]"; 93 | } 94 | } 95 | return $compiled_ref; 96 | } 97 | } 98 | 99 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_rdelim.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 27 | $_attr = $this->_get_attributes($args); 28 | if ($_attr['nocache'] === true) { 29 | $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno); 30 | } 31 | // this tag does not return compiled code 32 | $this->compiler->has_code = true; 33 | return $this->compiler->smarty->right_delimiter; 34 | } 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_compile_while.php: -------------------------------------------------------------------------------- 1 | compiler = $compiler; 27 | // check and get attributes 28 | $_attr = $this->_get_attributes($args); 29 | $this->_open_tag('while', $this->compiler->nocache); 30 | 31 | // maybe nocache because of nocache variables 32 | $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; 33 | if (is_array($parameter['if condition'])) { 34 | if ($this->compiler->nocache) { 35 | $_nocache = ',true'; 36 | // create nocache var to make it know for further compiling 37 | if (is_array($parameter['if condition']['var'])) { 38 | $this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true); 39 | } else { 40 | $this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true); 41 | } 42 | } else { 43 | $_nocache = ''; 44 | } 45 | if (is_array($parameter['if condition']['var'])) { 46 | $_output = "tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n"; 47 | $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>"; 48 | } else { 49 | $_output = "tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});"; 50 | $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>"; 51 | } 52 | return $_output; 53 | } else { 54 | return ""; 55 | } 56 | } 57 | } 58 | 59 | /** 60 | * Smarty Internal Plugin Compile Whileclose Class 61 | */ 62 | class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase { 63 | /** 64 | * Compiles code for the {/while} tag 65 | * 66 | * @param array $args array with attributes from parser 67 | * @param object $compiler compiler object 68 | * @return string compiled code 69 | */ 70 | public function compile($args, $compiler) 71 | { 72 | $this->compiler = $compiler; 73 | // must endblock be nocache? 74 | if ($this->compiler->nocache) { 75 | $this->compiler->tag_nocache = true; 76 | } 77 | $this->compiler->nocache = $this->_close_tag(array('while')); 78 | return ""; 79 | } 80 | } 81 | 82 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_config_file_compiler.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 24 | // get required plugins 25 | $this->smarty->loadPlugin('Smarty_Internal_Configfilelexer'); 26 | $this->smarty->loadPlugin('Smarty_Internal_Configfileparser'); 27 | $this->config_data['sections'] = array(); 28 | $this->config_data['vars'] = array(); 29 | } 30 | 31 | /** 32 | * Methode to compile a Smarty template 33 | * 34 | * @param $template template object to compile 35 | * @return bool true if compiling succeeded, false if it failed 36 | */ 37 | public function compileSource($config) 38 | { 39 | /* here is where the compiling takes place. Smarty 40 | tags in the templates are replaces with PHP code, 41 | then written to compiled files. */ 42 | $this->config = $config; 43 | // get config file source 44 | $_content = $config->getConfigSource() . "\n"; 45 | // on empty template just return 46 | if ($_content == '') { 47 | return true; 48 | } 49 | // init the lexer/parser to compile the config file 50 | $lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty); 51 | $parser = new Smarty_Internal_Configfileparser($lex, $this); 52 | if (isset($this->smarty->_parserdebug)) $parser->PrintTrace(); 53 | // get tokens from lexer and parse them 54 | while ($lex->yylex()) { 55 | if (isset($this->smarty->_parserdebug)) echo "
Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; 56 | $parser->doParse($lex->token, $lex->value); 57 | } 58 | // finish parsing process 59 | $parser->doParse(0, 0); 60 | $config->compiled_config = 'config_data, true) . '; ?>'; 61 | } 62 | /** 63 | * display compiler error messages without dying 64 | * 65 | * If parameter $args is empty it is a parser detected syntax error. 66 | * In this case the parser is called to obtain information about exspected tokens. 67 | * 68 | * If parameter $args contains a string this is used as error message 69 | * 70 | * @todo output exact position of parse error in source line 71 | * @param $args string individual error message or null 72 | */ 73 | public function trigger_config_file_error($args = null) 74 | { 75 | $this->lex = Smarty_Internal_Configfilelexer::instance(); 76 | $this->parser = Smarty_Internal_Configfileparser::instance(); 77 | // get template source line which has error 78 | $line = $this->lex->line; 79 | if (isset($args)) { 80 | // $line--; 81 | } 82 | $match = preg_split("/\n/", $this->lex->data); 83 | $error_text = "Syntax error in config file '{$this->config->getConfigFilepath()}' on line {$line} '{$match[$line-1]}' "; 84 | if (isset($args)) { 85 | // individual error message 86 | $error_text .= $args; 87 | } else { 88 | // exspected token from parser 89 | foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { 90 | $exp_token = $this->parser->yyTokenName[$token]; 91 | if (isset($this->lex->smarty_token_names[$exp_token])) { 92 | // token type from lexer 93 | $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"'; 94 | } else { 95 | // otherwise internal token name 96 | $expect[] = $this->parser->yyTokenName[$token]; 97 | } 98 | } 99 | // output parser error message 100 | $error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect); 101 | } 102 | throw new SmartyCompilerException($error_text); 103 | } 104 | } 105 | 106 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_filter.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 20 | } 21 | /** 22 | * Registers a filter function 23 | * 24 | * @param string $type filter type 25 | * @param callback $callback 26 | */ 27 | public function registerFilter($type, $callback) 28 | { 29 | $this->smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback; 30 | } 31 | 32 | /** 33 | * Unregisters a filter function 34 | * 35 | * @param string $type filter type 36 | * @param callback $callback 37 | */ 38 | public function unregisterFilter($type, $callback) 39 | { 40 | $name = $this->_get_filter_name($callback); 41 | if(isset($this->smarty->registered_filters[$type][$name])) { 42 | unset($this->smarty->registered_filters[$type][$name]); 43 | } 44 | } 45 | 46 | 47 | /** 48 | * Return internal filter name 49 | * 50 | * @param callback $function_name 51 | */ 52 | public function _get_filter_name($function_name) 53 | { 54 | if (is_array($function_name)) { 55 | $_class_name = (is_object($function_name[0]) ? 56 | get_class($function_name[0]) : $function_name[0]); 57 | return $_class_name . '_' . $function_name[1]; 58 | } else { 59 | return $function_name; 60 | } 61 | } 62 | 63 | 64 | /** 65 | * load a filter of specified type and name 66 | * 67 | * @param string $type filter type 68 | * @param string $name filter name 69 | * @return bool 70 | */ 71 | function loadFilter($type, $name) 72 | { 73 | $_plugin = "smarty_{$type}filter_{$name}"; 74 | $_filter_name = $_plugin; 75 | if ($this->smarty->loadPlugin($_plugin)) { 76 | if (class_exists($_plugin, false)) { 77 | $_plugin = array($_plugin, 'execute'); 78 | } 79 | if (is_callable($_plugin)) { 80 | return $this->smarty->registered_filters[$type][$_filter_name] = $_plugin; 81 | } 82 | } 83 | throw new SmartyException("{$type}filter \"{$name}\" not callable"); 84 | return false; 85 | } 86 | 87 | 88 | } 89 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_filter_handler.php: -------------------------------------------------------------------------------- 1 | smarty->variable_filter && $flag !== false) || $flag === true) { 33 | // loop over autoload filters of specified type 34 | if (!empty($template->smarty->autoload_filters[$type])) { 35 | foreach ((array)$template->smarty->autoload_filters[$type] as $name) { 36 | $plugin_name = "Smarty_{$type}filter_{$name}"; 37 | if ($template->smarty->loadPlugin($plugin_name)) { 38 | if (function_exists($plugin_name)) { 39 | // use loaded Smarty2 style plugin 40 | $output = $plugin_name($output, $template); 41 | } elseif (class_exists($plugin_name, false)) { 42 | // loaded class of filter plugin 43 | $output = call_user_func(array($plugin_name, 'execute'), $output, $template); 44 | } 45 | } else { 46 | // nothing found, throw exception 47 | throw new SmartyException("Unable to load filter {$plugin_name}"); 48 | } 49 | } 50 | } 51 | // loop over registerd filters of specified type 52 | if (!empty($template->smarty->registered_filters[$type])) { 53 | foreach ($template->smarty->registered_filters[$type] as $key => $name) { 54 | if (is_array($template->smarty->registered_filters[$type][$key])) { 55 | $output = call_user_func($template->smarty->registered_filters[$type][$key], $output, $template); 56 | } else { 57 | $output = $template->smarty->registered_filters[$type][$key]($output, $template); 58 | } 59 | } 60 | } 61 | } 62 | // return filtered output 63 | return $output; 64 | } 65 | } 66 | 67 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_function_call_handler.php: -------------------------------------------------------------------------------- 1 | smarty->template_functions[$_name]['called_nocache'] = true; 19 | } else { 20 | $_function = "smarty_template_function_{$_hash}_{$_name}"; 21 | } 22 | if (!is_callable($_function)) { 23 | $_code = "function {$_function}(\$_smarty_tpl,\$params) { 24 | \$saved_tpl_vars = \$_smarty_tpl->tpl_vars; 25 | foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}; 26 | foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>"; 27 | if ($_nocache) { 28 | $_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!", 29 | "!\\\'!"), array('', "'"), $_template->smarty->template_functions[$_name]['compiled']); 30 | } else { 31 | $_code .= preg_replace("/{$_template->smarty->template_functions[$_name]['nocache_hash']}/", $_template->properties['nocache_hash'], $_template->smarty->template_functions[$_name]['compiled']); 32 | } 33 | $_code .= "tpl_vars = \$saved_tpl_vars;}"; 34 | eval($_code); 35 | } 36 | $_function($_template, $_params); 37 | } 38 | } 39 | 40 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_get_include_path.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_nocache_insert.php: -------------------------------------------------------------------------------- 1 | assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . ",\$_smarty_tpl), true);?>"; 38 | } else { 39 | $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>"; 40 | } 41 | $_tpl = $_template; 42 | while ($_tpl->parent instanceof Smarty_Internal_Template) { 43 | $_tpl = $_tpl->parent; 44 | } 45 | return "/*%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/"; 46 | } 47 | } 48 | 49 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_resource_eval.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 20 | } 21 | // classes used for compiling Smarty templates from file resource 22 | public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; 23 | public $template_lexer_class = 'Smarty_Internal_Templatelexer'; 24 | public $template_parser_class = 'Smarty_Internal_Templateparser'; 25 | // properties 26 | public $usesCompiler = true; 27 | public $isEvaluated = true; 28 | 29 | /** 30 | * Return flag if template source is existing 31 | * 32 | * @return boolean true 33 | */ 34 | public function isExisting($template) 35 | { 36 | return true; 37 | } 38 | 39 | /** 40 | * Get filepath to template source 41 | * 42 | * @param object $_template template object 43 | * @return string return 'string' as template source is not a file 44 | */ 45 | public function getTemplateFilepath($_template) 46 | { 47 | // no filepath for evaluated strings 48 | // return "string" for compiler error messages 49 | return 'eval:'; 50 | } 51 | 52 | /** 53 | * Get timestamp to template source 54 | * 55 | * @param object $_template template object 56 | * @return boolean false as string resources have no timestamp 57 | */ 58 | public function getTemplateTimestamp($_template) 59 | { 60 | // evaluated strings must always be compiled and have no timestamp 61 | return false; 62 | } 63 | 64 | /** 65 | * Retuen template source from resource name 66 | * 67 | * @param object $_template template object 68 | * @return string content of template source 69 | */ 70 | public function getTemplateSource($_template) 71 | { 72 | // return template string 73 | $_template->template_source = $_template->resource_name; 74 | return true; 75 | } 76 | 77 | /** 78 | * Get filepath to compiled template 79 | * 80 | * @param object $_template template object 81 | * @return boolean return false as compiled template is not stored 82 | */ 83 | public function getCompiledFilepath($_template) 84 | { 85 | // no filepath for strings 86 | return false; 87 | } 88 | } 89 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_resource_file.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 20 | } 21 | // classes used for compiling Smarty templates from file resource 22 | public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; 23 | public $template_lexer_class = 'Smarty_Internal_Templatelexer'; 24 | public $template_parser_class = 'Smarty_Internal_Templateparser'; 25 | // properties 26 | public $usesCompiler = true; 27 | public $isEvaluated = false; 28 | 29 | /** 30 | * Return flag if template source is existing 31 | * 32 | * @return boolean true 33 | */ 34 | public function isExisting($template) 35 | { 36 | if ($template->getTemplateFilepath() === false) { 37 | return false; 38 | } else { 39 | return true; 40 | } 41 | } 42 | 43 | /** 44 | * Get filepath to template source 45 | * 46 | * @param object $_template template object 47 | * @return string filepath to template source file 48 | */ 49 | public function getTemplateFilepath($_template) 50 | { 51 | $_filepath = $_template->buildTemplateFilepath (); 52 | 53 | if ($_filepath !== false) { 54 | if (is_object($_template->smarty->security_policy)) { 55 | $_template->smarty->security_policy->isTrustedResourceDir($_filepath); 56 | } 57 | } 58 | $_template->templateUid = sha1($_filepath); 59 | return $_filepath; 60 | } 61 | 62 | /** 63 | * Get timestamp to template source 64 | * 65 | * @param object $_template template object 66 | * @return integer timestamp of template source file 67 | */ 68 | public function getTemplateTimestamp($_template) 69 | { 70 | return filemtime($_template->getTemplateFilepath()); 71 | } 72 | 73 | /** 74 | * Read template source from file 75 | * 76 | * @param object $_template template object 77 | * @return string content of template source file 78 | */ 79 | public function getTemplateSource($_template) 80 | { 81 | // read template file 82 | if (file_exists($_tfp = $_template->getTemplateFilepath())) { 83 | $_template->template_source = file_get_contents($_tfp); 84 | return true; 85 | } else { 86 | return false; 87 | } 88 | } 89 | 90 | /** 91 | * Get filepath to compiled template 92 | * 93 | * @param object $_template template object 94 | * @return string return path to compiled template 95 | */ 96 | public function getCompiledFilepath($_template) 97 | { 98 | $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; 99 | // calculate Uid if not already done 100 | if ($_template->templateUid == '') { 101 | $_template->getTemplateFilepath(); 102 | } 103 | $_filepath = $_template->templateUid; 104 | // if use_sub_dirs, break file into directories 105 | if ($_template->smarty->use_sub_dirs) { 106 | $_filepath = substr($_filepath, 0, 2) . DS 107 | . substr($_filepath, 2, 2) . DS 108 | . substr($_filepath, 4, 2) . DS 109 | . $_filepath; 110 | } 111 | $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^'; 112 | if (isset($_compile_id)) { 113 | $_filepath = $_compile_id . $_compile_dir_sep . $_filepath; 114 | } 115 | if ($_template->caching) { 116 | $_cache = '.cache'; 117 | } else { 118 | $_cache = ''; 119 | } 120 | $_compile_dir = $_template->smarty->compile_dir; 121 | if (strpos('/\\', substr($_compile_dir, -1)) === false) { 122 | $_compile_dir .= DS; 123 | } 124 | return $_compile_dir . $_filepath . '.' . $_template->resource_type . '.' . basename($_template->resource_name) . $_cache . '.php'; 125 | } 126 | } 127 | 128 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_resource_php.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 23 | ini_set('short_open_tag', '1'); 24 | } 25 | // properties 26 | public $usesCompiler = false; 27 | public $isEvaluated = false; 28 | 29 | /** 30 | * Return flag if template source is existing 31 | * 32 | * @return boolean true 33 | */ 34 | public function isExisting($template) 35 | { 36 | if ($template->getTemplateFilepath() === false) { 37 | return false; 38 | } else { 39 | return true; 40 | } 41 | } 42 | 43 | /** 44 | * Get filepath to template source 45 | * 46 | * @param object $_template template object 47 | * @return string filepath to template source file 48 | */ 49 | public function getTemplateFilepath($_template) 50 | { 51 | $_filepath = $_template->buildTemplateFilepath (); 52 | 53 | if (is_object($_template->smarty->security_policy)) { 54 | $_template->smarty->security_policy->isTrustedResourceDir($_filepath); 55 | } 56 | $_template->templateUid = sha1($_filepath); 57 | return $_filepath; 58 | } 59 | 60 | /** 61 | * Get timestamp to template source 62 | * 63 | * @param object $_template template object 64 | * @return integer timestamp of template source file 65 | */ 66 | public function getTemplateTimestamp($_template) 67 | { 68 | return filemtime($_template->getTemplateFilepath()); 69 | } 70 | 71 | /** 72 | * Read template source from file 73 | * 74 | * @param object $_template template object 75 | * @return string content of template source file 76 | */ 77 | public function getTemplateSource($_template) 78 | { 79 | if (file_exists($_tfp = $_template->getTemplateFilepath())) { 80 | $_template->template_source = file_get_contents($_tfp); 81 | return true; 82 | } else { 83 | return false; 84 | } 85 | } 86 | 87 | /** 88 | * Get filepath to compiled template 89 | * 90 | * @param object $_template template object 91 | * @return boolean return false as compiled template is not stored 92 | */ 93 | public function getCompiledFilepath($_template) 94 | { 95 | // no filepath for PHP templates 96 | return false; 97 | } 98 | 99 | /** 100 | * renders the PHP template 101 | */ 102 | public function renderUncompiled($_smarty_template) 103 | { 104 | if (!$this->smarty->allow_php_templates) { 105 | throw new SmartyException("PHP templates are disabled"); 106 | } 107 | if ($this->getTemplateFilepath($_smarty_template) === false) { 108 | throw new SmartyException("Unable to load template \"{$_smarty_template->resource_type} : {$_smarty_template->resource_name}\""); 109 | } 110 | // prepare variables 111 | $_smarty_ptr = $_smarty_template; 112 | do { 113 | foreach ($_smarty_ptr->tpl_vars as $_smarty_var => $_smarty_var_object) { 114 | if (isset($_smarty_var_object->value)) { 115 | $$_smarty_var = $_smarty_var_object->value; 116 | } 117 | } 118 | $_smarty_ptr = $_smarty_ptr->parent; 119 | } while ($_smarty_ptr != null); 120 | unset ($_smarty_var, $_smarty_var_object, $_smarty_ptr); 121 | // include PHP template 122 | include($this->getTemplateFilepath($_smarty_template)); 123 | return; 124 | } 125 | } 126 | 127 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_resource_stream.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 20 | } 21 | // classes used for compiling Smarty templates from file resource 22 | public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; 23 | public $template_lexer_class = 'Smarty_Internal_Templatelexer'; 24 | public $template_parser_class = 'Smarty_Internal_Templateparser'; 25 | // properties 26 | public $usesCompiler = true; 27 | public $isEvaluated = true; 28 | 29 | /** 30 | * Return flag if template source is existing 31 | * 32 | * @return boolean true 33 | */ 34 | public function isExisting($template) 35 | { 36 | if ($template->getTemplateSource() == '') { 37 | return false; 38 | } else { 39 | return true; 40 | } 41 | } 42 | /** 43 | * Get filepath to template source 44 | * 45 | * @param object $_template template object 46 | * @return string return 'string' as template source is not a file 47 | */ 48 | public function getTemplateFilepath($_template) 49 | { 50 | // no filepath for strings 51 | // return resource name for compiler error messages 52 | return str_replace(':', '://', $_template->template_resource); 53 | } 54 | 55 | /** 56 | * Get timestamp to template source 57 | * 58 | * @param object $_template template object 59 | * @return boolean false as string resources have no timestamp 60 | */ 61 | public function getTemplateTimestamp($_template) 62 | { 63 | // strings must always be compiled and have no timestamp 64 | return false; 65 | } 66 | 67 | /** 68 | * Retuen template source from resource name 69 | * 70 | * @param object $_template template object 71 | * @return string content of template source 72 | */ 73 | public function getTemplateSource($_template) 74 | { 75 | // return template string 76 | $_template->template_source = ''; 77 | if ($fp = fopen(str_replace(':', '://', $_template->template_resource),'r+')) { 78 | while (!feof($fp) && ($current_line = fgets($fp)) !== false ) { 79 | $_template->template_source .= $current_line; 80 | } 81 | fclose($fp); 82 | return true; 83 | } else { 84 | return false; 85 | } 86 | } 87 | 88 | /** 89 | * Get filepath to compiled template 90 | * 91 | * @param object $_template template object 92 | * @return boolean return false as compiled template is not stored 93 | */ 94 | public function getCompiledFilepath($_template) 95 | { 96 | // no filepath for strings 97 | return false; 98 | } 99 | } 100 | 101 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_resource_string.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 20 | } 21 | // classes used for compiling Smarty templates from file resource 22 | public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; 23 | public $template_lexer_class = 'Smarty_Internal_Templatelexer'; 24 | public $template_parser_class = 'Smarty_Internal_Templateparser'; 25 | // properties 26 | public $usesCompiler = true; 27 | public $isEvaluated = false; 28 | 29 | /** 30 | * Return flag if template source is existing 31 | * 32 | * @return boolean true 33 | */ 34 | public function isExisting($template) 35 | { 36 | return true; 37 | } 38 | 39 | /** 40 | * Get filepath to template source 41 | * 42 | * @param object $_template template object 43 | * @return string return 'string' as template source is not a file 44 | */ 45 | public function getTemplateFilepath($_template) 46 | { 47 | $_template->templateUid = sha1($_template->resource_name); 48 | // no filepath for strings 49 | // return "string" for compiler error messages 50 | return 'string:'; 51 | } 52 | 53 | /** 54 | * Get timestamp to template source 55 | * 56 | * @param object $_template template object 57 | * @return boolean false as string resources have no timestamp 58 | */ 59 | public function getTemplateTimestamp($_template) 60 | { 61 | if ($this->isEvaluated) { 62 | //must always be compiled and have no timestamp 63 | return false; 64 | } else { 65 | return 0; 66 | } 67 | } 68 | 69 | /** 70 | * Get timestamp of template source by type and name 71 | * 72 | * @param object $_template template object 73 | * @return int timestamp (always 0) 74 | */ 75 | public function getTemplateTimestampTypeName($_resource_type, $_resource_name) 76 | { 77 | // return timestamp 0 78 | return 0; 79 | } 80 | 81 | 82 | /** 83 | * Retuen template source from resource name 84 | * 85 | * @param object $_template template object 86 | * @return string content of template source 87 | */ 88 | public function getTemplateSource($_template) 89 | { 90 | // return template string 91 | $_template->template_source = $_template->resource_name; 92 | return true; 93 | } 94 | 95 | /** 96 | * Get filepath to compiled template 97 | * 98 | * @param object $_template template object 99 | * @return boolean return false as compiled template is not stored 100 | */ 101 | public function getCompiledFilepath($_template) 102 | { 103 | $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; 104 | // calculate Uid if not already done 105 | if ($_template->templateUid == '') { 106 | $_template->getTemplateFilepath(); 107 | } 108 | $_filepath = $_template->templateUid; 109 | // if use_sub_dirs, break file into directories 110 | if ($_template->smarty->use_sub_dirs) { 111 | $_filepath = substr($_filepath, 0, 2) . DS 112 | . substr($_filepath, 2, 2) . DS 113 | . substr($_filepath, 4, 2) . DS 114 | . $_filepath; 115 | } 116 | $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^'; 117 | if (isset($_compile_id)) { 118 | $_filepath = $_compile_id . $_compile_dir_sep . $_filepath; 119 | } 120 | if ($_template->caching) { 121 | $_cache = '.cache'; 122 | } else { 123 | $_cache = ''; 124 | } 125 | $_compile_dir = $_template->smarty->compile_dir; 126 | if (strpos('/\\', substr($_compile_dir, -1)) === false) { 127 | $_compile_dir .= DS; 128 | } 129 | return $_compile_dir . $_filepath . '.' . $_template->resource_type . $_cache . '.php'; 130 | } 131 | } 132 | 133 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_smartytemplatecompiler.php: -------------------------------------------------------------------------------- 1 | smarty = $smarty; 27 | parent::__construct(); 28 | // get required plugins 29 | $this->lexer_class = $lexer_class; 30 | $this->parser_class = $parser_class; 31 | } 32 | 33 | /** 34 | * Methode to compile a Smarty template 35 | * 36 | * @param $_content template source 37 | * @return bool true if compiling succeeded, false if it failed 38 | */ 39 | protected function doCompile($_content) 40 | { 41 | /* here is where the compiling takes place. Smarty 42 | tags in the templates are replaces with PHP code, 43 | then written to compiled files. */ 44 | // init the lexer/parser to compile the template 45 | $this->lex = new $this->lexer_class($_content, $this); 46 | $this->parser = new $this->parser_class($this->lex, $this); 47 | if (isset($this->smarty->_parserdebug)) $this->parser->PrintTrace(); 48 | // get tokens from lexer and parse them 49 | while ($this->lex->yylex() && !$this->abort_and_recompile) { 50 | if (isset($this->smarty->_parserdebug)) echo "
Line {$this->lex->line} Parsing  {$this->parser->yyTokenName[$this->lex->token]} Token " . htmlentities($this->lex->value) . "
"; 51 | $this->parser->doParse($this->lex->token, $this->lex->value); 52 | } 53 | 54 | if ($this->abort_and_recompile) { 55 | // exit here on abort 56 | return false; 57 | } 58 | // finish parsing process 59 | $this->parser->doParse(0, 0); 60 | // check for unclosed tags 61 | if (count($this->_tag_stack) > 0) { 62 | // get stacked info 63 | list($_open_tag, $_data) = array_pop($this->_tag_stack); 64 | $this->trigger_template_error("unclosed {" . $_open_tag . "} tag"); 65 | } 66 | // return compiled code 67 | // return str_replace(array("? >\nparser->retvalue); 68 | return $this->parser->retvalue; 69 | } 70 | } 71 | 72 | ?> -------------------------------------------------------------------------------- /smarty/sysplugins/smarty_internal_write_file.php: -------------------------------------------------------------------------------- 1 | _dir_perms, true); 29 | } 30 | // write to tmp file, then move to overt file lock race condition 31 | $_tmp_file = tempnam($_dirpath, 'wrt'); 32 | 33 | if (!($fd = @fopen($_tmp_file, 'wb'))) { 34 | $_tmp_file = $_dirpath . DS . uniqid('wrt'); 35 | if (!($fd = @fopen($_tmp_file, 'wb'))) { 36 | throw new SmartyException("unable to write file {$_tmp_file}"); 37 | return false; 38 | } 39 | } 40 | 41 | fwrite($fd, $_contents); 42 | fclose($fd); 43 | 44 | // remove original file 45 | if (file_exists($_filepath)) 46 | @unlink($_filepath); 47 | // rename tmp file 48 | rename($_tmp_file, $_filepath); 49 | // set file permissions 50 | chmod($_filepath, $smarty->_file_perms); 51 | umask($old_umask); 52 | return true; 53 | } 54 | } 55 | 56 | ?> -------------------------------------------------------------------------------- /templates/admin.tpl: -------------------------------------------------------------------------------- 1 | {extends file="page.tpl"} 2 | 3 | {block name="body"} 4 |
5 | 6 | 7 | 8 |
9 |
10 | 11 | 12 | 13 |
14 |
15 | {foreach $feeds as $feed} 16 |
17 | {$feed["feed"]} 18 |
19 | 20 | 21 | Max Items: 22 |
23 | 27 | items that match 28 | 32 | of the following rules: 33 | 34 |
35 | 36 | 37 | 40 | 43 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 55 | 62 | 65 | 68 | 69 | 70 | {foreach $feed["patterns"] as $pattern} 71 | 72 | 73 | 74 | 75 | 78 | 81 | 82 | 83 | 84 | 85 | {/foreach} 86 |
38 | Regex 39 | 41 | Field 42 | 44 | Case Insensitive 45 |
53 | //s 54 | 56 | 61 | 63 | 64 | 66 | 67 |
76 | {$pattern["regex"]} 77 | 79 | {$pattern["field"]} 80 |
87 | {/foreach} 88 | Aggregate Feeds 89 |
90 | {foreach $aggregates as $feed} 91 |
92 | {$feed["feeds"]|nl2br} 93 |
94 | Note: Articles will be sourced from the first feed in the list, all others will simply be used as filters 95 |
96 | 97 | 98 | 99 | 100 |
101 | {/foreach} 102 | {/block} 103 | -------------------------------------------------------------------------------- /templates/page.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RSS Filters 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | {block name="body"}{/block} 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /test.php: -------------------------------------------------------------------------------- 1 | enable_cache(false); 14 | $feed->set_feed_url($url); 15 | $feed->init(); 16 | // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it). 17 | $feed->handle_content_type(); 18 | 19 | foreach($feed->get_items() as $item) { 20 | $title = $item->get_title(); 21 | $summary = $item->get_description(); 22 | 23 | $articles[$i][$title] = $summary; 24 | } 25 | 26 | $i++; 27 | } 28 | 29 | $articles2 = $articles; 30 | 31 | foreach($articles as $src1=>$feedArticles) { 32 | foreach($feedArticles as $title=>$article) { 33 | foreach($articles2 as $src2=>$feedArticles2) { 34 | if($src1 == $src2) { 35 | continue; 36 | } 37 | foreach($feedArticles2 as $title2=>$article2) { 38 | $similarity; 39 | similar_text($title, $title2, $similarity); 40 | if($similarity > 60) { 41 | print $similarity." - ".$title." - ".$title2."
"; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | ?> --------------------------------------------------------------------------------