├── git-plugin-updates.php ├── includes ├── class-controller.php ├── class-updater-bitbucket.php ├── class-updater-github.php ├── class-updater.php └── gitweb │ ├── gitweb.php │ ├── phpQuery.php │ └── phpQuery │ ├── Callback.php │ ├── DOMDocumentWrapper.php │ ├── DOMEvent.php │ ├── Zend │ ├── Exception.php │ ├── Http │ │ ├── Client.php │ │ ├── Client │ │ │ ├── Adapter │ │ │ │ ├── Exception.php │ │ │ │ ├── Interface.php │ │ │ │ ├── Proxy.php │ │ │ │ ├── Socket.php │ │ │ │ └── Test.php │ │ │ └── Exception.php │ │ ├── Cookie.php │ │ ├── CookieJar.php │ │ ├── Exception.php │ │ └── Response.php │ ├── Json │ │ ├── Decoder.php │ │ ├── Encoder.php │ │ └── Exception.php │ ├── Loader.php │ ├── Registry.php │ ├── Uri.php │ ├── Uri │ │ ├── Exception.php │ │ └── Http.php │ └── Validate │ │ ├── Abstract.php │ │ ├── Alnum.php │ │ ├── Alpha.php │ │ ├── Barcode.php │ │ ├── Barcode │ │ ├── Ean13.php │ │ └── UpcA.php │ │ ├── Between.php │ │ ├── Ccnum.php │ │ ├── Date.php │ │ ├── Digits.php │ │ ├── EmailAddress.php │ │ ├── Exception.php │ │ ├── File │ │ ├── Count.php │ │ ├── Exists.php │ │ ├── Extension.php │ │ ├── FilesSize.php │ │ ├── ImageSize.php │ │ ├── MimeType.php │ │ ├── NotExists.php │ │ ├── Size.php │ │ └── Upload.php │ │ ├── Float.php │ │ ├── GreaterThan.php │ │ ├── Hex.php │ │ ├── Hostname.php │ │ ├── Hostname │ │ ├── At.php │ │ ├── Ch.php │ │ ├── De.php │ │ ├── Fi.php │ │ ├── Hu.php │ │ ├── Interface.php │ │ ├── Li.php │ │ ├── No.php │ │ └── Se.php │ │ ├── Identical.php │ │ ├── InArray.php │ │ ├── Int.php │ │ ├── Interface.php │ │ ├── Ip.php │ │ ├── LessThan.php │ │ ├── NotEmpty.php │ │ ├── Regex.php │ │ └── StringLength.php │ ├── bootstrap.example.php │ ├── compat │ └── mbstring.php │ ├── phpQueryEvents.php │ ├── phpQueryObject.php │ └── plugins │ ├── Scripts.php │ ├── Scripts │ ├── __config.example.php │ ├── example.php │ ├── fix_webroot.php │ ├── google_login.php │ ├── print_source.php │ └── print_websafe.php │ ├── WebBrowser.php │ └── example.php └── readme.md /git-plugin-updates.php: -------------------------------------------------------------------------------- 1 | Github and Bitbucket. Search and install plugins from Github using Github Plugin Search. 6 | Version: 2.0.1 7 | Author: Paul Clark, 10up 8 | Author URI: http://pdclark.com 9 | License: GPLv2 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 | Git URI: https://github.com/10up/git-plugin-updates 12 | */ 13 | 14 | /** 15 | * ## TESTING 16 | * Change version number above to 1.0 to test updates. 17 | */ 18 | 19 | /** 20 | * Verify we're in wp-admin -- plugin doesn't need to load in front-end. 21 | * Verify that we're running WordPress 3.2 (which enforces PHP 5.2.4). 22 | */ 23 | if ( is_admin() && version_compare( $GLOBALS['wp_version'], '3.2', '>=' ) ) : 24 | 25 | // Load plugin classes and instantiate the plugin. 26 | require_once dirname( __FILE__ ) . '/includes/class-controller.php'; 27 | require_once dirname( __FILE__ ) . '/includes/class-updater.php'; 28 | require_once dirname( __FILE__ ) . '/includes/class-updater-github.php'; 29 | require_once dirname( __FILE__ ) . '/includes/class-updater-bitbucket.php'; 30 | 31 | add_action( 'plugins_loaded', 'GPU_Controller::get_instance', 5 ); 32 | 33 | endif; 34 | -------------------------------------------------------------------------------- /includes/class-updater-bitbucket.php: -------------------------------------------------------------------------------- 1 | branch = 'master'; 22 | } 23 | 24 | public function set_repo_info( $plugin ) { 25 | parent::set_repo_info( $plugin ); 26 | 27 | // Remove .git extension 28 | $this->repository = str_replace( '.git', '', $this->repository ); 29 | } 30 | 31 | /** 32 | * Read the remote plugin file. 33 | * 34 | * Uses a transient to limit the calls to the API. 35 | * 36 | * @author Andy Fragen, Codepress 37 | * @link https://github.com/afragen/github-updater 38 | * 39 | * @param string $type plugin|readme 40 | */ 41 | protected function get_remote_info( $type = 'plugin' ) { 42 | if ( 'plugin' == $type ){ 43 | $type = 'raw/' . $this->branch . '/' . basename( $this->slug ); 44 | } 45 | 46 | // Transients fail if key is longer than 45 characters 47 | $transient_key = 'gpu-' . md5( $type ); 48 | 49 | $remote = get_site_transient( $transient_key ); 50 | 51 | if ( false === $remote ) { 52 | $remote = $this->api( '/repositories/:owner/:repo/' . $type ); 53 | 54 | if ( $remote ) { 55 | set_site_transient( $transient_key, $remote, GPU_Controller::$update_interval ); 56 | } 57 | } 58 | return $remote; 59 | } 60 | 61 | /** 62 | * Call the Bitbucket API and return a json decoded body. 63 | * 64 | * @author Andy Fragen, Codepress 65 | * @link https://github.com/afragen/github-updater 66 | * 67 | * @see http://developer.github.com/v3/ 68 | * @param string $url 69 | * @return boolean|object 70 | */ 71 | protected function api( $url ) { 72 | 73 | $request_args = $this->maybe_authenticate_http( $this->git_request_args ); 74 | $response = wp_remote_get( $this->get_api_url( $url ), $request_args ); 75 | 76 | if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != '200' ) { 77 | return false; 78 | } 79 | 80 | $body = wp_remote_retrieve_body( $response ); 81 | $json = json_decode( wp_remote_retrieve_body( $body ) ); 82 | 83 | if ( null === $json ) { 84 | return $body; 85 | } 86 | 87 | return $json; 88 | } 89 | 90 | /** 91 | * Return API url. 92 | * 93 | * @author Andy Fragen, Codepress 94 | * @link https://github.com/afragen/github-updater 95 | * 96 | * @param string $endpoint 97 | * @return string 98 | */ 99 | protected function get_api_url( $endpoint ) { 100 | $segments = array( 101 | 'owner' => $this->owner, 102 | 'repo' => $this->repository, 103 | ); 104 | 105 | /** 106 | * Add or filter the available segments that are used to replace placeholders. 107 | * 108 | * @since 1.5.0 109 | * 110 | * @param array $segments List of segments. 111 | */ 112 | $segments = apply_filters( 'gpu_api_segments', $segments ); 113 | 114 | foreach ( $segments as $segment => $value ) { 115 | $endpoint = str_replace( '/:' . $segment, '/' . $value, $endpoint ); 116 | } 117 | 118 | // if ( ! empty( $this->access_token ) ) 119 | // $endpoint = add_query_arg( 'access_token', $this->access_token, $endpoint ); 120 | 121 | // If a branch has been given, only check that for the remote info. 122 | // If it's not been given, Bitbucket will use the Default branch. 123 | // if ( ! empty( $this->branch ) ) 124 | // $endpoint = add_query_arg( 'ref', $this->branch, $endpoint ); 125 | 126 | return 'https://api.bitbucket.org/1.0' . $endpoint; 127 | } 128 | 129 | protected function get_zip_url() { 130 | 131 | return 'https://bitbucket.org/' . $this->owner . '/' . $this->repository . 132 | '/get/' . $this->branch . '.zip'; 133 | 134 | } 135 | 136 | /** 137 | * Get plugin details section for plugin details iframe 138 | * 139 | * @return array Sections array for wp-admin/plugin-install.php::install_plugin_information() 140 | */ 141 | protected function get_sections() { 142 | return array( 143 | 'description' => '
Plugin details not yet supported for Bitbucket repositories.
', 144 | ); 145 | } 146 | 147 | public function maybe_authenticate_http( $args ) { 148 | if ( !empty( $this->access_token ) ) { 149 | return $args; 150 | } 151 | 152 | $username = apply_filters( 'gpu_username_bitbucket', $this->username ); 153 | $password = apply_filters( 'gpu_password_bitbucket', $this->password ); 154 | 155 | if ( $username && $password ) { 156 | $args['headers']['Authorization'] = 'Basic ' . base64_encode( "$username:$password" ); 157 | } 158 | 159 | return $args; 160 | } 161 | 162 | } -------------------------------------------------------------------------------- /includes/class-updater-github.php: -------------------------------------------------------------------------------- 1 | branch = $this->get_default_branch(); 22 | } 23 | 24 | /** 25 | * Read the remote plugin file. 26 | * 27 | * Uses a transient to limit the calls to the API. 28 | * 29 | * @author Andy Fragen, Codepress 30 | * @link https://github.com/afragen/github-updater 31 | * 32 | * @param string $type plugin|readme 33 | */ 34 | protected function get_remote_info( $type = 'plugin' ) { 35 | if ( 'plugin' == $type ){ 36 | $type = 'contents/' . basename( $this->slug ); 37 | } 38 | 39 | // Transients fail if key is longer than 45 characters 40 | $transient_key = 'gpu-' . md5( $type ); 41 | 42 | $remote = get_site_transient( $transient_key ); 43 | 44 | if ( false === $remote ) { 45 | $remote = $this->api( '/repos/:owner/:repo/' . $type ); 46 | 47 | if ( $remote ) { 48 | set_site_transient( $transient_key, $remote, GPU_Controller::$update_interval ); 49 | } 50 | } 51 | return $remote; 52 | } 53 | 54 | /** 55 | * Call the GitHub API and return a json decoded body. 56 | * 57 | * @author Andy Fragen, Codepress 58 | * @link https://github.com/afragen/github-updater 59 | * 60 | * @see http://developer.github.com/v3/ 61 | * @param string $url 62 | * @return boolean|object 63 | */ 64 | protected function api( $url ) { 65 | 66 | $request_args = $this->maybe_authenticate_http( $this->git_request_args ); 67 | $response = wp_remote_get( $this->get_api_url( $url ), $request_args ); 68 | 69 | if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != '200' ) { 70 | return false; 71 | } 72 | 73 | return json_decode( wp_remote_retrieve_body( $response ) ); 74 | } 75 | 76 | /** 77 | * Return API url. 78 | * 79 | * @author Andy Fragen, Codepress 80 | * @link https://github.com/afragen/github-updater 81 | * 82 | * @param string $endpoint 83 | * @return string 84 | */ 85 | protected function get_api_url( $endpoint ) { 86 | $segments = array( 87 | 'owner' => $this->owner, 88 | 'repo' => $this->repository, 89 | ); 90 | 91 | /** 92 | * Add or filter the available segments that are used to replace placeholders. 93 | * 94 | * @since 1.5.0 95 | * 96 | * @param array $segments List of segments. 97 | */ 98 | $segments = apply_filters( 'gpu_api_segments', $segments ); 99 | 100 | foreach ( $segments as $segment => $value ) { 101 | $endpoint = str_replace( '/:' . $segment, '/' . $value, $endpoint ); 102 | } 103 | 104 | if ( ! empty( $this->access_token ) ) 105 | $endpoint = add_query_arg( 'access_token', $this->access_token, $endpoint ); 106 | 107 | // If a branch has been given, only check that for the remote info. 108 | // If it's not been given, GitHub will use the Default branch. 109 | if ( ! empty( $this->branch ) ) 110 | $endpoint = add_query_arg( 'ref', $this->branch, $endpoint ); 111 | 112 | return 'https://api.github.com' . $endpoint; 113 | } 114 | 115 | protected function get_zip_url() { 116 | 117 | return 'https://github.com/' . $this->owner . '/' . $this->repository . 118 | '/archive/' . $this->branch . '.zip'; 119 | 120 | } 121 | 122 | /** 123 | * Get update date 124 | * 125 | * @return string $date the date 126 | */ 127 | // protected function get_last_updated() { 128 | // $_date = $this->get_remote_info(); 129 | // if ( false === $_date ) { return false; } 130 | // return ( !empty($_date->updated_at) ) ? date( 'Y-m-d', strtotime( $_date->updated_at ) ) : false; 131 | // } 132 | 133 | public function maybe_authenticate_http( $args ) { 134 | if ( !empty( $this->access_token ) ) { 135 | return $args; 136 | } 137 | 138 | $username = apply_filters( 'gpu_username_github', $this->username ); 139 | $password = apply_filters( 'gpu_password_github', $this->password ); 140 | 141 | if ( $username && $password ) { 142 | $args['headers']['Authorization'] = 'Basic ' . base64_encode( "$username:$password" ); 143 | } 144 | 145 | return $args; 146 | } 147 | 148 | } -------------------------------------------------------------------------------- /includes/class-updater.php: -------------------------------------------------------------------------------- 1 | 5, 37 | 'sslverify' => false, 38 | ); 39 | 40 | public function __construct( $args ){ 41 | 42 | global $wp_version; 43 | 44 | $defaults = array( 45 | 'name' => $args['Name'], 46 | 'slug' => $args['slug'], 47 | 'folder_name' => dirname( $args['slug'] ), 48 | 'key' => dirname( $args['slug'] ), 49 | 'version' => $args['Version'], 50 | 'author' => $args['Author'], 51 | 'homepage' => $args['PluginURI'], 52 | 'requires' => $wp_version, 53 | 'tested' => $wp_version, 54 | ); 55 | 56 | $args = wp_parse_args( $args, $defaults ); 57 | 58 | foreach( $args as $key => $value ) { 59 | $this->$key = $value; 60 | } 61 | 62 | $this->set_repo_info( $args ); 63 | 64 | add_filter( 'http_request_args', array( $this, 'maybe_authenticate_zip_url' ), 10, 2 ); 65 | 66 | add_filter( 'gpu_ssl_disabled_urls', array( $this, 'ssl_disabled_urls' ) ); 67 | 68 | } 69 | 70 | /** 71 | * If a protected variable is accessed from outside the class, 72 | * return a value from method $this->get_$var() or $this->$var 73 | * 74 | * For example, $this->unread_count returns $this->get_unread_count() 75 | * 76 | * @return $this->get_$var()|$this->$var 77 | */ 78 | public function __get( $var ) { 79 | $method = 'get_' . $var; 80 | 81 | if ( method_exists( $this, $method ) ) { 82 | return $this->$method(); 83 | }else { 84 | return $this->$var; 85 | } 86 | } 87 | 88 | /** 89 | * Should this class be used as the updater the passed plugin? 90 | * Static so we can access this method without instantiating the object. 91 | * 92 | * @see GPU_Controller::get_plugin_updater_object() 93 | * @param $plugin array Metadata for a plugin 94 | */ 95 | public static function updates_this_plugin( $plugin ) { 96 | 97 | /** 98 | * static:: calls a static class in the extending class. 99 | * @see http://stackoverflow.com/questions/2859633/why-cant-you-call-abstract-functions-from-abstract-classes-in-php 100 | */ 101 | 102 | $uri = static::parse_plugin_uri( $plugin ); 103 | 104 | if ( isset( $uri['host'] ) && in_array( $uri['host'], static::$valid_domain_names ) ) { 105 | return true; 106 | } 107 | return false; 108 | 109 | } 110 | 111 | /** 112 | * @param $plugin array Plugin metadata 113 | * @return array Parsed plugin URI 114 | */ 115 | public static function parse_plugin_uri( $plugin ) { 116 | 117 | if ( !empty( $plugin['Git URI'] ) ) { 118 | $url = parse_url( $plugin['Git URI'] ); 119 | }elseif ( apply_filters( 'gpu_use_plugin_uri_header', false ) ) { 120 | $url = parse_url( $plugin['PluginURI'] ); 121 | } 122 | 123 | return $url; 124 | } 125 | 126 | public function ssl_disabled_urls( $urls ) { 127 | 128 | if ( !empty( $this->homepage ) ) { 129 | $urls[] = $this->homepage; 130 | } 131 | $urls[] = $this->get_api_url( '/repos/:owner/:repo' ); 132 | 133 | return $urls; 134 | } 135 | 136 | /** 137 | * Retrieves the local version from the file header of the plugin 138 | * 139 | * @author Andy Fragen, Codepress 140 | * @link https://github.com/afragen/github-updater 141 | * 142 | * @return string|boolean Version of installed plugin, false if not determined. 143 | */ 144 | protected function get_local_version() { 145 | $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $this->slug ); 146 | 147 | if ( ! empty( $data['Version'] ) ) 148 | return $data['Version']; 149 | 150 | return false; 151 | } 152 | 153 | /** 154 | * Retrieve the remote version from the file header of the plugin 155 | * 156 | * @author Andy Fragen, Codepress 157 | * @link https://github.com/afragen/github-updater 158 | * 159 | * @return string|boolean Version of remote plugin, false if not determined. 160 | */ 161 | protected function get_remote_version() { 162 | $response = $this->get_remote_info(); 163 | if ( false === $response ) { 164 | return false; 165 | } 166 | 167 | // Todo: Handle this switch in the sub classes 168 | if ( isset( $response->encoding ) && 'base64' == $response->encoding ) { 169 | // Github 170 | $content = base64_decode( $response->content ); 171 | }else { 172 | // Bitbucket 173 | $content = $response; 174 | } 175 | 176 | preg_match( '/^[ \t\/*#@]*Version\:\s*(.*)$/im', $content, $matches ); 177 | 178 | if ( ! empty( $matches[1] ) ) 179 | return $matches[1]; 180 | 181 | return false; 182 | } 183 | 184 | /** 185 | * Parse the remote info to find what the default branch is. 186 | * 187 | * @author Andy Fragen, Codepress 188 | * @link https://github.com/afragen/github-updater 189 | * 190 | * @return string Default branch name. 191 | */ 192 | protected function get_default_branch() { 193 | // If we've had to call this default branch method, we know that a branch header has not been provided. As such 194 | // the remote info was retrieved without a ?ref=... query argument. 195 | $response = $this->get_remote_info(); 196 | 197 | // If we can't contact API, then assume a sensible default in case the non-API part of GitHub is working. 198 | if ( false === $response ) { 199 | return 'master'; 200 | } 201 | 202 | // Assuming we've got some remote info, parse the 'url' field to get the last bit of the ref query string 203 | $components = parse_url( $response->url, PHP_URL_QUERY ); 204 | parse_str( $components ); 205 | return $ref; 206 | } 207 | 208 | /** 209 | * Get the last updated date from remote repo 210 | */ 211 | protected function get_last_updated() { 212 | return false; 213 | } 214 | 215 | /** 216 | * Get plugin details section for plugin details iframe 217 | * 218 | * @return array Sections array for wp-admin/plugin-install.php::install_plugin_information() 219 | */ 220 | protected function get_sections() { 221 | $readme = $this->get_remote_info( 'readme' ); 222 | 223 | if ( false === $readme ) { 224 | return array(); 225 | } 226 | 227 | $readme = base64_decode( $readme->content ); 228 | 229 | // Maybe TODO: parse readme textile into sections. 230 | // Also, maybe not, because $readme could be markdown. 231 | return array( 232 | 'description' => '
' . $readme . '
', 233 | // 'installation' => $readme, 234 | // 'changelog' => $readme, 235 | ); 236 | } 237 | 238 | /** 239 | * Set repo host, owner, username, password, and repository from URI 240 | */ 241 | protected function set_repo_info( $plugin ) { 242 | 243 | // parse_plugin_uri() defined in GPU_Updater 244 | $uri = self::parse_plugin_uri( $plugin ); 245 | $path = explode('/', $uri['path'] ); 246 | $this->host = $uri['host']; 247 | 248 | if ( isset( $uri['user'], $uri['pass'] ) ) { 249 | $this->username = str_replace( '%40', '@', $uri['user'] ); 250 | $this->password = $uri['pass']; 251 | } 252 | 253 | $this->owner = $path[1]; 254 | $this->repository = $path[2]; 255 | 256 | } 257 | 258 | /** 259 | * Disable SSL only for Git repo URLs 260 | * 261 | * @return array $args http_request_args 262 | */ 263 | public function maybe_authenticate_zip_url( $args, $url ) { 264 | 265 | if ( $url == $this->get_zip_url() ) { 266 | $args = $this->maybe_authenticate_http( $args ); 267 | } 268 | 269 | return $args; 270 | } 271 | 272 | abstract protected function api( $url ); 273 | 274 | abstract protected function get_api_url( $endpoint ); 275 | 276 | abstract protected function get_remote_info(); 277 | 278 | abstract protected function get_zip_url(); 279 | 280 | abstract protected function maybe_authenticate_http( $args ); 281 | 282 | } -------------------------------------------------------------------------------- /includes/gitweb/gitweb.php: -------------------------------------------------------------------------------- 1 | $args['Name'], 11 | 'slug' => $args['slug'], 12 | 'folder_name' => dirname( $args['slug'] ), 13 | 'key' => dirname( $args['slug'] ), 14 | 'host' => $args['host'], 15 | 'username' => $args['username'], 16 | 'repository' => $args['repository'], 17 | 'version' => $args['Version'], 18 | 'author' => $args['Author'], 19 | 'homepage' => $args['PluginURI'], 20 | 'requires' => $wp_version, 21 | 'tested' => $wp_version, 22 | ); 23 | 24 | $args = wp_parse_args($args, $defaults); 25 | 26 | foreach( $args as $key => $value ) { 27 | $this->$key = $value; 28 | } 29 | 30 | if ( $this->user && $this->pass ) { 31 | $this->url = $this->scheme.'://'.$this->user.':'.$this->pass.'@'.$this->host.'/'.$this->path; 32 | }else { 33 | $this->url = $this->scheme.'://'.$this->host.'/'.$this->path; 34 | } 35 | 36 | $this->get_data(); 37 | 38 | } 39 | 40 | public function get_data() { 41 | 42 | if ( !class_exists('phpQuery') ) { 43 | include dirname(__FILE__).'/phpQuery.php'; 44 | } 45 | 46 | $response = wp_remote_get( $this->url.'/tags' ); 47 | 48 | if ( is_wp_error( $response ) ) { 49 | return false; 50 | } 51 | 52 | phpQuery::newDocument( $response['body'] ); 53 | 54 | $version = false; 55 | $zip_url = false; 56 | foreach( pq('table.tags a.name') as $tag ) { 57 | $tag = pq($tag); 58 | if ( version_compare($tag->text(), $version, '>=') ) { 59 | 60 | $href = $tag->attr('href'); 61 | $commit = substr( $href, strrpos( $href, '/' )+1 ); 62 | 63 | $zip_url = $this->url.'/snapshot/'.$commit.'.zip'; 64 | $version = $tag->text(); 65 | $updated_at = $tag->parent()->prev()->text(); 66 | } 67 | } 68 | 69 | $this->new_version = $version; 70 | $this->zip_url = $zip_url; 71 | $this->updated_at = date( 'Y-m-d', strtotime( $updated_at ) ); 72 | $this->description = pq('div.page_footer_text')->text(); 73 | 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Callback.php: -------------------------------------------------------------------------------- 1 | 25 | * 26 | * @TODO??? return fake forwarding function created via create_function 27 | * @TODO honor paramStructure 28 | */ 29 | class Callback 30 | implements ICallbackNamed { 31 | public $callback = null; 32 | public $params = null; 33 | protected $name; 34 | public function __construct($callback, $param1 = null, $param2 = null, 35 | $param3 = null) { 36 | $params = func_get_args(); 37 | $params = array_slice($params, 1); 38 | if ($callback instanceof Callback) { 39 | // TODO implement recurention 40 | } else { 41 | $this->callback = $callback; 42 | $this->params = $params; 43 | } 44 | } 45 | public function getName() { 46 | return 'Callback: '.$this->name; 47 | } 48 | public function hasName() { 49 | return isset($this->name) && $this->name; 50 | } 51 | public function setName($name) { 52 | $this->name = $name; 53 | return $this; 54 | } 55 | // TODO test me 56 | // public function addParams() { 57 | // $params = func_get_args(); 58 | // return new Callback($this->callback, $this->params+$params); 59 | // } 60 | } 61 | /** 62 | * Shorthand for new Callback(create_function(...), ...); 63 | * 64 | * @author Tobiasz Cudnik 65 | */ 66 | class CallbackBody extends Callback { 67 | public function __construct($paramList, $code, $param1 = null, $param2 = null, 68 | $param3 = null) { 69 | $params = func_get_args(); 70 | $params = array_slice($params, 2); 71 | $this->callback = create_function($paramList, $code); 72 | $this->params = $params; 73 | } 74 | } 75 | /** 76 | * Callback type which on execution returns reference passed during creation. 77 | * 78 | * @author Tobiasz Cudnik 79 | */ 80 | class CallbackReturnReference extends Callback 81 | implements ICallbackNamed { 82 | protected $reference; 83 | public function __construct(&$reference, $name = null){ 84 | $this->reference =& $reference; 85 | $this->callback = array($this, 'callback'); 86 | } 87 | public function callback() { 88 | return $this->reference; 89 | } 90 | public function getName() { 91 | return 'Callback: '.$this->name; 92 | } 93 | public function hasName() { 94 | return isset($this->name) && $this->name; 95 | } 96 | } 97 | /** 98 | * Callback type which on execution returns value passed during creation. 99 | * 100 | * @author Tobiasz Cudnik 101 | */ 102 | class CallbackReturnValue extends Callback 103 | implements ICallbackNamed { 104 | protected $value; 105 | protected $name; 106 | public function __construct($value, $name = null){ 107 | $this->value =& $value; 108 | $this->name = $name; 109 | $this->callback = array($this, 'callback'); 110 | } 111 | public function callback() { 112 | return $this->value; 113 | } 114 | public function __toString() { 115 | return $this->getName(); 116 | } 117 | public function getName() { 118 | return 'Callback: '.$this->name; 119 | } 120 | public function hasName() { 121 | return isset($this->name) && $this->name; 122 | } 123 | } 124 | /** 125 | * CallbackParameterToReference can be used when we don't really want a callback, 126 | * only parameter passed to it. CallbackParameterToReference takes first 127 | * parameter's value and passes it to reference. 128 | * 129 | * @author Tobiasz Cudnik 130 | */ 131 | class CallbackParameterToReference extends Callback { 132 | /** 133 | * @param $reference 134 | * @TODO implement $paramIndex; 135 | * param index choose which callback param will be passed to reference 136 | */ 137 | public function __construct(&$reference){ 138 | $this->callback =& $reference; 139 | } 140 | } 141 | //class CallbackReference extends Callback { 142 | // /** 143 | // * 144 | // * @param $reference 145 | // * @param $paramIndex 146 | // * @todo implement $paramIndex; param index choose which callback param will be passed to reference 147 | // */ 148 | // public function __construct(&$reference, $name = null){ 149 | // $this->callback =& $reference; 150 | // } 151 | //} 152 | class CallbackParam {} -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/DOMEvent.php: -------------------------------------------------------------------------------- 1 | 8 | * @package phpQuery 9 | * @todo implement ArrayAccess ? 10 | */ 11 | class DOMEvent { 12 | /** 13 | * Returns a boolean indicating whether the event bubbles up through the DOM or not. 14 | * 15 | * @var unknown_type 16 | */ 17 | public $bubbles = true; 18 | /** 19 | * Returns a boolean indicating whether the event is cancelable. 20 | * 21 | * @var unknown_type 22 | */ 23 | public $cancelable = true; 24 | /** 25 | * Returns a reference to the currently registered target for the event. 26 | * 27 | * @var unknown_type 28 | */ 29 | public $currentTarget; 30 | /** 31 | * Returns detail about the event, depending on the type of event. 32 | * 33 | * @var unknown_type 34 | * @link http://developer.mozilla.org/en/DOM/event.detail 35 | */ 36 | public $detail; // ??? 37 | /** 38 | * Used to indicate which phase of the event flow is currently being evaluated. 39 | * 40 | * NOT IMPLEMENTED 41 | * 42 | * @var unknown_type 43 | * @link http://developer.mozilla.org/en/DOM/event.eventPhase 44 | */ 45 | public $eventPhase; // ??? 46 | /** 47 | * The explicit original target of the event (Mozilla-specific). 48 | * 49 | * NOT IMPLEMENTED 50 | * 51 | * @var unknown_type 52 | */ 53 | public $explicitOriginalTarget; // moz only 54 | /** 55 | * The original target of the event, before any retargetings (Mozilla-specific). 56 | * 57 | * NOT IMPLEMENTED 58 | * 59 | * @var unknown_type 60 | */ 61 | public $originalTarget; // moz only 62 | /** 63 | * Identifies a secondary target for the event. 64 | * 65 | * @var unknown_type 66 | */ 67 | public $relatedTarget; 68 | /** 69 | * Returns a reference to the target to which the event was originally dispatched. 70 | * 71 | * @var unknown_type 72 | */ 73 | public $target; 74 | /** 75 | * Returns the time that the event was created. 76 | * 77 | * @var unknown_type 78 | */ 79 | public $timeStamp; 80 | /** 81 | * Returns the name of the event (case-insensitive). 82 | */ 83 | public $type; 84 | public $runDefault = true; 85 | public $data = null; 86 | public function __construct($data) { 87 | foreach($data as $k => $v) { 88 | $this->$k = $v; 89 | } 90 | if (! $this->timeStamp) 91 | $this->timeStamp = time(); 92 | } 93 | /** 94 | * Cancels the event (if it is cancelable). 95 | * 96 | */ 97 | public function preventDefault() { 98 | $this->runDefault = false; 99 | } 100 | /** 101 | * Stops the propagation of events further along in the DOM. 102 | * 103 | */ 104 | public function stopPropagation() { 105 | $this->bubbles = false; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Exception.php: -------------------------------------------------------------------------------- 1 | $v) { 86 | $this->config[strtolower($k)] = $v; 87 | } 88 | } 89 | 90 | /** 91 | * Connect to the remote server 92 | * 93 | * @param string $host 94 | * @param int $port 95 | * @param boolean $secure 96 | * @param int $timeout 97 | */ 98 | public function connect($host, $port = 80, $secure = false) 99 | { } 100 | 101 | /** 102 | * Send request to the remote server 103 | * 104 | * @param string $method 105 | * @param Zend_Uri_Http $uri 106 | * @param string $http_ver 107 | * @param array $headers 108 | * @param string $body 109 | * @return string Request as string 110 | */ 111 | public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '') 112 | { 113 | $host = $uri->getHost(); 114 | $host = (strtolower($uri->getScheme()) == 'https' ? 'sslv2://' . $host : $host); 115 | 116 | // Build request headers 117 | $path = $uri->getPath(); 118 | if ($uri->getQuery()) $path .= '?' . $uri->getQuery(); 119 | $request = "{$method} {$path} HTTP/{$http_ver}\r\n"; 120 | foreach ($headers as $k => $v) { 121 | if (is_string($k)) $v = ucfirst($k) . ": $v"; 122 | $request .= "$v\r\n"; 123 | } 124 | 125 | // Add the request body 126 | $request .= "\r\n" . $body; 127 | 128 | // Do nothing - just return the request as string 129 | 130 | return $request; 131 | } 132 | 133 | /** 134 | * Return the response set in $this->setResponse() 135 | * 136 | * @return string 137 | */ 138 | public function read() 139 | { 140 | if ($this->responseIndex >= count($this->responses)) { 141 | $this->responseIndex = 0; 142 | } 143 | return $this->responses[$this->responseIndex++]; 144 | } 145 | 146 | /** 147 | * Close the connection (dummy) 148 | * 149 | */ 150 | public function close() 151 | { } 152 | 153 | /** 154 | * Set the HTTP response(s) to be returned by this adapter 155 | * 156 | * @param Zend_Http_Response|array|string $response 157 | */ 158 | public function setResponse($response) 159 | { 160 | if ($response instanceof Zend_Http_Response) { 161 | $response = $response->asString(); 162 | } 163 | 164 | $this->responses = (array)$response; 165 | $this->responseIndex = 0; 166 | } 167 | 168 | /** 169 | * Add another response to the response buffer. 170 | * 171 | * @param string $response 172 | */ 173 | public function addResponse($response) 174 | { 175 | $this->responses[] = $response; 176 | } 177 | 178 | /** 179 | * Sets the position of the response buffer. Selects which 180 | * response will be returned on the next call to read(). 181 | * 182 | * @param integer $index 183 | */ 184 | public function setResponseIndex($index) 185 | { 186 | if ($index < 0 || $index >= count($this->responses)) { 187 | require_once 'Zend/Http/Client/Adapter/Exception.php'; 188 | throw new Zend_Http_Client_Adapter_Exception( 189 | 'Index out of range of response buffer size'); 190 | } 191 | $this->responseIndex = $index; 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Http/Client/Exception.php: -------------------------------------------------------------------------------- 1 | offsetExists($index)) { 144 | require_once 'Zend/Exception.php'; 145 | throw new Zend_Exception("No entry is registered for key '$index'"); 146 | } 147 | 148 | return $instance->offsetGet($index); 149 | } 150 | 151 | /** 152 | * setter method, basically same as offsetSet(). 153 | * 154 | * This method can be called from an object of type Zend_Registry, or it 155 | * can be called statically. In the latter case, it uses the default 156 | * static instance stored in the class. 157 | * 158 | * @param string $index The location in the ArrayObject in which to store 159 | * the value. 160 | * @param mixed $value The object to store in the ArrayObject. 161 | * @return void 162 | */ 163 | public static function set($index, $value) 164 | { 165 | $instance = self::getInstance(); 166 | $instance->offsetSet($index, $value); 167 | } 168 | 169 | /** 170 | * Returns TRUE if the $index is a named value in the registry, 171 | * or FALSE if $index was not found in the registry. 172 | * 173 | * @param string $index 174 | * @return boolean 175 | */ 176 | public static function isRegistered($index) 177 | { 178 | if (self::$_registry === null) { 179 | return false; 180 | } 181 | return self::$_registry->offsetExists($index); 182 | } 183 | 184 | /** 185 | * @param string $index 186 | * @returns mixed 187 | * 188 | * Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960). 189 | */ 190 | public function offsetExists($index) 191 | { 192 | return array_key_exists($index, $this); 193 | } 194 | 195 | } 196 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Uri.php: -------------------------------------------------------------------------------- 1 | getUri(); 53 | } 54 | 55 | /** 56 | * Convenience function, checks that a $uri string is well-formed 57 | * by validating it but not returning an object. Returns TRUE if 58 | * $uri is a well-formed URI, or FALSE otherwise. 59 | * 60 | * @param string $uri The URI to check 61 | * @return boolean 62 | */ 63 | public static function check($uri) 64 | { 65 | try { 66 | $uri = self::factory($uri); 67 | } catch (Exception $e) { 68 | return false; 69 | } 70 | 71 | return $uri->valid(); 72 | } 73 | 74 | /** 75 | * Create a new Zend_Uri object for a URI. If building a new URI, then $uri should contain 76 | * only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI. 77 | * 78 | * @param string $uri The URI form which a Zend_Uri instance is created 79 | * @throws Zend_Uri_Exception When an empty string was supplied for the scheme 80 | * @throws Zend_Uri_Exception When an illegal scheme is supplied 81 | * @throws Zend_Uri_Exception When the scheme is not supported 82 | * @return Zend_Uri 83 | * @link http://www.faqs.org/rfcs/rfc2396.html 84 | */ 85 | public static function factory($uri = 'http') 86 | { 87 | // Separate the scheme from the scheme-specific parts 88 | $uri = explode(':', $uri, 2); 89 | $scheme = strtolower($uri[0]); 90 | $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; 91 | 92 | if (strlen($scheme) === 0) { 93 | require_once 'Zend/Uri/Exception.php'; 94 | throw new Zend_Uri_Exception('An empty string was supplied for the scheme'); 95 | } 96 | 97 | // Security check: $scheme is used to load a class file, so only alphanumerics are allowed. 98 | if (ctype_alnum($scheme) === false) { 99 | require_once 'Zend/Uri/Exception.php'; 100 | throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted'); 101 | } 102 | 103 | /** 104 | * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the 105 | * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. 106 | */ 107 | switch ($scheme) { 108 | case 'http': 109 | // Break intentionally omitted 110 | case 'https': 111 | $className = 'Zend_Uri_Http'; 112 | break; 113 | 114 | case 'mailto': 115 | // TODO 116 | default: 117 | require_once 'Zend/Uri/Exception.php'; 118 | throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); 119 | break; 120 | } 121 | 122 | Zend_Loader::loadClass($className); 123 | $schemeHandler = new $className($scheme, $schemeSpecific); 124 | 125 | return $schemeHandler; 126 | } 127 | 128 | /** 129 | * Get the URI's scheme 130 | * 131 | * @return string|false Scheme or false if no scheme is set. 132 | */ 133 | public function getScheme() 134 | { 135 | if (empty($this->_scheme) === false) { 136 | return $this->_scheme; 137 | } else { 138 | return false; 139 | } 140 | } 141 | 142 | /** 143 | * Zend_Uri and its subclasses cannot be instantiated directly. 144 | * Use Zend_Uri::factory() to return a new Zend_Uri object. 145 | * 146 | * @param string $scheme The scheme of the URI 147 | * @param string $schemeSpecific The scheme-specific part of the URI 148 | */ 149 | abstract protected function __construct($scheme, $schemeSpecific = ''); 150 | 151 | /** 152 | * Return a string representation of this URI. 153 | * 154 | * @return string 155 | */ 156 | abstract public function getUri(); 157 | 158 | /** 159 | * Returns TRUE if this URI is valid, or FALSE otherwise. 160 | * 161 | * @return boolean 162 | */ 163 | abstract public function valid(); 164 | } 165 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Uri/Exception.php: -------------------------------------------------------------------------------- 1 | "'%value%' has not only alphabetic and digit characters", 69 | self::STRING_EMPTY => "'%value%' is an empty string" 70 | ); 71 | 72 | /** 73 | * Sets default option values for this instance 74 | * 75 | * @param boolean $allowWhiteSpace 76 | * @return void 77 | */ 78 | public function __construct($allowWhiteSpace = false) 79 | { 80 | $this->allowWhiteSpace = (boolean) $allowWhiteSpace; 81 | } 82 | 83 | /** 84 | * Defined by Zend_Validate_Interface 85 | * 86 | * Returns true if and only if $value contains only alphabetic and digit characters 87 | * 88 | * @param string $value 89 | * @return boolean 90 | */ 91 | public function isValid($value) 92 | { 93 | $valueString = (string) $value; 94 | 95 | $this->_setValue($valueString); 96 | 97 | if ('' === $valueString) { 98 | $this->_error(self::STRING_EMPTY); 99 | return false; 100 | } 101 | 102 | if (null === self::$_filter) { 103 | /** 104 | * @see Zend_Filter_Alnum 105 | */ 106 | require_once 'Zend/Filter/Alnum.php'; 107 | self::$_filter = new Zend_Filter_Alnum(); 108 | } 109 | 110 | self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; 111 | 112 | if ($valueString !== self::$_filter->filter($valueString)) { 113 | $this->_error(self::NOT_ALNUM); 114 | return false; 115 | } 116 | 117 | return true; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Alpha.php: -------------------------------------------------------------------------------- 1 | "'%value%' has not only alphabetic characters", 69 | self::STRING_EMPTY => "'%value%' is an empty string" 70 | ); 71 | 72 | /** 73 | * Sets default option values for this instance 74 | * 75 | * @param boolean $allowWhiteSpace 76 | * @return void 77 | */ 78 | public function __construct($allowWhiteSpace = false) 79 | { 80 | $this->allowWhiteSpace = (boolean) $allowWhiteSpace; 81 | } 82 | 83 | /** 84 | * Defined by Zend_Validate_Interface 85 | * 86 | * Returns true if and only if $value contains only alphabetic characters 87 | * 88 | * @param string $value 89 | * @return boolean 90 | */ 91 | public function isValid($value) 92 | { 93 | $valueString = (string) $value; 94 | 95 | $this->_setValue($valueString); 96 | 97 | if ('' === $valueString) { 98 | $this->_error(self::STRING_EMPTY); 99 | return false; 100 | } 101 | 102 | if (null === self::$_filter) { 103 | /** 104 | * @see Zend_Filter_Alpha 105 | */ 106 | require_once 'Zend/Filter/Alpha.php'; 107 | self::$_filter = new Zend_Filter_Alpha(); 108 | } 109 | 110 | self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; 111 | 112 | if ($valueString !== self::$_filter->filter($valueString)) { 113 | $this->_error(self::NOT_ALPHA); 114 | return false; 115 | } 116 | 117 | return true; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Barcode.php: -------------------------------------------------------------------------------- 1 | setType($barcodeType); 55 | } 56 | 57 | /** 58 | * Sets a new barcode validator 59 | * 60 | * @param string $barcodeType - Barcode validator to use 61 | * @return void 62 | * @throws Zend_Validate_Exception 63 | */ 64 | public function setType($barcodeType) 65 | { 66 | switch (strtolower($barcodeType)) { 67 | case 'upc': 68 | case 'upc-a': 69 | $className = 'UpcA'; 70 | break; 71 | case 'ean13': 72 | case 'ean-13': 73 | $className = 'Ean13'; 74 | break; 75 | default: 76 | require_once 'Zend/Validate/Exception.php'; 77 | throw new Zend_Validate_Exception("Barcode type '$barcodeType' is not supported'"); 78 | break; 79 | } 80 | 81 | require_once 'Zend/Validate/Barcode/' . $className . '.php'; 82 | 83 | $class = 'Zend_Validate_Barcode_' . $className; 84 | $this->_barcodeValidator = new $class; 85 | } 86 | 87 | /** 88 | * Defined by Zend_Validate_Interface 89 | * 90 | * Returns true if and only if $value contains a valid barcode 91 | * 92 | * @param string $value 93 | * @return boolean 94 | */ 95 | public function isValid($value) 96 | { 97 | return call_user_func(array($this->_barcodeValidator, 'isValid'), $value); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Barcode/Ean13.php: -------------------------------------------------------------------------------- 1 | "'%value%' is an invalid EAN-13 barcode", 57 | self::INVALID_LENGTH => "'%value%' should be 13 characters", 58 | ); 59 | 60 | /** 61 | * Defined by Zend_Validate_Interface 62 | * 63 | * Returns true if and only if $value contains a valid barcode 64 | * 65 | * @param string $value 66 | * @return boolean 67 | */ 68 | public function isValid($value) 69 | { 70 | $valueString = (string) $value; 71 | $this->_setValue($valueString); 72 | 73 | if (strlen($valueString) !== 13) { 74 | $this->_error(self::INVALID_LENGTH); 75 | return false; 76 | } 77 | 78 | $barcode = strrev(substr($valueString, 0, -1)); 79 | $oddSum = 0; 80 | $evenSum = 0; 81 | 82 | for ($i = 0; $i < 12; $i++) { 83 | if ($i % 2 === 0) { 84 | $oddSum += $barcode[$i] * 3; 85 | } elseif ($i % 2 === 1) { 86 | $evenSum += $barcode[$i]; 87 | } 88 | } 89 | 90 | $calculation = ($oddSum + $evenSum) % 10; 91 | $checksum = ($calculation === 0) ? 0 : 10 - $calculation; 92 | 93 | if ($valueString[12] != $checksum) { 94 | $this->_error(self::INVALID); 95 | return false; 96 | } 97 | 98 | return true; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Barcode/UpcA.php: -------------------------------------------------------------------------------- 1 | "'%value%' is an invalid UPC-A barcode", 57 | self::INVALID_LENGTH => "'%value%' should be 12 characters", 58 | ); 59 | 60 | /** 61 | * Defined by Zend_Validate_Interface 62 | * 63 | * Returns true if and only if $value contains a valid barcode 64 | * 65 | * @param string $value 66 | * @return boolean 67 | */ 68 | public function isValid($value) 69 | { 70 | $valueString = (string) $value; 71 | $this->_setValue($valueString); 72 | 73 | if (strlen($valueString) !== 12) { 74 | $this->_error(self::INVALID_LENGTH); 75 | return false; 76 | } 77 | 78 | $barcode = substr($valueString, 0, -1); 79 | $oddSum = 0; 80 | $evenSum = 0; 81 | 82 | for ($i = 0; $i < 11; $i++) { 83 | if ($i % 2 === 0) { 84 | $oddSum += $barcode[$i] * 3; 85 | } elseif ($i % 2 === 1) { 86 | $evenSum += $barcode[$i]; 87 | } 88 | } 89 | 90 | $calculation = ($oddSum + $evenSum) % 10; 91 | $checksum = ($calculation === 0) ? 0 : 10 - $calculation; 92 | 93 | if ($valueString[11] != $checksum) { 94 | $this->_error(self::INVALID); 95 | return false; 96 | } 97 | 98 | return true; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Between.php: -------------------------------------------------------------------------------- 1 | "'%value%' is not between '%min%' and '%max%', inclusively", 55 | self::NOT_BETWEEN_STRICT => "'%value%' is not strictly between '%min%' and '%max%'" 56 | ); 57 | 58 | /** 59 | * Additional variables available for validation failure messages 60 | * 61 | * @var array 62 | */ 63 | protected $_messageVariables = array( 64 | 'min' => '_min', 65 | 'max' => '_max' 66 | ); 67 | 68 | /** 69 | * Minimum value 70 | * 71 | * @var mixed 72 | */ 73 | protected $_min; 74 | 75 | /** 76 | * Maximum value 77 | * 78 | * @var mixed 79 | */ 80 | protected $_max; 81 | 82 | /** 83 | * Whether to do inclusive comparisons, allowing equivalence to min and/or max 84 | * 85 | * If false, then strict comparisons are done, and the value may equal neither 86 | * the min nor max options 87 | * 88 | * @var boolean 89 | */ 90 | protected $_inclusive; 91 | 92 | /** 93 | * Sets validator options 94 | * 95 | * @param mixed $min 96 | * @param mixed $max 97 | * @param boolean $inclusive 98 | * @return void 99 | */ 100 | public function __construct($min, $max, $inclusive = true) 101 | { 102 | $this->setMin($min) 103 | ->setMax($max) 104 | ->setInclusive($inclusive); 105 | } 106 | 107 | /** 108 | * Returns the min option 109 | * 110 | * @return mixed 111 | */ 112 | public function getMin() 113 | { 114 | return $this->_min; 115 | } 116 | 117 | /** 118 | * Sets the min option 119 | * 120 | * @param mixed $min 121 | * @return Zend_Validate_Between Provides a fluent interface 122 | */ 123 | public function setMin($min) 124 | { 125 | $this->_min = $min; 126 | return $this; 127 | } 128 | 129 | /** 130 | * Returns the max option 131 | * 132 | * @return mixed 133 | */ 134 | public function getMax() 135 | { 136 | return $this->_max; 137 | } 138 | 139 | /** 140 | * Sets the max option 141 | * 142 | * @param mixed $max 143 | * @return Zend_Validate_Between Provides a fluent interface 144 | */ 145 | public function setMax($max) 146 | { 147 | $this->_max = $max; 148 | return $this; 149 | } 150 | 151 | /** 152 | * Returns the inclusive option 153 | * 154 | * @return boolean 155 | */ 156 | public function getInclusive() 157 | { 158 | return $this->_inclusive; 159 | } 160 | 161 | /** 162 | * Sets the inclusive option 163 | * 164 | * @param boolean $inclusive 165 | * @return Zend_Validate_Between Provides a fluent interface 166 | */ 167 | public function setInclusive($inclusive) 168 | { 169 | $this->_inclusive = $inclusive; 170 | return $this; 171 | } 172 | 173 | /** 174 | * Defined by Zend_Validate_Interface 175 | * 176 | * Returns true if and only if $value is between min and max options, inclusively 177 | * if inclusive option is true. 178 | * 179 | * @param mixed $value 180 | * @return boolean 181 | */ 182 | public function isValid($value) 183 | { 184 | $this->_setValue($value); 185 | 186 | if ($this->_inclusive) { 187 | if ($this->_min > $value || $value > $this->_max) { 188 | $this->_error(self::NOT_BETWEEN); 189 | return false; 190 | } 191 | } else { 192 | if ($this->_min >= $value || $value >= $this->_max) { 193 | $this->_error(self::NOT_BETWEEN_STRICT); 194 | return false; 195 | } 196 | } 197 | return true; 198 | } 199 | 200 | } 201 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Ccnum.php: -------------------------------------------------------------------------------- 1 | "'%value%' must contain between 13 and 19 digits", 62 | self::CHECKSUM => "Luhn algorithm (mod-10 checksum) failed on '%value%'" 63 | ); 64 | 65 | /** 66 | * Defined by Zend_Validate_Interface 67 | * 68 | * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum) 69 | * 70 | * @param string $value 71 | * @return boolean 72 | */ 73 | public function isValid($value) 74 | { 75 | $this->_setValue($value); 76 | 77 | if (null === self::$_filter) { 78 | /** 79 | * @see Zend_Filter_Digits 80 | */ 81 | require_once 'Zend/Filter/Digits.php'; 82 | self::$_filter = new Zend_Filter_Digits(); 83 | } 84 | 85 | $valueFiltered = self::$_filter->filter($value); 86 | 87 | $length = strlen($valueFiltered); 88 | 89 | if ($length < 13 || $length > 19) { 90 | $this->_error(self::LENGTH); 91 | return false; 92 | } 93 | 94 | $sum = 0; 95 | $weight = 2; 96 | 97 | for ($i = $length - 2; $i >= 0; $i--) { 98 | $digit = $weight * $valueFiltered[$i]; 99 | $sum += floor($digit / 10) + $digit % 10; 100 | $weight = $weight % 2 + 1; 101 | } 102 | 103 | if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) { 104 | $this->_error(self::CHECKSUM, $valueFiltered); 105 | return false; 106 | } 107 | 108 | return true; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Date.php: -------------------------------------------------------------------------------- 1 | "'%value%' is not of the format YYYY-MM-DD", 60 | self::INVALID => "'%value%' does not appear to be a valid date", 61 | self::FALSEFORMAT => "'%value%' does not fit given date format" 62 | ); 63 | 64 | /** 65 | * Optional format 66 | * 67 | * @var string|null 68 | */ 69 | protected $_format; 70 | 71 | /** 72 | * Optional locale 73 | * 74 | * @var string|Zend_Locale|null 75 | */ 76 | protected $_locale; 77 | 78 | /** 79 | * Sets validator options 80 | * 81 | * @param string $format OPTIONAL 82 | * @param string|Zend_Locale $locale OPTIONAL 83 | * @return void 84 | */ 85 | public function __construct($format = null, $locale = null) 86 | { 87 | $this->setFormat($format); 88 | $this->setLocale($locale); 89 | } 90 | 91 | /** 92 | * Returns the locale option 93 | * 94 | * @return string|Zend_Locale|null 95 | */ 96 | public function getLocale() 97 | { 98 | return $this->_locale; 99 | } 100 | 101 | /** 102 | * Sets the locale option 103 | * 104 | * @param string|Zend_Locale $locale 105 | * @return Zend_Validate_Date provides a fluent interface 106 | */ 107 | public function setLocale($locale = null) 108 | { 109 | if ($locale === null) { 110 | $this->_locale = null; 111 | return $this; 112 | } 113 | 114 | require_once 'Zend/Locale.php'; 115 | if (!Zend_Locale::isLocale($locale, true)) { 116 | if (!Zend_Locale::isLocale($locale, false)) { 117 | require_once 'Zend/Validate/Exception.php'; 118 | throw new Zend_Validate_Exception("The locale '$locale' is no known locale"); 119 | } 120 | 121 | $locale = new Zend_Locale($locale); 122 | } 123 | 124 | $this->_locale = (string) $locale; 125 | return $this; 126 | } 127 | 128 | /** 129 | * Returns the locale option 130 | * 131 | * @return string|null 132 | */ 133 | public function getFormat() 134 | { 135 | return $this->_format; 136 | } 137 | 138 | /** 139 | * Sets the format option 140 | * 141 | * @param string $format 142 | * @return Zend_Validate_Date provides a fluent interface 143 | */ 144 | public function setFormat($format = null) 145 | { 146 | $this->_format = $format; 147 | return $this; 148 | } 149 | 150 | /** 151 | * Defined by Zend_Validate_Interface 152 | * 153 | * Returns true if $value is a valid date of the format YYYY-MM-DD 154 | * If optional $format or $locale is set the date format is checked 155 | * according to Zend_Date, see Zend_Date::isDate() 156 | * 157 | * @param string $value 158 | * @return boolean 159 | */ 160 | public function isValid($value) 161 | { 162 | $valueString = (string) $value; 163 | 164 | $this->_setValue($valueString); 165 | 166 | if (($this->_format !== null) or ($this->_locale !== null)) { 167 | require_once 'Zend/Date.php'; 168 | if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) { 169 | if ($this->_checkFormat($value) === false) { 170 | $this->_error(self::FALSEFORMAT); 171 | } else { 172 | $this->_error(self::INVALID); 173 | } 174 | return false; 175 | } 176 | } else { 177 | if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $valueString)) { 178 | $this->_error(self::NOT_YYYY_MM_DD); 179 | return false; 180 | } 181 | 182 | list($year, $month, $day) = sscanf($valueString, '%d-%d-%d'); 183 | 184 | if (!checkdate($month, $day, $year)) { 185 | $this->_error(self::INVALID); 186 | return false; 187 | } 188 | } 189 | 190 | return true; 191 | } 192 | 193 | /** 194 | * Check if the given date fits the given format 195 | * 196 | * @param string $value Date to check 197 | * @return boolean False when date does not fit the format 198 | */ 199 | private function _checkFormat($value) 200 | { 201 | try { 202 | require_once 'Zend/Locale/Format.php'; 203 | $parsed = Zend_Locale_Format::getDate($value, array( 204 | 'date_format' => $this->_format, 'format_type' => 'iso', 205 | 'fix_date' => false)); 206 | if (isset($parsed['year']) and ((strpos(strtoupper($this->_format), 'YY') !== false) and 207 | (strpos(strtoupper($this->_format), 'YYYY') === false))) { 208 | $parsed['year'] = Zend_Date::_century($parsed['year']); 209 | } 210 | } catch (Exception $e) { 211 | // Date can not be parsed 212 | return false; 213 | } 214 | 215 | if (((strpos($this->_format, 'Y') !== false) or (strpos($this->_format, 'y') !== false)) and 216 | (!isset($parsed['year']))) { 217 | // Year expected but not found 218 | return false; 219 | } 220 | 221 | if ((strpos($this->_format, 'M') !== false) and (!isset($parsed['month']))) { 222 | // Month expected but not found 223 | return false; 224 | } 225 | 226 | if ((strpos($this->_format, 'd') !== false) and (!isset($parsed['day']))) { 227 | // Day expected but not found 228 | return false; 229 | } 230 | 231 | if (((strpos($this->_format, 'H') !== false) or (strpos($this->_format, 'h') !== false)) and 232 | (!isset($parsed['hour']))) { 233 | // Hour expected but not found 234 | return false; 235 | } 236 | 237 | if ((strpos($this->_format, 'm') !== false) and (!isset($parsed['minute']))) { 238 | // Minute expected but not found 239 | return false; 240 | } 241 | 242 | if ((strpos($this->_format, 's') !== false) and (!isset($parsed['second']))) { 243 | // Second expected but not found 244 | return false; 245 | } 246 | 247 | // Date fits the format 248 | return true; 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Digits.php: -------------------------------------------------------------------------------- 1 | "'%value%' contains not only digit characters", 62 | self::STRING_EMPTY => "'%value%' is an empty string" 63 | ); 64 | 65 | /** 66 | * Defined by Zend_Validate_Interface 67 | * 68 | * Returns true if and only if $value only contains digit characters 69 | * 70 | * @param string $value 71 | * @return boolean 72 | */ 73 | public function isValid($value) 74 | { 75 | $valueString = (string) $value; 76 | 77 | $this->_setValue($valueString); 78 | 79 | if ('' === $valueString) { 80 | $this->_error(self::STRING_EMPTY); 81 | return false; 82 | } 83 | 84 | if (null === self::$_filter) { 85 | /** 86 | * @see Zend_Filter_Digits 87 | */ 88 | require_once 'Zend/Filter/Digits.php'; 89 | self::$_filter = new Zend_Filter_Digits(); 90 | } 91 | 92 | if ($valueString !== self::$_filter->filter($valueString)) { 93 | $this->_error(self::NOT_DIGITS); 94 | return false; 95 | } 96 | 97 | return true; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/EmailAddress.php: -------------------------------------------------------------------------------- 1 | "'%value%' is not a valid email address in the basic format local-part@hostname", 57 | self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", 58 | self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", 59 | self::DOT_ATOM => "'%localPart%' not matched against dot-atom format", 60 | self::QUOTED_STRING => "'%localPart%' not matched against quoted-string format", 61 | self::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'" 62 | ); 63 | 64 | /** 65 | * @var array 66 | */ 67 | protected $_messageVariables = array( 68 | 'hostname' => '_hostname', 69 | 'localPart' => '_localPart' 70 | ); 71 | 72 | /** 73 | * Local object for validating the hostname part of an email address 74 | * 75 | * @var Zend_Validate_Hostname 76 | */ 77 | public $hostnameValidator; 78 | 79 | /** 80 | * Whether we check for a valid MX record via DNS 81 | * 82 | * @var boolean 83 | */ 84 | protected $_validateMx = false; 85 | 86 | /** 87 | * @var string 88 | */ 89 | protected $_hostname; 90 | 91 | /** 92 | * @var string 93 | */ 94 | protected $_localPart; 95 | 96 | /** 97 | * Instantiates hostname validator for local use 98 | * 99 | * You can pass a bitfield to determine what types of hostnames are allowed. 100 | * These bitfields are defined by the ALLOW_* constants in Zend_Validate_Hostname 101 | * The default is to allow DNS hostnames only 102 | * 103 | * @param integer $allow OPTIONAL 104 | * @param bool $validateMx OPTIONAL 105 | * @param Zend_Validate_Hostname $hostnameValidator OPTIONAL 106 | * @return void 107 | */ 108 | public function __construct($allow = Zend_Validate_Hostname::ALLOW_DNS, $validateMx = false, Zend_Validate_Hostname $hostnameValidator = null) 109 | { 110 | $this->setValidateMx($validateMx); 111 | $this->setHostnameValidator($hostnameValidator, $allow); 112 | } 113 | 114 | /** 115 | * @param Zend_Validate_Hostname $hostnameValidator OPTIONAL 116 | * @param int $allow OPTIONAL 117 | * @return void 118 | */ 119 | public function setHostnameValidator(Zend_Validate_Hostname $hostnameValidator = null, $allow = Zend_Validate_Hostname::ALLOW_DNS) 120 | { 121 | if ($hostnameValidator === null) { 122 | $hostnameValidator = new Zend_Validate_Hostname($allow); 123 | } 124 | $this->hostnameValidator = $hostnameValidator; 125 | } 126 | 127 | /** 128 | * Whether MX checking via dns_get_mx is supported or not 129 | * 130 | * This currently only works on UNIX systems 131 | * 132 | * @return boolean 133 | */ 134 | public function validateMxSupported() 135 | { 136 | return function_exists('dns_get_mx'); 137 | } 138 | 139 | /** 140 | * Set whether we check for a valid MX record via DNS 141 | * 142 | * This only applies when DNS hostnames are validated 143 | * 144 | * @param boolean $allowed Set allowed to true to validate for MX records, and false to not validate them 145 | */ 146 | public function setValidateMx($allowed) 147 | { 148 | $this->_validateMx = (bool) $allowed; 149 | } 150 | 151 | /** 152 | * Defined by Zend_Validate_Interface 153 | * 154 | * Returns true if and only if $value is a valid email address 155 | * according to RFC2822 156 | * 157 | * @link http://www.ietf.org/rfc/rfc2822.txt RFC2822 158 | * @link http://www.columbia.edu/kermit/ascii.html US-ASCII characters 159 | * @param string $value 160 | * @return boolean 161 | */ 162 | public function isValid($value) 163 | { 164 | $valueString = (string) $value; 165 | 166 | $this->_setValue($valueString); 167 | 168 | // Split email address up 169 | if (!preg_match('/^(.+)@([^@]+)$/', $valueString, $matches)) { 170 | $this->_error(self::INVALID); 171 | return false; 172 | } 173 | 174 | $this->_localPart = $matches[1]; 175 | $this->_hostname = $matches[2]; 176 | 177 | // Match hostname part 178 | $hostnameResult = $this->hostnameValidator->setTranslator($this->getTranslator()) 179 | ->isValid($this->_hostname); 180 | if (!$hostnameResult) { 181 | $this->_error(self::INVALID_HOSTNAME); 182 | 183 | // Get messages and errors from hostnameValidator 184 | foreach ($this->hostnameValidator->getMessages() as $message) { 185 | $this->_messages[] = $message; 186 | } 187 | foreach ($this->hostnameValidator->getErrors() as $error) { 188 | $this->_errors[] = $error; 189 | } 190 | } 191 | 192 | // MX check on hostname via dns_get_record() 193 | if ($this->_validateMx) { 194 | if ($this->validateMxSupported()) { 195 | $result = dns_get_mx($this->_hostname, $mxHosts); 196 | if (count($mxHosts) < 1) { 197 | $hostnameResult = false; 198 | $this->_error(self::INVALID_MX_RECORD); 199 | } 200 | } else { 201 | /** 202 | * MX checks are not supported by this system 203 | * @see Zend_Validate_Exception 204 | */ 205 | require_once 'Zend/Validate/Exception.php'; 206 | throw new Zend_Validate_Exception('Internal error: MX checking not available on this system'); 207 | } 208 | } 209 | 210 | // First try to match the local part on the common dot-atom format 211 | $localResult = false; 212 | 213 | // Dot-atom characters are: 1*atext *("." 1*atext) 214 | // atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*", 215 | // "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~" 216 | $atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d'; 217 | if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->_localPart)) { 218 | $localResult = true; 219 | } else { 220 | // Try quoted string format 221 | 222 | // Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE 223 | // qtext: Non white space controls, and the rest of the US-ASCII characters not 224 | // including "\" or the quote character 225 | $noWsCtl = '\x01-\x08\x0b\x0c\x0e-\x1f\x7f'; 226 | $qtext = $noWsCtl . '\x21\x23-\x5b\x5d-\x7e'; 227 | $ws = '\x20\x09'; 228 | if (preg_match('/^\x22([' . $ws . $qtext . '])*[$ws]?\x22$/', $this->_localPart)) { 229 | $localResult = true; 230 | } else { 231 | $this->_error(self::DOT_ATOM); 232 | $this->_error(self::QUOTED_STRING); 233 | $this->_error(self::INVALID_LOCAL_PART); 234 | } 235 | } 236 | 237 | // If both parts valid, return true 238 | if ($localResult && $hostnameResult) { 239 | return true; 240 | } else { 241 | return false; 242 | } 243 | } 244 | 245 | } 246 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Exception.php: -------------------------------------------------------------------------------- 1 | "Too much files, only '%value%' are allowed", 49 | self::TOO_LESS => "Too less files, minimum '%value%' must be given" 50 | ); 51 | 52 | /** 53 | * @var array Error message template variables 54 | */ 55 | protected $_messageVariables = array( 56 | 'min' => '_min', 57 | 'max' => '_max' 58 | ); 59 | 60 | /** 61 | * Minimum file count 62 | * 63 | * If null, there is no minimum file count 64 | * 65 | * @var integer 66 | */ 67 | protected $_min; 68 | 69 | /** 70 | * Maximum file count 71 | * 72 | * If null, there is no maximum file count 73 | * 74 | * @var integer|null 75 | */ 76 | protected $_max; 77 | 78 | /** 79 | * Internal file array 80 | * @var array 81 | */ 82 | protected $_files; 83 | 84 | /** 85 | * Sets validator options 86 | * 87 | * Min limits the file count, when used with max=null it is the maximum file count 88 | * It also accepts an array with the keys 'min' and 'max' 89 | * 90 | * @param integer|array $min Minimum file count 91 | * @param integer $max Maximum file count 92 | * @return void 93 | */ 94 | public function __construct($min, $max = null) 95 | { 96 | $this->_files = array(); 97 | if (is_array($min) === true) { 98 | if (isset($min['max']) === true) { 99 | $max = $min['max']; 100 | } 101 | 102 | if (isset($min['min']) === true) { 103 | $min = $min['min']; 104 | } 105 | 106 | if (isset($min[0]) === true) { 107 | if (count($min) === 2) { 108 | $max = $min[1]; 109 | $min = $min[0]; 110 | } else { 111 | $max = $min[0]; 112 | $min = null; 113 | } 114 | } 115 | } 116 | 117 | if (empty($max) === true) { 118 | $max = $min; 119 | $min = null; 120 | } 121 | 122 | $this->setMin($min); 123 | $this->setMax($max); 124 | } 125 | 126 | /** 127 | * Returns the minimum file count 128 | * 129 | * @return integer 130 | */ 131 | public function getMin() 132 | { 133 | $min = $this->_min; 134 | 135 | return $min; 136 | } 137 | 138 | /** 139 | * Sets the minimum file count 140 | * 141 | * @param integer $min The minimum file count 142 | * @return Zend_Validate_File_Size Provides a fluent interface 143 | * @throws Zend_Validate_Exception When min is greater than max 144 | */ 145 | public function setMin($min) 146 | { 147 | if ($min === null) { 148 | $this->_min = null; 149 | } else if (($this->_max !== null) and ($min > $this->_max)) { 150 | require_once 'Zend/Validate/Exception.php'; 151 | throw new Zend_Validate_Exception('The minimum must be less than or equal to the maximum file count, but ' 152 | . " {$min} > {$this->_max}"); 153 | } else { 154 | $this->_min = max(0, (integer) $min); 155 | } 156 | 157 | return $this; 158 | } 159 | 160 | /** 161 | * Returns the maximum file count 162 | * 163 | * @return integer|null 164 | */ 165 | public function getMax() 166 | { 167 | return $this->_max; 168 | } 169 | 170 | /** 171 | * Sets the maximum file count 172 | * 173 | * @param integer|null $max The maximum file count 174 | * @throws Zend_Validate_Exception When max is smaller than min 175 | * @return Zend_Validate_StringLength Provides a fluent interface 176 | */ 177 | public function setMax($max) 178 | { 179 | if ($max === null) { 180 | $this->_max = null; 181 | } else if (($this->_min !== null) and ($max < $this->_min)) { 182 | require_once 'Zend/Validate/Exception.php'; 183 | throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but " 184 | . "{$max} < {$this->_min}"); 185 | } else { 186 | $this->_max = (integer) $max; 187 | } 188 | 189 | return $this; 190 | } 191 | 192 | /** 193 | * Defined by Zend_Validate_Interface 194 | * 195 | * Returns true if and only if the file count of all checked files is at least min and 196 | * not bigger than max (when max is not null). Attention: When checking with set min you 197 | * must give all files with the first call, otherwise you will get an false. 198 | * 199 | * @param string|array $value Filenames to check for count 200 | * @param array $file File data from Zend_File_Transfer 201 | * @return boolean 202 | */ 203 | public function isValid($value, $file = null) 204 | { 205 | if (is_string($value)) { 206 | $value = array($value); 207 | } 208 | 209 | foreach ($value as $file) { 210 | if (!isset($this->_files[$file])) { 211 | $this->_files[$file] = $file; 212 | } 213 | } 214 | 215 | if (($this->_max !== null) && (count($this->_files) > $this->_max)) { 216 | $this->_value = $this->_max; 217 | $this->_error(self::TOO_MUCH); 218 | return false; 219 | } 220 | 221 | if (($this->_min !== null) && (count($this->_files) < $this->_min)) { 222 | $this->_value = $this->_min; 223 | $this->_error(self::TOO_LESS); 224 | return false; 225 | } 226 | 227 | return true; 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/File/Exists.php: -------------------------------------------------------------------------------- 1 | "The file '%value%' does not exist" 47 | ); 48 | 49 | /** 50 | * Internal list of directories 51 | * @var string 52 | */ 53 | protected $_directory = ''; 54 | 55 | /** 56 | * @var array Error message template variables 57 | */ 58 | protected $_messageVariables = array( 59 | 'directory' => '_directory' 60 | ); 61 | 62 | /** 63 | * Sets validator options 64 | * 65 | * @param string|array $directory 66 | * @return void 67 | */ 68 | public function __construct($directory = array()) 69 | { 70 | $this->setDirectory($directory); 71 | } 72 | 73 | /** 74 | * Returns the set file directories which are checked 75 | * 76 | * @param boolean $asArray Returns the values as array, when false an concated string is returned 77 | * @return string 78 | */ 79 | public function getDirectory($asArray = false) 80 | { 81 | $asArray = (bool) $asArray; 82 | $directory = (string) $this->_directory; 83 | if ($asArray) { 84 | $directory = explode(',', $directory); 85 | } 86 | 87 | return $directory; 88 | } 89 | 90 | /** 91 | * Sets the file directory which will be checked 92 | * 93 | * @param string|array $directory The directories to validate 94 | * @return Zend_Validate_File_Extension Provides a fluent interface 95 | */ 96 | public function setDirectory($directory) 97 | { 98 | $this->_directory = null; 99 | $this->addDirectory($directory); 100 | return $this; 101 | } 102 | 103 | /** 104 | * Adds the file directory which will be checked 105 | * 106 | * @param string|array $directory The directory to add for validation 107 | * @return Zend_Validate_File_Extension Provides a fluent interface 108 | */ 109 | public function addDirectory($directory) 110 | { 111 | $directories = $this->getDirectory(true); 112 | if (is_string($directory)) { 113 | $directory = explode(',', $directory); 114 | } 115 | 116 | foreach ($directory as $content) { 117 | if (empty($content) || !is_string($content)) { 118 | continue; 119 | } 120 | 121 | $directories[] = trim($content); 122 | } 123 | $directories = array_unique($directories); 124 | 125 | // Sanity check to ensure no empty values 126 | foreach ($directories as $key => $dir) { 127 | if (empty($dir)) { 128 | unset($directories[$key]); 129 | } 130 | } 131 | 132 | $this->_directory = implode(',', $directories); 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * Defined by Zend_Validate_Interface 139 | * 140 | * Returns true if and only if the file already exists in the set directories 141 | * 142 | * @param string $value Real file to check for existance 143 | * @param array $file File data from Zend_File_Transfer 144 | * @return boolean 145 | */ 146 | public function isValid($value, $file = null) 147 | { 148 | $directories = $this->getDirectory(true); 149 | if (($file !== null) and (!empty($file['destination']))) { 150 | $directories[] = $file['destination']; 151 | } else if (!isset($file['name'])) { 152 | $file['name'] = $value; 153 | } 154 | 155 | $check = false; 156 | foreach ($directories as $directory) { 157 | if (empty($directory)) { 158 | continue; 159 | } 160 | 161 | $check = true; 162 | if (!file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { 163 | $this->_throw($file, self::DOES_NOT_EXIST); 164 | return false; 165 | } 166 | } 167 | 168 | if (!$check) { 169 | $this->_throw($file, self::DOES_NOT_EXIST); 170 | return false; 171 | } 172 | 173 | return true; 174 | } 175 | 176 | /** 177 | * Throws an error of the given type 178 | * 179 | * @param string $file 180 | * @param string $errorType 181 | * @return false 182 | */ 183 | protected function _throw($file, $errorType) 184 | { 185 | if ($file !== null) { 186 | $this->_value = $file['name']; 187 | } 188 | 189 | $this->_error($errorType); 190 | return false; 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/File/Extension.php: -------------------------------------------------------------------------------- 1 | "The file '%value%' has a false extension", 48 | self::NOT_FOUND => "The file '%value%' was not found" 49 | ); 50 | 51 | /** 52 | * Internal list of extensions 53 | * @var string 54 | */ 55 | protected $_extension = ''; 56 | 57 | /** 58 | * Validate case sensitive 59 | * 60 | * @var boolean 61 | */ 62 | protected $_case = false; 63 | 64 | /** 65 | * @var array Error message template variables 66 | */ 67 | protected $_messageVariables = array( 68 | 'extension' => '_extension' 69 | ); 70 | 71 | /** 72 | * Sets validator options 73 | * 74 | * @param string|array $extension 75 | * @param boolean $case If true validation is done case sensitive 76 | * @return void 77 | */ 78 | public function __construct($extension, $case = false) 79 | { 80 | $this->_case = (boolean) $case; 81 | $this->setExtension($extension); 82 | } 83 | 84 | /** 85 | * Returns the set file extension 86 | * 87 | * @param boolean $asArray Returns the values as array, when false an concated string is returned 88 | * @return string 89 | */ 90 | public function getExtension($asArray = false) 91 | { 92 | $asArray = (bool) $asArray; 93 | $extension = (string) $this->_extension; 94 | if ($asArray) { 95 | $extension = explode(',', $extension); 96 | } 97 | 98 | return $extension; 99 | } 100 | 101 | /** 102 | * Sets the file extensions 103 | * 104 | * @param string|array $extension The extensions to validate 105 | * @return Zend_Validate_File_Extension Provides a fluent interface 106 | */ 107 | public function setExtension($extension) 108 | { 109 | $this->_extension = null; 110 | $this->addExtension($extension); 111 | return $this; 112 | } 113 | 114 | /** 115 | * Adds the file extensions 116 | * 117 | * @param string|array $extension The extensions to add for validation 118 | * @return Zend_Validate_File_Extension Provides a fluent interface 119 | */ 120 | public function addExtension($extension) 121 | { 122 | $extensions = $this->getExtension(true); 123 | if (is_string($extension)) { 124 | $extension = explode(',', $extension); 125 | } 126 | 127 | foreach ($extension as $content) { 128 | if (empty($content) || !is_string($content)) { 129 | continue; 130 | } 131 | 132 | $extensions[] = trim($content); 133 | } 134 | $extensions = array_unique($extensions); 135 | 136 | // Sanity check to ensure no empty values 137 | foreach ($extensions as $key => $ext) { 138 | if (empty($ext)) { 139 | unset($extensions[$key]); 140 | } 141 | } 142 | 143 | $this->_extension = implode(',', $extensions); 144 | 145 | return $this; 146 | } 147 | 148 | /** 149 | * Defined by Zend_Validate_Interface 150 | * 151 | * Returns true if and only if the fileextension of $value is included in the 152 | * set extension list 153 | * 154 | * @param string $value Real file to check for extension 155 | * @param array $file File data from Zend_File_Transfer 156 | * @return boolean 157 | */ 158 | public function isValid($value, $file = null) 159 | { 160 | // Is file readable ? 161 | if (!@is_readable($value)) { 162 | $this->_throw($file, self::NOT_FOUND); 163 | return false; 164 | } 165 | 166 | if ($file !== null) { 167 | $info['extension'] = substr($file['name'], strpos($file['name'], '.') + 1); 168 | } else { 169 | $info = @pathinfo($value); 170 | } 171 | 172 | $extensions = $this->getExtension(true); 173 | 174 | if ($this->_case and (in_array($info['extension'], $extensions))) { 175 | return true; 176 | } else if (!$this->_case) { 177 | foreach ($extensions as $extension) { 178 | if (strtolower($extension) == strtolower($info['extension'])) { 179 | return true; 180 | } 181 | } 182 | } 183 | 184 | $this->_throw($file, self::FALSE_EXTENSION); 185 | return false; 186 | } 187 | 188 | /** 189 | * Throws an error of the given type 190 | * 191 | * @param string $file 192 | * @param string $errorType 193 | * @return false 194 | */ 195 | protected function _throw($file, $errorType) 196 | { 197 | if ($file !== null) { 198 | $this->_value = $file['name']; 199 | } 200 | 201 | $this->_error($errorType); 202 | return false; 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/File/FilesSize.php: -------------------------------------------------------------------------------- 1 | "The files in sum exceed the maximum allowed size", 49 | self::TOO_SMALL => "All files are in sum smaller than required", 50 | self::NOT_READABLE => "One or more files can not be read" 51 | ); 52 | 53 | /** 54 | * @var array Error message template variables 55 | */ 56 | protected $_messageVariables = array( 57 | 'min' => '_min', 58 | 'max' => '_max' 59 | ); 60 | 61 | /** 62 | * Minimum filesize 63 | * 64 | * @var integer 65 | */ 66 | protected $_min; 67 | 68 | /** 69 | * Maximum filesize 70 | * 71 | * @var integer|null 72 | */ 73 | protected $_max; 74 | 75 | /** 76 | * Internal file array 77 | * 78 | * @var array 79 | */ 80 | protected $_files; 81 | 82 | /** 83 | * Internal file size counter 84 | * 85 | * @var integer 86 | */ 87 | protected $_size; 88 | 89 | /** 90 | * Sets validator options 91 | * 92 | * Min limits the used diskspace for all files, when used with max=null it is the maximum filesize 93 | * It also accepts an array with the keys 'min' and 'max' 94 | * 95 | * @param integer|array $min Minimum diskspace for all files 96 | * @param integer $max Maximum diskspace for all files 97 | * @return void 98 | */ 99 | public function __construct($min, $max = null) 100 | { 101 | $this->_files = array(); 102 | $this->_size = 0; 103 | parent::__construct($min, $max); 104 | } 105 | 106 | /** 107 | * Defined by Zend_Validate_Interface 108 | * 109 | * Returns true if and only if the disk usage of all files is at least min and 110 | * not bigger than max (when max is not null). 111 | * 112 | * @param string|array $value Real file to check for size 113 | * @param array $file File data from Zend_File_Transfer 114 | * @return boolean 115 | */ 116 | public function isValid($value, $file = null) 117 | { 118 | if (is_string($value)) { 119 | $value = array($value); 120 | } 121 | 122 | foreach ($value as $files) { 123 | // Is file readable ? 124 | if (!@is_readable($files)) { 125 | $this->_throw($file, self::NOT_READABLE); 126 | return false; 127 | } 128 | 129 | if (!isset($this->_files[$files])) { 130 | $this->_files[$files] = $files; 131 | } else { 132 | // file already counted... do not count twice 133 | continue; 134 | } 135 | 136 | // limited to 2GB files 137 | $size = @filesize($files); 138 | $this->_size += $size; 139 | $this->_setValue($this->_size); 140 | if (($this->_max !== null) && ($this->_max < $this->_size)) { 141 | $this->_throw($file, self::TOO_BIG); 142 | } 143 | } 144 | 145 | // Check that aggregate files are >= minimum size 146 | if (($this->_min !== null) && ($this->_size < $this->_min)) { 147 | $this->_throw($file, self::TOO_SMALL); 148 | } 149 | 150 | if (count($this->_messages) > 0) { 151 | return false; 152 | } else { 153 | return true; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/File/MimeType.php: -------------------------------------------------------------------------------- 1 | "The file '%value%' has a false mimetype", 46 | self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", 47 | self::NOT_READABLE => "The file '%value%' can not be read" 48 | ); 49 | 50 | /** 51 | * @var array 52 | */ 53 | protected $_messageVariables = array( 54 | 'mimetype' => '_mimetype' 55 | ); 56 | 57 | /** 58 | * Mimetypes 59 | * 60 | * If null, there is no mimetype 61 | * 62 | * @var string|null 63 | */ 64 | protected $_mimetype; 65 | 66 | /** 67 | * Sets validator options 68 | * 69 | * Mimetype to accept 70 | * 71 | * @param string|array $mimetype MimeType 72 | * @return void 73 | */ 74 | public function __construct($mimetype) 75 | { 76 | $this->setMimeType($mimetype); 77 | } 78 | 79 | /** 80 | * Returns the set mimetypes 81 | * 82 | * @param boolean $asArray Returns the values as array, when false an concated string is returned 83 | * @return integer 84 | */ 85 | public function getMimeType($asArray = false) 86 | { 87 | $asArray = (bool) $asArray; 88 | $mimetype = (string) $this->_mimetype; 89 | if ($asArray) { 90 | $mimetype = explode(',', $mimetype); 91 | } 92 | 93 | return $mimetype; 94 | } 95 | 96 | /** 97 | * Sets the mimetypes 98 | * 99 | * @param string|array $mimetype The mimetypes to validate 100 | * @return Zend_Validate_File_Extension Provides a fluent interface 101 | */ 102 | public function setMimeType($mimetype) 103 | { 104 | $this->_mimetype = null; 105 | $this->addMimeType($mimetype); 106 | return $this; 107 | } 108 | 109 | /** 110 | * Adds the mimetypes 111 | * 112 | * @param string|array $mimetype The mimetypes to add for validation 113 | * @return Zend_Validate_File_Extension Provides a fluent interface 114 | */ 115 | public function addMimeType($mimetype) 116 | { 117 | $mimetypes = $this->getMimeType(true); 118 | if (is_string($mimetype)) { 119 | $mimetype = explode(',', $mimetype); 120 | } 121 | 122 | foreach ($mimetype as $content) { 123 | if (empty($content) || !is_string($content)) { 124 | continue; 125 | } 126 | $mimetypes[] = trim($content); 127 | } 128 | $mimetypes = array_unique($mimetypes); 129 | 130 | // Sanity check to ensure no empty values 131 | foreach ($mimetypes as $key => $mt) { 132 | if (empty($mt)) { 133 | unset($mimetypes[$key]); 134 | } 135 | } 136 | 137 | $this->_mimetype = implode(',', $mimetypes); 138 | 139 | return $this; 140 | } 141 | 142 | /** 143 | * Defined by Zend_Validate_Interface 144 | * 145 | * Returns true if the mimetype of the file matches the given ones. Also parts 146 | * of mimetypes can be checked. If you give for example "image" all image 147 | * mime types will be accepted like "image/gif", "image/jpeg" and so on. 148 | * 149 | * @param string $value Real file to check for mimetype 150 | * @param array $file File data from Zend_File_Transfer 151 | * @return boolean 152 | */ 153 | public function isValid($value, $file = null) 154 | { 155 | // Is file readable ? 156 | if (!@is_readable($value)) { 157 | $this->_throw($file, self::NOT_READABLE); 158 | return false; 159 | } 160 | 161 | if ($file !== null) { 162 | $info['type'] = $file['type']; 163 | } else { 164 | $this->_throw($file, self::NOT_DETECTED); 165 | return false; 166 | } 167 | 168 | $mimetype = $this->getMimeType(true); 169 | if (in_array($info['type'], $mimetype)) { 170 | return true; 171 | } 172 | 173 | foreach($mimetype as $mime) { 174 | $types = explode('/', $info['type']); 175 | if (in_array($mime, $types)) { 176 | return true; 177 | } 178 | } 179 | 180 | $this->_throw($file, self::FALSE_TYPE); 181 | return false; 182 | } 183 | 184 | /** 185 | * Throws an error of the given type 186 | * 187 | * @param string $file 188 | * @param string $errorType 189 | * @return false 190 | */ 191 | protected function _throw($file, $errorType) 192 | { 193 | if ($file !== null) { 194 | $this->_value = $file['name']; 195 | } 196 | 197 | $this->_error($errorType); 198 | return false; 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/File/NotExists.php: -------------------------------------------------------------------------------- 1 | "The file '%value%' does exist" 47 | ); 48 | 49 | /** 50 | * Defined by Zend_Validate_Interface 51 | * 52 | * Returns true if and only if the file does not exist in the set destinations 53 | * 54 | * @param string $value Real file to check for 55 | * @param array $file File data from Zend_File_Transfer 56 | * @return boolean 57 | */ 58 | public function isValid($value, $file = null) 59 | { 60 | $directories = $this->getDirectory(true); 61 | if (($file !== null) and (!empty($file['destination']))) { 62 | $directories[] = $file['destination']; 63 | } else if (!isset($file['name'])) { 64 | $file['name'] = $value; 65 | } 66 | 67 | foreach ($directories as $directory) { 68 | if (empty($directory)) { 69 | continue; 70 | } 71 | 72 | $check = true; 73 | if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { 74 | $this->_throw($file, self::DOES_EXIST); 75 | return false; 76 | } 77 | } 78 | 79 | if (!isset($check)) { 80 | $this->_throw($file, self::DOES_EXIST); 81 | return false; 82 | } 83 | 84 | return true; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/File/Upload.php: -------------------------------------------------------------------------------- 1 | "The file '%value%' exceeds the defined ini size", 57 | self::FORM_SIZE => "The file '%value%' exceeds the defined form size", 58 | self::PARTIAL => "The file '%value%' was only partially uploaded", 59 | self::NO_FILE => "The file '%value%' was not uploaded", 60 | self::NO_TMP_DIR => "No temporary directory was found for the file '%value%'", 61 | self::CANT_WRITE => "The file '%value%' can't be written", 62 | self::EXTENSION => "The extension returned an error while uploading the file '%value%'", 63 | self::ATTACK => "The file '%value%' was illegal uploaded, possible attack", 64 | self::FILE_NOT_FOUND => "The file '%value%' was not found", 65 | self::UNKNOWN => "Unknown error while uploading the file '%value%'" 66 | ); 67 | 68 | /** 69 | * Internal array of files 70 | * @var array 71 | */ 72 | protected $_files = array(); 73 | 74 | /** 75 | * Sets validator options 76 | * 77 | * The array $files must be given in syntax of Zend_File_Transfer to be checked 78 | * If no files are given the $_FILES array will be used automatically. 79 | * NOTE: This validator will only work with HTTP POST uploads! 80 | * 81 | * @param array $files Array of files in syntax of Zend_File_Transfer 82 | * @return void 83 | */ 84 | public function __construct($files = array()) 85 | { 86 | $this->setFiles($files); 87 | } 88 | 89 | /** 90 | * Returns the array of set files 91 | * 92 | * @param string $files (Optional) The file to return in detail 93 | * @return array 94 | * @throws Zend_Validate_Exception If file is not found 95 | */ 96 | public function getFiles($file = null) 97 | { 98 | if ($file !== null) { 99 | $return = array(); 100 | foreach ($this->_files as $name => $content) { 101 | if ($name === $file) { 102 | $return[$file] = $this->_files[$name]; 103 | } 104 | 105 | if ($content['name'] === $file) { 106 | $return[$name] = $this->_files[$name]; 107 | } 108 | } 109 | 110 | if (count($return) === 0) { 111 | require_once 'Zend/Validate/Exception.php'; 112 | throw new Zend_Validate_Exception("The file '$file' was not found"); 113 | } 114 | 115 | return $return; 116 | } 117 | 118 | return $this->_files; 119 | } 120 | 121 | /** 122 | * Sets the minimum filesize 123 | * 124 | * @param array $files The files to check in syntax of Zend_File_Transfer 125 | * @return Zend_Validate_File_Upload Provides a fluent interface 126 | */ 127 | public function setFiles($files = array()) 128 | { 129 | if (count($files) === 0) { 130 | $this->_files = $_FILES; 131 | } else { 132 | $this->_files = $files; 133 | } 134 | return $this; 135 | } 136 | 137 | /** 138 | * Defined by Zend_Validate_Interface 139 | * 140 | * Returns true if and only if the file was uploaded without errors 141 | * 142 | * @param string $value Single file to check for upload errors, when giving null the $_FILES array 143 | * from initialization will be used 144 | * @return boolean 145 | */ 146 | public function isValid($value) 147 | { 148 | if (array_key_exists($value, $this->_files)) { 149 | $files[$value] = $this->_files[$value]; 150 | } else { 151 | foreach ($this->_files as $file => $content) { 152 | if ($content['name'] === $value) { 153 | $files[$file] = $this->_files[$file]; 154 | } 155 | 156 | if ($content['tmp_name'] === $value) { 157 | $files[$file] = $this->_files[$file]; 158 | } 159 | } 160 | } 161 | 162 | if (empty($files)) { 163 | $this->_error(self::FILE_NOT_FOUND); 164 | return false; 165 | } 166 | 167 | foreach ($files as $file => $content) { 168 | $this->_value = $file; 169 | switch($content['error']) { 170 | case 0: 171 | if (!is_uploaded_file($content['tmp_name'])) { 172 | $this->_error(self::ATTACK); 173 | } 174 | break; 175 | 176 | case 1: 177 | $this->_error(self::INI_SIZE); 178 | break; 179 | 180 | case 2: 181 | $this->_error(self::FORM_SIZE); 182 | break; 183 | 184 | case 3: 185 | $this->_error(self::PARTIAL); 186 | break; 187 | 188 | case 4: 189 | $this->_error(self::NO_FILE); 190 | break; 191 | 192 | case 6: 193 | $this->_error(self::NO_TMP_DIR); 194 | break; 195 | 196 | case 7: 197 | $this->_error(self::CANT_WRITE); 198 | break; 199 | 200 | case 8: 201 | $this->_error(self::EXTENSION); 202 | break; 203 | 204 | default: 205 | $this->_error(self::UNKNOWN); 206 | break; 207 | } 208 | } 209 | 210 | if (count($this->_messages) > 0) { 211 | return false; 212 | } else { 213 | return true; 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Float.php: -------------------------------------------------------------------------------- 1 | "'%value%' does not appear to be a float" 46 | ); 47 | 48 | /** 49 | * Defined by Zend_Validate_Interface 50 | * 51 | * Returns true if and only if $value is a floating-point value 52 | * 53 | * @param string $value 54 | * @return boolean 55 | */ 56 | public function isValid($value) 57 | { 58 | $valueString = (string) $value; 59 | 60 | $this->_setValue($valueString); 61 | 62 | $locale = localeconv(); 63 | 64 | $valueFiltered = str_replace($locale['thousands_sep'], '', $valueString); 65 | $valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered); 66 | 67 | if (strval(floatval($valueFiltered)) != $valueFiltered) { 68 | $this->_error(); 69 | return false; 70 | } 71 | 72 | return true; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/GreaterThan.php: -------------------------------------------------------------------------------- 1 | "'%value%' is not greater than '%min%'" 46 | ); 47 | 48 | /** 49 | * @var array 50 | */ 51 | protected $_messageVariables = array( 52 | 'min' => '_min' 53 | ); 54 | 55 | /** 56 | * Minimum value 57 | * 58 | * @var mixed 59 | */ 60 | protected $_min; 61 | 62 | /** 63 | * Sets validator options 64 | * 65 | * @param mixed $min 66 | * @return void 67 | */ 68 | public function __construct($min) 69 | { 70 | $this->setMin($min); 71 | } 72 | 73 | /** 74 | * Returns the min option 75 | * 76 | * @return mixed 77 | */ 78 | public function getMin() 79 | { 80 | return $this->_min; 81 | } 82 | 83 | /** 84 | * Sets the min option 85 | * 86 | * @param mixed $min 87 | * @return Zend_Validate_GreaterThan Provides a fluent interface 88 | */ 89 | public function setMin($min) 90 | { 91 | $this->_min = $min; 92 | return $this; 93 | } 94 | 95 | /** 96 | * Defined by Zend_Validate_Interface 97 | * 98 | * Returns true if and only if $value is greater than min option 99 | * 100 | * @param mixed $value 101 | * @return boolean 102 | */ 103 | public function isValid($value) 104 | { 105 | $this->_setValue($value); 106 | 107 | if ($this->_min >= $value) { 108 | $this->_error(); 109 | return false; 110 | } 111 | return true; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Hex.php: -------------------------------------------------------------------------------- 1 | "'%value%' has not only hexadecimal digit characters" 50 | ); 51 | 52 | /** 53 | * Defined by Zend_Validate_Interface 54 | * 55 | * Returns true if and only if $value contains only hexadecimal digit characters 56 | * 57 | * @param string $value 58 | * @return boolean 59 | */ 60 | public function isValid($value) 61 | { 62 | $valueString = (string) $value; 63 | 64 | $this->_setValue($valueString); 65 | 66 | if (!ctype_xdigit($valueString)) { 67 | $this->_error(); 68 | return false; 69 | } 70 | 71 | return true; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Hostname/At.php: -------------------------------------------------------------------------------- 1 | 'Tokens do not match', 47 | self::MISSING_TOKEN => 'No token was provided to match against', 48 | ); 49 | 50 | /** 51 | * Original token against which to validate 52 | * @var string 53 | */ 54 | protected $_token; 55 | 56 | /** 57 | * Sets validator options 58 | * 59 | * @param string $token 60 | * @return void 61 | */ 62 | public function __construct($token = null) 63 | { 64 | if (null !== $token) { 65 | $this->setToken($token); 66 | } 67 | } 68 | 69 | /** 70 | * Set token against which to compare 71 | * 72 | * @param string $token 73 | * @return Zend_Validate_Identical 74 | */ 75 | public function setToken($token) 76 | { 77 | $this->_token = (string) $token; 78 | return $this; 79 | } 80 | 81 | /** 82 | * Retrieve token 83 | * 84 | * @return string 85 | */ 86 | public function getToken() 87 | { 88 | return $this->_token; 89 | } 90 | 91 | /** 92 | * Defined by Zend_Validate_Interface 93 | * 94 | * Returns true if and only if a token has been set and the provided value 95 | * matches that token. 96 | * 97 | * @param string $value 98 | * @return boolean 99 | */ 100 | public function isValid($value) 101 | { 102 | $this->_setValue($value); 103 | $token = $this->getToken(); 104 | 105 | if (empty($token)) { 106 | $this->_error(self::MISSING_TOKEN); 107 | return false; 108 | } 109 | 110 | if ($value !== $token) { 111 | $this->_error(self::NOT_SAME); 112 | return false; 113 | } 114 | 115 | return true; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/InArray.php: -------------------------------------------------------------------------------- 1 | "'%value%' was not found in the haystack" 46 | ); 47 | 48 | /** 49 | * Haystack of possible values 50 | * 51 | * @var array 52 | */ 53 | protected $_haystack; 54 | 55 | /** 56 | * Whether a strict in_array() invocation is used 57 | * 58 | * @var boolean 59 | */ 60 | protected $_strict; 61 | 62 | /** 63 | * Sets validator options 64 | * 65 | * @param array $haystack 66 | * @param boolean $strict 67 | * @return void 68 | */ 69 | public function __construct(array $haystack, $strict = false) 70 | { 71 | $this->setHaystack($haystack) 72 | ->setStrict($strict); 73 | } 74 | 75 | /** 76 | * Returns the haystack option 77 | * 78 | * @return mixed 79 | */ 80 | public function getHaystack() 81 | { 82 | return $this->_haystack; 83 | } 84 | 85 | /** 86 | * Sets the haystack option 87 | * 88 | * @param mixed $haystack 89 | * @return Zend_Validate_InArray Provides a fluent interface 90 | */ 91 | public function setHaystack(array $haystack) 92 | { 93 | $this->_haystack = $haystack; 94 | return $this; 95 | } 96 | 97 | /** 98 | * Returns the strict option 99 | * 100 | * @return boolean 101 | */ 102 | public function getStrict() 103 | { 104 | return $this->_strict; 105 | } 106 | 107 | /** 108 | * Sets the strict option 109 | * 110 | * @param boolean $strict 111 | * @return Zend_Validate_InArray Provides a fluent interface 112 | */ 113 | public function setStrict($strict) 114 | { 115 | $this->_strict = $strict; 116 | return $this; 117 | } 118 | 119 | /** 120 | * Defined by Zend_Validate_Interface 121 | * 122 | * Returns true if and only if $value is contained in the haystack option. If the strict 123 | * option is true, then the type of $value is also checked. 124 | * 125 | * @param mixed $value 126 | * @return boolean 127 | */ 128 | public function isValid($value) 129 | { 130 | $this->_setValue($value); 131 | if (!in_array($value, $this->_haystack, $this->_strict)) { 132 | $this->_error(); 133 | return false; 134 | } 135 | return true; 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Int.php: -------------------------------------------------------------------------------- 1 | "'%value%' does not appear to be an integer" 46 | ); 47 | 48 | /** 49 | * Defined by Zend_Validate_Interface 50 | * 51 | * Returns true if and only if $value is a valid integer 52 | * 53 | * @param string $value 54 | * @return boolean 55 | */ 56 | public function isValid($value) 57 | { 58 | $valueString = (string) $value; 59 | 60 | $this->_setValue($valueString); 61 | 62 | $locale = localeconv(); 63 | 64 | $valueFiltered = str_replace($locale['decimal_point'], '.', $valueString); 65 | $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered); 66 | 67 | if (strval(intval($valueFiltered)) != $valueFiltered) { 68 | $this->_error(); 69 | return false; 70 | } 71 | 72 | return true; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Interface.php: -------------------------------------------------------------------------------- 1 | "'%value%' does not appear to be a valid IP address" 46 | ); 47 | 48 | /** 49 | * Defined by Zend_Validate_Interface 50 | * 51 | * Returns true if and only if $value is a valid IP address 52 | * 53 | * @param mixed $value 54 | * @return boolean 55 | */ 56 | public function isValid($value) 57 | { 58 | $valueString = (string) $value; 59 | 60 | $this->_setValue($valueString); 61 | 62 | if (ip2long($valueString) === false) { 63 | $this->_error(); 64 | return false; 65 | } 66 | 67 | return true; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/LessThan.php: -------------------------------------------------------------------------------- 1 | "'%value%' is not less than '%max%'" 46 | ); 47 | 48 | /** 49 | * @var array 50 | */ 51 | protected $_messageVariables = array( 52 | 'max' => '_max' 53 | ); 54 | 55 | /** 56 | * Maximum value 57 | * 58 | * @var mixed 59 | */ 60 | protected $_max; 61 | 62 | /** 63 | * Sets validator options 64 | * 65 | * @param mixed $max 66 | * @return void 67 | */ 68 | public function __construct($max) 69 | { 70 | $this->setMax($max); 71 | } 72 | 73 | /** 74 | * Returns the max option 75 | * 76 | * @return mixed 77 | */ 78 | public function getMax() 79 | { 80 | return $this->_max; 81 | } 82 | 83 | /** 84 | * Sets the max option 85 | * 86 | * @param mixed $max 87 | * @return Zend_Validate_LessThan Provides a fluent interface 88 | */ 89 | public function setMax($max) 90 | { 91 | $this->_max = $max; 92 | return $this; 93 | } 94 | 95 | /** 96 | * Defined by Zend_Validate_Interface 97 | * 98 | * Returns true if and only if $value is less than max option 99 | * 100 | * @param mixed $value 101 | * @return boolean 102 | */ 103 | public function isValid($value) 104 | { 105 | $this->_setValue($value); 106 | if ($this->_max <= $value) { 107 | $this->_error(); 108 | return false; 109 | } 110 | return true; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/NotEmpty.php: -------------------------------------------------------------------------------- 1 | "Value is empty, but a non-empty value is required" 46 | ); 47 | 48 | /** 49 | * Defined by Zend_Validate_Interface 50 | * 51 | * Returns true if and only if $value is not an empty value. 52 | * 53 | * @param string $value 54 | * @return boolean 55 | */ 56 | public function isValid($value) 57 | { 58 | $this->_setValue((string) $value); 59 | 60 | if (is_string($value) 61 | && (('' === $value) 62 | || preg_match('/^\s+$/s', $value)) 63 | ) { 64 | $this->_error(); 65 | return false; 66 | } elseif (!is_string($value) && empty($value)) { 67 | $this->_error(); 68 | return false; 69 | } 70 | 71 | return true; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/Regex.php: -------------------------------------------------------------------------------- 1 | "'%value%' does not match against pattern '%pattern%'" 46 | ); 47 | 48 | /** 49 | * @var array 50 | */ 51 | protected $_messageVariables = array( 52 | 'pattern' => '_pattern' 53 | ); 54 | 55 | /** 56 | * Regular expression pattern 57 | * 58 | * @var string 59 | */ 60 | protected $_pattern; 61 | 62 | /** 63 | * Sets validator options 64 | * 65 | * @param string $pattern 66 | * @return void 67 | */ 68 | public function __construct($pattern) 69 | { 70 | $this->setPattern($pattern); 71 | } 72 | 73 | /** 74 | * Returns the pattern option 75 | * 76 | * @return string 77 | */ 78 | public function getPattern() 79 | { 80 | return $this->_pattern; 81 | } 82 | 83 | /** 84 | * Sets the pattern option 85 | * 86 | * @param string $pattern 87 | * @return Zend_Validate_Regex Provides a fluent interface 88 | */ 89 | public function setPattern($pattern) 90 | { 91 | $this->_pattern = (string) $pattern; 92 | return $this; 93 | } 94 | 95 | /** 96 | * Defined by Zend_Validate_Interface 97 | * 98 | * Returns true if and only if $value matches against the pattern option 99 | * 100 | * @param string $value 101 | * @throws Zend_Validate_Exception if there is a fatal error in pattern matching 102 | * @return boolean 103 | */ 104 | public function isValid($value) 105 | { 106 | $valueString = (string) $value; 107 | 108 | $this->_setValue($valueString); 109 | 110 | $status = @preg_match($this->_pattern, $valueString); 111 | if (false === $status) { 112 | /** 113 | * @see Zend_Validate_Exception 114 | */ 115 | require_once 'Zend/Validate/Exception.php'; 116 | throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$valueString'"); 117 | } 118 | if (!$status) { 119 | $this->_error(); 120 | return false; 121 | } 122 | return true; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/Zend/Validate/StringLength.php: -------------------------------------------------------------------------------- 1 | "'%value%' is less than %min% characters long", 47 | self::TOO_LONG => "'%value%' is greater than %max% characters long" 48 | ); 49 | 50 | /** 51 | * @var array 52 | */ 53 | protected $_messageVariables = array( 54 | 'min' => '_min', 55 | 'max' => '_max' 56 | ); 57 | 58 | /** 59 | * Minimum length 60 | * 61 | * @var integer 62 | */ 63 | protected $_min; 64 | 65 | /** 66 | * Maximum length 67 | * 68 | * If null, there is no maximum length 69 | * 70 | * @var integer|null 71 | */ 72 | protected $_max; 73 | 74 | /** 75 | * Sets validator options 76 | * 77 | * @param integer $min 78 | * @param integer $max 79 | * @return void 80 | */ 81 | public function __construct($min = 0, $max = null) 82 | { 83 | $this->setMin($min); 84 | $this->setMax($max); 85 | } 86 | 87 | /** 88 | * Returns the min option 89 | * 90 | * @return integer 91 | */ 92 | public function getMin() 93 | { 94 | return $this->_min; 95 | } 96 | 97 | /** 98 | * Sets the min option 99 | * 100 | * @param integer $min 101 | * @throws Zend_Validate_Exception 102 | * @return Zend_Validate_StringLength Provides a fluent interface 103 | */ 104 | public function setMin($min) 105 | { 106 | if (null !== $this->_max && $min > $this->_max) { 107 | /** 108 | * @see Zend_Validate_Exception 109 | */ 110 | require_once 'Zend/Validate/Exception.php'; 111 | throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum length, but $min >" 112 | . " $this->_max"); 113 | } 114 | $this->_min = max(0, (integer) $min); 115 | return $this; 116 | } 117 | 118 | /** 119 | * Returns the max option 120 | * 121 | * @return integer|null 122 | */ 123 | public function getMax() 124 | { 125 | return $this->_max; 126 | } 127 | 128 | /** 129 | * Sets the max option 130 | * 131 | * @param integer|null $max 132 | * @throws Zend_Validate_Exception 133 | * @return Zend_Validate_StringLength Provides a fluent interface 134 | */ 135 | public function setMax($max) 136 | { 137 | if (null === $max) { 138 | $this->_max = null; 139 | } else if ($max < $this->_min) { 140 | /** 141 | * @see Zend_Validate_Exception 142 | */ 143 | require_once 'Zend/Validate/Exception.php'; 144 | throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum length, but " 145 | . "$max < $this->_min"); 146 | } else { 147 | $this->_max = (integer) $max; 148 | } 149 | 150 | return $this; 151 | } 152 | 153 | /** 154 | * Defined by Zend_Validate_Interface 155 | * 156 | * Returns true if and only if the string length of $value is at least the min option and 157 | * no greater than the max option (when the max option is not null). 158 | * 159 | * @param string $value 160 | * @return boolean 161 | */ 162 | public function isValid($value) 163 | { 164 | $valueString = (string) $value; 165 | $this->_setValue($valueString); 166 | $length = iconv_strlen($valueString); 167 | if ($length < $this->_min) { 168 | $this->_error(self::TOO_SHORT); 169 | } 170 | if (null !== $this->_max && $this->_max < $length) { 171 | $this->_error(self::TOO_LONG); 172 | } 173 | if (count($this->_messages)) { 174 | return false; 175 | } else { 176 | return true; 177 | } 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/bootstrap.example.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/compat/mbstring.php: -------------------------------------------------------------------------------- 1 | document) 33 | $pq->find('*')->add($pq->document) 34 | ->trigger($type, $data); 35 | } 36 | } else { 37 | if (isset($data[0]) && $data[0] instanceof DOMEvent) { 38 | $event = $data[0]; 39 | $event->relatedTarget = $event->target; 40 | $event->target = $node; 41 | $data = array_slice($data, 1); 42 | } else { 43 | $event = new DOMEvent(array( 44 | 'type' => $type, 45 | 'target' => $node, 46 | 'timeStamp' => time(), 47 | )); 48 | } 49 | $i = 0; 50 | while($node) { 51 | // TODO whois 52 | phpQuery::debug("Triggering ".($i?"bubbled ":'')."event '{$type}' on " 53 | ."node \n");//.phpQueryObject::whois($node)."\n"); 54 | $event->currentTarget = $node; 55 | $eventNode = self::getNode($documentID, $node); 56 | if (isset($eventNode->eventHandlers)) { 57 | foreach($eventNode->eventHandlers as $eventType => $handlers) { 58 | $eventNamespace = null; 59 | if (strpos($type, '.') !== false) 60 | list($eventName, $eventNamespace) = explode('.', $eventType); 61 | else 62 | $eventName = $eventType; 63 | if ($name != $eventName) 64 | continue; 65 | if ($namespace && $eventNamespace && $namespace != $eventNamespace) 66 | continue; 67 | foreach($handlers as $handler) { 68 | phpQuery::debug("Calling event handler\n"); 69 | $event->data = $handler['data'] 70 | ? $handler['data'] 71 | : null; 72 | $params = array_merge(array($event), $data); 73 | $return = phpQuery::callbackRun($handler['callback'], $params); 74 | if ($return === false) { 75 | $event->bubbles = false; 76 | } 77 | } 78 | } 79 | } 80 | // to bubble or not to bubble... 81 | if (! $event->bubbles) 82 | break; 83 | $node = $node->parentNode; 84 | $i++; 85 | } 86 | } 87 | } 88 | /** 89 | * Binds a handler to one or more events (like click) for each matched element. 90 | * Can also bind custom events. 91 | * 92 | * @param DOMNode|phpQueryObject|string $document 93 | * @param unknown_type $type 94 | * @param unknown_type $data Optional 95 | * @param unknown_type $callback 96 | * 97 | * @TODO support '!' (exclusive) events 98 | * @TODO support more than event in $type (space-separated) 99 | * @TODO support binding to global events 100 | */ 101 | public static function add($document, $node, $type, $data, $callback = null) { 102 | phpQuery::debug("Binding '$type' event"); 103 | $documentID = phpQuery::getDocumentID($document); 104 | // if (is_null($callback) && is_callable($data)) { 105 | // $callback = $data; 106 | // $data = null; 107 | // } 108 | $eventNode = self::getNode($documentID, $node); 109 | if (! $eventNode) 110 | $eventNode = self::setNode($documentID, $node); 111 | if (!isset($eventNode->eventHandlers[$type])) 112 | $eventNode->eventHandlers[$type] = array(); 113 | $eventNode->eventHandlers[$type][] = array( 114 | 'callback' => $callback, 115 | 'data' => $data, 116 | ); 117 | } 118 | /** 119 | * Enter description here... 120 | * 121 | * @param DOMNode|phpQueryObject|string $document 122 | * @param unknown_type $type 123 | * @param unknown_type $callback 124 | * 125 | * @TODO namespace events 126 | * @TODO support more than event in $type (space-separated) 127 | */ 128 | public static function remove($document, $node, $type = null, $callback = null) { 129 | $documentID = phpQuery::getDocumentID($document); 130 | $eventNode = self::getNode($documentID, $node); 131 | if (is_object($eventNode) && isset($eventNode->eventHandlers[$type])) { 132 | if ($callback) { 133 | foreach($eventNode->eventHandlers[$type] as $k => $handler) 134 | if ($handler['callback'] == $callback) 135 | unset($eventNode->eventHandlers[$type][$k]); 136 | } else { 137 | unset($eventNode->eventHandlers[$type]); 138 | } 139 | } 140 | } 141 | protected static function getNode($documentID, $node) { 142 | foreach(phpQuery::$documents[$documentID]->eventsNodes as $eventNode) { 143 | if ($node->isSameNode($eventNode)) 144 | return $eventNode; 145 | } 146 | } 147 | protected static function setNode($documentID, $node) { 148 | phpQuery::$documents[$documentID]->eventsNodes[] = $node; 149 | return phpQuery::$documents[$documentID]->eventsNodes[ 150 | count(phpQuery::$documents[$documentID]->eventsNodes)-1 151 | ]; 152 | } 153 | protected static function issetGlobal($documentID, $type) { 154 | return isset(phpQuery::$documents[$documentID]) 155 | ? in_array($type, phpQuery::$documents[$documentID]->eventsGlobal) 156 | : false; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts/__config.example.php: -------------------------------------------------------------------------------- 1 | array('login@mail', 'password'), 9 | ); 10 | ?> -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts/example.php: -------------------------------------------------------------------------------- 1 | find($params[0]); 14 | ?> -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts/fix_webroot.php: -------------------------------------------------------------------------------- 1 | filter($filter) as $el) { 9 | $el = pq($el, $self->getDocumentID()); 10 | // imgs and scripts 11 | if ( $el->is('img') || $el->is('script') ) 12 | $el->attr('src', $params[0].$el->attr('src')); 13 | // css 14 | if ( $el->is('link') ) 15 | $el->attr('href', $params[0].$el->attr('href')); 16 | } -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts/google_login.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | phpQuery::ajaxAllowHost( 10 | 'code.google.com', 11 | 'google.com', 'www.google.com', 12 | 'mail.google.com', 13 | 'docs.google.com', 14 | 'reader.google.com' 15 | ); 16 | if (! function_exists('ndfasui8923')) { 17 | function ndfasui8923($browser, $scope) { 18 | extract($scope); 19 | $browser 20 | ->WebBrowser() 21 | ->find('#Email') 22 | ->val($config['google_login'][0])->end() 23 | ->find('#Passwd') 24 | ->val($config['google_login'][1]) 25 | ->parents('form') 26 | ->submit(); 27 | } 28 | $ndfasui8923 = new Callback('ndfasui8923', new CallbackParam, compact( 29 | 'config', 'self', 'return', 'params' 30 | )); 31 | } 32 | phpQuery::plugin('WebBrowser'); 33 | $self->document->xhr = phpQuery::$plugins->browserGet( 34 | 'https://www.google.com/accounts/Login', 35 | $ndfasui8923 36 | ); 37 | //$self->document->xhr = phpQuery::$plugins->browserGet('https://www.google.com/accounts/Login', create_function('$browser', " 38 | // \$browser 39 | // ->WebBrowser() 40 | // ->find('#Email') 41 | // ->val('{$config['google_login'][0]}')->end() 42 | // ->find('#Passwd') 43 | // ->val('".str_replace("'", "\\'", $config['google_login'][1])."') 44 | // ->parents('form') 45 | // ->submit();" 46 | //)); 47 | ?> -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts/print_source.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | /** @var phpQueryObject */ 8 | $self = $self; 9 | $return = htmlspecialchars($self); -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/Scripts/print_websafe.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | /** @var phpQueryObject */ 8 | $self = $self; 9 | $self 10 | ->find('script') 11 | ->add('meta[http-equiv=refresh]') 12 | ->add('meta[http-equiv=Refresh]') 13 | ->remove(); -------------------------------------------------------------------------------- /includes/gitweb/phpQuery/plugins/example.php: -------------------------------------------------------------------------------- 1 | plugin('example') 9 | * pq('ul')->plugin('example', 'example.php') 10 | * 11 | * Plugin classes are never intialized, just method calls are forwarded 12 | * in static way from phpQuery. 13 | * 14 | * Have fun writing plugins :) 15 | */ 16 | 17 | /** 18 | * phpQuery plugin class extending phpQuery object. 19 | * Methods from this class are callable on every phpQuery object. 20 | * 21 | * Class name prefix 'phpQueryObjectPlugin_' must be preserved. 22 | */ 23 | abstract class phpQueryObjectPlugin_example { 24 | /** 25 | * Limit binded methods. 26 | * 27 | * null means all public. 28 | * array means only specified ones. 29 | * 30 | * @var array|null 31 | */ 32 | public static $phpQueryMethods = null; 33 | /** 34 | * Enter description here... 35 | * 36 | * @param phpQueryObject $self 37 | */ 38 | public static function example($self, $arg1) { 39 | // this method can be called on any phpQuery object, like this: 40 | // pq('div')->example('$arg1 Value') 41 | 42 | // do something 43 | $self->append('Im just an example !'); 44 | // change stack of result object 45 | return $self->find('div'); 46 | } 47 | protected static function helperFunction() { 48 | // this method WONT be avaible as phpQuery method, 49 | // because it isn't publicly callable 50 | } 51 | } 52 | 53 | /** 54 | * phpQuery plugin class extending phpQuery static namespace. 55 | * Methods from this class are callable as follows: 56 | * phpQuery::$plugins->staticMethod() 57 | * 58 | * Class name prefix 'phpQueryPlugin_' must be preserved. 59 | */ 60 | abstract class phpQueryPlugin_example { 61 | /** 62 | * Limit binded methods. 63 | * 64 | * null means all public. 65 | * array means only specified ones. 66 | * 67 | * @var array|null 68 | */ 69 | public static $phpQueryMethods = null; 70 | public static function staticMethod() { 71 | // this method can be called within phpQuery class namespace, like this: 72 | // phpQuery::$plugins->staticMethod() 73 | } 74 | } 75 | ?> -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Usage instructions 2 | 3 | This plugin will activate updates for every plugin with a Git or Bitbucket repository in its header: 4 | 5 | /* 6 | Plugin Name: Plugin Example 7 | Plugin URI: https://github.com/brainstormmedia/git-plugin-updates 8 | Git URI: https://github.com/brainstormmedia/git-plugin-updates 9 | */ 10 | 11 | Either `Plugin URI` or `Git URI` can be set to your repository address. You don't need both. 12 | 13 | For private repos, you can use the URI format: 14 | 15 | https://username:password@bitbucket.org/brainstormmedia/git-plugin-updates 16 | 17 | ### Using as a library in your own plugins 18 | 19 | Ideally, Git Plugin Updates runs as a stand-alone plugin. However, if you would like to bundle it as a package in your own plugins to make sure updates over Git are enabled by default, you may do so by moving `git-plugin-updates` into your plugin directory, then activating updates with this code: 20 | 21 | add_action( 'plugins_loaded', 'myplugin_git_updater' ); 22 | 23 | function myplugin_git_updater() { 24 | if ( is_admin() && !class_exists( 'GPU_Controller' ) ) { 25 | require_once dirname( __FILE__ ) . '/git-plugin-updates/git-plugin-updates.php'; 26 | add_action( 'plugins_loaded', 'GPU_Controller::get_instance', 20 ); 27 | } 28 | } 29 | 30 | This method allows your plugin to update over Git, and if Git Plugin Updates is installed as a plugin later, only the stand-alone-plugin copy will load. 31 | 32 | # Changelog 33 | 34 | ### 2.0.1 35 | 36 | * New: Updater ran as plugin overrides and prevents load of additional updaters included as libraries. 37 | * New: Cleaner readme code examples. 38 | * New: Ignore `Plugin URI` header by default to avoid conflicts with wordpress.org. Override with `add_filter( 'gpu_use_plugin_uri_header' '__return_true' );` 39 | * Fix: Don't use variables for text-domains. See [Internationalization: You're probably doing it wrong](http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/). 40 | * Minor: Code cleanup. Simplify plugin load. Remove unused `log` and `__get` methods. Remove variable github and bitbucket hosts. Move constants into `GPU_Controller`. Reorder pre-load checks in order of liklihood. 41 | 42 | ### 2.0 43 | * Rewrite to support Github as well as Bitbucket 44 | * Updates enabled on plugins by including a Git repository address in the Plugin Header under `Plugin URI` or `Git URI`. 45 | * Enable private repositories with `URI` format `https://username:password@repo_address`. 46 | * Get remote version number from plugin header. 47 | 48 | ### 1.4 49 | * Minor fixes from [@sc0ttkclark](https://github.com/sc0ttkclark)'s use in Pods Framework 50 | * Added readme file into config 51 | 52 | ### 1.3 53 | * Fixed all php notices 54 | * Fixed minor bugs 55 | * Added an example plugin that's used as a test 56 | * Minor documentation/readme adjustments 57 | 58 | ### 1.2 59 | * Added phpDoc and minor syntax/readability adjusments, props [@franz-josef-kaiser](https://github.com/franz-josef-kaiser), [@GaryJones](https://github.com/GaryJones) 60 | * Added a die to prevent direct access, props [@franz-josef-kaiser](https://github.com/franz-josef-kaiser) 61 | 62 | ### 1.0.3 63 | * Fixed sslverify issue, props [@pmichael](https://github.com/pmichael) 64 | 65 | ### 1.0.2 66 | * Fixed potential timeout 67 | 68 | ### 1.0.1 69 | * Fixed potential fatal error with wp_error 70 | 71 | ### 1.0 72 | * Initial Public Release 73 | 74 | 75 | # Credits 76 | 77 | This plugin is written and maintained by [Paul Clark](http://pdclark.com "pdclark"). 78 | 79 | It was forked from [WordPress Github Plugin Updater](https://github.com/jkudish/WordPress-GitHub-Plugin-Updater) by [Joachim Kudish](http://jkudish.com "Joachim Kudish"). 80 | 81 | It has been updated with methods from [Github Updater](https://github.com/afragen/github-updater) by [Andy Fragen](https://github.com/afragen "Andy Fragen, Codepress") and [@GaryJones](https://github.com/garyjones). 82 | --------------------------------------------------------------------------------