@@ -16,48 +16,48 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface iIdentifyUser |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * A way to uniquely identify the current api consumer |
|
| 21 | - * |
|
| 22 | - * When his user id is known it should be used otherwise ip address |
|
| 23 | - * can be used |
|
| 24 | - * |
|
| 25 | - * @param bool $includePlatform Should we consider user alone or should |
|
| 26 | - * consider the application/platform/device |
|
| 27 | - * as well for generating unique id |
|
| 28 | - * |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - public static function getUniqueIdentifier($includePlatform = false); |
|
| 19 | + /** |
|
| 20 | + * A way to uniquely identify the current api consumer |
|
| 21 | + * |
|
| 22 | + * When his user id is known it should be used otherwise ip address |
|
| 23 | + * can be used |
|
| 24 | + * |
|
| 25 | + * @param bool $includePlatform Should we consider user alone or should |
|
| 26 | + * consider the application/platform/device |
|
| 27 | + * as well for generating unique id |
|
| 28 | + * |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + public static function getUniqueIdentifier($includePlatform = false); |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * User identity to be used for caching purpose |
|
| 35 | - * |
|
| 36 | - * When the dynamic cache service places an object in the cache, it needs to |
|
| 37 | - * label it with a unique identifying string known as a cache ID. This |
|
| 38 | - * method gives that identifier |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public static function getCacheIdentifier(); |
|
| 33 | + /** |
|
| 34 | + * User identity to be used for caching purpose |
|
| 35 | + * |
|
| 36 | + * When the dynamic cache service places an object in the cache, it needs to |
|
| 37 | + * label it with a unique identifying string known as a cache ID. This |
|
| 38 | + * method gives that identifier |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public static function getCacheIdentifier(); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Authentication classes should call this method |
|
| 46 | - * |
|
| 47 | - * @param string $id user id as identified by the authentication classes |
|
| 48 | - * |
|
| 49 | - * @return void |
|
| 50 | - */ |
|
| 51 | - public static function setUniqueIdentifier($id); |
|
| 44 | + /** |
|
| 45 | + * Authentication classes should call this method |
|
| 46 | + * |
|
| 47 | + * @param string $id user id as identified by the authentication classes |
|
| 48 | + * |
|
| 49 | + * @return void |
|
| 50 | + */ |
|
| 51 | + public static function setUniqueIdentifier($id); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * User identity for caching purpose |
|
| 55 | - * |
|
| 56 | - * In a role based access control system this will be based on role |
|
| 57 | - * |
|
| 58 | - * @param $id |
|
| 59 | - * |
|
| 60 | - * @return void |
|
| 61 | - */ |
|
| 62 | - public static function setCacheIdentifier($id); |
|
| 53 | + /** |
|
| 54 | + * User identity for caching purpose |
|
| 55 | + * |
|
| 56 | + * In a role based access control system this will be based on role |
|
| 57 | + * |
|
| 58 | + * @param $id |
|
| 59 | + * |
|
| 60 | + * @return void |
|
| 61 | + */ |
|
| 62 | + public static function setCacheIdentifier($id); |
|
| 63 | 63 | } |
| 64 | 64 | \ No newline at end of file |
@@ -15,86 +15,86 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class User implements iIdentifyUser |
| 17 | 17 | { |
| 18 | - private static $initialized = false; |
|
| 19 | - public static $id = null; |
|
| 20 | - public static $cacheId = null; |
|
| 21 | - public static $ip; |
|
| 22 | - public static $browser = ''; |
|
| 23 | - public static $platform = ''; |
|
| 18 | + private static $initialized = false; |
|
| 19 | + public static $id = null; |
|
| 20 | + public static $cacheId = null; |
|
| 21 | + public static $ip; |
|
| 22 | + public static $browser = ''; |
|
| 23 | + public static $platform = ''; |
|
| 24 | 24 | |
| 25 | - public static function init() |
|
| 26 | - { |
|
| 27 | - static::$initialized = true; |
|
| 28 | - static::$ip = static::getIpAddress(); |
|
| 29 | - } |
|
| 25 | + public static function init() |
|
| 26 | + { |
|
| 27 | + static::$initialized = true; |
|
| 28 | + static::$ip = static::getIpAddress(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public static function getUniqueIdentifier($includePlatform = false) |
|
| 32 | - { |
|
| 33 | - if (!static::$initialized) static::init(); |
|
| 34 | - return static::$id ? : base64_encode('ip:' . ($includePlatform |
|
| 35 | - ? static::$ip . '-' . static::$platform |
|
| 36 | - : static::$ip |
|
| 37 | - )); |
|
| 38 | - } |
|
| 31 | + public static function getUniqueIdentifier($includePlatform = false) |
|
| 32 | + { |
|
| 33 | + if (!static::$initialized) static::init(); |
|
| 34 | + return static::$id ? : base64_encode('ip:' . ($includePlatform |
|
| 35 | + ? static::$ip . '-' . static::$platform |
|
| 36 | + : static::$ip |
|
| 37 | + )); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function getIpAddress($ignoreProxies = false) |
|
| 41 | - { |
|
| 42 | - foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', |
|
| 43 | - 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 44 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', |
|
| 45 | - 'REMOTE_ADDR') as $key) { |
|
| 46 | - if (array_key_exists($key, $_SERVER) === true) { |
|
| 47 | - foreach (explode(',', $_SERVER[$key]) as $ip) { |
|
| 48 | - $ip = trim($ip); // just to be safe |
|
| 40 | + public static function getIpAddress($ignoreProxies = false) |
|
| 41 | + { |
|
| 42 | + foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', |
|
| 43 | + 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 44 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', |
|
| 45 | + 'REMOTE_ADDR') as $key) { |
|
| 46 | + if (array_key_exists($key, $_SERVER) === true) { |
|
| 47 | + foreach (explode(',', $_SERVER[$key]) as $ip) { |
|
| 48 | + $ip = trim($ip); // just to be safe |
|
| 49 | 49 | |
| 50 | - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 |
|
| 51 | - | FILTER_FLAG_NO_PRIV_RANGE |
|
| 52 | - | FILTER_FLAG_NO_RES_RANGE) !== false |
|
| 53 | - ) { |
|
| 54 | - return $ip; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - } |
|
| 50 | + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 |
|
| 51 | + | FILTER_FLAG_NO_PRIV_RANGE |
|
| 52 | + | FILTER_FLAG_NO_RES_RANGE) !== false |
|
| 53 | + ) { |
|
| 54 | + return $ip; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Authentication classes should call this method |
|
| 63 | - * |
|
| 64 | - * @param string $id user id as identified by the authentication classes |
|
| 65 | - * |
|
| 66 | - * @return void |
|
| 67 | - */ |
|
| 68 | - public static function setUniqueIdentifier($id) |
|
| 69 | - { |
|
| 70 | - static::$id = $id; |
|
| 71 | - } |
|
| 61 | + /** |
|
| 62 | + * Authentication classes should call this method |
|
| 63 | + * |
|
| 64 | + * @param string $id user id as identified by the authentication classes |
|
| 65 | + * |
|
| 66 | + * @return void |
|
| 67 | + */ |
|
| 68 | + public static function setUniqueIdentifier($id) |
|
| 69 | + { |
|
| 70 | + static::$id = $id; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * User identity to be used for caching purpose |
|
| 75 | - * |
|
| 76 | - * When the dynamic cache service places an object in the cache, it needs to |
|
| 77 | - * label it with a unique identifying string known as a cache ID. This |
|
| 78 | - * method gives that identifier |
|
| 79 | - * |
|
| 80 | - * @return string |
|
| 81 | - */ |
|
| 82 | - public static function getCacheIdentifier() |
|
| 83 | - { |
|
| 84 | - return static::$cacheId ?: static::$id; |
|
| 85 | - } |
|
| 73 | + /** |
|
| 74 | + * User identity to be used for caching purpose |
|
| 75 | + * |
|
| 76 | + * When the dynamic cache service places an object in the cache, it needs to |
|
| 77 | + * label it with a unique identifying string known as a cache ID. This |
|
| 78 | + * method gives that identifier |
|
| 79 | + * |
|
| 80 | + * @return string |
|
| 81 | + */ |
|
| 82 | + public static function getCacheIdentifier() |
|
| 83 | + { |
|
| 84 | + return static::$cacheId ?: static::$id; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * User identity for caching purpose |
|
| 89 | - * |
|
| 90 | - * In a role based access control system this will be based on role |
|
| 91 | - * |
|
| 92 | - * @param $id |
|
| 93 | - * |
|
| 94 | - * @return void |
|
| 95 | - */ |
|
| 96 | - public static function setCacheIdentifier($id) |
|
| 97 | - { |
|
| 98 | - static::$cacheId = $id; |
|
| 99 | - } |
|
| 87 | + /** |
|
| 88 | + * User identity for caching purpose |
|
| 89 | + * |
|
| 90 | + * In a role based access control system this will be based on role |
|
| 91 | + * |
|
| 92 | + * @param $id |
|
| 93 | + * |
|
| 94 | + * @return void |
|
| 95 | + */ |
|
| 96 | + public static function setCacheIdentifier($id) |
|
| 97 | + { |
|
| 98 | + static::$cacheId = $id; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -31,8 +31,8 @@ |
||
| 31 | 31 | public static function getUniqueIdentifier($includePlatform = false) |
| 32 | 32 | { |
| 33 | 33 | if (!static::$initialized) static::init(); |
| 34 | - return static::$id ? : base64_encode('ip:' . ($includePlatform |
|
| 35 | - ? static::$ip . '-' . static::$platform |
|
| 34 | + return static::$id ?: base64_encode('ip:'.($includePlatform |
|
| 35 | + ? static::$ip.'-'.static::$platform |
|
| 36 | 36 | : static::$ip |
| 37 | 37 | )); |
| 38 | 38 | } |
@@ -30,7 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | public static function getUniqueIdentifier($includePlatform = false) |
| 32 | 32 | { |
| 33 | - if (!static::$initialized) static::init(); |
|
| 33 | + if (!static::$initialized) { |
|
| 34 | + static::init(); |
|
| 35 | + } |
|
| 34 | 36 | return static::$id ? : base64_encode('ip:' . ($includePlatform |
| 35 | 37 | ? static::$ip . '-' . static::$platform |
| 36 | 38 | : static::$ip |
@@ -19,156 +19,156 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Flash implements ArrayAccess |
| 21 | 21 | { |
| 22 | - const SUCCESS = 'success'; |
|
| 23 | - const INFO = 'info'; |
|
| 24 | - const WARNING = 'warning'; |
|
| 25 | - const DANGER = 'danger'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var Flash |
|
| 29 | - */ |
|
| 30 | - private static $instance; |
|
| 31 | - private $usedOnce = false; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Flash a success message to user |
|
| 35 | - * |
|
| 36 | - * @param string $message |
|
| 37 | - * @param string $header |
|
| 38 | - * |
|
| 39 | - * @return Flash |
|
| 40 | - */ |
|
| 41 | - public static function success($message, $header = '') |
|
| 42 | - { |
|
| 43 | - return static::message($message, $header, Flash::SUCCESS); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Flash a info message to user |
|
| 48 | - * |
|
| 49 | - * @param string $message |
|
| 50 | - * @param string $header |
|
| 51 | - * |
|
| 52 | - * @return Flash |
|
| 53 | - */ |
|
| 54 | - public static function info($message, $header = '') |
|
| 55 | - { |
|
| 56 | - return static::message($message, $header, Flash::INFO); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Flash a warning message to user |
|
| 61 | - * |
|
| 62 | - * @param string $message |
|
| 63 | - * @param string $header |
|
| 64 | - * |
|
| 65 | - * @return Flash |
|
| 66 | - */ |
|
| 67 | - public static function warning($message, $header = '') |
|
| 68 | - { |
|
| 69 | - return static::message($message, $header, Flash::WARNING); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Flash a error message to user |
|
| 74 | - * |
|
| 75 | - * @param string $message |
|
| 76 | - * @param string $header |
|
| 77 | - * |
|
| 78 | - * @return Flash |
|
| 79 | - */ |
|
| 80 | - public static function danger($message, $header = '') |
|
| 81 | - { |
|
| 82 | - return static::message($message, $header, Flash::DANGER); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Flash a message to user |
|
| 87 | - * |
|
| 88 | - * @param string $text message text |
|
| 89 | - * @param string $header |
|
| 90 | - * @param string $type |
|
| 91 | - * |
|
| 92 | - * @return Flash |
|
| 93 | - */ |
|
| 94 | - public static function message($text, $header = '', $type = Flash::WARNING) |
|
| 95 | - { |
|
| 96 | - return static::set(array('message' => $text, 'header' => $header, 'type' => $type)); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Set some data for one time use |
|
| 101 | - * |
|
| 102 | - * @param array $data array of key value pairs {@type associative} |
|
| 103 | - * |
|
| 104 | - * @return Flash |
|
| 105 | - */ |
|
| 106 | - public static function set(array $data) |
|
| 107 | - { |
|
| 108 | - if (!static::$instance) { |
|
| 109 | - static::$instance = new Flash(); |
|
| 110 | - } |
|
| 111 | - if (!isset($_SESSION['flash'])) { |
|
| 112 | - $_SESSION['flash'] = array(); |
|
| 113 | - } |
|
| 114 | - $_SESSION['flash'] += $data; |
|
| 115 | - HtmlFormat::$data['flash'] = static::$instance; |
|
| 116 | - |
|
| 117 | - return static::$instance; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public function __get($name) |
|
| 121 | - { |
|
| 122 | - $this->usedOnce = true; |
|
| 123 | - |
|
| 124 | - return Util::nestedValue($_SESSION, 'flash', $name); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - public function __isset($name) |
|
| 128 | - { |
|
| 129 | - return !is_null(Util::nestedValue($_SESSION, 'flash', $name)); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - public function __destruct() |
|
| 133 | - { |
|
| 134 | - if ($this->usedOnce) { |
|
| 135 | - unset($_SESSION['flash']); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Specify data which should be serialized to JSON |
|
| 141 | - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
| 142 | - * @return mixed data which can be serialized by <b>json_encode</b>, |
|
| 143 | - * which is a value of any type other than a resource. |
|
| 144 | - */ |
|
| 145 | - public function jsonSerialize() |
|
| 146 | - { |
|
| 147 | - $this->usedOnce = true; |
|
| 148 | - |
|
| 149 | - return isset($_SESSION['flash']) |
|
| 150 | - ? $_SESSION['flash'] |
|
| 151 | - : array(); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - public function offsetExists($offset) |
|
| 156 | - { |
|
| 157 | - return $this->__isset($offset); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - public function offsetGet($offset) |
|
| 161 | - { |
|
| 162 | - return $this->__get($offset); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - public function offsetSet($offset, $value) |
|
| 166 | - { |
|
| 167 | - //not implemented |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - public function offsetUnset($offset) |
|
| 171 | - { |
|
| 172 | - //not implemented |
|
| 173 | - } |
|
| 22 | + const SUCCESS = 'success'; |
|
| 23 | + const INFO = 'info'; |
|
| 24 | + const WARNING = 'warning'; |
|
| 25 | + const DANGER = 'danger'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var Flash |
|
| 29 | + */ |
|
| 30 | + private static $instance; |
|
| 31 | + private $usedOnce = false; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Flash a success message to user |
|
| 35 | + * |
|
| 36 | + * @param string $message |
|
| 37 | + * @param string $header |
|
| 38 | + * |
|
| 39 | + * @return Flash |
|
| 40 | + */ |
|
| 41 | + public static function success($message, $header = '') |
|
| 42 | + { |
|
| 43 | + return static::message($message, $header, Flash::SUCCESS); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Flash a info message to user |
|
| 48 | + * |
|
| 49 | + * @param string $message |
|
| 50 | + * @param string $header |
|
| 51 | + * |
|
| 52 | + * @return Flash |
|
| 53 | + */ |
|
| 54 | + public static function info($message, $header = '') |
|
| 55 | + { |
|
| 56 | + return static::message($message, $header, Flash::INFO); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Flash a warning message to user |
|
| 61 | + * |
|
| 62 | + * @param string $message |
|
| 63 | + * @param string $header |
|
| 64 | + * |
|
| 65 | + * @return Flash |
|
| 66 | + */ |
|
| 67 | + public static function warning($message, $header = '') |
|
| 68 | + { |
|
| 69 | + return static::message($message, $header, Flash::WARNING); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Flash a error message to user |
|
| 74 | + * |
|
| 75 | + * @param string $message |
|
| 76 | + * @param string $header |
|
| 77 | + * |
|
| 78 | + * @return Flash |
|
| 79 | + */ |
|
| 80 | + public static function danger($message, $header = '') |
|
| 81 | + { |
|
| 82 | + return static::message($message, $header, Flash::DANGER); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Flash a message to user |
|
| 87 | + * |
|
| 88 | + * @param string $text message text |
|
| 89 | + * @param string $header |
|
| 90 | + * @param string $type |
|
| 91 | + * |
|
| 92 | + * @return Flash |
|
| 93 | + */ |
|
| 94 | + public static function message($text, $header = '', $type = Flash::WARNING) |
|
| 95 | + { |
|
| 96 | + return static::set(array('message' => $text, 'header' => $header, 'type' => $type)); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Set some data for one time use |
|
| 101 | + * |
|
| 102 | + * @param array $data array of key value pairs {@type associative} |
|
| 103 | + * |
|
| 104 | + * @return Flash |
|
| 105 | + */ |
|
| 106 | + public static function set(array $data) |
|
| 107 | + { |
|
| 108 | + if (!static::$instance) { |
|
| 109 | + static::$instance = new Flash(); |
|
| 110 | + } |
|
| 111 | + if (!isset($_SESSION['flash'])) { |
|
| 112 | + $_SESSION['flash'] = array(); |
|
| 113 | + } |
|
| 114 | + $_SESSION['flash'] += $data; |
|
| 115 | + HtmlFormat::$data['flash'] = static::$instance; |
|
| 116 | + |
|
| 117 | + return static::$instance; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + public function __get($name) |
|
| 121 | + { |
|
| 122 | + $this->usedOnce = true; |
|
| 123 | + |
|
| 124 | + return Util::nestedValue($_SESSION, 'flash', $name); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + public function __isset($name) |
|
| 128 | + { |
|
| 129 | + return !is_null(Util::nestedValue($_SESSION, 'flash', $name)); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + public function __destruct() |
|
| 133 | + { |
|
| 134 | + if ($this->usedOnce) { |
|
| 135 | + unset($_SESSION['flash']); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Specify data which should be serialized to JSON |
|
| 141 | + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
| 142 | + * @return mixed data which can be serialized by <b>json_encode</b>, |
|
| 143 | + * which is a value of any type other than a resource. |
|
| 144 | + */ |
|
| 145 | + public function jsonSerialize() |
|
| 146 | + { |
|
| 147 | + $this->usedOnce = true; |
|
| 148 | + |
|
| 149 | + return isset($_SESSION['flash']) |
|
| 150 | + ? $_SESSION['flash'] |
|
| 151 | + : array(); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + public function offsetExists($offset) |
|
| 156 | + { |
|
| 157 | + return $this->__isset($offset); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + public function offsetGet($offset) |
|
| 161 | + { |
|
| 162 | + return $this->__get($offset); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + public function offsetSet($offset, $value) |
|
| 166 | + { |
|
| 167 | + //not implemented |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + public function offsetUnset($offset) |
|
| 171 | + { |
|
| 172 | + //not implemented |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | \ No newline at end of file |
@@ -16,15 +16,15 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface iFilter |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Access verification method. |
|
| 21 | - * |
|
| 22 | - * API access will be denied when this method returns false |
|
| 23 | - * |
|
| 24 | - * @abstract |
|
| 25 | - * @return boolean true when api access is allowed false otherwise |
|
| 26 | - */ |
|
| 27 | - public function __isAllowed(); |
|
| 19 | + /** |
|
| 20 | + * Access verification method. |
|
| 21 | + * |
|
| 22 | + * API access will be denied when this method returns false |
|
| 23 | + * |
|
| 24 | + * @abstract |
|
| 25 | + * @return boolean true when api access is allowed false otherwise |
|
| 26 | + */ |
|
| 27 | + public function __isAllowed(); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | interface iAuthenticate |
| 8 | 8 | { |
| 9 | - public function __isAuthenticated(); |
|
| 9 | + public function __isAuthenticated(); |
|
| 10 | 10 | } |
| 11 | 11 | \ No newline at end of file |
@@ -10,18 +10,18 @@ |
||
| 10 | 10 | $classMap = array(); |
| 11 | 11 | //find lowercase php files representing a class/interface |
| 12 | 12 | foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) |
| 13 | - foreach (new DirectoryIterator($path) as $fileInfo) |
|
| 14 | - if ($fileInfo->isFile() |
|
| 15 | - && 'php' === $fileInfo->getExtension() |
|
| 16 | - && ctype_lower($fileInfo->getBasename('.php')) |
|
| 17 | - && preg_match( |
|
| 18 | - '/^ *(class|interface|abstract +class)' |
|
| 19 | - . ' +([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/m', |
|
| 20 | - file_get_contents($fileInfo->getPathname()), |
|
| 21 | - $matches |
|
| 22 | - ) |
|
| 23 | - ) |
|
| 24 | - $classMap[$matches[2]] = $fileInfo->getPathname(); |
|
| 13 | + foreach (new DirectoryIterator($path) as $fileInfo) |
|
| 14 | + if ($fileInfo->isFile() |
|
| 15 | + && 'php' === $fileInfo->getExtension() |
|
| 16 | + && ctype_lower($fileInfo->getBasename('.php')) |
|
| 17 | + && preg_match( |
|
| 18 | + '/^ *(class|interface|abstract +class)' |
|
| 19 | + . ' +([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/m', |
|
| 20 | + file_get_contents($fileInfo->getPathname()), |
|
| 21 | + $matches |
|
| 22 | + ) |
|
| 23 | + ) |
|
| 24 | + $classMap[$matches[2]] = $fileInfo->getPathname(); |
|
| 25 | 25 | |
| 26 | 26 | AutoLoader::seen($classMap); |
| 27 | 27 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | //changes in iAuthenticate |
| 29 | 29 | Defaults::$authenticationMethod = '__isAuthenticated'; |
| 30 | 30 | |
| 31 | -include __DIR__ . '/iAuthenticate.php'; |
|
| 31 | +include __DIR__.'/iAuthenticate.php'; |
|
| 32 | 32 | |
| 33 | 33 | //changes in auto routing |
| 34 | 34 | Defaults::$smartAutoRouting = false; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | //changes in auto loading |
| 10 | 10 | $classMap = array(); |
| 11 | 11 | //find lowercase php files representing a class/interface |
| 12 | -foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) |
|
| 12 | +foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { |
|
| 13 | 13 | foreach (new DirectoryIterator($path) as $fileInfo) |
| 14 | 14 | if ($fileInfo->isFile() |
| 15 | 15 | && 'php' === $fileInfo->getExtension() |
@@ -22,6 +22,7 @@ discard block |
||
| 22 | 22 | ) |
| 23 | 23 | ) |
| 24 | 24 | $classMap[$matches[2]] = $fileInfo->getPathname(); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | AutoLoader::seen($classMap); |
| 27 | 28 | |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | //changes in iAuthenticate |
| 8 | 8 | Defaults::$authenticationMethod = 'isAuthenticated'; |
| 9 | -include __DIR__ . '/iAuthenticate.php'; |
|
| 9 | +include __DIR__.'/iAuthenticate.php'; |
|
| 10 | 10 | |
| 11 | 11 | //changes in routing |
| 12 | 12 | Defaults::$autoRoutingEnabled = false; |
@@ -13,51 +13,51 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | interface iCache |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * store data in the cache |
|
| 18 | - * |
|
| 19 | - * @abstract |
|
| 20 | - * |
|
| 21 | - * @param string $name |
|
| 22 | - * @param mixed $data |
|
| 23 | - * |
|
| 24 | - * @return boolean true if successful |
|
| 25 | - */ |
|
| 26 | - public function set($name, $data); |
|
| 16 | + /** |
|
| 17 | + * store data in the cache |
|
| 18 | + * |
|
| 19 | + * @abstract |
|
| 20 | + * |
|
| 21 | + * @param string $name |
|
| 22 | + * @param mixed $data |
|
| 23 | + * |
|
| 24 | + * @return boolean true if successful |
|
| 25 | + */ |
|
| 26 | + public function set($name, $data); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * retrieve data from the cache |
|
| 30 | - * |
|
| 31 | - * @abstract |
|
| 32 | - * |
|
| 33 | - * @param string $name |
|
| 34 | - * @param bool $ignoreErrors |
|
| 35 | - * |
|
| 36 | - * @return mixed |
|
| 37 | - */ |
|
| 38 | - public function get($name, $ignoreErrors = false); |
|
| 28 | + /** |
|
| 29 | + * retrieve data from the cache |
|
| 30 | + * |
|
| 31 | + * @abstract |
|
| 32 | + * |
|
| 33 | + * @param string $name |
|
| 34 | + * @param bool $ignoreErrors |
|
| 35 | + * |
|
| 36 | + * @return mixed |
|
| 37 | + */ |
|
| 38 | + public function get($name, $ignoreErrors = false); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * delete data from the cache |
|
| 42 | - * |
|
| 43 | - * @abstract |
|
| 44 | - * |
|
| 45 | - * @param string $name |
|
| 46 | - * @param bool $ignoreErrors |
|
| 47 | - * |
|
| 48 | - * @return boolean true if successful |
|
| 49 | - */ |
|
| 50 | - public function clear($name, $ignoreErrors = false); |
|
| 40 | + /** |
|
| 41 | + * delete data from the cache |
|
| 42 | + * |
|
| 43 | + * @abstract |
|
| 44 | + * |
|
| 45 | + * @param string $name |
|
| 46 | + * @param bool $ignoreErrors |
|
| 47 | + * |
|
| 48 | + * @return boolean true if successful |
|
| 49 | + */ |
|
| 50 | + public function clear($name, $ignoreErrors = false); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * check if the given name is cached |
|
| 54 | - * |
|
| 55 | - * @abstract |
|
| 56 | - * |
|
| 57 | - * @param string $name |
|
| 58 | - * |
|
| 59 | - * @return boolean true if cached |
|
| 60 | - */ |
|
| 61 | - public function isCached($name); |
|
| 52 | + /** |
|
| 53 | + * check if the given name is cached |
|
| 54 | + * |
|
| 55 | + * @abstract |
|
| 56 | + * |
|
| 57 | + * @param string $name |
|
| 58 | + * |
|
| 59 | + * @return boolean true if cached |
|
| 60 | + */ |
|
| 61 | + public function isCached($name); |
|
| 62 | 62 | } |
| 63 | 63 | |
@@ -15,41 +15,41 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | function exceptions() |
| 17 | 17 | { |
| 18 | - global $call_trace; |
|
| 19 | - $r = Util::$restler; |
|
| 20 | - $source = $r->_exceptions; |
|
| 21 | - if (count($source)) { |
|
| 22 | - $source = end($source); |
|
| 23 | - $traces = array(); |
|
| 24 | - do { |
|
| 25 | - $traces += $source->getTrace(); |
|
| 26 | - } while ($source = $source->getPrevious()); |
|
| 27 | - $traces += debug_backtrace(); |
|
| 28 | - $call_trace |
|
| 29 | - = parse_backtrace($traces, 0); |
|
| 30 | - } else { |
|
| 31 | - $call_trace |
|
| 32 | - = parse_backtrace(debug_backtrace()); |
|
| 33 | - } |
|
| 18 | + global $call_trace; |
|
| 19 | + $r = Util::$restler; |
|
| 20 | + $source = $r->_exceptions; |
|
| 21 | + if (count($source)) { |
|
| 22 | + $source = end($source); |
|
| 23 | + $traces = array(); |
|
| 24 | + do { |
|
| 25 | + $traces += $source->getTrace(); |
|
| 26 | + } while ($source = $source->getPrevious()); |
|
| 27 | + $traces += debug_backtrace(); |
|
| 28 | + $call_trace |
|
| 29 | + = parse_backtrace($traces, 0); |
|
| 30 | + } else { |
|
| 31 | + $call_trace |
|
| 32 | + = parse_backtrace(debug_backtrace()); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | exceptions(); |
| 37 | 37 | |
| 38 | 38 | function parse_backtrace($raw, $skip = 1) |
| 39 | 39 | { |
| 40 | - $output = ""; |
|
| 41 | - foreach ($raw as $entry) { |
|
| 42 | - if ($skip-- > 0) { |
|
| 43 | - continue; |
|
| 44 | - } |
|
| 45 | - //$output .= print_r($entry, true) . "\n"; |
|
| 46 | - $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n"; |
|
| 47 | - if (isset($entry['class'])) |
|
| 48 | - $output .= $entry['class'] . "::"; |
|
| 49 | - $output .= $entry['function'] |
|
| 50 | - . "( " . json_encode($entry['args']) . " )\n"; |
|
| 51 | - } |
|
| 52 | - return $output; |
|
| 40 | + $output = ""; |
|
| 41 | + foreach ($raw as $entry) { |
|
| 42 | + if ($skip-- > 0) { |
|
| 43 | + continue; |
|
| 44 | + } |
|
| 45 | + //$output .= print_r($entry, true) . "\n"; |
|
| 46 | + $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n"; |
|
| 47 | + if (isset($entry['class'])) |
|
| 48 | + $output .= $entry['class'] . "::"; |
|
| 49 | + $output .= $entry['function'] |
|
| 50 | + . "( " . json_encode($entry['args']) . " )\n"; |
|
| 51 | + } |
|
| 52 | + return $output; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -57,64 +57,64 @@ discard block |
||
| 57 | 57 | //print_r($response); |
| 58 | 58 | $icon; |
| 59 | 59 | if ($success && isset($api)) { |
| 60 | - $arguments = implode(', ', $api->parameters); |
|
| 61 | - $icon = "<icon class=\"success\"></icon>"; |
|
| 62 | - $title = "{$api->className}::" |
|
| 63 | - . "{$api->methodName}({$arguments})"; |
|
| 60 | + $arguments = implode(', ', $api->parameters); |
|
| 61 | + $icon = "<icon class=\"success\"></icon>"; |
|
| 62 | + $title = "{$api->className}::" |
|
| 63 | + . "{$api->methodName}({$arguments})"; |
|
| 64 | 64 | } else { |
| 65 | - if (isset($response['error']['message'])) { |
|
| 66 | - $icon = '<icon class="denied"></icon>'; |
|
| 67 | - $title = end(explode(':',$response['error']['message'],2)); |
|
| 68 | - } else { |
|
| 69 | - $icon = '<icon class="warning"></icon>'; |
|
| 70 | - $title = 'No Matching Resource'; |
|
| 71 | - } |
|
| 65 | + if (isset($response['error']['message'])) { |
|
| 66 | + $icon = '<icon class="denied"></icon>'; |
|
| 67 | + $title = end(explode(':',$response['error']['message'],2)); |
|
| 68 | + } else { |
|
| 69 | + $icon = '<icon class="warning"></icon>'; |
|
| 70 | + $title = 'No Matching Resource'; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | function render($data, $shadow=true) |
| 74 | 74 | { |
| 75 | - $r = ''; |
|
| 76 | - if (empty($data)) |
|
| 77 | - return $r; |
|
| 78 | - $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n"; |
|
| 79 | - if (is_array($data)) { |
|
| 80 | - // field name |
|
| 81 | - foreach ($data as $key => $value) { |
|
| 82 | - $r .= '<li>'; |
|
| 83 | - $r .= is_numeric($key) |
|
| 84 | - ? "<strong>[$key]</strong> " |
|
| 85 | - : "<strong>$key: </strong>"; |
|
| 86 | - $r .= '<span>'; |
|
| 87 | - if (is_array($value)) { |
|
| 88 | - // recursive |
|
| 89 | - $r .= render($value,false); |
|
| 90 | - } else { |
|
| 91 | - // value, with hyperlinked hyperlinks |
|
| 92 | - if (is_bool($value)) { |
|
| 93 | - $value = $value ? 'true' : 'false'; |
|
| 94 | - } |
|
| 95 | - $value = htmlentities($value, ENT_COMPAT, 'UTF-8'); |
|
| 96 | - if (strpos($value, 'http://') === 0) { |
|
| 97 | - $r .= '<a href="' . $value . '">' . $value . '</a>'; |
|
| 98 | - } else { |
|
| 99 | - $r .= $value; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - $r .= "</span></li>\n"; |
|
| 103 | - } |
|
| 104 | - } elseif (is_bool($data)) { |
|
| 105 | - $r .= '<li>' . ($data ? 'true' : 'false') . '</li>'; |
|
| 106 | - } else { |
|
| 107 | - $r .= "<li><strong>$data</strong></li>"; |
|
| 108 | - } |
|
| 109 | - $r .= "</ul>\n"; |
|
| 110 | - return $r; |
|
| 75 | + $r = ''; |
|
| 76 | + if (empty($data)) |
|
| 77 | + return $r; |
|
| 78 | + $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n"; |
|
| 79 | + if (is_array($data)) { |
|
| 80 | + // field name |
|
| 81 | + foreach ($data as $key => $value) { |
|
| 82 | + $r .= '<li>'; |
|
| 83 | + $r .= is_numeric($key) |
|
| 84 | + ? "<strong>[$key]</strong> " |
|
| 85 | + : "<strong>$key: </strong>"; |
|
| 86 | + $r .= '<span>'; |
|
| 87 | + if (is_array($value)) { |
|
| 88 | + // recursive |
|
| 89 | + $r .= render($value,false); |
|
| 90 | + } else { |
|
| 91 | + // value, with hyperlinked hyperlinks |
|
| 92 | + if (is_bool($value)) { |
|
| 93 | + $value = $value ? 'true' : 'false'; |
|
| 94 | + } |
|
| 95 | + $value = htmlentities($value, ENT_COMPAT, 'UTF-8'); |
|
| 96 | + if (strpos($value, 'http://') === 0) { |
|
| 97 | + $r .= '<a href="' . $value . '">' . $value . '</a>'; |
|
| 98 | + } else { |
|
| 99 | + $r .= $value; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + $r .= "</span></li>\n"; |
|
| 103 | + } |
|
| 104 | + } elseif (is_bool($data)) { |
|
| 105 | + $r .= '<li>' . ($data ? 'true' : 'false') . '</li>'; |
|
| 106 | + } else { |
|
| 107 | + $r .= "<li><strong>$data</strong></li>"; |
|
| 108 | + } |
|
| 109 | + $r .= "</ul>\n"; |
|
| 110 | + return $r; |
|
| 111 | 111 | } |
| 112 | 112 | $reqHeadersArr = array(); |
| 113 | 113 | $requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL; |
| 114 | 114 | foreach ($reqHeadersArr as $key => $value) { |
| 115 | - if ($key == 'Host') |
|
| 116 | - continue; |
|
| 117 | - $requestHeaders .= "$key: $value" . PHP_EOL; |
|
| 115 | + if ($key == 'Host') |
|
| 116 | + continue; |
|
| 117 | + $requestHeaders .= "$key: $value" . PHP_EOL; |
|
| 118 | 118 | } |
| 119 | 119 | // $requestHeaders = $this->encode(apache_request_headers(), FALSE, |
| 120 | 120 | // FALSE); |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | <body> |
| 135 | 135 | <div id="breadcrumbs-one"> |
| 136 | 136 | <?php |
| 137 | - if(Util::$restler->exception){ |
|
| 138 | - $stages = Util::$restler->exception->getStages(); |
|
| 139 | - $curStage = Util::$restler->exception->getStage(); |
|
| 140 | - foreach($stages['success'] as $stage){ |
|
| 141 | - echo "<a href=\"#\">$stage</a>"; |
|
| 142 | - } |
|
| 143 | - foreach($stages['failure'] as $stage){ |
|
| 144 | - echo '<a href="#" class="failure">' |
|
| 145 | - . $stage |
|
| 146 | - . ($stage==$curStage ? ' <span class="state"/> ' : '') |
|
| 147 | - . '</a>'; |
|
| 148 | - } |
|
| 149 | - } else { |
|
| 150 | - foreach(Util::$restler->_events as $stage){ |
|
| 151 | - echo "<a href=\"#\">$stage</a>"; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - ?> |
|
| 137 | + if(Util::$restler->exception){ |
|
| 138 | + $stages = Util::$restler->exception->getStages(); |
|
| 139 | + $curStage = Util::$restler->exception->getStage(); |
|
| 140 | + foreach($stages['success'] as $stage){ |
|
| 141 | + echo "<a href=\"#\">$stage</a>"; |
|
| 142 | + } |
|
| 143 | + foreach($stages['failure'] as $stage){ |
|
| 144 | + echo '<a href="#" class="failure">' |
|
| 145 | + . $stage |
|
| 146 | + . ($stage==$curStage ? ' <span class="state"/> ' : '') |
|
| 147 | + . '</a>'; |
|
| 148 | + } |
|
| 149 | + } else { |
|
| 150 | + foreach(Util::$restler->_events as $stage){ |
|
| 151 | + echo "<a href=\"#\">$stage</a>"; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + ?> |
|
| 155 | 155 | </div> |
| 156 | 156 | <header> |
| 157 | 157 | <h1><?php echo $title ?></h1> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | use Luracast\Restler\Restler; |
| 3 | 3 | use Luracast\Restler\Util; |
| 4 | 4 | |
| 5 | -$template_vars = $data;//get_defined_vars(); |
|
| 5 | +$template_vars = $data; //get_defined_vars(); |
|
| 6 | 6 | |
| 7 | 7 | unset($template_vars['response']); |
| 8 | 8 | unset($template_vars['api']); |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | continue; |
| 44 | 44 | } |
| 45 | 45 | //$output .= print_r($entry, true) . "\n"; |
| 46 | - $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n"; |
|
| 46 | + $output .= "\nFile: ".$entry['file']." (Line: ".$entry['line'].")\n"; |
|
| 47 | 47 | if (isset($entry['class'])) |
| 48 | - $output .= $entry['class'] . "::"; |
|
| 48 | + $output .= $entry['class']."::"; |
|
| 49 | 49 | $output .= $entry['function'] |
| 50 | - . "( " . json_encode($entry['args']) . " )\n"; |
|
| 50 | + . "( ".json_encode($entry['args'])." )\n"; |
|
| 51 | 51 | } |
| 52 | 52 | return $output; |
| 53 | 53 | } |
@@ -64,18 +64,18 @@ discard block |
||
| 64 | 64 | } else { |
| 65 | 65 | if (isset($response['error']['message'])) { |
| 66 | 66 | $icon = '<icon class="denied"></icon>'; |
| 67 | - $title = end(explode(':',$response['error']['message'],2)); |
|
| 67 | + $title = end(explode(':', $response['error']['message'], 2)); |
|
| 68 | 68 | } else { |
| 69 | 69 | $icon = '<icon class="warning"></icon>'; |
| 70 | 70 | $title = 'No Matching Resource'; |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | -function render($data, $shadow=true) |
|
| 73 | +function render($data, $shadow = true) |
|
| 74 | 74 | { |
| 75 | 75 | $r = ''; |
| 76 | 76 | if (empty($data)) |
| 77 | 77 | return $r; |
| 78 | - $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n"; |
|
| 78 | + $r .= $shadow ? "<ul class=\"shadow\">\n" : "<ul>\n"; |
|
| 79 | 79 | if (is_array($data)) { |
| 80 | 80 | // field name |
| 81 | 81 | foreach ($data as $key => $value) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $r .= '<span>'; |
| 87 | 87 | if (is_array($value)) { |
| 88 | 88 | // recursive |
| 89 | - $r .= render($value,false); |
|
| 89 | + $r .= render($value, false); |
|
| 90 | 90 | } else { |
| 91 | 91 | // value, with hyperlinked hyperlinks |
| 92 | 92 | if (is_bool($value)) { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | $value = htmlentities($value, ENT_COMPAT, 'UTF-8'); |
| 96 | 96 | if (strpos($value, 'http://') === 0) { |
| 97 | - $r .= '<a href="' . $value . '">' . $value . '</a>'; |
|
| 97 | + $r .= '<a href="'.$value.'">'.$value.'</a>'; |
|
| 98 | 98 | } else { |
| 99 | 99 | $r .= $value; |
| 100 | 100 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $r .= "</span></li>\n"; |
| 103 | 103 | } |
| 104 | 104 | } elseif (is_bool($data)) { |
| 105 | - $r .= '<li>' . ($data ? 'true' : 'false') . '</li>'; |
|
| 105 | + $r .= '<li>'.($data ? 'true' : 'false').'</li>'; |
|
| 106 | 106 | } else { |
| 107 | 107 | $r .= "<li><strong>$data</strong></li>"; |
| 108 | 108 | } |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | return $r; |
| 111 | 111 | } |
| 112 | 112 | $reqHeadersArr = array(); |
| 113 | -$requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL; |
|
| 113 | +$requestHeaders = $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL'].PHP_EOL; |
|
| 114 | 114 | foreach ($reqHeadersArr as $key => $value) { |
| 115 | 115 | if ($key == 'Host') |
| 116 | 116 | continue; |
| 117 | - $requestHeaders .= "$key: $value" . PHP_EOL; |
|
| 117 | + $requestHeaders .= "$key: $value".PHP_EOL; |
|
| 118 | 118 | } |
| 119 | 119 | // $requestHeaders = $this->encode(apache_request_headers(), FALSE, |
| 120 | 120 | // FALSE); |
@@ -134,20 +134,20 @@ discard block |
||
| 134 | 134 | <body> |
| 135 | 135 | <div id="breadcrumbs-one"> |
| 136 | 136 | <?php |
| 137 | - if(Util::$restler->exception){ |
|
| 138 | - $stages = Util::$restler->exception->getStages(); |
|
| 137 | + if (Util::$restler->exception) { |
|
| 138 | + $stages = Util::$restler->exception->getStages(); |
|
| 139 | 139 | $curStage = Util::$restler->exception->getStage(); |
| 140 | - foreach($stages['success'] as $stage){ |
|
| 140 | + foreach ($stages['success'] as $stage) { |
|
| 141 | 141 | echo "<a href=\"#\">$stage</a>"; |
| 142 | 142 | } |
| 143 | - foreach($stages['failure'] as $stage){ |
|
| 143 | + foreach ($stages['failure'] as $stage) { |
|
| 144 | 144 | echo '<a href="#" class="failure">' |
| 145 | 145 | . $stage |
| 146 | - . ($stage==$curStage ? ' <span class="state"/> ' : '') |
|
| 146 | + . ($stage == $curStage ? ' <span class="state"/> ' : '') |
|
| 147 | 147 | . '</a>'; |
| 148 | 148 | } |
| 149 | 149 | } else { |
| 150 | - foreach(Util::$restler->_events as $stage){ |
|
| 150 | + foreach (Util::$restler->_events as $stage) { |
|
| 151 | 151 | echo "<a href=\"#\">$stage</a>"; |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | </header> |
| 159 | 159 | <article> |
| 160 | 160 | |
| 161 | - <h2>Response:<right><?php echo $icon;?></right></h2> |
|
| 161 | + <h2>Response:<right><?php echo $icon; ?></right></h2> |
|
| 162 | 162 | <pre class="header"><?php echo $responseHeaders ?></pre> |
| 163 | 163 | <?php echo render($response); ?> |
| 164 | 164 | <h2>Additional Template Data:</h2> |
@@ -44,8 +44,9 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | //$output .= print_r($entry, true) . "\n"; |
| 46 | 46 | $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n"; |
| 47 | - if (isset($entry['class'])) |
|
| 48 | - $output .= $entry['class'] . "::"; |
|
| 47 | + if (isset($entry['class'])) { |
|
| 48 | + $output .= $entry['class'] . "::"; |
|
| 49 | + } |
|
| 49 | 50 | $output .= $entry['function'] |
| 50 | 51 | . "( " . json_encode($entry['args']) . " )\n"; |
| 51 | 52 | } |
@@ -73,8 +74,9 @@ discard block |
||
| 73 | 74 | function render($data, $shadow=true) |
| 74 | 75 | { |
| 75 | 76 | $r = ''; |
| 76 | - if (empty($data)) |
|
| 77 | - return $r; |
|
| 77 | + if (empty($data)) { |
|
| 78 | + return $r; |
|
| 79 | + } |
|
| 78 | 80 | $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n"; |
| 79 | 81 | if (is_array($data)) { |
| 80 | 82 | // field name |
@@ -112,8 +114,9 @@ discard block |
||
| 112 | 114 | $reqHeadersArr = array(); |
| 113 | 115 | $requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL; |
| 114 | 116 | foreach ($reqHeadersArr as $key => $value) { |
| 115 | - if ($key == 'Host') |
|
| 116 | - continue; |
|
| 117 | + if ($key == 'Host') { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 117 | 120 | $requestHeaders .= "$key: $value" . PHP_EOL; |
| 118 | 121 | } |
| 119 | 122 | // $requestHeaders = $this->encode(apache_request_headers(), FALSE, |