Changeset 1766
- Timestamp:
- 01/21/2008 06:56:39 AM (9 months ago)
- Location:
- trunk
- Files:
-
- 45 modified
-
application/controllers/examples.php (modified) (2 diffs)
-
modules/auth/models/user.php (modified) (1 diff)
-
modules/media/controllers/media.php (modified) (11 diffs)
-
modules/media/libraries/JavaScriptPacker.php (modified) (47 diffs)
-
modules/user_guide/controllers/user_guide.php (modified) (1 diff)
-
modules/user_guide/views/user_guide/en/helpers/url.php (modified) (1 diff)
-
system/config/mimes.php (modified) (1 diff)
-
system/core/Event.php (modified) (1 diff)
-
system/core/utf8.php (modified) (1 diff)
-
system/helpers/html.php (modified) (1 diff)
-
system/helpers/url.php (modified) (1 diff)
-
system/i18n/13_37/image.php (modified) (1 diff)
-
system/i18n/de_DE/core.php (modified) (1 diff)
-
system/i18n/de_DE/image.php (modified) (1 diff)
-
system/i18n/en_US/image.php (modified) (1 diff)
-
system/i18n/es_ES/image.php (modified) (1 diff)
-
system/i18n/es_ES/validation.php (modified) (1 diff)
-
system/i18n/fr_FR/cache.php (modified) (1 diff)
-
system/i18n/fr_FR/core.php (modified) (1 diff)
-
system/i18n/fr_FR/database.php (modified) (1 diff)
-
system/i18n/fr_FR/image.php (modified) (1 diff)
-
system/i18n/fr_FR/inflector.php (modified) (1 diff)
-
system/i18n/fr_FR/profiler.php (modified) (1 diff)
-
system/i18n/fr_FR/upload.php (modified) (1 diff)
-
system/i18n/fr_FR/validation.php (modified) (2 diffs)
-
system/i18n/it_IT/errors.php (modified) (1 diff)
-
system/i18n/it_IT/image.php (modified) (1 diff)
-
system/i18n/mk_MK/image.php (modified) (1 diff)
-
system/i18n/nl_NL/image.php (modified) (1 diff)
-
system/i18n/nl_NL/upload.php (modified) (1 diff)
-
system/i18n/pl_PL/validation.php (modified) (1 diff)
-
system/i18n/pt_BR/image.php (modified) (1 diff)
-
system/libraries/Ftp.php (modified) (1 diff)
-
system/libraries/Payment.php (modified) (1 diff)
-
system/libraries/Validation.php (modified) (1 diff)
-
system/libraries/drivers/Database_Pdosqlite.php (modified) (5 diffs)
-
system/libraries/drivers/Database_Pgsql.php (modified) (5 diffs)
-
system/libraries/drivers/Payment_Authorize.php (modified) (3 diffs)
-
system/libraries/drivers/Payment_Paypal.php (modified) (2 diffs)
-
system/libraries/drivers/Payment_Trustcommerce.php (modified) (1 diff)
-
system/libraries/drivers/Payment_Yourpay.php (modified) (2 diffs)
-
system/views/pagination/classic.php (modified) (3 diffs)
-
system/views/pagination/digg.php (modified) (7 diffs)
-
system/views/pagination/extended.php (modified) (3 diffs)
-
system/views/pagination/punbb.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/application/controllers/examples.php
r1733 r1766 288 288 $credit_card = new Payment('Paypal'); 289 289 $credit_card = new Payment('Authorize'); 290 290 291 291 // You can specify one parameter at a time: 292 292 $credit_card->login = 'this'; … … 299 299 // Or you can also set fields with an array and the <Payment.set_fields> method: 300 300 $credit_card->set_fields(array('login' => 'test', 301 'first_name' => 'Jeremy',302 'last_name' => 'Bush',303 'card_num' => '1234567890',304 'exp_date' => '0910',305 'amount' => '487.41'));301 'first_name' => 'Jeremy', 302 'last_name' => 'Bush', 303 'card_num' => '1234567890', 304 'exp_date' => '0910', 305 'amount' => '487.41')); 306 306 307 307 echo '<pre>'.print_r($credit_card, true).'</pre>'; -
trunk/modules/auth/models/user.php
r1707 r1766 60 60 if (is_object($role)) 61 61 return parent::has_role($role); 62 62 63 63 // Make sure the role name is a string 64 64 $role = (string) $role; 65 65 66 66 if (ctype_digit($role)) 67 67 { -
trunk/modules/media/controllers/media.php
r1765 r1766 21 21 protected $use_cache = FALSE; 22 22 protected $cache_lifetime; 23 23 24 24 protected $pack_css = FALSE; 25 25 protected $pack_js = FALSE; 26 26 27 27 public function __construct() 28 28 { 29 29 parent::__construct(); 30 30 31 31 $cache = Config::item('media.cache'); 32 32 $this->use_cache = ($cache > 0); 33 33 34 34 if (is_int($cache)) 35 35 { … … 40 40 $this->cache_lifetime = config::item('cache.lifetime') OR $this->cache_lifetime = 1800; 41 41 } 42 42 43 43 if ($this->use_cache AND ! isset($this->cache)) 44 44 { 45 45 $this->load->library('cache'); 46 46 } 47 47 48 48 $this->pack_css = (bool) Config::item('media.pack_css'); 49 49 $this->pack_js = Config::item('media.pack_js'); 50 50 51 51 if ($this->pack_js === TRUE) 52 52 { … … 54 54 } 55 55 } 56 56 57 57 public function css() 58 58 { … … 62 62 $filename = substr($filename, 0, -4); 63 63 } 64 64 65 65 $mimetype = config::item('mimes.css'); 66 66 $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/stylesheet'; 67 67 68 68 $this->use_cache AND $data = $this->cache->get('media.css.'.$filename); 69 69 70 70 if ( ! isset($data) OR empty($data)) 71 71 { … … 87 87 } 88 88 } 89 89 90 90 if (isset($view)) 91 91 { 92 92 $data = $view->render(); 93 93 94 94 if ($this->pack_css) 95 95 { 96 96 $data = $this->_css_compress($data); 97 97 } 98 98 99 99 if ($this->use_cache) 100 100 { … … 107 107 } 108 108 } 109 109 110 110 $mimetype AND header('Content-type: '.$mimetype); 111 111 echo $data; … … 119 119 $filename = substr($filename, 0, -3); 120 120 } 121 121 122 122 $mimetype = Config::item('mimes.js'); 123 123 $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/javascript'; 124 124 125 125 126 126 $this->use_cache AND $data = $this->cache->get('media.js.'.$filename); 127 127 128 128 if ( ! isset($data) OR empty($data)) 129 129 { … … 145 145 } 146 146 } 147 147 148 148 if (isset($view)) 149 149 { 150 150 $data = $view->render(); 151 151 152 152 if ($this->pack_js) 153 153 { … … 155 155 $data = $packer->pack(); 156 156 } 157 157 158 158 if ($this->use_cache) 159 159 { … … 166 166 } 167 167 } 168 168 169 169 $mimetype AND header('Content-type: '.$mimetype); 170 170 echo $data; … … 184 184 // Remove comments 185 185 $data = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data); 186 186 187 187 // Remove tabs, spaces, newlines, etc. 188 188 $data = preg_replace('/\s+/s', ' ', $data); -
trunk/modules/media/libraries/JavaScriptPacker.php
r1641 r1766 73 73 private $_fastDecode = true; 74 74 private $_specialChars = false; 75 75 76 76 private $LITERAL_ENCODING = array( 77 77 'None' => 0, … … 80 80 'High ASCII' => 95 81 81 ); 82 82 83 83 public function __construct($_script, $_encoding = 62, $_fastDecode = true, $_specialChars = false) 84 84 { … … 90 90 $this->_specialChars = $_specialChars; 91 91 } 92 92 93 93 public function pack() { 94 94 $this->_addParser('_basicCompression'); … … 97 97 if ($this->_encoding) 98 98 $this->_addParser('_encodeKeywords'); 99 99 100 100 // go! 101 101 return $this->_pack($this->_script); 102 102 } 103 103 104 104 // apply all parsing routines 105 105 private function _pack($script) { … … 109 109 return $script; 110 110 } 111 111 112 112 // keep a list of parsing functions, they'll be executed all at once 113 113 private $_parsers = array(); … … 115 115 $this->_parsers[] = $parser; 116 116 } 117 117 118 118 // zero encoding - just removal of white space and comments 119 119 private function _basicCompression($script) { … … 145 145 return $parser->exec($script); 146 146 } 147 147 148 148 private function _encodeSpecialChars($script) { 149 149 $parser = new ParseMaster(); … … 158 158 // quick ref 159 159 $encoded = $keywords['encoded']; 160 160 161 161 $parser->add($regexp, 162 162 array( … … 167 167 return $parser->exec($script); 168 168 } 169 169 170 170 private function _encodeKeywords($script) { 171 171 // escape high-ascii values already in the script (i.e. in strings) … … 180 180 $keywords = $this->_analyze($script, $regexp, $encode); 181 181 $encoded = $keywords['encoded']; 182 182 183 183 // encode 184 184 $parser->add($regexp, … … 196 196 } 197 197 } 198 198 199 199 private function _analyze($script, $regexp, $encode) { 200 200 // analyse … … 243 243 } 244 244 } while ($i); 245 245 246 246 // sort the words by frequency 247 247 // Note: the javascript and php version of sort can be different : … … 269 269 'protected' => $_protected); 270 270 } 271 271 272 272 private $_count = array(); 273 273 private function _sortWords($match1, $match2) { 274 274 return $this->_count[$match2] - $this->_count[$match1]; 275 275 } 276 276 277 277 // build the boot function used for loading and decoding 278 278 private function _bootStrap($packed, $keywords) { … … 341 341 $unpackPacker = new JavaScriptPacker($unpack, 0, false, true); 342 342 $unpack = $unpackPacker->pack(); 343 343 344 344 // arguments 345 345 $params = array($packed, $ascii, $count, $keywords); … … 349 349 } 350 350 $params = implode(',', $params); 351 351 352 352 // the whole thing 353 353 return 'eval(' . $unpack . '(' . $params . "))\n"; 354 354 } 355 355 356 356 private $buffer; 357 357 private function _insertFastDecode($match) { … … 361 361 return '{$encode=' . $this->buffer . ';'; 362 362 } 363 363 364 364 // mmm.. ..which one do i need ?? 365 365 private function _getEncoder($ascii) { … … 367 367 '_encode95' : '_encode62' : '_encode36' : '_encode10'; 368 368 } 369 369 370 370 // zero encoding 371 371 // characters: 0123456789 … … 373 373 return $charCode; 374 374 } 375 375 376 376 // inherent base36 support 377 377 // characters: 0123456789abcdefghijklmnopqrstuvwxyz … … 379 379 return base_convert($charCode, 10, 36); 380 380 } 381 381 382 382 // hitch a ride on base36 and add the upper case alpha characters 383 383 // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ … … 388 388 } 389 389 $charCode = $charCode % $this->_encoding; 390 390 391 391 if ($charCode > 35) 392 392 return $res . chr($charCode + 29); … … 394 394 return $res . base_convert($charCode, 10, 36); 395 395 } 396 396 397 397 // use high-ascii values 398 398 // characters: ¡¢£¤¥¦§¨©ª«¬Â®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖרÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûüýþ … … 401 401 if ($charCode >= $this->_encoding) 402 402 $res = $this->_encode95($charCode / $this->_encoding); 403 403 404 404 return $res . chr(($charCode % $this->_encoding) + 161); 405 405 } 406 406 407 407 private function _safeRegExp($string) { 408 408 return '/'.preg_replace('/\$/', '\\\$', $string).'/'; 409 409 } 410 410 411 411 private function _encodePrivate($charCode) { 412 412 return "_" . $charCode; 413 413 } 414 414 415 415 // protect characters used by the parser 416 416 private function _escape($script) { 417 417 return preg_replace('/([\\\\\'])/', '\\\$1', $script); 418 418 } 419 419 420 420 // protect high-ascii characters already in the script 421 421 private function _escape95($script) { … … 429 429 return '\x'.((string)dechex(ord($match))); 430 430 } 431 432 431 432 433 433 private function _getJSFunction($aName) { 434 434 if (defined('self::JSFUNCTION'.$aName)) … … 437 437 return ''; 438 438 } 439 439 440 440 // JavaScript Functions used. 441 441 // Note : In Dean's version, these functions are converted … … 445 445 // 'while (aBool) { anAction(); }'. 446 446 // The JavaScript functions below are corrected. 447 447 448 448 // unpacking function - this is the boot strap function 449 449 // data extracted from this packing routine is passed to … … 468 468 }'; 469 469 */ 470 470 471 471 // code-snippet inserted into the unpacker to speed up decoding 472 472 const JSFUNCTION_decodeBody = … … 501 501 }'; 502 502 */ 503 503 504 504 // zero encoding 505 505 // characters: 0123456789 … … 508 508 return $charCode; 509 509 }';//;'; 510 510 511 511 // inherent base36 support 512 512 // characters: 0123456789abcdefghijklmnopqrstuvwxyz … … 515 515 return $charCode.toString(36); 516 516 }';//;'; 517 517 518 518 // hitch a ride on base36 and add the upper case alpha characters 519 519 // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ … … 523 523 (($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36)); 524 524 }'; 525 525 526 526 // use high-ascii values 527 527 // characters: ¡¢£¤¥¦§¨©ª«¬Â®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖרÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûüýþ … … 531 531 String.fromCharCode($charCode % _encoding + 161); 532 532 }'; 533 533 534 534 } 535 535 … … 538 538 public $ignoreCase = false; 539 539 public $escapeChar = ''; 540 540 541 541 // constants 542 542 const EXPRESSION = 0; 543 543 const REPLACEMENT = 1; 544 544 const LENGTH = 2; 545 545 546 546 // used to determine nesting levels 547 547 private $GROUPS = '/\\(/';//g … … 552 552 private $QUOTE = '/\'/'; 553 553 private $DELETED = '/\\x01[^\\x01]*\\x01/';//g 554 554 555 555 public function add($expression, $replacement = '') { 556 556 // count the number of sub-expressions 557 557 // - add one because each pattern is itself a sub-expression 558 558 $length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string)$expression), $out); 559 559 560 560 // treat only strings $replacement 561 561 if (is_string($replacement)) { … … 585 585 else $this->_add('/^$/', $replacement, $length); 586 586 } 587 587 588 588 public function exec($string) { 589 589 // execute the global replacement 590 590 $this->_escaped = array(); 591 591 592 592 // simulate the _patterns.toSTring of Dean 593 593 $regexp = '/'; … …
