[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Project: Smarty: the PHP compiling template engine 4 * File: smarty_internal_utility.php 5 * SVN: $Id: $ 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 21 * For questions, help, comments, discussion, etc., please join the 22 * Smarty mailing list. Send a blank e-mail to 23 * [email protected] 24 * 25 * @link http://www.smarty.net/ 26 * @copyright 2008 New Digital Group, Inc. 27 * @author Monte Ohrt <monte at ohrt dot com> 28 * @author Uwe Tews 29 * @package Smarty 30 * @subpackage PluginsInternal 31 * @version 3-SVN$Rev: 3286 $ 32 */ 33 34 35 /** 36 * Utility class 37 * 38 * @package Smarty 39 * @subpackage Security 40 */ 41 class Smarty_Internal_Utility { 42 43 /** 44 * private constructor to prevent calls creation of new instances 45 */ 46 private final function __construct() 47 { 48 // intentionally left blank 49 } 50 51 /** 52 * Compile all template files 53 * 54 * @param string $extension template file name extension 55 * @param bool $force_compile force all to recompile 56 * @param int $time_limit set maximum execution time 57 * @param int $max_errors set maximum allowed errors 58 * @param Smarty $smarty Smarty instance 59 * @return integer number of template files compiled 60 */ 61 public static function compileAllTemplates($extention, $force_compile, $time_limit, $max_errors, Smarty $smarty) 62 { 63 // switch off time limit 64 if (function_exists('set_time_limit')) { 65 @set_time_limit($time_limit); 66 } 67 $smarty->force_compile = $force_compile; 68 $_count = 0; 69 $_error_count = 0; 70 // loop over array of template directories 71 foreach($smarty->getTemplateDir() as $_dir) { 72 $_compileDirs = new RecursiveDirectoryIterator($_dir); 73 $_compile = new RecursiveIteratorIterator($_compileDirs); 74 foreach ($_compile as $_fileinfo) { 75 if (substr($_fileinfo->getBasename(),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue; 76 $_file = $_fileinfo->getFilename(); 77 if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue; 78 if ($_fileinfo->getPath() == substr($_dir, 0, -1)) { 79 $_template_file = $_file; 80 } else { 81 $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; 82 } 83 echo '<br>', $_dir, '---', $_template_file; 84 flush(); 85 $_start_time = microtime(true); 86 try { 87 $_tpl = $smarty->createTemplate($_template_file,null,null,null,false); 88 if ($_tpl->mustCompile()) { 89 $_tpl->compileTemplateSource(); 90 echo ' compiled in ', microtime(true) - $_start_time, ' seconds'; 91 flush(); 92 } else { 93 echo ' is up to date'; 94 flush(); 95 } 96 } 97 catch (Exception $e) { 98 echo 'Error: ', $e->getMessage(), "<br><br>"; 99 $_error_count++; 100 } 101 // free memory 102 $smarty->template_objects = array(); 103 $_tpl->smarty->template_objects = array(); 104 $_tpl = null; 105 if ($max_errors !== null && $_error_count == $max_errors) { 106 echo '<br><br>too many errors'; 107 exit(); 108 } 109 } 110 } 111 return $_count; 112 } 113 114 /** 115 * Compile all config files 116 * 117 * @param string $extension config file name extension 118 * @param bool $force_compile force all to recompile 119 * @param int $time_limit set maximum execution time 120 * @param int $max_errors set maximum allowed errors 121 * @param Smarty $smarty Smarty instance 122 * @return integer number of config files compiled 123 */ 124 public static function compileAllConfig($extention, $force_compile, $time_limit, $max_errors, Smarty $smarty) 125 { 126 // switch off time limit 127 if (function_exists('set_time_limit')) { 128 @set_time_limit($time_limit); 129 } 130 $smarty->force_compile = $force_compile; 131 $_count = 0; 132 $_error_count = 0; 133 // loop over array of template directories 134 foreach($smarty->getConfigDir() as $_dir) { 135 $_compileDirs = new RecursiveDirectoryIterator($_dir); 136 $_compile = new RecursiveIteratorIterator($_compileDirs); 137 foreach ($_compile as $_fileinfo) { 138 if (substr($_fileinfo->getBasename(),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue; 139 $_file = $_fileinfo->getFilename(); 140 if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue; 141 if ($_fileinfo->getPath() == substr($_dir, 0, -1)) { 142 $_config_file = $_file; 143 } else { 144 $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; 145 } 146 echo '<br>', $_dir, '---', $_config_file; 147 flush(); 148 $_start_time = microtime(true); 149 try { 150 $_config = new Smarty_Internal_Config($_config_file, $smarty); 151 if ($_config->mustCompile()) { 152 $_config->compileConfigSource(); 153 echo ' compiled in ', microtime(true) - $_start_time, ' seconds'; 154 flush(); 155 } else { 156 echo ' is up to date'; 157 flush(); 158 } 159 } 160 catch (Exception $e) { 161 echo 'Error: ', $e->getMessage(), "<br><br>"; 162 $_error_count++; 163 } 164 if ($max_errors !== null && $_error_count == $max_errors) { 165 echo '<br><br>too many errors'; 166 exit(); 167 } 168 } 169 } 170 return $_count; 171 } 172 173 /** 174 * Delete compiled template file 175 * 176 * @param string $resource_name template name 177 * @param string $compile_id compile id 178 * @param integer $exp_time expiration time 179 * @param Smarty $smarty Smarty instance 180 * @return integer number of template files deleted 181 */ 182 public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty) 183 { 184 $_compile_dir = $smarty->getCompileDir(); 185 $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; 186 $_dir_sep = $smarty->use_sub_dirs ? DS : '^'; 187 if (isset($resource_name)) { 188 $_save_stat = $smarty->caching; 189 $smarty->caching = false; 190 $tpl = new $smarty->template_class($resource_name, $smarty); 191 $smarty->caching = $_save_stat; 192 193 // remove from template cache 194 $tpl->source; // have the template registered before unset() 195 if ($smarty->allow_ambiguous_resources) { 196 $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; 197 } else { 198 $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id; 199 } 200 if (isset($_templateId[150])) { 201 $_templateId = sha1($_templateId); 202 } 203 unset($smarty->template_objects[$_templateId]); 204 205 if ($tpl->source->exists) { 206 $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath)); 207 $_resource_part_1_length = strlen($_resource_part_1); 208 } else { 209 return 0; 210 } 211 212 $_resource_part_2 = str_replace('.php','.cache.php',$_resource_part_1); 213 $_resource_part_2_length = strlen($_resource_part_2); 214 } else { 215 $_resource_part = ''; 216 } 217 $_dir = $_compile_dir; 218 if ($smarty->use_sub_dirs && isset($_compile_id)) { 219 $_dir .= $_compile_id . $_dir_sep; 220 } 221 if (isset($_compile_id)) { 222 $_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep; 223 $_compile_id_part_length = strlen($_compile_id_part); 224 } 225 $_count = 0; 226 try { 227 $_compileDirs = new RecursiveDirectoryIterator($_dir); 228 // NOTE: UnexpectedValueException thrown for PHP >= 5.3 229 } catch (Exception $e) { 230 return 0; 231 } 232 $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST); 233 foreach ($_compile as $_file) { 234 if (substr($_file->getBasename(), 0, 1) == '.' || strpos($_file, '.svn') !== false) 235 continue; 236 237 $_filepath = (string) $_file; 238 239 if ($_file->isDir()) { 240 if (!$_compile->isDot()) { 241 // delete folder if empty 242 @rmdir($_file->getPathname()); 243 } 244 } else { 245 $unlink = false; 246 if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) 247 && (!isset($resource_name) 248 || (isset($_filepath[$_resource_part_1_length]) 249 && substr_compare($_filepath, $_resource_part_1, -$_resource_part_1_length, $_resource_part_1_length) == 0) 250 || (isset($_filepath[$_resource_part_2_length]) 251 && substr_compare($_filepath, $_resource_part_2, -$_resource_part_2_length, $_resource_part_2_length) == 0))) { 252 if (isset($exp_time)) { 253 if (time() - @filemtime($_filepath) >= $exp_time) { 254 $unlink = true; 255 } 256 } else { 257 $unlink = true; 258 } 259 } 260 261 if ($unlink && @unlink($_filepath)) { 262 $_count++; 263 } 264 } 265 } 266 // clear compiled cache 267 Smarty_Resource::$sources = array(); 268 Smarty_Resource::$compileds = array(); 269 return $_count; 270 } 271 272 /** 273 * Return array of tag/attributes of all tags used by an template 274 * 275 * @param Smarty_Internal_Template $templae template object 276 * @return array of tag/attributes 277 */ 278 public static function getTags(Smarty_Internal_Template $template) 279 { 280 $template->smarty->get_used_tags = true; 281 $template->compileTemplateSource(); 282 return $template->used_tags; 283 } 284 285 286 /** 287 * diagnose Smarty setup 288 * 289 * If $errors is secified, the diagnostic report will be appended to the array, rather than being output. 290 * 291 * @param Smarty $smarty Smarty instance to test 292 * @param array $errors array to push results into rather than outputting them 293 * @return bool status, true if everything is fine, false else 294 */ 295 public static function testInstall(Smarty $smarty, &$errors=null) 296 { 297 $status = true; 298 299 if ($errors === null) { 300 echo "<PRE>\n"; 301 echo "Smarty Installation test...\n"; 302 echo "Testing template directory...\n"; 303 } 304 305 // test if all registered template_dir are accessible 306 foreach($smarty->getTemplateDir() as $template_dir) { 307 $_template_dir = $template_dir; 308 $template_dir = realpath($template_dir); 309 // resolve include_path or fail existance 310 if (!$template_dir) { 311 if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) { 312 // try PHP include_path 313 if (($template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir)) !== false) { 314 if ($errors === null) { 315 echo "$template_dir is OK.\n"; 316 } 317 318 continue; 319 } else { 320 $status = false; 321 $message = "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)"; 322 if ($errors === null) { 323 echo $message . ".\n"; 324 } else { 325 $errors['template_dir'] = $message; 326 } 327 328 continue; 329 } 330 } else { 331 $status = false; 332 $message = "FAILED: $_template_dir does not exist"; 333 if ($errors === null) { 334 echo $message . ".\n"; 335 } else { 336 $errors['template_dir'] = $message; 337 } 338 339 continue; 340 } 341 } 342 343 if (!is_dir($template_dir)) { 344 $status = false; 345 $message = "FAILED: $template_dir is not a directory"; 346 if ($errors === null) { 347 echo $message . ".\n"; 348 } else { 349 $errors['template_dir'] = $message; 350 } 351 } elseif (!is_readable($template_dir)) { 352 $status = false; 353 $message = "FAILED: $template_dir is not readable"; 354 if ($errors === null) { 355 echo $message . ".\n"; 356 } else { 357 $errors['template_dir'] = $message; 358 } 359 } else { 360 if ($errors === null) { 361 echo "$template_dir is OK.\n"; 362 } 363 } 364 } 365 366 367 if ($errors === null) { 368 echo "Testing compile directory...\n"; 369 } 370 371 // test if registered compile_dir is accessible 372 $__compile_dir = $smarty->getCompileDir(); 373 $_compile_dir = realpath($__compile_dir); 374 if (!$_compile_dir) { 375 $status = false; 376 $message = "FAILED: {$__compile_dir} does not exist"; 377 if ($errors === null) { 378 echo $message . ".\n"; 379 } else { 380 $errors['compile_dir'] = $message; 381 } 382 } elseif (!is_dir($_compile_dir)) { 383 $status = false; 384 $message = "FAILED: {$_compile_dir} is not a directory"; 385 if ($errors === null) { 386 echo $message . ".\n"; 387 } else { 388 $errors['compile_dir'] = $message; 389 } 390 } elseif (!is_readable($_compile_dir)) { 391 $status = false; 392 $message = "FAILED: {$_compile_dir} is not readable"; 393 if ($errors === null) { 394 echo $message . ".\n"; 395 } else { 396 $errors['compile_dir'] = $message; 397 } 398 } elseif (!is_writable($_compile_dir)) { 399 $status = false; 400 $message = "FAILED: {$_compile_dir} is not writable"; 401 if ($errors === null) { 402 echo $message . ".\n"; 403 } else { 404 $errors['compile_dir'] = $message; 405 } 406 } else { 407 if ($errors === null) { 408 echo "{$_compile_dir} is OK.\n"; 409 } 410 } 411 412 413 if ($errors === null) { 414 echo "Testing plugins directory...\n"; 415 } 416 417 // test if all registered plugins_dir are accessible 418 // and if core plugins directory is still registered 419 $_core_plugins_dir = realpath(dirname(__FILE__) .'/../plugins'); 420 $_core_plugins_available = false; 421 foreach($smarty->getPluginsDir() as $plugin_dir) { 422 $_plugin_dir = $plugin_dir; 423 $plugin_dir = realpath($plugin_dir); 424 // resolve include_path or fail existance 425 if (!$plugin_dir) { 426 if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { 427 // try PHP include_path 428 if (($plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir)) !== false) { 429 if ($errors === null) { 430 echo "$plugin_dir is OK.\n"; 431 } 432 433 continue; 434 } else { 435 $status = false; 436 $message = "FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)"; 437 if ($errors === null) { 438 echo $message . ".\n"; 439 } else { 440 $errors['plugins_dir'] = $message; 441 } 442 443 continue; 444 } 445 } else { 446 $status = false; 447 $message = "FAILED: $_plugin_dir does not exist"; 448 if ($errors === null) { 449 echo $message . ".\n"; 450 } else { 451 $errors['plugins_dir'] = $message; 452 } 453 454 continue; 455 } 456 } 457 458 if (!is_dir($plugin_dir)) { 459 $status = false; 460 $message = "FAILED: $plugin_dir is not a directory"; 461 if ($errors === null) { 462 echo $message . ".\n"; 463 } else { 464 $errors['plugins_dir'] = $message; 465 } 466 } elseif (!is_readable($plugin_dir)) { 467 $status = false; 468 $message = "FAILED: $plugin_dir is not readable"; 469 if ($errors === null) { 470 echo $message . ".\n"; 471 } else { 472 $errors['plugins_dir'] = $message; 473 } 474 } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) { 475 $_core_plugins_available = true; 476 if ($errors === null) { 477 echo "$plugin_dir is OK.\n"; 478 } 479 } else { 480 if ($errors === null) { 481 echo "$plugin_dir is OK.\n"; 482 } 483 } 484 } 485 if (!$_core_plugins_available) { 486 $status = false; 487 $message = "WARNING: Smarty's own libs/plugins is not available"; 488 if ($errors === null) { 489 echo $message . ".\n"; 490 } elseif (!isset($errors['plugins_dir'])) { 491 $errors['plugins_dir'] = $message; 492 } 493 } 494 495 if ($errors === null) { 496 echo "Testing cache directory...\n"; 497 } 498 499 500 // test if all registered cache_dir is accessible 501 $__cache_dir = $smarty->getCacheDir(); 502 $_cache_dir = realpath($__cache_dir); 503 if (!$_cache_dir) { 504 $status = false; 505 $message = "FAILED: {$__cache_dir} does not exist"; 506 if ($errors === null) { 507 echo $message . ".\n"; 508 } else { 509 $errors['cache_dir'] = $message; 510 } 511 } elseif (!is_dir($_cache_dir)) { 512 $status = false; 513 $message = "FAILED: {$_cache_dir} is not a directory"; 514 if ($errors === null) { 515 echo $message . ".\n"; 516 } else { 517 $errors['cache_dir'] = $message; 518 } 519 } elseif (!is_readable($_cache_dir)) { 520 $status = false; 521 $message = "FAILED: {$_cache_dir} is not readable"; 522 if ($errors === null) { 523 echo $message . ".\n"; 524 } else { 525 $errors['cache_dir'] = $message; 526 } 527 } elseif (!is_writable($_cache_dir)) { 528 $status = false; 529 $message = "FAILED: {$_cache_dir} is not writable"; 530 if ($errors === null) { 531 echo $message . ".\n"; 532 } else { 533 $errors['cache_dir'] = $message; 534 } 535 } else { 536 if ($errors === null) { 537 echo "{$_cache_dir} is OK.\n"; 538 } 539 } 540 541 542 if ($errors === null) { 543 echo "Testing configs directory...\n"; 544 } 545 546 // test if all registered config_dir are accessible 547 foreach($smarty->getConfigDir() as $config_dir) { 548 $_config_dir = $config_dir; 549 $config_dir = realpath($config_dir); 550 // resolve include_path or fail existance 551 if (!$config_dir) { 552 if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) { 553 // try PHP include_path 554 if (($config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir)) !== false) { 555 if ($errors === null) { 556 echo "$config_dir is OK.\n"; 557 } 558 559 continue; 560 } else { 561 $status = false; 562 $message = "FAILED: $_config_dir does not exist (and couldn't be found in include_path either)"; 563 if ($errors === null) { 564 echo $message . ".\n"; 565 } else { 566 $errors['config_dir'] = $message; 567 } 568 569 continue; 570 } 571 } else { 572 $status = false; 573 $message = "FAILED: $_config_dir does not exist"; 574 if ($errors === null) { 575 echo $message . ".\n"; 576 } else { 577 $errors['config_dir'] = $message; 578 } 579 580 continue; 581 } 582 } 583 584 if (!is_dir($config_dir)) { 585 $status = false; 586 $message = "FAILED: $config_dir is not a directory"; 587 if ($errors === null) { 588 echo $message . ".\n"; 589 } else { 590 $errors['config_dir'] = $message; 591 } 592 } elseif (!is_readable($config_dir)) { 593 $status = false; 594 $message = "FAILED: $config_dir is not readable"; 595 if ($errors === null) { 596 echo $message . ".\n"; 597 } else { 598 $errors['config_dir'] = $message; 599 } 600 } else { 601 if ($errors === null) { 602 echo "$config_dir is OK.\n"; 603 } 604 } 605 } 606 607 608 if ($errors === null) { 609 echo "Testing sysplugin files...\n"; 610 } 611 // test if sysplugins are available 612 $source = SMARTY_SYSPLUGINS_DIR; 613 if (is_dir($source)) { 614 $expected = array( 615 "smarty_cacheresource.php" => true, 616 "smarty_cacheresource_custom.php" => true, 617 "smarty_cacheresource_keyvaluestore.php" => true, 618 "smarty_config_source.php" => true, 619 "smarty_internal_cacheresource_file.php" => true, 620 "smarty_internal_compile_append.php" => true, 621 "smarty_internal_compile_assign.php" => true, 622 "smarty_internal_compile_block.php" => true, 623 "smarty_internal_compile_break.php" => true, 624 "smarty_internal_compile_call.php" => true, 625 "smarty_internal_compile_capture.php" => true, 626 "smarty_internal_compile_config_load.php" => true, 627 "smarty_internal_compile_continue.php" => true, 628 "smarty_internal_compile_debug.php" => true, 629 "smarty_internal_compile_eval.php" => true, 630 "smarty_internal_compile_extends.php" => true, 631 "smarty_internal_compile_for.php" => true, 632 "smarty_internal_compile_foreach.php" => true, 633 "smarty_internal_compile_function.php" => true, 634 "smarty_internal_compile_if.php" => true, 635 "smarty_internal_compile_include.php" => true, 636 "smarty_internal_compile_include_php.php" => true, 637 "smarty_internal_compile_insert.php" => true, 638 "smarty_internal_compile_ldelim.php" => true, 639 "smarty_internal_compile_nocache.php" => true, 640 "smarty_internal_compile_private_block_plugin.php" => true, 641 "smarty_internal_compile_private_function_plugin.php" => true, 642 "smarty_internal_compile_private_modifier.php" => true, 643 "smarty_internal_compile_private_object_block_function.php" => true, 644 "smarty_internal_compile_private_object_function.php" => true, 645 "smarty_internal_compile_private_print_expression.php" => true, 646 "smarty_internal_compile_private_registered_block.php" => true, 647 "smarty_internal_compile_private_registered_function.php" => true, 648 "smarty_internal_compile_private_special_variable.php" => true, 649 "smarty_internal_compile_rdelim.php" => true, 650 "smarty_internal_compile_section.php" => true, 651 "smarty_internal_compile_setfilter.php" => true, 652 "smarty_internal_compile_while.php" => true, 653 "smarty_internal_compilebase.php" => true, 654 "smarty_internal_config.php" => true, 655 "smarty_internal_config_file_compiler.php" => true, 656 "smarty_internal_configfilelexer.php" => true, 657 "smarty_internal_configfileparser.php" => true, 658 "smarty_internal_data.php" => true, 659 "smarty_internal_debug.php" => true, 660 "smarty_internal_filter_handler.php" => true, 661 "smarty_internal_function_call_handler.php" => true, 662 "smarty_internal_get_include_path.php" => true, 663 "smarty_internal_nocache_insert.php" => true, 664 "smarty_internal_parsetree.php" => true, 665 "smarty_internal_resource_eval.php" => true, 666 "smarty_internal_resource_extends.php" => true, 667 "smarty_internal_resource_file.php" => true, 668 "smarty_internal_resource_registered.php" => true, 669 "smarty_internal_resource_stream.php" => true, 670 "smarty_internal_resource_string.php" => true, 671 "smarty_internal_smartytemplatecompiler.php" => true, 672 "smarty_internal_template.php" => true, 673 "smarty_internal_templatebase.php" => true, 674 "smarty_internal_templatecompilerbase.php" => true, 675 "smarty_internal_templatelexer.php" => true, 676 "smarty_internal_templateparser.php" => true, 677 "smarty_internal_utility.php" => true, 678 "smarty_internal_write_file.php" => true, 679 "smarty_resource.php" => true, 680 "smarty_resource_custom.php" => true, 681 "smarty_resource_recompiled.php" => true, 682 "smarty_resource_uncompiled.php" => true, 683 "smarty_security.php" => true, 684 ); 685 $iterator = new DirectoryIterator($source); 686 foreach ($iterator as $file) { 687 if (!$file->isDot()) { 688 $filename = $file->getFilename(); 689 if (isset($expected[$filename])) { 690 unset($expected[$filename]); 691 } 692 } 693 } 694 if ($expected) { 695 $status = false; 696 $message = "FAILED: files missing from libs/sysplugins: ". join(', ', array_keys($expected)); 697 if ($errors === null) { 698 echo $message . ".\n"; 699 } else { 700 $errors['sysplugins'] = $message; 701 } 702 } elseif ($errors === null) { 703 echo "... OK\n"; 704 } 705 } else { 706 $status = false; 707 $message = "FAILED: ". SMARTY_SYSPLUGINS_DIR .' is not a directory'; 708 if ($errors === null) { 709 echo $message . ".\n"; 710 } else { 711 $errors['sysplugins_dir_constant'] = $message; 712 } 713 } 714 715 if ($errors === null) { 716 echo "Testing plugin files...\n"; 717 } 718 // test if core plugins are available 719 $source = SMARTY_PLUGINS_DIR; 720 if (is_dir($source)) { 721 $expected = array( 722 "block.textformat.php" => true, 723 "function.counter.php" => true, 724 "function.cycle.php" => true, 725 "function.fetch.php" => true, 726 "function.html_checkboxes.php" => true, 727 "function.html_image.php" => true, 728 "function.html_options.php" => true, 729 "function.html_radios.php" => true, 730 "function.html_select_date.php" => true, 731 "function.html_select_time.php" => true, 732 "function.html_table.php" => true, 733 "function.mailto.php" => true, 734 "function.math.php" => true, 735 "modifier.capitalize.php" => true, 736 "modifier.date_format.php" => true, 737 "modifier.debug_print_var.php" => true, 738 "modifier.escape.php" => true, 739 "modifier.regex_replace.php" => true, 740 "modifier.replace.php" => true, 741 "modifier.spacify.php" => true, 742 "modifier.truncate.php" => true, 743 "modifiercompiler.cat.php" => true, 744 "modifiercompiler.count_characters.php" => true, 745 "modifiercompiler.count_paragraphs.php" => true, 746 "modifiercompiler.count_sentences.php" => true, 747 "modifiercompiler.count_words.php" => true, 748 "modifiercompiler.default.php" => true, 749 "modifiercompiler.escape.php" => true, 750 "modifiercompiler.from_charset.php" => true, 751 "modifiercompiler.indent.php" => true, 752 "modifiercompiler.lower.php" => true, 753 "modifiercompiler.noprint.php" => true, 754 "modifiercompiler.string_format.php" => true, 755 "modifiercompiler.strip.php" => true, 756 "modifiercompiler.strip_tags.php" => true, 757 "modifiercompiler.to_charset.php" => true, 758 "modifiercompiler.unescape.php" => true, 759 "modifiercompiler.upper.php" => true, 760 "modifiercompiler.wordwrap.php" => true, 761 "outputfilter.trimwhitespace.php" => true, 762 "shared.escape_special_chars.php" => true, 763 "shared.literal_compiler_param.php" => true, 764 "shared.make_timestamp.php" => true, 765 "shared.mb_str_replace.php" => true, 766 "shared.mb_unicode.php" => true, 767 "shared.mb_wordwrap.php" => true, 768 "variablefilter.htmlspecialchars.php" => true, 769 ); 770 $iterator = new DirectoryIterator($source); 771 foreach ($iterator as $file) { 772 if (!$file->isDot()) { 773 $filename = $file->getFilename(); 774 if (isset($expected[$filename])) { 775 unset($expected[$filename]); 776 } 777 } 778 } 779 if ($expected) { 780 $status = false; 781 $message = "FAILED: files missing from libs/plugins: ". join(', ', array_keys($expected)); 782 if ($errors === null) { 783 echo $message . ".\n"; 784 } else { 785 $errors['plugins'] = $message; 786 } 787 } elseif ($errors === null) { 788 echo "... OK\n"; 789 } 790 } else { 791 $status = false; 792 $message = "FAILED: ". SMARTY_PLUGINS_DIR .' is not a directory'; 793 if ($errors === null) { 794 echo $message . ".\n"; 795 } else { 796 $errors['plugins_dir_constant'] = $message; 797 } 798 } 799 800 if ($errors === null) { 801 echo "Tests complete.\n"; 802 echo "</PRE>\n"; 803 } 804 805 return $status; 806 } 807 808 } 809 810 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |