| @@ -171,16 +171,16 @@ | ||
| 171 | 171 | |
| 172 | 172 |          if (is_dir($source)) { // resource is a collection | 
| 173 | 173 |              switch ($options["depth"]) { | 
| 174 | - case "infinity": // valid | |
| 175 | - break; | |
| 176 | - case "0": // valid for COPY only | |
| 177 | -                if ($del) { // MOVE? | |
| 178 | - return "400 Bad request"; | |
| 179 | - } | |
| 180 | - break; | |
| 181 | - case "1": // invalid for both COPY and MOVE | |
| 182 | - default: | |
| 183 | - return "400 Bad request"; | |
| 174 | + case "infinity": // valid | |
| 175 | + break; | |
| 176 | + case "0": // valid for COPY only | |
| 177 | +                	if ($del) { // MOVE? | |
| 178 | + return "400 Bad request"; | |
| 179 | + } | |
| 180 | + break; | |
| 181 | + case "1": // invalid for both COPY and MOVE | |
| 182 | + default: | |
| 183 | + return "400 Bad request"; | |
| 184 | 184 | } | 
| 185 | 185 | } | 
| 186 | 186 | |
| @@ -179,16 +179,16 @@ | ||
| 179 | 179 |          } else if ($ns == "DAV:") { | 
| 180 | 180 | // parse only the essential tags | 
| 181 | 181 |              switch ($tag) { | 
| 182 | - case "write": | |
| 183 | - $this->locktype = $tag; | |
| 184 | - break; | |
| 185 | - case "exclusive": | |
| 186 | - case "shared": | |
| 187 | - $this->lockscope = $tag; | |
| 188 | - break; | |
| 189 | - case "owner": | |
| 190 | - $this->collect_owner = true; | |
| 191 | - break; | |
| 182 | + case "write": | |
| 183 | + $this->locktype = $tag; | |
| 184 | + break; | |
| 185 | + case "exclusive": | |
| 186 | + case "shared": | |
| 187 | + $this->lockscope = $tag; | |
| 188 | + break; | |
| 189 | + case "owner": | |
| 190 | + $this->collect_owner = true; | |
| 191 | + break; | |
| 192 | 192 | } | 
| 193 | 193 | } | 
| 194 | 194 | } | 
| @@ -816,34 +816,34 @@ discard block | ||
| 816 | 816 | // this can happen if we have allprop and prop in one propfind: | 
| 817 | 817 | // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop | 
| 818 | 818 |  	                switch(is_array($props) ? $props[0] : $props) { | 
| 819 | - case "all": | |
| 820 | - // nothing to remove | |
| 821 | - break; | |
| 822 | - | |
| 823 | - case "names": | |
| 824 | - // only the names of all existing properties were requested | |
| 825 | - // so we remove all values | |
| 826 | - unset($prop["val"]); | |
| 827 | - break; | |
| 828 | - | |
| 829 | - default: | |
| 830 | - $found = false; | |
| 831 | - | |
| 832 | - // search property name in requested properties | |
| 833 | -	                    foreach ((array)$props as $reqprop) { | |
| 834 | - if ( $reqprop["name"] == $prop["name"] | |
| 835 | -	                               && @$reqprop["xmlns"] == $prop["ns"]) { | |
| 836 | - $found = true; | |
| 837 | - break; | |
| 838 | - } | |
| 839 | - } | |
| 840 | - | |
| 841 | - // unset property and continue with next one if not found/requested | |
| 842 | -	                    if (!$found) { | |
| 843 | - $prop=""; | |
| 844 | - continue(2); | |
| 845 | - } | |
| 846 | - break; | |
| 819 | + case "all": | |
| 820 | + // nothing to remove | |
| 821 | + break; | |
| 822 | + | |
| 823 | + case "names": | |
| 824 | + // only the names of all existing properties were requested | |
| 825 | + // so we remove all values | |
| 826 | + unset($prop["val"]); | |
| 827 | + break; | |
| 828 | + | |
| 829 | + default: | |
| 830 | + $found = false; | |
| 831 | + | |
| 832 | + // search property name in requested properties | |
| 833 | +	                    	foreach ((array)$props as $reqprop) { | |
| 834 | + if ( $reqprop["name"] == $prop["name"] | |
| 835 | +	                               	&& @$reqprop["xmlns"] == $prop["ns"]) { | |
| 836 | + $found = true; | |
| 837 | + break; | |
| 838 | + } | |
| 839 | + } | |
| 840 | + | |
| 841 | + // unset property and continue with next one if not found/requested | |
| 842 | +	                    	if (!$found) { | |
| 843 | + $prop=""; | |
| 844 | + continue(2); | |
| 845 | + } | |
| 846 | + break; | |
| 847 | 847 | } | 
| 848 | 848 | |
| 849 | 849 | // namespace handling | 
| @@ -964,49 +964,49 @@ discard block | ||
| 964 | 964 |                      } else if ($prop["ns"] == "DAV:") { | 
| 965 | 965 | // some WebDAV properties need special treatment | 
| 966 | 966 |                          switch ($prop["name"]) { | 
| 967 | - case "creationdate": | |
| 968 | - echo ' <'.($this->crrnd?'':'D:')."creationdate ns0:dt=\"dateTime.tz\">" | |
| 969 | -                                . gmdate("Y-m-d\\TH:i:s\\Z", $prop['val']) | |
| 970 | - . '</'.($this->crrnd?'':'D:')."creationdate>\n"; | |
| 971 | - break; | |
| 972 | - case "getlastmodified": | |
| 973 | - echo ' <'.($this->crrnd?'':'D:')."getlastmodified ns0:dt=\"dateTime.rfc1123\">" | |
| 974 | -                                . gmdate("D, d M Y H:i:s ", $prop['val']) | |
| 975 | - . "GMT</".($this->crrnd?'':'D:')."getlastmodified>\n"; | |
| 976 | - break; | |
| 977 | - case "supportedlock": | |
| 978 | - echo ' <'.($this->crrnd?'':'D:')."supportedlock>$prop[val]</".($this->crrnd?'':'D:')."supportedlock>\n"; | |
| 979 | - break; | |
| 980 | - case "lockdiscovery": | |
| 981 | - echo ' <'.($this->crrnd?'':'D:')."lockdiscovery>\n"; | |
| 982 | - echo $prop["val"]; | |
| 983 | - echo ' </'.($this->crrnd?'':'D:')."lockdiscovery>\n"; | |
| 984 | - break; | |
| 985 | - // the following are non-standard Microsoft extensions to the DAV namespace | |
| 986 | - case "lastaccessed": | |
| 987 | - echo ' <'.($this->crrnd?'':'D:')."lastaccessed ns0:dt=\"dateTime.rfc1123\">" | |
| 988 | -                                . gmdate("D, d M Y H:i:s ", $prop['val']) | |
| 989 | - . 'GMT</'.($this->crrnd?'':'D:')."lastaccessed>\n"; | |
| 990 | - break; | |
| 991 | - case "ishidden": | |
| 992 | - echo ' <'.($this->crrnd?'':'D:')."ishidden>" | |
| 993 | - . is_string($prop['val']) ? $prop['val'] : ($prop['val'] ? 'true' : 'false') | |
| 994 | - . '</'.($this->crrnd?'':'D:')."</D:ishidden>\n"; | |
| 995 | - break; | |
| 996 | - default: | |
| 997 | - $ns_defs = ''; | |
| 998 | - if (is_array($prop['val'])) | |
| 999 | -                            { | |
| 1000 | - $hns_hash = $ns_hash; | |
| 1001 | - $val = $this->_hierarchical_prop_encode($prop['val'], 'DAV:', $ns_defs, $hns_hash); | |
| 1002 | -                            } elseif (isset($prop['raw'])) { | |
| 1003 | -                            	$val = $this->_prop_encode('<![CDATA['.$prop['val'].']]>'); | |
| 1004 | -                            } else { | |
| 1005 | - $val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8')); | |
| 1006 | - } | |
| 1007 | - echo ' <'.($this->crrnd?'':'D:')."$prop[name]$ns_defs>$val". | |
| 1008 | - '</'.($this->crrnd?'':'D:')."$prop[name]>\n"; | |
| 1009 | - break; | |
| 967 | + case "creationdate": | |
| 968 | + echo ' <'.($this->crrnd?'':'D:')."creationdate ns0:dt=\"dateTime.tz\">" | |
| 969 | +                                	. gmdate("Y-m-d\\TH:i:s\\Z", $prop['val']) | |
| 970 | + . '</'.($this->crrnd?'':'D:')."creationdate>\n"; | |
| 971 | + break; | |
| 972 | + case "getlastmodified": | |
| 973 | + echo ' <'.($this->crrnd?'':'D:')."getlastmodified ns0:dt=\"dateTime.rfc1123\">" | |
| 974 | +                                	. gmdate("D, d M Y H:i:s ", $prop['val']) | |
| 975 | + . "GMT</".($this->crrnd?'':'D:')."getlastmodified>\n"; | |
| 976 | + break; | |
| 977 | + case "supportedlock": | |
| 978 | + echo ' <'.($this->crrnd?'':'D:')."supportedlock>$prop[val]</".($this->crrnd?'':'D:')."supportedlock>\n"; | |
| 979 | + break; | |
| 980 | + case "lockdiscovery": | |
| 981 | + echo ' <'.($this->crrnd?'':'D:')."lockdiscovery>\n"; | |
| 982 | + echo $prop["val"]; | |
| 983 | + echo ' </'.($this->crrnd?'':'D:')."lockdiscovery>\n"; | |
| 984 | + break; | |
| 985 | + // the following are non-standard Microsoft extensions to the DAV namespace | |
| 986 | + case "lastaccessed": | |
| 987 | + echo ' <'.($this->crrnd?'':'D:')."lastaccessed ns0:dt=\"dateTime.rfc1123\">" | |
| 988 | +                                	. gmdate("D, d M Y H:i:s ", $prop['val']) | |
| 989 | + . 'GMT</'.($this->crrnd?'':'D:')."lastaccessed>\n"; | |
| 990 | + break; | |
| 991 | + case "ishidden": | |
| 992 | + echo ' <'.($this->crrnd?'':'D:')."ishidden>" | |
| 993 | + . is_string($prop['val']) ? $prop['val'] : ($prop['val'] ? 'true' : 'false') | |
| 994 | + . '</'.($this->crrnd?'':'D:')."</D:ishidden>\n"; | |
| 995 | + break; | |
| 996 | + default: | |
| 997 | + $ns_defs = ''; | |
| 998 | + if (is_array($prop['val'])) | |
| 999 | +                            	{ | |
| 1000 | + $hns_hash = $ns_hash; | |
| 1001 | + $val = $this->_hierarchical_prop_encode($prop['val'], 'DAV:', $ns_defs, $hns_hash); | |
| 1002 | +                            	} elseif (isset($prop['raw'])) { | |
| 1003 | +                            		$val = $this->_prop_encode('<![CDATA['.$prop['val'].']]>'); | |
| 1004 | +                            	} else { | |
| 1005 | + $val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8')); | |
| 1006 | + } | |
| 1007 | + echo ' <'.($this->crrnd?'':'D:')."$prop[name]$ns_defs>$val". | |
| 1008 | + '</'.($this->crrnd?'':'D:')."$prop[name]>\n"; | |
| 1009 | + break; | |
| 1010 | 1010 | } | 
| 1011 | 1011 |                      } else { | 
| 1012 | 1012 | // allow multiple values and attributes, required eg. for caldav:supported-calendar-component-set | 
| @@ -1761,9 +1761,9 @@ discard block | ||
| 1761 | 1761 |              foreach ($this->_SERVER as $key => $val) { | 
| 1762 | 1762 | if (strncmp($key, "HTTP_CONTENT", 11)) continue; | 
| 1763 | 1763 |                  switch ($key) { | 
| 1764 | - case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11 | |
| 1765 | - switch($this->_SERVER['HTTP_CONTENT_ENCODING']) | |
| 1766 | -		        	{ | |
| 1764 | + case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11 | |
| 1765 | + switch($this->_SERVER['HTTP_CONTENT_ENCODING']) | |
| 1766 | +		        		{ | |
| 1767 | 1767 | case 'gzip': | 
| 1768 | 1768 | case 'deflate': //zlib | 
| 1769 | 1769 |  		        			if (extension_loaded('zlib')) break; | 
| @@ -1772,67 +1772,67 @@ discard block | ||
| 1772 | 1772 |  					        $this->http_status('415 Unsupported Media Type'); | 
| 1773 | 1773 | echo "The service does not support '$val' content encoding"; | 
| 1774 | 1774 | return; | 
| 1775 | - } | |
| 1775 | + } | |
| 1776 | 1776 | break; | 
| 1777 | 1777 | |
| 1778 | - case 'HTTP_CONTENT_LANGUAGE': // RFC 2616 14.12 | |
| 1779 | - // we assume it is not critical if this one is ignored | |
| 1780 | - // in the actual PUT implementation ... | |
| 1781 | - $options["content_language"] = $val; | |
| 1782 | - break; | |
| 1778 | + case 'HTTP_CONTENT_LANGUAGE': // RFC 2616 14.12 | |
| 1779 | + // we assume it is not critical if this one is ignored | |
| 1780 | + // in the actual PUT implementation ... | |
| 1781 | + $options["content_language"] = $val; | |
| 1782 | + break; | |
| 1783 | 1783 | |
| 1784 | - case 'HTTP_CONTENT_LENGTH': | |
| 1785 | - // defined on IIS and has the same value as CONTENT_LENGTH | |
| 1786 | - break; | |
| 1784 | + case 'HTTP_CONTENT_LENGTH': | |
| 1785 | + // defined on IIS and has the same value as CONTENT_LENGTH | |
| 1786 | + break; | |
| 1787 | 1787 | |
| 1788 | - case 'HTTP_CONTENT_LOCATION': // RFC 2616 14.14 | |
| 1789 | - /* The meaning of the Content-Location header in PUT | |
| 1788 | + case 'HTTP_CONTENT_LOCATION': // RFC 2616 14.14 | |
| 1789 | + /* The meaning of the Content-Location header in PUT | |
| 1790 | 1790 | or POST requests is undefined; servers are free | 
| 1791 | 1791 | to ignore it in those cases. */ | 
| 1792 | - break; | |
| 1793 | - | |
| 1794 | - case 'HTTP_CONTENT_RANGE': // RFC 2616 14.16 | |
| 1795 | - // single byte range requests are supported | |
| 1796 | - // the header format is also specified in RFC 2616 14.16 | |
| 1797 | - // TODO we have to ensure that implementations support this or send 501 instead | |
| 1798 | - $matches = null; | |
| 1799 | -                    if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) { | |
| 1800 | -                        $this->http_status("400 bad request"); | |
| 1801 | - echo "The service does only support single byte ranges"; | |
| 1802 | - return; | |
| 1803 | - } | |
| 1804 | - | |
| 1805 | -                    $range = array("start" => $matches[1], "end" => $matches[2]); | |
| 1806 | -                    if (is_numeric($matches[3])) { | |
| 1807 | - $range["total_length"] = $matches[3]; | |
| 1808 | - } | |
| 1809 | - | |
| 1810 | -                    if (!isset($options['ranges'])) { | |
| 1811 | - $options['ranges'] = array(); | |
| 1812 | - } | |
| 1813 | - | |
| 1814 | - $options["ranges"][] = $range; | |
| 1815 | - | |
| 1816 | - // TODO make sure the implementation supports partial PUT | |
| 1817 | - // this has to be done in advance to avoid data being overwritten | |
| 1818 | - // on implementations that do not support this ... | |
| 1819 | - break; | |
| 1820 | - | |
| 1821 | - case 'HTTP_CONTENT_TYPE': | |
| 1822 | - // defined on IIS and has the same value as CONTENT_TYPE | |
| 1823 | - break; | |
| 1824 | - | |
| 1825 | - case 'HTTP_CONTENT_MD5': // RFC 2616 14.15 | |
| 1826 | - // TODO: maybe we can just pretend here? | |
| 1827 | -                    $this->http_status("501 not implemented"); | |
| 1828 | - echo "The service does not support content MD5 checksum verification"; | |
| 1829 | - return; | |
| 1830 | - | |
| 1831 | - default: | |
| 1832 | - // any other unknown Content-* headers | |
| 1833 | -                    $this->http_status("501 not implemented"); | |
| 1834 | - echo "The service does not support '$key'"; | |
| 1835 | - return; | |
| 1792 | + break; | |
| 1793 | + | |
| 1794 | + case 'HTTP_CONTENT_RANGE': // RFC 2616 14.16 | |
| 1795 | + // single byte range requests are supported | |
| 1796 | + // the header format is also specified in RFC 2616 14.16 | |
| 1797 | + // TODO we have to ensure that implementations support this or send 501 instead | |
| 1798 | + $matches = null; | |
| 1799 | +                    	if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) { | |
| 1800 | +                        	$this->http_status("400 bad request"); | |
| 1801 | + echo "The service does only support single byte ranges"; | |
| 1802 | + return; | |
| 1803 | + } | |
| 1804 | + | |
| 1805 | +                    	$range = array("start" => $matches[1], "end" => $matches[2]); | |
| 1806 | +                    	if (is_numeric($matches[3])) { | |
| 1807 | + $range["total_length"] = $matches[3]; | |
| 1808 | + } | |
| 1809 | + | |
| 1810 | +                    	if (!isset($options['ranges'])) { | |
| 1811 | + $options['ranges'] = array(); | |
| 1812 | + } | |
| 1813 | + | |
| 1814 | + $options["ranges"][] = $range; | |
| 1815 | + | |
| 1816 | + // TODO make sure the implementation supports partial PUT | |
| 1817 | + // this has to be done in advance to avoid data being overwritten | |
| 1818 | + // on implementations that do not support this ... | |
| 1819 | + break; | |
| 1820 | + | |
| 1821 | + case 'HTTP_CONTENT_TYPE': | |
| 1822 | + // defined on IIS and has the same value as CONTENT_TYPE | |
| 1823 | + break; | |
| 1824 | + | |
| 1825 | + case 'HTTP_CONTENT_MD5': // RFC 2616 14.15 | |
| 1826 | + // TODO: maybe we can just pretend here? | |
| 1827 | +                    	$this->http_status("501 not implemented"); | |
| 1828 | + echo "The service does not support content MD5 checksum verification"; | |
| 1829 | + return; | |
| 1830 | + | |
| 1831 | + default: | |
| 1832 | + // any other unknown Content-* headers | |
| 1833 | +                    	$this->http_status("501 not implemented"); | |
| 1834 | + echo "The service does not support '$key'"; | |
| 1835 | + return; | |
| 1836 | 1836 | } | 
| 1837 | 1837 | } | 
| 1838 | 1838 | |
| @@ -2390,34 +2390,34 @@ discard block | ||
| 2390 | 2390 | |
| 2391 | 2391 | // now it depends on what we found | 
| 2392 | 2392 |          switch ($c) { | 
| 2393 | - case "<": | |
| 2394 | - // URIs are enclosed in <...> | |
| 2395 | - $pos2 = strpos($string, ">", $pos); | |
| 2396 | - $uri = substr($string, $pos, $pos2 - $pos); | |
| 2397 | - $pos = $pos2 + 1; | |
| 2398 | -            return array("URI", $uri); | |
| 2399 | - | |
| 2400 | - case "[": | |
| 2401 | - //Etags are enclosed in [...] | |
| 2402 | -            if ($string{$pos} == "W") { | |
| 2403 | - $type = "ETAG_WEAK"; | |
| 2404 | - $pos += 2; | |
| 2405 | -            } else { | |
| 2406 | - $type = "ETAG_STRONG"; | |
| 2407 | - } | |
| 2408 | - $pos2 = strpos($string, "]", $pos); | |
| 2409 | - $etag = substr($string, $pos + 1, $pos2 - $pos - 2); | |
| 2410 | - $pos = $pos2 + 1; | |
| 2411 | - return array($type, $etag); | |
| 2412 | - | |
| 2413 | - case "N": | |
| 2414 | - // "N" indicates negation | |
| 2415 | - $pos += 2; | |
| 2416 | -            return array("NOT", "Not"); | |
| 2417 | - | |
| 2418 | - default: | |
| 2419 | - // anything else is passed verbatim char by char | |
| 2420 | -            return array("CHAR", $c); | |
| 2393 | + case "<": | |
| 2394 | + // URIs are enclosed in <...> | |
| 2395 | + $pos2 = strpos($string, ">", $pos); | |
| 2396 | + $uri = substr($string, $pos, $pos2 - $pos); | |
| 2397 | + $pos = $pos2 + 1; | |
| 2398 | +            	return array("URI", $uri); | |
| 2399 | + | |
| 2400 | + case "[": | |
| 2401 | + //Etags are enclosed in [...] | |
| 2402 | +            	if ($string{$pos} == "W") { | |
| 2403 | + $type = "ETAG_WEAK"; | |
| 2404 | + $pos += 2; | |
| 2405 | +            	} else { | |
| 2406 | + $type = "ETAG_STRONG"; | |
| 2407 | + } | |
| 2408 | + $pos2 = strpos($string, "]", $pos); | |
| 2409 | + $etag = substr($string, $pos + 1, $pos2 - $pos - 2); | |
| 2410 | + $pos = $pos2 + 1; | |
| 2411 | + return array($type, $etag); | |
| 2412 | + | |
| 2413 | + case "N": | |
| 2414 | + // "N" indicates negation | |
| 2415 | + $pos += 2; | |
| 2416 | +            	return array("NOT", "Not"); | |
| 2417 | + | |
| 2418 | + default: | |
| 2419 | + // anything else is passed verbatim char by char | |
| 2420 | +            	return array("CHAR", $c); | |
| 2421 | 2421 | } | 
| 2422 | 2422 | } | 
| 2423 | 2423 | |
| @@ -2461,33 +2461,33 @@ discard block | ||
| 2461 | 2461 | continue; | 
| 2462 | 2462 | } | 
| 2463 | 2463 |                  switch ($token[0]) { | 
| 2464 | - case "CHAR": | |
| 2465 | -                    switch ($token[1]) { | |
| 2466 | -                    case "(": | |
| 2467 | - $level++; | |
| 2468 | - break; | |
| 2469 | - case ")": | |
| 2470 | - $level--; | |
| 2471 | - break; | |
| 2472 | - default: | |
| 2473 | - return false; | |
| 2474 | - } | |
| 2464 | + case "CHAR": | |
| 2465 | +                    	switch ($token[1]) { | |
| 2466 | +                    		case "(": | |
| 2467 | + $level++; | |
| 2468 | + break; | |
| 2469 | + case ")": | |
| 2470 | + $level--; | |
| 2471 | + break; | |
| 2472 | + default: | |
| 2473 | + return false; | |
| 2474 | + } | |
| 2475 | 2475 | break; | 
| 2476 | 2476 | |
| 2477 | - case "URI": | |
| 2478 | - $list[] = $not."<$token[1]>"; | |
| 2479 | - break; | |
| 2477 | + case "URI": | |
| 2478 | + $list[] = $not."<$token[1]>"; | |
| 2479 | + break; | |
| 2480 | 2480 | |
| 2481 | - case "ETAG_WEAK": | |
| 2482 | - $list[] = $not."[W/'$token[1]']>"; | |
| 2483 | - break; | |
| 2481 | + case "ETAG_WEAK": | |
| 2482 | + $list[] = $not."[W/'$token[1]']>"; | |
| 2483 | + break; | |
| 2484 | 2484 | |
| 2485 | - case "ETAG_STRONG": | |
| 2486 | - $list[] = $not."['$token[1]']>"; | |
| 2487 | - break; | |
| 2485 | + case "ETAG_STRONG": | |
| 2486 | + $list[] = $not."['$token[1]']>"; | |
| 2487 | + break; | |
| 2488 | 2488 | |
| 2489 | - default: | |
| 2490 | - return false; | |
| 2489 | + default: | |
| 2490 | + return false; | |
| 2491 | 2491 | } | 
| 2492 | 2492 | $not = ""; | 
| 2493 | 2493 | } | 
| @@ -365,18 +365,18 @@ discard block | ||
| 365 | 365 | // the registry) | 
| 366 | 366 | // TODO: have a seperate PEAR class for mimetype detection? | 
| 367 | 367 |              switch (strtolower(strrchr(basename($fspath), "."))) { | 
| 368 | - case ".html": | |
| 369 | - $mime_type = "text/html"; | |
| 370 | - break; | |
| 371 | - case ".gif": | |
| 372 | - $mime_type = "image/gif"; | |
| 373 | - break; | |
| 374 | - case ".jpg": | |
| 375 | - $mime_type = "image/jpeg"; | |
| 376 | - break; | |
| 377 | - default: | |
| 378 | - $mime_type = "application/octet-stream"; | |
| 379 | - break; | |
| 368 | + case ".html": | |
| 369 | + $mime_type = "text/html"; | |
| 370 | + break; | |
| 371 | + case ".gif": | |
| 372 | + $mime_type = "image/gif"; | |
| 373 | + break; | |
| 374 | + case ".jpg": | |
| 375 | + $mime_type = "image/jpeg"; | |
| 376 | + break; | |
| 377 | + default: | |
| 378 | + $mime_type = "application/octet-stream"; | |
| 379 | + break; | |
| 380 | 380 | } | 
| 381 | 381 | } | 
| 382 | 382 | |
| @@ -633,16 +633,16 @@ discard block | ||
| 633 | 633 | |
| 634 | 634 |          if (is_dir($source)) { // resource is a collection | 
| 635 | 635 |              switch ($options["depth"]) { | 
| 636 | - case "infinity": // valid | |
| 637 | - break; | |
| 638 | - case "0": // valid for COPY only | |
| 639 | -                if ($del) { // MOVE? | |
| 640 | - return "400 Bad request"; | |
| 641 | - } | |
| 642 | - break; | |
| 643 | - case "1": // invalid for both COPY and MOVE | |
| 644 | - default: | |
| 645 | - return "400 Bad request"; | |
| 636 | + case "infinity": // valid | |
| 637 | + break; | |
| 638 | + case "0": // valid for COPY only | |
| 639 | +                	if ($del) { // MOVE? | |
| 640 | + return "400 Bad request"; | |
| 641 | + } | |
| 642 | + break; | |
| 643 | + case "1": // invalid for both COPY and MOVE | |
| 644 | + default: | |
| 645 | + return "400 Bad request"; | |
| 646 | 646 | } | 
| 647 | 647 | } | 
| 648 | 648 | |
| @@ -580,16 +580,16 @@ discard block | ||
| 580 | 580 | $mailbox = ''; | 
| 581 | 581 |  		if ( is_int( $restriction_search ) ){ | 
| 582 | 582 |  			switch ( $restriction_search ) { | 
| 583 | - case 0: | |
| 584 | - $searchstring = $reference."*"; | |
| 585 | - break; | |
| 586 | - case 1: | |
| 587 | - $mailbox = $searchstring = $reference; | |
| 588 | - //$reference = '%'; | |
| 589 | - break; | |
| 590 | - case 2: | |
| 591 | - $searchstring = $reference."%"; | |
| 592 | - break; | |
| 583 | + case 0: | |
| 584 | + $searchstring = $reference."*"; | |
| 585 | + break; | |
| 586 | + case 1: | |
| 587 | + $mailbox = $searchstring = $reference; | |
| 588 | + //$reference = '%'; | |
| 589 | + break; | |
| 590 | + case 2: | |
| 591 | + $searchstring = $reference."%"; | |
| 592 | + break; | |
| 593 | 593 | } | 
| 594 | 594 |  		}else{ | 
| 595 | 595 |  			if ( is_string( $restriction_search ) ){ | 
| @@ -664,16 +664,16 @@ discard block | ||
| 664 | 664 | $mailbox = ''; | 
| 665 | 665 |  		if ( is_int( $restriction_search ) ){ | 
| 666 | 666 |  			switch ( $restriction_search ) { | 
| 667 | - case 0: | |
| 668 | - $searchstring = $reference."*"; | |
| 669 | - break; | |
| 670 | - case 1: | |
| 671 | - $mailbox = $searchstring = $reference; | |
| 672 | - //$reference = '%'; | |
| 673 | - break; | |
| 674 | - case 2: | |
| 675 | - $searchstring = $reference."%"; | |
| 676 | - break; | |
| 667 | + case 0: | |
| 668 | + $searchstring = $reference."*"; | |
| 669 | + break; | |
| 670 | + case 1: | |
| 671 | + $mailbox = $searchstring = $reference; | |
| 672 | + //$reference = '%'; | |
| 673 | + break; | |
| 674 | + case 2: | |
| 675 | + $searchstring = $reference."%"; | |
| 676 | + break; | |
| 677 | 677 | } | 
| 678 | 678 |  		}else{ | 
| 679 | 679 |  			if ( is_string( $restriction_search ) ){ | 
| @@ -730,16 +730,16 @@ discard block | ||
| 730 | 730 | |
| 731 | 731 |  		if ( is_int( $restriction_search ) ){ | 
| 732 | 732 |  			switch ( $restriction_search ) { | 
| 733 | - case 0: | |
| 734 | - $mailbox = $reference."*"; | |
| 735 | - break; | |
| 736 | - case 1: | |
| 737 | - $mailbox = $reference; | |
| 738 | - $reference = '%'; | |
| 739 | - break; | |
| 740 | - case 2: | |
| 741 | - $mailbox = "%"; | |
| 742 | - break; | |
| 733 | + case 0: | |
| 734 | + $mailbox = $reference."*"; | |
| 735 | + break; | |
| 736 | + case 1: | |
| 737 | + $mailbox = $reference; | |
| 738 | + $reference = '%'; | |
| 739 | + break; | |
| 740 | + case 2: | |
| 741 | + $mailbox = "%"; | |
| 742 | + break; | |
| 743 | 743 | } | 
| 744 | 744 |  		}else{ | 
| 745 | 745 |  			if ( is_string( $restriction_search ) ){ | 
| @@ -68,91 +68,91 @@ | ||
| 68 | 68 | |
| 69 | 69 | switch($action) | 
| 70 | 70 |  { | 
| 71 | - case '--version': | |
| 72 | - case '--check': | |
| 73 | - setup_cmd::check_installed($arguments[0],0,true); | |
| 74 | - break; | |
| 75 | - | |
| 76 | - case '--create-header': | |
| 77 | - case '--edit-header': | |
| 78 | - case '--upgrade-header': | |
| 79 | - case '--update-header': | |
| 80 | - do_header($action == '--create-header',$arguments); | |
| 81 | - break; | |
| 82 | - | |
| 83 | - case '--install': | |
| 84 | - do_install($arguments); | |
| 85 | - break; | |
| 86 | - | |
| 87 | - case '--config': | |
| 88 | - do_config($arguments); | |
| 89 | - break; | |
| 90 | - | |
| 91 | - case '--admin': | |
| 92 | - do_admin($arguments[0]); | |
| 93 | - break; | |
| 94 | - | |
| 95 | - case '--update': | |
| 96 | - do_update($arguments[0]); | |
| 97 | - break; | |
| 98 | - | |
| 99 | - case '--register-hooks': | |
| 100 | - case '--register-all-hooks': | |
| 101 | - do_hooks($arguments[0]); | |
| 102 | - break; | |
| 103 | - | |
| 104 | - case '--backup': | |
| 105 | - do_backup($arguments[0]); | |
| 106 | - break; | |
| 107 | - | |
| 108 | - case '--languages': | |
| 109 | -		echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8'); | |
| 110 | - break; | |
| 111 | - | |
| 112 | - case '--charsets': | |
| 113 | -		echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n"; | |
| 114 | - break; | |
| 115 | - | |
| 116 | - case '--exit-codes': | |
| 117 | - list_exit_codes(); | |
| 118 | - break; | |
| 119 | - | |
| 120 | - case '--help': | |
| 121 | - case '--usage': | |
| 122 | - do_usage($arguments[0]); | |
| 123 | - break; | |
| 124 | - | |
| 125 | - default: | |
| 126 | - // we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE | |
| 127 | -		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) && | |
| 128 | - is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) | |
| 129 | -		{ | |
| 130 | - $args = array(); | |
| 131 | -			list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include | |
| 132 | - foreach($arguments as $arg) | |
| 71 | + case '--version': | |
| 72 | + case '--check': | |
| 73 | + setup_cmd::check_installed($arguments[0],0,true); | |
| 74 | + break; | |
| 75 | + | |
| 76 | + case '--create-header': | |
| 77 | + case '--edit-header': | |
| 78 | + case '--upgrade-header': | |
| 79 | + case '--update-header': | |
| 80 | + do_header($action == '--create-header',$arguments); | |
| 81 | + break; | |
| 82 | + | |
| 83 | + case '--install': | |
| 84 | + do_install($arguments); | |
| 85 | + break; | |
| 86 | + | |
| 87 | + case '--config': | |
| 88 | + do_config($arguments); | |
| 89 | + break; | |
| 90 | + | |
| 91 | + case '--admin': | |
| 92 | + do_admin($arguments[0]); | |
| 93 | + break; | |
| 94 | + | |
| 95 | + case '--update': | |
| 96 | + do_update($arguments[0]); | |
| 97 | + break; | |
| 98 | + | |
| 99 | + case '--register-hooks': | |
| 100 | + case '--register-all-hooks': | |
| 101 | + do_hooks($arguments[0]); | |
| 102 | + break; | |
| 103 | + | |
| 104 | + case '--backup': | |
| 105 | + do_backup($arguments[0]); | |
| 106 | + break; | |
| 107 | + | |
| 108 | + case '--languages': | |
| 109 | +			echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8'); | |
| 110 | + break; | |
| 111 | + | |
| 112 | + case '--charsets': | |
| 113 | +			echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n"; | |
| 114 | + break; | |
| 115 | + | |
| 116 | + case '--exit-codes': | |
| 117 | + list_exit_codes(); | |
| 118 | + break; | |
| 119 | + | |
| 120 | + case '--help': | |
| 121 | + case '--usage': | |
| 122 | + do_usage($arguments[0]); | |
| 123 | + break; | |
| 124 | + | |
| 125 | + default: | |
| 126 | + // we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE | |
| 127 | +			if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) && | |
| 128 | + is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) | |
| 133 | 129 |  			{ | 
| 134 | -				list($name,$value) = explode('=',$arg,2); | |
| 135 | -				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties | |
| 136 | -				{ | |
| 137 | -					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); | |
| 138 | - } | |
| 139 | - if (substr($name,-1) == ']') // allow 1-dim. arrays | |
| 130 | + $args = array(); | |
| 131 | +				list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include | |
| 132 | + foreach($arguments as $arg) | |
| 140 | 133 |  				{ | 
| 141 | -					list($name,$sub) = explode('[',substr($name,0,-1),2); | |
| 142 | - $args[$name][$sub] = $value; | |
| 143 | - } | |
| 144 | - else | |
| 145 | -				{ | |
| 146 | - $args[$name] = $value; | |
| 134 | +					list($name,$value) = explode('=',$arg,2); | |
| 135 | +					if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties | |
| 136 | +					{ | |
| 137 | +						throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); | |
| 138 | + } | |
| 139 | + if (substr($name,-1) == ']') // allow 1-dim. arrays | |
| 140 | +					{ | |
| 141 | +						list($name,$sub) = explode('[',substr($name,0,-1),2); | |
| 142 | + $args[$name][$sub] = $value; | |
| 143 | + } | |
| 144 | + else | |
| 145 | +					{ | |
| 146 | + $args[$name] = $value; | |
| 147 | + } | |
| 147 | 148 | } | 
| 149 | + $cmd = new $class($args); | |
| 150 | + $msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run); | |
| 151 | + if (is_array($msg)) $msg = print_r($msg,true); | |
| 152 | + echo "$msg\n"; | |
| 153 | + break; | |
| 148 | 154 | } | 
| 149 | - $cmd = new $class($args); | |
| 150 | - $msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run); | |
| 151 | - if (is_array($msg)) $msg = print_r($msg,true); | |
| 152 | - echo "$msg\n"; | |
| 153 | - break; | |
| 154 | - } | |
| 155 | -		throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90); | |
| 155 | +			throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90); | |
| 156 | 156 | } | 
| 157 | 157 | exit(0); | 
| 158 | 158 | |
| @@ -184,17 +184,17 @@ discard block | ||
| 184 | 184 | |
| 185 | 185 | switch($GLOBALS['egw_info']['setup']['stage']['db']) | 
| 186 | 186 |  { | 
| 187 | - case 1: | |
| 188 | -		$setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); | |
| 189 | -		$setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set')); | |
| 190 | -		$setup_tpl->set_var('notcomplete',lang('not complete')); | |
| 191 | -		$setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); | |
| 192 | -		$setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>'); | |
| 193 | -		$setup_tpl->set_var('create_database',lang('Create database')); | |
| 194 | -		$setup_tpl->set_var('instr',''); | |
| 195 | - $info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]; | |
| 196 | - switch ($info['db_type']) | |
| 197 | -		{ | |
| 187 | + case 1: | |
| 188 | +			$setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); | |
| 189 | +			$setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set')); | |
| 190 | +			$setup_tpl->set_var('notcomplete',lang('not complete')); | |
| 191 | +			$setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); | |
| 192 | +			$setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>'); | |
| 193 | +			$setup_tpl->set_var('create_database',lang('Create database')); | |
| 194 | +			$setup_tpl->set_var('instr',''); | |
| 195 | + $info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]; | |
| 196 | + switch ($info['db_type']) | |
| 197 | +			{ | |
| 198 | 198 | case 'mysql': | 
| 199 | 199 | case 'mysqli': | 
| 200 | 200 | case 'mysqlt': | 
| @@ -227,77 +227,77 @@ discard block | ||
| 227 | 227 | //break; | 
| 228 | 228 | default: | 
| 229 | 229 |  				$setup_tpl->parse('V_db_stage_1','B_db_stage_1a'); | 
| 230 | - } | |
| 230 | + } | |
| 231 | 231 |  		$db_filled_block = $setup_tpl->get_var('V_db_stage_1'); | 
| 232 | 232 |  		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | 
| 233 | 233 | break; | 
| 234 | - case 2: | |
| 235 | -		$setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); | |
| 236 | -		$setup_tpl->set_var('notcomplete',lang('not complete')); | |
| 237 | -		$setup_tpl->parse('V_db_stage_2','B_db_stage_2'); | |
| 238 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_2'); | |
| 239 | -		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 240 | - break; | |
| 241 | - case 3: | |
| 242 | -		$setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); | |
| 243 | -		$setup_tpl->set_var('install',lang('Install')); | |
| 244 | -		$setup_tpl->set_var('proceed',lang('We can proceed')); | |
| 245 | -		$setup_tpl->set_var('coreapps',lang('all applications')); | |
| 246 | -		$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); | |
| 247 | -		$setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.')); | |
| 248 | -		$setup_tpl->set_var('upload','<input type="file" name="uploaded" />  '. | |
| 249 | -			'<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />'); | |
| 250 | -		$setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); | |
| 251 | -		$setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'. | |
| 252 | -			lang('Convert backup to charset selected above').'</label>'); | |
| 253 | -		$setup_tpl->parse('V_db_stage_3','B_db_stage_3'); | |
| 254 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_3'); | |
| 255 | -		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 256 | - break; | |
| 257 | - case 4: | |
| 258 | -		$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__))); | |
| 259 | -		$setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare', | |
| 260 | - isset($setup_info['api']['currentver']) ? $setup_info['api']['currentver'] : $setup_info['phpgwapi']['currentver'])); | |
| 261 | -		$setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['api']['version'])); | |
| 262 | -		$setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); | |
| 263 | -		$setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB')); | |
| 264 | -		$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); | |
| 265 | -		$setup_tpl->set_var('upgrade',lang('Upgrade')); | |
| 266 | -		$setup_tpl->set_var('goto',lang('Go to')); | |
| 267 | -		$setup_tpl->set_var('configuration',lang('configuration')); | |
| 268 | -		$setup_tpl->set_var('admin_account',lang('Create admin account')); | |
| 269 | -		$setup_tpl->set_var('applications',lang('Manage Applications')); | |
| 270 | -		$setup_tpl->set_var('db_backup',lang('DB backup and restore')); | |
| 271 | -		$setup_tpl->set_var('language_management',lang('Manage Languages')); | |
| 272 | -		$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); | |
| 273 | -		$setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); | |
| 274 | -		$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); | |
| 234 | + case 2: | |
| 235 | +			$setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); | |
| 236 | +			$setup_tpl->set_var('notcomplete',lang('not complete')); | |
| 237 | +			$setup_tpl->parse('V_db_stage_2','B_db_stage_2'); | |
| 238 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_2'); | |
| 239 | +			$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 240 | + break; | |
| 241 | + case 3: | |
| 242 | +			$setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); | |
| 243 | +			$setup_tpl->set_var('install',lang('Install')); | |
| 244 | +			$setup_tpl->set_var('proceed',lang('We can proceed')); | |
| 245 | +			$setup_tpl->set_var('coreapps',lang('all applications')); | |
| 246 | +			$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); | |
| 247 | +			$setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.')); | |
| 248 | +			$setup_tpl->set_var('upload','<input type="file" name="uploaded" />  '. | |
| 249 | +				'<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />'); | |
| 250 | +			$setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); | |
| 251 | +			$setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'. | |
| 252 | +				lang('Convert backup to charset selected above').'</label>'); | |
| 253 | +			$setup_tpl->parse('V_db_stage_3','B_db_stage_3'); | |
| 254 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_3'); | |
| 255 | +			$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 256 | + break; | |
| 257 | + case 4: | |
| 258 | +			$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__))); | |
| 259 | +			$setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare', | |
| 260 | + isset($setup_info['api']['currentver']) ? $setup_info['api']['currentver'] : $setup_info['phpgwapi']['currentver'])); | |
| 261 | +			$setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['api']['version'])); | |
| 262 | +			$setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); | |
| 263 | +			$setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB')); | |
| 264 | +			$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); | |
| 265 | +			$setup_tpl->set_var('upgrade',lang('Upgrade')); | |
| 266 | +			$setup_tpl->set_var('goto',lang('Go to')); | |
| 267 | +			$setup_tpl->set_var('configuration',lang('configuration')); | |
| 268 | +			$setup_tpl->set_var('admin_account',lang('Create admin account')); | |
| 269 | +			$setup_tpl->set_var('applications',lang('Manage Applications')); | |
| 270 | +			$setup_tpl->set_var('db_backup',lang('DB backup and restore')); | |
| 271 | +			$setup_tpl->set_var('language_management',lang('Manage Languages')); | |
| 272 | +			$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); | |
| 273 | +			$setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); | |
| 274 | +			$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); | |
| 275 | 275 | |
| 276 | -		$setup_tpl->parse('V_db_stage_4','B_db_stage_4'); | |
| 277 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_4'); | |
| 278 | -		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 279 | - break; | |
| 280 | - case 5: | |
| 281 | -		$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__))); | |
| 282 | -		$setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); | |
| 283 | -		$setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); | |
| 284 | -		$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); | |
| 285 | -		$setup_tpl->set_var('cancel',lang('cancel')); | |
| 286 | -		$setup_tpl->parse('V_db_stage_5','B_db_stage_5'); | |
| 287 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_5'); | |
| 288 | -		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 289 | - break; | |
| 290 | - case 6: | |
| 291 | -		$setup_tpl->set_var('status',lang('Status')); | |
| 292 | -		$setup_tpl->set_var('notcomplete',lang('not complete')); | |
| 293 | -		$setup_tpl->set_var('tblchange',lang('Table Change Messages')); | |
| 294 | -		$setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); | |
| 295 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); | |
| 296 | -		$setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); | |
| 276 | +			$setup_tpl->parse('V_db_stage_4','B_db_stage_4'); | |
| 277 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_4'); | |
| 278 | +			$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 279 | + break; | |
| 280 | + case 5: | |
| 281 | +			$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__))); | |
| 282 | +			$setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); | |
| 283 | +			$setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); | |
| 284 | +			$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); | |
| 285 | +			$setup_tpl->set_var('cancel',lang('cancel')); | |
| 286 | +			$setup_tpl->parse('V_db_stage_5','B_db_stage_5'); | |
| 287 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_5'); | |
| 288 | +			$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 289 | + break; | |
| 290 | + case 6: | |
| 291 | +			$setup_tpl->set_var('status',lang('Status')); | |
| 292 | +			$setup_tpl->set_var('notcomplete',lang('not complete')); | |
| 293 | +			$setup_tpl->set_var('tblchange',lang('Table Change Messages')); | |
| 294 | +			$setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); | |
| 295 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); | |
| 296 | +			$setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); | |
| 297 | 297 | |
| 298 | -		try {	// catch DB errors to report them | |
| 299 | - switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) | |
| 300 | -			{ | |
| 298 | +			try {	// catch DB errors to report them | |
| 299 | + switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) | |
| 300 | +				{ | |
| 301 | 301 | case 'dbcreate': | 
| 302 | 302 | $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], 'utf8', // create all new db's with utf8 | 
| 303 | 303 |  						!preg_match('/^[0-9.a-z_]+$/i', $_POST['db_grant_host']) ? 'localhost' : $_POST['db_grant_host']); | 
| @@ -376,7 +376,7 @@ discard block | ||
| 376 | 376 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; | 
| 377 | 377 | } | 
| 378 | 378 | break; | 
| 379 | - } | |
| 379 | + } | |
| 380 | 380 | } | 
| 381 | 381 | catch (Api\Db\Exception $e) | 
| 382 | 382 |  		{ | 
| @@ -388,21 +388,21 @@ discard block | ||
| 388 | 388 |  		$db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post'); | 
| 389 | 389 |  		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | 
| 390 | 390 | break; | 
| 391 | - case 10: | |
| 392 | -		$setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current')); | |
| 393 | -		$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); | |
| 394 | -		$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); | |
| 395 | -		$setup_tpl->set_var('deletetables',lang('Uninstall all applications')); | |
| 396 | -		$setup_tpl->parse('V_db_stage_10','B_db_stage_10'); | |
| 397 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_10'); | |
| 398 | -		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 399 | - break; | |
| 400 | - default: | |
| 401 | -		$setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); | |
| 402 | -		$setup_tpl->parse('V_db_stage_default','B_db_stage_default'); | |
| 403 | -		$db_filled_block = $setup_tpl->get_var('V_db_stage_default'); | |
| 404 | -		$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 405 | - break; | |
| 391 | + case 10: | |
| 392 | +			$setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current')); | |
| 393 | +			$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); | |
| 394 | +			$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); | |
| 395 | +			$setup_tpl->set_var('deletetables',lang('Uninstall all applications')); | |
| 396 | +			$setup_tpl->parse('V_db_stage_10','B_db_stage_10'); | |
| 397 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_10'); | |
| 398 | +			$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 399 | + break; | |
| 400 | + default: | |
| 401 | +			$setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); | |
| 402 | +			$setup_tpl->parse('V_db_stage_default','B_db_stage_default'); | |
| 403 | +			$db_filled_block = $setup_tpl->get_var('V_db_stage_default'); | |
| 404 | +			$setup_tpl->set_var('V_db_filled_block',$db_filled_block); | |
| 405 | + break; | |
| 406 | 406 | } | 
| 407 | 407 | |
| 408 | 408 | // Config Section | 
| @@ -344,105 +344,105 @@ discard block | ||
| 344 | 344 | |
| 345 | 345 |  	switch ($MYREQUEST['IMG']) { | 
| 346 | 346 | |
| 347 | - case 1: | |
| 348 | - $s=$mem['num_seg']*$mem['seg_size']; | |
| 349 | - $a=$mem['avail_mem']; | |
| 350 | - $x=$y=$size/2; | |
| 351 | - $fuzz = 0.000001; | |
| 352 | - | |
| 353 | - // This block of code creates the pie chart. It is a lot more complex than you | |
| 354 | - // would expect because we try to visualize any memory fragmentation as well. | |
| 355 | - $angle_from = 0; | |
| 356 | - $string_placement=array(); | |
| 357 | -		for($i=0; $i<$mem['num_seg']; $i++) { | |
| 358 | - $ptr = 0; | |
| 359 | - $free = $mem['block_lists'][$i]; | |
| 360 | - uasort($free, 'block_sort'); | |
| 361 | -			foreach($free as $block) { | |
| 362 | -				if($block['offset']!=$ptr) {       // Used block | |
| 363 | - $angle_to = $angle_from+($block['offset']-$ptr)/$s; | |
| 347 | + case 1: | |
| 348 | + $s=$mem['num_seg']*$mem['seg_size']; | |
| 349 | + $a=$mem['avail_mem']; | |
| 350 | + $x=$y=$size/2; | |
| 351 | + $fuzz = 0.000001; | |
| 352 | + | |
| 353 | + // This block of code creates the pie chart. It is a lot more complex than you | |
| 354 | + // would expect because we try to visualize any memory fragmentation as well. | |
| 355 | + $angle_from = 0; | |
| 356 | + $string_placement=array(); | |
| 357 | +			for($i=0; $i<$mem['num_seg']; $i++) { | |
| 358 | + $ptr = 0; | |
| 359 | + $free = $mem['block_lists'][$i]; | |
| 360 | + uasort($free, 'block_sort'); | |
| 361 | +				foreach($free as $block) { | |
| 362 | +					if($block['offset']!=$ptr) {       // Used block | |
| 363 | + $angle_to = $angle_from+($block['offset']-$ptr)/$s; | |
| 364 | + if(($angle_to+$fuzz)>1) $angle_to = 1; | |
| 365 | +						if( ($angle_to*360) - ($angle_from*360) >= 1) { | |
| 366 | + fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); | |
| 367 | +							if (($angle_to-$angle_from)>0.05) { | |
| 368 | + array_push($string_placement, array($angle_from,$angle_to)); | |
| 369 | + } | |
| 370 | + } | |
| 371 | + $angle_from = $angle_to; | |
| 372 | + } | |
| 373 | + $angle_to = $angle_from+($block['size'])/$s; | |
| 364 | 374 | if(($angle_to+$fuzz)>1) $angle_to = 1; | 
| 365 | 375 |  					if( ($angle_to*360) - ($angle_from*360) >= 1) { | 
| 366 | - fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); | |
| 376 | + fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green); | |
| 367 | 377 |  						if (($angle_to-$angle_from)>0.05) { | 
| 368 | 378 | array_push($string_placement, array($angle_from,$angle_to)); | 
| 369 | 379 | } | 
| 370 | 380 | } | 
| 371 | 381 | $angle_from = $angle_to; | 
| 382 | + $ptr = $block['offset']+$block['size']; | |
| 372 | 383 | } | 
| 373 | - $angle_to = $angle_from+($block['size'])/$s; | |
| 374 | - if(($angle_to+$fuzz)>1) $angle_to = 1; | |
| 375 | -				if( ($angle_to*360) - ($angle_from*360) >= 1) { | |
| 376 | - fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green); | |
| 384 | +				if ($ptr < $mem['seg_size']) { // memory at the end | |
| 385 | + $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s; | |
| 386 | + if(($angle_to+$fuzz)>1) $angle_to = 1; | |
| 387 | + fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); | |
| 377 | 388 |  					if (($angle_to-$angle_from)>0.05) { | 
| 378 | 389 | array_push($string_placement, array($angle_from,$angle_to)); | 
| 379 | 390 | } | 
| 380 | 391 | } | 
| 381 | - $angle_from = $angle_to; | |
| 382 | - $ptr = $block['offset']+$block['size']; | |
| 383 | 392 | } | 
| 384 | -			if ($ptr < $mem['seg_size']) { // memory at the end | |
| 385 | - $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s; | |
| 386 | - if(($angle_to+$fuzz)>1) $angle_to = 1; | |
| 387 | - fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); | |
| 388 | -				if (($angle_to-$angle_from)>0.05) { | |
| 389 | - array_push($string_placement, array($angle_from,$angle_to)); | |
| 390 | - } | |
| 393 | +			foreach ($string_placement as $angle) { | |
| 394 | + text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0]))); | |
| 391 | 395 | } | 
| 392 | - } | |
| 393 | -		foreach ($string_placement as $angle) { | |
| 394 | - text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0]))); | |
| 395 | - } | |
| 396 | - break; | |
| 397 | - | |
| 398 | - case 2: | |
| 399 | - $s=$cache['num_hits']+$cache['num_misses']; | |
| 400 | - $a=$cache['num_hits']; | |
| 396 | + break; | |
| 401 | 397 | |
| 402 | -		fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['num_hits']*100/$s : 0)); | |
| 403 | -		fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['num_misses']*100/$s : 0)); | |
| 404 | - break; | |
| 405 | - | |
| 406 | - case 3: | |
| 407 | - $s=$mem['num_seg']*$mem['seg_size']; | |
| 408 | - $a=$mem['avail_mem']; | |
| 409 | - $x=130; | |
| 410 | - $y=1; | |
| 411 | - $j=1; | |
| 398 | + case 2: | |
| 399 | + $s=$cache['num_hits']+$cache['num_misses']; | |
| 400 | + $a=$cache['num_hits']; | |
| 412 | 401 | |
| 413 | - // This block of code creates the bar chart. It is a lot more complex than you | |
| 414 | - // would expect because we try to visualize any memory fragmentation as well. | |
| 415 | -		for($i=0; $i<$mem['num_seg']; $i++) { | |
| 416 | - $ptr = 0; | |
| 417 | - $free = $mem['block_lists'][$i]; | |
| 418 | - uasort($free, 'block_sort'); | |
| 419 | -			foreach($free as $block) { | |
| 420 | -				if($block['offset']!=$ptr) {       // Used block | |
| 421 | - $h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s; | |
| 402 | +			fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['num_hits']*100/$s : 0)); | |
| 403 | +			fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['num_misses']*100/$s : 0)); | |
| 404 | + break; | |
| 405 | + | |
| 406 | + case 3: | |
| 407 | + $s=$mem['num_seg']*$mem['seg_size']; | |
| 408 | + $a=$mem['avail_mem']; | |
| 409 | + $x=130; | |
| 410 | + $y=1; | |
| 411 | + $j=1; | |
| 412 | + | |
| 413 | + // This block of code creates the bar chart. It is a lot more complex than you | |
| 414 | + // would expect because we try to visualize any memory fragmentation as well. | |
| 415 | +			for($i=0; $i<$mem['num_seg']; $i++) { | |
| 416 | + $ptr = 0; | |
| 417 | + $free = $mem['block_lists'][$i]; | |
| 418 | + uasort($free, 'block_sort'); | |
| 419 | +				foreach($free as $block) { | |
| 420 | +					if($block['offset']!=$ptr) {       // Used block | |
| 421 | + $h=(GRAPH_SIZE-5)*($block['offset']-$ptr)/$s; | |
| 422 | +						if ($h>0) { | |
| 423 | + $j++; | |
| 424 | + if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j); | |
| 425 | + else fill_box($image,$x,$y,50,$h,$col_black,$col_red); | |
| 426 | + } | |
| 427 | + $y+=$h; | |
| 428 | + } | |
| 429 | + $h=(GRAPH_SIZE-5)*($block['size'])/$s; | |
| 422 | 430 |  					if ($h>0) { | 
| 423 | - $j++; | |
| 424 | - if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($block['offset']-$ptr),$j); | |
| 425 | - else fill_box($image,$x,$y,50,$h,$col_black,$col_red); | |
| 426 | - } | |
| 431 | + $j++; | |
| 432 | + if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j); | |
| 433 | + else fill_box($image,$x,$y,50,$h,$col_black,$col_green); | |
| 434 | + } | |
| 427 | 435 | $y+=$h; | 
| 436 | + $ptr = $block['offset']+$block['size']; | |
| 428 | 437 | } | 
| 429 | - $h=(GRAPH_SIZE-5)*($block['size'])/$s; | |
| 430 | -				if ($h>0) { | |
| 431 | - $j++; | |
| 432 | - if($j<75) fill_box($image,$x,$y,50,$h,$col_black,$col_green,bsize($block['size']),$j); | |
| 433 | - else fill_box($image,$x,$y,50,$h,$col_black,$col_green); | |
| 434 | - } | |
| 435 | - $y+=$h; | |
| 436 | - $ptr = $block['offset']+$block['size']; | |
| 437 | - } | |
| 438 | -			if ($ptr < $mem['seg_size']) { // memory at the end | |
| 439 | - $h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s; | |
| 440 | -				if ($h > 0) { | |
| 441 | - fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++); | |
| 438 | +				if ($ptr < $mem['seg_size']) { // memory at the end | |
| 439 | + $h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s; | |
| 440 | +					if ($h > 0) { | |
| 441 | + fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++); | |
| 442 | + } | |
| 442 | 443 | } | 
| 443 | 444 | } | 
| 444 | - } | |
| 445 | - break; | |
| 445 | + break; | |
| 446 | 446 | |
| 447 | 447 | case 4: | 
| 448 | 448 | $s=$cache['num_hits']+$cache['num_misses']; | 
| @@ -769,40 +769,40 @@ discard block | ||
| 769 | 769 | // ----------------------------------------------- | 
| 770 | 770 | // Host Stats | 
| 771 | 771 | // ----------------------------------------------- | 
| 772 | -case OB_HOST_STATS: | |
| 773 | - $mem_size = $mem['num_seg']*$mem['seg_size']; | |
| 774 | - $mem_avail= $mem['avail_mem']; | |
| 775 | - $mem_used = $mem_size-$mem_avail; | |
| 776 | - $seg_size = bsize($mem['seg_size']); | |
| 777 | -	$req_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time'])) : 0); | |
| 778 | -	$hit_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits'])/($time-$cache['start_time'])) : 0); | |
| 779 | -	$miss_rate_user = sprintf("%.2f", $cache['num_misses'] ? (($cache['num_misses'])/($time-$cache['start_time'])) : 0); | |
| 780 | -	$insert_rate_user = sprintf("%.2f", $cache['num_inserts'] ? (($cache['num_inserts'])/($time-$cache['start_time'])) : 0); | |
| 781 | -	$apcversion = phpversion('apcu'); | |
| 782 | - $phpversion = phpversion(); | |
| 783 | - $number_vars = $cache['num_entries']; | |
| 784 | - $size_vars = bsize($cache['mem_size']); | |
| 785 | - $i=0; | |
| 786 | - echo <<< EOB | |
| 772 | + case OB_HOST_STATS: | |
| 773 | + $mem_size = $mem['num_seg']*$mem['seg_size']; | |
| 774 | + $mem_avail= $mem['avail_mem']; | |
| 775 | + $mem_used = $mem_size-$mem_avail; | |
| 776 | + $seg_size = bsize($mem['seg_size']); | |
| 777 | +		$req_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time'])) : 0); | |
| 778 | +		$hit_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits'])/($time-$cache['start_time'])) : 0); | |
| 779 | +		$miss_rate_user = sprintf("%.2f", $cache['num_misses'] ? (($cache['num_misses'])/($time-$cache['start_time'])) : 0); | |
| 780 | +		$insert_rate_user = sprintf("%.2f", $cache['num_inserts'] ? (($cache['num_inserts'])/($time-$cache['start_time'])) : 0); | |
| 781 | +		$apcversion = phpversion('apcu'); | |
| 782 | + $phpversion = phpversion(); | |
| 783 | + $number_vars = $cache['num_entries']; | |
| 784 | + $size_vars = bsize($cache['mem_size']); | |
| 785 | + $i=0; | |
| 786 | + echo <<< EOB | |
| 787 | 787 | <div class="info div1"><h2>General Cache Information</h2> | 
| 788 | 788 | <table cellspacing=0><tbody> | 
| 789 | 789 | <tr class=tr-0><td class=td-0>APCu Version</td><td>$apcversion</td></tr> | 
| 790 | 790 | <tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr> | 
| 791 | -EOB; | |
| 791 | + EOB; | |
| 792 | 792 | |
| 793 | - if(!empty($_SERVER['SERVER_NAME'])) | |
| 794 | -		echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n"; | |
| 795 | - if(!empty($_SERVER['SERVER_SOFTWARE'])) | |
| 796 | -		echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; | |
| 793 | + if(!empty($_SERVER['SERVER_NAME'])) | |
| 794 | +			echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n"; | |
| 795 | + if(!empty($_SERVER['SERVER_SOFTWARE'])) | |
| 796 | +			echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; | |
| 797 | 797 | |
| 798 | - echo <<<EOB | |
| 799 | -		<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size | |
| 798 | + echo <<<EOB | |
| 799 | +			<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size | |
| 800 | 800 |      <br/> ({$cache['memory_type']} memory) | 
| 801 | 801 | </td></tr> | 
| 802 | 802 | EOB; | 
| 803 | - echo '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['start_time']),'</td></tr>'; | |
| 804 | - echo '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['start_time']),'</td></tr>'; | |
| 805 | - echo <<<EOB | |
| 803 | + echo '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['start_time']),'</td></tr>'; | |
| 804 | + echo '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['start_time']),'</td></tr>'; | |
| 805 | + echo <<<EOB | |
| 806 | 806 | </tbody></table> | 
| 807 | 807 | </div> | 
| 808 | 808 | |
| @@ -824,46 +824,46 @@ discard block | ||
| 824 | 824 | <div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody> | 
| 825 | 825 | EOB; | 
| 826 | 826 | |
| 827 | - $j = 0; | |
| 828 | -	foreach (ini_get_all('apcu') as $k => $v) { | |
| 829 | -		echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n"; | |
| 830 | - $j = 1 - $j; | |
| 831 | - } | |
| 827 | + $j = 0; | |
| 828 | +		foreach (ini_get_all('apcu') as $k => $v) { | |
| 829 | +			echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n"; | |
| 830 | + $j = 1 - $j; | |
| 831 | + } | |
| 832 | 832 | |
| 833 | - if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1) | |
| 834 | - $mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>"; | |
| 835 | - else | |
| 836 | - $mem_note = "Memory Usage"; | |
| 833 | + if($mem['num_seg']>1 || $mem['num_seg']==1 && count($mem['block_lists'][0])>1) | |
| 834 | + $mem_note = "Memory Usage<br /><font size=-2>(multiple slices indicate fragments)</font>"; | |
| 835 | + else | |
| 836 | + $mem_note = "Memory Usage"; | |
| 837 | 837 | |
| 838 | - echo <<< EOB | |
| 838 | + echo <<< EOB | |
| 839 | 839 | </tbody></table> | 
| 840 | 840 | </div> | 
| 841 | 841 | |
| 842 | 842 | <div class="graph div3"><h2>Host Status Diagrams</h2> | 
| 843 | 843 | <table cellspacing=0><tbody> | 
| 844 | 844 | EOB; | 
| 845 | - $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10); | |
| 846 | -echo <<<EOB | |
| 845 | + $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10); | |
| 846 | + echo <<<EOB | |
| 847 | 847 | <tr> | 
| 848 | 848 | <td class=td-0>$mem_note</td> | 
| 849 | 849 | <td class=td-1>Hits & Misses</td> | 
| 850 | 850 | </tr> | 
| 851 | 851 | EOB; | 
| 852 | 852 | |
| 853 | - echo | |
| 854 | - graphics_avail() ? | |
| 855 | - '<tr>'. | |
| 856 | - "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>". | |
| 857 | - "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n" | |
| 858 | - : "", | |
| 859 | - '<tr>', | |
| 860 | -		'<td class=td-0><span class="green box"> </span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n", | |
| 861 | -		'<td class=td-1><span class="green box"> </span>Hits: ',$cache['num_hits'].@sprintf(" (%.1f%%)",$cache['num_hits']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n", | |
| 862 | - '</tr>', | |
| 863 | - '<tr>', | |
| 864 | -		'<td class=td-0><span class="red box"> </span>Used: ',bsize($mem_used).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n", | |
| 865 | -		'<td class=td-1><span class="red box"> </span>Misses: ',$cache['num_misses'].@sprintf(" (%.1f%%)",$cache['num_misses']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n"; | |
| 866 | - echo <<< EOB | |
| 853 | + echo | |
| 854 | + graphics_avail() ? | |
| 855 | + '<tr>'. | |
| 856 | + "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>". | |
| 857 | + "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n" | |
| 858 | + : "", | |
| 859 | + '<tr>', | |
| 860 | +			'<td class=td-0><span class="green box"> </span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n", | |
| 861 | +			'<td class=td-1><span class="green box"> </span>Hits: ',$cache['num_hits'].@sprintf(" (%.1f%%)",$cache['num_hits']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n", | |
| 862 | + '</tr>', | |
| 863 | + '<tr>', | |
| 864 | +			'<td class=td-0><span class="red box"> </span>Used: ',bsize($mem_used).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n", | |
| 865 | +			'<td class=td-1><span class="red box"> </span>Misses: ',$cache['num_misses'].@sprintf(" (%.1f%%)",$cache['num_misses']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n"; | |
| 866 | + echo <<< EOB | |
| 867 | 867 | </tr> | 
| 868 | 868 | </tbody></table> | 
| 869 | 869 | |
| @@ -874,141 +874,141 @@ discard block | ||
| 874 | 874 | <td class=td-0 colspan=2><br/> | 
| 875 | 875 | EOB; | 
| 876 | 876 | |
| 877 | - // Fragementation: (freeseg - 1) / total_seg | |
| 878 | - $nseg = $freeseg = $fragsize = $freetotal = 0; | |
| 879 | -	for($i=0; $i<$mem['num_seg']; $i++) { | |
| 880 | - $ptr = 0; | |
| 881 | -		foreach($mem['block_lists'][$i] as $block) { | |
| 882 | -			if ($block['offset'] != $ptr) { | |
| 883 | - ++$nseg; | |
| 877 | + // Fragementation: (freeseg - 1) / total_seg | |
| 878 | + $nseg = $freeseg = $fragsize = $freetotal = 0; | |
| 879 | +		for($i=0; $i<$mem['num_seg']; $i++) { | |
| 880 | + $ptr = 0; | |
| 881 | +			foreach($mem['block_lists'][$i] as $block) { | |
| 882 | +				if ($block['offset'] != $ptr) { | |
| 883 | + ++$nseg; | |
| 884 | + } | |
| 885 | + $ptr = $block['offset'] + $block['size']; | |
| 886 | + /* Only consider blocks <5M for the fragmentation % */ | |
| 887 | + if($block['size']<(5*1024*1024)) $fragsize+=$block['size']; | |
| 888 | + $freetotal+=$block['size']; | |
| 884 | 889 | } | 
| 885 | - $ptr = $block['offset'] + $block['size']; | |
| 886 | - /* Only consider blocks <5M for the fragmentation % */ | |
| 887 | - if($block['size']<(5*1024*1024)) $fragsize+=$block['size']; | |
| 888 | - $freetotal+=$block['size']; | |
| 890 | + $freeseg += count($mem['block_lists'][$i]); | |
| 889 | 891 | } | 
| 890 | - $freeseg += count($mem['block_lists'][$i]); | |
| 891 | - } | |
| 892 | 892 | |
| 893 | -	if ($freeseg > 1) { | |
| 894 | -		$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg); | |
| 895 | -	} else { | |
| 896 | - $frag = "0%"; | |
| 897 | - } | |
| 893 | +		if ($freeseg > 1) { | |
| 894 | +			$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg); | |
| 895 | +		} else { | |
| 896 | + $frag = "0%"; | |
| 897 | + } | |
| 898 | 898 | |
| 899 | -	if (graphics_avail()) { | |
| 900 | - $size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10); | |
| 899 | +		if (graphics_avail()) { | |
| 900 | + $size='width='.(2*GRAPH_SIZE+150).' height='.(GRAPH_SIZE+10); | |
| 901 | + echo <<<EOB | |
| 902 | + <img alt="" $size src="$PHP_SELF?IMG=3&$time"> | |
| 903 | + EOB; | |
| 904 | + } | |
| 901 | 905 | echo <<<EOB | 
| 902 | - <img alt="" $size src="$PHP_SELF?IMG=3&$time"> | |
| 903 | -EOB; | |
| 904 | - } | |
| 905 | - echo <<<EOB | |
| 906 | - </br>Fragmentation: $frag | |
| 906 | + </br>Fragmentation: $frag | |
| 907 | 907 | </td> | 
| 908 | 908 | </tr> | 
| 909 | 909 | EOB; | 
| 910 | -        if(isset($mem['adist'])) { | |
| 911 | -          foreach($mem['adist'] as $i=>$v) { | |
| 912 | - $cur = pow(2,$i); $nxt = pow(2,$i+1)-1; | |
| 913 | - if($i==0) $range = "1"; | |
| 914 | - else $range = "$cur - $nxt"; | |
| 915 | - echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n"; | |
| 916 | - } | |
| 917 | - } | |
| 918 | - echo <<<EOB | |
| 910 | +        	if(isset($mem['adist'])) { | |
| 911 | +          	foreach($mem['adist'] as $i=>$v) { | |
| 912 | + $cur = pow(2,$i); $nxt = pow(2,$i+1)-1; | |
| 913 | + if($i==0) $range = "1"; | |
| 914 | + else $range = "$cur - $nxt"; | |
| 915 | + echo "<tr><th align=right>$range</th><td align=right>$v</td></tr>\n"; | |
| 916 | + } | |
| 917 | + } | |
| 918 | + echo <<<EOB | |
| 919 | 919 | </tbody></table> | 
| 920 | 920 | </div> | 
| 921 | 921 | EOB; | 
| 922 | 922 | |
| 923 | - break; | |
| 923 | + break; | |
| 924 | 924 | |
| 925 | 925 | |
| 926 | -// ----------------------------------------------- | |
| 927 | -// User Cache Entries | |
| 928 | -// ----------------------------------------------- | |
| 929 | -case OB_USER_CACHE: | |
| 930 | -	if (!$AUTHENTICATED) { | |
| 931 | - echo '<div class="error">You need to login to see the user values here!<br/> <br/>'; | |
| 932 | -		put_login_link("Login now!"); | |
| 933 | - echo '</div>'; | |
| 934 | - break; | |
| 935 | - } | |
| 936 | - $fieldname='info'; | |
| 937 | - $fieldheading='User Entry Label'; | |
| 938 | - $fieldkey='info'; | |
| 926 | + // ----------------------------------------------- | |
| 927 | + // User Cache Entries | |
| 928 | + // ----------------------------------------------- | |
| 929 | + case OB_USER_CACHE: | |
| 930 | +		if (!$AUTHENTICATED) { | |
| 931 | + echo '<div class="error">You need to login to see the user values here!<br/> <br/>'; | |
| 932 | +			put_login_link("Login now!"); | |
| 933 | + echo '</div>'; | |
| 934 | + break; | |
| 935 | + } | |
| 936 | + $fieldname='info'; | |
| 937 | + $fieldheading='User Entry Label'; | |
| 938 | + $fieldkey='info'; | |
| 939 | 939 | |
| 940 | - $cols=6; | |
| 941 | - echo <<<EOB | |
| 940 | + $cols=6; | |
| 941 | + echo <<<EOB | |
| 942 | 942 | <div class=sorting><form>Scope: | 
| 943 | 943 |  		<input type=hidden name=OB value={$MYREQUEST['OB']}> | 
| 944 | 944 | <select name=SCOPE> | 
| 945 | 945 | EOB; | 
| 946 | - echo | |
| 947 | - "<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>", | |
| 948 | - "<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>", | |
| 949 | - "</select>", | |
| 950 | - ", Sorting:<select name=SORT1>", | |
| 951 | - "<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>", | |
| 952 | - "<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>", | |
| 953 | - "<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>", | |
| 954 | - "<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>", | |
| 955 | - "<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>", | |
| 956 | - "<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>", | |
| 957 | - "<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>"; | |
| 958 | - if($fieldname=='info') echo | |
| 959 | - "<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>"; | |
| 960 | - echo | |
| 961 | - '</select>', | |
| 962 | - '<select name=SORT2>', | |
| 963 | - '<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>', | |
| 964 | - '<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>', | |
| 965 | - '</select>', | |
| 966 | - '<select name=COUNT onChange="form.submit()">', | |
| 967 | - '<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>', | |
| 968 | - '<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>', | |
| 969 | - '<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>', | |
| 970 | - '<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>', | |
| 971 | - '<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>', | |
| 972 | - '<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>', | |
| 973 | - '<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>', | |
| 974 | - '<option value=0 ',$MYREQUEST['COUNT']=='0' ? ' selected':'','>All</option>', | |
| 975 | - '</select>', | |
| 976 | - '  Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>', | |
| 977 | - ' <input type=submit value="GO!">', | |
| 978 | - '</form></div>'; | |
| 979 | - | |
| 980 | -  if (isset($MYREQUEST['SEARCH'])) { | |
| 981 | - // Don't use preg_quote because we want the user to be able to specify a | |
| 982 | - // regular expression subpattern. | |
| 983 | -   $MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i'; | |
| 984 | -   if (preg_match($MYREQUEST['SEARCH'], 'test') === false) { | |
| 985 | - echo '<div class="error">Error: enter a valid regular expression as a search query.</div>'; | |
| 986 | - break; | |
| 987 | - } | |
| 988 | - } | |
| 989 | - | |
| 990 | - echo | |
| 991 | - '<div class="info"><table cellspacing=0><tbody>', | |
| 992 | - '<tr>', | |
| 993 | -		'<th>',sortheader('S',$fieldheading,  "&OB=".$MYREQUEST['OB']),'</th>', | |
| 994 | -		'<th>',sortheader('H','Hits',         "&OB=".$MYREQUEST['OB']),'</th>', | |
| 995 | -		'<th>',sortheader('Z','Size',         "&OB=".$MYREQUEST['OB']),'</th>', | |
| 996 | -		'<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>', | |
| 997 | -		'<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>', | |
| 998 | -		'<th>',sortheader('C','Created at',   "&OB=".$MYREQUEST['OB']),'</th>'; | |
| 999 | - | |
| 1000 | -	if($fieldname=='info') { | |
| 1001 | - $cols+=2; | |
| 1002 | -		 echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>'; | |
| 1003 | - } | |
| 1004 | -	echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>'; | |
| 946 | + echo | |
| 947 | + "<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>", | |
| 948 | + "<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>", | |
| 949 | + "</select>", | |
| 950 | + ", Sorting:<select name=SORT1>", | |
| 951 | + "<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Hits</option>", | |
| 952 | + "<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Size</option>", | |
| 953 | + "<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">$fieldheading</option>", | |
| 954 | + "<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Last accessed</option>", | |
| 955 | + "<option value=M",$MYREQUEST['SORT1']=='M' ? " selected":"",">Last modified</option>", | |
| 956 | + "<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Created at</option>", | |
| 957 | + "<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>"; | |
| 958 | + if($fieldname=='info') echo | |
| 959 | + "<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>"; | |
| 960 | + echo | |
| 961 | + '</select>', | |
| 962 | + '<select name=SORT2>', | |
| 963 | + '<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>', | |
| 964 | + '<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>', | |
| 965 | + '</select>', | |
| 966 | + '<select name=COUNT onChange="form.submit()">', | |
| 967 | + '<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>', | |
| 968 | + '<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>', | |
| 969 | + '<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>', | |
| 970 | + '<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>', | |
| 971 | + '<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>', | |
| 972 | + '<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>', | |
| 973 | + '<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>', | |
| 974 | + '<option value=0 ',$MYREQUEST['COUNT']=='0' ? ' selected':'','>All</option>', | |
| 975 | + '</select>', | |
| 976 | + '  Search: <input name=SEARCH value="',$MYREQUEST['SEARCH'],'" type=text size=25/>', | |
| 977 | + ' <input type=submit value="GO!">', | |
| 978 | + '</form></div>'; | |
| 979 | + | |
| 980 | +  	if (isset($MYREQUEST['SEARCH'])) { | |
| 981 | + // Don't use preg_quote because we want the user to be able to specify a | |
| 982 | + // regular expression subpattern. | |
| 983 | +   	$MYREQUEST['SEARCH'] = '/'.str_replace('/', '\\/', $MYREQUEST['SEARCH']).'/i'; | |
| 984 | +   	if (preg_match($MYREQUEST['SEARCH'], 'test') === false) { | |
| 985 | + echo '<div class="error">Error: enter a valid regular expression as a search query.</div>'; | |
| 986 | + break; | |
| 987 | + } | |
| 988 | + } | |
| 989 | + | |
| 990 | + echo | |
| 991 | + '<div class="info"><table cellspacing=0><tbody>', | |
| 992 | + '<tr>', | |
| 993 | +			'<th>',sortheader('S',$fieldheading,  "&OB=".$MYREQUEST['OB']),'</th>', | |
| 994 | +			'<th>',sortheader('H','Hits',         "&OB=".$MYREQUEST['OB']),'</th>', | |
| 995 | +			'<th>',sortheader('Z','Size',         "&OB=".$MYREQUEST['OB']),'</th>', | |
| 996 | +			'<th>',sortheader('A','Last accessed',"&OB=".$MYREQUEST['OB']),'</th>', | |
| 997 | +			'<th>',sortheader('M','Last modified',"&OB=".$MYREQUEST['OB']),'</th>', | |
| 998 | +			'<th>',sortheader('C','Created at',   "&OB=".$MYREQUEST['OB']),'</th>'; | |
| 999 | + | |
| 1000 | +		if($fieldname=='info') { | |
| 1001 | + $cols+=2; | |
| 1002 | +		 	echo '<th>',sortheader('T','Timeout',"&OB=".$MYREQUEST['OB']),'</th>'; | |
| 1003 | + } | |
| 1004 | +		echo '<th>',sortheader('D','Deleted at',"&OB=".$MYREQUEST['OB']),'</th></tr>'; | |
| 1005 | 1005 | |
| 1006 | - // builds list with alpha numeric sortable keys | |
| 1007 | - // | |
| 1008 | - $list = array(); | |
| 1006 | + // builds list with alpha numeric sortable keys | |
| 1007 | + // | |
| 1008 | + $list = array(); | |
| 1009 | 1009 | |
| 1010 | -	foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) { | |
| 1011 | -		switch($MYREQUEST['SORT1']) { | |
| 1010 | +		foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) { | |
| 1011 | +			switch($MYREQUEST['SORT1']) { | |
| 1012 | 1012 |  			case 'A': $k=sprintf('%015d-',$entry['access_time']);  	     break; | 
| 1013 | 1013 |  			case 'H': $k=sprintf('%015d-',$entry['num_hits']); 	     break; | 
| 1014 | 1014 |  			case 'Z': $k=sprintf('%015d-',$entry['mem_size']); 	     break; | 
| @@ -1017,7 +1017,7 @@ discard block | ||
| 1017 | 1017 |  			case 'T': $k=sprintf('%015d-',$entry['ttl']);		     break; | 
| 1018 | 1018 |  			case 'D': $k=sprintf('%015d-',$entry['deletion_time']);      break; | 
| 1019 | 1019 | case 'S': $k=$entry["info"]; break; | 
| 1020 | - } | |
| 1020 | + } | |
| 1021 | 1021 |  		if (!$AUTHENTICATED) { | 
| 1022 | 1022 | // hide all path entries if not logged in | 
| 1023 | 1023 |  			$list[$k.$entry[$fieldname]]=preg_replace('/^.*(\\/|\\\\)/','*hidden*/',$entry); | 
| @@ -1097,61 +1097,61 @@ discard block | ||
| 1097 | 1097 | // ----------------------------------------------- | 
| 1098 | 1098 | // Version check | 
| 1099 | 1099 | // ----------------------------------------------- | 
| 1100 | -case OB_VERSION_CHECK: | |
| 1101 | - echo <<<EOB | |
| 1100 | + case OB_VERSION_CHECK: | |
| 1101 | + echo <<<EOB | |
| 1102 | 1102 | <div class="info"><h2>APCu Version Information</h2> | 
| 1103 | 1103 | <table cellspacing=0><tbody> | 
| 1104 | 1104 | <tr> | 
| 1105 | 1105 | <th></th> | 
| 1106 | 1106 | </tr> | 
| 1107 | 1107 | EOB; | 
| 1108 | -  if (defined('PROXY')) { | |
| 1109 | - $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) ); | |
| 1110 | -    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt); | |
| 1111 | -  } else { | |
| 1112 | -    $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss"); | |
| 1113 | - } | |
| 1114 | -	if (!$rss) { | |
| 1115 | - echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>'; | |
| 1116 | -	} else { | |
| 1117 | -		$apcversion = phpversion('apcu'); | |
| 1118 | - | |
| 1119 | -		preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match); | |
| 1120 | - echo '<tr class="tr-0 center"><td>'; | |
| 1121 | -		if (version_compare($apcversion, $match[1], '>=')) { | |
| 1122 | -			echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>'; | |
| 1123 | - $i = 3; | |
| 1108 | +  	if (defined('PROXY')) { | |
| 1109 | + $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) ); | |
| 1110 | +    	$rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt); | |
| 1111 | +  	} else { | |
| 1112 | +    	$rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss"); | |
| 1113 | + } | |
| 1114 | +		if (!$rss) { | |
| 1115 | + echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>'; | |
| 1124 | 1116 |  		} else { | 
| 1125 | -			echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'), | |
| 1117 | +			$apcversion = phpversion('apcu'); | |
| 1118 | + | |
| 1119 | +			preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match); | |
| 1120 | + echo '<tr class="tr-0 center"><td>'; | |
| 1121 | +			if (version_compare($apcversion, $match[1], '>=')) { | |
| 1122 | +				echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>'; | |
| 1123 | + $i = 3; | |
| 1124 | +			} else { | |
| 1125 | +				echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'), | |
| 1126 | 1126 | newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APCu/'.$match[1].'"> | 
| 1127 | 1127 | http://pecl.php.net/package/APCu/'.$match[1].'</a> | 
| 1128 | 1128 | </div>'; | 
| 1129 | - $i = -1; | |
| 1130 | - } | |
| 1131 | - echo '</td></tr>'; | |
| 1132 | - echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>'; | |
| 1133 | - | |
| 1134 | -		preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match); | |
| 1135 | - next($match[2]); next($match[2]); | |
| 1136 | - | |
| 1137 | -		while (list(,$v) = each($match[2])) { | |
| 1138 | -			list(,$ver) = explode(' ', $v, 2); | |
| 1139 | -			if ($i < 0 && version_compare($apcversion, $ver, '>=')) { | |
| 1140 | - break; | |
| 1141 | -			} else if (!$i--) { | |
| 1142 | - break; | |
| 1129 | + $i = -1; | |
| 1130 | + } | |
| 1131 | + echo '</td></tr>'; | |
| 1132 | + echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>'; | |
| 1133 | + | |
| 1134 | +			preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match); | |
| 1135 | + next($match[2]); next($match[2]); | |
| 1136 | + | |
| 1137 | +			while (list(,$v) = each($match[2])) { | |
| 1138 | +				list(,$ver) = explode(' ', $v, 2); | |
| 1139 | +				if ($i < 0 && version_compare($apcversion, $ver, '>=')) { | |
| 1140 | + break; | |
| 1141 | +				} else if (!$i--) { | |
| 1142 | + break; | |
| 1143 | + } | |
| 1144 | + echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>"; | |
| 1145 | + echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>"; | |
| 1146 | + next($match[2]); | |
| 1143 | 1147 | } | 
| 1144 | - echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>"; | |
| 1145 | - echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>"; | |
| 1146 | - next($match[2]); | |
| 1148 | + echo '</td></tr>'; | |
| 1147 | 1149 | } | 
| 1148 | - echo '</td></tr>'; | |
| 1149 | - } | |
| 1150 | - echo <<< EOB | |
| 1150 | + echo <<< EOB | |
| 1151 | 1151 | </tbody></table> | 
| 1152 | 1152 | </div> | 
| 1153 | 1153 | EOB; | 
| 1154 | - break; | |
| 1154 | + break; | |
| 1155 | 1155 | |
| 1156 | 1156 | } | 
| 1157 | 1157 | |
| @@ -584,214 +584,214 @@ discard block | ||
| 584 | 584 | |
| 585 | 585 | switch((string)$button) | 
| 586 | 586 |  		{ | 
| 587 | - case 'exception': // create an exception in a recuring event | |
| 588 | - $msg = $this->_create_exception($event,$preserv); | |
| 589 | - break; | |
| 587 | + case 'exception': // create an exception in a recuring event | |
| 588 | + $msg = $this->_create_exception($event,$preserv); | |
| 589 | + break; | |
| 590 | 590 | |
| 591 | - case 'copy': // create new event with copied content, some content need to be unset to make a "new" event | |
| 592 | - unset($event['id']); | |
| 593 | - unset($event['uid']); | |
| 594 | - unset($event['reference']); | |
| 595 | - unset($preserv['reference']); | |
| 596 | - unset($event['recurrence']); | |
| 597 | - unset($preserv['recurrence']); | |
| 598 | - unset($event['recur_exception']); | |
| 599 | - unset($event['edit_single']); // in case it has been set | |
| 600 | - unset($event['modified']); | |
| 601 | - unset($event['modifier']); | |
| 602 | - unset($event['caldav_name']); | |
| 603 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; | |
| 591 | + case 'copy': // create new event with copied content, some content need to be unset to make a "new" event | |
| 592 | + unset($event['id']); | |
| 593 | + unset($event['uid']); | |
| 594 | + unset($event['reference']); | |
| 595 | + unset($preserv['reference']); | |
| 596 | + unset($event['recurrence']); | |
| 597 | + unset($preserv['recurrence']); | |
| 598 | + unset($event['recur_exception']); | |
| 599 | + unset($event['edit_single']); // in case it has been set | |
| 600 | + unset($event['modified']); | |
| 601 | + unset($event['modifier']); | |
| 602 | + unset($event['caldav_name']); | |
| 603 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; | |
| 604 | + | |
| 605 | + // Clear participant stati | |
| 606 | + foreach($event['participant_types'] as $type => &$participants) | |
| 607 | +				{ | |
| 608 | + foreach($participants as $id => &$p_response) | |
| 609 | +					{ | |
| 610 | + if($type == 'u' && $id == $event['owner']) continue; | |
| 611 | + calendar_so::split_status($p_response, $quantity, $role); | |
| 612 | + // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it | |
| 613 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; | |
| 614 | + $p_response = calendar_so::combine_status($status,$quantity,$role); | |
| 615 | + } | |
| 616 | + } | |
| 604 | 617 | |
| 605 | - // Clear participant stati | |
| 606 | - foreach($event['participant_types'] as $type => &$participants) | |
| 607 | -			{ | |
| 608 | - foreach($participants as $id => &$p_response) | |
| 618 | + // Copy alarms | |
| 619 | + if (is_array($event['alarm'])) | |
| 609 | 620 |  				{ | 
| 610 | - if($type == 'u' && $id == $event['owner']) continue; | |
| 611 | - calendar_so::split_status($p_response, $quantity, $role); | |
| 612 | - // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it | |
| 613 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; | |
| 614 | - $p_response = calendar_so::combine_status($status,$quantity,$role); | |
| 621 | + foreach($event['alarm'] as $n => &$alarm) | |
| 622 | +					{ | |
| 623 | + unset($alarm['id']); | |
| 624 | + unset($alarm['cal_id']); | |
| 625 | + } | |
| 615 | 626 | } | 
| 616 | - } | |
| 617 | 627 | |
| 618 | - // Copy alarms | |
| 619 | - if (is_array($event['alarm'])) | |
| 620 | -			{ | |
| 621 | - foreach($event['alarm'] as $n => &$alarm) | |
| 628 | + // Get links to be copied | |
| 629 | + // With no ID, $content['link_to']['to_id'] is used | |
| 630 | +				$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); | |
| 631 | +				foreach(Link::get_links('calendar', $content['id']) as $link) | |
| 622 | 632 |  				{ | 
| 623 | - unset($alarm['id']); | |
| 624 | - unset($alarm['cal_id']); | |
| 633 | + if ($link['app'] != Link::VFS_APPNAME) | |
| 634 | +					{ | |
| 635 | +						Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); | |
| 636 | + } | |
| 637 | + elseif ($link['app'] == Link::VFS_APPNAME) | |
| 638 | +					{ | |
| 639 | +						Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( | |
| 640 | + 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], | |
| 641 | + 'name' => $link['id'], | |
| 642 | + ), $link['remark']); | |
| 643 | + } | |
| 625 | 644 | } | 
| 626 | - } | |
| 645 | + unset($link); | |
| 646 | + $preserv['view'] = $preserv['edit_single'] = false; | |
| 647 | +				$msg = lang('Event copied - the copy can now be edited'); | |
| 648 | +				$event['title'] = lang('Copy of:').' '.$event['title']; | |
| 649 | + break; | |
| 627 | 650 | |
| 628 | - // Get links to be copied | |
| 629 | - // With no ID, $content['link_to']['to_id'] is used | |
| 630 | -			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); | |
| 631 | -			foreach(Link::get_links('calendar', $content['id']) as $link) | |
| 632 | -			{ | |
| 633 | - if ($link['app'] != Link::VFS_APPNAME) | |
| 651 | + case 'mail': | |
| 652 | + case 'sendrequest': | |
| 653 | + case 'save': | |
| 654 | + case 'print': | |
| 655 | + case 'apply': | |
| 656 | + case 'infolog': | |
| 657 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) | |
| 634 | 658 |  				{ | 
| 635 | -					Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); | |
| 659 | +					$msg = lang('Permission denied'); | |
| 660 | + $button = ''; | |
| 661 | + break; | |
| 636 | 662 | } | 
| 637 | - elseif ($link['app'] == Link::VFS_APPNAME) | |
| 663 | + if ($event['start'] > $event['end']) | |
| 638 | 664 |  				{ | 
| 639 | -					Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( | |
| 640 | - 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], | |
| 641 | - 'name' => $link['id'], | |
| 642 | - ), $link['remark']); | |
| 665 | +					$msg = lang('Error: Starttime has to be before the endtime !!!'); | |
| 666 | + $button = ''; | |
| 667 | + break; | |
| 643 | 668 | } | 
| 644 | - } | |
| 645 | - unset($link); | |
| 646 | - $preserv['view'] = $preserv['edit_single'] = false; | |
| 647 | -			$msg = lang('Event copied - the copy can now be edited'); | |
| 648 | -			$event['title'] = lang('Copy of:').' '.$event['title']; | |
| 649 | - break; | |
| 650 | - | |
| 651 | - case 'mail': | |
| 652 | - case 'sendrequest': | |
| 653 | - case 'save': | |
| 654 | - case 'print': | |
| 655 | - case 'apply': | |
| 656 | - case 'infolog': | |
| 657 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) | |
| 658 | -			{ | |
| 659 | -				$msg = lang('Permission denied'); | |
| 660 | - $button = ''; | |
| 661 | - break; | |
| 662 | - } | |
| 663 | - if ($event['start'] > $event['end']) | |
| 664 | -			{ | |
| 665 | -				$msg = lang('Error: Starttime has to be before the endtime !!!'); | |
| 666 | - $button = ''; | |
| 667 | - break; | |
| 668 | - } | |
| 669 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) | |
| 670 | -			{ | |
| 671 | -				$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); | |
| 672 | - $button = ''; | |
| 673 | - break; | |
| 674 | - } | |
| 675 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) | |
| 676 | -			{ | |
| 677 | -				$msg = lang('Error: Duration of event longer then recurrence interval!'); | |
| 678 | - $button = ''; | |
| 679 | - break; | |
| 680 | - } | |
| 681 | - if (!$event['participants']) | |
| 682 | -			{ | |
| 683 | -				$msg = lang('Error: no participants selected !!!'); | |
| 684 | - $button = ''; | |
| 685 | - break; | |
| 686 | - } | |
| 687 | - // if private event with ressource reservation is forbidden | |
| 688 | - if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) | |
| 689 | -			{ | |
| 690 | - foreach (array_keys($event['participants']) as $uid) | |
| 669 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) | |
| 691 | 670 |  				{ | 
| 692 | - if ($uid[0] == 'r') //ressource detection | |
| 671 | +					$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); | |
| 672 | + $button = ''; | |
| 673 | + break; | |
| 674 | + } | |
| 675 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) | |
| 676 | +				{ | |
| 677 | +					$msg = lang('Error: Duration of event longer then recurrence interval!'); | |
| 678 | + $button = ''; | |
| 679 | + break; | |
| 680 | + } | |
| 681 | + if (!$event['participants']) | |
| 682 | +				{ | |
| 683 | +					$msg = lang('Error: no participants selected !!!'); | |
| 684 | + $button = ''; | |
| 685 | + break; | |
| 686 | + } | |
| 687 | + // if private event with ressource reservation is forbidden | |
| 688 | + if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) | |
| 689 | +				{ | |
| 690 | + foreach (array_keys($event['participants']) as $uid) | |
| 693 | 691 |  					{ | 
| 694 | -						$msg = lang('Error: ressources reservation in private events is not allowed!!!'); | |
| 695 | - $button = ''; | |
| 696 | - break 2; //break foreach and case | |
| 692 | + if ($uid[0] == 'r') //ressource detection | |
| 693 | +						{ | |
| 694 | +							$msg = lang('Error: ressources reservation in private events is not allowed!!!'); | |
| 695 | + $button = ''; | |
| 696 | + break 2; //break foreach and case | |
| 697 | + } | |
| 697 | 698 | } | 
| 698 | 699 | } | 
| 699 | - } | |
| 700 | - if ($content['edit_single']) // we edited a single event from a series | |
| 701 | -			{ | |
| 702 | - $event['reference'] = $event['id']; | |
| 703 | - $event['recurrence'] = $content['edit_single']; | |
| 704 | - unset($event['id']); | |
| 705 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); | |
| 706 | - if (!is_array($conflicts) && $conflicts) | |
| 700 | + if ($content['edit_single']) // we edited a single event from a series | |
| 707 | 701 |  				{ | 
| 708 | - // now we need to add the original start as recur-execption to the series | |
| 709 | - $recur_event = $this->bo->read($event['reference']); | |
| 710 | - $recur_event['recur_exception'][] = $content['edit_single']; | |
| 711 | - // check if we need to move the alarms, because they are next on that exception | |
| 712 | - foreach($recur_event['alarm'] as $id => $alarm) | |
| 702 | + $event['reference'] = $event['id']; | |
| 703 | + $event['recurrence'] = $content['edit_single']; | |
| 704 | + unset($event['id']); | |
| 705 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); | |
| 706 | + if (!is_array($conflicts) && $conflicts) | |
| 713 | 707 |  					{ | 
| 714 | - if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) | |
| 708 | + // now we need to add the original start as recur-execption to the series | |
| 709 | + $recur_event = $this->bo->read($event['reference']); | |
| 710 | + $recur_event['recur_exception'][] = $content['edit_single']; | |
| 711 | + // check if we need to move the alarms, because they are next on that exception | |
| 712 | + foreach($recur_event['alarm'] as $id => $alarm) | |
| 715 | 713 |  						{ | 
| 716 | - $rrule = calendar_rrule::event2rrule($recur_event, true); | |
| 717 | - foreach ($rrule as $time) | |
| 714 | + if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) | |
| 718 | 715 |  							{ | 
| 719 | -								if ($content['edit_single'] < $time->format('ts')) | |
| 716 | + $rrule = calendar_rrule::event2rrule($recur_event, true); | |
| 717 | + foreach ($rrule as $time) | |
| 720 | 718 |  								{ | 
| 721 | -									$alarm['time'] = $time->format('ts') - $alarm['offset']; | |
| 722 | - $this->bo->save_alarm($event['reference'], $alarm); | |
| 723 | - break; | |
| 719 | +									if ($content['edit_single'] < $time->format('ts')) | |
| 720 | +									{ | |
| 721 | +										$alarm['time'] = $time->format('ts') - $alarm['offset']; | |
| 722 | + $this->bo->save_alarm($event['reference'], $alarm); | |
| 723 | + break; | |
| 724 | + } | |
| 724 | 725 | } | 
| 725 | 726 | } | 
| 726 | 727 | } | 
| 727 | - } | |
| 728 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary | |
| 729 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! | |
| 730 | - $this->bo->update($recur_event,true); // no conflict check here | |
| 728 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary | |
| 729 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! | |
| 730 | + $this->bo->update($recur_event,true); // no conflict check here | |
| 731 | 731 | |
| 732 | - if(Api\Json\Response::isJSONResponse()) | |
| 732 | + if(Api\Json\Response::isJSONResponse()) | |
| 733 | +						{ | |
| 734 | + // Sending null will trigger a removal of the original | |
| 735 | + // for that date | |
| 736 | +							Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); | |
| 737 | + } | |
| 738 | + | |
| 739 | + unset($recur_event); | |
| 740 | + unset($event['edit_single']); // if we further edit it, it's just a single event | |
| 741 | + unset($preserv['edit_single']); | |
| 742 | + } | |
| 743 | + else // conflict or error, we need to reset everything to the state befor we tried to save it | |
| 733 | 744 |  					{ | 
| 734 | - // Sending null will trigger a removal of the original | |
| 735 | - // for that date | |
| 736 | -						Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); | |
| 745 | + $event['id'] = $event['reference']; | |
| 746 | + $event['reference'] = $event['recurrence'] = 0; | |
| 747 | + $event['uid'] = $content['uid']; | |
| 737 | 748 | } | 
| 738 | - | |
| 739 | - unset($recur_event); | |
| 740 | - unset($event['edit_single']); // if we further edit it, it's just a single event | |
| 741 | - unset($preserv['edit_single']); | |
| 742 | - } | |
| 743 | - else // conflict or error, we need to reset everything to the state befor we tried to save it | |
| 744 | -				{ | |
| 745 | - $event['id'] = $event['reference']; | |
| 746 | - $event['reference'] = $event['recurrence'] = 0; | |
| 747 | - $event['uid'] = $content['uid']; | |
| 749 | + $update_type = 'edit'; | |
| 748 | 750 | } | 
| 749 | - $update_type = 'edit'; | |
| 750 | - } | |
| 751 | - else // we edited a non-reccuring event or the whole series | |
| 752 | -			{ | |
| 753 | - if (($old_event = $this->bo->read($event['id']))) | |
| 751 | + else // we edited a non-reccuring event or the whole series | |
| 754 | 752 |  				{ | 
| 755 | - if ($event['recur_type'] != MCAL_RECUR_NONE) | |
| 753 | + if (($old_event = $this->bo->read($event['id']))) | |
| 756 | 754 |  					{ | 
| 757 | - $update_type = 'edit'; | |
| 758 | - | |
| 759 | - // we edit a existing series event | |
| 760 | - if ($event['start'] != $old_event['start'] || | |
| 761 | - $event['whole_day'] != $old_event['whole_day'] || | |
| 762 | - $event['end'] != $old_event['end']) | |
| 755 | + if ($event['recur_type'] != MCAL_RECUR_NONE) | |
| 763 | 756 |  						{ | 
| 764 | - // calculate offset against old series start or clicked recurrance, | |
| 765 | - // depending on which is smaller | |
| 766 | - $offset = $event['start'] - $old_event['start']; | |
| 767 | - if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) | |
| 768 | -							{ | |
| 769 | - $offset = $off2; | |
| 770 | - } | |
| 771 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); | |
| 772 | - if($msg) | |
| 757 | + $update_type = 'edit'; | |
| 758 | + | |
| 759 | + // we edit a existing series event | |
| 760 | + if ($event['start'] != $old_event['start'] || | |
| 761 | + $event['whole_day'] != $old_event['whole_day'] || | |
| 762 | + $event['end'] != $old_event['end']) | |
| 773 | 763 |  							{ | 
| 774 | - $noerror = false; | |
| 764 | + // calculate offset against old series start or clicked recurrance, | |
| 765 | + // depending on which is smaller | |
| 766 | + $offset = $event['start'] - $old_event['start']; | |
| 767 | + if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) | |
| 768 | +								{ | |
| 769 | + $offset = $off2; | |
| 770 | + } | |
| 771 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); | |
| 772 | + if($msg) | |
| 773 | +								{ | |
| 774 | + $noerror = false; | |
| 775 | + } | |
| 775 | 776 | } | 
| 776 | 777 | } | 
| 777 | - } | |
| 778 | - else | |
| 779 | -					{ | |
| 780 | - if ($old_event['start'] != $event['start'] || | |
| 781 | - $old_event['end'] != $event['end'] || | |
| 782 | - $event['whole_day'] != $old_event['whole_day']) | |
| 778 | + else | |
| 783 | 779 |  						{ | 
| 784 | -							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); | |
| 785 | - foreach((array)$event['participants'] as $uid => $status) | |
| 780 | + if ($old_event['start'] != $event['start'] || | |
| 781 | + $old_event['end'] != $event['end'] || | |
| 782 | + $event['whole_day'] != $old_event['whole_day']) | |
| 786 | 783 |  							{ | 
| 787 | - $q = $r = null; | |
| 788 | - calendar_so::split_status($status,$q,$r); | |
| 789 | - if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') | |
| 784 | +								$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); | |
| 785 | + foreach((array)$event['participants'] as $uid => $status) | |
| 790 | 786 |  								{ | 
| 791 | - $preferences = new Api\Preferences($uid); | |
| 792 | - $part_prefs = $preferences->read_repository(); | |
| 793 | - switch ($part_prefs['calendar']['reset_stati']) | |
| 787 | + $q = $r = null; | |
| 788 | + calendar_so::split_status($status,$q,$r); | |
| 789 | + if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') | |
| 794 | 790 |  									{ | 
| 791 | + $preferences = new Api\Preferences($uid); | |
| 792 | + $part_prefs = $preferences->read_repository(); | |
| 793 | + switch ($part_prefs['calendar']['reset_stati']) | |
| 794 | +										{ | |
| 795 | 795 | case 'no': | 
| 796 | 796 | break; | 
| 797 | 797 | case 'startday': | 
| @@ -800,7 +800,7 @@ discard block | ||
| 800 | 800 | $status_reset_to_unknown = true; | 
| 801 | 801 |  											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); | 
| 802 | 802 | // todo: report reset status to user | 
| 803 | - } | |
| 803 | + } | |
| 804 | 804 | } | 
| 805 | 805 | } | 
| 806 | 806 | // check if we need to move the alarms, because they are relative | 
| @@ -942,83 +942,83 @@ discard block | ||
| 942 | 942 | } | 
| 943 | 943 | break; | 
| 944 | 944 | |
| 945 | - case 'cancel': | |
| 946 | - if($content['cancel_needs_refresh']) | |
| 947 | -			{ | |
| 948 | - Framework::refresh_opener($msg, 'calendar'); | |
| 949 | - } | |
| 950 | - break; | |
| 951 | - | |
| 952 | - case 'delete': // delete of event (regular or series) | |
| 953 | - $exceptions_kept = null; | |
| 954 | - if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], | |
| 955 | - $content['delete_exceptions'] == 'true', $exceptions_kept)) | |
| 956 | -			{ | |
| 957 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) | |
| 945 | + case 'cancel': | |
| 946 | + if($content['cancel_needs_refresh']) | |
| 958 | 947 |  				{ | 
| 959 | -					$msg = lang('Series deleted'); | |
| 960 | -					if ($exceptions_kept) $msg .= lang(', exceptions preserved'); | |
| 948 | + Framework::refresh_opener($msg, 'calendar'); | |
| 961 | 949 | } | 
| 962 | - else | |
| 950 | + break; | |
| 951 | + | |
| 952 | + case 'delete': // delete of event (regular or series) | |
| 953 | + $exceptions_kept = null; | |
| 954 | + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], | |
| 955 | + $content['delete_exceptions'] == 'true', $exceptions_kept)) | |
| 963 | 956 |  				{ | 
| 964 | -					$msg = lang('Event deleted'); | |
| 965 | - } | |
| 957 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) | |
| 958 | +					{ | |
| 959 | +						$msg = lang('Series deleted'); | |
| 960 | +						if ($exceptions_kept) $msg .= lang(', exceptions preserved'); | |
| 961 | + } | |
| 962 | + else | |
| 963 | +					{ | |
| 964 | +						$msg = lang('Event deleted'); | |
| 965 | + } | |
| 966 | 966 | |
| 967 | - } | |
| 968 | - break; | |
| 967 | + } | |
| 968 | + break; | |
| 969 | 969 | |
| 970 | - case 'freetime': | |
| 971 | - // the "click" has to be in onload, to make sure the button is already created | |
| 972 | - $event['button_was'] = $button; | |
| 973 | - break; | |
| 970 | + case 'freetime': | |
| 971 | + // the "click" has to be in onload, to make sure the button is already created | |
| 972 | + $event['button_was'] = $button; | |
| 973 | + break; | |
| 974 | 974 | |
| 975 | - case 'add_alarm': | |
| 976 | - $time = $content['start']; | |
| 977 | - $offset = $time - $content['new_alarm']['date']; | |
| 978 | - if ($event['recur_type'] != MCAL_RECUR_NONE && | |
| 979 | - ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && | |
| 980 | - $time < $next_occurrence['start']) | |
| 981 | -			{ | |
| 982 | - $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; | |
| 983 | - } | |
| 984 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) | |
| 985 | -			{ | |
| 986 | - $alarm = array( | |
| 987 | - 'offset' => $offset, | |
| 988 | - 'time' => $content['new_alarm']['date'], | |
| 989 | - 'all' => !$content['new_alarm']['owner'], | |
| 990 | - 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, | |
| 991 | - ); | |
| 992 | - if ($alarm['time'] < $this->bo->now_su) | |
| 975 | + case 'add_alarm': | |
| 976 | + $time = $content['start']; | |
| 977 | + $offset = $time - $content['new_alarm']['date']; | |
| 978 | + if ($event['recur_type'] != MCAL_RECUR_NONE && | |
| 979 | + ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && | |
| 980 | + $time < $next_occurrence['start']) | |
| 993 | 981 |  				{ | 
| 994 | -					$msg = lang("Can't add alarms in the past !!!"); | |
| 982 | + $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; | |
| 995 | 983 | } | 
| 996 | - elseif ($event['id']) // save the alarm immediatly | |
| 984 | + if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) | |
| 997 | 985 |  				{ | 
| 998 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) | |
| 986 | + $alarm = array( | |
| 987 | + 'offset' => $offset, | |
| 988 | + 'time' => $content['new_alarm']['date'], | |
| 989 | + 'all' => !$content['new_alarm']['owner'], | |
| 990 | + 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, | |
| 991 | + ); | |
| 992 | + if ($alarm['time'] < $this->bo->now_su) | |
| 993 | +					{ | |
| 994 | +						$msg = lang("Can't add alarms in the past !!!"); | |
| 995 | + } | |
| 996 | + elseif ($event['id']) // save the alarm immediatly | |
| 999 | 997 |  					{ | 
| 1000 | - $alarm['id'] = $alarm_id; | |
| 1001 | - $event['alarm'][$alarm_id] = $alarm; | |
| 998 | + if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) | |
| 999 | +						{ | |
| 1000 | + $alarm['id'] = $alarm_id; | |
| 1001 | + $event['alarm'][$alarm_id] = $alarm; | |
| 1002 | 1002 | |
| 1003 | -						$msg = lang('Alarm added'); | |
| 1004 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); | |
| 1003 | +							$msg = lang('Alarm added'); | |
| 1004 | + Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); | |
| 1005 | + } | |
| 1006 | + else | |
| 1007 | +						{ | |
| 1008 | +							$msg = lang('Error adding the alarm'); | |
| 1009 | + } | |
| 1005 | 1010 | } | 
| 1006 | 1011 | else | 
| 1007 | 1012 |  					{ | 
| 1008 | -						$msg = lang('Error adding the alarm'); | |
| 1013 | +						for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id | |
| 1014 | + $event['alarm'][$alarm['id']] = $alarm; | |
| 1009 | 1015 | } | 
| 1010 | 1016 | } | 
| 1011 | 1017 | else | 
| 1012 | 1018 |  				{ | 
| 1013 | -					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id | |
| 1014 | - $event['alarm'][$alarm['id']] = $alarm; | |
| 1019 | +					$msg = lang('Permission denied'); | |
| 1015 | 1020 | } | 
| 1016 | - } | |
| 1017 | - else | |
| 1018 | -			{ | |
| 1019 | -				$msg = lang('Permission denied'); | |
| 1020 | - } | |
| 1021 | - break; | |
| 1021 | + break; | |
| 1022 | 1022 | } | 
| 1023 | 1023 | // add notification-errors, if we have some | 
| 1024 | 1024 | if (($notification_errors = notifications::errors(true))) |