@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public static function sass(string $path) |
193 | 193 | { |
194 | - \Cookie\helper::one('sass' . self::$key, 'compiler', 1, function () use ($path) { |
|
194 | + \Cookie\helper::one('sass' . self::$key, 'compiler', 1, function() use ($path) { |
|
195 | 195 | if (is_file($path)) { |
196 | 196 | if (self::is_windows()) { |
197 | 197 | $path = self::fixSlash($path); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | public static function babel(string $path) |
244 | 244 | { |
245 | - \Cookie\helper::one('babel' . self::$key, 'compiler', 1, function () use ($path) { |
|
245 | + \Cookie\helper::one('babel' . self::$key, 'compiler', 1, function() use ($path) { |
|
246 | 246 | if (is_file($path)) { |
247 | 247 | if (self::is_windows()) { |
248 | 248 | $path = self::fixSlash($path); |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); |
651 | 651 | header('Access-Control-Expose-Headers: date,content-type,transfer-encoding,connection,access-control-allow-origin,server,x-xss-protection,x-content-type-options,x-request-id,content-encoding,x-final-url'); |
652 | 652 | header('Access-Control-Allow-Credentials: true'); |
653 | - header('Access-Control-Max-Age: 86400'); // cache for 1 day |
|
653 | + header('Access-Control-Max-Age: 86400'); // cache for 1 day |
|
654 | 654 | if (isset($_SERVER['HTTP_REFERER'])) { |
655 | 655 | $parseRef = parse_url($_SERVER['HTTP_REFERER']); |
656 | 656 | $parseOri = parse_url($_SERVER['HTTP_ORIGIN']); |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | */ |
929 | 929 | public static function get_url_path($path, bool $cache = null) |
930 | 930 | { |
931 | - $load = function (string $path) use ($cache) { |
|
931 | + $load = function(string $path) use ($cache) { |
|
932 | 932 | if ($realpath = realpath($path)) { |
933 | 933 | $f = str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', $realpath); |
934 | 934 | |
@@ -980,9 +980,9 @@ discard block |
||
980 | 980 | return $buffer; |
981 | 981 | } |
982 | 982 | $search = [ |
983 | - '/\>[^\S ]+/s', // strip whitespaces after tags, except space |
|
984 | - '/[^\S ]+\</s', // strip whitespaces before tags, except space |
|
985 | - '/(\s)+/s', // shorten multiple whitespace sequences |
|
983 | + '/\>[^\S ]+/s', // strip whitespaces after tags, except space |
|
984 | + '/[^\S ]+\</s', // strip whitespaces before tags, except space |
|
985 | + '/(\s)+/s', // shorten multiple whitespace sequences |
|
986 | 986 | '/<!--(.|\s)*?-->/', // Remove HTML comments |
987 | 987 | ]; |
988 | 988 |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | if (isset($_POST['config'])) { |
8 | 8 | unset($_POST['config']); |
9 | - array_walk_recursive($_POST, function (&$key, $value) { |
|
9 | + array_walk_recursive($_POST, function(&$key, $value) { |
|
10 | 10 | if (preg_match('/^(true|false)$/s', $key, $match)) { |
11 | 11 | if ($match[0] == 'true') { |
12 | 12 | $key = true; |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | -if (!user()->is_admin()){ |
|
2 | +if (!user()->is_admin()) { |
|
3 | 3 | safe_redirect('/'); |
4 | 4 | } |
5 | 5 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | if (isset($package['devDependencies'])) { |
23 | 23 | $packages = array_merge($package['devDependencies'], $packages); |
24 | 24 | } |
25 | -$packages = array_map(function ($pkg) { |
|
25 | +$packages = array_map(function($pkg) { |
|
26 | 26 | //var_dump($pkg); |
27 | 27 | if (false === strpos($pkg, '@types/')) { |
28 | 28 | return $pkg; |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | } |
32 | 32 | }, array_keys($packages)); |
33 | 33 | $packages = array_values(array_filter($packages)); |
34 | -$packages = array_map(function ($pkg) { |
|
34 | +$packages = array_map(function($pkg) { |
|
35 | 35 | return "@types/$pkg"; |
36 | 36 | }, $packages); |
37 | 37 | |
38 | 38 | if (isset($package['devDependencies'])) { |
39 | - array_map(function ($types) { |
|
39 | + array_map(function($types) { |
|
40 | 40 | $package['devDependencies'][$types] = '*'; |
41 | 41 | }, $packages); |
42 | 42 | } |
43 | 43 | |
44 | 44 | \Filemanager\file::file($location, $package, true); |
45 | 45 | |
46 | -$cmd = function ($pkg) { |
|
46 | +$cmd = function($pkg) { |
|
47 | 47 | return 'cd ' . ROOT . ' && echo "Installing ' . $pkg . ' On %cd%" && '; |
48 | 48 | }; |
49 | 49 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $data = $p->fetchAll(); |
36 | 36 | $result['recordsTotal'] = count($data); |
37 | 37 | $result['recordsFiltered'] = (int) count($data); |
38 | -$data_filter = array_map(function ($map_data) { |
|
38 | +$data_filter = array_map(function($map_data) { |
|
39 | 39 | $i = 0; |
40 | 40 | foreach ($map_data as $key => $value) { |
41 | 41 | if (is_numeric($value)) { |
@@ -386,7 +386,7 @@ |
||
386 | 386 | throw new Exception('Callback must be function', 1); |
387 | 387 | } |
388 | 388 | |
389 | - return array_map(function ($key, $val) use ($callback) { |
|
389 | + return array_map(function($key, $val) use ($callback) { |
|
390 | 390 | return call_user_func($callback, $key, $val); |
391 | 391 | }, array_keys($arr), $arr); |
392 | 392 | } |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | |
25 | 25 | // Constructs an Event object from the given array of key=>values. |
26 | 26 | // You can optionally force the timezone of the parsed dates. |
27 | - public function __construct($array, $timezone=null) { |
|
27 | + public function __construct($array, $timezone = null) { |
|
28 | 28 | |
29 | 29 | $this->title = $array['title']; |
30 | 30 | |
31 | 31 | if (isset($array['allDay'])) { |
32 | 32 | // allDay has been explicitly specified |
33 | - $this->allDay = (bool)$array['allDay']; |
|
33 | + $this->allDay = (bool) $array['allDay']; |
|
34 | 34 | } |
35 | 35 | else { |
36 | 36 | // Guess allDay based off of ISO8601 date strings |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | |
110 | 110 | // Parses a string into a DateTime object, optionally forced into the given timezone. |
111 | -function parseDateTime($string, $timezone=null) { |
|
111 | +function parseDateTime($string, $timezone = null) { |
|
112 | 112 | $date = new DateTime( |
113 | 113 | $string, |
114 | 114 | $timezone ? $timezone : new DateTimeZone('UTC') |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | if (isset($array['allDay'])) { |
32 | 32 | // allDay has been explicitly specified |
33 | 33 | $this->allDay = (bool)$array['allDay']; |
34 | - } |
|
35 | - else { |
|
34 | + } else { |
|
36 | 35 | // Guess allDay based off of ISO8601 date strings |
37 | 36 | $this->allDay = preg_match(self::ALL_DAY_REGEX, $array['start']) && |
38 | 37 | (!isset($array['end']) || preg_match(self::ALL_DAY_REGEX, $array['end'])); |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | |
66 | 65 | if (isset($this->end)) { |
67 | 66 | $eventEnd = stripTime($this->end); // normalize |
68 | - } |
|
69 | - else { |
|
67 | + } else { |
|
70 | 68 | $eventEnd = $eventStart; // consider this a zero-duration event |
71 | 69 | } |
72 | 70 | |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | // Figure out the date format. This essentially encodes allDay into the date string. |
87 | 85 | if ($this->allDay) { |
88 | 86 | $format = 'Y-m-d'; // output like "2013-12-29" |
89 | - } |
|
90 | - else { |
|
87 | + } else { |
|
91 | 88 | $format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00" |
92 | 89 | } |
93 | 90 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | // Short-circuit if the client did not give us a date range. |
16 | 16 | if (!isset($_GET['start']) || !isset($_GET['end'])) { |
17 | - die("Please provide a date range."); |
|
17 | + die("Please provide a date range."); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | // Parse the start/end parameters. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | // Parse the timezone parameter if it is present. |
27 | 27 | $timezone = null; |
28 | 28 | if (isset($_GET['timezone'])) { |
29 | - $timezone = new DateTimeZone($_GET['timezone']); |
|
29 | + $timezone = new DateTimeZone($_GET['timezone']); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | // Read and parse our events JSON file into an array of event data arrays. |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | $output_arrays = array(); |
38 | 38 | foreach ($input_arrays as $array) { |
39 | 39 | |
40 | - // Convert the input array into a useful Event object |
|
41 | - $event = new Event($array, $timezone); |
|
40 | + // Convert the input array into a useful Event object |
|
41 | + $event = new Event($array, $timezone); |
|
42 | 42 | |
43 | - // If the event is in-bounds, add it to the output |
|
44 | - if ($event->isWithinDayRange($range_start, $range_end)) { |
|
45 | - $output_arrays[] = $event->toArray(); |
|
46 | - } |
|
43 | + // If the event is in-bounds, add it to the output |
|
44 | + if ($event->isWithinDayRange($range_start, $range_end)) { |
|
45 | + $output_arrays[] = $event->toArray(); |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // Send JSON to the client. |
@@ -12,93 +12,93 @@ discard block |
||
12 | 12 | |
13 | 13 | class Event { |
14 | 14 | |
15 | - // Tests whether the given ISO8601 string has a time-of-day or not |
|
16 | - const ALL_DAY_REGEX = '/^\d{4}-\d\d-\d\d$/'; // matches strings like "2013-12-29" |
|
17 | - |
|
18 | - public $title; |
|
19 | - public $allDay; // a boolean |
|
20 | - public $start; // a DateTime |
|
21 | - public $end; // a DateTime, or null |
|
22 | - public $properties = array(); // an array of other misc properties |
|
23 | - |
|
24 | - |
|
25 | - // Constructs an Event object from the given array of key=>values. |
|
26 | - // You can optionally force the timezone of the parsed dates. |
|
27 | - public function __construct($array, $timezone=null) { |
|
28 | - |
|
29 | - $this->title = $array['title']; |
|
30 | - |
|
31 | - if (isset($array['allDay'])) { |
|
32 | - // allDay has been explicitly specified |
|
33 | - $this->allDay = (bool)$array['allDay']; |
|
34 | - } |
|
35 | - else { |
|
36 | - // Guess allDay based off of ISO8601 date strings |
|
37 | - $this->allDay = preg_match(self::ALL_DAY_REGEX, $array['start']) && |
|
38 | - (!isset($array['end']) || preg_match(self::ALL_DAY_REGEX, $array['end'])); |
|
39 | - } |
|
40 | - |
|
41 | - if ($this->allDay) { |
|
42 | - // If dates are allDay, we want to parse them in UTC to avoid DST issues. |
|
43 | - $timezone = null; |
|
44 | - } |
|
45 | - |
|
46 | - // Parse dates |
|
47 | - $this->start = parseDateTime($array['start'], $timezone); |
|
48 | - $this->end = isset($array['end']) ? parseDateTime($array['end'], $timezone) : null; |
|
49 | - |
|
50 | - // Record misc properties |
|
51 | - foreach ($array as $name => $value) { |
|
52 | - if (!in_array($name, array('title', 'allDay', 'start', 'end'))) { |
|
53 | - $this->properties[$name] = $value; |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - // Returns whether the date range of our event intersects with the given all-day range. |
|
60 | - // $rangeStart and $rangeEnd are assumed to be dates in UTC with 00:00:00 time. |
|
61 | - public function isWithinDayRange($rangeStart, $rangeEnd) { |
|
62 | - |
|
63 | - // Normalize our event's dates for comparison with the all-day range. |
|
64 | - $eventStart = stripTime($this->start); |
|
65 | - |
|
66 | - if (isset($this->end)) { |
|
67 | - $eventEnd = stripTime($this->end); // normalize |
|
68 | - } |
|
69 | - else { |
|
70 | - $eventEnd = $eventStart; // consider this a zero-duration event |
|
71 | - } |
|
72 | - |
|
73 | - // Check if the two whole-day ranges intersect. |
|
74 | - return $eventStart < $rangeEnd && $eventEnd >= $rangeStart; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - // Converts this Event object back to a plain data array, to be used for generating JSON |
|
79 | - public function toArray() { |
|
80 | - |
|
81 | - // Start with the misc properties (don't worry, PHP won't affect the original array) |
|
82 | - $array = $this->properties; |
|
83 | - |
|
84 | - $array['title'] = $this->title; |
|
85 | - |
|
86 | - // Figure out the date format. This essentially encodes allDay into the date string. |
|
87 | - if ($this->allDay) { |
|
88 | - $format = 'Y-m-d'; // output like "2013-12-29" |
|
89 | - } |
|
90 | - else { |
|
91 | - $format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00" |
|
92 | - } |
|
93 | - |
|
94 | - // Serialize dates into strings |
|
95 | - $array['start'] = $this->start->format($format); |
|
96 | - if (isset($this->end)) { |
|
97 | - $array['end'] = $this->end->format($format); |
|
98 | - } |
|
99 | - |
|
100 | - return $array; |
|
101 | - } |
|
15 | + // Tests whether the given ISO8601 string has a time-of-day or not |
|
16 | + const ALL_DAY_REGEX = '/^\d{4}-\d\d-\d\d$/'; // matches strings like "2013-12-29" |
|
17 | + |
|
18 | + public $title; |
|
19 | + public $allDay; // a boolean |
|
20 | + public $start; // a DateTime |
|
21 | + public $end; // a DateTime, or null |
|
22 | + public $properties = array(); // an array of other misc properties |
|
23 | + |
|
24 | + |
|
25 | + // Constructs an Event object from the given array of key=>values. |
|
26 | + // You can optionally force the timezone of the parsed dates. |
|
27 | + public function __construct($array, $timezone=null) { |
|
28 | + |
|
29 | + $this->title = $array['title']; |
|
30 | + |
|
31 | + if (isset($array['allDay'])) { |
|
32 | + // allDay has been explicitly specified |
|
33 | + $this->allDay = (bool)$array['allDay']; |
|
34 | + } |
|
35 | + else { |
|
36 | + // Guess allDay based off of ISO8601 date strings |
|
37 | + $this->allDay = preg_match(self::ALL_DAY_REGEX, $array['start']) && |
|
38 | + (!isset($array['end']) || preg_match(self::ALL_DAY_REGEX, $array['end'])); |
|
39 | + } |
|
40 | + |
|
41 | + if ($this->allDay) { |
|
42 | + // If dates are allDay, we want to parse them in UTC to avoid DST issues. |
|
43 | + $timezone = null; |
|
44 | + } |
|
45 | + |
|
46 | + // Parse dates |
|
47 | + $this->start = parseDateTime($array['start'], $timezone); |
|
48 | + $this->end = isset($array['end']) ? parseDateTime($array['end'], $timezone) : null; |
|
49 | + |
|
50 | + // Record misc properties |
|
51 | + foreach ($array as $name => $value) { |
|
52 | + if (!in_array($name, array('title', 'allDay', 'start', 'end'))) { |
|
53 | + $this->properties[$name] = $value; |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + // Returns whether the date range of our event intersects with the given all-day range. |
|
60 | + // $rangeStart and $rangeEnd are assumed to be dates in UTC with 00:00:00 time. |
|
61 | + public function isWithinDayRange($rangeStart, $rangeEnd) { |
|
62 | + |
|
63 | + // Normalize our event's dates for comparison with the all-day range. |
|
64 | + $eventStart = stripTime($this->start); |
|
65 | + |
|
66 | + if (isset($this->end)) { |
|
67 | + $eventEnd = stripTime($this->end); // normalize |
|
68 | + } |
|
69 | + else { |
|
70 | + $eventEnd = $eventStart; // consider this a zero-duration event |
|
71 | + } |
|
72 | + |
|
73 | + // Check if the two whole-day ranges intersect. |
|
74 | + return $eventStart < $rangeEnd && $eventEnd >= $rangeStart; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + // Converts this Event object back to a plain data array, to be used for generating JSON |
|
79 | + public function toArray() { |
|
80 | + |
|
81 | + // Start with the misc properties (don't worry, PHP won't affect the original array) |
|
82 | + $array = $this->properties; |
|
83 | + |
|
84 | + $array['title'] = $this->title; |
|
85 | + |
|
86 | + // Figure out the date format. This essentially encodes allDay into the date string. |
|
87 | + if ($this->allDay) { |
|
88 | + $format = 'Y-m-d'; // output like "2013-12-29" |
|
89 | + } |
|
90 | + else { |
|
91 | + $format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00" |
|
92 | + } |
|
93 | + |
|
94 | + // Serialize dates into strings |
|
95 | + $array['start'] = $this->start->format($format); |
|
96 | + if (isset($this->end)) { |
|
97 | + $array['end'] = $this->end->format($format); |
|
98 | + } |
|
99 | + |
|
100 | + return $array; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -109,22 +109,22 @@ discard block |
||
109 | 109 | |
110 | 110 | // Parses a string into a DateTime object, optionally forced into the given timezone. |
111 | 111 | function parseDateTime($string, $timezone=null) { |
112 | - $date = new DateTime( |
|
113 | - $string, |
|
114 | - $timezone ? $timezone : new DateTimeZone('UTC') |
|
115 | - // Used only when the string is ambiguous. |
|
116 | - // Ignored if string has a timezone offset in it. |
|
117 | - ); |
|
118 | - if ($timezone) { |
|
119 | - // If our timezone was ignored above, force it. |
|
120 | - $date->setTimezone($timezone); |
|
121 | - } |
|
122 | - return $date; |
|
112 | + $date = new DateTime( |
|
113 | + $string, |
|
114 | + $timezone ? $timezone : new DateTimeZone('UTC') |
|
115 | + // Used only when the string is ambiguous. |
|
116 | + // Ignored if string has a timezone offset in it. |
|
117 | + ); |
|
118 | + if ($timezone) { |
|
119 | + // If our timezone was ignored above, force it. |
|
120 | + $date->setTimezone($timezone); |
|
121 | + } |
|
122 | + return $date; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | // Takes the year/month/date values of the given DateTime and converts them to a new DateTime, |
127 | 127 | // but in UTC. |
128 | 128 | function stripTime($datetime) { |
129 | - return new DateTime($datetime->format('Y-m-d')); |
|
129 | + return new DateTime($datetime->format('Y-m-d')); |
|
130 | 130 | } |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | |
25 | 25 | // Constructs an Event object from the given array of key=>values. |
26 | 26 | // You can optionally force the timezone of the parsed dates. |
27 | - public function __construct($array, $timezone=null) { |
|
27 | + public function __construct($array, $timezone = null) { |
|
28 | 28 | |
29 | 29 | $this->title = $array['title']; |
30 | 30 | |
31 | 31 | if (isset($array['allDay'])) { |
32 | 32 | // allDay has been explicitly specified |
33 | - $this->allDay = (bool)$array['allDay']; |
|
33 | + $this->allDay = (bool) $array['allDay']; |
|
34 | 34 | } |
35 | 35 | else { |
36 | 36 | // Guess allDay based off of ISO8601 date strings |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | |
110 | 110 | // Parses a string into a DateTime object, optionally forced into the given timezone. |
111 | -function parseDateTime($string, $timezone=null) { |
|
111 | +function parseDateTime($string, $timezone = null) { |
|
112 | 112 | $date = new DateTime( |
113 | 113 | $string, |
114 | 114 | $timezone ? $timezone : new DateTimeZone('UTC') |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | if (isset($array['allDay'])) { |
32 | 32 | // allDay has been explicitly specified |
33 | 33 | $this->allDay = (bool)$array['allDay']; |
34 | - } |
|
35 | - else { |
|
34 | + } else { |
|
36 | 35 | // Guess allDay based off of ISO8601 date strings |
37 | 36 | $this->allDay = preg_match(self::ALL_DAY_REGEX, $array['start']) && |
38 | 37 | (!isset($array['end']) || preg_match(self::ALL_DAY_REGEX, $array['end'])); |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | |
66 | 65 | if (isset($this->end)) { |
67 | 66 | $eventEnd = stripTime($this->end); // normalize |
68 | - } |
|
69 | - else { |
|
67 | + } else { |
|
70 | 68 | $eventEnd = $eventStart; // consider this a zero-duration event |
71 | 69 | } |
72 | 70 | |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | // Figure out the date format. This essentially encodes allDay into the date string. |
87 | 85 | if ($this->allDay) { |
88 | 86 | $format = 'Y-m-d'; // output like "2013-12-29" |
89 | - } |
|
90 | - else { |
|
87 | + } else { |
|
91 | 88 | $format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00" |
92 | 89 | } |
93 | 90 |