@@ -616,6 +616,9 @@ discard block |
||
| 616 | 616 | Output: |
| 617 | 617 | \*======================================================================*/ |
| 618 | 618 | |
| 619 | + /** |
|
| 620 | + * @param string $http_method |
|
| 621 | + */ |
|
| 619 | 622 | function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "") |
| 620 | 623 | { |
| 621 | 624 | $cookie_headers = ''; |
@@ -923,6 +926,10 @@ discard block |
||
| 923 | 926 | Output: post body |
| 924 | 927 | \*======================================================================*/ |
| 925 | 928 | |
| 929 | + /** |
|
| 930 | + * @param string $formvars |
|
| 931 | + * @param string $formfiles |
|
| 932 | + */ |
|
| 926 | 933 | function _prepare_post_body($formvars, $formfiles) |
| 927 | 934 | { |
| 928 | 935 | settype($formvars, "array"); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | // using proxy, send entire URI |
| 150 | 150 | $this->_httprequest($URI, $fp, $URI, $this->_httpmethod); |
| 151 | 151 | } else { |
| 152 | - $path = $URI_PARTS["path"] . ($URI_PARTS["query"] ? "?" . $URI_PARTS["query"] : ""); |
|
| 152 | + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); |
|
| 153 | 153 | // no proxy, send only the path |
| 154 | 154 | $this->_httprequest($path, $fp, $URI, $this->_httpmethod); |
| 155 | 155 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | /* url was redirected, check if we've hit the max depth */ |
| 161 | 161 | if ($this->maxredirs > $this->_redirectdepth) { |
| 162 | 162 | // only follow redirect if it's on this site, or offsiteok is true |
| 163 | - if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 163 | + if (preg_match("|^https?://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 164 | 164 | /* follow the redirect */ |
| 165 | 165 | $this->_redirectdepth++; |
| 166 | 166 | $this->lastredirectaddr = $this->_redirectaddr; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | break; |
| 189 | 189 | default: |
| 190 | 190 | // not a valid protocol |
| 191 | - $this->error = 'Invalid protocol "' . $URI_PARTS["scheme"] . '"\n'; |
|
| 191 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 192 | 192 | return false; |
| 193 | 193 | break; |
| 194 | 194 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | // using proxy, send entire URI |
| 240 | 240 | $this->_httprequest($URI, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
| 241 | 241 | } else { |
| 242 | - $path = $URI_PARTS["path"] . ($URI_PARTS["query"] ? "?" . $URI_PARTS["query"] : ""); |
|
| 242 | + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); |
|
| 243 | 243 | // no proxy, send only the path |
| 244 | 244 | $this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
| 245 | 245 | } |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | if ($this->_redirectaddr) { |
| 250 | 250 | /* url was redirected, check if we've hit the max depth */ |
| 251 | 251 | if ($this->maxredirs > $this->_redirectdepth) { |
| 252 | - if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) |
|
| 253 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
| 252 | + if (!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) |
|
| 253 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"]."://".$URI_PARTS["host"]); |
|
| 254 | 254 | |
| 255 | 255 | // only follow redirect if it's on this site, or offsiteok is true |
| 256 | - if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 256 | + if (preg_match("|^https?://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) { |
|
| 257 | 257 | /* follow the redirect */ |
| 258 | 258 | $this->_redirectdepth++; |
| 259 | 259 | $this->lastredirectaddr = $this->_redirectaddr; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | break; |
| 286 | 286 | default: |
| 287 | 287 | // not a valid protocol |
| 288 | - $this->error = 'Invalid protocol "' . $URI_PARTS["scheme"] . '"\n'; |
|
| 288 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 289 | 289 | return false; |
| 290 | 290 | break; |
| 291 | 291 | } |
@@ -585,9 +585,9 @@ discard block |
||
| 585 | 585 | $match = preg_replace("|/$|", "", $match); |
| 586 | 586 | $match_part = parse_url($match); |
| 587 | 587 | $match_root = |
| 588 | - $match_part["scheme"] . "://" . $match_part["host"]; |
|
| 588 | + $match_part["scheme"]."://".$match_part["host"]; |
|
| 589 | 589 | |
| 590 | - $search = array("|^http://" . preg_quote($this->host) . "|i", |
|
| 590 | + $search = array("|^http://".preg_quote($this->host)."|i", |
|
| 591 | 591 | "|^(\/)|i", |
| 592 | 592 | "|^(?!http://)(?!mailto:)|i", |
| 593 | 593 | "|/\./|", |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | ); |
| 596 | 596 | |
| 597 | 597 | $replace = array("", |
| 598 | - $match_root . "/", |
|
| 599 | - $match . "/", |
|
| 598 | + $match_root."/", |
|
| 599 | + $match."/", |
|
| 600 | 600 | "/", |
| 601 | 601 | "/" |
| 602 | 602 | ); |
@@ -625,17 +625,17 @@ discard block |
||
| 625 | 625 | $URI_PARTS = parse_url($URI); |
| 626 | 626 | if (empty($url)) |
| 627 | 627 | $url = "/"; |
| 628 | - $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n"; |
|
| 628 | + $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; |
|
| 629 | 629 | if (!empty($this->host) && !isset($this->rawheaders['Host'])) { |
| 630 | - $headers .= "Host: " . $this->host; |
|
| 630 | + $headers .= "Host: ".$this->host; |
|
| 631 | 631 | if (!empty($this->port) && $this->port != '80') |
| 632 | - $headers .= ":" . $this->port; |
|
| 632 | + $headers .= ":".$this->port; |
|
| 633 | 633 | $headers .= "\r\n"; |
| 634 | 634 | } |
| 635 | 635 | if (!empty($this->agent)) |
| 636 | - $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
| 636 | + $headers .= "User-Agent: ".$this->agent."\r\n"; |
|
| 637 | 637 | if (!empty($this->accept)) |
| 638 | - $headers .= "Accept: " . $this->accept . "\r\n"; |
|
| 638 | + $headers .= "Accept: ".$this->accept."\r\n"; |
|
| 639 | 639 | if ($this->use_gzip) { |
| 640 | 640 | // make sure PHP was built with --with-zlib |
| 641 | 641 | // and we can handle gzipp'ed data |
@@ -643,46 +643,46 @@ discard block |
||
| 643 | 643 | $headers .= "Accept-encoding: gzip\r\n"; |
| 644 | 644 | } else { |
| 645 | 645 | trigger_error( |
| 646 | - "use_gzip is on, but PHP was built without zlib support." . |
|
| 646 | + "use_gzip is on, but PHP was built without zlib support.". |
|
| 647 | 647 | " Requesting file(s) without gzip encoding.", |
| 648 | 648 | E_USER_NOTICE); |
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | if (!empty($this->referer)) |
| 652 | - $headers .= "Referer: " . $this->referer . "\r\n"; |
|
| 652 | + $headers .= "Referer: ".$this->referer."\r\n"; |
|
| 653 | 653 | if (!empty($this->cookies)) { |
| 654 | 654 | if (!is_array($this->cookies)) |
| 655 | - $this->cookies = (array)$this->cookies; |
|
| 655 | + $this->cookies = (array) $this->cookies; |
|
| 656 | 656 | |
| 657 | 657 | reset($this->cookies); |
| 658 | 658 | if (count($this->cookies) > 0) { |
| 659 | 659 | $cookie_headers .= 'Cookie: '; |
| 660 | 660 | foreach ($this->cookies as $cookieKey => $cookieVal) { |
| 661 | - $cookie_headers .= $cookieKey . "=" . urlencode($cookieVal) . "; "; |
|
| 661 | + $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; |
|
| 662 | 662 | } |
| 663 | - $headers .= substr($cookie_headers, 0, -2) . "\r\n"; |
|
| 663 | + $headers .= substr($cookie_headers, 0, -2)."\r\n"; |
|
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | if (!empty($this->rawheaders)) { |
| 667 | 667 | if (!is_array($this->rawheaders)) |
| 668 | - $this->rawheaders = (array)$this->rawheaders; |
|
| 668 | + $this->rawheaders = (array) $this->rawheaders; |
|
| 669 | 669 | while (list($headerKey, $headerVal) = each($this->rawheaders)) |
| 670 | - $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
| 670 | + $headers .= $headerKey.": ".$headerVal."\r\n"; |
|
| 671 | 671 | } |
| 672 | 672 | if (!empty($content_type)) { |
| 673 | 673 | $headers .= "Content-type: $content_type"; |
| 674 | 674 | if ($content_type == "multipart/form-data") |
| 675 | - $headers .= "; boundary=" . $this->_mime_boundary; |
|
| 675 | + $headers .= "; boundary=".$this->_mime_boundary; |
|
| 676 | 676 | $headers .= "\r\n"; |
| 677 | 677 | } |
| 678 | 678 | if (!empty($body)) |
| 679 | - $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
| 679 | + $headers .= "Content-length: ".strlen($body)."\r\n"; |
|
| 680 | 680 | if (!empty($this->user) || !empty($this->pass)) |
| 681 | - $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
| 681 | + $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; |
|
| 682 | 682 | |
| 683 | 683 | //add proxy auth headers |
| 684 | 684 | if (!empty($this->proxy_user)) |
| 685 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
| 685 | + $headers .= 'Proxy-Authorization: '.'Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass)."\r\n"; |
|
| 686 | 686 | |
| 687 | 687 | |
| 688 | 688 | $headers .= "\r\n"; |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | socket_set_timeout($fp, $this->read_timeout); |
| 693 | 693 | $this->timed_out = false; |
| 694 | 694 | |
| 695 | - fwrite($fp, $headers . $body, strlen($headers . $body)); |
|
| 695 | + fwrite($fp, $headers.$body, strlen($headers.$body)); |
|
| 696 | 696 | |
| 697 | 697 | $this->_redirectaddr = false; |
| 698 | 698 | unset($this->headers); |
@@ -716,10 +716,10 @@ discard block |
||
| 716 | 716 | // look for :// in the Location header to see if hostname is included |
| 717 | 717 | if (!preg_match("|\:\/\/|", $matches[2])) { |
| 718 | 718 | // no host in the path, so prepend |
| 719 | - $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port; |
|
| 719 | + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
|
| 720 | 720 | // eliminate double slash |
| 721 | 721 | if (!preg_match("|^/|", $matches[2])) |
| 722 | - $this->_redirectaddr .= "/" . $matches[2]; |
|
| 722 | + $this->_redirectaddr .= "/".$matches[2]; |
|
| 723 | 723 | else |
| 724 | 724 | $this->_redirectaddr .= $matches[2]; |
| 725 | 725 | } else |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) { |
| 772 | 772 | $this->results[] = $results; |
| 773 | 773 | for ($x = 0; $x < count($match[1]); $x++) |
| 774 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
| 774 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host); |
|
| 775 | 775 | } // have we already fetched framed content? |
| 776 | 776 | elseif (is_array($this->results)) |
| 777 | 777 | $this->results[] = $results; |
@@ -858,14 +858,14 @@ discard block |
||
| 858 | 858 | $context_opts['ssl']['capath'] = $this->capath; |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | - $host = 'ssl://' . $host; |
|
| 861 | + $host = 'ssl://'.$host; |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | $context = stream_context_create($context_opts); |
| 865 | 865 | |
| 866 | 866 | if (version_compare(PHP_VERSION, '5.0.0', '>')) { |
| 867 | - if($this->scheme == 'http') |
|
| 868 | - $host = "tcp://" . $host; |
|
| 867 | + if ($this->scheme == 'http') |
|
| 868 | + $host = "tcp://".$host; |
|
| 869 | 869 | $fp = stream_socket_client( |
| 870 | 870 | "$host:$port", |
| 871 | 871 | $errno, |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | case -5: |
| 898 | 898 | $this->error = "connection refused or timed out (-5)"; |
| 899 | 899 | default: |
| 900 | - $this->error = "connection failed (" . $errno . ")"; |
|
| 900 | + $this->error = "connection failed (".$errno.")"; |
|
| 901 | 901 | } |
| 902 | 902 | return false; |
| 903 | 903 | } |
@@ -938,26 +938,26 @@ discard block |
||
| 938 | 938 | while (list($key, $val) = each($formvars)) { |
| 939 | 939 | if (is_array($val) || is_object($val)) { |
| 940 | 940 | while (list($cur_key, $cur_val) = each($val)) { |
| 941 | - $postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&"; |
|
| 941 | + $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; |
|
| 942 | 942 | } |
| 943 | 943 | } else |
| 944 | - $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
| 944 | + $postdata .= urlencode($key)."=".urlencode($val)."&"; |
|
| 945 | 945 | } |
| 946 | 946 | break; |
| 947 | 947 | |
| 948 | 948 | case "multipart/form-data": |
| 949 | - $this->_mime_boundary = "Snoopy" . md5(uniqid(microtime())); |
|
| 949 | + $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); |
|
| 950 | 950 | |
| 951 | 951 | reset($formvars); |
| 952 | 952 | while (list($key, $val) = each($formvars)) { |
| 953 | 953 | if (is_array($val) || is_object($val)) { |
| 954 | 954 | while (list($cur_key, $cur_val) = each($val)) { |
| 955 | - $postdata .= "--" . $this->_mime_boundary . "\r\n"; |
|
| 955 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
| 956 | 956 | $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; |
| 957 | 957 | $postdata .= "$cur_val\r\n"; |
| 958 | 958 | } |
| 959 | 959 | } else { |
| 960 | - $postdata .= "--" . $this->_mime_boundary . "\r\n"; |
|
| 960 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
| 961 | 961 | $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; |
| 962 | 962 | $postdata .= "$val\r\n"; |
| 963 | 963 | } |
@@ -974,12 +974,12 @@ discard block |
||
| 974 | 974 | fclose($fp); |
| 975 | 975 | $base_name = basename($file_name); |
| 976 | 976 | |
| 977 | - $postdata .= "--" . $this->_mime_boundary . "\r\n"; |
|
| 977 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
| 978 | 978 | $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; |
| 979 | 979 | $postdata .= "$file_content\r\n"; |
| 980 | 980 | } |
| 981 | 981 | } |
| 982 | - $postdata .= "--" . $this->_mime_boundary . "--\r\n"; |
|
| 982 | + $postdata .= "--".$this->_mime_boundary."--\r\n"; |
|
| 983 | 983 | break; |
| 984 | 984 | } |
| 985 | 985 | |
@@ -121,14 +121,18 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | |
| 123 | 123 | $URI_PARTS = parse_url($URI); |
| 124 | - if (!empty($URI_PARTS["user"])) |
|
| 125 | - $this->user = $URI_PARTS["user"]; |
|
| 126 | - if (!empty($URI_PARTS["pass"])) |
|
| 127 | - $this->pass = $URI_PARTS["pass"]; |
|
| 128 | - if (empty($URI_PARTS["query"])) |
|
| 129 | - $URI_PARTS["query"] = ''; |
|
| 130 | - if (empty($URI_PARTS["path"])) |
|
| 131 | - $URI_PARTS["path"] = ''; |
|
| 124 | + if (!empty($URI_PARTS["user"])) { |
|
| 125 | + $this->user = $URI_PARTS["user"]; |
|
| 126 | + } |
|
| 127 | + if (!empty($URI_PARTS["pass"])) { |
|
| 128 | + $this->pass = $URI_PARTS["pass"]; |
|
| 129 | + } |
|
| 130 | + if (empty($URI_PARTS["query"])) { |
|
| 131 | + $URI_PARTS["query"] = ''; |
|
| 132 | + } |
|
| 133 | + if (empty($URI_PARTS["path"])) { |
|
| 134 | + $URI_PARTS["path"] = ''; |
|
| 135 | + } |
|
| 132 | 136 | |
| 133 | 137 | $fp = null; |
| 134 | 138 | |
@@ -142,8 +146,9 @@ discard block |
||
| 142 | 146 | case "http": |
| 143 | 147 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
| 144 | 148 | $this->host = $URI_PARTS["host"]; |
| 145 | - if (!empty($URI_PARTS["port"])) |
|
| 146 | - $this->port = $URI_PARTS["port"]; |
|
| 149 | + if (!empty($URI_PARTS["port"])) { |
|
| 150 | + $this->port = $URI_PARTS["port"]; |
|
| 151 | + } |
|
| 147 | 152 | if ($this->_connect($fp)) { |
| 148 | 153 | if ($this->_isproxy) { |
| 149 | 154 | // using proxy, send entire URI |
@@ -177,8 +182,9 @@ discard block |
||
| 177 | 182 | if ($this->_framedepth < $this->maxframes) { |
| 178 | 183 | $this->fetch($frameurl); |
| 179 | 184 | $this->_framedepth++; |
| 180 | - } else |
|
| 181 | - break; |
|
| 185 | + } else { |
|
| 186 | + break; |
|
| 187 | + } |
|
| 182 | 188 | } |
| 183 | 189 | } |
| 184 | 190 | } else { |
@@ -213,14 +219,18 @@ discard block |
||
| 213 | 219 | $postdata = $this->_prepare_post_body($formvars, $formfiles); |
| 214 | 220 | |
| 215 | 221 | $URI_PARTS = parse_url($URI); |
| 216 | - if (!empty($URI_PARTS["user"])) |
|
| 217 | - $this->user = $URI_PARTS["user"]; |
|
| 218 | - if (!empty($URI_PARTS["pass"])) |
|
| 219 | - $this->pass = $URI_PARTS["pass"]; |
|
| 220 | - if (empty($URI_PARTS["query"])) |
|
| 221 | - $URI_PARTS["query"] = ''; |
|
| 222 | - if (empty($URI_PARTS["path"])) |
|
| 223 | - $URI_PARTS["path"] = ''; |
|
| 222 | + if (!empty($URI_PARTS["user"])) { |
|
| 223 | + $this->user = $URI_PARTS["user"]; |
|
| 224 | + } |
|
| 225 | + if (!empty($URI_PARTS["pass"])) { |
|
| 226 | + $this->pass = $URI_PARTS["pass"]; |
|
| 227 | + } |
|
| 228 | + if (empty($URI_PARTS["query"])) { |
|
| 229 | + $URI_PARTS["query"] = ''; |
|
| 230 | + } |
|
| 231 | + if (empty($URI_PARTS["path"])) { |
|
| 232 | + $URI_PARTS["path"] = ''; |
|
| 233 | + } |
|
| 224 | 234 | |
| 225 | 235 | switch (strtolower($URI_PARTS["scheme"])) { |
| 226 | 236 | case "https": |
@@ -232,8 +242,9 @@ discard block |
||
| 232 | 242 | case "http": |
| 233 | 243 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
| 234 | 244 | $this->host = $URI_PARTS["host"]; |
| 235 | - if (!empty($URI_PARTS["port"])) |
|
| 236 | - $this->port = $URI_PARTS["port"]; |
|
| 245 | + if (!empty($URI_PARTS["port"])) { |
|
| 246 | + $this->port = $URI_PARTS["port"]; |
|
| 247 | + } |
|
| 237 | 248 | if ($this->_connect($fp)) { |
| 238 | 249 | if ($this->_isproxy) { |
| 239 | 250 | // using proxy, send entire URI |
@@ -249,18 +260,22 @@ discard block |
||
| 249 | 260 | if ($this->_redirectaddr) { |
| 250 | 261 | /* url was redirected, check if we've hit the max depth */ |
| 251 | 262 | if ($this->maxredirs > $this->_redirectdepth) { |
| 252 | - if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) |
|
| 253 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
| 263 | + if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) { |
|
| 264 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
| 265 | + } |
|
| 254 | 266 | |
| 255 | 267 | // only follow redirect if it's on this site, or offsiteok is true |
| 256 | 268 | if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
| 257 | 269 | /* follow the redirect */ |
| 258 | 270 | $this->_redirectdepth++; |
| 259 | 271 | $this->lastredirectaddr = $this->_redirectaddr; |
| 260 | - if (strpos($this->_redirectaddr, "?") > 0) |
|
| 261 | - $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get |
|
| 262 | - else |
|
| 263 | - $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
| 272 | + if (strpos($this->_redirectaddr, "?") > 0) { |
|
| 273 | + $this->fetch($this->_redirectaddr); |
|
| 274 | + } |
|
| 275 | + // the redirect has changed the request method from post to get |
|
| 276 | + else { |
|
| 277 | + $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
| 278 | + } |
|
| 264 | 279 | } |
| 265 | 280 | } |
| 266 | 281 | } |
@@ -273,8 +288,9 @@ discard block |
||
| 273 | 288 | if ($this->_framedepth < $this->maxframes) { |
| 274 | 289 | $this->fetch($frameurl); |
| 275 | 290 | $this->_framedepth++; |
| 276 | - } else |
|
| 277 | - break; |
|
| 291 | + } else { |
|
| 292 | + break; |
|
| 293 | + } |
|
| 278 | 294 | } |
| 279 | 295 | } |
| 280 | 296 | |
@@ -302,19 +318,24 @@ discard block |
||
| 302 | 318 | function fetchlinks($URI) |
| 303 | 319 | { |
| 304 | 320 | if ($this->fetch($URI) !== false) { |
| 305 | - if ($this->lastredirectaddr) |
|
| 306 | - $URI = $this->lastredirectaddr; |
|
| 321 | + if ($this->lastredirectaddr) { |
|
| 322 | + $URI = $this->lastredirectaddr; |
|
| 323 | + } |
|
| 307 | 324 | if (is_array($this->results)) { |
| 308 | - for ($x = 0; $x < count($this->results); $x++) |
|
| 309 | - $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
| 310 | - } else |
|
| 311 | - $this->results = $this->_striplinks($this->results); |
|
| 325 | + for ($x = 0; $x < count($this->results); $x++) { |
|
| 326 | + $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
| 327 | + } |
|
| 328 | + } else { |
|
| 329 | + $this->results = $this->_striplinks($this->results); |
|
| 330 | + } |
|
| 312 | 331 | |
| 313 | - if ($this->expandlinks) |
|
| 314 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
| 332 | + if ($this->expandlinks) { |
|
| 333 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 334 | + } |
|
| 315 | 335 | return $this; |
| 316 | - } else |
|
| 317 | - return false; |
|
| 336 | + } else { |
|
| 337 | + return false; |
|
| 338 | + } |
|
| 318 | 339 | } |
| 319 | 340 | |
| 320 | 341 | /*======================================================================*\ |
@@ -330,14 +351,17 @@ discard block |
||
| 330 | 351 | if ($this->fetch($URI) !== false) { |
| 331 | 352 | |
| 332 | 353 | if (is_array($this->results)) { |
| 333 | - for ($x = 0; $x < count($this->results); $x++) |
|
| 334 | - $this->results[$x] = $this->_stripform($this->results[$x]); |
|
| 335 | - } else |
|
| 336 | - $this->results = $this->_stripform($this->results); |
|
| 354 | + for ($x = 0; $x < count($this->results); $x++) { |
|
| 355 | + $this->results[$x] = $this->_stripform($this->results[$x]); |
|
| 356 | + } |
|
| 357 | + } else { |
|
| 358 | + $this->results = $this->_stripform($this->results); |
|
| 359 | + } |
|
| 337 | 360 | |
| 338 | 361 | return $this; |
| 339 | - } else |
|
| 340 | - return false; |
|
| 362 | + } else { |
|
| 363 | + return false; |
|
| 364 | + } |
|
| 341 | 365 | } |
| 342 | 366 | |
| 343 | 367 | |
@@ -352,13 +376,16 @@ discard block |
||
| 352 | 376 | { |
| 353 | 377 | if ($this->fetch($URI) !== false) { |
| 354 | 378 | if (is_array($this->results)) { |
| 355 | - for ($x = 0; $x < count($this->results); $x++) |
|
| 356 | - $this->results[$x] = $this->_striptext($this->results[$x]); |
|
| 357 | - } else |
|
| 358 | - $this->results = $this->_striptext($this->results); |
|
| 379 | + for ($x = 0; $x < count($this->results); $x++) { |
|
| 380 | + $this->results[$x] = $this->_striptext($this->results[$x]); |
|
| 381 | + } |
|
| 382 | + } else { |
|
| 383 | + $this->results = $this->_striptext($this->results); |
|
| 384 | + } |
|
| 359 | 385 | return $this; |
| 360 | - } else |
|
| 361 | - return false; |
|
| 386 | + } else { |
|
| 387 | + return false; |
|
| 388 | + } |
|
| 362 | 389 | } |
| 363 | 390 | |
| 364 | 391 | /*======================================================================*\ |
@@ -371,22 +398,26 @@ discard block |
||
| 371 | 398 | function submitlinks($URI, $formvars = "", $formfiles = "") |
| 372 | 399 | { |
| 373 | 400 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
| 374 | - if ($this->lastredirectaddr) |
|
| 375 | - $URI = $this->lastredirectaddr; |
|
| 401 | + if ($this->lastredirectaddr) { |
|
| 402 | + $URI = $this->lastredirectaddr; |
|
| 403 | + } |
|
| 376 | 404 | if (is_array($this->results)) { |
| 377 | 405 | for ($x = 0; $x < count($this->results); $x++) { |
| 378 | 406 | $this->results[$x] = $this->_striplinks($this->results[$x]); |
| 379 | - if ($this->expandlinks) |
|
| 380 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 407 | + if ($this->expandlinks) { |
|
| 408 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 409 | + } |
|
| 381 | 410 | } |
| 382 | 411 | } else { |
| 383 | 412 | $this->results = $this->_striplinks($this->results); |
| 384 | - if ($this->expandlinks) |
|
| 385 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
| 413 | + if ($this->expandlinks) { |
|
| 414 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 415 | + } |
|
| 386 | 416 | } |
| 387 | 417 | return $this; |
| 388 | - } else |
|
| 389 | - return false; |
|
| 418 | + } else { |
|
| 419 | + return false; |
|
| 420 | + } |
|
| 390 | 421 | } |
| 391 | 422 | |
| 392 | 423 | /*======================================================================*\ |
@@ -399,22 +430,26 @@ discard block |
||
| 399 | 430 | function submittext($URI, $formvars = "", $formfiles = "") |
| 400 | 431 | { |
| 401 | 432 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
| 402 | - if ($this->lastredirectaddr) |
|
| 403 | - $URI = $this->lastredirectaddr; |
|
| 433 | + if ($this->lastredirectaddr) { |
|
| 434 | + $URI = $this->lastredirectaddr; |
|
| 435 | + } |
|
| 404 | 436 | if (is_array($this->results)) { |
| 405 | 437 | for ($x = 0; $x < count($this->results); $x++) { |
| 406 | 438 | $this->results[$x] = $this->_striptext($this->results[$x]); |
| 407 | - if ($this->expandlinks) |
|
| 408 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 439 | + if ($this->expandlinks) { |
|
| 440 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 441 | + } |
|
| 409 | 442 | } |
| 410 | 443 | } else { |
| 411 | 444 | $this->results = $this->_striptext($this->results); |
| 412 | - if ($this->expandlinks) |
|
| 413 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
| 445 | + if ($this->expandlinks) { |
|
| 446 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 447 | + } |
|
| 414 | 448 | } |
| 415 | 449 | return $this; |
| 416 | - } else |
|
| 417 | - return false; |
|
| 450 | + } else { |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 418 | 453 | } |
| 419 | 454 | |
| 420 | 455 | |
@@ -468,13 +503,15 @@ discard block |
||
| 468 | 503 | // catenate the non-empty matches from the conditional subpattern |
| 469 | 504 | |
| 470 | 505 | while (list($key, $val) = each($links[2])) { |
| 471 | - if (!empty($val)) |
|
| 472 | - $match[] = $val; |
|
| 506 | + if (!empty($val)) { |
|
| 507 | + $match[] = $val; |
|
| 508 | + } |
|
| 473 | 509 | } |
| 474 | 510 | |
| 475 | 511 | while (list($key, $val) = each($links[3])) { |
| 476 | - if (!empty($val)) |
|
| 477 | - $match[] = $val; |
|
| 512 | + if (!empty($val)) { |
|
| 513 | + $match[] = $val; |
|
| 514 | + } |
|
| 478 | 515 | } |
| 479 | 516 | |
| 480 | 517 | // return the links |
@@ -619,23 +656,28 @@ discard block |
||
| 619 | 656 | function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "") |
| 620 | 657 | { |
| 621 | 658 | $cookie_headers = ''; |
| 622 | - if ($this->passcookies && $this->_redirectaddr) |
|
| 623 | - $this->setcookies(); |
|
| 659 | + if ($this->passcookies && $this->_redirectaddr) { |
|
| 660 | + $this->setcookies(); |
|
| 661 | + } |
|
| 624 | 662 | |
| 625 | 663 | $URI_PARTS = parse_url($URI); |
| 626 | - if (empty($url)) |
|
| 627 | - $url = "/"; |
|
| 664 | + if (empty($url)) { |
|
| 665 | + $url = "/"; |
|
| 666 | + } |
|
| 628 | 667 | $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n"; |
| 629 | 668 | if (!empty($this->host) && !isset($this->rawheaders['Host'])) { |
| 630 | 669 | $headers .= "Host: " . $this->host; |
| 631 | - if (!empty($this->port) && $this->port != '80') |
|
| 632 | - $headers .= ":" . $this->port; |
|
| 670 | + if (!empty($this->port) && $this->port != '80') { |
|
| 671 | + $headers .= ":" . $this->port; |
|
| 672 | + } |
|
| 633 | 673 | $headers .= "\r\n"; |
| 634 | 674 | } |
| 635 | - if (!empty($this->agent)) |
|
| 636 | - $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
| 637 | - if (!empty($this->accept)) |
|
| 638 | - $headers .= "Accept: " . $this->accept . "\r\n"; |
|
| 675 | + if (!empty($this->agent)) { |
|
| 676 | + $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
| 677 | + } |
|
| 678 | + if (!empty($this->accept)) { |
|
| 679 | + $headers .= "Accept: " . $this->accept . "\r\n"; |
|
| 680 | + } |
|
| 639 | 681 | if ($this->use_gzip) { |
| 640 | 682 | // make sure PHP was built with --with-zlib |
| 641 | 683 | // and we can handle gzipp'ed data |
@@ -648,11 +690,13 @@ discard block |
||
| 648 | 690 | E_USER_NOTICE); |
| 649 | 691 | } |
| 650 | 692 | } |
| 651 | - if (!empty($this->referer)) |
|
| 652 | - $headers .= "Referer: " . $this->referer . "\r\n"; |
|
| 693 | + if (!empty($this->referer)) { |
|
| 694 | + $headers .= "Referer: " . $this->referer . "\r\n"; |
|
| 695 | + } |
|
| 653 | 696 | if (!empty($this->cookies)) { |
| 654 | - if (!is_array($this->cookies)) |
|
| 655 | - $this->cookies = (array)$this->cookies; |
|
| 697 | + if (!is_array($this->cookies)) { |
|
| 698 | + $this->cookies = (array)$this->cookies; |
|
| 699 | + } |
|
| 656 | 700 | |
| 657 | 701 | reset($this->cookies); |
| 658 | 702 | if (count($this->cookies) > 0) { |
@@ -664,32 +708,39 @@ discard block |
||
| 664 | 708 | } |
| 665 | 709 | } |
| 666 | 710 | if (!empty($this->rawheaders)) { |
| 667 | - if (!is_array($this->rawheaders)) |
|
| 668 | - $this->rawheaders = (array)$this->rawheaders; |
|
| 669 | - while (list($headerKey, $headerVal) = each($this->rawheaders)) |
|
| 670 | - $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
| 711 | + if (!is_array($this->rawheaders)) { |
|
| 712 | + $this->rawheaders = (array)$this->rawheaders; |
|
| 713 | + } |
|
| 714 | + while (list($headerKey, $headerVal) = each($this->rawheaders)) { |
|
| 715 | + $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
| 716 | + } |
|
| 671 | 717 | } |
| 672 | 718 | if (!empty($content_type)) { |
| 673 | 719 | $headers .= "Content-type: $content_type"; |
| 674 | - if ($content_type == "multipart/form-data") |
|
| 675 | - $headers .= "; boundary=" . $this->_mime_boundary; |
|
| 720 | + if ($content_type == "multipart/form-data") { |
|
| 721 | + $headers .= "; boundary=" . $this->_mime_boundary; |
|
| 722 | + } |
|
| 676 | 723 | $headers .= "\r\n"; |
| 677 | 724 | } |
| 678 | - if (!empty($body)) |
|
| 679 | - $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
| 680 | - if (!empty($this->user) || !empty($this->pass)) |
|
| 681 | - $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
| 725 | + if (!empty($body)) { |
|
| 726 | + $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
| 727 | + } |
|
| 728 | + if (!empty($this->user) || !empty($this->pass)) { |
|
| 729 | + $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
| 730 | + } |
|
| 682 | 731 | |
| 683 | 732 | //add proxy auth headers |
| 684 | - if (!empty($this->proxy_user)) |
|
| 685 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
| 733 | + if (!empty($this->proxy_user)) { |
|
| 734 | + $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
| 735 | + } |
|
| 686 | 736 | |
| 687 | 737 | |
| 688 | 738 | $headers .= "\r\n"; |
| 689 | 739 | |
| 690 | 740 | // set the read timeout if needed |
| 691 | - if ($this->read_timeout > 0) |
|
| 692 | - socket_set_timeout($fp, $this->read_timeout); |
|
| 741 | + if ($this->read_timeout > 0) { |
|
| 742 | + socket_set_timeout($fp, $this->read_timeout); |
|
| 743 | + } |
|
| 693 | 744 | $this->timed_out = false; |
| 694 | 745 | |
| 695 | 746 | fwrite($fp, $headers . $body, strlen($headers . $body)); |
@@ -706,8 +757,9 @@ discard block |
||
| 706 | 757 | return false; |
| 707 | 758 | } |
| 708 | 759 | |
| 709 | - if ($currentHeader == "\r\n") |
|
| 710 | - break; |
|
| 760 | + if ($currentHeader == "\r\n") { |
|
| 761 | + break; |
|
| 762 | + } |
|
| 711 | 763 | |
| 712 | 764 | // if a header begins with Location: or URI:, set the redirect |
| 713 | 765 | if (preg_match("/^(Location:|URI:)/i", $currentHeader)) { |
@@ -718,12 +770,14 @@ discard block |
||
| 718 | 770 | // no host in the path, so prepend |
| 719 | 771 | $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port; |
| 720 | 772 | // eliminate double slash |
| 721 | - if (!preg_match("|^/|", $matches[2])) |
|
| 722 | - $this->_redirectaddr .= "/" . $matches[2]; |
|
| 723 | - else |
|
| 724 | - $this->_redirectaddr .= $matches[2]; |
|
| 725 | - } else |
|
| 726 | - $this->_redirectaddr = $matches[2]; |
|
| 773 | + if (!preg_match("|^/|", $matches[2])) { |
|
| 774 | + $this->_redirectaddr .= "/" . $matches[2]; |
|
| 775 | + } else { |
|
| 776 | + $this->_redirectaddr .= $matches[2]; |
|
| 777 | + } |
|
| 778 | + } else { |
|
| 779 | + $this->_redirectaddr = $matches[2]; |
|
| 780 | + } |
|
| 727 | 781 | } |
| 728 | 782 | |
| 729 | 783 | if (preg_match("|^HTTP/|", $currentHeader)) { |
@@ -770,14 +824,17 @@ discard block |
||
| 770 | 824 | // have we hit our frame depth and is there frame src to fetch? |
| 771 | 825 | if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) { |
| 772 | 826 | $this->results[] = $results; |
| 773 | - for ($x = 0; $x < count($match[1]); $x++) |
|
| 774 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
| 827 | + for ($x = 0; $x < count($match[1]); $x++) { |
|
| 828 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
| 829 | + } |
|
| 775 | 830 | } // have we already fetched framed content? |
| 776 | - elseif (is_array($this->results)) |
|
| 777 | - $this->results[] = $results; |
|
| 831 | + elseif (is_array($this->results)) { |
|
| 832 | + $this->results[] = $results; |
|
| 833 | + } |
|
| 778 | 834 | // no framed content |
| 779 | - else |
|
| 780 | - $this->results = $results; |
|
| 835 | + else { |
|
| 836 | + $this->results = $results; |
|
| 837 | + } |
|
| 781 | 838 | |
| 782 | 839 | return $this; |
| 783 | 840 | } |
@@ -790,8 +847,9 @@ discard block |
||
| 790 | 847 | function setcookies() |
| 791 | 848 | { |
| 792 | 849 | for ($x = 0; $x < count($this->headers); $x++) { |
| 793 | - if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) |
|
| 794 | - $this->cookies[$match[1]] = urldecode($match[2]); |
|
| 850 | + if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) { |
|
| 851 | + $this->cookies[$match[1]] = urldecode($match[2]); |
|
| 852 | + } |
|
| 795 | 853 | } |
| 796 | 854 | return $this; |
| 797 | 855 | } |
@@ -852,10 +910,12 @@ discard block |
||
| 852 | 910 | 'disable_compression' => true, |
| 853 | 911 | ); |
| 854 | 912 | |
| 855 | - if (isset($this->cafile)) |
|
| 856 | - $context_opts['ssl']['cafile'] = $this->cafile; |
|
| 857 | - if (isset($this->capath)) |
|
| 858 | - $context_opts['ssl']['capath'] = $this->capath; |
|
| 913 | + if (isset($this->cafile)) { |
|
| 914 | + $context_opts['ssl']['cafile'] = $this->cafile; |
|
| 915 | + } |
|
| 916 | + if (isset($this->capath)) { |
|
| 917 | + $context_opts['ssl']['capath'] = $this->capath; |
|
| 918 | + } |
|
| 859 | 919 | } |
| 860 | 920 | |
| 861 | 921 | $host = 'ssl://' . $host; |
@@ -864,8 +924,9 @@ discard block |
||
| 864 | 924 | $context = stream_context_create($context_opts); |
| 865 | 925 | |
| 866 | 926 | if (version_compare(PHP_VERSION, '5.0.0', '>')) { |
| 867 | - if($this->scheme == 'http') |
|
| 868 | - $host = "tcp://" . $host; |
|
| 927 | + if($this->scheme == 'http') { |
|
| 928 | + $host = "tcp://" . $host; |
|
| 929 | + } |
|
| 869 | 930 | $fp = stream_socket_client( |
| 870 | 931 | "$host:$port", |
| 871 | 932 | $errno, |
@@ -929,8 +990,9 @@ discard block |
||
| 929 | 990 | settype($formfiles, "array"); |
| 930 | 991 | $postdata = ''; |
| 931 | 992 | |
| 932 | - if (count($formvars) == 0 && count($formfiles) == 0) |
|
| 933 | - return; |
|
| 993 | + if (count($formvars) == 0 && count($formfiles) == 0) { |
|
| 994 | + return; |
|
| 995 | + } |
|
| 934 | 996 | |
| 935 | 997 | switch ($this->_submit_type) { |
| 936 | 998 | case "application/x-www-form-urlencoded": |
@@ -940,8 +1002,9 @@ discard block |
||
| 940 | 1002 | while (list($cur_key, $cur_val) = each($val)) { |
| 941 | 1003 | $postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&"; |
| 942 | 1004 | } |
| 943 | - } else |
|
| 944 | - $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
| 1005 | + } else { |
|
| 1006 | + $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
| 1007 | + } |
|
| 945 | 1008 | } |
| 946 | 1009 | break; |
| 947 | 1010 | |
@@ -967,7 +1030,9 @@ discard block |
||
| 967 | 1030 | while (list($field_name, $file_names) = each($formfiles)) { |
| 968 | 1031 | settype($file_names, "array"); |
| 969 | 1032 | while (list(, $file_name) = each($file_names)) { |
| 970 | - if (!is_readable($file_name)) continue; |
|
| 1033 | + if (!is_readable($file_name)) { |
|
| 1034 | + continue; |
|
| 1035 | + } |
|
| 971 | 1036 | |
| 972 | 1037 | $fp = fopen($file_name, "r"); |
| 973 | 1038 | $file_content = fread($fp, filesize($file_name)); |
@@ -243,6 +243,9 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | +/** |
|
| 247 | + * @param integer $lvl |
|
| 248 | + */ |
|
| 246 | 249 | function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
| 247 | 250 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
| 248 | 251 | } |
@@ -289,6 +292,9 @@ discard block |
||
| 289 | 292 | Input: an HTTP response object (see Snoopy) |
| 290 | 293 | Output: parsed RSS object (see rss_parse) |
| 291 | 294 | \*=======================================================================*/ |
| 295 | +/** |
|
| 296 | + * @param Snoopy $resp |
|
| 297 | + */ |
|
| 292 | 298 | function _response_to_rss ($resp) { |
| 293 | 299 | $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
| 294 | 300 | |
@@ -166,7 +166,7 @@ |
||
| 166 | 166 | $resp = _fetch_remote_file( $url, $request_headers ); |
| 167 | 167 | |
| 168 | 168 | if (isset($resp) and $resp) { |
| 169 | - if ($resp->status == '304' ) { |
|
| 169 | + if ($resp->status == '304' ) { |
|
| 170 | 170 | // we have the most current copy |
| 171 | 171 | if ( MAGPIE_DEBUG > 1) { |
| 172 | 172 | debug("Got 304 for $url"); |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if (!defined('MAGPIE_DIR')) { |
| 27 | - define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP); |
|
| 27 | + define('MAGPIE_DIR', dirname(__FILE__).DIR_SEP); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if (!defined('MAGPIE_CACHE_DIR')) { |
| 31 | - define('MAGPIE_CACHE_DIR', MODX_BASE_PATH . 'assets/cache/rss'); |
|
| 31 | + define('MAGPIE_CACHE_DIR', MODX_BASE_PATH.'assets/cache/rss'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -require_once( MAGPIE_DIR . 'rss_parse.inc' ); |
|
| 35 | -require_once( MAGPIE_DIR . 'rss_cache.inc' ); |
|
| 34 | +require_once(MAGPIE_DIR.'rss_parse.inc'); |
|
| 35 | +require_once(MAGPIE_DIR.'rss_cache.inc'); |
|
| 36 | 36 | |
| 37 | 37 | // for including 3rd party libraries |
| 38 | -define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP); |
|
| 39 | -require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc'); |
|
| 38 | +define('MAGPIE_EXTLIB', MAGPIE_DIR.'extlib'.DIR_SEP); |
|
| 39 | +require_once(MAGPIE_EXTLIB.'Snoopy.class.inc'); |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /* |
@@ -89,21 +89,21 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $MAGPIE_ERROR = ""; |
| 91 | 91 | |
| 92 | -function fetch_rss ($url) { |
|
| 92 | +function fetch_rss($url){ |
|
| 93 | 93 | // initialize constants |
| 94 | 94 | init(); |
| 95 | 95 | |
| 96 | - if ( !isset($url) ) { |
|
| 96 | + if (!isset($url)) { |
|
| 97 | 97 | error("fetch_rss called without a url"); |
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // if cache is disabled |
| 102 | - if ( !MAGPIE_CACHE_ON ) { |
|
| 102 | + if (!MAGPIE_CACHE_ON) { |
|
| 103 | 103 | // fetch file, and parse it |
| 104 | - $resp = _fetch_remote_file( $url ); |
|
| 105 | - if ( is_success( $resp->status ) ) { |
|
| 106 | - return _response_to_rss( $resp ); |
|
| 104 | + $resp = _fetch_remote_file($url); |
|
| 105 | + if (is_success($resp->status)) { |
|
| 106 | + return _response_to_rss($resp); |
|
| 107 | 107 | } |
| 108 | 108 | else { |
| 109 | 109 | error("Failed to fetch $url and cache is off"); |
@@ -118,34 +118,34 @@ discard block |
||
| 118 | 118 | // 3. if cached obj fails freshness check, fetch remote |
| 119 | 119 | // 4. if remote fails, return stale object, or error |
| 120 | 120 | |
| 121 | - $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); |
|
| 121 | + $cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE); |
|
| 122 | 122 | |
| 123 | 123 | if (MAGPIE_DEBUG and $cache->ERROR) { |
| 124 | 124 | debug($cache->ERROR, E_USER_WARNING); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
| 128 | - $cache_status = 0; // response of check_cache |
|
| 128 | + $cache_status = 0; // response of check_cache |
|
| 129 | 129 | $request_headers = array(); // HTTP headers to send with fetch |
| 130 | - $rss = 0; // parsed RSS object |
|
| 131 | - $errormsg = 0; // errors, if any |
|
| 130 | + $rss = 0; // parsed RSS object |
|
| 131 | + $errormsg = 0; // errors, if any |
|
| 132 | 132 | |
| 133 | 133 | // store parsed XML by desired output encoding |
| 134 | 134 | // as character munging happens at parse time |
| 135 | - $cache_key = $url . MAGPIE_OUTPUT_ENCODING; |
|
| 135 | + $cache_key = $url.MAGPIE_OUTPUT_ENCODING; |
|
| 136 | 136 | |
| 137 | 137 | if (!$cache->ERROR) { |
| 138 | 138 | // return cache HIT, MISS, or STALE |
| 139 | - $cache_status = $cache->check_cache( $cache_key); |
|
| 139 | + $cache_status = $cache->check_cache($cache_key); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // if object cached, and cache is fresh, return cached obj |
| 143 | - if ( $cache_status == 'HIT' ) { |
|
| 144 | - $rss = $cache->get( $cache_key ); |
|
| 145 | - if ( isset($rss) and $rss ) { |
|
| 143 | + if ($cache_status == 'HIT') { |
|
| 144 | + $rss = $cache->get($cache_key); |
|
| 145 | + if (isset($rss) and $rss) { |
|
| 146 | 146 | // should be cache age |
| 147 | 147 | $rss->from_cache = 1; |
| 148 | - if ( MAGPIE_DEBUG > 1) { |
|
| 148 | + if (MAGPIE_DEBUG > 1) { |
|
| 149 | 149 | debug("MagpieRSS: Cache HIT", E_USER_NOTICE); |
| 150 | 150 | } |
| 151 | 151 | return $rss; |
@@ -155,50 +155,50 @@ discard block |
||
| 155 | 155 | // else attempt a conditional get |
| 156 | 156 | |
| 157 | 157 | // setup headers |
| 158 | - if ( $cache_status == 'STALE' ) { |
|
| 159 | - $rss = $cache->get( $cache_key ); |
|
| 160 | - if ( $rss and $rss->etag and $rss->last_modified ) { |
|
| 158 | + if ($cache_status == 'STALE') { |
|
| 159 | + $rss = $cache->get($cache_key); |
|
| 160 | + if ($rss and $rss->etag and $rss->last_modified) { |
|
| 161 | 161 | $request_headers['If-None-Match'] = $rss->etag; |
| 162 | 162 | $request_headers['If-Last-Modified'] = $rss->last_modified; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $resp = _fetch_remote_file( $url, $request_headers ); |
|
| 166 | + $resp = _fetch_remote_file($url, $request_headers); |
|
| 167 | 167 | |
| 168 | 168 | if (isset($resp) and $resp) { |
| 169 | - if ($resp->status == '304' ) { |
|
| 169 | + if ($resp->status == '304') { |
|
| 170 | 170 | // we have the most current copy |
| 171 | - if ( MAGPIE_DEBUG > 1) { |
|
| 171 | + if (MAGPIE_DEBUG > 1) { |
|
| 172 | 172 | debug("Got 304 for $url"); |
| 173 | 173 | } |
| 174 | 174 | // reset cache on 304 (at minutillo insistent prodding) |
| 175 | 175 | $cache->set($cache_key, $rss); |
| 176 | 176 | return $rss; |
| 177 | 177 | } |
| 178 | - elseif ( is_success( $resp->status ) ) { |
|
| 179 | - $rss = _response_to_rss( $resp ); |
|
| 180 | - if ( $rss ) { |
|
| 178 | + elseif (is_success($resp->status)) { |
|
| 179 | + $rss = _response_to_rss($resp); |
|
| 180 | + if ($rss) { |
|
| 181 | 181 | if (MAGPIE_DEBUG > 1) { |
| 182 | 182 | debug("Fetch successful"); |
| 183 | 183 | } |
| 184 | 184 | // add object to cache |
| 185 | - $cache->set( $cache_key, $rss ); |
|
| 185 | + $cache->set($cache_key, $rss); |
|
| 186 | 186 | return $rss; |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | else { |
| 190 | 190 | $errormsg = "Failed to fetch $url "; |
| 191 | - if ( $resp->status == '-100' ) { |
|
| 192 | - $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
|
| 191 | + if ($resp->status == '-100') { |
|
| 192 | + $errormsg .= "(Request timed out after ".MAGPIE_FETCH_TIME_OUT." seconds)"; |
|
| 193 | 193 | } |
| 194 | - elseif ( $resp->error ) { |
|
| 194 | + elseif ($resp->error) { |
|
| 195 | 195 | # compensate for Snoopy's annoying habbit to tacking |
| 196 | 196 | # on '\n' |
| 197 | 197 | $http_error = substr($resp->error, 0, -2); |
| 198 | 198 | $errormsg .= "(HTTP Error: $http_error)"; |
| 199 | 199 | } |
| 200 | 200 | else { |
| 201 | - $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
|
| 201 | + $errormsg .= "(HTTP Response: ".$resp->response_code.')'; |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | // attempt to return cached object |
| 212 | 212 | if ($rss) { |
| 213 | - if ( MAGPIE_DEBUG ) { |
|
| 213 | + if (MAGPIE_DEBUG) { |
|
| 214 | 214 | debug("Returning STALE object for $url"); |
| 215 | 215 | } |
| 216 | 216 | return $rss; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // else we totally failed |
| 220 | - error( $errormsg ); |
|
| 220 | + error($errormsg); |
|
| 221 | 221 | |
| 222 | 222 | return false; |
| 223 | 223 | |
@@ -229,21 +229,21 @@ discard block |
||
| 229 | 229 | Purpose: set MAGPIE_ERROR, and trigger error |
| 230 | 230 | \*=======================================================================*/ |
| 231 | 231 | |
| 232 | -function error ($errormsg, $lvl=E_USER_WARNING) { |
|
| 232 | +function error($errormsg, $lvl = E_USER_WARNING){ |
|
| 233 | 233 | global $MAGPIE_ERROR; |
| 234 | 234 | |
| 235 | 235 | // append PHP's error message if track_errors enabled |
| 236 | - if ( isset($php_errormsg) ) { |
|
| 236 | + if (isset($php_errormsg)) { |
|
| 237 | 237 | $errormsg .= " ($php_errormsg)"; |
| 238 | 238 | } |
| 239 | - if ( $errormsg ) { |
|
| 239 | + if ($errormsg) { |
|
| 240 | 240 | $errormsg = "MagpieRSS: $errormsg"; |
| 241 | 241 | $MAGPIE_ERROR = $errormsg; |
| 242 | - trigger_error( $errormsg, $lvl); |
|
| 242 | + trigger_error($errormsg, $lvl); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | -function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
| 246 | +function debug($debugmsg, $lvl = E_USER_NOTICE){ |
|
| 247 | 247 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | Function: magpie_error |
| 252 | 252 | Purpose: accessor for the magpie error variable |
| 253 | 253 | \*=======================================================================*/ |
| 254 | -function magpie_error ($errormsg="") { |
|
| 254 | +function magpie_error($errormsg = ""){ |
|
| 255 | 255 | global $MAGPIE_ERROR; |
| 256 | 256 | |
| 257 | - if ( isset($errormsg) and $errormsg ) { |
|
| 257 | + if (isset($errormsg) and $errormsg) { |
|
| 258 | 258 | $MAGPIE_ERROR = $errormsg; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | headers to send along with the request (optional) |
| 269 | 269 | Output: an HTTP response object (see Snoopy.class.inc) |
| 270 | 270 | \*=======================================================================*/ |
| 271 | -function _fetch_remote_file ($url, $headers = "" ) { |
|
| 271 | +function _fetch_remote_file($url, $headers = ""){ |
|
| 272 | 272 | // Snoopy is an HTTP client in PHP |
| 273 | 273 | $client = new Snoopy(); |
| 274 | 274 | $client->agent = MAGPIE_USER_AGENT; |
| 275 | 275 | $client->read_timeout = MAGPIE_FETCH_TIME_OUT; |
| 276 | 276 | $client->use_gzip = MAGPIE_USE_GZIP; |
| 277 | - if (is_array($headers) ) { |
|
| 277 | + if (is_array($headers)) { |
|
| 278 | 278 | $client->rawheaders = $headers; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -289,14 +289,14 @@ discard block |
||
| 289 | 289 | Input: an HTTP response object (see Snoopy) |
| 290 | 290 | Output: parsed RSS object (see rss_parse) |
| 291 | 291 | \*=======================================================================*/ |
| 292 | -function _response_to_rss ($resp) { |
|
| 293 | - $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
|
| 292 | +function _response_to_rss($resp){ |
|
| 293 | + $rss = new MagpieRSS($resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING); |
|
| 294 | 294 | |
| 295 | 295 | // if RSS parsed successfully |
| 296 | - if ( $rss and !$rss->ERROR) { |
|
| 296 | + if ($rss and !$rss->ERROR) { |
|
| 297 | 297 | |
| 298 | 298 | // find Etag, and Last-Modified |
| 299 | - foreach($resp->headers as $h) { |
|
| 299 | + foreach ($resp->headers as $h) { |
|
| 300 | 300 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
| 301 | 301 | if (strpos($h, ": ")) { |
| 302 | 302 | list($field, $val) = explode(": ", $h, 2); |
@@ -306,11 +306,11 @@ discard block |
||
| 306 | 306 | $val = ""; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if ( $field == 'ETag' ) { |
|
| 309 | + if ($field == 'ETag') { |
|
| 310 | 310 | $rss->etag = $val; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if ( $field == 'Last-Modified' ) { |
|
| 313 | + if ($field == 'Last-Modified') { |
|
| 314 | 314 | $rss->last_modified = $val; |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $errormsg = "Failed to parse RSS file."; |
| 322 | 322 | |
| 323 | 323 | if ($rss) { |
| 324 | - $errormsg .= " (" . $rss->ERROR . ")"; |
|
| 324 | + $errormsg .= " (".$rss->ERROR.")"; |
|
| 325 | 325 | } |
| 326 | 326 | error($errormsg); |
| 327 | 327 | |
@@ -334,67 +334,67 @@ discard block |
||
| 334 | 334 | Purpose: setup constants with default values |
| 335 | 335 | check for user overrides |
| 336 | 336 | \*=======================================================================*/ |
| 337 | -function init () { |
|
| 338 | - if ( defined('MAGPIE_INITALIZED') ) { |
|
| 337 | +function init(){ |
|
| 338 | + if (defined('MAGPIE_INITALIZED')) { |
|
| 339 | 339 | return; |
| 340 | 340 | } |
| 341 | 341 | else { |
| 342 | 342 | define('MAGPIE_INITALIZED', true); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if ( !defined('MAGPIE_CACHE_ON') ) { |
|
| 345 | + if (!defined('MAGPIE_CACHE_ON')) { |
|
| 346 | 346 | define('MAGPIE_CACHE_ON', true); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if ( !defined('MAGPIE_CACHE_DIR') ) { |
|
| 349 | + if (!defined('MAGPIE_CACHE_DIR')) { |
|
| 350 | 350 | define('MAGPIE_CACHE_DIR', './cache'); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - if ( !defined('MAGPIE_CACHE_AGE') ) { |
|
| 354 | - define('MAGPIE_CACHE_AGE', 60*60); // one hour |
|
| 353 | + if (!defined('MAGPIE_CACHE_AGE')) { |
|
| 354 | + define('MAGPIE_CACHE_AGE', 60 * 60); // one hour |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { |
|
| 357 | + if (!defined('MAGPIE_CACHE_FRESH_ONLY')) { |
|
| 358 | 358 | define('MAGPIE_CACHE_FRESH_ONLY', false); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { |
|
| 361 | + if (!defined('MAGPIE_OUTPUT_ENCODING')) { |
|
| 362 | 362 | global $modx_manager_charset; |
| 363 | - if(empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
| 363 | + if (empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
| 364 | 364 | define('MAGPIE_OUTPUT_ENCODING', $modx_manager_charset); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( !defined('MAGPIE_INPUT_ENCODING') ) { |
|
| 367 | + if (!defined('MAGPIE_INPUT_ENCODING')) { |
|
| 368 | 368 | define('MAGPIE_INPUT_ENCODING', null); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if ( !defined('MAGPIE_DETECT_ENCODING') ) { |
|
| 371 | + if (!defined('MAGPIE_DETECT_ENCODING')) { |
|
| 372 | 372 | define('MAGPIE_DETECT_ENCODING', true); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if ( !defined('MAGPIE_DEBUG') ) { |
|
| 375 | + if (!defined('MAGPIE_DEBUG')) { |
|
| 376 | 376 | define('MAGPIE_DEBUG', 0); |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if ( !defined('MAGPIE_USER_AGENT') ) { |
|
| 380 | - $ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net'; |
|
| 379 | + if (!defined('MAGPIE_USER_AGENT')) { |
|
| 380 | + $ua = 'MagpieRSS/'.MAGPIE_VERSION.' (+http://magpierss.sf.net'; |
|
| 381 | 381 | |
| 382 | - if ( MAGPIE_CACHE_ON ) { |
|
| 383 | - $ua = $ua . ')'; |
|
| 382 | + if (MAGPIE_CACHE_ON) { |
|
| 383 | + $ua = $ua.')'; |
|
| 384 | 384 | } |
| 385 | 385 | else { |
| 386 | - $ua = $ua . '; No cache)'; |
|
| 386 | + $ua = $ua.'; No cache)'; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | define('MAGPIE_USER_AGENT', $ua); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { |
|
| 392 | + if (!defined('MAGPIE_FETCH_TIME_OUT')) { |
|
| 393 | 393 | define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // use gzip encoding to fetch rss files if supported? |
| 397 | - if ( !defined('MAGPIE_USE_GZIP') ) { |
|
| 397 | + if (!defined('MAGPIE_USE_GZIP')) { |
|
| 398 | 398 | define('MAGPIE_USE_GZIP', true); |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | Function: is_info |
| 418 | 418 | Purpose: return true if Informational status code |
| 419 | 419 | \*=======================================================================*/ |
| 420 | -function is_info ($sc) { |
|
| 420 | +function is_info($sc){ |
|
| 421 | 421 | return $sc >= 100 && $sc < 200; |
| 422 | 422 | } |
| 423 | 423 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | Function: is_success |
| 426 | 426 | Purpose: return true if Successful status code |
| 427 | 427 | \*=======================================================================*/ |
| 428 | -function is_success ($sc) { |
|
| 428 | +function is_success($sc){ |
|
| 429 | 429 | return $sc >= 200 && $sc < 300; |
| 430 | 430 | } |
| 431 | 431 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | Function: is_redirect |
| 434 | 434 | Purpose: return true if Redirection status code |
| 435 | 435 | \*=======================================================================*/ |
| 436 | -function is_redirect ($sc) { |
|
| 436 | +function is_redirect($sc){ |
|
| 437 | 437 | return $sc >= 300 && $sc < 400; |
| 438 | 438 | } |
| 439 | 439 | |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | Function: is_error |
| 442 | 442 | Purpose: return true if Error status code |
| 443 | 443 | \*=======================================================================*/ |
| 444 | -function is_error ($sc) { |
|
| 444 | +function is_error($sc){ |
|
| 445 | 445 | return $sc >= 400 && $sc < 600; |
| 446 | 446 | } |
| 447 | 447 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | Function: is_client_error |
| 450 | 450 | Purpose: return true if Error status code, and its a client error |
| 451 | 451 | \*=======================================================================*/ |
| 452 | -function is_client_error ($sc) { |
|
| 452 | +function is_client_error($sc){ |
|
| 453 | 453 | return $sc >= 400 && $sc < 500; |
| 454 | 454 | } |
| 455 | 455 | |
@@ -457,6 +457,6 @@ discard block |
||
| 457 | 457 | Function: is_client_error |
| 458 | 458 | Purpose: return true if Error status code, and its a server error |
| 459 | 459 | \*=======================================================================*/ |
| 460 | -function is_server_error ($sc) { |
|
| 460 | +function is_server_error($sc){ |
|
| 461 | 461 | return $sc >= 500 && $sc < 600; |
| 462 | 462 | } |
@@ -89,7 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $MAGPIE_ERROR = ""; |
| 91 | 91 | |
| 92 | -function fetch_rss ($url) { |
|
| 92 | +function fetch_rss ($url) |
|
| 93 | +{ |
|
| 93 | 94 | // initialize constants |
| 94 | 95 | init(); |
| 95 | 96 | |
@@ -104,8 +105,7 @@ discard block |
||
| 104 | 105 | $resp = _fetch_remote_file( $url ); |
| 105 | 106 | if ( is_success( $resp->status ) ) { |
| 106 | 107 | return _response_to_rss( $resp ); |
| 107 | - } |
|
| 108 | - else { |
|
| 108 | + } else { |
|
| 109 | 109 | error("Failed to fetch $url and cache is off"); |
| 110 | 110 | return false; |
| 111 | 111 | } |
@@ -174,8 +174,7 @@ discard block |
||
| 174 | 174 | // reset cache on 304 (at minutillo insistent prodding) |
| 175 | 175 | $cache->set($cache_key, $rss); |
| 176 | 176 | return $rss; |
| 177 | - } |
|
| 178 | - elseif ( is_success( $resp->status ) ) { |
|
| 177 | + } elseif ( is_success( $resp->status ) ) { |
|
| 179 | 178 | $rss = _response_to_rss( $resp ); |
| 180 | 179 | if ( $rss ) { |
| 181 | 180 | if (MAGPIE_DEBUG > 1) { |
@@ -185,24 +184,20 @@ discard block |
||
| 185 | 184 | $cache->set( $cache_key, $rss ); |
| 186 | 185 | return $rss; |
| 187 | 186 | } |
| 188 | - } |
|
| 189 | - else { |
|
| 187 | + } else { |
|
| 190 | 188 | $errormsg = "Failed to fetch $url "; |
| 191 | 189 | if ( $resp->status == '-100' ) { |
| 192 | 190 | $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
| 193 | - } |
|
| 194 | - elseif ( $resp->error ) { |
|
| 191 | + } elseif ( $resp->error ) { |
|
| 195 | 192 | # compensate for Snoopy's annoying habbit to tacking |
| 196 | 193 | # on '\n' |
| 197 | 194 | $http_error = substr($resp->error, 0, -2); |
| 198 | 195 | $errormsg .= "(HTTP Error: $http_error)"; |
| 199 | - } |
|
| 200 | - else { |
|
| 196 | + } else { |
|
| 201 | 197 | $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
| 202 | 198 | } |
| 203 | 199 | } |
| 204 | - } |
|
| 205 | - else { |
|
| 200 | + } else { |
|
| 206 | 201 | $errormsg = "Unable to retrieve RSS file for unknown reasons."; |
| 207 | 202 | } |
| 208 | 203 | |
@@ -229,7 +224,8 @@ discard block |
||
| 229 | 224 | Purpose: set MAGPIE_ERROR, and trigger error |
| 230 | 225 | \*=======================================================================*/ |
| 231 | 226 | |
| 232 | -function error ($errormsg, $lvl=E_USER_WARNING) { |
|
| 227 | +function error ($errormsg, $lvl=E_USER_WARNING) |
|
| 228 | +{ |
|
| 233 | 229 | global $MAGPIE_ERROR; |
| 234 | 230 | |
| 235 | 231 | // append PHP's error message if track_errors enabled |
@@ -243,7 +239,8 @@ discard block |
||
| 243 | 239 | } |
| 244 | 240 | } |
| 245 | 241 | |
| 246 | -function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
| 242 | +function debug ($debugmsg, $lvl=E_USER_NOTICE) |
|
| 243 | +{ |
|
| 247 | 244 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
| 248 | 245 | } |
| 249 | 246 | |
@@ -251,7 +248,8 @@ discard block |
||
| 251 | 248 | Function: magpie_error |
| 252 | 249 | Purpose: accessor for the magpie error variable |
| 253 | 250 | \*=======================================================================*/ |
| 254 | -function magpie_error ($errormsg="") { |
|
| 251 | +function magpie_error ($errormsg="") |
|
| 252 | +{ |
|
| 255 | 253 | global $MAGPIE_ERROR; |
| 256 | 254 | |
| 257 | 255 | if ( isset($errormsg) and $errormsg ) { |
@@ -268,7 +266,8 @@ discard block |
||
| 268 | 266 | headers to send along with the request (optional) |
| 269 | 267 | Output: an HTTP response object (see Snoopy.class.inc) |
| 270 | 268 | \*=======================================================================*/ |
| 271 | -function _fetch_remote_file ($url, $headers = "" ) { |
|
| 269 | +function _fetch_remote_file ($url, $headers = "" ) |
|
| 270 | +{ |
|
| 272 | 271 | // Snoopy is an HTTP client in PHP |
| 273 | 272 | $client = new Snoopy(); |
| 274 | 273 | $client->agent = MAGPIE_USER_AGENT; |
@@ -289,7 +288,8 @@ discard block |
||
| 289 | 288 | Input: an HTTP response object (see Snoopy) |
| 290 | 289 | Output: parsed RSS object (see rss_parse) |
| 291 | 290 | \*=======================================================================*/ |
| 292 | -function _response_to_rss ($resp) { |
|
| 291 | +function _response_to_rss ($resp) |
|
| 292 | +{ |
|
| 293 | 293 | $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
| 294 | 294 | |
| 295 | 295 | // if RSS parsed successfully |
@@ -300,8 +300,7 @@ discard block |
||
| 300 | 300 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
| 301 | 301 | if (strpos($h, ": ")) { |
| 302 | 302 | list($field, $val) = explode(": ", $h, 2); |
| 303 | - } |
|
| 304 | - else { |
|
| 303 | + } else { |
|
| 305 | 304 | $field = $h; |
| 306 | 305 | $val = ""; |
| 307 | 306 | } |
@@ -334,11 +333,11 @@ discard block |
||
| 334 | 333 | Purpose: setup constants with default values |
| 335 | 334 | check for user overrides |
| 336 | 335 | \*=======================================================================*/ |
| 337 | -function init () { |
|
| 336 | +function init () |
|
| 337 | +{ |
|
| 338 | 338 | if ( defined('MAGPIE_INITALIZED') ) { |
| 339 | 339 | return; |
| 340 | - } |
|
| 341 | - else { |
|
| 340 | + } else { |
|
| 342 | 341 | define('MAGPIE_INITALIZED', true); |
| 343 | 342 | } |
| 344 | 343 | |
@@ -360,7 +359,9 @@ discard block |
||
| 360 | 359 | |
| 361 | 360 | if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { |
| 362 | 361 | global $modx_manager_charset; |
| 363 | - if(empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
| 362 | + if(empty($modx_manager_charset)) { |
|
| 363 | + $modx_manager_charset = 'ISO-8859-1'; |
|
| 364 | + } |
|
| 364 | 365 | define('MAGPIE_OUTPUT_ENCODING', $modx_manager_charset); |
| 365 | 366 | } |
| 366 | 367 | |
@@ -381,8 +382,7 @@ discard block |
||
| 381 | 382 | |
| 382 | 383 | if ( MAGPIE_CACHE_ON ) { |
| 383 | 384 | $ua = $ua . ')'; |
| 384 | - } |
|
| 385 | - else { |
|
| 385 | + } else { |
|
| 386 | 386 | $ua = $ua . '; No cache)'; |
| 387 | 387 | } |
| 388 | 388 | |
@@ -417,7 +417,8 @@ discard block |
||
| 417 | 417 | Function: is_info |
| 418 | 418 | Purpose: return true if Informational status code |
| 419 | 419 | \*=======================================================================*/ |
| 420 | -function is_info ($sc) { |
|
| 420 | +function is_info ($sc) |
|
| 421 | +{ |
|
| 421 | 422 | return $sc >= 100 && $sc < 200; |
| 422 | 423 | } |
| 423 | 424 | |
@@ -425,7 +426,8 @@ discard block |
||
| 425 | 426 | Function: is_success |
| 426 | 427 | Purpose: return true if Successful status code |
| 427 | 428 | \*=======================================================================*/ |
| 428 | -function is_success ($sc) { |
|
| 429 | +function is_success ($sc) |
|
| 430 | +{ |
|
| 429 | 431 | return $sc >= 200 && $sc < 300; |
| 430 | 432 | } |
| 431 | 433 | |
@@ -433,7 +435,8 @@ discard block |
||
| 433 | 435 | Function: is_redirect |
| 434 | 436 | Purpose: return true if Redirection status code |
| 435 | 437 | \*=======================================================================*/ |
| 436 | -function is_redirect ($sc) { |
|
| 438 | +function is_redirect ($sc) |
|
| 439 | +{ |
|
| 437 | 440 | return $sc >= 300 && $sc < 400; |
| 438 | 441 | } |
| 439 | 442 | |
@@ -441,7 +444,8 @@ discard block |
||
| 441 | 444 | Function: is_error |
| 442 | 445 | Purpose: return true if Error status code |
| 443 | 446 | \*=======================================================================*/ |
| 444 | -function is_error ($sc) { |
|
| 447 | +function is_error ($sc) |
|
| 448 | +{ |
|
| 445 | 449 | return $sc >= 400 && $sc < 600; |
| 446 | 450 | } |
| 447 | 451 | |
@@ -449,7 +453,8 @@ discard block |
||
| 449 | 453 | Function: is_client_error |
| 450 | 454 | Purpose: return true if Error status code, and its a client error |
| 451 | 455 | \*=======================================================================*/ |
| 452 | -function is_client_error ($sc) { |
|
| 456 | +function is_client_error ($sc) |
|
| 457 | +{ |
|
| 453 | 458 | return $sc >= 400 && $sc < 500; |
| 454 | 459 | } |
| 455 | 460 | |
@@ -457,6 +462,7 @@ discard block |
||
| 457 | 462 | Function: is_client_error |
| 458 | 463 | Purpose: return true if Error status code, and its a server error |
| 459 | 464 | \*=======================================================================*/ |
| 460 | -function is_server_error ($sc) { |
|
| 465 | +function is_server_error ($sc) |
|
| 466 | +{ |
|
| 461 | 467 | return $sc >= 500 && $sc < 600; |
| 462 | 468 | } |
@@ -18,11 +18,17 @@ discard block |
||
| 18 | 18 | $this->request_time = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | + /** |
|
| 22 | + * @param string $path |
|
| 23 | + */ |
|
| 21 | 24 | function setCachepath($path) |
| 22 | 25 | { |
| 23 | 26 | $this->cachePath = $path; |
| 24 | 27 | } |
| 25 | 28 | |
| 29 | + /** |
|
| 30 | + * @param boolean $bool |
|
| 31 | + */ |
|
| 26 | 32 | function setReport($bool) |
| 27 | 33 | { |
| 28 | 34 | $this->showReport = $bool; |
@@ -45,6 +51,9 @@ discard block |
||
| 45 | 51 | return str_replace($q1, $q2, $s); |
| 46 | 52 | } |
| 47 | 53 | |
| 54 | + /** |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 48 | 57 | function getParents($id, $path = '') |
| 49 | 58 | { // modx:returns child's parent |
| 50 | 59 | global $modx; |
@@ -148,6 +157,9 @@ discard block |
||
| 148 | 157 | } |
| 149 | 158 | } |
| 150 | 159 | |
| 160 | + /** |
|
| 161 | + * @return string |
|
| 162 | + */ |
|
| 151 | 163 | public function getCacheRefreshTime() |
| 152 | 164 | { |
| 153 | 165 | global $modx; |
@@ -190,7 +202,7 @@ discard block |
||
| 190 | 202 | /** |
| 191 | 203 | * build siteCache file |
| 192 | 204 | * @param DocumentParser $modx |
| 193 | - * @return boolean success |
|
| 205 | + * @return null|boolean success |
|
| 194 | 206 | */ |
| 195 | 207 | public function buildCache($modx) |
| 196 | 208 | { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (isset($this->aliases[$id])) { |
| 62 | 62 | if ($this->aliasVisible[$id] == 1) { |
| 63 | 63 | if ($path != '') { |
| 64 | - $path = $this->aliases[$id] . '/' . $path; |
|
| 64 | + $path = $this->aliases[$id].'/'.$path; |
|
| 65 | 65 | } else { |
| 66 | 66 | $path = $this->aliases[$id]; |
| 67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $modx->messageQuit("Cache path not set."); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $files = glob(realpath($this->cachePath) . '/*.pageCache.php'); |
|
| 83 | + $files = glob(realpath($this->cachePath).'/*.pageCache.php'); |
|
| 84 | 84 | $filesincache = count($files); |
| 85 | 85 | $deletedfiles = array(); |
| 86 | 86 | while ($file = array_shift($files)) { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if(function_exists('opcache_get_status')) { |
|
| 96 | + if (function_exists('opcache_get_status')) { |
|
| 97 | 97 | $opcache = opcache_get_status(); |
| 98 | 98 | if (!empty($opcache['opcache_enabled'])) { |
| 99 | 99 | opcache_reset(); |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | if (isset($opcache)) { |
| 114 | 114 | echo '<p>Opcache empty.</p>'; |
| 115 | 115 | } |
| 116 | - echo '<p>' . $_lang['cache_files_deleted'] . '</p><ul>'; |
|
| 116 | + echo '<p>'.$_lang['cache_files_deleted'].'</p><ul>'; |
|
| 117 | 117 | foreach ($deletedfiles as $deletedfile) { |
| 118 | - echo '<li>' . $deletedfile . '</li>'; |
|
| 118 | + echo '<li>'.$deletedfile.'</li>'; |
|
| 119 | 119 | } |
| 120 | 120 | echo '</ul>'; |
| 121 | 121 | } |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | // write the file |
| 134 | - $content = '<?php' . "\n"; |
|
| 135 | - $content .= '$recent_update=\'' . $this->request_time . '\';' . "\n"; |
|
| 136 | - $content .= '$cacheRefreshTime=\'' . $cacheRefreshTime . '\';' . "\n"; |
|
| 134 | + $content = '<?php'."\n"; |
|
| 135 | + $content .= '$recent_update=\''.$this->request_time.'\';'."\n"; |
|
| 136 | + $content .= '$cacheRefreshTime=\''.$cacheRefreshTime.'\';'."\n"; |
|
| 137 | 137 | |
| 138 | - $filename = $this->cachePath . '/sitePublishing.idx.php'; |
|
| 138 | + $filename = $this->cachePath.'/sitePublishing.idx.php'; |
|
| 139 | 139 | if (!$handle = fopen($filename, 'w')) { |
| 140 | 140 | exit("Cannot open file ({$filename}"); |
| 141 | 141 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | // update publish time file |
| 156 | 156 | $timesArr = array(); |
| 157 | 157 | |
| 158 | - $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', 'pub_date>' . $this->request_time); |
|
| 158 | + $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', 'pub_date>'.$this->request_time); |
|
| 159 | 159 | if (!$result) { |
| 160 | 160 | echo "Couldn't determine next publish event!"; |
| 161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $timesArr[] = $minpub; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', 'unpub_date>' . $this->request_time); |
|
| 168 | + $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', 'unpub_date>'.$this->request_time); |
|
| 169 | 169 | if (!$result) { |
| 170 | 170 | echo "Couldn't determine next unpublish event!"; |
| 171 | 171 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $config = array(); |
| 204 | 204 | $content .= '$c=&$this->config;'; |
| 205 | 205 | while (list($key, $value) = $modx->db->getRow($rs, 'num')) { |
| 206 | - $content .= '$c[\'' . $key . '\']="' . $this->escapeDoubleQuotes($value) . '";'; |
|
| 206 | + $content .= '$c[\''.$key.'\']="'.$this->escapeDoubleQuotes($value).'";'; |
|
| 207 | 207 | $config[$key] = $value; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -241,23 +241,23 @@ discard block |
||
| 241 | 241 | $docid = $doc['id']; |
| 242 | 242 | if ($use_alias_path) { |
| 243 | 243 | $tmpPath = $this->getParents($doc['parent']); |
| 244 | - $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '') . $doc['alias']; |
|
| 244 | + $alias = (strlen($tmpPath) > 0 ? "$tmpPath/" : '').$doc['alias']; |
|
| 245 | 245 | $key = $alias; |
| 246 | 246 | } else { |
| 247 | 247 | $key = $doc['alias']; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | $doc['path'] = $tmpPath; |
| 251 | - $content .= '$a[' . $docid . ']=array(\'id\'=>' . $docid . ',\'alias\'=>\'' . $doc['alias'] . '\',\'path\'=>\'' . $doc['path'] . '\',\'parent\'=>' . $doc['parent'] . ',\'isfolder\'=>' . $doc['isfolder'] . ',\'alias_visible\'=>' . $doc['alias_visible'] . ');'; |
|
| 252 | - $content .= '$d[\'' . $key . '\']=' . $docid . ';'; |
|
| 253 | - $content .= '$m[]=array(' . $doc['parent'] . '=>' . $docid . ');'; |
|
| 251 | + $content .= '$a['.$docid.']=array(\'id\'=>'.$docid.',\'alias\'=>\''.$doc['alias'].'\',\'path\'=>\''.$doc['path'].'\',\'parent\'=>'.$doc['parent'].',\'isfolder\'=>'.$doc['isfolder'].',\'alias_visible\'=>'.$doc['alias_visible'].');'; |
|
| 252 | + $content .= '$d[\''.$key.'\']='.$docid.';'; |
|
| 253 | + $content .= '$m[]=array('.$doc['parent'].'=>'.$docid.');'; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // get content types |
| 257 | 257 | $rs = $modx->db->select('id, contentType', '[+prefix+]site_content', "contentType!='text/html'"); |
| 258 | 258 | $content .= '$c=&$this->contentTypes;'; |
| 259 | 259 | while ($doc = $modx->db->getRow($rs)) { |
| 260 | - $content .= '$c[\'' . $doc['id'] . '\']=\'' . $doc['contentType'] . '\';'; |
|
| 260 | + $content .= '$c[\''.$doc['id'].'\']=\''.$doc['contentType'].'\';'; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // WRITE Chunks to cache file |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | if ($modx->config['minifyphp_incache']) { |
| 268 | 268 | $doc['snippet'] = $this->php_strip_whitespace($doc['snippet']); |
| 269 | 269 | } |
| 270 | - $content .= '$c[\'' . $doc['name'] . '\']=\'' . ($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])) . '\';'; |
|
| 270 | + $content .= '$c[\''.$doc['name'].'\']=\''.($doc['disabled'] ? '' : $this->escapeSingleQuotes($doc['snippet'])).'\';'; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // WRITE snippets to cache file |
@@ -278,18 +278,18 @@ discard block |
||
| 278 | 278 | while ($row = $modx->db->getRow($rs)) { |
| 279 | 279 | $key = $row['name']; |
| 280 | 280 | if ($row['disabled']) { |
| 281 | - $content .= '$s[\'' . $key . '\']=\'return false;\';'; |
|
| 281 | + $content .= '$s[\''.$key.'\']=\'return false;\';'; |
|
| 282 | 282 | } else { |
| 283 | 283 | $value = trim($row['snippet']); |
| 284 | 284 | if ($modx->config['minifyphp_incache']) { |
| 285 | 285 | $value = $this->php_strip_whitespace($value); |
| 286 | 286 | } |
| 287 | - $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
| 287 | + $content .= '$s[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
| 288 | 288 | $properties = $modx->parseProperties($row['properties']); |
| 289 | 289 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
| 290 | 290 | $properties = array_merge($sharedproperties, $properties); |
| 291 | 291 | if (0 < count($properties)) { |
| 292 | - $content .= '$s[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
| 292 | + $content .= '$s[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | } |
@@ -307,13 +307,13 @@ discard block |
||
| 307 | 307 | if ($modx->config['minifyphp_incache']) { |
| 308 | 308 | $value = $this->php_strip_whitespace($value); |
| 309 | 309 | } |
| 310 | - $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; |
|
| 310 | + $content .= '$p[\''.$key.'\']=\''.$this->escapeSingleQuotes($value).'\';'; |
|
| 311 | 311 | if ($row['properties'] != '' || $row['sharedproperties'] != '') { |
| 312 | 312 | $properties = $modx->parseProperties($row['properties']); |
| 313 | 313 | $sharedproperties = $modx->parseProperties($row['sharedproperties']); |
| 314 | 314 | $properties = array_merge($sharedproperties, $properties); |
| 315 | 315 | if (0 < count($properties)) { |
| 316 | - $content .= '$p[\'' . $key . 'Props\']=\'' . $this->escapeSingleQuotes(json_encode($properties)) . '\';'; |
|
| 316 | + $content .= '$p[\''.$key.'Props\']=\''.$this->escapeSingleQuotes(json_encode($properties)).'\';'; |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | foreach ($events as $evtname => $pluginnames) { |
| 338 | 338 | $events[$evtname] = $pluginnames; |
| 339 | - $content .= '$e[\'' . $evtname . '\']=array(\'' . implode('\',\'', $this->escapeSingleQuotes($pluginnames)) . '\');'; |
|
| 339 | + $content .= '$e[\''.$evtname.'\']=array(\''.implode('\',\'', $this->escapeSingleQuotes($pluginnames)).'\');'; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | $content .= "\n"; |
| 343 | 343 | |
| 344 | 344 | // close and write the file |
| 345 | - $filename = $this->cachePath . 'siteCache.idx.php'; |
|
| 345 | + $filename = $this->cachePath.'siteCache.idx.php'; |
|
| 346 | 346 | |
| 347 | 347 | // invoke OnBeforeCacheUpdate event |
| 348 | 348 | if ($modx) { |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | exit("Cannot write main MODX cache file! Make sure the assets/cache directory is writable!"); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if (!is_file($this->cachePath . '/.htaccess')) { |
|
| 357 | - file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n"); |
|
| 356 | + if (!is_file($this->cachePath.'/.htaccess')) { |
|
| 357 | + file_put_contents($this->cachePath.'/.htaccess', "order deny,allow\ndeny from all\n"); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | // invoke OnCacheUpdate event |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | $source = trim($source); |
| 373 | 373 | if (substr($source, 0, 5) !== '<?php') { |
| 374 | - $source = '<?php ' . $source; |
|
| 374 | + $source = '<?php '.$source; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $tokens = token_get_all($source); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | $_ .= $text; |
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | - $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), array('', ' ', "\n" . '<!--', '-->' . "\n", '-->' . "\n" . '<!--'), $_); |
|
| 430 | + $source = preg_replace(array('@^<\?php@i', '|\s+|', '|<!--|', '|-->|', '|-->\s+<!--|'), array('', ' ', "\n".'<!--', '-->'."\n", '-->'."\n".'<!--'), $_); |
|
| 431 | 431 | $source = trim($source); |
| 432 | 432 | return $source; |
| 433 | 433 | } |
@@ -46,7 +46,8 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function getParents($id, $path = '') |
| 49 | - { // modx:returns child's parent |
|
| 49 | + { |
|
| 50 | +// modx:returns child's parent |
|
| 50 | 51 | global $modx; |
| 51 | 52 | if (empty($this->aliases)) { |
| 52 | 53 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -403,7 +404,8 @@ discard block |
||
| 403 | 404 | $_ = trim($_); |
| 404 | 405 | } |
| 405 | 406 | $lastChar = substr($_, -1); |
| 406 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
| 407 | + if (!in_array($lastChar, $chars)) { |
|
| 408 | +// ,320,327,288,284,289 |
|
| 407 | 409 | if (!in_array($prev_token, array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
| 408 | 410 | $_ .= ' '; |
| 409 | 411 | } |
@@ -170,70 +170,70 @@ |
||
| 170 | 170 | array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | - if (intval($params['shareparams']) || !empty($params['dependencies'])) { |
|
| 174 | - $dependencies = explode(',', $params['dependencies']); |
|
| 175 | - foreach ($dependencies as $dependency) { |
|
| 176 | - $dependency = explode(':', $dependency); |
|
| 177 | - switch (trim($dependency[0])) { |
|
| 178 | - case 'template': |
|
| 179 | - $mdp[] = array( |
|
| 180 | - 'module' => $params['name'], |
|
| 181 | - 'table' => 'templates', |
|
| 182 | - 'column' => 'templatename', |
|
| 183 | - 'type' => 50, |
|
| 184 | - 'name' => trim($dependency[1]) |
|
| 185 | - ); |
|
| 186 | - break; |
|
| 187 | - case 'tv': |
|
| 188 | - case 'tmplvar': |
|
| 189 | - $mdp[] = array( |
|
| 190 | - 'module' => $params['name'], |
|
| 191 | - 'table' => 'tmplvars', |
|
| 192 | - 'column' => 'name', |
|
| 193 | - 'type' => 60, |
|
| 194 | - 'name' => trim($dependency[1]) |
|
| 195 | - ); |
|
| 196 | - break; |
|
| 197 | - case 'chunk': |
|
| 198 | - case 'htmlsnippet': |
|
| 199 | - $mdp[] = array( |
|
| 200 | - 'module' => $params['name'], |
|
| 201 | - 'table' => 'htmlsnippets', |
|
| 202 | - 'column' => 'name', |
|
| 203 | - 'type' => 10, |
|
| 204 | - 'name' => trim($dependency[1]) |
|
| 205 | - ); |
|
| 206 | - break; |
|
| 207 | - case 'snippet': |
|
| 208 | - $mdp[] = array( |
|
| 209 | - 'module' => $params['name'], |
|
| 210 | - 'table' => 'snippets', |
|
| 211 | - 'column' => 'name', |
|
| 212 | - 'type' => 40, |
|
| 213 | - 'name' => trim($dependency[1]) |
|
| 214 | - ); |
|
| 215 | - break; |
|
| 216 | - case 'plugin': |
|
| 217 | - $mdp[] = array( |
|
| 218 | - 'module' => $params['name'], |
|
| 219 | - 'table' => 'plugins', |
|
| 220 | - 'column' => 'name', |
|
| 221 | - 'type' => 30, |
|
| 222 | - 'name' => trim($dependency[1]) |
|
| 223 | - ); |
|
| 224 | - break; |
|
| 225 | - case 'resource': |
|
| 226 | - $mdp[] = array( |
|
| 227 | - 'module' => $params['name'], |
|
| 228 | - 'table' => 'content', |
|
| 229 | - 'column' => 'pagetitle', |
|
| 230 | - 'type' => 20, |
|
| 231 | - 'name' => trim($dependency[1]) |
|
| 232 | - ); |
|
| 233 | - break; |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - } |
|
| 173 | + if (intval($params['shareparams']) || !empty($params['dependencies'])) { |
|
| 174 | + $dependencies = explode(',', $params['dependencies']); |
|
| 175 | + foreach ($dependencies as $dependency) { |
|
| 176 | + $dependency = explode(':', $dependency); |
|
| 177 | + switch (trim($dependency[0])) { |
|
| 178 | + case 'template': |
|
| 179 | + $mdp[] = array( |
|
| 180 | + 'module' => $params['name'], |
|
| 181 | + 'table' => 'templates', |
|
| 182 | + 'column' => 'templatename', |
|
| 183 | + 'type' => 50, |
|
| 184 | + 'name' => trim($dependency[1]) |
|
| 185 | + ); |
|
| 186 | + break; |
|
| 187 | + case 'tv': |
|
| 188 | + case 'tmplvar': |
|
| 189 | + $mdp[] = array( |
|
| 190 | + 'module' => $params['name'], |
|
| 191 | + 'table' => 'tmplvars', |
|
| 192 | + 'column' => 'name', |
|
| 193 | + 'type' => 60, |
|
| 194 | + 'name' => trim($dependency[1]) |
|
| 195 | + ); |
|
| 196 | + break; |
|
| 197 | + case 'chunk': |
|
| 198 | + case 'htmlsnippet': |
|
| 199 | + $mdp[] = array( |
|
| 200 | + 'module' => $params['name'], |
|
| 201 | + 'table' => 'htmlsnippets', |
|
| 202 | + 'column' => 'name', |
|
| 203 | + 'type' => 10, |
|
| 204 | + 'name' => trim($dependency[1]) |
|
| 205 | + ); |
|
| 206 | + break; |
|
| 207 | + case 'snippet': |
|
| 208 | + $mdp[] = array( |
|
| 209 | + 'module' => $params['name'], |
|
| 210 | + 'table' => 'snippets', |
|
| 211 | + 'column' => 'name', |
|
| 212 | + 'type' => 40, |
|
| 213 | + 'name' => trim($dependency[1]) |
|
| 214 | + ); |
|
| 215 | + break; |
|
| 216 | + case 'plugin': |
|
| 217 | + $mdp[] = array( |
|
| 218 | + 'module' => $params['name'], |
|
| 219 | + 'table' => 'plugins', |
|
| 220 | + 'column' => 'name', |
|
| 221 | + 'type' => 30, |
|
| 222 | + 'name' => trim($dependency[1]) |
|
| 223 | + ); |
|
| 224 | + break; |
|
| 225 | + case 'resource': |
|
| 226 | + $mdp[] = array( |
|
| 227 | + 'module' => $params['name'], |
|
| 228 | + 'table' => 'content', |
|
| 229 | + 'column' => 'pagetitle', |
|
| 230 | + 'type' => 20, |
|
| 231 | + 'name' => trim($dependency[1]) |
|
| 232 | + ); |
|
| 233 | + break; |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | 238 | $d->close(); |
| 239 | 239 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $params['modx_category'], |
| 37 | 37 | $params['lock_template'], |
| 38 | 38 | array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false, |
| 39 | - isset($params['save_sql_id_as']) ? $params['save_sql_id_as'] : NULL // Nessecary to fix template-ID for demo-site |
|
| 39 | + isset($params['save_sql_id_as']) ? $params['save_sql_id_as'] : null // Nessecary to fix template-ID for demo-site |
|
| 40 | 40 | ); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -1,33 +1,32 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | //:: EVO Installer Setup file |
| 3 | 3 | //::::::::::::::::::::::::::::::::::::::::: |
| 4 | -if (is_file($base_path . 'assets/cache/siteManager.php')) { |
|
| 5 | - include_once($base_path . 'assets/cache/siteManager.php'); |
|
| 4 | +if (is_file($base_path.'assets/cache/siteManager.php')) { |
|
| 5 | + include_once($base_path.'assets/cache/siteManager.php'); |
|
| 6 | 6 | } |
| 7 | -if(!defined('MGR_DIR')) define('MGR_DIR', 'manager'); |
|
| 7 | +if (!defined('MGR_DIR')) define('MGR_DIR', 'manager'); |
|
| 8 | 8 | |
| 9 | 9 | require_once('../'.MGR_DIR.'/includes/version.inc.php'); |
| 10 | 10 | |
| 11 | -$chunkPath = $base_path .'install/assets/chunks'; |
|
| 12 | -$snippetPath = $base_path .'install/assets/snippets'; |
|
| 13 | -$pluginPath = $base_path .'install/assets/plugins'; |
|
| 14 | -$modulePath = $base_path .'install/assets/modules'; |
|
| 15 | -$templatePath = $base_path .'install/assets/templates'; |
|
| 16 | -$tvPath = $base_path .'install/assets/tvs'; |
|
| 11 | +$chunkPath = $base_path.'install/assets/chunks'; |
|
| 12 | +$snippetPath = $base_path.'install/assets/snippets'; |
|
| 13 | +$pluginPath = $base_path.'install/assets/plugins'; |
|
| 14 | +$modulePath = $base_path.'install/assets/modules'; |
|
| 15 | +$templatePath = $base_path.'install/assets/templates'; |
|
| 16 | +$tvPath = $base_path.'install/assets/tvs'; |
|
| 17 | 17 | |
| 18 | 18 | // setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category |
| 19 | 19 | $mt = &$moduleTemplates; |
| 20 | -if(is_dir($templatePath) && is_readable($templatePath)) { |
|
| 20 | +if (is_dir($templatePath) && is_readable($templatePath)) { |
|
| 21 | 21 | $d = dir($templatePath); |
| 22 | 22 | while (false !== ($tplfile = $d->read())) |
| 23 | 23 | { |
| 24 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 24 | + if (substr($tplfile, -4) != '.tpl') continue; |
|
| 25 | 25 | $params = parse_docblock($templatePath, $tplfile); |
| 26 | - if(is_array($params) && (count($params)>0)) |
|
| 26 | + if (is_array($params) && (count($params) > 0)) |
|
| 27 | 27 | { |
| 28 | 28 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 29 | - $mt[] = array |
|
| 30 | - ( |
|
| 29 | + $mt[] = array( |
|
| 31 | 30 | $params['name'], |
| 32 | 31 | $description, |
| 33 | 32 | // Don't think this is gonna be used ... but adding it just in case 'type' |
@@ -45,12 +44,12 @@ discard block |
||
| 45 | 44 | |
| 46 | 45 | // setup Template Variable template files |
| 47 | 46 | $mtv = &$moduleTVs; |
| 48 | -if(is_dir($tvPath) && is_readable($tvPath)) { |
|
| 47 | +if (is_dir($tvPath) && is_readable($tvPath)) { |
|
| 49 | 48 | $d = dir($tvPath); |
| 50 | 49 | while (false !== ($tplfile = $d->read())) { |
| 51 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 50 | + if (substr($tplfile, -4) != '.tpl') continue; |
|
| 52 | 51 | $params = parse_docblock($tvPath, $tplfile); |
| 53 | - if(is_array($params) && (count($params)>0)) { |
|
| 52 | + if (is_array($params) && (count($params) > 0)) { |
|
| 54 | 53 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 55 | 54 | $mtv[] = array( |
| 56 | 55 | $params['name'], |
@@ -62,9 +61,9 @@ discard block |
||
| 62 | 61 | $params['output_widget'], |
| 63 | 62 | $params['output_widget_params'], |
| 64 | 63 | "$templatePath/{$params['filename']}", /* not currently used */ |
| 65 | - $params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(create_function('$v','return $v[0];'),$mt)), /* comma-separated list of template names */ |
|
| 64 | + $params['template_assignments'] != "*" ? $params['template_assignments'] : implode(",", array_map(create_function('$v', 'return $v[0];'), $mt)), /* comma-separated list of template names */ |
|
| 66 | 65 | $params['modx_category'], |
| 67 | - $params['lock_tv'], /* value should be 1 or 0 */ |
|
| 66 | + $params['lock_tv'], /* value should be 1 or 0 */ |
|
| 68 | 67 | array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
| 69 | 68 | ); |
| 70 | 69 | } |
@@ -74,14 +73,14 @@ discard block |
||
| 74 | 73 | |
| 75 | 74 | // setup chunks template files - array : name, description, type - 0:file or 1:content, file or content |
| 76 | 75 | $mc = &$moduleChunks; |
| 77 | -if(is_dir($chunkPath) && is_readable($chunkPath)) { |
|
| 76 | +if (is_dir($chunkPath) && is_readable($chunkPath)) { |
|
| 78 | 77 | $d = dir($chunkPath); |
| 79 | 78 | while (false !== ($tplfile = $d->read())) { |
| 80 | - if(substr($tplfile, -4) != '.tpl') { |
|
| 79 | + if (substr($tplfile, -4) != '.tpl') { |
|
| 81 | 80 | continue; |
| 82 | 81 | } |
| 83 | 82 | $params = parse_docblock($chunkPath, $tplfile); |
| 84 | - if(is_array($params) && count($params) > 0) { |
|
| 83 | + if (is_array($params) && count($params) > 0) { |
|
| 85 | 84 | $mc[] = array( |
| 86 | 85 | $params['name'], |
| 87 | 86 | $params['description'], |
@@ -97,14 +96,14 @@ discard block |
||
| 97 | 96 | |
| 98 | 97 | // setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties |
| 99 | 98 | $ms = &$moduleSnippets; |
| 100 | -if(is_dir($snippetPath) && is_readable($snippetPath)) { |
|
| 99 | +if (is_dir($snippetPath) && is_readable($snippetPath)) { |
|
| 101 | 100 | $d = dir($snippetPath); |
| 102 | 101 | while (false !== ($tplfile = $d->read())) { |
| 103 | - if(substr($tplfile, -4) != '.tpl') { |
|
| 102 | + if (substr($tplfile, -4) != '.tpl') { |
|
| 104 | 103 | continue; |
| 105 | 104 | } |
| 106 | 105 | $params = parse_docblock($snippetPath, $tplfile); |
| 107 | - if(is_array($params) && count($params) > 0) { |
|
| 106 | + if (is_array($params) && count($params) > 0) { |
|
| 108 | 107 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 109 | 108 | $ms[] = array( |
| 110 | 109 | $params['name'], |
@@ -121,14 +120,14 @@ discard block |
||
| 121 | 120 | |
| 122 | 121 | // setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties |
| 123 | 122 | $mp = &$modulePlugins; |
| 124 | -if(is_dir($pluginPath) && is_readable($pluginPath)) { |
|
| 123 | +if (is_dir($pluginPath) && is_readable($pluginPath)) { |
|
| 125 | 124 | $d = dir($pluginPath); |
| 126 | 125 | while (false !== ($tplfile = $d->read())) { |
| 127 | - if(substr($tplfile, -4) != '.tpl') { |
|
| 126 | + if (substr($tplfile, -4) != '.tpl') { |
|
| 128 | 127 | continue; |
| 129 | 128 | } |
| 130 | 129 | $params = parse_docblock($pluginPath, $tplfile); |
| 131 | - if(is_array($params) && count($params) > 0) { |
|
| 130 | + if (is_array($params) && count($params) > 0) { |
|
| 132 | 131 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 133 | 132 | $mp[] = array( |
| 134 | 133 | $params['name'], |
@@ -150,14 +149,14 @@ discard block |
||
| 150 | 149 | // setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams |
| 151 | 150 | $mm = &$moduleModules; |
| 152 | 151 | $mdp = &$moduleDependencies; |
| 153 | -if(is_dir($modulePath) && is_readable($modulePath)) { |
|
| 152 | +if (is_dir($modulePath) && is_readable($modulePath)) { |
|
| 154 | 153 | $d = dir($modulePath); |
| 155 | 154 | while (false !== ($tplfile = $d->read())) { |
| 156 | - if(substr($tplfile, -4) != '.tpl') { |
|
| 155 | + if (substr($tplfile, -4) != '.tpl') { |
|
| 157 | 156 | continue; |
| 158 | 157 | } |
| 159 | 158 | $params = parse_docblock($modulePath, $tplfile); |
| 160 | - if(is_array($params) && count($params) > 0) { |
|
| 159 | + if (is_array($params) && count($params) > 0) { |
|
| 161 | 160 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 162 | 161 | $mm[] = array( |
| 163 | 162 | $params['name'], |
@@ -241,103 +240,103 @@ discard block |
||
| 241 | 240 | // setup callback function |
| 242 | 241 | $callBackFnc = "clean_up"; |
| 243 | 242 | |
| 244 | -function clean_up($sqlParser) { |
|
| 243 | +function clean_up($sqlParser){ |
|
| 245 | 244 | $ids = array(); |
| 246 | 245 | |
| 247 | 246 | // secure web documents - privateweb |
| 248 | - mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1"); |
|
| 249 | - $sql = "SELECT DISTINCT sc.id |
|
| 247 | + mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1"); |
|
| 248 | + $sql = "SELECT DISTINCT sc.id |
|
| 250 | 249 | FROM `".$sqlParser->prefix."site_content` sc |
| 251 | 250 | LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id |
| 252 | 251 | LEFT JOIN `".$sqlParser->prefix."webgroup_access` wga ON wga.documentgroup = dg.document_group |
| 253 | 252 | WHERE wga.id>0"; |
| 254 | - $ds = mysqli_query($sqlParser->conn,$sql); |
|
| 255 | - if(!$ds) { |
|
| 253 | + $ds = mysqli_query($sqlParser->conn, $sql); |
|
| 254 | + if (!$ds) { |
|
| 256 | 255 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 257 | 256 | } |
| 258 | 257 | else { |
| 259 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 260 | - if(count($ids)>0) { |
|
| 261 | - mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")"); |
|
| 258 | + while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"]; |
|
| 259 | + if (count($ids) > 0) { |
|
| 260 | + mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ", $ids).")"); |
|
| 262 | 261 | unset($ids); |
| 263 | 262 | } |
| 264 | 263 | } |
| 265 | 264 | |
| 266 | 265 | // secure manager documents privatemgr |
| 267 | - mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1"); |
|
| 268 | - $sql = "SELECT DISTINCT sc.id |
|
| 266 | + mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1"); |
|
| 267 | + $sql = "SELECT DISTINCT sc.id |
|
| 269 | 268 | FROM `".$sqlParser->prefix."site_content` sc |
| 270 | 269 | LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id |
| 271 | 270 | LEFT JOIN `".$sqlParser->prefix."membergroup_access` mga ON mga.documentgroup = dg.document_group |
| 272 | 271 | WHERE mga.id>0"; |
| 273 | - $ds = mysqli_query($sqlParser->conn,$sql); |
|
| 274 | - if(!$ds) { |
|
| 272 | + $ds = mysqli_query($sqlParser->conn, $sql); |
|
| 273 | + if (!$ds) { |
|
| 275 | 274 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 276 | 275 | } |
| 277 | 276 | else { |
| 278 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 279 | - if(count($ids)>0) { |
|
| 280 | - mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); |
|
| 277 | + while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"]; |
|
| 278 | + if (count($ids) > 0) { |
|
| 279 | + mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ", $ids).")"); |
|
| 281 | 280 | unset($ids); |
| 282 | 281 | } |
| 283 | 282 | } |
| 284 | 283 | } |
| 285 | 284 | |
| 286 | -function parse_docblock($element_dir, $filename) { |
|
| 285 | +function parse_docblock($element_dir, $filename){ |
|
| 287 | 286 | $params = array(); |
| 288 | - $fullpath = $element_dir . '/' . $filename; |
|
| 289 | - if(is_readable($fullpath)) { |
|
| 287 | + $fullpath = $element_dir.'/'.$filename; |
|
| 288 | + if (is_readable($fullpath)) { |
|
| 290 | 289 | $tpl = @fopen($fullpath, "r"); |
| 291 | - if($tpl) { |
|
| 290 | + if ($tpl) { |
|
| 292 | 291 | $params['filename'] = $filename; |
| 293 | 292 | $docblock_start_found = false; |
| 294 | 293 | $name_found = false; |
| 295 | 294 | $description_found = false; |
| 296 | 295 | |
| 297 | - while(!feof($tpl)) { |
|
| 296 | + while (!feof($tpl)) { |
|
| 298 | 297 | $line = fgets($tpl); |
| 299 | - if(!$docblock_start_found) { |
|
| 298 | + if (!$docblock_start_found) { |
|
| 300 | 299 | // find docblock start |
| 301 | - if(strpos($line, '/**') !== false) { |
|
| 300 | + if (strpos($line, '/**') !== false) { |
|
| 302 | 301 | $docblock_start_found = true; |
| 303 | 302 | } |
| 304 | 303 | continue; |
| 305 | - } elseif(!$name_found) { |
|
| 304 | + } elseif (!$name_found) { |
|
| 306 | 305 | // find name |
| 307 | 306 | $ma = null; |
| 308 | - if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) { |
|
| 307 | + if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) { |
|
| 309 | 308 | $params['name'] = trim($ma[1]); |
| 310 | 309 | $name_found = !empty($params['name']); |
| 311 | 310 | } |
| 312 | 311 | continue; |
| 313 | - } elseif(!$description_found) { |
|
| 312 | + } elseif (!$description_found) { |
|
| 314 | 313 | // find description |
| 315 | 314 | $ma = null; |
| 316 | - if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) { |
|
| 315 | + if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) { |
|
| 317 | 316 | $params['description'] = trim($ma[1]); |
| 318 | 317 | $description_found = !empty($params['description']); |
| 319 | 318 | } |
| 320 | 319 | continue; |
| 321 | 320 | } else { |
| 322 | 321 | $ma = null; |
| 323 | - if(preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) { |
|
| 322 | + if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) { |
|
| 324 | 323 | $param = trim($ma[1]); |
| 325 | 324 | $val = trim($ma[2]); |
| 326 | - if(!empty($param) && !empty($val)) { |
|
| 327 | - if($param == 'internal') { |
|
| 325 | + if (!empty($param) && !empty($val)) { |
|
| 326 | + if ($param == 'internal') { |
|
| 328 | 327 | $ma = null; |
| 329 | - if(preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) { |
|
| 328 | + if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) { |
|
| 330 | 329 | $param = trim($ma[1]); |
| 331 | 330 | $val = trim($ma[2]); |
| 332 | 331 | } |
| 333 | 332 | //if($val !== '0' && (empty($param) || empty($val))) { |
| 334 | - if(empty($param)) { |
|
| 333 | + if (empty($param)) { |
|
| 335 | 334 | continue; |
| 336 | 335 | } |
| 337 | 336 | } |
| 338 | 337 | $params[$param] = $val; |
| 339 | 338 | } |
| 340 | - } elseif(preg_match("/^\s*\*\/\s*$/", $line)) { |
|
| 339 | + } elseif (preg_match("/^\s*\*\/\s*$/", $line)) { |
|
| 341 | 340 | break; |
| 342 | 341 | } |
| 343 | 342 | } |
@@ -4,7 +4,9 @@ discard block |
||
| 4 | 4 | if (is_file($base_path . 'assets/cache/siteManager.php')) { |
| 5 | 5 | include_once($base_path . 'assets/cache/siteManager.php'); |
| 6 | 6 | } |
| 7 | -if(!defined('MGR_DIR')) define('MGR_DIR', 'manager'); |
|
| 7 | +if(!defined('MGR_DIR')) { |
|
| 8 | + define('MGR_DIR', 'manager'); |
|
| 9 | +} |
|
| 8 | 10 | |
| 9 | 11 | require_once('../'.MGR_DIR.'/includes/version.inc.php'); |
| 10 | 12 | |
@@ -19,12 +21,12 @@ discard block |
||
| 19 | 21 | $mt = &$moduleTemplates; |
| 20 | 22 | if(is_dir($templatePath) && is_readable($templatePath)) { |
| 21 | 23 | $d = dir($templatePath); |
| 22 | - while (false !== ($tplfile = $d->read())) |
|
| 23 | - { |
|
| 24 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 24 | + while (false !== ($tplfile = $d->read())) { |
|
| 25 | + if(substr($tplfile, -4) != '.tpl') { |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 25 | 28 | $params = parse_docblock($templatePath, $tplfile); |
| 26 | - if(is_array($params) && (count($params)>0)) |
|
| 27 | - { |
|
| 29 | + if(is_array($params) && (count($params)>0)) { |
|
| 28 | 30 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 29 | 31 | $mt[] = array |
| 30 | 32 | ( |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | if(is_dir($tvPath) && is_readable($tvPath)) { |
| 49 | 51 | $d = dir($tvPath); |
| 50 | 52 | while (false !== ($tplfile = $d->read())) { |
| 51 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 53 | + if(substr($tplfile, -4) != '.tpl') { |
|
| 54 | + continue; |
|
| 55 | + } |
|
| 52 | 56 | $params = parse_docblock($tvPath, $tplfile); |
| 53 | 57 | if(is_array($params) && (count($params)>0)) { |
| 54 | 58 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
@@ -241,7 +245,8 @@ discard block |
||
| 241 | 245 | // setup callback function |
| 242 | 246 | $callBackFnc = "clean_up"; |
| 243 | 247 | |
| 244 | -function clean_up($sqlParser) { |
|
| 248 | +function clean_up($sqlParser) |
|
| 249 | +{ |
|
| 245 | 250 | $ids = array(); |
| 246 | 251 | |
| 247 | 252 | // secure web documents - privateweb |
@@ -254,9 +259,10 @@ discard block |
||
| 254 | 259 | $ds = mysqli_query($sqlParser->conn,$sql); |
| 255 | 260 | if(!$ds) { |
| 256 | 261 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 257 | - } |
|
| 258 | - else { |
|
| 259 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 262 | + } else { |
|
| 263 | + while($r = mysqli_fetch_assoc($ds)) { |
|
| 264 | + $ids[]=$r["id"]; |
|
| 265 | + } |
|
| 260 | 266 | if(count($ids)>0) { |
| 261 | 267 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")"); |
| 262 | 268 | unset($ids); |
@@ -273,9 +279,10 @@ discard block |
||
| 273 | 279 | $ds = mysqli_query($sqlParser->conn,$sql); |
| 274 | 280 | if(!$ds) { |
| 275 | 281 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 276 | - } |
|
| 277 | - else { |
|
| 278 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 282 | + } else { |
|
| 283 | + while($r = mysqli_fetch_assoc($ds)) { |
|
| 284 | + $ids[]=$r["id"]; |
|
| 285 | + } |
|
| 279 | 286 | if(count($ids)>0) { |
| 280 | 287 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); |
| 281 | 288 | unset($ids); |
@@ -283,7 +290,8 @@ discard block |
||
| 283 | 290 | } |
| 284 | 291 | } |
| 285 | 292 | |
| 286 | -function parse_docblock($element_dir, $filename) { |
|
| 293 | +function parse_docblock($element_dir, $filename) |
|
| 294 | +{ |
|
| 287 | 295 | $params = array(); |
| 288 | 296 | $fullpath = $element_dir . '/' . $filename; |
| 289 | 297 | if(is_readable($fullpath)) { |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | <form name="install" id="install_form" action="index.php?action=options" method="post"> |
| 21 | 21 | <?php |
| 22 | 22 | if ($errors == 0) { |
| 23 | - // check if install folder is removeable |
|
| 23 | + // check if install folder is removeable |
|
| 24 | 24 | if (is_writable("../install")) { ?> |
| 25 | 25 | <span id="removeinstall" style="float:left;cursor:pointer;color:#505050;line-height:18px;" onclick="var chk=document.install.rminstaller; if(chk) chk.checked=!chk.checked;"><input type="checkbox" name="rminstaller" onclick="event.cancelBubble=true;" <?php echo (empty ($errors) ? 'checked="checked"' : '') ?> style="cursor:default;" /><?php echo $_lang['remove_install_folder_auto'] ?></span> |
| 26 | 26 | <?php |
@@ -43,10 +43,10 @@ |
||
| 43 | 43 | var chk = document.install.rminstaller; |
| 44 | 44 | if(chk && chk.checked) { |
| 45 | 45 | // remove install folder and files |
| 46 | - window.location.href = "../<?php echo MGR_DIR;?>/processors/remove_installer.processor.php?rminstall=1"; |
|
| 46 | + window.location.href = "../<?php echo MGR_DIR; ?>/processors/remove_installer.processor.php?rminstall=1"; |
|
| 47 | 47 | } |
| 48 | 48 | else { |
| 49 | - window.location.href = "../<?php echo MGR_DIR;?>/"; |
|
| 49 | + window.location.href = "../<?php echo MGR_DIR; ?>/"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | /* ]]> */ |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | $self = 'install/connection.databasetest.php'; |
| 9 | 9 | $base_path = str_replace($self,'',str_replace('\\','/', __FILE__)); |
| 10 | 10 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 11 | - include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 11 | + include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 12 | 12 | } |
| 13 | 13 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
| 14 | - define('MGR_DIR','manager'); |
|
| 14 | + define('MGR_DIR','manager'); |
|
| 15 | 15 | } |
| 16 | 16 | require_once("lang.php"); |
| 17 | 17 | |
@@ -6,12 +6,12 @@ discard block |
||
| 6 | 6 | $installMode = $_POST['installMode']; |
| 7 | 7 | |
| 8 | 8 | $self = 'install/connection.databasetest.php'; |
| 9 | -$base_path = str_replace($self,'',str_replace('\\','/', __FILE__)); |
|
| 9 | +$base_path = str_replace($self, '', str_replace('\\', '/', __FILE__)); |
|
| 10 | 10 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 11 | 11 | include_once("{$base_path}assets/cache/siteManager.php"); |
| 12 | 12 | } |
| 13 | -if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
|
| 14 | - define('MGR_DIR','manager'); |
|
| 13 | +if (!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
|
| 14 | + define('MGR_DIR', 'manager'); |
|
| 15 | 15 | } |
| 16 | 16 | require_once("lang.php"); |
| 17 | 17 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 32 | 32 | $query = "CREATE DATABASE `".$database_name."` CHARACTER SET ".$database_charset." COLLATE ".$database_collation.";"; |
| 33 | 33 | |
| 34 | - if (! mysqli_query($conn, $query)){ |
|
| 34 | + if (!mysqli_query($conn, $query)) { |
|
| 35 | 35 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_could_not_create_database'].'</span>'; |
| 36 | 36 | } |
| 37 | 37 | else { |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | $output = $_lang["status_checking_database"]; |
| 19 | 19 | if (!$conn = mysqli_connect($host, $uid, $pwd)) { |
| 20 | 20 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed'].'</span>'; |
| 21 | -} |
|
| 22 | -else { |
|
| 21 | +} else { |
|
| 23 | 22 | $database_name = mysqli_real_escape_string($conn, $_POST['database_name']); |
| 24 | 23 | $database_name = str_replace("`", "", $database_name); |
| 25 | 24 | $tableprefix = mysqli_real_escape_string($conn, $_POST['tableprefix']); |
@@ -31,20 +30,16 @@ discard block |
||
| 31 | 30 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 32 | 31 | $query = "CREATE DATABASE `".$database_name."` CHARACTER SET ".$database_charset." COLLATE ".$database_collation.";"; |
| 33 | 32 | |
| 34 | - if (! mysqli_query($conn, $query)){ |
|
| 33 | + if (! mysqli_query($conn, $query)) { |
|
| 35 | 34 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_could_not_create_database'].'</span>'; |
| 36 | - } |
|
| 37 | - else { |
|
| 35 | + } else { |
|
| 38 | 36 | $output .= '<span id="database_pass" style="color:#80c000;">'.$_lang['status_passed_database_created'].'</span>'; |
| 39 | 37 | } |
| 40 | - } |
|
| 41 | - elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { |
|
| 38 | + } elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { |
|
| 42 | 39 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_table_prefix_already_in_use'].'</span>'; |
| 43 | - } |
|
| 44 | - elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { |
|
| 40 | + } elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { |
|
| 45 | 41 | $output .= '<span id="database_fail" style="color:#FF0000;">'.sprintf($_lang['status_failed_database_collation_does_not_match'], $row[1]).'</span>'; |
| 46 | - } |
|
| 47 | - else { |
|
| 42 | + } else { |
|
| 48 | 43 | $output .= '<span id="database_pass" style="color:#80c000;">'.$_lang['status_passed'].'</span>'; |
| 49 | 44 | } |
| 50 | 45 | } |
@@ -16,10 +16,10 @@ |
||
| 16 | 16 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); |
| 17 | 17 | |
| 18 | 18 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 19 | - include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 19 | + include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 20 | 20 | } |
| 21 | 21 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
| 22 | - define('MGR_DIR', 'manager'); |
|
| 22 | + define('MGR_DIR', 'manager'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | $self = 'install/index.php'; |
| 12 | -$base_path = str_replace($self,'',str_replace('\\','/', __FILE__)); |
|
| 12 | +$base_path = str_replace($self, '', str_replace('\\', '/', __FILE__)); |
|
| 13 | 13 | require_once("{$base_path}install/functions.php"); |
| 14 | 14 | |
| 15 | 15 | // set error reporting |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 19 | 19 | include_once("{$base_path}assets/cache/siteManager.php"); |
| 20 | 20 | } |
| 21 | -if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
|
| 21 | +if (!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
|
| 22 | 22 | define('MGR_DIR', 'manager'); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -38,26 +38,26 @@ discard block |
||
| 38 | 38 | $moduleSQLDataFile = "setup.data.sql"; |
| 39 | 39 | $moduleSQLResetFile = "setup.data.reset.sql"; |
| 40 | 40 | |
| 41 | -$moduleChunks = array (); // chunks - array : name, description, type - 0:file or 1:content, file or content |
|
| 42 | -$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content |
|
| 43 | -$moduleSnippets = array (); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties |
|
| 44 | -$modulePlugins = array (); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid |
|
| 45 | -$moduleModules = array (); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid |
|
| 46 | -$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content,properties |
|
| 47 | -$moduleTVs = array (); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties |
|
| 41 | +$moduleChunks = array(); // chunks - array : name, description, type - 0:file or 1:content, file or content |
|
| 42 | +$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content |
|
| 43 | +$moduleSnippets = array(); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties |
|
| 44 | +$modulePlugins = array(); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid |
|
| 45 | +$moduleModules = array(); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid |
|
| 46 | +$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content,properties |
|
| 47 | +$moduleTVs = array(); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties |
|
| 48 | 48 | $moduleDependencies = array(); // module depedencies - array : module, table, column, type, name |
| 49 | 49 | |
| 50 | -$errors= 0; |
|
| 50 | +$errors = 0; |
|
| 51 | 51 | |
| 52 | 52 | // get post back status |
| 53 | 53 | $isPostBack = (count($_POST)); |
| 54 | 54 | |
| 55 | 55 | $ph = ph(); |
| 56 | -$ph = array_merge($ph,$_lang); |
|
| 56 | +$ph = array_merge($ph, $_lang); |
|
| 57 | 57 | $ph['install_language'] = $install_language; |
| 58 | 58 | |
| 59 | 59 | ob_start(); |
| 60 | -$action= isset ($_GET['action']) ? trim(strip_tags($_GET['action'])) : 'language'; |
|
| 60 | +$action = isset ($_GET['action']) ? trim(strip_tags($_GET['action'])) : 'language'; |
|
| 61 | 61 | if (!@include_once("actions/action_{$action}.php")) { |
| 62 | 62 | die ("Invalid install action attempted. [action={$action}]"); |
| 63 | 63 | } |
@@ -65,5 +65,5 @@ discard block |
||
| 65 | 65 | ob_end_clean(); |
| 66 | 66 | |
| 67 | 67 | $tpl = file_get_contents("{$base_path}install/template.tpl"); |
| 68 | -echo parse($tpl,$ph); |
|
| 68 | +echo parse($tpl, $ph); |
|
| 69 | 69 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // write $somecontent to our opened file. |
| 241 | -if (@ fwrite($handle, $configString) === FALSE) { |
|
| 241 | +if (@ fwrite($handle, $configString) === false) { |
|
| 242 | 242 | $configFileFailed = true; |
| 243 | 243 | } |
| 244 | 244 | @ fclose($handle); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"); |
| 327 | 327 | |
| 328 | 328 | if (mysqli_num_rows($rs)) { |
| 329 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
| 329 | + if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
| 330 | 330 | $errors += 1; |
| 331 | 331 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 332 | 332 | return; |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | if (mysqli_num_rows($rs)) { |
| 383 | 383 | $insert = true; |
| 384 | 384 | while($row = mysqli_fetch_assoc($rs)) { |
| 385 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) { |
|
| 385 | + if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) { |
|
| 386 | 386 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 387 | 387 | return; |
| 388 | 388 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | $update = $count_original_name > 0 && $overwrite == 'true'; |
| 460 | 460 | if ($update) { |
| 461 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 461 | + if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 462 | 462 | $errors += 1; |
| 463 | 463 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 464 | 464 | return; |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | if (mysqli_num_rows($rs)) { |
| 509 | 509 | $row = mysqli_fetch_assoc($rs); |
| 510 | 510 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 511 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 511 | + if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 512 | 512 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 513 | 513 | return; |
| 514 | 514 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | // disable legacy versions based on legacy_names provided |
| 554 | 554 | if(!empty($leg_names)) { |
| 555 | - $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 555 | + $update_query = "update $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 556 | 556 | $rs = mysqli_query($sqlParser->conn, $update_query); |
| 557 | 557 | } |
| 558 | 558 | |
@@ -568,13 +568,13 @@ discard block |
||
| 568 | 568 | while($row = mysqli_fetch_assoc($rs)) { |
| 569 | 569 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 570 | 570 | if($row['description'] == $desc){ |
| 571 | - if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 571 | + if (! mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 572 | 572 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 573 | 573 | return; |
| 574 | 574 | } |
| 575 | 575 | $insert = false; |
| 576 | 576 | } else { |
| 577 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 577 | + if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 578 | 578 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 579 | 579 | return; |
| 580 | 580 | } |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | if (mysqli_num_rows($rs)) { |
| 640 | 640 | $row = mysqli_fetch_assoc($rs); |
| 641 | 641 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 642 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 642 | + if (!mysqli_query($sqlParser->conn, "update $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 643 | 643 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 644 | 644 | return; |
| 645 | 645 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 86 | 86 | $create = true; |
| 87 | 87 | } else { |
| 88 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 88 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 89 | 89 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
| 90 | 90 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 91 | 91 | } |
@@ -280,23 +280,23 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | // Reset database for installation of demo-site |
| 282 | 282 | if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
| 283 | - echo "<p>" . $_lang['resetting_database']; |
|
| 284 | - $sqlParser->process($moduleSQLResetFile); |
|
| 285 | - // display database results |
|
| 286 | - if ($sqlParser->installFailed == true) { |
|
| 287 | - $errors += 1; |
|
| 288 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 289 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 290 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 291 | - for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
|
| 292 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 293 | - } |
|
| 294 | - echo "</p>"; |
|
| 295 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 296 | - return; |
|
| 297 | - } else { |
|
| 298 | - echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
|
| 299 | - } |
|
| 283 | + echo "<p>" . $_lang['resetting_database']; |
|
| 284 | + $sqlParser->process($moduleSQLResetFile); |
|
| 285 | + // display database results |
|
| 286 | + if ($sqlParser->installFailed == true) { |
|
| 287 | + $errors += 1; |
|
| 288 | + echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 289 | + echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 290 | + echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 291 | + for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
|
| 292 | + echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 293 | + } |
|
| 294 | + echo "</p>"; |
|
| 295 | + echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 296 | + return; |
|
| 297 | + } else { |
|
| 298 | + echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
|
| 299 | + } |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Install Templates |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $tRow = mysqli_fetch_assoc($ts); |
| 419 | 419 | $templateId = $tRow['id']; |
| 420 | 420 | mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
| 421 | - } |
|
| 421 | + } |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -687,51 +687,51 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | // Install Dependencies |
| 689 | 689 | foreach ($moduleDependencies as $dependency) { |
| 690 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
| 691 | - if (!$ds) { |
|
| 692 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 693 | - return; |
|
| 694 | - } else { |
|
| 695 | - $row = mysqli_fetch_assoc($ds); |
|
| 696 | - $moduleId = $row["id"]; |
|
| 697 | - $moduleGuid = $row["guid"]; |
|
| 698 | - } |
|
| 699 | - // get extra id |
|
| 700 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
| 701 | - if (!$ds) { |
|
| 702 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 703 | - return; |
|
| 704 | - } else { |
|
| 705 | - $row = mysqli_fetch_assoc($ds); |
|
| 706 | - $extraId = $row["id"]; |
|
| 707 | - } |
|
| 708 | - // setup extra as module dependency |
|
| 709 | - $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1'); |
|
| 710 | - if (!$ds) { |
|
| 711 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 712 | - return; |
|
| 713 | - } else { |
|
| 714 | - if (mysqli_num_rows($ds) === 0) { |
|
| 715 | - mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
| 716 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>'; |
|
| 717 | - } else { |
|
| 718 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']); |
|
| 719 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>'; |
|
| 720 | - } |
|
| 721 | - if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
|
| 722 | - // set extra guid for plugins and snippets |
|
| 723 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
| 724 | - if (!$ds) { |
|
| 725 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 726 | - return; |
|
| 727 | - } else { |
|
| 728 | - if (mysqli_num_rows($ds) != 0) { |
|
| 729 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
| 730 | - echo '<p> ' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>'; |
|
| 731 | - } |
|
| 732 | - } |
|
| 733 | - } |
|
| 734 | - } |
|
| 690 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
| 691 | + if (!$ds) { |
|
| 692 | + echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 693 | + return; |
|
| 694 | + } else { |
|
| 695 | + $row = mysqli_fetch_assoc($ds); |
|
| 696 | + $moduleId = $row["id"]; |
|
| 697 | + $moduleGuid = $row["guid"]; |
|
| 698 | + } |
|
| 699 | + // get extra id |
|
| 700 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
| 701 | + if (!$ds) { |
|
| 702 | + echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 703 | + return; |
|
| 704 | + } else { |
|
| 705 | + $row = mysqli_fetch_assoc($ds); |
|
| 706 | + $extraId = $row["id"]; |
|
| 707 | + } |
|
| 708 | + // setup extra as module dependency |
|
| 709 | + $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1'); |
|
| 710 | + if (!$ds) { |
|
| 711 | + echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 712 | + return; |
|
| 713 | + } else { |
|
| 714 | + if (mysqli_num_rows($ds) === 0) { |
|
| 715 | + mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
| 716 | + echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>'; |
|
| 717 | + } else { |
|
| 718 | + mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']); |
|
| 719 | + echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>'; |
|
| 720 | + } |
|
| 721 | + if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
|
| 722 | + // set extra guid for plugins and snippets |
|
| 723 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
| 724 | + if (!$ds) { |
|
| 725 | + echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 726 | + return; |
|
| 727 | + } else { |
|
| 728 | + if (mysqli_num_rows($ds) != 0) { |
|
| 729 | + mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
| 730 | + echo '<p> ' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>'; |
|
| 731 | + } |
|
| 732 | + } |
|
| 733 | + } |
|
| 734 | + } |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | // call back function |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
| 3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
| 4 | -}else{ |
|
| 4 | +} else { |
|
| 5 | 5 | define('MGR_DIR', 'manager'); |
| 6 | 6 | } |
| 7 | 7 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | echo "<p>{$_lang['setup_database']}</p>\n"; |
| 30 | 30 | |
| 31 | -$installMode= intval($_POST['installmode']); |
|
| 31 | +$installMode = intval($_POST['installmode']); |
|
| 32 | 32 | $installData = $_POST['installdata'] == "1" ? 1 : 0; |
| 33 | 33 | |
| 34 | 34 | //if ($installMode == 1) { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 43 | 43 | $database_connection_charset = $_POST['database_connection_charset']; |
| 44 | 44 | $database_connection_method = $_POST['database_connection_method']; |
| 45 | -$dbase = "`" . $_POST['database_name'] . "`"; |
|
| 45 | +$dbase = "`".$_POST['database_name']."`"; |
|
| 46 | 46 | $table_prefix = $_POST['tableprefix']; |
| 47 | 47 | $adminname = $_POST['cmsadmin']; |
| 48 | 48 | $adminemail = $_POST['cmsadminemail']; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | // set session name variable |
| 55 | 55 | if (!isset ($site_sessionname)) { |
| 56 | - $site_sessionname = 'SN' . uniqid(''); |
|
| 56 | + $site_sessionname = 'SN'.uniqid(''); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // get base path and url |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | array_pop($a); |
| 68 | 68 | $pth = implode("install", $a); |
| 69 | 69 | unset ($a); |
| 70 | -$base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
|
| 71 | -$base_path = $pth . (substr($pth, -1) != "/" ? "/" : ""); |
|
| 70 | +$base_url = $url.(substr($url, -1) != "/" ? "/" : ""); |
|
| 71 | +$base_path = $pth.(substr($pth, -1) != "/" ? "/" : ""); |
|
| 72 | 72 | |
| 73 | 73 | // connect to the database |
| 74 | -echo "<p>". $_lang['setup_database_create_connection']; |
|
| 74 | +echo "<p>".$_lang['setup_database_create_connection']; |
|
| 75 | 75 | if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
| 76 | 76 | echo '<span class="notok">'.$_lang["setup_database_create_connection_failed"]."</span></p><p>".$_lang['setup_database_create_connection_failed_note']."</p>"; |
| 77 | 77 | return; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // select database |
| 83 | -echo "<p>".$_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: "; |
|
| 83 | +echo "<p>".$_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: "; |
|
| 84 | 84 | if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) { |
| 85 | 85 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 86 | 86 | $create = true; |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // try to create the database |
| 94 | 94 | if ($create) { |
| 95 | - echo "<p>".$_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: "; |
|
| 95 | + echo "<p>".$_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: "; |
|
| 96 | 96 | // if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) { |
| 97 | - if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
| 97 | + if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
| 98 | 98 | echo '<span class="notok">'.$_lang['setup_database_creation_failed']."</span>".$_lang['setup_database_creation_failed_note']."</p>"; |
| 99 | 99 | $errors += 1; |
| 100 | 100 | ?> |
@@ -113,33 +113,33 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | // check table prefix |
| 115 | 115 | if ($installMode == 0) { |
| 116 | - echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: "; |
|
| 117 | - if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { |
|
| 118 | - echo '<span class="notok">' . $_lang['failed'] . "</span>" . $_lang['table_prefix_already_inuse'] . "</p>"; |
|
| 116 | + echo "<p>".$_lang['checking_table_prefix'].$table_prefix."`: "; |
|
| 117 | + if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) { |
|
| 118 | + echo '<span class="notok">'.$_lang['failed']."</span>".$_lang['table_prefix_already_inuse']."</p>"; |
|
| 119 | 119 | $errors += 1; |
| 120 | - echo "<p>" . $_lang['table_prefix_already_inuse_note'] . "</p>"; |
|
| 120 | + echo "<p>".$_lang['table_prefix_already_inuse_note']."</p>"; |
|
| 121 | 121 | return; |
| 122 | 122 | } else { |
| 123 | 123 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | -if(!function_exists('parseProperties')) { |
|
| 127 | +if (!function_exists('parseProperties')) { |
|
| 128 | 128 | // parses a resource property string and returns the result as an array |
| 129 | 129 | // duplicate of method in documentParser class |
| 130 | - function parseProperties($propertyString) { |
|
| 131 | - $parameter= array (); |
|
| 130 | + function parseProperties($propertyString){ |
|
| 131 | + $parameter = array(); |
|
| 132 | 132 | if (!empty ($propertyString)) { |
| 133 | - $tmpParams= explode("&", $propertyString); |
|
| 134 | - for ($x= 0; $x < count($tmpParams); $x++) { |
|
| 133 | + $tmpParams = explode("&", $propertyString); |
|
| 134 | + for ($x = 0; $x < count($tmpParams); $x++) { |
|
| 135 | 135 | if (strpos($tmpParams[$x], '=', 0)) { |
| 136 | - $pTmp= explode("=", $tmpParams[$x]); |
|
| 137 | - $pvTmp= explode(";", trim($pTmp[1])); |
|
| 136 | + $pTmp = explode("=", $tmpParams[$x]); |
|
| 137 | + $pvTmp = explode(";", trim($pTmp[1])); |
|
| 138 | 138 | if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
| 139 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 139 | + $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default |
|
| 140 | 140 | else |
| 141 | 141 | if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
| 142 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 142 | + $parameter[trim($pTmp[0])] = $pvTmp[2]; |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -150,20 +150,20 @@ discard block |
||
| 150 | 150 | // check status of Inherit Parent Template plugin |
| 151 | 151 | $auto_template_logic = 'parent'; |
| 152 | 152 | if ($installMode != 0) { |
| 153 | - $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'"); |
|
| 153 | + $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'"); |
|
| 154 | 154 | $row = mysqli_fetch_row($rs); |
| 155 | - if(!$row) { |
|
| 155 | + if (!$row) { |
|
| 156 | 156 | // not installed |
| 157 | 157 | $auto_template_logic = 'system'; |
| 158 | 158 | } else { |
| 159 | - if($row[1] == 1) { |
|
| 159 | + if ($row[1] == 1) { |
|
| 160 | 160 | // installed but disabled |
| 161 | 161 | $auto_template_logic = 'system'; |
| 162 | 162 | } else { |
| 163 | 163 | // installed, enabled .. see how it's configured |
| 164 | 164 | $properties = parseProperties($row[0]); |
| 165 | - if(isset($properties['inheritTemplate'])) { |
|
| 166 | - if($properties['inheritTemplate'] == 'From First Sibling') { |
|
| 165 | + if (isset($properties['inheritTemplate'])) { |
|
| 166 | + if ($properties['inheritTemplate'] == 'From First Sibling') { |
|
| 167 | 167 | $auto_template_logic = 'sibling'; |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -187,20 +187,20 @@ discard block |
||
| 187 | 187 | $sqlParser->connect(); |
| 188 | 188 | |
| 189 | 189 | // install/update database |
| 190 | -echo "<p>" . $_lang['setup_database_creating_tables']; |
|
| 190 | +echo "<p>".$_lang['setup_database_creating_tables']; |
|
| 191 | 191 | if ($moduleSQLBaseFile) { |
| 192 | 192 | $sqlParser->process($moduleSQLBaseFile); |
| 193 | 193 | // display database results |
| 194 | 194 | if ($sqlParser->installFailed == true) { |
| 195 | 195 | $errors += 1; |
| 196 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 197 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 198 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 196 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 197 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 198 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 199 | 199 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 200 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 200 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 201 | 201 | } |
| 202 | 202 | echo "</p>"; |
| 203 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 203 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 204 | 204 | return; |
| 205 | 205 | } else { |
| 206 | 206 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | // custom or not |
| 211 | 211 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 212 | 212 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 213 | -}else{ |
|
| 213 | +} else { |
|
| 214 | 214 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // write the config.inc.php file if new installation |
| 218 | -echo "<p>" . $_lang['writing_config_file']; |
|
| 218 | +echo "<p>".$_lang['writing_config_file']; |
|
| 219 | 219 | |
| 220 | 220 | $confph = array(); |
| 221 | 221 | $confph['database_server'] = $database_server; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $chmodSuccess = @chmod($filename, 0404); |
| 248 | 248 | |
| 249 | 249 | if ($configFileFailed == true) { |
| 250 | - echo '<span class="notok">' . $_lang['failed'] . "</span></p>"; |
|
| 250 | + echo '<span class="notok">'.$_lang['failed']."</span></p>"; |
|
| 251 | 251 | $errors += 1; |
| 252 | 252 | ?> |
| 253 | 253 | <p><?php echo $_lang['cant_write_config_file']?><span class="mono"><?php echo MGR_DIR; ?>/includes/config.inc.php</span></p> |
@@ -264,35 +264,35 @@ discard block |
||
| 264 | 264 | // generate new site_id and set manager theme to default |
| 265 | 265 | if ($installMode == 0) { |
| 266 | 266 | $siteid = uniqid(''); |
| 267 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
| 267 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
| 268 | 268 | } else { |
| 269 | 269 | // update site_id if missing |
| 270 | - $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'"); |
|
| 270 | + $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'"); |
|
| 271 | 271 | if ($ds) { |
| 272 | 272 | $r = mysqli_fetch_assoc($ds); |
| 273 | 273 | $siteid = $r['setting_value']; |
| 274 | 274 | if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') { |
| 275 | 275 | $siteid = uniqid(''); |
| 276 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
| 276 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // Reset database for installation of demo-site |
| 282 | 282 | if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
| 283 | - echo "<p>" . $_lang['resetting_database']; |
|
| 283 | + echo "<p>".$_lang['resetting_database']; |
|
| 284 | 284 | $sqlParser->process($moduleSQLResetFile); |
| 285 | 285 | // display database results |
| 286 | 286 | if ($sqlParser->installFailed == true) { |
| 287 | 287 | $errors += 1; |
| 288 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 289 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 290 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 288 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 289 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 290 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 291 | 291 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 292 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 292 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 293 | 293 | } |
| 294 | 294 | echo "</p>"; |
| 295 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 295 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 296 | 296 | return; |
| 297 | 297 | } else { |
| 298 | 298 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | // Install Templates |
| 303 | 303 | if (isset ($_POST['template']) || $installData) { |
| 304 | - echo "<h3>" . $_lang['templates'] . ":</h3> "; |
|
| 304 | + echo "<h3>".$_lang['templates'].":</h3> "; |
|
| 305 | 305 | $selTemplates = $_POST['template']; |
| 306 | 306 | foreach ($moduleTemplates as $k=>$moduleTemplate) { |
| 307 | 307 | $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1; |
| 308 | - if($installSample || in_array($k, $selTemplates)) { |
|
| 308 | + if ($installSample || in_array($k, $selTemplates)) { |
|
| 309 | 309 | $name = mysqli_real_escape_string($conn, $moduleTemplate[0]); |
| 310 | 310 | $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]); |
| 311 | 311 | $category = mysqli_real_escape_string($conn, $moduleTemplate[4]); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $filecontent = $moduleTemplate[3]; |
| 314 | 314 | $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site |
| 315 | 315 | if (!file_exists($filecontent)) { |
| 316 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 316 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 317 | 317 | } else { |
| 318 | 318 | // Create the category if it does not already exist |
| 319 | 319 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -323,31 +323,31 @@ discard block |
||
| 323 | 323 | $template = mysqli_real_escape_string($conn, $template); |
| 324 | 324 | |
| 325 | 325 | // See if the template already exists |
| 326 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"); |
|
| 326 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'"); |
|
| 327 | 327 | |
| 328 | 328 | if (mysqli_num_rows($rs)) { |
| 329 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
| 329 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked' WHERE templatename='$name' LIMIT 1;")) { |
|
| 330 | 330 | $errors += 1; |
| 331 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 331 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 332 | 332 | return; |
| 333 | 333 | } |
| 334 | - if(!is_null($save_sql_id_as)) { |
|
| 334 | + if (!is_null($save_sql_id_as)) { |
|
| 335 | 335 | $sql_id = @mysqli_insert_id($sqlParser->conn); |
| 336 | - if(!$sql_id) { |
|
| 337 | - $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
| 336 | + if (!$sql_id) { |
|
| 337 | + $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
| 338 | 338 | $sql_id = $idQuery['id']; |
| 339 | 339 | } |
| 340 | 340 | $custom_placeholders[$save_sql_id_as] = $sql_id; |
| 341 | 341 | } |
| 342 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 342 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 343 | 343 | } else { |
| 344 | - if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
| 344 | + if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
| 345 | 345 | $errors += 1; |
| 346 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 346 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 347 | 347 | return; |
| 348 | 348 | } |
| 349 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 350 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 349 | + if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 350 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | } |
@@ -356,11 +356,11 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | // Install Template Variables |
| 358 | 358 | if (isset ($_POST['tv']) || $installData) { |
| 359 | - echo "<h3>" . $_lang['tvs'] . ":</h3> "; |
|
| 359 | + echo "<h3>".$_lang['tvs'].":</h3> "; |
|
| 360 | 360 | $selTVs = $_POST['tv']; |
| 361 | 361 | foreach ($moduleTVs as $k=>$moduleTV) { |
| 362 | 362 | $installSample = in_array('sample', $moduleTV[12]) && $installData == 1; |
| 363 | - if($installSample || in_array($k, $selTVs)) { |
|
| 363 | + if ($installSample || in_array($k, $selTVs)) { |
|
| 364 | 364 | $name = mysqli_real_escape_string($conn, $moduleTV[0]); |
| 365 | 365 | $caption = mysqli_real_escape_string($conn, $moduleTV[1]); |
| 366 | 366 | $desc = mysqli_real_escape_string($conn, $moduleTV[2]); |
@@ -378,25 +378,25 @@ discard block |
||
| 378 | 378 | // Create the category if it does not already exist |
| 379 | 379 | $category = getCreateDbCategory($category, $sqlParser); |
| 380 | 380 | |
| 381 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'"); |
|
| 381 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'"); |
|
| 382 | 382 | if (mysqli_num_rows($rs)) { |
| 383 | 383 | $insert = true; |
| 384 | - while($row = mysqli_fetch_assoc($rs)) { |
|
| 385 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) { |
|
| 386 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 384 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
| 385 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) { |
|
| 386 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 387 | 387 | return; |
| 388 | 388 | } |
| 389 | 389 | $insert = false; |
| 390 | 390 | } |
| 391 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 391 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 392 | 392 | } else { |
| 393 | 393 | //$q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',(SELECT (CASE COUNT(*) WHEN 0 THEN 0 ELSE `id` END) `id` FROM $dbase.`" . $table_prefix . "categories` WHERE `category` = '$category'),$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
| 394 | - $q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
|
| 394 | + $q = "INSERT INTO $dbase.`".$table_prefix."site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
|
| 395 | 395 | if (!mysqli_query($sqlParser->conn, $q)) { |
| 396 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 396 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 397 | 397 | return; |
| 398 | 398 | } |
| 399 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 399 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | // add template assignments |
@@ -405,10 +405,10 @@ discard block |
||
| 405 | 405 | if (count($assignments) > 0) { |
| 406 | 406 | |
| 407 | 407 | // remove existing tv -> template assignments |
| 408 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 408 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 409 | 409 | $row = mysqli_fetch_assoc($ds); |
| 410 | 410 | $id = $row["id"]; |
| 411 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
| 411 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\''); |
|
| 412 | 412 | |
| 413 | 413 | // add tv -> template assignments |
| 414 | 414 | foreach ($assignments as $assignment) { |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if ($ds && $ts) { |
| 418 | 418 | $tRow = mysqli_fetch_assoc($ts); |
| 419 | 419 | $templateId = $tRow['id']; |
| 420 | - mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 420 | + mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | } |
@@ -427,12 +427,12 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | // Install Chunks |
| 429 | 429 | if (isset ($_POST['chunk']) || $installData) { |
| 430 | - echo "<h3>" . $_lang['chunks'] . ":</h3> "; |
|
| 430 | + echo "<h3>".$_lang['chunks'].":</h3> "; |
|
| 431 | 431 | $selChunks = $_POST['chunk']; |
| 432 | 432 | foreach ($moduleChunks as $k=>$moduleChunk) { |
| 433 | 433 | $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; |
| 434 | 434 | $count_new_name = 0; |
| 435 | - if($installSample || in_array($k, $selChunks)) { |
|
| 435 | + if ($installSample || in_array($k, $selChunks)) { |
|
| 436 | 436 | |
| 437 | 437 | $name = mysqli_real_escape_string($conn, $moduleChunk[0]); |
| 438 | 438 | $desc = mysqli_real_escape_string($conn, $moduleChunk[1]); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $filecontent = $moduleChunk[2]; |
| 442 | 442 | |
| 443 | 443 | if (!file_exists($filecontent)) |
| 444 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 444 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 445 | 445 | else { |
| 446 | 446 | |
| 447 | 447 | // Create the category if it does not already exist |
@@ -449,31 +449,31 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
| 451 | 451 | $chunk = mysqli_real_escape_string($conn, $chunk); |
| 452 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'"); |
|
| 452 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'"); |
|
| 453 | 453 | $count_original_name = mysqli_num_rows($rs); |
| 454 | - if($overwrite == 'false') { |
|
| 455 | - $newname = $name . '-' . str_replace('.', '_', $modx_version); |
|
| 456 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'"); |
|
| 454 | + if ($overwrite == 'false') { |
|
| 455 | + $newname = $name.'-'.str_replace('.', '_', $modx_version); |
|
| 456 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'"); |
|
| 457 | 457 | $count_new_name = mysqli_num_rows($rs); |
| 458 | 458 | } |
| 459 | 459 | $update = $count_original_name > 0 && $overwrite == 'true'; |
| 460 | 460 | if ($update) { |
| 461 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 461 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 462 | 462 | $errors += 1; |
| 463 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 463 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 464 | 464 | return; |
| 465 | 465 | } |
| 466 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 467 | - } elseif($count_new_name == 0) { |
|
| 468 | - if($count_original_name > 0 && $overwrite == 'false') { |
|
| 466 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 467 | + } elseif ($count_new_name == 0) { |
|
| 468 | + if ($count_original_name > 0 && $overwrite == 'false') { |
|
| 469 | 469 | $name = $newname; |
| 470 | 470 | } |
| 471 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
| 471 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
| 472 | 472 | $errors += 1; |
| 473 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 473 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 474 | 474 | return; |
| 475 | 475 | } |
| 476 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 476 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | } |
@@ -482,11 +482,11 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | // Install Modules |
| 484 | 484 | if (isset ($_POST['module']) || $installData) { |
| 485 | - echo "<h3>" . $_lang['modules'] . ":</h3> "; |
|
| 485 | + echo "<h3>".$_lang['modules'].":</h3> "; |
|
| 486 | 486 | $selModules = $_POST['module']; |
| 487 | 487 | foreach ($moduleModules as $k=>$moduleModule) { |
| 488 | 488 | $installSample = in_array('sample', $moduleModule[7]) && $installData == 1; |
| 489 | - if($installSample || in_array($k, $selModules)) { |
|
| 489 | + if ($installSample || in_array($k, $selModules)) { |
|
| 490 | 490 | $name = mysqli_real_escape_string($conn, $moduleModule[0]); |
| 491 | 491 | $desc = mysqli_real_escape_string($conn, $moduleModule[1]); |
| 492 | 492 | $filecontent = $moduleModule[2]; |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 496 | 496 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 497 | 497 | if (!file_exists($filecontent)) |
| 498 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 498 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 499 | 499 | else { |
| 500 | 500 | |
| 501 | 501 | // Create the category if it does not already exist |
@@ -504,22 +504,22 @@ discard block |
||
| 504 | 504 | $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 505 | 505 | // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
| 506 | 506 | $module = mysqli_real_escape_string($conn, $module); |
| 507 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
|
| 507 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'"); |
|
| 508 | 508 | if (mysqli_num_rows($rs)) { |
| 509 | 509 | $row = mysqli_fetch_assoc($rs); |
| 510 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 511 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 512 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 510 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 511 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 512 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 513 | 513 | return; |
| 514 | 514 | } |
| 515 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 515 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 516 | 516 | } else { |
| 517 | 517 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 518 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
|
| 519 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 518 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
|
| 519 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 520 | 520 | return; |
| 521 | 521 | } |
| 522 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 522 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | } |
@@ -528,11 +528,11 @@ discard block |
||
| 528 | 528 | |
| 529 | 529 | // Install Plugins |
| 530 | 530 | if (isset ($_POST['plugin']) || $installData) { |
| 531 | - echo "<h3>" . $_lang['plugins'] . ":</h3> "; |
|
| 531 | + echo "<h3>".$_lang['plugins'].":</h3> "; |
|
| 532 | 532 | $selPlugs = $_POST['plugin']; |
| 533 | 533 | foreach ($modulePlugins as $k=>$modulePlugin) { |
| 534 | 534 | $installSample = in_array('sample', $modulePlugin[8]) && $installData == 1; |
| 535 | - if($installSample || in_array($k, $selPlugs)) { |
|
| 535 | + if ($installSample || in_array($k, $selPlugs)) { |
|
| 536 | 536 | $name = mysqli_real_escape_string($conn, $modulePlugin[0]); |
| 537 | 537 | $desc = mysqli_real_escape_string($conn, $modulePlugin[1]); |
| 538 | 538 | $filecontent = $modulePlugin[2]; |
@@ -542,17 +542,17 @@ discard block |
||
| 542 | 542 | $category = mysqli_real_escape_string($conn, $modulePlugin[6]); |
| 543 | 543 | $leg_names = ''; |
| 544 | 544 | $disabled = $modulePlugin[9]; |
| 545 | - if(array_key_exists(7, $modulePlugin)) { |
|
| 545 | + if (array_key_exists(7, $modulePlugin)) { |
|
| 546 | 546 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 547 | - $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
|
| 547 | + $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'"; |
|
| 548 | 548 | } |
| 549 | 549 | if (!file_exists($filecontent)) |
| 550 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 550 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 551 | 551 | else { |
| 552 | 552 | |
| 553 | 553 | // disable legacy versions based on legacy_names provided |
| 554 | - if(!empty($leg_names)) { |
|
| 555 | - $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 554 | + if (!empty($leg_names)) { |
|
| 555 | + $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 556 | 556 | $rs = mysqli_query($sqlParser->conn, $update_query); |
| 557 | 557 | } |
| 558 | 558 | |
@@ -562,50 +562,50 @@ discard block |
||
| 562 | 562 | $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 563 | 563 | $plugin = removeDocblock($plugin, 'plugin'); |
| 564 | 564 | $plugin = mysqli_real_escape_string($conn, $plugin); |
| 565 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'"); |
|
| 565 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'"); |
|
| 566 | 566 | if (mysqli_num_rows($rs)) { |
| 567 | 567 | $insert = true; |
| 568 | - while($row = mysqli_fetch_assoc($rs)) { |
|
| 569 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 570 | - if($row['description'] == $desc){ |
|
| 571 | - if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 572 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 568 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
| 569 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 570 | + if ($row['description'] == $desc) { |
|
| 571 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 572 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 573 | 573 | return; |
| 574 | 574 | } |
| 575 | 575 | $insert = false; |
| 576 | 576 | } else { |
| 577 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 577 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 578 | 578 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 579 | 579 | return; |
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | - if($insert === true) { |
|
| 584 | - $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 585 | - if(!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) { |
|
| 583 | + if ($insert === true) { |
|
| 584 | + $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 585 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) { |
|
| 586 | 586 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 587 | 587 | return; |
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 590 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 591 | 591 | } else { |
| 592 | 592 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 593 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) { |
|
| 594 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 593 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) { |
|
| 594 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 595 | 595 | return; |
| 596 | 596 | } |
| 597 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 597 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 598 | 598 | } |
| 599 | 599 | // add system events |
| 600 | 600 | if (count($events) > 0) { |
| 601 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
| 601 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
| 602 | 602 | if ($ds) { |
| 603 | 603 | $row = mysqli_fetch_assoc($ds); |
| 604 | 604 | $id = $row["id"]; |
| 605 | 605 | // remove existing events |
| 606 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\''); |
|
| 606 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\''); |
|
| 607 | 607 | // add new events |
| 608 | - mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('" . implode("','", $events) . "')"); |
|
| 608 | + mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`".$table_prefix."system_eventnames` se WHERE name IN ('".implode("','", $events)."')"); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | } |
@@ -615,18 +615,18 @@ discard block |
||
| 615 | 615 | |
| 616 | 616 | // Install Snippets |
| 617 | 617 | if (isset ($_POST['snippet']) || $installData) { |
| 618 | - echo "<h3>" . $_lang['snippets'] . ":</h3> "; |
|
| 618 | + echo "<h3>".$_lang['snippets'].":</h3> "; |
|
| 619 | 619 | $selSnips = $_POST['snippet']; |
| 620 | 620 | foreach ($moduleSnippets as $k=>$moduleSnippet) { |
| 621 | 621 | $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; |
| 622 | - if($installSample || in_array($k, $selSnips)) { |
|
| 622 | + if ($installSample || in_array($k, $selSnips)) { |
|
| 623 | 623 | $name = mysqli_real_escape_string($conn, $moduleSnippet[0]); |
| 624 | 624 | $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]); |
| 625 | 625 | $filecontent = $moduleSnippet[2]; |
| 626 | 626 | $properties = $moduleSnippet[3]; |
| 627 | 627 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 628 | 628 | if (!file_exists($filecontent)) |
| 629 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 629 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 630 | 630 | else { |
| 631 | 631 | |
| 632 | 632 | // Create the category if it does not already exist |
@@ -635,22 +635,22 @@ discard block |
||
| 635 | 635 | $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
| 636 | 636 | $snippet = removeDocblock($snippet, 'snippet'); |
| 637 | 637 | $snippet = mysqli_real_escape_string($conn, $snippet); |
| 638 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
|
| 638 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'"); |
|
| 639 | 639 | if (mysqli_num_rows($rs)) { |
| 640 | 640 | $row = mysqli_fetch_assoc($rs); |
| 641 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 642 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 643 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 641 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 642 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 643 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 644 | 644 | return; |
| 645 | 645 | } |
| 646 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 646 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 647 | 647 | } else { |
| 648 | 648 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 649 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
| 650 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 649 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
| 650 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 651 | 651 | return; |
| 652 | 652 | } |
| 653 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 653 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | } |
@@ -659,24 +659,24 @@ discard block |
||
| 659 | 659 | |
| 660 | 660 | // Install demo-site |
| 661 | 661 | if ($installData && $moduleSQLDataFile) { |
| 662 | - echo "<p>" . $_lang['installing_demo_site']; |
|
| 662 | + echo "<p>".$_lang['installing_demo_site']; |
|
| 663 | 663 | $sqlParser->process($moduleSQLDataFile); |
| 664 | 664 | // display database results |
| 665 | 665 | if ($sqlParser->installFailed == true) { |
| 666 | 666 | $errors += 1; |
| 667 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 668 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 669 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 667 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 668 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 669 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 670 | 670 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 671 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 671 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 672 | 672 | } |
| 673 | 673 | echo "</p>"; |
| 674 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 674 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 675 | 675 | return; |
| 676 | 676 | } else { |
| 677 | 677 | $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix); |
| 678 | 678 | $rs = mysqli_query($sqlParser->conn, $sql); |
| 679 | - if(mysqli_num_rows($rs)) { |
|
| 679 | + if (mysqli_num_rows($rs)) { |
|
| 680 | 680 | $row = mysqli_fetch_assoc($rs); |
| 681 | 681 | $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']); |
| 682 | 682 | mysqli_query($sqlParser->conn, $sql); |
@@ -687,9 +687,9 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | // Install Dependencies |
| 689 | 689 | foreach ($moduleDependencies as $dependency) { |
| 690 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
| 690 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"'); |
|
| 691 | 691 | if (!$ds) { |
| 692 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 692 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 693 | 693 | return; |
| 694 | 694 | } else { |
| 695 | 695 | $row = mysqli_fetch_assoc($ds); |
@@ -697,37 +697,37 @@ discard block |
||
| 697 | 697 | $moduleGuid = $row["guid"]; |
| 698 | 698 | } |
| 699 | 699 | // get extra id |
| 700 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
| 700 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"'); |
|
| 701 | 701 | if (!$ds) { |
| 702 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 702 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 703 | 703 | return; |
| 704 | 704 | } else { |
| 705 | 705 | $row = mysqli_fetch_assoc($ds); |
| 706 | 706 | $extraId = $row["id"]; |
| 707 | 707 | } |
| 708 | 708 | // setup extra as module dependency |
| 709 | - $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1'); |
|
| 709 | + $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type'].' LIMIT 1'); |
|
| 710 | 710 | if (!$ds) { |
| 711 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 711 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 712 | 712 | return; |
| 713 | 713 | } else { |
| 714 | 714 | if (mysqli_num_rows($ds) === 0) { |
| 715 | - mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
| 716 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>'; |
|
| 715 | + mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')'); |
|
| 716 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_create'].'</span></p>'; |
|
| 717 | 717 | } else { |
| 718 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']); |
|
| 719 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>'; |
|
| 718 | + mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` SET module = '.$moduleId.', resource = '.$extraId.', type = '.$dependency['type'].' WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type']); |
|
| 719 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_update'].'</span></p>'; |
|
| 720 | 720 | } |
| 721 | 721 | if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
| 722 | 722 | // set extra guid for plugins and snippets |
| 723 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
| 723 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1'); |
|
| 724 | 724 | if (!$ds) { |
| 725 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 725 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 726 | 726 | return; |
| 727 | 727 | } else { |
| 728 | 728 | if (mysqli_num_rows($ds) != 0) { |
| 729 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
| 730 | - echo '<p> ' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>'; |
|
| 729 | + mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId); |
|
| 730 | + echo '<p> '.$dependency['name'].': <span class="ok">'.$_lang['guid_set'].'</span></p>'; |
|
| 731 | 731 | } |
| 732 | 732 | } |
| 733 | 733 | } |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | // call back function |
| 738 | 738 | if ($callBackFnc != "") |
| 739 | - $callBackFnc ($sqlParser); |
|
| 739 | + $callBackFnc($sqlParser); |
|
| 740 | 740 | |
| 741 | 741 | // Setup the MODX API -- needed for the cache processor |
| 742 | 742 | define('MODX_API_MODE', true); |
@@ -771,20 +771,20 @@ discard block |
||
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | // setup completed! |
| 774 | -echo "<p><b>" . $_lang['installation_successful'] . "</b></p>"; |
|
| 775 | -echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>"; |
|
| 774 | +echo "<p><b>".$_lang['installation_successful']."</b></p>"; |
|
| 775 | +echo "<p>".$_lang['to_log_into_content_manager']."</p>"; |
|
| 776 | 776 | if ($installMode == 0) { |
| 777 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['installation_note'] . "</p>"; |
|
| 777 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['installation_note']."</p>"; |
|
| 778 | 778 | } else { |
| 779 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['upgrade_note'] . "</p>"; |
|
| 779 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['upgrade_note']."</p>"; |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | // Property Update function |
| 783 | -function propUpdate($new,$old){ |
|
| 783 | +function propUpdate($new, $old){ |
|
| 784 | 784 | $newArr = parseProperties($new); |
| 785 | 785 | $oldArr = parseProperties($old); |
| 786 | - foreach ($oldArr as $k => $v){ |
|
| 787 | - if (isset($v['0']['options'])){ |
|
| 786 | + foreach ($oldArr as $k => $v) { |
|
| 787 | + if (isset($v['0']['options'])) { |
|
| 788 | 788 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 789 | 789 | } |
| 790 | 790 | } |
@@ -794,30 +794,30 @@ discard block |
||
| 794 | 794 | return $return; |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | -function parseProperties($propertyString, $json=false) { |
|
| 798 | - $propertyString = str_replace('{}', '', $propertyString ); |
|
| 799 | - $propertyString = str_replace('} {', ',', $propertyString ); |
|
| 797 | +function parseProperties($propertyString, $json = false){ |
|
| 798 | + $propertyString = str_replace('{}', '', $propertyString); |
|
| 799 | + $propertyString = str_replace('} {', ',', $propertyString); |
|
| 800 | 800 | |
| 801 | - if(empty($propertyString)) return array(); |
|
| 802 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 801 | + if (empty($propertyString)) return array(); |
|
| 802 | + if ($propertyString == '{}' || $propertyString == '[]') return array(); |
|
| 803 | 803 | |
| 804 | 804 | $jsonFormat = isJson($propertyString, true); |
| 805 | 805 | $property = array(); |
| 806 | 806 | // old format |
| 807 | - if ( $jsonFormat === false) { |
|
| 808 | - $props= explode('&', $propertyString); |
|
| 807 | + if ($jsonFormat === false) { |
|
| 808 | + $props = explode('&', $propertyString); |
|
| 809 | 809 | foreach ($props as $prop) { |
| 810 | 810 | $prop = trim($prop); |
| 811 | - if($prop === '') { |
|
| 811 | + if ($prop === '') { |
|
| 812 | 812 | continue; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | $arr = explode(';', $prop); |
| 816 | - if( ! is_array($arr)) { |
|
| 816 | + if (!is_array($arr)) { |
|
| 817 | 817 | $arr = array(); |
| 818 | 818 | } |
| 819 | 819 | $key = explode('=', isset($arr[0]) ? $arr[0] : ''); |
| 820 | - if( ! is_array($key) || empty($key[0])) { |
|
| 820 | + if (!is_array($key) || empty($key[0])) { |
|
| 821 | 821 | continue; |
| 822 | 822 | } |
| 823 | 823 | |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | } |
| 843 | 843 | // new json-format |
| 844 | - } else if(!empty($jsonFormat)){ |
|
| 844 | + } else if (!empty($jsonFormat)) { |
|
| 845 | 845 | $property = $jsonFormat; |
| 846 | 846 | } |
| 847 | 847 | if ($json) { |
@@ -851,25 +851,25 @@ discard block |
||
| 851 | 851 | return $property; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | -function isJson($string, $returnData=false) { |
|
| 854 | +function isJson($string, $returnData = false){ |
|
| 855 | 855 | $data = json_decode($string, true); |
| 856 | 856 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 859 | +function getCreateDbCategory($category, $sqlParser){ |
|
| 860 | 860 | $dbase = $sqlParser->dbname; |
| 861 | - $dbase = '`' . trim($dbase,'`') . '`'; |
|
| 861 | + $dbase = '`'.trim($dbase, '`').'`'; |
|
| 862 | 862 | $table_prefix = $sqlParser->prefix; |
| 863 | 863 | $category_id = 0; |
| 864 | - if(!empty($category)) { |
|
| 864 | + if (!empty($category)) { |
|
| 865 | 865 | $category = mysqli_real_escape_string($sqlParser->conn, $category); |
| 866 | 866 | $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'"); |
| 867 | - if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
| 867 | + if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
| 868 | 868 | $category_id = $row['id']; |
| 869 | 869 | } else { |
| 870 | 870 | $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');"; |
| 871 | 871 | $rs = mysqli_query($sqlParser->conn, $q); |
| 872 | - if($rs) { |
|
| 872 | + if ($rs) { |
|
| 873 | 873 | $category_id = mysqli_insert_id($sqlParser->conn); |
| 874 | 874 | } |
| 875 | 875 | } |
@@ -878,12 +878,12 @@ discard block |
||
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | // Remove installer Docblock only from components using plugin FileSource / fileBinding |
| 881 | -function removeDocblock($code, $type) { |
|
| 881 | +function removeDocblock($code, $type){ |
|
| 882 | 882 | |
| 883 | 883 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 884 | 884 | |
| 885 | 885 | // Procedure taken from plugin.filesource.php |
| 886 | - switch($type) { |
|
| 886 | + switch ($type) { |
|
| 887 | 887 | case 'snippet': |
| 888 | 888 | $elm_name = 'snippets'; |
| 889 | 889 | $include = 'return require'; |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | default: |
| 900 | 900 | return $cleaned; |
| 901 | 901 | }; |
| 902 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 902 | + if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 903 | 903 | return $cleaned; |
| 904 | 904 | |
| 905 | 905 | // fileBinding not found - return code incl docblock |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
| 3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
| 4 | -}else{ |
|
| 4 | +} else { |
|
| 5 | 5 | define('MGR_DIR', 'manager'); |
| 6 | 6 | } |
| 7 | 7 | |
@@ -58,13 +58,15 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // get base path and url |
| 60 | 60 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
| 61 | -if (count($a) > 1) |
|
| 61 | +if (count($a) > 1) { |
|
| 62 | 62 | array_pop($a); |
| 63 | +} |
|
| 63 | 64 | $url = implode("install", $a); |
| 64 | 65 | reset($a); |
| 65 | 66 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
| 66 | -if (count($a) > 1) |
|
| 67 | +if (count($a) > 1) { |
|
| 67 | 68 | array_pop($a); |
| 69 | +} |
|
| 68 | 70 | $pth = implode("install", $a); |
| 69 | 71 | unset ($a); |
| 70 | 72 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 86 | 88 | $create = true; |
| 87 | 89 | } else { |
| 88 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 90 | + if (function_exists('mysqli_set_charset')) { |
|
| 91 | + mysqli_set_charset($conn, $database_charset); |
|
| 92 | + } |
|
| 89 | 93 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
| 90 | 94 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 91 | 95 | } |
@@ -127,7 +131,8 @@ discard block |
||
| 127 | 131 | if(!function_exists('parseProperties')) { |
| 128 | 132 | // parses a resource property string and returns the result as an array |
| 129 | 133 | // duplicate of method in documentParser class |
| 130 | - function parseProperties($propertyString) { |
|
| 134 | + function parseProperties($propertyString) |
|
| 135 | + { |
|
| 131 | 136 | $parameter= array (); |
| 132 | 137 | if (!empty ($propertyString)) { |
| 133 | 138 | $tmpParams= explode("&", $propertyString); |
@@ -135,11 +140,14 @@ discard block |
||
| 135 | 140 | if (strpos($tmpParams[$x], '=', 0)) { |
| 136 | 141 | $pTmp= explode("=", $tmpParams[$x]); |
| 137 | 142 | $pvTmp= explode(";", trim($pTmp[1])); |
| 138 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
| 139 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 143 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
| 144 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
| 145 | + } |
|
| 146 | + //list default |
|
| 140 | 147 | else |
| 141 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
| 142 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 148 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
| 149 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | } |
| 145 | 153 | } |
@@ -210,7 +218,7 @@ discard block |
||
| 210 | 218 | // custom or not |
| 211 | 219 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 212 | 220 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 213 | -}else{ |
|
| 221 | +} else { |
|
| 214 | 222 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 215 | 223 | } |
| 216 | 224 | |
@@ -346,7 +354,9 @@ discard block |
||
| 346 | 354 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 347 | 355 | return; |
| 348 | 356 | } |
| 349 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 357 | + if(!is_null($save_sql_id_as)) { |
|
| 358 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 359 | + } |
|
| 350 | 360 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
| 351 | 361 | } |
| 352 | 362 | } |
@@ -440,9 +450,9 @@ discard block |
||
| 440 | 450 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
| 441 | 451 | $filecontent = $moduleChunk[2]; |
| 442 | 452 | |
| 443 | - if (!file_exists($filecontent)) |
|
| 444 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 445 | - else { |
|
| 453 | + if (!file_exists($filecontent)) { |
|
| 454 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 455 | + } else { |
|
| 446 | 456 | |
| 447 | 457 | // Create the category if it does not already exist |
| 448 | 458 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -494,9 +504,9 @@ discard block |
||
| 494 | 504 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
| 495 | 505 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 496 | 506 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 497 | - if (!file_exists($filecontent)) |
|
| 498 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 499 | - else { |
|
| 507 | + if (!file_exists($filecontent)) { |
|
| 508 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 509 | + } else { |
|
| 500 | 510 | |
| 501 | 511 | // Create the category if it does not already exist |
| 502 | 512 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -546,9 +556,9 @@ discard block |
||
| 546 | 556 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 547 | 557 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
| 548 | 558 | } |
| 549 | - if (!file_exists($filecontent)) |
|
| 550 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 551 | - else { |
|
| 559 | + if (!file_exists($filecontent)) { |
|
| 560 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 561 | + } else { |
|
| 552 | 562 | |
| 553 | 563 | // disable legacy versions based on legacy_names provided |
| 554 | 564 | if(!empty($leg_names)) { |
@@ -567,7 +577,7 @@ discard block |
||
| 567 | 577 | $insert = true; |
| 568 | 578 | while($row = mysqli_fetch_assoc($rs)) { |
| 569 | 579 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 570 | - if($row['description'] == $desc){ |
|
| 580 | + if($row['description'] == $desc) { |
|
| 571 | 581 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
| 572 | 582 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 573 | 583 | return; |
@@ -625,9 +635,9 @@ discard block |
||
| 625 | 635 | $filecontent = $moduleSnippet[2]; |
| 626 | 636 | $properties = $moduleSnippet[3]; |
| 627 | 637 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 628 | - if (!file_exists($filecontent)) |
|
| 629 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 630 | - else { |
|
| 638 | + if (!file_exists($filecontent)) { |
|
| 639 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 640 | + } else { |
|
| 631 | 641 | |
| 632 | 642 | // Create the category if it does not already exist |
| 633 | 643 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -735,13 +745,16 @@ discard block |
||
| 735 | 745 | } |
| 736 | 746 | |
| 737 | 747 | // call back function |
| 738 | -if ($callBackFnc != "") |
|
| 748 | +if ($callBackFnc != "") { |
|
| 739 | 749 | $callBackFnc ($sqlParser); |
| 750 | +} |
|
| 740 | 751 | |
| 741 | 752 | // Setup the MODX API -- needed for the cache processor |
| 742 | 753 | define('MODX_API_MODE', true); |
| 743 | 754 | define('MODX_BASE_PATH', $base_path); |
| 744 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 755 | +if (!defined('MODX_MANAGER_PATH')) { |
|
| 756 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 757 | +} |
|
| 745 | 758 | $database_type = 'mysqli'; |
| 746 | 759 | // initiate a new document parser |
| 747 | 760 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -780,11 +793,12 @@ discard block |
||
| 780 | 793 | } |
| 781 | 794 | |
| 782 | 795 | // Property Update function |
| 783 | -function propUpdate($new,$old){ |
|
| 796 | +function propUpdate($new,$old) |
|
| 797 | +{ |
|
| 784 | 798 | $newArr = parseProperties($new); |
| 785 | 799 | $oldArr = parseProperties($old); |
| 786 | - foreach ($oldArr as $k => $v){ |
|
| 787 | - if (isset($v['0']['options'])){ |
|
| 800 | + foreach ($oldArr as $k => $v) { |
|
| 801 | + if (isset($v['0']['options'])) { |
|
| 788 | 802 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 789 | 803 | } |
| 790 | 804 | } |
@@ -794,12 +808,17 @@ discard block |
||
| 794 | 808 | return $return; |
| 795 | 809 | } |
| 796 | 810 | |
| 797 | -function parseProperties($propertyString, $json=false) { |
|
| 811 | +function parseProperties($propertyString, $json=false) |
|
| 812 | +{ |
|
| 798 | 813 | $propertyString = str_replace('{}', '', $propertyString ); |
| 799 | 814 | $propertyString = str_replace('} {', ',', $propertyString ); |
| 800 | 815 | |
| 801 | - if(empty($propertyString)) return array(); |
|
| 802 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 816 | + if(empty($propertyString)) { |
|
| 817 | + return array(); |
|
| 818 | + } |
|
| 819 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
| 820 | + return array(); |
|
| 821 | + } |
|
| 803 | 822 | |
| 804 | 823 | $jsonFormat = isJson($propertyString, true); |
| 805 | 824 | $property = array(); |
@@ -841,7 +860,7 @@ discard block |
||
| 841 | 860 | |
| 842 | 861 | } |
| 843 | 862 | // new json-format |
| 844 | - } else if(!empty($jsonFormat)){ |
|
| 863 | + } else if(!empty($jsonFormat)) { |
|
| 845 | 864 | $property = $jsonFormat; |
| 846 | 865 | } |
| 847 | 866 | if ($json) { |
@@ -851,12 +870,14 @@ discard block |
||
| 851 | 870 | return $property; |
| 852 | 871 | } |
| 853 | 872 | |
| 854 | -function isJson($string, $returnData=false) { |
|
| 873 | +function isJson($string, $returnData=false) |
|
| 874 | +{ |
|
| 855 | 875 | $data = json_decode($string, true); |
| 856 | 876 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 857 | 877 | } |
| 858 | 878 | |
| 859 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 879 | +function getCreateDbCategory($category, $sqlParser) |
|
| 880 | +{ |
|
| 860 | 881 | $dbase = $sqlParser->dbname; |
| 861 | 882 | $dbase = '`' . trim($dbase,'`') . '`'; |
| 862 | 883 | $table_prefix = $sqlParser->prefix; |
@@ -878,7 +899,8 @@ discard block |
||
| 878 | 899 | } |
| 879 | 900 | |
| 880 | 901 | // Remove installer Docblock only from components using plugin FileSource / fileBinding |
| 881 | -function removeDocblock($code, $type) { |
|
| 902 | +function removeDocblock($code, $type) |
|
| 903 | +{ |
|
| 882 | 904 | |
| 883 | 905 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 884 | 906 | |
@@ -899,8 +921,9 @@ discard block |
||
| 899 | 921 | default: |
| 900 | 922 | return $cleaned; |
| 901 | 923 | }; |
| 902 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 903 | - return $cleaned; |
|
| 924 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
| 925 | + return $cleaned; |
|
| 926 | + } |
|
| 904 | 927 | |
| 905 | 928 | // fileBinding not found - return code incl docblock |
| 906 | 929 | return $code; |
@@ -478,7 +478,8 @@ discard block |
||
| 478 | 478 | return s; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - <?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 481 | + <?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { |
|
| 482 | +// Web Link specific ?> |
|
| 482 | 483 | var lastImageCtrl; |
| 483 | 484 | var lastFileCtrl; |
| 484 | 485 | |
@@ -694,7 +695,8 @@ discard block |
||
| 694 | 695 | </td> |
| 695 | 696 | </tr> |
| 696 | 697 | |
| 697 | - <?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 698 | + <?php if($content['type'] == 'reference' || $modx->manager->action == '72') { |
|
| 699 | +// Web Link specific ?> |
|
| 698 | 700 | |
| 699 | 701 | <tr> |
| 700 | 702 | <td><span class="warning"><?= $_lang['weblink'] ?></span> |
@@ -1356,7 +1358,9 @@ discard block |
||
| 1356 | 1358 | if($documentId > 0) { |
| 1357 | 1359 | // Load up, the permissions from the parent (if new document) or existing document |
| 1358 | 1360 | $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
| 1359 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1361 | + while($currentgroup = $modx->db->getRow($rs)) { |
|
| 1362 | + $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1363 | + } |
|
| 1360 | 1364 | |
| 1361 | 1365 | // Load up the current permissions and names |
| 1362 | 1366 | $vs = array( |
@@ -1418,7 +1422,9 @@ discard block |
||
| 1418 | 1422 | |
| 1419 | 1423 | // Create attribute string list |
| 1420 | 1424 | $inputString = array(); |
| 1421 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1425 | + foreach($inputAttributes as $k => $v) { |
|
| 1426 | + $inputString[] = $k . '="' . $v . '"'; |
|
| 1427 | + } |
|
| 1422 | 1428 | |
| 1423 | 1429 | // Make the <input> HTML |
| 1424 | 1430 | $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
@@ -1535,7 +1541,8 @@ discard block |
||
| 1535 | 1541 | } |
| 1536 | 1542 | } |
| 1537 | 1543 | |
| 1538 | -function getDefaultTemplate() { |
|
| 1544 | +function getDefaultTemplate() |
|
| 1545 | +{ |
|
| 1539 | 1546 | global $modx; |
| 1540 | 1547 | |
| 1541 | 1548 | switch($modx->config['auto_template_logic']) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /********************/ |
@@ -12,30 +12,30 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // check permissions |
| 14 | 14 | switch($modx->manager->action) { |
| 15 | - case 27: |
|
| 16 | - if(!$modx->hasPermission('edit_document')) { |
|
| 17 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 18 | - } |
|
| 19 | - break; |
|
| 20 | - case 85: |
|
| 21 | - case 72: |
|
| 22 | - case 4: |
|
| 23 | - if(!$modx->hasPermission('new_document')) { |
|
| 24 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 25 | - } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 26 | - // check user has permissions for parent |
|
| 27 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 28 | - $udperms = new udperms(); |
|
| 29 | - $udperms->user = $modx->getLoginUserID(); |
|
| 30 | - $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
|
| 31 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 32 | - if(!$udperms->checkPermissions()) { |
|
| 33 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - break; |
|
| 37 | - default: |
|
| 38 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 15 | + case 27: |
|
| 16 | + if(!$modx->hasPermission('edit_document')) { |
|
| 17 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 18 | + } |
|
| 19 | + break; |
|
| 20 | + case 85: |
|
| 21 | + case 72: |
|
| 22 | + case 4: |
|
| 23 | + if(!$modx->hasPermission('new_document')) { |
|
| 24 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 25 | + } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 26 | + // check user has permissions for parent |
|
| 27 | + include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 28 | + $udperms = new udperms(); |
|
| 29 | + $udperms->user = $modx->getLoginUserID(); |
|
| 30 | + $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
|
| 31 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 32 | + if(!$udperms->checkPermissions()) { |
|
| 33 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + break; |
|
| 37 | + default: |
|
| 38 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; |
@@ -54,22 +54,22 @@ discard block |
||
| 54 | 54 | $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars'); |
| 55 | 55 | |
| 56 | 56 | if($modx->manager->action == 27) { |
| 57 | - //editing an existing document |
|
| 58 | - // check permissions on the document |
|
| 59 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 60 | - $udperms = new udperms(); |
|
| 61 | - $udperms->user = $modx->getLoginUserID(); |
|
| 62 | - $udperms->document = $id; |
|
| 63 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 64 | - |
|
| 65 | - if(!$udperms->checkPermissions()) { |
|
| 66 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 67 | - } |
|
| 57 | + //editing an existing document |
|
| 58 | + // check permissions on the document |
|
| 59 | + include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 60 | + $udperms = new udperms(); |
|
| 61 | + $udperms->user = $modx->getLoginUserID(); |
|
| 62 | + $udperms->document = $id; |
|
| 63 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 64 | + |
|
| 65 | + if(!$udperms->checkPermissions()) { |
|
| 66 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // check to see if resource isn't locked |
| 71 | 71 | if($lockedEl = $modx->elementIsLocked(7, $id)) { |
| 72 | - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
|
| 72 | + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
|
| 73 | 73 | } |
| 74 | 74 | // end check for lock |
| 75 | 75 | |
@@ -78,74 +78,74 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // get document groups for current user |
| 80 | 80 | if($_SESSION['mgrDocgroups']) { |
| 81 | - $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
|
| 81 | + $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if(!empty ($id)) { |
| 85 | - $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
|
| 86 | - if($docgrp) { |
|
| 87 | - $access .= " OR dg.document_group IN ({$docgrp})"; |
|
| 88 | - } |
|
| 89 | - $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})"); |
|
| 90 | - $content = array(); |
|
| 91 | - $content = $modx->db->getRow($rs); |
|
| 92 | - $modx->documentObject = &$content; |
|
| 93 | - if(!$content) { |
|
| 94 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 95 | - } |
|
| 96 | - $_SESSION['itemname'] = $content['pagetitle']; |
|
| 85 | + $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
|
| 86 | + if($docgrp) { |
|
| 87 | + $access .= " OR dg.document_group IN ({$docgrp})"; |
|
| 88 | + } |
|
| 89 | + $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})"); |
|
| 90 | + $content = array(); |
|
| 91 | + $content = $modx->db->getRow($rs); |
|
| 92 | + $modx->documentObject = &$content; |
|
| 93 | + if(!$content) { |
|
| 94 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 95 | + } |
|
| 96 | + $_SESSION['itemname'] = $content['pagetitle']; |
|
| 97 | 97 | } else { |
| 98 | - $content = array(); |
|
| 98 | + $content = array(); |
|
| 99 | 99 | |
| 100 | - if(isset($_REQUEST['newtemplate'])) { |
|
| 101 | - $content['template'] = $_REQUEST['newtemplate']; |
|
| 102 | - } else { |
|
| 103 | - $content['template'] = getDefaultTemplate(); |
|
| 104 | - } |
|
| 100 | + if(isset($_REQUEST['newtemplate'])) { |
|
| 101 | + $content['template'] = $_REQUEST['newtemplate']; |
|
| 102 | + } else { |
|
| 103 | + $content['template'] = getDefaultTemplate(); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - $_SESSION['itemname'] = $_lang["new_resource"]; |
|
| 106 | + $_SESSION['itemname'] = $_lang["new_resource"]; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // restore saved form |
| 110 | 110 | $formRestored = $modx->manager->loadFormValues(); |
| 111 | 111 | if(isset($_REQUEST['newtemplate'])) { |
| 112 | - $formRestored = true; |
|
| 112 | + $formRestored = true; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // retain form values if template was changed |
| 116 | 116 | // edited to convert pub_date and unpub_date |
| 117 | 117 | // sottwell 02-09-2006 |
| 118 | 118 | if($formRestored == true) { |
| 119 | - $content = array_merge($content, $_POST); |
|
| 120 | - $content['content'] = $_POST['ta']; |
|
| 121 | - if(empty ($content['pub_date'])) { |
|
| 122 | - unset ($content['pub_date']); |
|
| 123 | - } else { |
|
| 124 | - $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
|
| 125 | - } |
|
| 126 | - if(empty ($content['unpub_date'])) { |
|
| 127 | - unset ($content['unpub_date']); |
|
| 128 | - } else { |
|
| 129 | - $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
|
| 130 | - } |
|
| 119 | + $content = array_merge($content, $_POST); |
|
| 120 | + $content['content'] = $_POST['ta']; |
|
| 121 | + if(empty ($content['pub_date'])) { |
|
| 122 | + unset ($content['pub_date']); |
|
| 123 | + } else { |
|
| 124 | + $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
|
| 125 | + } |
|
| 126 | + if(empty ($content['unpub_date'])) { |
|
| 127 | + unset ($content['unpub_date']); |
|
| 128 | + } else { |
|
| 129 | + $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
|
| 130 | + } |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // increase menu index if this is a new document |
| 134 | 134 | if(!isset ($_REQUEST['id'])) { |
| 135 | - if(!isset ($modx->config['auto_menuindex'])) { |
|
| 136 | - $modx->config['auto_menuindex'] = 1; |
|
| 137 | - } |
|
| 138 | - if($modx->config['auto_menuindex']) { |
|
| 139 | - $pid = intval($_REQUEST['pid']); |
|
| 140 | - $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
|
| 141 | - $content['menuindex'] = $modx->db->getValue($rs); |
|
| 142 | - } else { |
|
| 143 | - $content['menuindex'] = 0; |
|
| 144 | - } |
|
| 135 | + if(!isset ($modx->config['auto_menuindex'])) { |
|
| 136 | + $modx->config['auto_menuindex'] = 1; |
|
| 137 | + } |
|
| 138 | + if($modx->config['auto_menuindex']) { |
|
| 139 | + $pid = intval($_REQUEST['pid']); |
|
| 140 | + $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
|
| 141 | + $content['menuindex'] = $modx->db->getValue($rs); |
|
| 142 | + } else { |
|
| 143 | + $content['menuindex'] = 0; |
|
| 144 | + } |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if(isset ($_POST['which_editor'])) { |
| 148 | - $modx->config['which_editor'] = $_POST['which_editor']; |
|
| 148 | + $modx->config['which_editor'] = $_POST['which_editor']; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Add lock-element JS-Script |
@@ -545,23 +545,23 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | <form name="mutate" id="mutate" class="content" method="post" enctype="multipart/form-data" action="index.php" onsubmit="documentDirty=false;"> |
| 547 | 547 | <?php |
| 548 | - // invoke OnDocFormPrerender event |
|
| 549 | - $evtOut = $modx->invokeEvent('OnDocFormPrerender', array( |
|
| 550 | - 'id' => $id, |
|
| 551 | - 'template' => $content['template'] |
|
| 552 | - )); |
|
| 553 | - |
|
| 554 | - if(is_array($evtOut)) { |
|
| 555 | - echo implode('', $evtOut); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - /*************************/ |
|
| 559 | - $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : ''; |
|
| 560 | - $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon'; |
|
| 561 | - $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : ''; |
|
| 562 | - /*************************/ |
|
| 563 | - |
|
| 564 | - ?> |
|
| 548 | + // invoke OnDocFormPrerender event |
|
| 549 | + $evtOut = $modx->invokeEvent('OnDocFormPrerender', array( |
|
| 550 | + 'id' => $id, |
|
| 551 | + 'template' => $content['template'] |
|
| 552 | + )); |
|
| 553 | + |
|
| 554 | + if(is_array($evtOut)) { |
|
| 555 | + echo implode('', $evtOut); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + /*************************/ |
|
| 559 | + $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : ''; |
|
| 560 | + $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon'; |
|
| 561 | + $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : ''; |
|
| 562 | + /*************************/ |
|
| 563 | + |
|
| 564 | + ?> |
|
| 565 | 565 | <input type="hidden" name="a" value="5" /> |
| 566 | 566 | <input type="hidden" name="id" value="<?= $content['id'] ?>" /> |
| 567 | 567 | <input type="hidden" name="mode" value="<?= $modx->manager->action ?>" /> |
@@ -576,54 +576,54 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | <h1> |
| 578 | 578 | <i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) { |
| 579 | - echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>'; |
|
| 580 | - } else { |
|
| 581 | - if ($modx->manager->action == '4') { |
|
| 579 | + echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>'; |
|
| 580 | + } else { |
|
| 581 | + if ($modx->manager->action == '4') { |
|
| 582 | 582 | echo $_lang['add_resource']; |
| 583 | 583 | } else if ($modx->manager->action == '72') { |
| 584 | 584 | echo $_lang['add_weblink']; |
| 585 | 585 | } else { |
| 586 | 586 | echo $_lang['create_resource_title']; |
| 587 | 587 | } |
| 588 | - } ?> |
|
| 588 | + } ?> |
|
| 589 | 589 | </h1> |
| 590 | 590 | |
| 591 | 591 | <?= $_style['actionbuttons']['dynamic']['document'] ?> |
| 592 | 592 | |
| 593 | 593 | <?php |
| 594 | - // breadcrumbs |
|
| 595 | - if($modx->config['use_breadcrumbs']) { |
|
| 596 | - $temp = array(); |
|
| 597 | - $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
|
| 598 | - |
|
| 599 | - if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 600 | - $bID = (int) $_REQUEST['id']; |
|
| 601 | - $temp = $modx->getParentIds($bID); |
|
| 602 | - } else if(isset($_REQUEST['pid'])) { |
|
| 603 | - $bID = (int) $_REQUEST['pid']; |
|
| 604 | - $temp = $modx->getParentIds($bID); |
|
| 605 | - array_unshift($temp, $bID); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - if($temp) { |
|
| 609 | - $parents = implode(',', $temp); |
|
| 610 | - |
|
| 611 | - if(!empty($parents)) { |
|
| 612 | - $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
|
| 613 | - $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
|
| 614 | - while($row = $modx->db->getRow($rs)) { |
|
| 615 | - $out .= '<li class="breadcrumbs__li"> |
|
| 594 | + // breadcrumbs |
|
| 595 | + if($modx->config['use_breadcrumbs']) { |
|
| 596 | + $temp = array(); |
|
| 597 | + $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
|
| 598 | + |
|
| 599 | + if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 600 | + $bID = (int) $_REQUEST['id']; |
|
| 601 | + $temp = $modx->getParentIds($bID); |
|
| 602 | + } else if(isset($_REQUEST['pid'])) { |
|
| 603 | + $bID = (int) $_REQUEST['pid']; |
|
| 604 | + $temp = $modx->getParentIds($bID); |
|
| 605 | + array_unshift($temp, $bID); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + if($temp) { |
|
| 609 | + $parents = implode(',', $temp); |
|
| 610 | + |
|
| 611 | + if(!empty($parents)) { |
|
| 612 | + $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
|
| 613 | + $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
|
| 614 | + while($row = $modx->db->getRow($rs)) { |
|
| 615 | + $out .= '<li class="breadcrumbs__li"> |
|
| 616 | 616 | <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a> |
| 617 | 617 | <span class="breadcrumbs__sep">></span> |
| 618 | 618 | </li>'; |
| 619 | - } |
|
| 620 | - } |
|
| 621 | - } |
|
| 619 | + } |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | - $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
|
| 624 | - echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
|
| 625 | - } |
|
| 626 | - ?> |
|
| 623 | + $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
|
| 624 | + echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
|
| 625 | + } |
|
| 626 | + ?> |
|
| 627 | 627 | |
| 628 | 628 | <!-- start main wrapper --> |
| 629 | 629 | <div class="sectionBody"> |
@@ -635,13 +635,13 @@ discard block |
||
| 635 | 635 | |
| 636 | 636 | <!-- General --> |
| 637 | 637 | <?php |
| 638 | - $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
|
| 639 | - 'id' => $id |
|
| 640 | - )); |
|
| 641 | - if(is_array($evtOut)) { |
|
| 642 | - echo implode('', $evtOut); |
|
| 643 | - } else { |
|
| 644 | - ?> |
|
| 638 | + $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
|
| 639 | + 'id' => $id |
|
| 640 | + )); |
|
| 641 | + if(is_array($evtOut)) { |
|
| 642 | + echo implode('', $evtOut); |
|
| 643 | + } else { |
|
| 644 | + ?> |
|
| 645 | 645 | <div class="tab-page" id="tabGeneral"> |
| 646 | 646 | <h2 class="tab"><?= $_lang['settings_general'] ?></h2> |
| 647 | 647 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabGeneral"));</script> |
@@ -726,36 +726,36 @@ discard block |
||
| 726 | 726 | <select id="template" name="template" class="inputBox" onchange="templateWarning();"> |
| 727 | 727 | <option value="0">(blank)</option> |
| 728 | 728 | <?php |
| 729 | - $field = "t.templatename, t.selectable, t.id, c.category"; |
|
| 730 | - $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
|
| 731 | - $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC'); |
|
| 732 | - $currentCategory = ''; |
|
| 733 | - while($row = $modx->db->getRow($rs)) { |
|
| 734 | - if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 735 | - continue; |
|
| 736 | - }; |
|
| 737 | - // Skip if not selectable but show if selected! |
|
| 738 | - $thisCategory = $row['category']; |
|
| 739 | - if($thisCategory == null) { |
|
| 740 | - $thisCategory = $_lang["no_category"]; |
|
| 741 | - } |
|
| 742 | - if($thisCategory != $currentCategory) { |
|
| 743 | - if($closeOptGroup) { |
|
| 744 | - echo "\t\t\t\t\t</optgroup>\n"; |
|
| 745 | - } |
|
| 746 | - echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
|
| 747 | - $closeOptGroup = true; |
|
| 748 | - } |
|
| 729 | + $field = "t.templatename, t.selectable, t.id, c.category"; |
|
| 730 | + $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
|
| 731 | + $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC'); |
|
| 732 | + $currentCategory = ''; |
|
| 733 | + while($row = $modx->db->getRow($rs)) { |
|
| 734 | + if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 735 | + continue; |
|
| 736 | + }; |
|
| 737 | + // Skip if not selectable but show if selected! |
|
| 738 | + $thisCategory = $row['category']; |
|
| 739 | + if($thisCategory == null) { |
|
| 740 | + $thisCategory = $_lang["no_category"]; |
|
| 741 | + } |
|
| 742 | + if($thisCategory != $currentCategory) { |
|
| 743 | + if($closeOptGroup) { |
|
| 744 | + echo "\t\t\t\t\t</optgroup>\n"; |
|
| 745 | + } |
|
| 746 | + echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
|
| 747 | + $closeOptGroup = true; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : ''; |
|
| 750 | + $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : ''; |
|
| 751 | 751 | |
| 752 | - echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n"; |
|
| 753 | - $currentCategory = $thisCategory; |
|
| 754 | - } |
|
| 755 | - if($thisCategory != '') { |
|
| 756 | - echo "\t\t\t\t\t</optgroup>\n"; |
|
| 757 | - } |
|
| 758 | - ?> |
|
| 752 | + echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n"; |
|
| 753 | + $currentCategory = $thisCategory; |
|
| 754 | + } |
|
| 755 | + if($thisCategory != '') { |
|
| 756 | + echo "\t\t\t\t\t</optgroup>\n"; |
|
| 757 | + } |
|
| 758 | + ?> |
|
| 759 | 759 | </select> |
| 760 | 760 | </td> |
| 761 | 761 | </tr> |
@@ -795,37 +795,37 @@ discard block |
||
| 795 | 795 | </td> |
| 796 | 796 | <td valign="top"> |
| 797 | 797 | <?php |
| 798 | - $parentlookup = false; |
|
| 799 | - if(isset ($_REQUEST['id'])) { |
|
| 800 | - if($content['parent'] == 0) { |
|
| 801 | - $parentname = $site_name; |
|
| 802 | - } else { |
|
| 803 | - $parentlookup = $content['parent']; |
|
| 804 | - } |
|
| 805 | - } elseif(isset ($_REQUEST['pid'])) { |
|
| 806 | - if($_REQUEST['pid'] == 0) { |
|
| 807 | - $parentname = $site_name; |
|
| 808 | - } else { |
|
| 809 | - $parentlookup = $_REQUEST['pid']; |
|
| 810 | - } |
|
| 811 | - } elseif(isset($_POST['parent'])) { |
|
| 812 | - if($_POST['parent'] == 0) { |
|
| 813 | - $parentname = $site_name; |
|
| 814 | - } else { |
|
| 815 | - $parentlookup = $_POST['parent']; |
|
| 816 | - } |
|
| 817 | - } else { |
|
| 818 | - $parentname = $site_name; |
|
| 819 | - $content['parent'] = 0; |
|
| 820 | - } |
|
| 821 | - if($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 822 | - $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
|
| 823 | - $parentname = $modx->db->getValue($rs); |
|
| 824 | - if(!$parentname) { |
|
| 825 | - $modx->webAlertAndQuit($_lang["error_no_parent"]); |
|
| 826 | - } |
|
| 827 | - } |
|
| 828 | - ?> |
|
| 798 | + $parentlookup = false; |
|
| 799 | + if(isset ($_REQUEST['id'])) { |
|
| 800 | + if($content['parent'] == 0) { |
|
| 801 | + $parentname = $site_name; |
|
| 802 | + } else { |
|
| 803 | + $parentlookup = $content['parent']; |
|
| 804 | + } |
|
| 805 | + } elseif(isset ($_REQUEST['pid'])) { |
|
| 806 | + if($_REQUEST['pid'] == 0) { |
|
| 807 | + $parentname = $site_name; |
|
| 808 | + } else { |
|
| 809 | + $parentlookup = $_REQUEST['pid']; |
|
| 810 | + } |
|
| 811 | + } elseif(isset($_POST['parent'])) { |
|
| 812 | + if($_POST['parent'] == 0) { |
|
| 813 | + $parentname = $site_name; |
|
| 814 | + } else { |
|
| 815 | + $parentlookup = $_POST['parent']; |
|
| 816 | + } |
|
| 817 | + } else { |
|
| 818 | + $parentname = $site_name; |
|
| 819 | + $content['parent'] = 0; |
|
| 820 | + } |
|
| 821 | + if($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 822 | + $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
|
| 823 | + $parentname = $modx->db->getValue($rs); |
|
| 824 | + if(!$parentname) { |
|
| 825 | + $modx->webAlertAndQuit($_lang["error_no_parent"]); |
|
| 826 | + } |
|
| 827 | + } |
|
| 828 | + ?> |
|
| 829 | 829 | <i id="plock" class="<?= $_style["actions_folder"] ?>" onclick="enableParentSelection(!allowParentSelection);"></i> |
| 830 | 830 | <b><span id="parentName"><?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?> (<?= $parentname ?>)</span></b> |
| 831 | 831 | <input type="hidden" name="parent" value="<?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?>" onchange="documentDirty=true;" /> |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | </tr> |
| 834 | 834 | <tr></tr> |
| 835 | 835 | <?php |
| 836 | - /* |
|
| 836 | + /* |
|
| 837 | 837 | if($content['type'] == 'reference' || $modx->manager->action == '72') { |
| 838 | 838 | ?> |
| 839 | 839 | <tr> |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | </tr> |
| 862 | 862 | <?php |
| 863 | 863 | }*/ |
| 864 | - ?> |
|
| 864 | + ?> |
|
| 865 | 865 | |
| 866 | 866 | <?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?> |
| 867 | 867 | <tr> |
@@ -874,36 +874,36 @@ discard block |
||
| 874 | 874 | <select id="which_editor" class="form-control form-control-sm" size="1" name="which_editor" onchange="changeRTE();"> |
| 875 | 875 | <option value="none"><?= $_lang['none'] ?></option> |
| 876 | 876 | <?php |
| 877 | - // invoke OnRichTextEditorRegister event |
|
| 878 | - $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
|
| 879 | - if(is_array($evtOut)) { |
|
| 880 | - for($i = 0; $i < count($evtOut); $i++) { |
|
| 881 | - $editor = $evtOut[$i]; |
|
| 882 | - echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
|
| 883 | - } |
|
| 884 | - } |
|
| 885 | - ?> |
|
| 877 | + // invoke OnRichTextEditorRegister event |
|
| 878 | + $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
|
| 879 | + if(is_array($evtOut)) { |
|
| 880 | + for($i = 0; $i < count($evtOut); $i++) { |
|
| 881 | + $editor = $evtOut[$i]; |
|
| 882 | + echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
|
| 883 | + } |
|
| 884 | + } |
|
| 885 | + ?> |
|
| 886 | 886 | </select> |
| 887 | 887 | </label> |
| 888 | 888 | </div> |
| 889 | 889 | <div id="content_body"> |
| 890 | 890 | <?php |
| 891 | - if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 892 | - $htmlContent = $content['content']; |
|
| 893 | - ?> |
|
| 891 | + if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 892 | + $htmlContent = $content['content']; |
|
| 893 | + ?> |
|
| 894 | 894 | <div class="section-editor clearfix"> |
| 895 | 895 | <textarea id="ta" name="ta" onchange="documentDirty=true;"><?= $modx->htmlspecialchars($htmlContent) ?></textarea> |
| 896 | 896 | </div> |
| 897 | 897 | <?php |
| 898 | - // Richtext-[*content*] |
|
| 899 | - $richtexteditorIds = array(); |
|
| 900 | - $richtexteditorOptions = array(); |
|
| 901 | - $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
|
| 902 | - $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
|
| 903 | - } else { |
|
| 904 | - echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n"; |
|
| 905 | - } |
|
| 906 | - ?> |
|
| 898 | + // Richtext-[*content*] |
|
| 899 | + $richtexteditorIds = array(); |
|
| 900 | + $richtexteditorOptions = array(); |
|
| 901 | + $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
|
| 902 | + $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
|
| 903 | + } else { |
|
| 904 | + echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n"; |
|
| 905 | + } |
|
| 906 | + ?> |
|
| 907 | 907 | </div> |
| 908 | 908 | </td> |
| 909 | 909 | </tr> |
@@ -1190,8 +1190,8 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | <?php |
| 1192 | 1192 | |
| 1193 | - if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1194 | - ?> |
|
| 1193 | + if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1194 | + ?> |
|
| 1195 | 1195 | <tr> |
| 1196 | 1196 | <td> |
| 1197 | 1197 | <span class="warning"><?= $_lang['resource_type'] ?></span> |
@@ -1213,15 +1213,15 @@ discard block |
||
| 1213 | 1213 | <td> |
| 1214 | 1214 | <select name="contentType" class="inputBox" onchange="documentDirty=true;"> |
| 1215 | 1215 | <?php |
| 1216 | - if(!$content['contentType']) { |
|
| 1217 | - $content['contentType'] = 'text/html'; |
|
| 1218 | - } |
|
| 1219 | - $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
|
| 1220 | - $ct = explode(",", $custom_contenttype); |
|
| 1221 | - for($i = 0; $i < count($ct); $i++) { |
|
| 1222 | - echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
|
| 1223 | - } |
|
| 1224 | - ?> |
|
| 1216 | + if(!$content['contentType']) { |
|
| 1217 | + $content['contentType'] = 'text/html'; |
|
| 1218 | + } |
|
| 1219 | + $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
|
| 1220 | + $ct = explode(",", $custom_contenttype); |
|
| 1221 | + for($i = 0; $i < count($ct); $i++) { |
|
| 1222 | + echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
|
| 1223 | + } |
|
| 1224 | + ?> |
|
| 1225 | 1225 | </select> |
| 1226 | 1226 | </td> |
| 1227 | 1227 | </tr> |
@@ -1244,23 +1244,23 @@ discard block |
||
| 1244 | 1244 | </td> |
| 1245 | 1245 | </tr> |
| 1246 | 1246 | <?php |
| 1247 | - } else { |
|
| 1248 | - if($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1249 | - // non-admin managers creating or editing a document resource |
|
| 1250 | - ?> |
|
| 1247 | + } else { |
|
| 1248 | + if($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1249 | + // non-admin managers creating or editing a document resource |
|
| 1250 | + ?> |
|
| 1251 | 1251 | <input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" /> |
| 1252 | 1252 | <input type="hidden" name="type" value="document" /> |
| 1253 | 1253 | <input type="hidden" name="content_dispo" value="<?= (isset($content['content_dispo']) ? $content['content_dispo'] : '0') ?>" /> |
| 1254 | 1254 | <?php |
| 1255 | - } else { |
|
| 1256 | - // non-admin managers creating or editing a reference (weblink) resource |
|
| 1257 | - ?> |
|
| 1255 | + } else { |
|
| 1256 | + // non-admin managers creating or editing a reference (weblink) resource |
|
| 1257 | + ?> |
|
| 1258 | 1258 | <input type="hidden" name="type" value="reference" /> |
| 1259 | 1259 | <input type="hidden" name="contentType" value="text/html" /> |
| 1260 | 1260 | <?php |
| 1261 | - } |
|
| 1262 | - }//if mgrRole |
|
| 1263 | - ?> |
|
| 1261 | + } |
|
| 1262 | + }//if mgrRole |
|
| 1263 | + ?> |
|
| 1264 | 1264 | |
| 1265 | 1265 | <tr> |
| 1266 | 1266 | <td> |
@@ -1343,112 +1343,112 @@ discard block |
||
| 1343 | 1343 | ?> |
| 1344 | 1344 | |
| 1345 | 1345 | <?php |
| 1346 | - /******************************* |
|
| 1346 | + /******************************* |
|
| 1347 | 1347 | * Document Access Permissions */ |
| 1348 | - if($use_udperms == 1) { |
|
| 1349 | - $groupsarray = array(); |
|
| 1350 | - $sql = ''; |
|
| 1351 | - |
|
| 1352 | - $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
|
| 1353 | - if($documentId > 0) { |
|
| 1354 | - // Load up, the permissions from the parent (if new document) or existing document |
|
| 1355 | - $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
|
| 1356 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1357 | - |
|
| 1358 | - // Load up the current permissions and names |
|
| 1359 | - $vs = array( |
|
| 1360 | - $tbl_document_group_names, |
|
| 1361 | - $tbl_document_groups, |
|
| 1362 | - $documentId |
|
| 1363 | - ); |
|
| 1364 | - $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs); |
|
| 1365 | - $rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name'); |
|
| 1366 | - } else { |
|
| 1367 | - // Just load up the names, we're starting clean |
|
| 1368 | - $rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name'); |
|
| 1369 | - } |
|
| 1370 | - |
|
| 1371 | - // retain selected doc groups between post |
|
| 1372 | - if(isset($_POST['docgroups'])) { |
|
| 1373 | - $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
|
| 1374 | - } |
|
| 1348 | + if($use_udperms == 1) { |
|
| 1349 | + $groupsarray = array(); |
|
| 1350 | + $sql = ''; |
|
| 1351 | + |
|
| 1352 | + $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
|
| 1353 | + if($documentId > 0) { |
|
| 1354 | + // Load up, the permissions from the parent (if new document) or existing document |
|
| 1355 | + $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
|
| 1356 | + while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1357 | + |
|
| 1358 | + // Load up the current permissions and names |
|
| 1359 | + $vs = array( |
|
| 1360 | + $tbl_document_group_names, |
|
| 1361 | + $tbl_document_groups, |
|
| 1362 | + $documentId |
|
| 1363 | + ); |
|
| 1364 | + $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs); |
|
| 1365 | + $rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name'); |
|
| 1366 | + } else { |
|
| 1367 | + // Just load up the names, we're starting clean |
|
| 1368 | + $rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name'); |
|
| 1369 | + } |
|
| 1370 | + |
|
| 1371 | + // retain selected doc groups between post |
|
| 1372 | + if(isset($_POST['docgroups'])) { |
|
| 1373 | + $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + $isManager = $modx->hasPermission('access_permissions'); |
|
| 1377 | + $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 1378 | + |
|
| 1379 | + // Setup Basic attributes for each Input box |
|
| 1380 | + $inputAttributes = array( |
|
| 1381 | + 'type' => 'checkbox', |
|
| 1382 | + 'class' => 'checkbox', |
|
| 1383 | + 'name' => 'docgroups[]', |
|
| 1384 | + 'onclick' => 'makePublic(false);', |
|
| 1385 | + ); |
|
| 1386 | + $permissions = array(); // New Permissions array list (this contains the HTML) |
|
| 1387 | + $permissions_yes = 0; // count permissions the current mgr user has |
|
| 1388 | + $permissions_no = 0; // count permissions the current mgr user doesn't have |
|
| 1389 | + |
|
| 1390 | + // Loop through the permissions list |
|
| 1391 | + while($row = $modx->db->getRow($rs)) { |
|
| 1392 | + |
|
| 1393 | + // Create an inputValue pair (group ID and group link (if it exists)) |
|
| 1394 | + $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1395 | + $inputId = 'group-' . $row['id']; |
|
| 1396 | + |
|
| 1397 | + $checked = in_array($inputValue, $groupsarray); |
|
| 1398 | + if($checked) { |
|
| 1399 | + $notPublic = true; |
|
| 1400 | + } // Mark as private access (either web or manager) |
|
| 1401 | + |
|
| 1402 | + // Skip the access permission if the user doesn't have access... |
|
| 1403 | + if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1404 | + continue; |
|
| 1405 | + } |
|
| 1375 | 1406 | |
| 1376 | - $isManager = $modx->hasPermission('access_permissions'); |
|
| 1377 | - $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 1378 | - |
|
| 1379 | - // Setup Basic attributes for each Input box |
|
| 1380 | - $inputAttributes = array( |
|
| 1381 | - 'type' => 'checkbox', |
|
| 1382 | - 'class' => 'checkbox', |
|
| 1383 | - 'name' => 'docgroups[]', |
|
| 1384 | - 'onclick' => 'makePublic(false);', |
|
| 1385 | - ); |
|
| 1386 | - $permissions = array(); // New Permissions array list (this contains the HTML) |
|
| 1387 | - $permissions_yes = 0; // count permissions the current mgr user has |
|
| 1388 | - $permissions_no = 0; // count permissions the current mgr user doesn't have |
|
| 1389 | - |
|
| 1390 | - // Loop through the permissions list |
|
| 1391 | - while($row = $modx->db->getRow($rs)) { |
|
| 1392 | - |
|
| 1393 | - // Create an inputValue pair (group ID and group link (if it exists)) |
|
| 1394 | - $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1395 | - $inputId = 'group-' . $row['id']; |
|
| 1396 | - |
|
| 1397 | - $checked = in_array($inputValue, $groupsarray); |
|
| 1398 | - if($checked) { |
|
| 1399 | - $notPublic = true; |
|
| 1400 | - } // Mark as private access (either web or manager) |
|
| 1401 | - |
|
| 1402 | - // Skip the access permission if the user doesn't have access... |
|
| 1403 | - if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1404 | - continue; |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - // Setup attributes for this Input box |
|
| 1408 | - $inputAttributes['id'] = $inputId; |
|
| 1409 | - $inputAttributes['value'] = $inputValue; |
|
| 1410 | - if($checked) { |
|
| 1411 | - $inputAttributes['checked'] = 'checked'; |
|
| 1412 | - } else { |
|
| 1413 | - unset($inputAttributes['checked']); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - // Create attribute string list |
|
| 1417 | - $inputString = array(); |
|
| 1418 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1419 | - |
|
| 1420 | - // Make the <input> HTML |
|
| 1421 | - $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
|
| 1422 | - |
|
| 1423 | - // does user have this permission? |
|
| 1424 | - $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
|
| 1425 | - $vs = array( |
|
| 1426 | - $row['id'], |
|
| 1427 | - $_SESSION['mgrInternalKey'] |
|
| 1428 | - ); |
|
| 1429 | - $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
|
| 1430 | - $rsp = $modx->db->select('COUNT(mg.id)', $from, $where); |
|
| 1431 | - $count = $modx->db->getValue($rsp); |
|
| 1432 | - if($count > 0) { |
|
| 1433 | - ++$permissions_yes; |
|
| 1434 | - } else { |
|
| 1435 | - ++$permissions_no; |
|
| 1436 | - } |
|
| 1437 | - $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
|
| 1438 | - } |
|
| 1439 | - // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
|
| 1440 | - if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1441 | - $permissions = array(); |
|
| 1442 | - } |
|
| 1407 | + // Setup attributes for this Input box |
|
| 1408 | + $inputAttributes['id'] = $inputId; |
|
| 1409 | + $inputAttributes['value'] = $inputValue; |
|
| 1410 | + if($checked) { |
|
| 1411 | + $inputAttributes['checked'] = 'checked'; |
|
| 1412 | + } else { |
|
| 1413 | + unset($inputAttributes['checked']); |
|
| 1414 | + } |
|
| 1443 | 1415 | |
| 1444 | - // See if the Access Permissions section is worth displaying... |
|
| 1445 | - if(!empty($permissions)) { |
|
| 1446 | - // Add the "All Document Groups" item if we have rights in both contexts |
|
| 1447 | - if($isManager && $isWeb) { |
|
| 1448 | - array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>'); |
|
| 1449 | - } |
|
| 1450 | - // Output the permissions list... |
|
| 1451 | - ?> |
|
| 1416 | + // Create attribute string list |
|
| 1417 | + $inputString = array(); |
|
| 1418 | + foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1419 | + |
|
| 1420 | + // Make the <input> HTML |
|
| 1421 | + $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
|
| 1422 | + |
|
| 1423 | + // does user have this permission? |
|
| 1424 | + $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
|
| 1425 | + $vs = array( |
|
| 1426 | + $row['id'], |
|
| 1427 | + $_SESSION['mgrInternalKey'] |
|
| 1428 | + ); |
|
| 1429 | + $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
|
| 1430 | + $rsp = $modx->db->select('COUNT(mg.id)', $from, $where); |
|
| 1431 | + $count = $modx->db->getValue($rsp); |
|
| 1432 | + if($count > 0) { |
|
| 1433 | + ++$permissions_yes; |
|
| 1434 | + } else { |
|
| 1435 | + ++$permissions_no; |
|
| 1436 | + } |
|
| 1437 | + $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
|
| 1438 | + } |
|
| 1439 | + // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
|
| 1440 | + if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1441 | + $permissions = array(); |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + // See if the Access Permissions section is worth displaying... |
|
| 1445 | + if(!empty($permissions)) { |
|
| 1446 | + // Add the "All Document Groups" item if we have rights in both contexts |
|
| 1447 | + if($isManager && $isWeb) { |
|
| 1448 | + array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>'); |
|
| 1449 | + } |
|
| 1450 | + // Output the permissions list... |
|
| 1451 | + ?> |
|
| 1452 | 1452 | <!-- Access Permissions --> |
| 1453 | 1453 | <div class="tab-page" id="tabAccess"> |
| 1454 | 1454 | <h2 class="tab" id="tab_access_header"><?= $_lang['access_permissions'] ?></h2> |
@@ -1482,31 +1482,31 @@ discard block |
||
| 1482 | 1482 | </ul> |
| 1483 | 1483 | </div><!--div class="tab-page" id="tabAccess"--> |
| 1484 | 1484 | <?php |
| 1485 | - } // !empty($permissions) |
|
| 1486 | - elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1487 | - ?> |
|
| 1485 | + } // !empty($permissions) |
|
| 1486 | + elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1487 | + ?> |
|
| 1488 | 1488 | <p><?= $_lang["access_permissions_docs_collision"] ?></p> |
| 1489 | 1489 | <?php |
| 1490 | 1490 | |
| 1491 | - } |
|
| 1492 | - } |
|
| 1493 | - /* End Document Access Permissions * |
|
| 1491 | + } |
|
| 1492 | + } |
|
| 1493 | + /* End Document Access Permissions * |
|
| 1494 | 1494 | ***********************************/ |
| 1495 | - ?> |
|
| 1495 | + ?> |
|
| 1496 | 1496 | |
| 1497 | 1497 | <input type="submit" name="save" style="display:none" /> |
| 1498 | 1498 | <?php |
| 1499 | 1499 | |
| 1500 | - // invoke OnDocFormRender event |
|
| 1501 | - $evtOut = $modx->invokeEvent('OnDocFormRender', array( |
|
| 1502 | - 'id' => $id, |
|
| 1503 | - 'template' => $content['template'] |
|
| 1504 | - )); |
|
| 1500 | + // invoke OnDocFormRender event |
|
| 1501 | + $evtOut = $modx->invokeEvent('OnDocFormRender', array( |
|
| 1502 | + 'id' => $id, |
|
| 1503 | + 'template' => $content['template'] |
|
| 1504 | + )); |
|
| 1505 | 1505 | |
| 1506 | - if(is_array($evtOut)) { |
|
| 1507 | - echo implode('', $evtOut); |
|
| 1508 | - } |
|
| 1509 | - ?> |
|
| 1506 | + if(is_array($evtOut)) { |
|
| 1507 | + echo implode('', $evtOut); |
|
| 1508 | + } |
|
| 1509 | + ?> |
|
| 1510 | 1510 | </div><!--div class="tab-pane" id="documentPane"--> |
| 1511 | 1511 | </div><!--div class="sectionBody"--> |
| 1512 | 1512 | </fieldset> |
@@ -1517,62 +1517,62 @@ discard block |
||
| 1517 | 1517 | </script> |
| 1518 | 1518 | <?php |
| 1519 | 1519 | if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) { |
| 1520 | - if(is_array($richtexteditorIds)) { |
|
| 1521 | - foreach($richtexteditorIds as $editor => $elements) { |
|
| 1522 | - // invoke OnRichTextEditorInit event |
|
| 1523 | - $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
|
| 1524 | - 'editor' => $editor, |
|
| 1525 | - 'elements' => $elements, |
|
| 1526 | - 'options' => $richtexteditorOptions[$editor] |
|
| 1527 | - )); |
|
| 1528 | - if(is_array($evtOut)) { |
|
| 1529 | - echo implode('', $evtOut); |
|
| 1530 | - } |
|
| 1531 | - } |
|
| 1532 | - } |
|
| 1520 | + if(is_array($richtexteditorIds)) { |
|
| 1521 | + foreach($richtexteditorIds as $editor => $elements) { |
|
| 1522 | + // invoke OnRichTextEditorInit event |
|
| 1523 | + $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
|
| 1524 | + 'editor' => $editor, |
|
| 1525 | + 'elements' => $elements, |
|
| 1526 | + 'options' => $richtexteditorOptions[$editor] |
|
| 1527 | + )); |
|
| 1528 | + if(is_array($evtOut)) { |
|
| 1529 | + echo implode('', $evtOut); |
|
| 1530 | + } |
|
| 1531 | + } |
|
| 1532 | + } |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | function getDefaultTemplate() { |
| 1536 | - global $modx; |
|
| 1537 | - |
|
| 1538 | - switch($modx->config['auto_template_logic']) { |
|
| 1539 | - case 'sibling': |
|
| 1540 | - if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1541 | - $site_start = $modx->config['site_start']; |
|
| 1542 | - $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
|
| 1543 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
|
| 1544 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1545 | - $default_template = $sibl[0]['template']; |
|
| 1546 | - } |
|
| 1547 | - } else { |
|
| 1548 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1549 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1550 | - $default_template = $sibl[0]['template']; |
|
| 1551 | - } else { |
|
| 1552 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1553 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | - $default_template = $sibl[0]['template']; |
|
| 1555 | - } |
|
| 1556 | - } |
|
| 1557 | - } |
|
| 1558 | - if(isset($default_template)) { |
|
| 1559 | - break; |
|
| 1560 | - } // If $default_template could not be determined, fall back / through to "parent"-mode |
|
| 1561 | - case 'parent': |
|
| 1562 | - if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1563 | - $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
|
| 1564 | - if(isset($parent['template'])) { |
|
| 1565 | - $default_template = $parent['template']; |
|
| 1566 | - } |
|
| 1567 | - } |
|
| 1568 | - break; |
|
| 1569 | - case 'system': |
|
| 1570 | - default: // default_template is already set |
|
| 1571 | - $default_template = $modx->config['default_template']; |
|
| 1572 | - } |
|
| 1573 | - if(!isset($default_template)) { |
|
| 1574 | - $default_template = $modx->config['default_template']; |
|
| 1575 | - } // default_template is already set |
|
| 1576 | - |
|
| 1577 | - return $default_template; |
|
| 1536 | + global $modx; |
|
| 1537 | + |
|
| 1538 | + switch($modx->config['auto_template_logic']) { |
|
| 1539 | + case 'sibling': |
|
| 1540 | + if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1541 | + $site_start = $modx->config['site_start']; |
|
| 1542 | + $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
|
| 1543 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
|
| 1544 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1545 | + $default_template = $sibl[0]['template']; |
|
| 1546 | + } |
|
| 1547 | + } else { |
|
| 1548 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1549 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1550 | + $default_template = $sibl[0]['template']; |
|
| 1551 | + } else { |
|
| 1552 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1553 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | + $default_template = $sibl[0]['template']; |
|
| 1555 | + } |
|
| 1556 | + } |
|
| 1557 | + } |
|
| 1558 | + if(isset($default_template)) { |
|
| 1559 | + break; |
|
| 1560 | + } // If $default_template could not be determined, fall back / through to "parent"-mode |
|
| 1561 | + case 'parent': |
|
| 1562 | + if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1563 | + $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
|
| 1564 | + if(isset($parent['template'])) { |
|
| 1565 | + $default_template = $parent['template']; |
|
| 1566 | + } |
|
| 1567 | + } |
|
| 1568 | + break; |
|
| 1569 | + case 'system': |
|
| 1570 | + default: // default_template is already set |
|
| 1571 | + $default_template = $modx->config['default_template']; |
|
| 1572 | + } |
|
| 1573 | + if(!isset($default_template)) { |
|
| 1574 | + $default_template = $modx->config['default_template']; |
|
| 1575 | + } // default_template is already set |
|
| 1576 | + |
|
| 1577 | + return $default_template; |
|
| 1578 | 1578 | } |
@@ -1,35 +1,35 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /********************/ |
| 7 | -$sd = isset($_REQUEST['dir']) ? '&dir=' . $_REQUEST['dir'] : '&dir=DESC'; |
|
| 8 | -$sb = isset($_REQUEST['sort']) ? '&sort=' . $_REQUEST['sort'] : '&sort=createdon'; |
|
| 9 | -$pg = isset($_REQUEST['page']) ? '&page=' . (int) $_REQUEST['page'] : ''; |
|
| 10 | -$add_path = $sd . $sb . $pg; |
|
| 7 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
| 8 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
| 9 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
| 10 | +$add_path = $sd.$sb.$pg; |
|
| 11 | 11 | /*******************/ |
| 12 | 12 | |
| 13 | 13 | // check permissions |
| 14 | -switch($modx->manager->action) { |
|
| 14 | +switch ($modx->manager->action) { |
|
| 15 | 15 | case 27: |
| 16 | - if(!$modx->hasPermission('edit_document')) { |
|
| 16 | + if (!$modx->hasPermission('edit_document')) { |
|
| 17 | 17 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 18 | 18 | } |
| 19 | 19 | break; |
| 20 | 20 | case 85: |
| 21 | 21 | case 72: |
| 22 | 22 | case 4: |
| 23 | - if(!$modx->hasPermission('new_document')) { |
|
| 23 | + if (!$modx->hasPermission('new_document')) { |
|
| 24 | 24 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 25 | - } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 25 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 26 | 26 | // check user has permissions for parent |
| 27 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 27 | + include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php'); |
|
| 28 | 28 | $udperms = new udperms(); |
| 29 | 29 | $udperms->user = $modx->getLoginUserID(); |
| 30 | 30 | $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
| 31 | 31 | $udperms->role = $_SESSION['mgrRole']; |
| 32 | - if(!$udperms->checkPermissions()) { |
|
| 32 | + if (!$udperms->checkPermissions()) { |
|
| 33 | 33 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -53,22 +53,22 @@ discard block |
||
| 53 | 53 | $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates'); |
| 54 | 54 | $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars'); |
| 55 | 55 | |
| 56 | -if($modx->manager->action == 27) { |
|
| 56 | +if ($modx->manager->action == 27) { |
|
| 57 | 57 | //editing an existing document |
| 58 | 58 | // check permissions on the document |
| 59 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 59 | + include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php'); |
|
| 60 | 60 | $udperms = new udperms(); |
| 61 | 61 | $udperms->user = $modx->getLoginUserID(); |
| 62 | 62 | $udperms->document = $id; |
| 63 | 63 | $udperms->role = $_SESSION['mgrRole']; |
| 64 | 64 | |
| 65 | - if(!$udperms->checkPermissions()) { |
|
| 65 | + if (!$udperms->checkPermissions()) { |
|
| 66 | 66 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // check to see if resource isn't locked |
| 71 | -if($lockedEl = $modx->elementIsLocked(7, $id)) { |
|
| 71 | +if ($lockedEl = $modx->elementIsLocked(7, $id)) { |
|
| 72 | 72 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
| 73 | 73 | } |
| 74 | 74 | // end check for lock |
@@ -77,27 +77,27 @@ discard block |
||
| 77 | 77 | $modx->lockElement(7, $id); |
| 78 | 78 | |
| 79 | 79 | // get document groups for current user |
| 80 | -if($_SESSION['mgrDocgroups']) { |
|
| 80 | +if ($_SESSION['mgrDocgroups']) { |
|
| 81 | 81 | $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -if(!empty ($id)) { |
|
| 84 | +if (!empty ($id)) { |
|
| 85 | 85 | $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
| 86 | - if($docgrp) { |
|
| 86 | + if ($docgrp) { |
|
| 87 | 87 | $access .= " OR dg.document_group IN ({$docgrp})"; |
| 88 | 88 | } |
| 89 | 89 | $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})"); |
| 90 | 90 | $content = array(); |
| 91 | 91 | $content = $modx->db->getRow($rs); |
| 92 | 92 | $modx->documentObject = &$content; |
| 93 | - if(!$content) { |
|
| 93 | + if (!$content) { |
|
| 94 | 94 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 95 | 95 | } |
| 96 | 96 | $_SESSION['itemname'] = $content['pagetitle']; |
| 97 | 97 | } else { |
| 98 | 98 | $content = array(); |
| 99 | 99 | |
| 100 | - if(isset($_REQUEST['newtemplate'])) { |
|
| 100 | + if (isset($_REQUEST['newtemplate'])) { |
|
| 101 | 101 | $content['template'] = $_REQUEST['newtemplate']; |
| 102 | 102 | } else { |
| 103 | 103 | $content['template'] = getDefaultTemplate(); |
@@ -108,22 +108,22 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // restore saved form |
| 110 | 110 | $formRestored = $modx->manager->loadFormValues(); |
| 111 | -if(isset($_REQUEST['newtemplate'])) { |
|
| 111 | +if (isset($_REQUEST['newtemplate'])) { |
|
| 112 | 112 | $formRestored = true; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // retain form values if template was changed |
| 116 | 116 | // edited to convert pub_date and unpub_date |
| 117 | 117 | // sottwell 02-09-2006 |
| 118 | -if($formRestored == true) { |
|
| 118 | +if ($formRestored == true) { |
|
| 119 | 119 | $content = array_merge($content, $_POST); |
| 120 | 120 | $content['content'] = $_POST['ta']; |
| 121 | - if(empty ($content['pub_date'])) { |
|
| 121 | + if (empty ($content['pub_date'])) { |
|
| 122 | 122 | unset ($content['pub_date']); |
| 123 | 123 | } else { |
| 124 | 124 | $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
| 125 | 125 | } |
| 126 | - if(empty ($content['unpub_date'])) { |
|
| 126 | + if (empty ($content['unpub_date'])) { |
|
| 127 | 127 | unset ($content['unpub_date']); |
| 128 | 128 | } else { |
| 129 | 129 | $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // increase menu index if this is a new document |
| 134 | -if(!isset ($_REQUEST['id'])) { |
|
| 135 | - if(!isset ($modx->config['auto_menuindex'])) { |
|
| 134 | +if (!isset ($_REQUEST['id'])) { |
|
| 135 | + if (!isset ($modx->config['auto_menuindex'])) { |
|
| 136 | 136 | $modx->config['auto_menuindex'] = 1; |
| 137 | 137 | } |
| 138 | - if($modx->config['auto_menuindex']) { |
|
| 138 | + if ($modx->config['auto_menuindex']) { |
|
| 139 | 139 | $pid = intval($_REQUEST['pid']); |
| 140 | 140 | $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
| 141 | 141 | $content['menuindex'] = $modx->db->getValue($rs); |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -if(isset ($_POST['which_editor'])) { |
|
| 147 | +if (isset ($_POST['which_editor'])) { |
|
| 148 | 148 | $modx->config['which_editor'] = $_POST['which_editor']; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Add lock-element JS-Script |
| 152 | 152 | $lockElementId = $id; |
| 153 | 153 | $lockElementType = 7; |
| 154 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
| 154 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
| 155 | 155 | ?> |
| 156 | 156 | <script type="text/javascript"> |
| 157 | 157 | /* <![CDATA[ */ |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | }, |
| 182 | 182 | cancel: function() { |
| 183 | 183 | documentDirty = false; |
| 184 | - document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id=' . $id . $add_path) ?>'; |
|
| 184 | + document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id='.$id.$add_path) ?>'; |
|
| 185 | 185 | }, |
| 186 | 186 | duplicate: function() { |
| 187 | 187 | if(confirm("<?= $_lang['confirm_resource_duplicate']?>") === true) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | }, |
| 191 | 191 | view: function() { |
| 192 | - window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'] . 'index.php?id=' . $id ?>', 'previeWin'); |
|
| 192 | + window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'].'index.php?id='.$id ?>', 'previeWin'); |
|
| 193 | 193 | } |
| 194 | 194 | }; |
| 195 | 195 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | 'template' => $content['template'] |
| 552 | 552 | )); |
| 553 | 553 | |
| 554 | - if(is_array($evtOut)) { |
|
| 554 | + if (is_array($evtOut)) { |
|
| 555 | 555 | echo implode('', $evtOut); |
| 556 | 556 | } |
| 557 | 557 | |
@@ -575,8 +575,8 @@ discard block |
||
| 575 | 575 | <fieldset id="create_edit"> |
| 576 | 576 | |
| 577 | 577 | <h1> |
| 578 | - <i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) { |
|
| 579 | - echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>'; |
|
| 578 | + <i class="fa fa-pencil-square-o"></i><?php if (isset($_REQUEST['id'])) { |
|
| 579 | + echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']).(iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '').'<small>('.$_REQUEST['id'].')</small>'; |
|
| 580 | 580 | } else { |
| 581 | 581 | if ($modx->manager->action == '4') { |
| 582 | 582 | echo $_lang['add_resource']; |
@@ -592,36 +592,36 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | <?php |
| 594 | 594 | // breadcrumbs |
| 595 | - if($modx->config['use_breadcrumbs']) { |
|
| 595 | + if ($modx->config['use_breadcrumbs']) { |
|
| 596 | 596 | $temp = array(); |
| 597 | 597 | $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
| 598 | 598 | |
| 599 | - if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 599 | + if (isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 600 | 600 | $bID = (int) $_REQUEST['id']; |
| 601 | 601 | $temp = $modx->getParentIds($bID); |
| 602 | - } else if(isset($_REQUEST['pid'])) { |
|
| 602 | + } else if (isset($_REQUEST['pid'])) { |
|
| 603 | 603 | $bID = (int) $_REQUEST['pid']; |
| 604 | 604 | $temp = $modx->getParentIds($bID); |
| 605 | 605 | array_unshift($temp, $bID); |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - if($temp) { |
|
| 608 | + if ($temp) { |
|
| 609 | 609 | $parents = implode(',', $temp); |
| 610 | 610 | |
| 611 | - if(!empty($parents)) { |
|
| 611 | + if (!empty($parents)) { |
|
| 612 | 612 | $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
| 613 | 613 | $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
| 614 | - while($row = $modx->db->getRow($rs)) { |
|
| 614 | + while ($row = $modx->db->getRow($rs)) { |
|
| 615 | 615 | $out .= '<li class="breadcrumbs__li"> |
| 616 | - <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a> |
|
| 616 | + <a href="index.php?a=27&id=' . $row['id'].'" class="breadcrumbs__a">'.htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']).'</a> |
|
| 617 | 617 | <span class="breadcrumbs__sep">></span> |
| 618 | 618 | </li>'; |
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
|
| 624 | - echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
|
| 623 | + $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">'.$title.'</li>'; |
|
| 624 | + echo '<ul class="breadcrumbs">'.$out.'</ul>'; |
|
| 625 | 625 | } |
| 626 | 626 | ?> |
| 627 | 627 | |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
| 639 | 639 | 'id' => $id |
| 640 | 640 | )); |
| 641 | - if(is_array($evtOut)) { |
|
| 641 | + if (is_array($evtOut)) { |
|
| 642 | 642 | echo implode('', $evtOut); |
| 643 | 643 | } else { |
| 644 | 644 | ?> |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | </td> |
| 695 | 695 | </tr> |
| 696 | 696 | |
| 697 | - <?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 697 | + <?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 698 | 698 | |
| 699 | 699 | <tr> |
| 700 | 700 | <td><span class="warning"><?= $_lang['weblink'] ?></span> |
@@ -730,17 +730,17 @@ discard block |
||
| 730 | 730 | $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
| 731 | 731 | $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC'); |
| 732 | 732 | $currentCategory = ''; |
| 733 | - while($row = $modx->db->getRow($rs)) { |
|
| 734 | - if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 733 | + while ($row = $modx->db->getRow($rs)) { |
|
| 734 | + if ($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 735 | 735 | continue; |
| 736 | 736 | }; |
| 737 | 737 | // Skip if not selectable but show if selected! |
| 738 | 738 | $thisCategory = $row['category']; |
| 739 | - if($thisCategory == null) { |
|
| 739 | + if ($thisCategory == null) { |
|
| 740 | 740 | $thisCategory = $_lang["no_category"]; |
| 741 | 741 | } |
| 742 | - if($thisCategory != $currentCategory) { |
|
| 743 | - if($closeOptGroup) { |
|
| 742 | + if ($thisCategory != $currentCategory) { |
|
| 743 | + if ($closeOptGroup) { |
|
| 744 | 744 | echo "\t\t\t\t\t</optgroup>\n"; |
| 745 | 745 | } |
| 746 | 746 | echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
@@ -749,10 +749,10 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : ''; |
| 751 | 751 | |
| 752 | - echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n"; |
|
| 752 | + echo "\t\t\t\t\t".'<option value="'.$row['id'].'"'.$selectedtext.'>'.$row['templatename']."</option>\n"; |
|
| 753 | 753 | $currentCategory = $thisCategory; |
| 754 | 754 | } |
| 755 | - if($thisCategory != '') { |
|
| 755 | + if ($thisCategory != '') { |
|
| 756 | 756 | echo "\t\t\t\t\t</optgroup>\n"; |
| 757 | 757 | } |
| 758 | 758 | ?> |
@@ -796,20 +796,20 @@ discard block |
||
| 796 | 796 | <td valign="top"> |
| 797 | 797 | <?php |
| 798 | 798 | $parentlookup = false; |
| 799 | - if(isset ($_REQUEST['id'])) { |
|
| 800 | - if($content['parent'] == 0) { |
|
| 799 | + if (isset ($_REQUEST['id'])) { |
|
| 800 | + if ($content['parent'] == 0) { |
|
| 801 | 801 | $parentname = $site_name; |
| 802 | 802 | } else { |
| 803 | 803 | $parentlookup = $content['parent']; |
| 804 | 804 | } |
| 805 | - } elseif(isset ($_REQUEST['pid'])) { |
|
| 806 | - if($_REQUEST['pid'] == 0) { |
|
| 805 | + } elseif (isset ($_REQUEST['pid'])) { |
|
| 806 | + if ($_REQUEST['pid'] == 0) { |
|
| 807 | 807 | $parentname = $site_name; |
| 808 | 808 | } else { |
| 809 | 809 | $parentlookup = $_REQUEST['pid']; |
| 810 | 810 | } |
| 811 | - } elseif(isset($_POST['parent'])) { |
|
| 812 | - if($_POST['parent'] == 0) { |
|
| 811 | + } elseif (isset($_POST['parent'])) { |
|
| 812 | + if ($_POST['parent'] == 0) { |
|
| 813 | 813 | $parentname = $site_name; |
| 814 | 814 | } else { |
| 815 | 815 | $parentlookup = $_POST['parent']; |
@@ -818,10 +818,10 @@ discard block |
||
| 818 | 818 | $parentname = $site_name; |
| 819 | 819 | $content['parent'] = 0; |
| 820 | 820 | } |
| 821 | - if($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 821 | + if ($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 822 | 822 | $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
| 823 | 823 | $parentname = $modx->db->getValue($rs); |
| 824 | - if(!$parentname) { |
|
| 824 | + if (!$parentname) { |
|
| 825 | 825 | $modx->webAlertAndQuit($_lang["error_no_parent"]); |
| 826 | 826 | } |
| 827 | 827 | } |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | }*/ |
| 864 | 864 | ?> |
| 865 | 865 | |
| 866 | - <?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?> |
|
| 866 | + <?php if ($content['type'] == 'document' || $modx->manager->action == '4') { ?> |
|
| 867 | 867 | <tr> |
| 868 | 868 | <td colspan="2"> |
| 869 | 869 | <hr> |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | <?php |
| 877 | 877 | // invoke OnRichTextEditorRegister event |
| 878 | 878 | $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
| 879 | - if(is_array($evtOut)) { |
|
| 880 | - for($i = 0; $i < count($evtOut); $i++) { |
|
| 879 | + if (is_array($evtOut)) { |
|
| 880 | + for ($i = 0; $i < count($evtOut); $i++) { |
|
| 881 | 881 | $editor = $evtOut[$i]; |
| 882 | 882 | echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
| 883 | 883 | } |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | </div> |
| 889 | 889 | <div id="content_body"> |
| 890 | 890 | <?php |
| 891 | - if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 891 | + if (($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 892 | 892 | $htmlContent = $content['content']; |
| 893 | 893 | ?> |
| 894 | 894 | <div class="section-editor clearfix"> |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
| 902 | 902 | $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
| 903 | 903 | } else { |
| 904 | - echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n"; |
|
| 904 | + echo "\t".'<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>'."\n"; |
|
| 905 | 905 | } |
| 906 | 906 | ?> |
| 907 | 907 | </div> |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | if (($content['type'] == 'document' || $modx->manager->action == '4') || ($content['type'] == 'reference' || $modx->manager->action == 72)) { |
| 919 | 919 | $template = $default_template; |
| 920 | - $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int)$modx->config['group_tvs']; |
|
| 920 | + $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int) $modx->config['group_tvs']; |
|
| 921 | 921 | if (isset ($_REQUEST['newtemplate'])) { |
| 922 | 922 | $template = $_REQUEST['newtemplate']; |
| 923 | 923 | } else { |
@@ -945,10 +945,10 @@ discard block |
||
| 945 | 945 | ); |
| 946 | 946 | $sort = 'tvtpl.rank,tv.rank, tv.id'; |
| 947 | 947 | if ($group_tvs) { |
| 948 | - $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"' . $_lang['no_category'] . '") AS category, IFNULL(cat.rank,0) AS category_rank'; |
|
| 948 | + $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"'.$_lang['no_category'].'") AS category, IFNULL(cat.rank,0) AS category_rank'; |
|
| 949 | 949 | $from .= ' |
| 950 | - LEFT JOIN ' . $tbl_categories . ' AS cat ON cat.id=tv.category'; |
|
| 951 | - $sort = 'cat.rank,cat.id,' . $sort; |
|
| 950 | + LEFT JOIN ' . $tbl_categories.' AS cat ON cat.id=tv.category'; |
|
| 951 | + $sort = 'cat.rank,cat.id,'.$sort; |
|
| 952 | 952 | } |
| 953 | 953 | $where = vsprintf("tvtpl.templateid='%s' AND (1='%s' OR ISNULL(tva.documentgroup) %s)", $vs); |
| 954 | 954 | $rs = $modx->db->select($field, $from, $where, $sort); |
@@ -957,37 +957,37 @@ discard block |
||
| 957 | 957 | <!-- Template Variables -->' . "\n"; |
| 958 | 958 | if (!$group_tvs) { |
| 959 | 959 | $templateVariables .= ' |
| 960 | - <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'] . '</div> |
|
| 960 | + <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'].'</div> |
|
| 961 | 961 | <div class="sectionBody tmplvars"> |
| 962 | 962 | <table>'; |
| 963 | 963 | } else if ($group_tvs == 2) { |
| 964 | 964 | $templateVariables .= ' |
| 965 | 965 | <div class="tab-section"> |
| 966 | - <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'] . '</div> |
|
| 966 | + <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'].'</div> |
|
| 967 | 967 | <div class="tab-pane" id="paneTemplateVariables"> |
| 968 | 968 | <script type="text/javascript"> |
| 969 | - tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
|
| 969 | + tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').'); |
|
| 970 | 970 | </script>'; |
| 971 | 971 | } else if ($group_tvs == 3) { |
| 972 | 972 | $templateVariables .= ' |
| 973 | 973 | <div id="templateVariables" class="tab-page tmplvars"> |
| 974 | - <h2 class="tab">' . $_lang['settings_templvars'] . '</h2> |
|
| 974 | + <h2 class="tab">' . $_lang['settings_templvars'].'</h2> |
|
| 975 | 975 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>'; |
| 976 | 976 | } else if ($group_tvs == 4) { |
| 977 | 977 | $templateVariables .= ' |
| 978 | 978 | <div id="templateVariables" class="tab-page tmplvars"> |
| 979 | - <h2 class="tab">' . $_lang['settings_templvars'] . '</h2> |
|
| 979 | + <h2 class="tab">' . $_lang['settings_templvars'].'</h2> |
|
| 980 | 980 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script> |
| 981 | 981 | |
| 982 | 982 | <div class="tab-pane" id="paneTemplateVariables"> |
| 983 | 983 | <script type="text/javascript"> |
| 984 | - tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
|
| 984 | + tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').'); |
|
| 985 | 985 | </script>'; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | $tvsArray = $modx->db->makeArray($rs, 'name'); |
| 989 | - require_once(MODX_MANAGER_PATH . 'includes/tmplvars.inc.php'); |
|
| 990 | - require_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); |
|
| 989 | + require_once(MODX_MANAGER_PATH.'includes/tmplvars.inc.php'); |
|
| 990 | + require_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php'); |
|
| 991 | 991 | $i = 0; |
| 992 | 992 | $tab = ''; |
| 993 | 993 | foreach ($tvsArray as $row) { |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | if ($group_tvs == 1 || $group_tvs == 3) { |
| 996 | 996 | if ($i === 0) { |
| 997 | 997 | $templateVariables .= ' |
| 998 | - <div class="tab-section" id="tabTV_' . $row['category_id'] . '"> |
|
| 999 | - <div class="tab-header">' . $row['category'] . '</div> |
|
| 998 | + <div class="tab-section" id="tabTV_' . $row['category_id'].'"> |
|
| 999 | + <div class="tab-header">' . $row['category'].'</div> |
|
| 1000 | 1000 | <div class="tab-body tmplvars"> |
| 1001 | 1001 | <table>' . "\n"; |
| 1002 | 1002 | } else { |
@@ -1005,17 +1005,17 @@ discard block |
||
| 1005 | 1005 | </div> |
| 1006 | 1006 | </div> |
| 1007 | 1007 | |
| 1008 | - <div class="tab-section" id="tabTV_' . $row['category_id'] . '"> |
|
| 1009 | - <div class="tab-header">' . $row['category'] . '</div> |
|
| 1008 | + <div class="tab-section" id="tabTV_' . $row['category_id'].'"> |
|
| 1009 | + <div class="tab-header">' . $row['category'].'</div> |
|
| 1010 | 1010 | <div class="tab-body tmplvars"> |
| 1011 | 1011 | <table>'; |
| 1012 | 1012 | } |
| 1013 | 1013 | } else if ($group_tvs == 2 || $group_tvs == 4) { |
| 1014 | 1014 | if ($i === 0) { |
| 1015 | 1015 | $templateVariables .= ' |
| 1016 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1017 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1018 | - <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1016 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1017 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1018 | + <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1019 | 1019 | |
| 1020 | 1020 | <div class="tab-body tmplvars"> |
| 1021 | 1021 | <table>'; |
@@ -1025,9 +1025,9 @@ discard block |
||
| 1025 | 1025 | </div> |
| 1026 | 1026 | </div> |
| 1027 | 1027 | |
| 1028 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1029 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1030 | - <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1028 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1029 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1030 | + <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1031 | 1031 | |
| 1032 | 1032 | <div class="tab-body tmplvars"> |
| 1033 | 1033 | <table>'; |
@@ -1035,18 +1035,18 @@ discard block |
||
| 1035 | 1035 | } else if ($group_tvs == 5) { |
| 1036 | 1036 | if ($i === 0) { |
| 1037 | 1037 | $templateVariables .= ' |
| 1038 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1039 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1040 | - <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1038 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1039 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1040 | + <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1041 | 1041 | <table>'; |
| 1042 | 1042 | } else { |
| 1043 | 1043 | $templateVariables .= ' |
| 1044 | 1044 | </table> |
| 1045 | 1045 | </div> |
| 1046 | 1046 | |
| 1047 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1048 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1049 | - <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1047 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1048 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1049 | + <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1050 | 1050 | |
| 1051 | 1051 | <table>'; |
| 1052 | 1052 | } |
@@ -1064,8 +1064,8 @@ discard block |
||
| 1064 | 1064 | $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor']; |
| 1065 | 1065 | }; |
| 1066 | 1066 | // Add richtext editor to the list |
| 1067 | - $richtexteditorIds[$editor][] = "tv" . $row['id']; |
|
| 1068 | - $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions; |
|
| 1067 | + $richtexteditorIds[$editor][] = "tv".$row['id']; |
|
| 1068 | + $richtexteditorOptions[$editor]["tv".$row['id']] = $tvOptions; |
|
| 1069 | 1069 | } |
| 1070 | 1070 | // splitter |
| 1071 | 1071 | if ($group_tvs) { |
@@ -1079,24 +1079,24 @@ discard block |
||
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | // post back value |
| 1082 | - if (array_key_exists('tv' . $row['id'], $_POST)) { |
|
| 1083 | - if (is_array($_POST['tv' . $row['id']])) { |
|
| 1084 | - $tvPBV = implode('||', $_POST['tv' . $row['id']]); |
|
| 1082 | + if (array_key_exists('tv'.$row['id'], $_POST)) { |
|
| 1083 | + if (is_array($_POST['tv'.$row['id']])) { |
|
| 1084 | + $tvPBV = implode('||', $_POST['tv'.$row['id']]); |
|
| 1085 | 1085 | } else { |
| 1086 | - $tvPBV = $_POST['tv' . $row['id']]; |
|
| 1086 | + $tvPBV = $_POST['tv'.$row['id']]; |
|
| 1087 | 1087 | } |
| 1088 | 1088 | } else { |
| 1089 | 1089 | $tvPBV = $row['value']; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">' . $row['description'] . '</span>' : ''; |
|
| 1093 | - $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">(' . $_lang['tmplvars_inherited'] . ')</span>' : ''; |
|
| 1094 | - $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*' . $row['name'] . '*]</small>' : ''; |
|
| 1092 | + $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">'.$row['description'].'</span>' : ''; |
|
| 1093 | + $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">('.$_lang['tmplvars_inherited'].')</span>' : ''; |
|
| 1094 | + $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*'.$row['name'].'*]</small>' : ''; |
|
| 1095 | 1095 | |
| 1096 | 1096 | $templateVariables .= ' |
| 1097 | 1097 | <tr> |
| 1098 | - <td><span class="warning">' . $row['caption'] . $tvName . '</span>' . $tvDescription . $tvInherited . '</td> |
|
| 1099 | - <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '') . '">' . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . '</div></td> |
|
| 1098 | + <td><span class="warning">' . $row['caption'].$tvName.'</span>'.$tvDescription.$tvInherited.'</td> |
|
| 1099 | + <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '').'">'.renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray).'</div></td> |
|
| 1100 | 1100 | </tr>'; |
| 1101 | 1101 | |
| 1102 | 1102 | $tab = $row['category_id']; |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | <?php |
| 1192 | 1192 | |
| 1193 | - if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1193 | + if ($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1194 | 1194 | ?> |
| 1195 | 1195 | <tr> |
| 1196 | 1196 | <td> |
@@ -1213,13 +1213,13 @@ discard block |
||
| 1213 | 1213 | <td> |
| 1214 | 1214 | <select name="contentType" class="inputBox" onchange="documentDirty=true;"> |
| 1215 | 1215 | <?php |
| 1216 | - if(!$content['contentType']) { |
|
| 1216 | + if (!$content['contentType']) { |
|
| 1217 | 1217 | $content['contentType'] = 'text/html'; |
| 1218 | 1218 | } |
| 1219 | 1219 | $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
| 1220 | 1220 | $ct = explode(",", $custom_contenttype); |
| 1221 | - for($i = 0; $i < count($ct); $i++) { |
|
| 1222 | - echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
|
| 1221 | + for ($i = 0; $i < count($ct); $i++) { |
|
| 1222 | + echo "\t\t\t\t\t".'<option value="'.$ct[$i].'"'.($content['contentType'] == $ct[$i] ? ' selected="selected"' : '').'>'.$ct[$i]."</option>\n"; |
|
| 1223 | 1223 | } |
| 1224 | 1224 | ?> |
| 1225 | 1225 | </select> |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | </tr> |
| 1246 | 1246 | <?php |
| 1247 | 1247 | } else { |
| 1248 | - if($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1248 | + if ($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1249 | 1249 | // non-admin managers creating or editing a document resource |
| 1250 | 1250 | ?> |
| 1251 | 1251 | <input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" /> |
@@ -1345,15 +1345,15 @@ discard block |
||
| 1345 | 1345 | <?php |
| 1346 | 1346 | /******************************* |
| 1347 | 1347 | * Document Access Permissions */ |
| 1348 | - if($use_udperms == 1) { |
|
| 1348 | + if ($use_udperms == 1) { |
|
| 1349 | 1349 | $groupsarray = array(); |
| 1350 | 1350 | $sql = ''; |
| 1351 | 1351 | |
| 1352 | 1352 | $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
| 1353 | - if($documentId > 0) { |
|
| 1353 | + if ($documentId > 0) { |
|
| 1354 | 1354 | // Load up, the permissions from the parent (if new document) or existing document |
| 1355 | 1355 | $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
| 1356 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1356 | + while ($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'].','.$currentgroup['id']; |
|
| 1357 | 1357 | |
| 1358 | 1358 | // Load up the current permissions and names |
| 1359 | 1359 | $vs = array( |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | // retain selected doc groups between post |
| 1372 | - if(isset($_POST['docgroups'])) { |
|
| 1372 | + if (isset($_POST['docgroups'])) { |
|
| 1373 | 1373 | $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
| 1374 | 1374 | } |
| 1375 | 1375 | |
@@ -1388,26 +1388,26 @@ discard block |
||
| 1388 | 1388 | $permissions_no = 0; // count permissions the current mgr user doesn't have |
| 1389 | 1389 | |
| 1390 | 1390 | // Loop through the permissions list |
| 1391 | - while($row = $modx->db->getRow($rs)) { |
|
| 1391 | + while ($row = $modx->db->getRow($rs)) { |
|
| 1392 | 1392 | |
| 1393 | 1393 | // Create an inputValue pair (group ID and group link (if it exists)) |
| 1394 | - $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1395 | - $inputId = 'group-' . $row['id']; |
|
| 1394 | + $inputValue = $row['id'].','.($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1395 | + $inputId = 'group-'.$row['id']; |
|
| 1396 | 1396 | |
| 1397 | 1397 | $checked = in_array($inputValue, $groupsarray); |
| 1398 | - if($checked) { |
|
| 1398 | + if ($checked) { |
|
| 1399 | 1399 | $notPublic = true; |
| 1400 | 1400 | } // Mark as private access (either web or manager) |
| 1401 | 1401 | |
| 1402 | 1402 | // Skip the access permission if the user doesn't have access... |
| 1403 | - if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1403 | + if ((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1404 | 1404 | continue; |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | 1407 | // Setup attributes for this Input box |
| 1408 | 1408 | $inputAttributes['id'] = $inputId; |
| 1409 | 1409 | $inputAttributes['value'] = $inputValue; |
| 1410 | - if($checked) { |
|
| 1410 | + if ($checked) { |
|
| 1411 | 1411 | $inputAttributes['checked'] = 'checked'; |
| 1412 | 1412 | } else { |
| 1413 | 1413 | unset($inputAttributes['checked']); |
@@ -1415,10 +1415,10 @@ discard block |
||
| 1415 | 1415 | |
| 1416 | 1416 | // Create attribute string list |
| 1417 | 1417 | $inputString = array(); |
| 1418 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1418 | + foreach ($inputAttributes as $k => $v) $inputString[] = $k.'="'.$v.'"'; |
|
| 1419 | 1419 | |
| 1420 | 1420 | // Make the <input> HTML |
| 1421 | - $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
|
| 1421 | + $inputHTML = '<input '.implode(' ', $inputString).' />'; |
|
| 1422 | 1422 | |
| 1423 | 1423 | // does user have this permission? |
| 1424 | 1424 | $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
@@ -1429,23 +1429,23 @@ discard block |
||
| 1429 | 1429 | $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
| 1430 | 1430 | $rsp = $modx->db->select('COUNT(mg.id)', $from, $where); |
| 1431 | 1431 | $count = $modx->db->getValue($rsp); |
| 1432 | - if($count > 0) { |
|
| 1432 | + if ($count > 0) { |
|
| 1433 | 1433 | ++$permissions_yes; |
| 1434 | 1434 | } else { |
| 1435 | 1435 | ++$permissions_no; |
| 1436 | 1436 | } |
| 1437 | - $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
|
| 1437 | + $permissions[] = "\t\t".'<li>'.$inputHTML.'<label for="'.$inputId.'">'.$row['name'].'</label></li>'; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
| 1440 | - if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1440 | + if ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1441 | 1441 | $permissions = array(); |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | // See if the Access Permissions section is worth displaying... |
| 1445 | - if(!empty($permissions)) { |
|
| 1445 | + if (!empty($permissions)) { |
|
| 1446 | 1446 | // Add the "All Document Groups" item if we have rights in both contexts |
| 1447 | - if($isManager && $isWeb) { |
|
| 1448 | - array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>'); |
|
| 1447 | + if ($isManager && $isWeb) { |
|
| 1448 | + array_unshift($permissions, "\t\t".'<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"'.(!$notPublic ? ' checked="checked"' : '').' onclick="makePublic(true);" /><label for="groupall" class="warning">'.$_lang['all_doc_groups'].'</label></li>'); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | // Output the permissions list... |
| 1451 | 1451 | ?> |
@@ -1478,12 +1478,12 @@ discard block |
||
| 1478 | 1478 | </script> |
| 1479 | 1479 | <p><?= $_lang['access_permissions_docs_message'] ?></p> |
| 1480 | 1480 | <ul> |
| 1481 | - <?= implode("\n", $permissions) . "\n" ?> |
|
| 1481 | + <?= implode("\n", $permissions)."\n" ?> |
|
| 1482 | 1482 | </ul> |
| 1483 | 1483 | </div><!--div class="tab-page" id="tabAccess"--> |
| 1484 | 1484 | <?php |
| 1485 | 1485 | } // !empty($permissions) |
| 1486 | - elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1486 | + elseif ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1487 | 1487 | ?> |
| 1488 | 1488 | <p><?= $_lang["access_permissions_docs_collision"] ?></p> |
| 1489 | 1489 | <?php |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | 'template' => $content['template'] |
| 1504 | 1504 | )); |
| 1505 | 1505 | |
| 1506 | - if(is_array($evtOut)) { |
|
| 1506 | + if (is_array($evtOut)) { |
|
| 1507 | 1507 | echo implode('', $evtOut); |
| 1508 | 1508 | } |
| 1509 | 1509 | ?> |
@@ -1516,52 +1516,52 @@ discard block |
||
| 1516 | 1516 | storeCurTemplate(); |
| 1517 | 1517 | </script> |
| 1518 | 1518 | <?php |
| 1519 | -if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) { |
|
| 1520 | - if(is_array($richtexteditorIds)) { |
|
| 1521 | - foreach($richtexteditorIds as $editor => $elements) { |
|
| 1519 | +if (($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) { |
|
| 1520 | + if (is_array($richtexteditorIds)) { |
|
| 1521 | + foreach ($richtexteditorIds as $editor => $elements) { |
|
| 1522 | 1522 | // invoke OnRichTextEditorInit event |
| 1523 | 1523 | $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
| 1524 | 1524 | 'editor' => $editor, |
| 1525 | 1525 | 'elements' => $elements, |
| 1526 | 1526 | 'options' => $richtexteditorOptions[$editor] |
| 1527 | 1527 | )); |
| 1528 | - if(is_array($evtOut)) { |
|
| 1528 | + if (is_array($evtOut)) { |
|
| 1529 | 1529 | echo implode('', $evtOut); |
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | -function getDefaultTemplate() { |
|
| 1535 | +function getDefaultTemplate(){ |
|
| 1536 | 1536 | global $modx; |
| 1537 | 1537 | |
| 1538 | - switch($modx->config['auto_template_logic']) { |
|
| 1538 | + switch ($modx->config['auto_template_logic']) { |
|
| 1539 | 1539 | case 'sibling': |
| 1540 | - if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1540 | + if (!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1541 | 1541 | $site_start = $modx->config['site_start']; |
| 1542 | 1542 | $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
| 1543 | 1543 | $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
| 1544 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1544 | + if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1545 | 1545 | $default_template = $sibl[0]['template']; |
| 1546 | 1546 | } |
| 1547 | 1547 | } else { |
| 1548 | 1548 | $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
| 1549 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1549 | + if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1550 | 1550 | $default_template = $sibl[0]['template']; |
| 1551 | 1551 | } else { |
| 1552 | 1552 | $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
| 1553 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1553 | + if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | 1554 | $default_template = $sibl[0]['template']; |
| 1555 | 1555 | } |
| 1556 | 1556 | } |
| 1557 | 1557 | } |
| 1558 | - if(isset($default_template)) { |
|
| 1558 | + if (isset($default_template)) { |
|
| 1559 | 1559 | break; |
| 1560 | 1560 | } // If $default_template could not be determined, fall back / through to "parent"-mode |
| 1561 | 1561 | case 'parent': |
| 1562 | - if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1562 | + if (isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1563 | 1563 | $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
| 1564 | - if(isset($parent['template'])) { |
|
| 1564 | + if (isset($parent['template'])) { |
|
| 1565 | 1565 | $default_template = $parent['template']; |
| 1566 | 1566 | } |
| 1567 | 1567 | } |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | default: // default_template is already set |
| 1571 | 1571 | $default_template = $modx->config['default_template']; |
| 1572 | 1572 | } |
| 1573 | - if(!isset($default_template)) { |
|
| 1573 | + if (!isset($default_template)) { |
|
| 1574 | 1574 | $default_template = $modx->config['default_template']; |
| 1575 | 1575 | } // default_template is already set |
| 1576 | 1576 | |