Changeset 2652765
- Timestamp:
- 01/04/2022 07:59:49 PM (4 years ago)
- Location:
- optipic
- Files:
-
- 15 added
- 4 edited
-
tags/1.27.0 (added)
-
tags/1.27.0/images (added)
-
tags/1.27.0/images/op_logo.png (added)
-
tags/1.27.0/includes (added)
-
tags/1.27.0/includes/functions.php (added)
-
tags/1.27.0/includes/optipic-cdn-php (added)
-
tags/1.27.0/includes/optipic-cdn-php/ImgUrlConverter.php (added)
-
tags/1.27.0/includes/settings.php (added)
-
tags/1.27.0/includes/template_loader.php (added)
-
tags/1.27.0/optipic-ru_RU.mo (added)
-
tags/1.27.0/optipic-ru_RU.po (added)
-
tags/1.27.0/optipic.php (added)
-
tags/1.27.0/optipic.pot (added)
-
tags/1.27.0/readme.txt (added)
-
tags/1.27.0/uninstall.php (added)
-
trunk/includes/functions.php (modified) (3 diffs)
-
trunk/includes/optipic-cdn-php/ImgUrlConverter.php (modified) (10 diffs)
-
trunk/optipic.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
optipic/trunk/includes/functions.php
r2643600 r2652765 2 2 3 3 function optipic_version() { 4 return '1.2 5.1';4 return '1.27.0'; 5 5 } 6 6 … … 36 36 // die('-------------'); 37 37 38 $optipicSiteID = $optipicSettings['cdn_site_id'];39 $autoreplaceActive = $optipicSettings['cdn_autoreplace_active'];38 $optipicSiteID = (!empty($optipicSettings['cdn_site_id']))? $optipicSettings['cdn_site_id']: ''; 39 $autoreplaceActive = (!empty($optipicSettings['cdn_autoreplace_active']))? $optipicSettings['cdn_autoreplace_active']: ''; 40 40 //$domains = $optipicSettings['domains']; 41 41 … … 50 50 foreach(array('domains', 'exclusions_url', 'whitelist_img_urls', 'srcset_attrs') as $attrName) { 51 51 $list = array(); 52 foreach(explode("\n", $optipicSettings[$attrName]) as $val) { 52 $attrVal = (!empty($optipicSettings[$attrName]))? $optipicSettings[$attrName]: ''; 53 foreach(explode("\n", $attrVal) as $val) { 53 54 $val = trim($val); 54 55 if($val) { -
optipic/trunk/includes/optipic-cdn-php/ImgUrlConverter.php
r2643122 r2652765 17 17 * Library version number 18 18 */ 19 const VERSION = '1.2 5';19 const VERSION = '1.27'; 20 20 21 21 /** … … 71 71 { 72 72 73 if (empty(self::$url)) {73 if (empty(self::$url)) { 74 74 self::$url = $_SERVER['REQUEST_URI']; 75 75 } 76 if (empty(self::$host)) {76 if (empty(self::$host)) { 77 77 self::$host = $_SERVER['HTTP_HOST']; 78 78 } … … 123 123 124 124 125 if ($detectBaseUrl) {125 if ($detectBaseUrl) { 126 126 self::$baseUrl = self::getBaseUrlFromHtml($content); 127 127 if (self::$baseUrl) { … … 230 230 $cdnDomainsForRegexp[] = '\/\/'.preg_quote($cdnDomain, '#'); // plain html 231 231 $cdnDomainsForRegexp[] = '\\/\\/'.preg_quote($cdnDomain, '#'); // html in json 232 233 232 } 234 233 $cdnDomainsForRegexp = implode("|", $cdnDomainsForRegexp); … … 398 397 } 399 398 //var_dump($parseUrl);exit; 400 } 401 else { 399 } else { 402 400 $parseUrl = parse_url($urlOriginal); 403 401 } … … 416 414 $ext = self::strtolower(pathinfo($parseUrl['path'], PATHINFO_EXTENSION)); 417 415 if (!in_array($ext, array('png', 'jpg', 'jpeg'))) { 416 return $replaceWithoutOptiPic; 417 } 418 419 if (self::urlHasPhpScript($urlOriginal)) { 418 420 return $replaceWithoutOptiPic; 419 421 } … … 520 522 } 521 523 522 if (self::substr($relativeUrl, 0, s trlen($slash))==$slash) {524 if (self::substr($relativeUrl, 0, self::strlen($slash))==$slash) { 523 525 return $relativeUrl; 524 526 } … … 534 536 535 537 // CASE filepath ".img.png" (remove first dot) 536 if (s ubstr($relativeUrl, 0, 1) == '.' &&substr($relativeUrl, 1, 1) != '.') {537 $relativeUrl = s ubstr($relativeUrl, 1);538 if (self::substr($relativeUrl, 0, 1) == '.' && self::substr($relativeUrl, 1, 1) != '.') { 539 $relativeUrl = self::substr($relativeUrl, 1); 538 540 } 539 541 // CASE baseUrl "." (remove first dot) 540 if (s trlen($baseUrl)>0 && substr($baseUrl, 0, 1) == '.' &&substr($baseUrl, 1, 1) != '.') {541 $baseUrl = (s trlen($baseUrl)>1)? "".substr($baseUrl, 1): "";542 if (self::strlen($baseUrl)>0 && self::substr($baseUrl, 0, 1) == '.' && self::substr($baseUrl, 1, 1) != '.') { 543 $baseUrl = (self::strlen($baseUrl)>1)? "".self::substr($baseUrl, 1): ""; 542 544 } 543 545 544 546 // CASE /catalog + img.png (/catalogimg.png is wrong) 545 if (s ubstr($baseUrl, -1)!='/' &&substr($relativeUrl, 0, 1) != '/') {547 if (self::substr($baseUrl, -1)!='/' && self::substr($relativeUrl, 0, 1) != '/') { 546 548 $tryUrl = str_replace($slash.$slash, $slash, $baseUrl.$slash.$relativeUrl); 547 549 // Try to /catalog/img.png 548 550 if (file_exists(self::getDocumentDoot().$slash.$tryUrl)) { 549 551 return $tryUrl; 550 } 551 // Try to /img.png 552 else { 552 } else { // Try to /img.png 553 553 $tryUrl = str_replace($slash.$slash, $slash, '/'.$relativeUrl); 554 554 if (file_exists(self::getDocumentDoot().$slash.$tryUrl)) { … … 732 732 public static function substr($string, $offset, $length = null) 733 733 { 734 return substr($string, $offset, $length);734 return (($length===null)? substr($string, $offset): substr($string, $offset, $length)); 735 735 } 736 736 … … 757 757 return $_SERVER['DOCUMENT_ROOT']; 758 758 } 759 760 761 /** 762 * Check if URL has php script logic (no static image) 763 * Examples: 764 * - /index.php?route=product/image/catalog/payment.png 765 * - /manager/?a=system/file/edit&file=assets/template/css/../images/lines.png 766 */ 767 public static function urlHasPhpScript($url) 768 { 769 $ext = pathinfo($url, PATHINFO_EXTENSION); 770 $posQ = stripos($url, '?'); 771 772 if (!$posQ) { 773 $posQ = stripos($url, '&'); 774 if (!$posQ) { 775 return false; 776 } 777 } 778 779 if (!$ext) { 780 return true; 781 } 782 783 $posExt = stripos($url, $ext); 784 if ($posQ < $posExt) { 785 return true; 786 } 787 788 return false; 789 } 759 790 } -
optipic/trunk/optipic.php
r2643600 r2652765 4 4 Plugin URI: https://optipic.io/en/webp/wordpress/ 5 5 Description: OptiPic.io - image optimization via smart CDN. The module automates the process of optimizing and compressing all images on the site according to the recommendations of Google PageSpeed Insights. 6 Version: 1.2 5.16 Version: 1.27.0 7 7 Author: OptiPic.io 8 8 Author URI: https://optipic.io/en/ -
optipic/trunk/readme.txt
r2643600 r2652765 4 4 Requires at least: 4.0 5 5 Tested up to: 5.8.2 6 Stable tag: 1.2 5.16 Stable tag: 1.27.0 7 7 License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 8 8 … … 90 90 = 1.25.1 = 91 91 * Optimized images replacing logic. 92 93 = 1.27.0 = 94 * Optimized images replacing logic.
Note: See TracChangeset
for help on using the changeset viewer.