"
- list( , $salt, ) = explode( ':', $yourls_user_passwords[ $user ] );
- return( $yourls_user_passwords[ $user ] == 'md5:'.$salt.':'.md5( $salt . $submitted_password ) );
- } else {
- // Password stored in clear text
- return( $yourls_user_passwords[ $user ] == $submitted_password );
- }
-}
-
-/**
- * Overwrite plaintext passwords in config file with phpassed versions.
- *
- * @since 1.7
- * @param string $config_file Full path to file
- * @return true if overwrite was successful, an error message otherwise
- */
-function yourls_hash_passwords_now( $config_file ) {
- if( !is_readable( $config_file ) )
- return 'cannot read file'; // not sure that can actually happen...
-
- if( !is_writable( $config_file ) )
- return 'cannot write file';
-
- // Include file to read value of $yourls_user_passwords
- // Temporary suppress error reporting to avoid notices about redeclared constants
- $errlevel = error_reporting();
- error_reporting( 0 );
- require $config_file;
- error_reporting( $errlevel );
-
- $configdata = file_get_contents( $config_file );
- if( $configdata == false )
- return 'could not read file';
-
- $to_hash = 0; // keep track of number of passwords that need hashing
- foreach ( $yourls_user_passwords as $user => $password ) {
- if ( !yourls_has_phpass_password( $user ) && !yourls_has_md5_password( $user ) ) {
- $to_hash++;
- $hash = yourls_phpass_hash( $password );
- // PHP would interpret $ as a variable, so replace it in storage.
- $hash = str_replace( '$', '!', $hash );
- $quotes = "'" . '"';
- $pattern = "/[$quotes]${user}[$quotes]\s*=>\s*[$quotes]" . preg_quote( $password, '-' ) . "[$quotes]/";
- $replace = "'$user' => 'phpass:$hash' /* Password encrypted by YOURLS */ ";
- $count = 0;
- $configdata = preg_replace( $pattern, $replace, $configdata, -1, $count );
- // There should be exactly one replacement. Otherwise, fast fail.
- if ( $count != 1 ) {
- yourls_debug_log( "Problem with preg_replace for password hash of user $user" );
- return 'preg_replace problem';
- }
- }
- }
-
- if( $to_hash == 0 )
- return 0; // There was no password to encrypt
-
- $success = file_put_contents( $config_file, $configdata );
- if ( $success === FALSE ) {
- yourls_debug_log( 'Failed writing to ' . $config_file );
- return 'could not write file';
- }
- return true;
-}
-
-/**
- * Hash a password using phpass
- *
- * @since 1.7
- * @param string $password password to hash
- * @return string hashed password
- */
-function yourls_phpass_hash( $password ) {
- $hasher = yourls_phpass_instance();
- return $hasher->HashPassword( $password );
-}
-
-/**
- * Check a clear password against a phpass hash
- *
- * @since 1.7
- * @param string $password clear (eg submitted in a form) password
- * @param string $hash hash supposedly generated by phpass
- * @return bool true if the hash matches the password once hashed by phpass, false otherwise
- */
-function yourls_phpass_check( $password, $hash ) {
- $hasher = yourls_phpass_instance();
- return $hasher->CheckPassword( $password, $hash );
-}
-
-/**
- * Helper function: create new instance or return existing instance of phpass class
- *
- * @since 1.7
- * @param int $iteration iteration count - 8 is default in phpass
- * @param bool $portable flag to force portable (cross platform and system independant) hashes - false to use whatever the system can do best
- * @return object a PasswordHash instance
- */
-function yourls_phpass_instance( $iteration = 8, $portable = false ) {
- $iteration = yourls_apply_filter( 'phpass_new_instance_iteration', $iteration );
- $portable = yourls_apply_filter( 'phpass_new_instance_portable', $portable );
-
- if( !class_exists( 'PasswordHash' ) ) {
- require_once( YOURLS_INC.'/phpass/PasswordHash.php' );
- }
-
- static $instance = false;
- if( $instance == false ) {
- $instance = new PasswordHash( $iteration, $portable );
- }
-
- return $instance;
-}
-
-
-/**
- * Check to see if any passwords are stored as cleartext.
- *
- * @since 1.7
- * @return bool true if any passwords are cleartext
- */
-function yourls_has_cleartext_passwords() {
- global $yourls_user_passwords;
- foreach ( $yourls_user_passwords as $user => $pwdata ) {
- if ( !yourls_has_md5_password( $user ) && !yourls_has_phpass_password( $user ) ) {
- return true;
- }
- }
- return false;
-}
-
-/**
- * Check if a user has a hashed password
- *
- * Check if a user password is 'md5:[38 chars]'.
- * TODO: deprecate this when/if we have proper user management with password hashes stored in the DB
- *
- * @since 1.7
- * @param string $user user login
- * @return bool true if password hashed, false otherwise
- */
-function yourls_has_md5_password( $user ) {
- global $yourls_user_passwords;
- return( isset( $yourls_user_passwords[ $user ] )
- && substr( $yourls_user_passwords[ $user ], 0, 4 ) == 'md5:'
- && strlen( $yourls_user_passwords[ $user ] ) == 42 // http://www.google.com/search?q=the+answer+to+life+the+universe+and+everything
- );
-}
-
-/**
- * Check if a user's password is hashed with PHPASS.
- *
- * Check if a user password is 'phpass:[lots of chars]'.
- * TODO: deprecate this when/if we have proper user management with password hashes stored in the DB
- *
- * @since 1.7
- * @param string $user user login
- * @return bool true if password hashed with PHPASS, otherwise false
- */
-function yourls_has_phpass_password( $user ) {
- global $yourls_user_passwords;
- return( isset( $yourls_user_passwords[ $user ] )
- && substr( $yourls_user_passwords[ $user ], 0, 7 ) == 'phpass:'
- );
-}
-
-/**
- * Check auth against encrypted COOKIE data. Sets user if applicable, returns bool
- *
- */
-function yourls_check_auth_cookie() {
- global $yourls_user_passwords;
- foreach( $yourls_user_passwords as $valid_user => $valid_password ) {
- if ( yourls_salt( $valid_user ) == $_COOKIE['yourls_username'] ) {
- yourls_set_user( $valid_user );
- return true;
- }
- }
- return false;
-}
-
-/**
- * Check auth against signature and timestamp. Sets user if applicable, returns bool
- *
- */
-function yourls_check_signature_timestamp() {
- // Timestamp in PHP : time()
- // Timestamp in JS: parseInt(new Date().getTime() / 1000)
- global $yourls_user_passwords;
- foreach( $yourls_user_passwords as $valid_user => $valid_password ) {
- if (
- (
- md5( $_REQUEST['timestamp'].yourls_auth_signature( $valid_user ) ) == $_REQUEST['signature']
- or
- md5( yourls_auth_signature( $valid_user ).$_REQUEST['timestamp'] ) == $_REQUEST['signature']
- )
- &&
- yourls_check_timestamp( $_REQUEST['timestamp'] )
- ) {
- yourls_set_user( $valid_user );
- return true;
- }
- }
- return false;
-}
-
-/**
- * Check auth against signature. Sets user if applicable, returns bool
- *
- */
-function yourls_check_signature() {
- global $yourls_user_passwords;
- foreach( $yourls_user_passwords as $valid_user => $valid_password ) {
- if ( yourls_auth_signature( $valid_user ) == $_REQUEST['signature'] ) {
- yourls_set_user( $valid_user );
- return true;
- }
- }
- return false;
-}
-
-/**
- * Generate secret signature hash
- *
- */
-function yourls_auth_signature( $username = false ) {
- if( !$username && defined('YOURLS_USER') ) {
- $username = YOURLS_USER;
- }
- return ( $username ? substr( yourls_salt( $username ), 0, 10 ) : 'Cannot generate auth signature: no username' );
-}
-
-/**
- * Check if timestamp is not too old
- *
- */
-function yourls_check_timestamp( $time ) {
- $now = time();
- // Allow timestamp to be a little in the future or the past -- see Issue 766
- return yourls_apply_filter( 'check_timestamp', abs( $now - $time ) < YOURLS_NONCE_LIFE, $time );
-}
-
-/**
- * Store new cookie. No $user will delete the cookie.
- *
- */
-function yourls_store_cookie( $user = null ) {
- if( !$user ) {
- $pass = null;
- $time = time() - 3600;
- } else {
- global $yourls_user_passwords;
- if( isset($yourls_user_passwords[$user]) ) {
- $pass = $yourls_user_passwords[$user];
- } else {
- die( 'Stealing cookies?' ); // This should never happen
- }
- $time = time() + YOURLS_COOKIE_LIFE;
- }
-
- $domain = yourls_apply_filter( 'setcookie_domain', parse_url( YOURLS_SITE, 1 ) );
- $secure = yourls_apply_filter( 'setcookie_secure', yourls_is_ssl() );
- $httponly = yourls_apply_filter( 'setcookie_httponly', true );
-
- // Some browser refuse to store localhost cookie
- if ( $domain == 'localhost' )
- $domain = '';
-
- if ( !headers_sent() ) {
- // Set httponly if the php version is >= 5.2.0
- if( version_compare( phpversion(), '5.2.0', 'ge' ) ) {
- setcookie('yourls_username', yourls_salt( $user ), $time, '/', $domain, $secure, $httponly );
- } else {
- setcookie('yourls_username', yourls_salt( $user ), $time, '/', $domain, $secure );
- }
- } else {
- // For some reason cookies were not stored: action to be able to debug that
- yourls_do_action( 'setcookie_failed', $user );
- }
-}
-
-/**
- * Set user name
- *
- */
-function yourls_set_user( $user ) {
- if( !defined( 'YOURLS_USER' ) )
- define( 'YOURLS_USER', $user );
-}
-
diff --git a/sources/includes/functions-compat.php b/sources/includes/functions-compat.php
deleted file mode 100644
index cda6f8e..0000000
--- a/sources/includes/functions-compat.php
+++ /dev/null
@@ -1,175 +0,0 @@
- $value ){
-
- // We first copy each key/value pair into a staging array,
- // formatting each key and value properly as we go.
-
- // Format the key:
- if( is_numeric( $key ) ){
- $key = "key_$key";
- }
- $key = '"'.addslashes( $key ).'"';
-
- // Format the value:
- if( is_array( $value )){
- $value = yourls_array_to_json( $value );
- } else if( !is_numeric( $value ) || is_string( $value ) ){
- $value = '"'.addslashes( $value ).'"';
- }
-
- // Add to staging array:
- $construct[] = "$key: $value";
- }
-
- // Then we collapse the staging array into the JSON form:
- $result = "{ " . implode( ", ", $construct ) . " }";
-
- } else { // If the array is a vector (not associative):
-
- $construct = array();
- foreach( $array as $value ){
-
- // Format the value:
- if( is_array( $value )){
- $value = yourls_array_to_json( $value );
- } else if( !is_numeric( $value ) || is_string( $value ) ){
- $value = '"'.addslashes($value).'"';
- }
-
- // Add to staging array:
- $construct[] = $value;
- }
-
- // Then we collapse the staging array into the JSON form:
- $result = "[ " . implode( ", ", $construct ) . " ]";
- }
-
- return $result;
-}
-
-/**
- * Compat http_build_query for PHP4
- *
- */
-if ( !function_exists( 'http_build_query' ) ) {
- function http_build_query( $data, $prefix=null, $sep=null ) {
- return yourls_http_build_query( $data, $prefix, $sep );
- }
-}
-
-/**
- * Compat http_build_query for PHP4. Stolen from WP.
- *
- * from php.net (modified by Mark Jaquith to behave like the native PHP5 function)
- *
- */
-function yourls_http_build_query( $data, $prefix=null, $sep=null, $key='', $urlencode=true ) {
- $ret = array();
-
- foreach ( (array) $data as $k => $v ) {
- if ( $urlencode)
- $k = urlencode( $k );
- if ( is_int($k) && $prefix != null )
- $k = $prefix.$k;
- if ( !empty( $key ) )
- $k = $key . '%5B' . $k . '%5D';
- if ( $v === NULL )
- continue;
- elseif ( $v === FALSE )
- $v = '0';
-
- if ( is_array( $v ) || is_object( $v ) )
- array_push( $ret,yourls_http_build_query( $v, '', $sep, $k, $urlencode ) );
- elseif ( $urlencode )
- array_push( $ret, $k.'='.urlencode( $v ) );
- else
- array_push( $ret, $k.'='.$v );
- }
-
- if ( NULL === $sep )
- $sep = ini_get( 'arg_separator.output' );
-
- return implode( $sep, $ret );
-}
-
-/**
- * htmlspecialchars_decode for PHP < 5.1
- *
- */
-if ( !function_exists( 'htmlspecialchars_decode' ) ) {
- function htmlspecialchars_decode( $text ) {
- return strtr( $text, array_flip( get_html_translation_table( HTML_SPECIALCHARS ) ) );
- }
-}
-
-/**
- * BC Math functions (assuming if one doesn't exist, none does)
- *
- */
-if ( !function_exists( 'bcdiv' ) ) {
- function bcdiv( $dividend, $divisor ) {
- $quotient = floor( $dividend/$divisor );
- return $quotient;
- }
- function bcmod( $dividend, $modulo ) {
- $remainder = $dividend%$modulo;
- return $remainder;
- }
- function bcmul( $left, $right ) {
- return $left * $right;
- }
- function bcadd( $left, $right ) {
- return $left + $right;
- }
- function bcpow( $base, $power ) {
- return pow( $base, $power );
- }
-}
-
-/**
- * Replacement for property_exists() (5.1+)
- *
- */
-if ( !function_exists( 'property_exists' ) ) {
- function property_exists( $class, $property ) {
- if ( is_object( $class ) ) {
- $vars = get_object_vars( $class );
- } else {
- $vars = get_class_vars( $class );
- }
- return array_key_exists( $property, $vars );
- }
-}
diff --git a/sources/includes/functions-deprecated.php b/sources/includes/functions-deprecated.php
deleted file mode 100644
index 71dac61..0000000
--- a/sources/includes/functions-deprecated.php
+++ /dev/null
@@ -1,49 +0,0 @@
- 1 ? 's' : '');
-}
-
-/**
- * Return list of all shorturls associated to the same long URL. Returns NULL or array of keywords.
- *
- */
-function yourls_get_duplicate_keywords( $longurl ) {
- yourls_deprecated_function( __FUNCTION__, '1.7', 'yourls_get_longurl_keywords' );
- if( !yourls_allow_duplicate_longurls() )
- return NULL;
- return yourls_apply_filter( 'get_duplicate_keywords', yourls_get_longurl_keywords ( $longurl ), $longurl );
-}
-
-/**
- * Make sure a integer is safe
- *
- * Note: this function is dumb and dumbly named since it does not intval(). DO NOT USE.
- *
- */
-function yourls_intval( $in ) {
- yourls_deprecated_function( __FUNCTION__, '1.7', 'yourls_sanitize_int' );
- return yourls_escape( $in );
-}
-
-/**
- * Get remote content via a GET request using best transport available
- *
- */
-function yourls_get_remote_content( $url, $maxlen = 4096, $timeout = 5 ) {
- yourls_deprecated_function( __FUNCTION__, '1.7', 'yourls_http_get_body' );
- return yourls_http_get_body( $url );
-}
-
diff --git a/sources/includes/functions-formatting.php b/sources/includes/functions-formatting.php
deleted file mode 100644
index f16219f..0000000
--- a/sources/includes/functions-formatting.php
+++ /dev/null
@@ -1,616 +0,0 @@
-= $len ) {
- $mod = bcmod( $num, $len );
- $num = bcdiv( $num, $len );
- $string = $chars[ $mod ] . $string;
- }
- $string = $chars[ intval( $num ) ] . $string;
-
- return yourls_apply_filter( 'int2string', $string, $num, $chars );
-}
-
-/**
- * Convert a string (3jk) to an integer (1337)
- *
- */
-function yourls_string2int( $string, $chars = null ) {
- if( $chars == null )
- $chars = yourls_get_shorturl_charset();
- $integer = 0;
- $string = strrev( $string );
- $baselen = strlen( $chars );
- $inputlen = strlen( $string );
- for ($i = 0; $i < $inputlen; $i++) {
- $index = strpos( $chars, $string[$i] );
- $integer = bcadd( $integer, bcmul( $index, bcpow( $baselen, $i ) ) );
- }
-
- return yourls_apply_filter( 'string2int', $integer, $string, $chars );
-}
-
-/**
- * Return a unique(ish) hash for a string to be used as a valid HTML id
- *
- */
-function yourls_string2htmlid( $string ) {
- return yourls_apply_filter( 'string2htmlid', 'y'.abs( crc32( $string ) ) );
-}
-
-/**
- * Make sure a link keyword (ie "1fv" as in "site.com/1fv") is valid.
- *
- */
-function yourls_sanitize_string( $string ) {
- // make a regexp pattern with the shorturl charset, and remove everything but this
- $pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() );
- $valid = substr( preg_replace( '![^'.$pattern.']!', '', $string ), 0, 199 );
-
- return yourls_apply_filter( 'sanitize_string', $valid, $string );
-}
-
-/**
- * Alias function. I was always getting it wrong.
- *
- */
-function yourls_sanitize_keyword( $keyword ) {
- return yourls_sanitize_string( $keyword );
-}
-
-/**
- * Sanitize a page title. No HTML per W3C http://www.w3.org/TR/html401/struct/global.html#h-7.4.2
- *
- */
-function yourls_sanitize_title( $unsafe_title ) {
- $title = $unsafe_title;
- $title = strip_tags( $title );
- $title = preg_replace( "/\s+/", ' ', trim( $title ) );
- return yourls_apply_filter( 'sanitize_title', $title, $unsafe_title );
-}
-
-/**
- * A few sanity checks on the URL. Used for redirection or DB. For display purpose, see yourls_esc_url()
- *
- */
-function yourls_sanitize_url( $unsafe_url ) {
- $url = yourls_esc_url( $unsafe_url, 'redirection' );
- return yourls_apply_filter( 'sanitize_url', $url, $unsafe_url );
-}
-
-/**
- * Perform a replacement while a string is found, eg $subject = '%0%0%0DDD', $search ='%0D' -> $result =''
- *
- * Stolen from WP's _deep_replace
- *
- */
-function yourls_deep_replace( $search, $subject ){
- $found = true;
- while($found) {
- $found = false;
- foreach( (array) $search as $val ) {
- while( strpos( $subject, $val ) !== false ) {
- $found = true;
- $subject = str_replace( $val, '', $subject );
- }
- }
- }
-
- return $subject;
-}
-
-/**
- * Make sure an integer is a valid integer (PHP's intval() limits to too small numbers)
- *
- */
-function yourls_sanitize_int( $in ) {
- return ( substr( preg_replace( '/[^0-9]/', '', strval( $in ) ), 0, 20 ) );
-}
-
-/**
- * Escape a string or an array of strings before DB usage. ALWAYS escape before using in a SQL query. Thanks.
- *
- * @param string|array $data string or array of strings to be escaped
- * @return string|array escaped data
- */
-function yourls_escape( $data ) {
- if( is_array( $data ) ) {
- foreach( $data as $k => $v ) {
- if( is_array( $v ) ) {
- $data[ $k ] = yourls_escape( $v );
- } else {
- $data[ $k ] = yourls_escape_real( $v );
- }
- }
- } else {
- $data = yourls_escape_real( $data );
- }
-
- return $data;
-}
-
-/**
- * "Real" escape. This function should NOT be called directly. Use yourls_escape() instead.
- *
- * This function uses a "real" escape if possible, using PDO, MySQL or MySQLi functions,
- * with a fallback to a "simple" addslashes
- * If you're implementing a custom DB engine or a custom cache system, you can define an
- * escape function using filter 'custom_escape_real'
- *
- * @since 1.7
- * @param string $a string to be escaped
- * @return string escaped string
- */
-function yourls_escape_real( $string ) {
- global $ydb;
- if( isset( $ydb ) && is_a( $ydb, 'ezSQLcore' ) )
- return $ydb->escape( $string );
-
- // YOURLS DB classes have been bypassed by a custom DB engine or a custom cache layer
- return yourls_apply_filters( 'custom_escape_real', addslashes( $string ), $string );
-}
-
-/**
- * Sanitize an IP address
- *
- */
-function yourls_sanitize_ip( $ip ) {
- return preg_replace( '/[^0-9a-fA-F:., ]/', '', $ip );
-}
-
-/**
- * Make sure a date is m(m)/d(d)/yyyy, return false otherwise
- *
- */
-function yourls_sanitize_date( $date ) {
- if( !preg_match( '!^\d{1,2}/\d{1,2}/\d{4}$!' , $date ) ) {
- return false;
- }
- return $date;
-}
-
-/**
- * Sanitize a date for SQL search. Return false if malformed input.
- *
- */
-function yourls_sanitize_date_for_sql( $date ) {
- if( !yourls_sanitize_date( $date ) )
- return false;
- return date( 'Y-m-d', strtotime( $date ) );
-}
-
-/**
- * Return trimmed string
- *
- */
-function yourls_trim_long_string( $string, $length = 60, $append = '[...]' ) {
- $newstring = $string;
- if( function_exists( 'mb_substr' ) ) {
- if ( mb_strlen( $newstring ) > $length ) {
- $newstring = mb_substr( $newstring, 0, $length - mb_strlen( $append ), 'UTF-8' ) . $append;
- }
- } else {
- if ( strlen( $newstring ) > $length ) {
- $newstring = substr( $newstring, 0, $length - strlen( $append ) ) . $append;
- }
- }
- return yourls_apply_filter( 'trim_long_string', $newstring, $string, $length, $append );
-}
-
-/**
- * Sanitize a version number (1.4.1-whatever -> 1.4.1)
- *
- */
-function yourls_sanitize_version( $ver ) {
- return preg_replace( '/[^0-9.]/', '', $ver );
-}
-
-/**
- * Sanitize a filename (no Win32 stuff)
- *
- */
-function yourls_sanitize_filename( $file ) {
- $file = str_replace( '\\', '/', $file ); // sanitize for Win32 installs
- $file = preg_replace( '|/+|' ,'/', $file ); // remove any duplicate slash
- return $file;
-}
-
-/**
- * Check if a string seems to be UTF-8. Stolen from WP.
- *
- */
-function yourls_seems_utf8( $str ) {
- $length = strlen( $str );
- for ( $i=0; $i < $length; $i++ ) {
- $c = ord( $str[ $i ] );
- if ( $c < 0x80 ) $n = 0; # 0bbbbbbb
- elseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb
- elseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb
- elseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb
- elseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb
- elseif (($c & 0xFE) == 0xFC) $n=5; # 1111110b
- else return false; # Does not match any model
- for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
- if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
- return false;
- }
- }
- return true;
-}
-
-/**
- * Checks for invalid UTF8 in a string. Stolen from WP
- *
- * @since 1.6
- *
- * @param string $string The text which is to be checked.
- * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
- * @return string The checked text.
- */
-function yourls_check_invalid_utf8( $string, $strip = false ) {
- $string = (string) $string;
-
- if ( 0 === strlen( $string ) ) {
- return '';
- }
-
- // Check for support for utf8 in the installed PCRE library once and store the result in a static
- static $utf8_pcre;
- if ( !isset( $utf8_pcre ) ) {
- $utf8_pcre = @preg_match( '/^./u', 'a' );
- }
- // We can't demand utf8 in the PCRE installation, so just return the string in those cases
- if ( !$utf8_pcre ) {
- return $string;
- }
-
- // preg_match fails when it encounters invalid UTF8 in $string
- if ( 1 === @preg_match( '/^./us', $string ) ) {
- return $string;
- }
-
- // Attempt to strip the bad chars if requested (not recommended)
- if ( $strip && function_exists( 'iconv' ) ) {
- return iconv( 'utf-8', 'utf-8', $string );
- }
-
- return '';
-}
-
-/**
- * Converts a number of special characters into their HTML entities. Stolen from WP.
- *
- * Specifically deals with: &, <, >, ", and '.
- *
- * $quote_style can be set to ENT_COMPAT to encode " to
- * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded.
- *
- * @since 1.6
- *
- * @param string $string The text which is to be encoded.
- * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
- * @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.
- * @return string The encoded text with HTML entities.
- */
-function yourls_specialchars( $string, $quote_style = ENT_NOQUOTES, $double_encode = false ) {
- $string = (string) $string;
-
- if ( 0 === strlen( $string ) )
- return '';
-
- // Don't bother if there are no specialchars - saves some processing
- if ( ! preg_match( '/[&<>"\']/', $string ) )
- return $string;
-
- // Account for the previous behaviour of the function when the $quote_style is not an accepted value
- if ( empty( $quote_style ) )
- $quote_style = ENT_NOQUOTES;
- elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
- $quote_style = ENT_QUOTES;
-
- $charset = 'UTF-8';
-
- $_quote_style = $quote_style;
-
- if ( $quote_style === 'double' ) {
- $quote_style = ENT_COMPAT;
- $_quote_style = ENT_COMPAT;
- } elseif ( $quote_style === 'single' ) {
- $quote_style = ENT_NOQUOTES;
- }
-
- // Handle double encoding ourselves
- if ( $double_encode ) {
- $string = @htmlspecialchars( $string, $quote_style, $charset );
- } else {
- // Decode & into &
- $string = yourls_specialchars_decode( $string, $_quote_style );
-
- // Guarantee every &entity; is valid or re-encode the &
- $string = yourls_kses_normalize_entities( $string );
-
- // Now re-encode everything except &entity;
- $string = preg_split( '/(?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
-
- for ( $i = 0; $i < count( $string ); $i += 2 )
- $string[$i] = @htmlspecialchars( $string[$i], $quote_style, $charset );
-
- $string = implode( '', $string );
- }
-
- // Backwards compatibility
- if ( 'single' === $_quote_style )
- $string = str_replace( "'", ''', $string );
-
- return $string;
-}
-
-/**
- * Converts a number of HTML entities into their special characters. Stolen from WP.
- *
- * Specifically deals with: &, <, >, ", and '.
- *
- * $quote_style can be set to ENT_COMPAT to decode " entities,
- * or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded.
- *
- * @since 1.6
- *
- * @param string $string The text which is to be decoded.
- * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
- * @return string The decoded text without HTML entities.
- */
-function yourls_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
- $string = (string) $string;
-
- if ( 0 === strlen( $string ) ) {
- return '';
- }
-
- // Don't bother if there are no entities - saves a lot of processing
- if ( strpos( $string, '&' ) === false ) {
- return $string;
- }
-
- // Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value
- if ( empty( $quote_style ) ) {
- $quote_style = ENT_NOQUOTES;
- } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
- $quote_style = ENT_QUOTES;
- }
-
- // More complete than get_html_translation_table( HTML_SPECIALCHARS )
- $single = array( ''' => '\'', ''' => '\'' );
- $single_preg = array( '/*39;/' => ''', '/*27;/i' => ''' );
- $double = array( '"' => '"', '"' => '"', '"' => '"' );
- $double_preg = array( '/*34;/' => '"', '/*22;/i' => '"' );
- $others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' );
- $others_preg = array( '/*60;/' => '<', '/*62;/' => '>', '/*38;/' => '&', '/*26;/i' => '&' );
-
- if ( $quote_style === ENT_QUOTES ) {
- $translation = array_merge( $single, $double, $others );
- $translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
- } elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
- $translation = array_merge( $double, $others );
- $translation_preg = array_merge( $double_preg, $others_preg );
- } elseif ( $quote_style === 'single' ) {
- $translation = array_merge( $single, $others );
- $translation_preg = array_merge( $single_preg, $others_preg );
- } elseif ( $quote_style === ENT_NOQUOTES ) {
- $translation = $others;
- $translation_preg = $others_preg;
- }
-
- // Remove zero padding on numeric entities
- $string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );
-
- // Replace characters according to translation table
- return strtr( $string, $translation );
-}
-
-
-/**
- * Escaping for HTML blocks. Stolen from WP
- *
- * @since 1.6
- *
- * @param string $text
- * @return string
- */
-function yourls_esc_html( $text ) {
- $safe_text = yourls_check_invalid_utf8( $text );
- $safe_text = yourls_specialchars( $safe_text, ENT_QUOTES );
- return yourls_apply_filters( 'esc_html', $safe_text, $text );
-}
-
-/**
- * Escaping for HTML attributes. Stolen from WP
- *
- * @since 1.6
- *
- * @param string $text
- * @return string
- */
-function yourls_esc_attr( $text ) {
- $safe_text = yourls_check_invalid_utf8( $text );
- $safe_text = yourls_specialchars( $safe_text, ENT_QUOTES );
- return yourls_apply_filters( 'esc_attr', $safe_text, $text );
-}
-
-/**
- * Checks and cleans a URL before printing it. Stolen from WP.
- *
- * A number of characters are removed from the URL. If the URL is for displaying
- * (the default behaviour) ampersands are also replaced.
- *
- * @since 1.6
- *
- * @param string $url The URL to be cleaned.
- * @param string $context 'display' or something else. Use yourls_sanitize_url() for database or redirection usage.
- * @param array $protocols Optional. Array of allowed protocols, defaults to global $yourls_allowedprotocols
- * @return string The cleaned $url
- */
-function yourls_esc_url( $url, $context = 'display', $protocols = array() ) {
- // make sure there's only one 'http://' at the beginning (prevents pasting a URL right after the default 'http://')
- $url = str_replace(
- array( 'http://http://', 'http://https://' ),
- array( 'http://', 'https://' ),
- $url
- );
-
- if ( '' == $url )
- return $url;
-
- // make sure there's a protocol, add http:// if not
- if ( ! yourls_get_protocol( $url ) )
- $url = 'http://'.$url;
-
- // force scheme and domain to lowercase - see issue 591
- preg_match( '!^([a-zA-Z]+://([^/]+))(.*)$!', $url, $matches );
- if( isset( $matches[1] ) && isset( $matches[3] ) )
- $url = strtolower( $matches[1] ) . $matches[3];
-
- $original_url = $url;
-
- $url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url );
- // Previous regexp in YOURLS was '|[^a-z0-9-~+_.?\[\]\^#=!&;,/:%@$\|*`\'<>"()\\x80-\\xff\{\}]|i'
- // TODO: check if that was it too destructive
- $strip = array( '%0d', '%0a', '%0D', '%0A' );
- $url = yourls_deep_replace( $strip, $url );
- $url = str_replace( ';//', '://', $url );
-
- // Replace ampersands and single quotes only when displaying.
- if ( 'display' == $context ) {
- $url = yourls_kses_normalize_entities( $url );
- $url = str_replace( '&', '&', $url );
- $url = str_replace( "'", ''', $url );
- }
-
- if ( ! is_array( $protocols ) or ! $protocols ) {
- global $yourls_allowedprotocols;
- $protocols = yourls_apply_filter( 'esc_url_protocols', $yourls_allowedprotocols );
- // Note: $yourls_allowedprotocols is also globally filterable in functions-kses.php/yourls_kses_init()
- }
-
- if ( !yourls_is_allowed_protocol( $url, $protocols ) )
- return '';
-
- // I didn't use KSES function kses_bad_protocol() because it doesn't work the way I liked (returns //blah from illegal://blah)
-
- $url = substr( $url, 0, 1999 );
-
- return yourls_apply_filter( 'esc_url', $url, $original_url, $context );
-}
-
-/**
- * Escape single quotes, htmlspecialchar " < > &, and fix line endings. Stolen from WP.
- *
- * Escapes text strings for echoing in JS. It is intended to be used for inline JS
- * (in a tag attribute, for example onclick="..."). Note that the strings have to
- * be in single quotes. The filter 'js_escape' is also applied here.
- *
- * @since 1.6
- *
- * @param string $text The text to be escaped.
- * @return string Escaped text.
- */
-function yourls_esc_js( $text ) {
- $safe_text = yourls_check_invalid_utf8( $text );
- $safe_text = yourls_specialchars( $safe_text, ENT_COMPAT );
- $safe_text = preg_replace( '/(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
- $safe_text = str_replace( "\r", '', $safe_text );
- $safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
- return yourls_apply_filters( 'esc_js', $safe_text, $text );
-}
-
-/**
- * Escaping for textarea values. Stolen from WP.
- *
- * @since 1.6
- *
- * @param string $text
- * @return string
- */
-function yourls_esc_textarea( $text ) {
- $safe_text = htmlspecialchars( $text, ENT_QUOTES );
- return yourls_apply_filters( 'esc_textarea', $safe_text, $text );
-}
-
-
-/**
-* PHP emulation of JS's encodeURI
-*
-* @link https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
-* @param $url
-* @return string
-*/
-function yourls_encodeURI( $url ) {
- // Decode URL all the way
- $result = yourls_rawurldecode_while_encoded( $url );
- // Encode once
- $result = strtr( rawurlencode( $result ), array (
- '%3B' => ';', '%2C' => ',', '%2F' => '/', '%3F' => '?', '%3A' => ':', '%40' => '@',
- '%26' => '&', '%3D' => '=', '%2B' => '+', '%24' => '$', '%21' => '!', '%2A' => '*',
- '%27' => '\'', '%28' => '(', '%29' => ')', '%23' => '#',
- ) );
- // @TODO:
- // Known limit: this will most likely break IDN URLs such as http://www.académie-française.fr/
- // To fully support IDN URLs, advocate use of a plugin.
- return yourls_apply_filter( 'encodeURI', $result, $url );
-}
-
-/**
- * Adds backslashes before letters and before a number at the start of a string. Stolen from WP.
- *
- * @since 1.6
- *
- * @param string $string Value to which backslashes will be added.
- * @return string String with backslashes inserted.
- */
-function yourls_backslashit($string) {
- $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
- $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
- return $string;
-}
-
-/**
- * Check if a string seems to be urlencoded
- *
- * We use rawurlencode instead of urlencode to avoid messing with '+'
- *
- * @since 1.7
- * @param string $string
- * @return bool
- */
-function yourls_is_rawurlencoded( $string ) {
- return rawurldecode( $string ) != $string;
-}
-
-/**
- * rawurldecode a string till it's not encoded anymore
- *
- * Deals with multiple encoding (eg "%2521" => "%21" => "!").
- * See https://github.com/YOURLS/YOURLS/issues/1303
- *
- * @since 1.7
- * @param string $string
- * @return string
- */
-function yourls_rawurldecode_while_encoded( $string ) {
- $string = rawurldecode( $string );
- if( yourls_is_rawurlencoded( $string ) ) {
- $string = yourls_rawurldecode_while_encoded( $string );
- }
- return $string;
-}
diff --git a/sources/includes/functions-html.php b/sources/includes/functions-html.php
deleted file mode 100644
index e666ea7..0000000
--- a/sources/includes/functions-html.php
+++ /dev/null
@@ -1,931 +0,0 @@
- header and logo
- *
- */
-function yourls_html_logo() {
- yourls_do_action( 'pre_html_logo' );
- ?>
-
- tag
- *
- * @param string $context Context of the page (stats, index, infos, ...)
- * @param string $title HTML title of the page
- */
-function yourls_html_head( $context = 'index', $title = '' ) {
-
- yourls_do_action( 'pre_html_head', $context, $title );
-
- // All components to false, except when specified true
- $share = $insert = $tablesorter = $tabs = $cal = $charts = false;
-
- // Load components as needed
- switch ( $context ) {
- case 'infos':
- $share = $tabs = $charts = true;
- break;
-
- case 'bookmark':
- $share = $insert = $tablesorter = true;
- break;
-
- case 'index':
- $insert = $tablesorter = $cal = $share = true;
- break;
-
- case 'plugins':
- case 'tools':
- $tablesorter = true;
- break;
-
- case 'install':
- case 'login':
- case 'new':
- case 'upgrade':
- break;
- }
-
- // Force no cache for all admin pages
- if( yourls_is_admin() && !headers_sent() ) {
- header( 'Expires: Thu, 23 Mar 1972 07:00:00 GMT' );
- header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
- header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
- header( 'Pragma: no-cache' );
- yourls_content_type_header( yourls_apply_filters( 'html_head_content-type', 'text/html' ) );
- yourls_do_action( 'admin_headers', $context, $title );
- }
-
- // Store page context in global object
- global $ydb;
- $ydb->context = $context;
-
- // Body class
- $bodyclass = yourls_apply_filter( 'bodyclass', '' );
- $bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' );
-
- // Page title
- $_title = 'YOURLS — Your Own URL Shortener | ' . yourls_link();
- $title = $title ? $title . " « " . $_title : $_title;
- $title = yourls_apply_filter( 'html_title', $title, $context );
-
- ?>
-
->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- num_queries ), $ydb->num_queries );
- ?>
-
-
- ';
- echo join( "\n", $ydb->debug_log );
- echo '';
- } ?>
- context ); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 'Text displayed'
- * @param string $selected optional 'value' from the $options array that will be highlighted
- * @param boolean $display false (default) to return, true to echo
- * @return string HTML content of the select element
- */
-function yourls_html_select( $name, $options, $selected = '', $display = false ) {
- $html = "\n";
- foreach( $options as $value => $text ) {
- $html .= "' . yourls__( 'Your short link' ) . '';
- if ( $share_title == '' )
- $share_title = '' . yourls__( 'Quick Share' ) . ' ';
-
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_share_box', false );
- if ( false !== $pre )
- return $pre;
-
- $text = ( $text ? '"'.$text.'" ' : '' );
- $title = ( $title ? "$title " : '' );
- $share = yourls_esc_textarea( $title.$text.$shorturl );
- $count = 140 - strlen( $share );
- $hidden = ( $hidden ? 'style="display:none;"' : '' );
-
- // Allow plugins to filter all data
- $data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' );
- $data = yourls_apply_filter( 'share_box_data', $data );
- extract( $data );
-
- $_share = rawurlencode( $share );
- $_url = rawurlencode( $shorturl );
- ?>
-
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
- $title" );
- echo yourls_apply_filter( 'die_message', "$message
" );
- yourls_do_action( 'yourls_die' );
- if( !yourls_did_action( 'html_head' ) ) {
- yourls_html_footer();
- }
- die();
-}
-
-/**
- * Return an "Edit" row for the main table
- *
- * @param string $keyword Keyword to edit
- * @return string HTML of the edit row
- */
-function yourls_table_edit_row( $keyword ) {
- $keyword = yourls_sanitize_string( $keyword );
- $id = yourls_string2htmlid( $keyword ); // used as HTML #id
- $url = yourls_get_keyword_longurl( $keyword );
-
- $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) );
- $safe_url = yourls_esc_attr( $url );
- $safe_title = yourls_esc_attr( $title );
- $www = yourls_link();
-
- $nonce = yourls_create_nonce( 'edit-save_'.$id );
-
- if( $url ) {
- $return = <<%s :%s : $www%s :
-RETURN;
- $return = sprintf( urldecode( $return ), yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) );
- } else {
- $return = '' . yourls__( 'Error, URL not found' ) . ' ';
- }
-
- $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title );
-
- return $return;
-}
-
-/**
- * Return an "Add" row for the main table
- *
- * @return string HTML of the edit row
- */
-function yourls_table_add_row( $keyword, $url, $title = '', $ip, $clicks, $timestamp ) {
- $keyword = yourls_sanitize_string( $keyword );
- $id = yourls_string2htmlid( $keyword ); // used as HTML #id
- $shorturl = yourls_link( $keyword );
-
- $statlink = yourls_statlink( $keyword );
-
- $delete_link = yourls_nonce_url( 'delete-link_'.$id,
- yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) )
- );
-
- $edit_link = yourls_nonce_url( 'edit-link_'.$id,
- yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) )
- );
-
- // Action link buttons: the array
- $actions = array(
- 'stats' => array(
- 'href' => $statlink,
- 'id' => "statlink-$id",
- 'title' => yourls_esc_attr__( 'Stats' ),
- 'anchor' => yourls__( 'Stats' ),
- ),
- 'share' => array(
- 'href' => '',
- 'id' => "share-button-$id",
- 'title' => yourls_esc_attr__( 'Share' ),
- 'anchor' => yourls__( 'Share' ),
- 'onclick' => "toggle_share('$id');return false;",
- ),
- 'edit' => array(
- 'href' => $edit_link,
- 'id' => "edit-button-$id",
- 'title' => yourls_esc_attr__( 'Edit' ),
- 'anchor' => yourls__( 'Edit' ),
- 'onclick' => "edit_link_display('$id');return false;",
- ),
- 'delete' => array(
- 'href' => $delete_link,
- 'id' => "delete-button-$id",
- 'title' => yourls_esc_attr__( 'Delete' ),
- 'anchor' => yourls__( 'Delete' ),
- 'onclick' => "remove_link('$id');return false;",
- )
- );
- $actions = yourls_apply_filter( 'table_add_row_action_array', $actions );
-
- // Action link buttons: the HTML
- $action_links = '';
- foreach( $actions as $key => $action ) {
- $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ;
- $action_links .= sprintf( '%s ',
- $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor']
- );
- }
- $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp );
-
- if( ! $title )
- $title = $url;
-
- $protocol_warning = '';
- if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) )
- $protocol_warning = yourls_apply_filters( 'add_row_protocol_warning', '★ ' );
-
- // Row cells: the array
- $cells = array(
- 'keyword' => array(
- 'template' => '%keyword_html% ',
- 'shorturl' => yourls_esc_url( $shorturl ),
- 'keyword_html' => yourls_esc_html( $keyword ),
- ),
- 'url' => array(
- 'template' => '%title_html% %warning%%long_url_html% ',
- 'long_url' => yourls_esc_url( $url ),
- 'title_attr' => yourls_esc_attr( $title ),
- 'title_html' => yourls_esc_html( yourls_trim_long_string( $title ) ),
- 'long_url_html' => yourls_esc_html( yourls_trim_long_string( $url ) ),
- 'warning' => $protocol_warning,
- ),
- 'timestamp' => array(
- 'template' => '%date%',
- 'date' => date( 'M d, Y H:i', $timestamp +( YOURLS_HOURS_OFFSET * 3600 ) ),
- ),
- 'ip' => array(
- 'template' => '%ip%',
- 'ip' => $ip,
- ),
- 'clicks' => array(
- 'template' => '%clicks%',
- 'clicks' => yourls_number_format_i18n( $clicks, 0, '', '' ),
- ),
- 'actions' => array(
- 'template' => '%actions% ',
- 'actions' => $action_links,
- 'id' => $id,
- 'keyword' => $keyword,
- ),
- );
- $cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp );
-
- // Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value.
- $row = "";
- foreach( $cells as $cell_id => $elements ) {
- $callback = new yourls_table_add_row_callback( $elements );
- $row .= sprintf( '', $cell_id, $cell_id . '-' . $id );
- $row .= preg_replace_callback( '/%([^%]+)?%/', array( $callback, 'callback' ), $elements['template'] );
- // For the record, in PHP 5.3+ we don't need to introduce a class in order to pass additional parameters
- // to the callback function. Instead, we would have used the 'use' keyword :
- // $row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] );
-
- $row .= ' ';
- }
- $row .= " ";
- $row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp );
-
- return $row;
-}
-
-/**
- * Callback class for yourls_table_add_row
- *
- * See comment about PHP 5.3+ in yourls_table_add_row()
- *
- * @since 1.7
- */
-class yourls_table_add_row_callback {
- private $elements;
-
- function __construct($elements) {
- $this->elements = $elements;
- }
-
- function callback( $matches ) {
- return $this->elements[ $matches[1] ];
- }
-}
-
-
-/**
- * Echo the main table head
- *
- */
-function yourls_table_head() {
- $start = ''."\n";
- echo yourls_apply_filter( 'table_head_start', $start );
-
- $cells = yourls_apply_filter( 'table_head_cells', array(
- 'shorturl' => yourls__( 'Short URL' ),
- 'longurl' => yourls__( 'Original URL' ),
- 'date' => yourls__( 'Date' ),
- 'ip' => yourls__( 'IP' ),
- 'clicks' => yourls__( 'Clicks' ),
- 'actions' => yourls__( 'Actions' )
- ) );
- foreach( $cells as $k => $v ) {
- echo "$v \n";
- }
-
- $end = " \n";
- echo yourls_apply_filter( 'table_head_end', $end );
-}
-
-/**
- * Echo the tbody start tag
- *
- */
-function yourls_table_tbody_start() {
- echo yourls_apply_filter( 'table_tbody_start', '' );
-}
-
-/**
- * Echo the tbody end tag
- *
- */
-function yourls_table_tbody_end() {
- echo yourls_apply_filter( 'table_tbody_end', ' ' );
-}
-
-/**
- * Echo the table start tag
- *
- */
-function yourls_table_end() {
- echo yourls_apply_filter( 'table_end', '
' );
-}
-
-/**
- * Echo HTML tag for a link
- *
- */
-function yourls_html_link( $href, $title = '', $element = '' ) {
- if( !$title )
- $title = $href;
- if( $element )
- $element = sprintf( 'id="%s"', yourls_esc_attr( $element ) );
- $link = sprintf( '%s ', yourls_esc_url( $href ), $element, yourls_esc_html( $title ) );
- echo yourls_apply_filter( 'html_link', $link );
-}
-
-/**
- * Display the login screen. Nothing past this point.
- *
- */
-function yourls_login_screen( $error_msg = '' ) {
- yourls_html_head( 'login' );
-
- $action = ( isset( $_GET['action'] ) && $_GET['action'] == 'logout' ? '?' : '' );
-
- yourls_html_logo();
- ?>
-
- %s'), YOURLS_USER ) . ' (' . yourls__( 'Logout' ) . ' )' );
- } else {
- $logout_link = yourls_apply_filter( 'logout_link', '' );
- }
- $help_link = yourls_apply_filter( 'help_link', '' . yourls__( 'Help' ) . ' ' );
-
- $admin_links = array();
- $admin_sublinks = array();
-
- $admin_links['admin'] = array(
- 'url' => yourls_admin_url( 'index.php' ),
- 'title' => yourls__( 'Go to the admin interface' ),
- 'anchor' => yourls__( 'Admin interface' )
- );
-
- if( yourls_is_admin() ) {
- $admin_links['tools'] = array(
- 'url' => yourls_admin_url( 'tools.php' ),
- 'anchor' => yourls__( 'Tools' )
- );
- $admin_links['plugins'] = array(
- 'url' => yourls_admin_url( 'plugins.php' ),
- 'anchor' => yourls__( 'Manage Plugins' )
- );
- $admin_sublinks['plugins'] = yourls_list_plugin_admin_pages();
- }
-
- $admin_links = yourls_apply_filter( 'admin_links', $admin_links );
- $admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks );
-
- // Now output menu
- echo '\n";
- yourls_do_action( 'admin_notices' );
- yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice'
- /*
- To display a notice:
- $message = "OMG, dude, I mean!
" );
- yourls_add_action( 'admin_notices', create_function( '', "echo '$message';" ) );
- */
-}
-
-/**
- * Wrapper function to display admin notices
- *
- */
-function yourls_add_notice( $message, $style = 'notice' ) {
- // Escape single quotes in $message to avoid breaking the anonymous function
- $message = yourls_notice_box( strtr( $message, array( "'" => "\'" ) ), $style );
- yourls_add_action( 'admin_notices', create_function( '', "echo '$message';" ) );
-}
-
-/**
- * Return a formatted notice
- *
- */
-function yourls_notice_box( $message, $style = 'notice' ) {
- return <<
- $message
-
-HTML;
-}
-
-/**
- * Display a page
- *
- */
-function yourls_page( $page ) {
- $include = YOURLS_ABSPATH . "/pages/$page.php";
- if( !file_exists( $include ) ) {
- yourls_die( "Page '$page' not found", 'Not found', 404 );
- }
- yourls_do_action( 'pre_page', $page );
- include_once( $include );
- yourls_do_action( 'post_page', $page );
- die();
-}
-
-/**
- * Display the language attributes for the HTML tag.
- *
- * Builds up a set of html attributes containing the text direction and language
- * information for the page. Stolen from WP.
- *
- * @since 1.6
- */
-function yourls_html_language_attributes() {
- $attributes = array();
- $output = '';
-
- $attributes[] = ( yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"' );
-
- $doctype = yourls_apply_filters( 'html_language_attributes_doctype', 'html' );
- // Experimental: get HTML lang from locale. Should work. Convert fr_FR -> fr-FR
- if ( $lang = str_replace( '_', '-', yourls_get_locale() ) ) {
- if( $doctype == 'xhtml' ) {
- $attributes[] = "xml:lang=\"$lang\"";
- } else {
- $attributes[] = "lang=\"$lang\"";
- }
- }
-
- $output = implode( ' ', $attributes );
- $output = yourls_apply_filters( 'html_language_attributes', $output );
- echo $output;
-}
-
-/**
- * Output translated strings used by the Javascript calendar
- *
- * @since 1.6
- */
-function yourls_l10n_calendar_strings() {
- echo "\n\n";
-
- // Dummy returns, to initialize l10n strings used in the calendar
- yourls__( 'Today' );
- yourls__( 'Close' );
-}
-
-
-/**
- * Display a notice if there is a newer version of YOURLS available
- *
- * @since 1.7
- */
-function yourls_new_core_version_notice() {
-
- yourls_debug_log( 'Check for new version: ' . ( yourls_maybe_check_core_version() ? 'yes' : 'no' ) );
-
- $checks = yourls_get_option( 'core_version_checks' );
-
- if( isset( $checks->last_result->latest ) AND version_compare( $checks->last_result->latest, YOURLS_VERSION, '>' ) ) {
- $msg = yourls_s( 'YOURLS version %s is available. Please update!', 'http://yourls.org/download', $checks->last_result->latest );
- yourls_add_notice( $msg );
- }
-}
-
-/**
- * Send a filerable content type header
- *
- * @since 1.7
- * @param string $type content type ('text/html', 'application/json', ...)
- * @return bool whether header was sent
- */
-function yourls_content_type_header( $type ) {
- if( !headers_sent() ) {
- $charset = yourls_apply_filters( 'content_type_header_charset', 'utf-8' );
- header( "Content-Type: $type; charset=$charset" );
- return true;
- }
- return false;
-}
-
-/**
- * Get search text from query string variables search_protocol, search_slashes and search
- *
- * Some servers don't like query strings containing "(ht|f)tp(s)://". A javascript bit
- * explodes the search text into protocol, slashes and the rest (see JS function
- * split_search_text_before_search()) and this function glues pieces back together
- * See issue https://github.com/YOURLS/YOURLS/issues/1576
- *
- * @since 1.7
- * @return string Search string
- */
-function yourls_get_search_text() {
- $search = '';
- if( isset( $_GET['search_protocol'] ) )
- $search .= $_GET['search_protocol'];
- if( isset( $_GET['search_slashes'] ) )
- $search .= $_GET['search_slashes'];
- if( isset( $_GET['search'] ) )
- $search .= $_GET['search'];
-
- return htmlspecialchars( trim( $search ) );
-}
diff --git a/sources/includes/functions-http.php b/sources/includes/functions-http.php
deleted file mode 100644
index 8856bea..0000000
--- a/sources/includes/functions-http.php
+++ /dev/null
@@ -1,369 +0,0 @@
-body, ->headers, ->status_code, etc...) or
- * a simple string (error message)
- * - yourls_http_METHOD_body() :
- * Return a string (response body) or null if there was an error
- *
- * @since 1.7
- */
-
-/**
- * Perform a GET request, return response object or error string message
- *
- * Notable object properties: body, headers, status_code
- *
- * @since 1.7
- * @see yourls_http_request
- * @return mixed Response object, or error string
- */
-function yourls_http_get( $url, $headers = array(), $data = array(), $options = array() ) {
- return yourls_http_request( 'GET', $url, $headers, $data, $options );
-}
-
-/**
- * Perform a GET request, return body or null if there was an error
- *
- * @since 1.7
- * @see yourls_http_request
- * @return mixed String (page body) or null if error
- */
-function yourls_http_get_body( $url, $headers = array(), $data = array(), $options = array() ) {
- $return = yourls_http_get( $url, $headers, $data, $options );
- return isset( $return->body ) ? $return->body : null;
-}
-
-/**
- * Perform a POST request, return response object
- *
- * Notable object properties: body, headers, status_code
- *
- * @since 1.7
- * @see yourls_http_request
- * @return mixed Response object, or error string
- */
-function yourls_http_post( $url, $headers = array(), $data = array(), $options = array() ) {
- return yourls_http_request( 'POST', $url, $headers, $data, $options );
-}
-
-/**
- * Perform a POST request, return body
- *
- * Wrapper for yourls_http_request()
- *
- * @since 1.7
- * @see yourls_http_request
- * @return mixed String (page body) or null if error
- */
-function yourls_http_post_body( $url, $headers = array(), $data = array(), $options = array() ) {
- $return = yourls_http_post( $url, $headers, $data, $options );
- return isset( $return->body ) ? $return->body : null;
-}
-
-/**
- * Check if a proxy is defined for HTTP requests
- *
- * @uses YOURLS_PROXY
- * @since 1.7
- * @return bool true if a proxy is defined, false otherwise
- */
-function yourls_http_proxy_is_defined() {
- return yourls_apply_filter( 'http_proxy_is_defined', defined( 'YOURLS_PROXY' ) );
-}
-
-/**
- * Default HTTP requests options for YOURLS
- *
- * For a list of all available options, see function request() in /includes/Requests/Requests.php
- *
- * @uses YOURLS_PROXY
- * @uses YOURLS_PROXY_USERNAME
- * @uses YOURLS_PROXY_PASSWORD
- * @since 1.7
- * @return array Options
- */
-function yourls_http_default_options() {
- $options = array(
- 'timeout' => yourls_apply_filter( 'http_default_options_timeout', 3 ),
- 'useragent' => yourls_http_user_agent(),
- 'follow_redirects' => true,
- 'redirects' => 3,
- );
-
- if( yourls_http_proxy_is_defined() ) {
- if( defined( 'YOURLS_PROXY_USERNAME' ) && defined( 'YOURLS_PROXY_PASSWORD' ) ) {
- $options['proxy'] = array( YOURLS_PROXY, YOURLS_PROXY_USERNAME, YOURLS_PROXY_PASSWORD );
- } else {
- $options['proxy'] = YOURLS_PROXY;
- }
- }
-
- return yourls_apply_filter( 'http_default_options', $options );
-}
-
-/**
- * Whether URL should be sent through the proxy server.
- *
- * Concept stolen from WordPress. The idea is to allow some URLs, including localhost and the YOURLS install itself,
- * to be requested directly and bypassing any defined proxy.
- *
- * @uses YOURLS_PROXY
- * @uses YOURLS_PROXY_BYPASS_HOSTS
- * @since 1.7
- * @param string $url URL to check
- * @return bool true to request through proxy, false to request directly
- */
-function yourls_send_through_proxy( $url ) {
-
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_send_through_proxy', null, $url );
- if ( null !== $pre )
- return $pre;
-
- $check = @parse_url( $url );
-
- // Malformed URL, can not process, but this could mean ssl, so let through anyway.
- if ( $check === false )
- return true;
-
- // Self and loopback URLs are considered local (':' is parse_url() host on '::1')
- $home = parse_url( YOURLS_SITE );
- $local = array( 'localhost', '127.0.0.1', '127.1', '[::1]', ':', $home['host'] );
-
- if( in_array( $check['host'], $local ) )
- return false;
-
- if ( !defined( 'YOURLS_PROXY_BYPASS_HOSTS' ) )
- return true;
-
- // Check YOURLS_PROXY_BYPASS_HOSTS
- static $bypass_hosts;
- static $wildcard_regex = false;
- if ( null == $bypass_hosts ) {
- $bypass_hosts = preg_split( '|,\s*|', YOURLS_PROXY_BYPASS_HOSTS );
-
- if ( false !== strpos( YOURLS_PROXY_BYPASS_HOSTS, '*' ) ) {
- $wildcard_regex = array();
- foreach ( $bypass_hosts as $host )
- $wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
- $wildcard_regex = '/^(' . implode( '|', $wildcard_regex ) . ')$/i';
- }
- }
-
- if ( !empty( $wildcard_regex ) )
- return !preg_match( $wildcard_regex, $check['host'] );
- else
- return !in_array( $check['host'], $bypass_hosts );
-}
-
-/**
- * Perform a HTTP request, return response object
- *
- * @since 1.7
- * @param string $var Stuff
- * @return string Result
- */
-function yourls_http_request( $type, $url, $headers, $data, $options ) {
- yourls_http_load_library();
-
- $options = array_merge( yourls_http_default_options(), $options );
-
- if( yourls_http_proxy_is_defined() && !yourls_send_through_proxy( $url ) )
- unset( $options['proxy'] );
-
- try {
- $result = Requests::request( $url, $headers, $data, $type, $options );
- } catch( Requests_Exception $e ) {
- $result = yourls_debug_log( $e->getMessage() . ' (' . $type . ' on ' . $url . ')' );
- };
-
- return $result;
-}
-
-/**
- * Check if Requests class is defined, include Requests library if need be
- *
- * All HTTP functions should perform that check prior to any operation. This is to avoid
- * include()-ing all the Requests files on every YOURLS instance disregarding whether needed or not.
- *
- * @since 1.7
- */
-function yourls_http_load_library() {
- if ( !class_exists( 'Requests', false ) ) {
- require_once dirname( __FILE__ ) . '/Requests/Requests.php';
- Requests::register_autoloader();
- }
-}
-
-/**
- * Return funky user agent string
- *
- * @since 1.5
- * @return string UA string
- */
-function yourls_http_user_agent() {
- return yourls_apply_filter( 'http_user_agent', 'YOURLS v'.YOURLS_VERSION.' +http://yourls.org/ (running on '.YOURLS_SITE.')' );
-}
-
-/**
- * Check api.yourls.org if there's a newer version of YOURLS
- *
- * This function collects various stats to help us improve YOURLS. See the blog post about it:
- * http://blog.yourls.org/2014/01/on-yourls-1-7-and-api-yourls-org/
- * Results of requests sent to api.yourls.org are stored in option 'core_version_checks' and is an object
- * with the following properties:
- * - failed_attempts : number of consecutive failed attempts
- * - last_attempt : time() of last attempt
- * - last_result : content retrieved from api.yourls.org during previous check
- * - version_checked : installed YOURLS version that was last checked
- *
- * @since 1.7
- * @return mixed JSON data if api.yourls.org successfully requested, false otherwise
- */
-function yourls_check_core_version() {
-
- global $ydb, $yourls_user_passwords;
-
- $checks = yourls_get_option( 'core_version_checks' );
-
- // Invalidate check data when YOURLS version changes
- if ( is_object( $checks ) && YOURLS_VERSION != $checks->version_checked ) {
- $checks = false;
- }
-
- if( !is_object( $checks ) ) {
- $checks = new stdClass;
- $checks->failed_attempts = 0;
- $checks->last_attempt = 0;
- $checks->last_result = '';
- $checks->version_checked = YOURLS_VERSION;
- }
-
- // Config file location ('u' for '/user' or 'i' for '/includes')
- $conf_loc = str_replace( YOURLS_ABSPATH, '', YOURLS_CONFIGFILE );
- $conf_loc = str_replace( '/config.php', '', $conf_loc );
- $conf_loc = ( $conf_loc == '/user' ? 'u' : 'i' );
-
- // The collection of stuff to report
- $stuff = array(
- // Globally uniquish site identifier
- 'md5' => md5( YOURLS_SITE . YOURLS_ABSPATH ),
-
- // Install information
- 'failed_attempts' => $checks->failed_attempts,
- 'yourls_site' => defined( 'YOURLS_SITE' ) ? YOURLS_SITE : 'unknown',
- 'yourls_version' => defined( 'YOURLS_VERSION' ) ? YOURLS_VERSION : 'unknown',
- 'php_version' => phpversion(),
- 'mysql_version' => $ydb->mysql_version(),
- 'locale' => yourls_get_locale(),
-
- // custom DB driver if any, and useful common PHP extensions
- 'db_driver' => defined( 'YOURLS_DB_DRIVER' ) ? YOURLS_DB_DRIVER : 'unset',
- 'db_ext_pdo' => extension_loaded( 'pdo_mysql' ) ? 1 : 0,
- 'db_ext_mysql' => extension_loaded( 'mysql' ) ? 1 : 0,
- 'db_ext_mysqli' => extension_loaded( 'mysqli' ) ? 1 : 0,
- 'ext_curl' => extension_loaded( 'curl' ) ? 1 : 0,
-
- // Config information
- 'num_users' => count( $yourls_user_passwords ),
- 'config_location' => $conf_loc,
- 'yourls_private' => defined( 'YOURLS_PRIVATE' ) && YOURLS_PRIVATE ? 1 : 0,
- 'yourls_unique' => defined( 'YOURLS_UNIQUE_URLS' ) && YOURLS_UNIQUE_URLS ? 1 : 0,
- 'yourls_url_convert' => defined( 'YOURLS_URL_CONVERT' ) ? YOURLS_URL_CONVERT : 'unknown',
- 'num_active_plugins' => yourls_has_active_plugins(),
- 'num_pages' => defined( 'YOURLS_PAGEDIR' ) ? count( (array) glob( YOURLS_PAGEDIR .'/*.php') ) : 0,
- );
-
- $stuff = yourls_apply_filter( 'version_check_stuff', $stuff );
-
- // Send it in
- $url = 'https://api.yourls.org/core/version/1.0/';
- $req = yourls_http_post( $url, array(), $stuff );
-
- $checks->last_attempt = time();
- $checks->version_checked = YOURLS_VERSION;
-
- // Unexpected results ?
- if( is_string( $req ) or !$req->success ) {
- $checks->failed_attempts = $checks->failed_attempts + 1;
- yourls_update_option( 'core_version_checks', $checks );
- return false;
- }
-
- // Parse response
- $json = json_decode( trim( $req->body ) );
-
- if( isset( $json->latest ) && isset( $json->zipurl ) ) {
- // All went OK - mark this down
- $checks->failed_attempts = 0;
- $checks->last_result = $json;
- yourls_update_option( 'core_version_checks', $checks );
-
- return $json;
- }
-
- // Request returned actual result, but not what we expected
- return false;
-}
-
-/**
- * Determine if we want to check for a newer YOURLS version (and check if applicable)
- *
- * Currently checks are performed every 24h and only when someone is visiting an admin page.
- * In the future (1.8?) maybe check with cronjob emulation instead.
- *
- * @since 1.7
- * @return bool true if a check was needed and successfully performed, false otherwise
- */
-function yourls_maybe_check_core_version() {
-
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_maybe_check_core_version', null );
- if ( null !== $pre )
- return $pre;
-
- if( defined( 'YOURLS_NO_VERSION_CHECK' ) && YOURLS_NO_VERSION_CHECK )
- return false;
-
- if( !yourls_is_admin() )
- return false;
-
- $checks = yourls_get_option( 'core_version_checks' );
-
- /* We don't want to check if :
- - last_result is set (a previous check was performed)
- - and it was less than 24h ago (or less than 2h ago if it wasn't successful)
- - and version checked matched version running
- Otherwise, we want to check.
- */
- if( !empty( $checks->last_result )
- AND
- (
- ( $checks->failed_attempts == 0 && ( ( time() - $checks->last_attempt ) < 24 * 3600 ) )
- OR
- ( $checks->failed_attempts > 0 && ( ( time() - $checks->last_attempt ) < 2 * 3600 ) )
- )
- AND ( $checks->version_checked == YOURLS_VERSION )
- )
- return false;
-
- // We want to check if there's a new version
- $new_check = yourls_check_core_version();
-
- // Could not check for a new version, and we don't have ancient data
- if( false == $new_check && !isset( $checks->last_result->latest ) )
- return false;
-
- return true;
-}
-
diff --git a/sources/includes/functions-infos.php b/sources/includes/functions-infos.php
deleted file mode 100644
index bb5828d..0000000
--- a/sources/includes/functions-infos.php
+++ /dev/null
@@ -1,339 +0,0 @@
- 'number of visits' (sort by DESC)
- *
- */
-function yourls_stats_countries_map( $countries, $id = null ) {
-
- yourls_do_action( 'pre_stats_countries_map' );
-
- // if $id is null then assign a random string
- if( $id === null )
- $id = uniqid ( 'yourls_stats_map_' );
-
- $data = array_merge( array( 'Country' => 'Hits' ), $countries );
- $data = yourls_google_array_to_data_table( $data );
-
- $options = array(
- 'backgroundColor' => "white",
- 'colorAxis' => "{colors:['A8D0ED','99C4E4','8AB8DB','7BACD2','6BA1C9','5C95C0','4D89B7','3E7DAE','2E72A5','1F669C']}",
- 'width' => "550",
- 'height' => "340",
- 'theme' => 'maximized'
- );
- $options = yourls_apply_filter( 'stats_countries_map_options', $options );
-
- $map = yourls_google_viz_code( 'GeoChart', $data, $options, $id );
-
- echo yourls_apply_filter( 'stats_countries_map', $map, $countries, $options, $id );
-}
-
-/**
- * Echoes an image tag of Google Charts pie from sorted array of 'data' => 'value' (sort by DESC). Optional $limit = (integer) limit list of X first countries, sorted by most visits
- *
- */
-function yourls_stats_pie( $data, $limit = 10, $size = '340x220', $id = null ) {
-
- yourls_do_action( 'pre_stats_pie' );
-
- // if $id is null then assign a random string
- if( $id === null )
- $id = uniqid ( 'yourls_stats_pie_' );
-
- // Trim array: $limit first item + the sum of all others
- if ( count( $data ) > $limit ) {
- $i= 0;
- $trim_data = array( 'Others' => 0 );
- foreach( $data as $item=>$value ) {
- $i++;
- if( $i <= $limit ) {
- $trim_data[$item] = $value;
- } else {
- $trim_data['Others'] += $value;
- }
- }
- $data = $trim_data;
- }
-
- // Scale items
- $_data = yourls_scale_data( $data );
-
- list($width, $height) = explode( 'x', $size );
-
- $options = array(
- 'theme' => 'maximized',
- 'width' => $width,
- 'height' => $height,
- 'colors' => "['A8D0ED','99C4E4','8AB8DB','7BACD2','6BA1C9','5C95C0','4D89B7','3E7DAE','2E72A5','1F669C']",
- 'legend' => 'none',
- 'chartArea' => '{top: "5%", height: "90%"}',
- 'pieSliceText' => 'label',
- );
- $options = yourls_apply_filter( 'stats_pie_options', $options );
-
- $script_data = array_merge( array( 'Country' => 'Value' ), $_data );
- $script_data = yourls_google_array_to_data_table( $script_data );
-
- $pie = yourls_google_viz_code( 'PieChart', $script_data, $options, $id );
-
- echo yourls_apply_filter( 'stats_pie', $pie, $data, $limit, $size, $options, $id );
-}
-
-/**
- * Build a list of all daily values between d1/m1/y1 to d2/m2/y2.
- *
- */
-function yourls_build_list_of_days( $dates ) {
- /* Say we have an array like:
- $dates = array (
- 2009 => array (
- '08' => array (
- 29 => 15,
- 30 => 5,
- ),
- '09' => array (
- '02' => 3,
- '03' => 5,
- '04' => 2,
- '05' => 99,
- ),
- ),
- )
- */
-
- if( !$dates )
- return array();
-
- // Get first & last years from our range. In our example: 2009 & 2009
- $first_year = key( $dates );
- $_keys = array_keys( $dates );
- $last_year = end( $_keys );
- reset( $dates );
-
- // Get first & last months from our range. In our example: 08 & 09
- $first_month = key( $dates[ $first_year ] );
- $_keys = array_keys( $dates[ $last_year ] );
- $last_month = end( $_keys );
- reset( $dates );
-
- // Get first & last days from our range. In our example: 29 & 05
- $first_day = key( $dates[ $first_year ][ $first_month ] );
- $_keys = array_keys( $dates[ $last_year ][ $last_month ] );
- $last_day = end( $_keys );
-
- unset( $_keys );
-
- // Now build a list of all years (2009), month (08 & 09) and days (all from 2009-08-29 to 2009-09-05)
- $list_of_years = array();
- $list_of_months = array();
- $list_of_days = array();
- for ( $year = $first_year; $year <= $last_year; $year++ ) {
- $_year = sprintf( '%04d', $year );
- $list_of_years[ $_year ] = $_year;
- $current_first_month = ( $year == $first_year ? $first_month : '01' );
- $current_last_month = ( $year == $last_year ? $last_month : '12' );
- for ( $month = $current_first_month; $month <= $current_last_month; $month++ ) {
- $_month = sprintf( '%02d', $month );
- $list_of_months[ $_month ] = $_month;
- $current_first_day = ( $year == $first_year && $month == $first_month ? $first_day : '01' );
- $current_last_day = ( $year == $last_year && $month == $last_month ? $last_day : yourls_days_in_month( $month, $year) );
- for ( $day = $current_first_day; $day <= $current_last_day; $day++ ) {
- $day = sprintf( '%02d', $day );
- $key = date( 'M d, Y', mktime( 0, 0, 0, $_month, $day, $_year ) );
- $list_of_days[ $key ] = isset( $dates[$_year][$_month][$day] ) ? $dates[$_year][$_month][$day] : 0;
- }
- }
- }
-
- return array(
- 'list_of_days' => $list_of_days,
- 'list_of_months' => $list_of_months,
- 'list_of_years' => $list_of_years,
- );
-}
-
-/**
- * Echoes an image tag of Google Charts line graph from array of values (eg 'number of clicks').
- *
- * $legend1_list & legend2_list are values used for the 2 x-axis labels. $id is an HTML/JS id
- *
- */
-function yourls_stats_line( $values, $id = null ) {
-
- yourls_do_action( 'pre_stats_line' );
-
- // if $id is null then assign a random string
- if( $id === null )
- $id = uniqid ( 'yourls_stats_line_' );
-
- // If we have only 1 day of data, prepend a fake day with 0 hits for a prettier graph
- if ( count( $values ) == 1 )
- array_unshift( $values, 0 );
-
- // Keep only a subset of values to keep graph smooth
- $values = yourls_array_granularity( $values, 30 );
-
- $data = array_merge( array( 'Time' => 'Hits' ), $values );
- $data = yourls_google_array_to_data_table( $data );
-
- $options = array(
- "legend" => "none",
- "pointSize" => "3",
- "theme" => "maximized",
- "curveType" => "function",
- "width" => 430,
- "height" => 220,
- "hAxis" => "{minTextSpacing: 80, maxTextLines: 1, maxAlternation: 1}",
- "vAxis" => "{minValue: -0.5, format: '#'}",
- "colors" => "['#2a85b3']",
- );
- $options = yourls_apply_filter( 'stats_line_options', $options );
-
- $lineChart = yourls_google_viz_code( 'LineChart', $data, $options, $id );
-
- echo yourls_apply_filter( 'stats_line', $lineChart, $values, $options, $id );
-}
-
-/**
- * Return the number of days in a month. From php.net, used if PHP built without calendar functions
- *
- */
-function yourls_days_in_month( $month, $year ) {
- // calculate number of days in a month
- return $month == 2 ? ( $year % 4 ? 28 : ( $year % 100 ? 29 : ( $year % 400 ? 28 : 29 ) ) ) : ( ( $month - 1 ) % 7 % 2 ? 30 : 31 );
-}
-
-/**
- * Get max value from date array of 'Aug 12, 2012' = '1337'
- *
- */
-function yourls_stats_get_best_day( $list_of_days ) {
- $max = max( $list_of_days );
- foreach( $list_of_days as $k=>$v ) {
- if ( $v == $max )
- return array( 'day' => $k, 'max' => $max );
- }
-}
-
-/**
- * Return domain of a URL
- *
- */
-function yourls_get_domain( $url, $include_scheme = false ) {
- $parse = @parse_url( $url ); // Hiding ugly stuff coming from malformed referrer URLs
-
- // Get host & scheme. Fall back to path if not found.
- $host = isset( $parse['host'] ) ? $parse['host'] : '';
- $scheme = isset( $parse['scheme'] ) ? $parse['scheme'] : '';
- $path = isset( $parse['path'] ) ? $parse['path'] : '';
- if( !$host )
- $host = $path;
-
- if ( $include_scheme && $scheme )
- $host = $scheme.'://'.$host;
-
- return $host;
-}
-
-/**
- * Return favicon URL
- *
- */
-function yourls_get_favicon_url( $url ) {
- return yourls_match_current_protocol( 'http://www.google.com/s2/u/0/favicons?domain=' . yourls_get_domain( $url, false ) );
-}
-
-/**
- * Scale array of data from 0 to 100 max
- *
- */
-function yourls_scale_data( $data ) {
- $max = max( $data );
- if( $max > 100 ) {
- foreach( $data as $k=>$v ) {
- $data[$k] = intval( $v / $max * 100 );
- }
- }
- return $data;
-}
-
-/**
- * Tweak granularity of array $array: keep only $grain values. This make less accurate but less messy graphs when too much values. See http://code.google.com/apis/chart/formats.html#granularity
- *
- */
-function yourls_array_granularity( $array, $grain = 100, $preserve_max = true ) {
- if ( count( $array ) > $grain ) {
- $max = max( $array );
- $step = intval( count( $array ) / $grain );
- $i = 0;
- // Loop through each item and unset except every $step (optional preserve the max value)
- foreach( $array as $k=>$v ) {
- $i++;
- if ( $i % $step != 0 ) {
- if ( $preserve_max == false ) {
- unset( $array[$k] );
- } else {
- if ( $v < $max )
- unset( $array[$k] );
- }
- }
- }
- }
- return $array;
-}
-
-/**
- * Transform data array to data table for Google API
- *
- */
-function yourls_google_array_to_data_table( $data ){
- $str = "var data = google.visualization.arrayToDataTable([\n";
- foreach( $data as $label => $values ){
- if( !is_array( $values ) ) {
- $values = array( $values );
- }
- $str .= "\t['$label',";
- foreach( $values as $value ){
- if( !is_numeric( $value ) && strpos( $value, '[' ) !== 0 && strpos( $value, '{' ) !== 0 ) {
- $value = "'$value'";
- }
- $str .= "$value";
- }
- $str .= "],\n";
- }
- $str = substr( $str, 0, -2 ) . "\n"; // remove the trailing comma/return, reappend the return
- $str .= "]);\n"; // wrap it up
- return $str;
-}
-
-/**
- * Return javascript code that will display the Google Chart
- *
- */
-function yourls_google_viz_code( $graph_type, $data, $options, $id ) {
- $function_name = 'yourls_graph' . $id;
- $code = "\n\n";
- $code .= "
\n";
-
- return $code;
-}
-
diff --git a/sources/includes/functions-install.php b/sources/includes/functions-install.php
deleted file mode 100644
index f72489b..0000000
--- a/sources/includes/functions-install.php
+++ /dev/null
@@ -1,326 +0,0 @@
-captured_errors );
- $version = yourls_get_database_version();
- $num_errors2 = count( $ydb->captured_errors );
-
- if( $version == NULL || ( $num_errors2 > $num_errors1 ) ) {
- yourls_die( yourls__( 'Incorrect DB config, or could not connect to DB' ), yourls__( 'Fatal error' ), 503 );
- }
-
- return ( version_compare( '5.0', $version ) <= 0 );
-}
-
-/**
- * Get DB version
- *
- * The regex removes everything that's not a number at the start of the string, or remove anything that's not a number and what
- * follows after that.
- * 'omgmysql-5.5-ubuntu-4.20' => '5.5'
- * 'mysql5.5-ubuntu-4.20' => '5.5'
- * '5.5-ubuntu-4.20' => '5.5'
- * '5.5-beta2' => '5.5'
- * '5.5' => '5.5'
- *
- * @since 1.7
- * @return string sanitized DB version
- */
-function yourls_get_database_version() {
- global $ydb;
-
- return preg_replace( '/(^[^0-9]*)|[^0-9.].*/', '', $ydb->mysql_version() );
-}
-
-/**
- * Check if PHP > 5.2
- *
- */
-function yourls_check_php_version() {
- return ( version_compare( '5.2', phpversion() ) <= 0 );
-}
-
-/**
- * Check if server is an Apache
- *
- */
-function yourls_is_apache() {
- if( !array_key_exists( 'SERVER_SOFTWARE', $_SERVER ) )
- return false;
- return (
- strpos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false
- || strpos( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) !== false
- );
-}
-
-/**
- * Check if server is running IIS
- *
- */
-function yourls_is_iis() {
- return ( array_key_exists( 'SERVER_SOFTWARE', $_SERVER ) ? ( strpos( $_SERVER['SERVER_SOFTWARE'], 'IIS' ) !== false ) : false );
-}
-
-
-/**
- * Create .htaccess or web.config. Returns boolean
- *
- */
-function yourls_create_htaccess() {
- $host = parse_url( YOURLS_SITE );
- $path = ( isset( $host['path'] ) ? $host['path'] : '' );
-
- if ( yourls_is_iis() ) {
- // Prepare content for a web.config file
- $content = array(
- ''.'xml version="1.0" encoding="UTF-8"?>',
- '',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- );
-
- $filename = YOURLS_ABSPATH.'/web.config';
- $marker = 'none';
-
- } else {
- // Prepare content for a .htaccess file
- $content = array(
- '',
- 'RewriteEngine On',
- 'RewriteBase '.$path.'/',
- 'RewriteCond %{REQUEST_FILENAME} !-f',
- 'RewriteCond %{REQUEST_FILENAME} !-d',
- 'RewriteRule ^.*$ '.$path.'/yourls-loader.php [L]',
- ' ',
- );
-
- $filename = YOURLS_ABSPATH.'/.htaccess';
- $marker = 'YOURLS';
-
- }
-
- return ( yourls_insert_with_markers( $filename, $marker, $content ) );
-}
-
-/**
- * Inserts $insertion (text in an array of lines) into $filename (.htaccess) between BEGIN/END $marker block. Returns bool. Stolen from WP
- *
- */
-function yourls_insert_with_markers( $filename, $marker, $insertion ) {
- if ( !file_exists( $filename ) || is_writeable( $filename ) ) {
- if ( !file_exists( $filename ) ) {
- $markerdata = '';
- } else {
- $markerdata = explode( "\n", implode( '', file( $filename ) ) );
- }
-
- if ( !$f = @fopen( $filename, 'w' ) )
- return false;
-
- $foundit = false;
- if ( $markerdata ) {
- $state = true;
- foreach ( $markerdata as $n => $markerline ) {
- if ( strpos( $markerline, '# BEGIN ' . $marker ) !== false )
- $state = false;
- if ( $state ) {
- if ( $n + 1 < count( $markerdata ) )
- fwrite( $f, "{$markerline}\n" );
- else
- fwrite( $f, "{$markerline}" );
- }
- if ( strpos( $markerline, '# END ' . $marker ) !== false ) {
- if ( $marker != 'none' )
- fwrite( $f, "# BEGIN {$marker}\n" );
- if ( is_array( $insertion ) )
- foreach ( $insertion as $insertline )
- fwrite( $f, "{$insertline}\n" );
- if ( $marker != 'none' )
- fwrite( $f, "# END {$marker}\n" );
- $state = true;
- $foundit = true;
- }
- }
- }
- if ( !$foundit ) {
- if ( $marker != 'none' )
- fwrite( $f, "\n\n# BEGIN {$marker}\n" );
- foreach ( $insertion as $insertline )
- fwrite( $f, "{$insertline}\n" );
- if ( $marker != 'none' )
- fwrite( $f, "# END {$marker}\n\n" );
- }
- fclose( $f );
- return true;
- } else {
- return false;
- }
-}
-
-/**
- * Create MySQL tables. Return array( 'success' => array of success strings, 'errors' => array of error strings )
- *
- */
-function yourls_create_sql_tables() {
- global $ydb;
-
- $error_msg = array();
- $success_msg = array();
-
- // Create Table Query
- $create_tables = array();
- $create_tables[YOURLS_DB_TABLE_URL] =
- 'CREATE TABLE IF NOT EXISTS `'.YOURLS_DB_TABLE_URL.'` ('.
- '`keyword` varchar(200) BINARY NOT NULL,'.
- '`url` text BINARY NOT NULL,'.
- '`title` text CHARACTER SET utf8,'.
- '`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,'.
- '`ip` VARCHAR(41) NOT NULL,'.
- '`clicks` INT(10) UNSIGNED NOT NULL,'.
- ' PRIMARY KEY (`keyword`),'.
- ' KEY `timestamp` (`timestamp`),'.
- ' KEY `ip` (`ip`)'.
- ');';
-
- $create_tables[YOURLS_DB_TABLE_OPTIONS] =
- 'CREATE TABLE IF NOT EXISTS `'.YOURLS_DB_TABLE_OPTIONS.'` ('.
- '`option_id` bigint(20) unsigned NOT NULL auto_increment,'.
- '`option_name` varchar(64) NOT NULL default "",'.
- '`option_value` longtext NOT NULL,'.
- 'PRIMARY KEY (`option_id`,`option_name`),'.
- 'KEY `option_name` (`option_name`)'.
- ') AUTO_INCREMENT=1 ;';
-
- $create_tables[YOURLS_DB_TABLE_LOG] =
- 'CREATE TABLE IF NOT EXISTS `'.YOURLS_DB_TABLE_LOG.'` ('.
- '`click_id` int(11) NOT NULL auto_increment,'.
- '`click_time` datetime NOT NULL,'.
- '`shorturl` varchar(200) BINARY NOT NULL,'.
- '`referrer` varchar(200) NOT NULL,'.
- '`user_agent` varchar(255) NOT NULL,'.
- '`ip_address` varchar(41) NOT NULL,'.
- '`country_code` char(2) NOT NULL,'.
- 'PRIMARY KEY (`click_id`),'.
- 'KEY `shorturl` (`shorturl`)'.
- ') AUTO_INCREMENT=1 ;';
-
-
- $create_table_count = 0;
-
- $ydb->show_errors = true;
-
- // Create tables
- foreach ( $create_tables as $table_name => $table_query ) {
- $ydb->query( $table_query );
- $create_success = $ydb->query( "SHOW TABLES LIKE '$table_name'" );
- if( $create_success ) {
- $create_table_count++;
- $success_msg[] = yourls_s( "Table '%s' created.", $table_name );
- } else {
- $error_msg[] = yourls_s( "Error creating table '%s'.", $table_name );
- }
- }
-
- // Initializes the option table
- if( !yourls_initialize_options() )
- $error_msg[] = yourls__( 'Could not initialize options' );
-
- // Insert sample links
- if( !yourls_insert_sample_links() )
- $error_msg[] = yourls__( 'Could not insert sample short URLs' );
-
- // Check results of operations
- if ( sizeof( $create_tables ) == $create_table_count ) {
- $success_msg[] = yourls__( 'YOURLS tables successfully created.' );
- } else {
- $error_msg[] = yourls__( 'Error creating YOURLS tables.' );
- }
-
- return array( 'success' => $success_msg, 'error' => $error_msg );
-}
-
-/**
- * Initializes the option table
- *
- * Each yourls_update_option() returns either true on success (option updated) or false on failure (new value == old value, or
- * for some reason it could not save to DB).
- * Since true & true & true = 1, we cast it to boolean type to return true (or false)
- *
- * @since 1.7
- * @return bool
- */
-function yourls_initialize_options() {
- return ( bool ) (
- yourls_update_option( 'version', YOURLS_VERSION )
- & yourls_update_option( 'db_version', YOURLS_DB_VERSION )
- & yourls_update_option( 'next_id', 1 )
- );
-}
-
-/**
- * Populates the URL table with a few sample links
- *
- * @since 1.7
- * @return bool
- */
-function yourls_insert_sample_links() {
- $link1 = yourls_add_new_link( 'http://blog.yourls.org/', 'yourlsblog', 'YOURLS\' Blog' );
- $link2 = yourls_add_new_link( 'http://yourls.org/', 'yourls', 'YOURLS: Your Own URL Shortener' );
- $link3 = yourls_add_new_link( 'http://ozh.org/', 'ozh', 'ozh.org' );
- return ( bool ) (
- $link1['status'] == 'success'
- & $link2['status'] == 'success'
- & $link3['status'] == 'success'
- );
-}
-
-
-/**
- * Toggle maintenance mode. Inspired from WP. Returns true for success, false otherwise
- *
- */
-function yourls_maintenance_mode( $maintenance = true ) {
-
- $file = YOURLS_ABSPATH . '/.maintenance' ;
-
- // Turn maintenance mode on : create .maintenance file
- if ( (bool)$maintenance ) {
- if ( ! ( $fp = @fopen( $file, 'w' ) ) )
- return false;
-
- $maintenance_string = '';
- @fwrite( $fp, $maintenance_string );
- @fclose( $fp );
- @chmod( $file, 0644 ); // Read and write for owner, read for everybody else
-
- // Not sure why the fwrite would fail if the fopen worked... Just in case
- return( is_readable( $file ) );
-
- // Turn maintenance mode off : delete the .maintenance file
- } else {
- return @unlink($file);
- }
-}
\ No newline at end of file
diff --git a/sources/includes/functions-kses.php b/sources/includes/functions-kses.php
deleted file mode 100644
index d141fe6..0000000
--- a/sources/includes/functions-kses.php
+++ /dev/null
@@ -1,778 +0,0 @@
-
- *
- * @package External
- * @subpackage KSES
- *
- */
-
-/* NOTE ABOUT GLOBALS
- * Two globals are defined: $yourls_allowedentitynames and $yourls_allowedprotocols
- * - $yourls_allowedentitynames is used internally in KSES functions to sanitize HTML entities
- * - $yourls_allowedprotocols is used in various parts of YOURLS, not just in KSES, albeit being defined here
- * Two globals are not defined and unused at this moment: $yourls_allowedtags_all and $yourls_allowedtags
- * The code for these vars is here and ready for any future use
- */
-
-// Populate after plugins have loaded to allow user defined values
-yourls_add_action( 'plugins_loaded', 'yourls_kses_init' );
-
-/**
- * Init KSES globals if not already defined (by a plugin)
- *
- * @since 1.6
- *
- */
-function yourls_kses_init() {
- global $yourls_allowedentitynames, $yourls_allowedprotocols;
-
- if( ! $yourls_allowedentitynames ) {
- $yourls_allowedentitynames = yourls_apply_filter( 'kses_allowed_entities', yourls_kses_allowed_entities() );
- }
-
- if( ! $yourls_allowedprotocols ) {
- $yourls_allowedprotocols = yourls_apply_filter( 'kses_allowed_protocols', yourls_kses_allowed_protocols() );
- }
-
- /** See NOTE ABOUT GLOBALS **
-
- if( ! $yourls_allowedtags_all ) {
- $yourls_allowedtags_all = yourls_kses_allowed_tags_all();
- $yourls_allowedtags_all = array_map( '_yourls_add_global_attributes', $yourls_allowedtags_all );
- $yourls_allowedtags_all = yourls_apply_filter( 'kses_allowed_tags_all', $yourls_allowedtags_all );
- } else {
- // User defined: let's sanitize
- $yourls_allowedtags_all = yourls_kses_array_lc( $yourls_allowedtags_all );
- }
-
- if( ! $yourls_allowedtags ) {
- $yourls_allowedtags = yourls_kses_allowed_tags();
- $yourls_allowedtags = array_map( '_yourls_add_global_attributes', $yourls_allowedtags );
- $yourls_allowedtags = yourls_apply_filter( 'kses_allowed_tags', $yourls_allowedtags );
- } else {
- // User defined: let's sanitize
- $yourls_allowedtags = yourls_kses_array_lc( $yourls_allowedtags );
- }
-
- /**/
-}
-
-/**
- * Kses global for all allowable HTML tags.
- *
- * Complete (?) list of HTML tags. Keep this function available for any plugin or
- * future feature that will want to display lots of HTML.
- *
- * @since 1.6
- *
- * @return array All tags
- */
-function yourls_kses_allowed_tags_all() {
- return array(
- 'address' => array(),
- 'a' => array(
- 'href' => true,
- 'rel' => true,
- 'rev' => true,
- 'name' => true,
- 'target' => true,
- ),
- 'abbr' => array(),
- 'acronym' => array(),
- 'area' => array(
- 'alt' => true,
- 'coords' => true,
- 'href' => true,
- 'nohref' => true,
- 'shape' => true,
- 'target' => true,
- ),
- 'article' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'aside' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'b' => array(),
- 'big' => array(),
- 'blockquote' => array(
- 'cite' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'br' => array(),
- 'button' => array(
- 'disabled' => true,
- 'name' => true,
- 'type' => true,
- 'value' => true,
- ),
- 'caption' => array(
- 'align' => true,
- ),
- 'cite' => array(
- 'dir' => true,
- 'lang' => true,
- ),
- 'code' => array(),
- 'col' => array(
- 'align' => true,
- 'char' => true,
- 'charoff' => true,
- 'span' => true,
- 'dir' => true,
- 'valign' => true,
- 'width' => true,
- ),
- 'del' => array(
- 'datetime' => true,
- ),
- 'dd' => array(),
- 'details' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'open' => true,
- 'xml:lang' => true,
- ),
- 'div' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'dl' => array(),
- 'dt' => array(),
- 'em' => array(),
- 'fieldset' => array(),
- 'figure' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'figcaption' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'font' => array(
- 'color' => true,
- 'face' => true,
- 'size' => true,
- ),
- 'footer' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'form' => array(
- 'action' => true,
- 'accept' => true,
- 'accept-charset' => true,
- 'enctype' => true,
- 'method' => true,
- 'name' => true,
- 'target' => true,
- ),
- 'h1' => array(
- 'align' => true,
- ),
- 'h2' => array(
- 'align' => true,
- ),
- 'h3' => array(
- 'align' => true,
- ),
- 'h4' => array(
- 'align' => true,
- ),
- 'h5' => array(
- 'align' => true,
- ),
- 'h6' => array(
- 'align' => true,
- ),
- 'header' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'hgroup' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'hr' => array(
- 'align' => true,
- 'noshade' => true,
- 'size' => true,
- 'width' => true,
- ),
- 'i' => array(),
- 'img' => array(
- 'alt' => true,
- 'align' => true,
- 'border' => true,
- 'height' => true,
- 'hspace' => true,
- 'longdesc' => true,
- 'vspace' => true,
- 'src' => true,
- 'usemap' => true,
- 'width' => true,
- ),
- 'ins' => array(
- 'datetime' => true,
- 'cite' => true,
- ),
- 'kbd' => array(),
- 'label' => array(
- 'for' => true,
- ),
- 'legend' => array(
- 'align' => true,
- ),
- 'li' => array(
- 'align' => true,
- ),
- 'map' => array(
- 'name' => true,
- ),
- 'menu' => array(
- 'type' => true,
- ),
- 'nav' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'p' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'pre' => array(
- 'width' => true,
- ),
- 'q' => array(
- 'cite' => true,
- ),
- 's' => array(),
- 'span' => array(
- 'dir' => true,
- 'align' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'section' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'small' => array(),
- 'strike' => array(),
- 'strong' => array(),
- 'sub' => array(),
- 'summary' => array(
- 'align' => true,
- 'dir' => true,
- 'lang' => true,
- 'xml:lang' => true,
- ),
- 'sup' => array(),
- 'table' => array(
- 'align' => true,
- 'bgcolor' => true,
- 'border' => true,
- 'cellpadding' => true,
- 'cellspacing' => true,
- 'dir' => true,
- 'rules' => true,
- 'summary' => true,
- 'width' => true,
- ),
- 'tbody' => array(
- 'align' => true,
- 'char' => true,
- 'charoff' => true,
- 'valign' => true,
- ),
- 'td' => array(
- 'abbr' => true,
- 'align' => true,
- 'axis' => true,
- 'bgcolor' => true,
- 'char' => true,
- 'charoff' => true,
- 'colspan' => true,
- 'dir' => true,
- 'headers' => true,
- 'height' => true,
- 'nowrap' => true,
- 'rowspan' => true,
- 'scope' => true,
- 'valign' => true,
- 'width' => true,
- ),
- 'textarea' => array(
- 'cols' => true,
- 'rows' => true,
- 'disabled' => true,
- 'name' => true,
- 'readonly' => true,
- ),
- 'tfoot' => array(
- 'align' => true,
- 'char' => true,
- 'charoff' => true,
- 'valign' => true,
- ),
- 'th' => array(
- 'abbr' => true,
- 'align' => true,
- 'axis' => true,
- 'bgcolor' => true,
- 'char' => true,
- 'charoff' => true,
- 'colspan' => true,
- 'headers' => true,
- 'height' => true,
- 'nowrap' => true,
- 'rowspan' => true,
- 'scope' => true,
- 'valign' => true,
- 'width' => true,
- ),
- 'thead' => array(
- 'align' => true,
- 'char' => true,
- 'charoff' => true,
- 'valign' => true,
- ),
- 'title' => array(),
- 'tr' => array(
- 'align' => true,
- 'bgcolor' => true,
- 'char' => true,
- 'charoff' => true,
- 'valign' => true,
- ),
- 'tt' => array(),
- 'u' => array(),
- 'ul' => array(
- 'type' => true,
- ),
- 'ol' => array(
- 'start' => true,
- 'type' => true,
- ),
- 'var' => array(),
- );
-}
-
-/**
- * Kses global for default allowable HTML tags. TODO: trim down to necessary only.
- *
- * Short list of HTML tags used in YOURLS core for display
- *
- * @since 1.6
- *
- * @return array Allowed tags
- */
-function yourls_kses_allowed_tags() {
- return array(
- 'a' => array(
- 'href' => true,
- 'title' => true,
- ),
- 'abbr' => array(
- 'title' => true,
- ),
- 'acronym' => array(
- 'title' => true,
- ),
- 'b' => array(),
- 'blockquote' => array(
- 'cite' => true,
- ),
- 'cite' => array(),
- 'code' => array(),
- 'del' => array(
- 'datetime' => true,
- ),
- 'em' => array(),
- 'i' => array(),
- 'q' => array(
- 'cite' => true,
- ),
- 'strike' => array(),
- 'strong' => array(),
- );
-}
-
-/**
- * Kses global for allowable HTML entities.
- *
- * @since 1.6
- *
- * @return array Allowed entities
- */
-function yourls_kses_allowed_entities() {
- return array(
- 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen',
- 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo',
- 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn',
- 'acute', 'micro', 'para', 'middot', 'cedil', 'ordm',
- 'raquo', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde',
- 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute',
- 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml',
- 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde',
- 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc',
- 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute',
- 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil',
- 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute',
- 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute',
- 'ocirc', 'otilde', 'ouml', 'divide', 'oslash', 'ugrave',
- 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml',
- 'quot', 'amp', 'lt', 'gt', 'apos', 'OElig',
- 'oelig', 'Scaron', 'scaron', 'Yuml', 'circ', 'tilde',
- 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm',
- 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo',
- 'ldquo', 'rdquo', 'bdquo', 'dagger', 'Dagger', 'permil',
- 'lsaquo', 'rsaquo', 'euro', 'fnof', 'Alpha', 'Beta',
- 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta',
- 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi',
- 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon',
- 'Phi', 'Chi', 'Psi', 'Omega', 'alpha', 'beta',
- 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta',
- 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi',
- 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau',
- 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym',
- 'upsih', 'piv', 'bull', 'hellip', 'prime', 'Prime',
- 'oline', 'frasl', 'weierp', 'image', 'real', 'trade',
- 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr',
- 'crarr', 'lArr', 'uArr', 'rArr', 'dArr', 'hArr',
- 'forall', 'part', 'exist', 'empty', 'nabla', 'isin',
- 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast',
- 'radic', 'prop', 'infin', 'ang', 'and', 'or',
- 'cap', 'cup', 'int', 'sim', 'cong', 'asymp',
- 'ne', 'equiv', 'le', 'ge', 'sub', 'sup',
- 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp',
- 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang',
- 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams',
- );
-}
-
-/**
- * Kses global for allowable protocols.
- *
- * @since 1.6
- *
- * @return array Allowed protocols
- */
-function yourls_kses_allowed_protocols() {
- // More or less common stuff in links. From http://en.wikipedia.org/wiki/URI_scheme
- return array(
- // Common
- 'http://', 'https://', 'ftp://',
- 'file://', 'smb://',
- 'sftp://',
- 'feed:', 'feed://',
- 'mailto:',
- 'news:', 'nntp://',
-
- // Old school bearded geek
- 'gopher://', 'telnet://', 'finger://',
- 'nntp://', 'worldwind://',
-
- // Dev
- 'ssh://', 'svn://', 'svn+ssh://', 'git://', 'cvs://',
- 'apt:',
- 'market://', // Google Play
- 'view-source:',
-
- // P2P
- 'ed2k://', 'magnet:', 'udp://',
-
- // Streaming stuff
- 'mms://', 'lastfm://', 'spotify:', 'rtsp://',
-
- // Text & voice
- 'aim:', 'facetime://', 'gtalk:', 'xmpp:',
- 'irc://', 'ircs://', 'mumble://',
- 'callto:', 'skype:', 'sip:',
- 'teamspeak://', 'ventrilo://', 'xfire:',
- 'ymsgr:',
-
- // Misc
- 'steam:', 'steam://',
- 'bitcoin:',
- 'ldap://', 'ldaps://',
-
- // Purposedly removed for security
- /*
- 'about:', 'chrome://', 'chrome-extension://',
- 'javascript:',
- 'data:',
- */
- );
-}
-
-
-/**
- * Converts and fixes HTML entities.
- *
- * This function normalizes HTML entities. It will convert "AT&T" to the correct
- * "AT&T", ":" to ":", "YZZY;" to "&#XYZZY;" and so on.
- *
- * @since 1.6
- *
- * @param string $string Content to normalize entities
- * @return string Content with normalized entities
- */
-function yourls_kses_normalize_entities($string) {
- # Disarm all entities by converting & to &
-
- $string = str_replace('&', '&', $string);
-
- # Change back the allowed entities in our entity whitelist
-
- $string = preg_replace_callback('/&([A-Za-z]{2,8});/', 'yourls_kses_named_entities', $string);
- $string = preg_replace_callback('/&#(0*[0-9]{1,7});/', 'yourls_kses_normalize_entities2', $string);
- $string = preg_replace_callback('/&#[Xx](0*[0-9A-Fa-f]{1,6});/', 'yourls_kses_normalize_entities3', $string);
-
- return $string;
-}
-
-/**
- * Callback for yourls_kses_normalize_entities() regular expression.
- *
- * This function only accepts valid named entity references, which are finite,
- * case-sensitive, and highly scrutinized by HTML and XML validators.
- *
- * @since 1.6
- *
- * @param array $matches preg_replace_callback() matches array
- * @return string Correctly encoded entity
- */
-function yourls_kses_named_entities($matches) {
- global $yourls_allowedentitynames;
-
- if ( empty($matches[1]) )
- return '';
-
- $i = $matches[1];
- return ( ( ! in_array($i, $yourls_allowedentitynames) ) ? "&$i;" : "&$i;" );
-}
-
-/**
- * Callback for yourls_kses_normalize_entities() regular expression.
- *
- * This function helps yourls_kses_normalize_entities() to only accept 16-bit values
- * and nothing more for number; entities.
- *
- * @access private
- * @since 1.6
- *
- * @param array $matches preg_replace_callback() matches array
- * @return string Correctly encoded entity
- */
-function yourls_kses_normalize_entities2($matches) {
- if ( empty($matches[1]) )
- return '';
-
- $i = $matches[1];
- if (yourls_valid_unicode($i)) {
- $i = str_pad(ltrim($i,'0'), 3, '0', STR_PAD_LEFT);
- $i = "$i;";
- } else {
- $i = "&#$i;";
- }
-
- return $i;
-}
-
-/**
- * Callback for yourls_kses_normalize_entities() for regular expression.
- *
- * This function helps yourls_kses_normalize_entities() to only accept valid Unicode
- * numeric entities in hex form.
- *
- * @access private
- * @since 1.6
- *
- * @param array $matches preg_replace_callback() matches array
- * @return string Correctly encoded entity
- */
-function yourls_kses_normalize_entities3($matches) {
- if ( empty($matches[1]) )
- return '';
-
- $hexchars = $matches[1];
- return ( ( ! yourls_valid_unicode(hexdec($hexchars)) ) ? "&#x$hexchars;" : ''.ltrim($hexchars,'0').';' );
-}
-
-/**
- * Helper function to add global attributes to a tag in the allowed html list.
- *
- * @since 1.6
- * @access private
- *
- * @param array $value An array of attributes.
- * @return array The array of attributes with global attributes added.
- */
-function _yourls_add_global_attributes( $value ) {
- $global_attributes = array(
- 'class' => true,
- 'id' => true,
- 'style' => true,
- 'title' => true,
- );
-
- if ( true === $value )
- $value = array();
-
- if ( is_array( $value ) )
- return array_merge( $value, $global_attributes );
-
- return $value;
-}
-
-/**
- * Helper function to determine if a Unicode value is valid.
- *
- * @since 1.6
- *
- * @param int $i Unicode value
- * @return bool True if the value was a valid Unicode number
- */
-function yourls_valid_unicode($i) {
- return ( $i == 0x9 || $i == 0xa || $i == 0xd ||
- ($i >= 0x20 && $i <= 0xd7ff) ||
- ($i >= 0xe000 && $i <= 0xfffd) ||
- ($i >= 0x10000 && $i <= 0x10ffff) );
-}
-
-/**
- * Goes through an array and changes the keys to all lower case.
- *
- * @since 1.6
- *
- * @param array $inarray Unfiltered array
- * @return array Fixed array with all lowercase keys
- */
-function yourls_kses_array_lc($inarray) {
- $outarray = array ();
-
- foreach ( (array) $inarray as $inkey => $inval) {
- $outkey = strtolower($inkey);
- $outarray[$outkey] = array ();
-
- foreach ( (array) $inval as $inkey2 => $inval2) {
- $outkey2 = strtolower($inkey2);
- $outarray[$outkey][$outkey2] = $inval2;
- } # foreach $inval
- } # foreach $inarray
-
- return $outarray;
-}
-
-/**
- * Convert all entities to their character counterparts.
- *
- * This function decodes numeric HTML entities (A and A). It doesn't do
- * anything with other entities like ä, but we don't need them in the URL
- * protocol whitelisting system anyway.
- *
- * @since 1.6
- *
- * @param string $string Content to change entities
- * @return string Content after decoded entities
- */
-function yourls_kses_decode_entities($string) {
- $string = preg_replace_callback('/([0-9]+);/', '_yourls_kses_decode_entities_chr', $string);
- $string = preg_replace_callback('/[Xx]([0-9A-Fa-f]+);/', '_yourls_kses_decode_entities_chr_hexdec', $string);
-
- return $string;
-}
-
-/**
- * Regex callback for yourls_kses_decode_entities()
- *
- * @since 1.6
- *
- * @param array $match preg match
- * @return string
- */
-function _yourls_kses_decode_entities_chr( $match ) {
- return chr( $match[1] );
-}
-
-/**
- * Regex callback for yourls_kses_decode_entities()
- *
- * @since 1.6
- *
- * @param array $match preg match
- * @return string
- */
-function _yourls_kses_decode_entities_chr_hexdec( $match ) {
- return chr( hexdec( $match[1] ) );
-}
-
-/**
- * Removes any null characters in $string.
- *
- * @since 1.6
- *
- * @param string $string
- * @return string
- */
-function yourls_kses_no_null($string) {
- $string = preg_replace( '/\0+/', '', $string );
- $string = preg_replace( '/(\\\\0)+/', '', $string );
-
- return $string;
-}
diff --git a/sources/includes/functions-l10n.php b/sources/includes/functions-l10n.php
deleted file mode 100644
index 528a6b5..0000000
--- a/sources/includes/functions-l10n.php
+++ /dev/null
@@ -1,1151 +0,0 @@
-translate( $text ), $text, $domain );
-}
-
-/**
- * Retrieves the translation of $text with a given $context. If there is no translation, or
- * the domain isn't loaded, the original text is returned.
- *
- * Quite a few times, there will be collisions with similar translatable text
- * found in more than two places but with different translated context.
- *
- * By including the context in the pot file translators can translate the two
- * strings differently.
- *
- * @since 1.6
- * @param string $text Text to translate.
- * @param string $context Context.
- * @param string $domain Domain to retrieve the translated text.
- * @return string Translated text
- */
-function yourls_translate_with_context( $text, $context, $domain = 'default' ) {
- $translations = yourls_get_translations_for_domain( $domain );
- return yourls_apply_filters( 'translate_with_context', $translations->translate( $text, $context ), $text, $context, $domain );
-}
-
-/**
- * Retrieves the translation of $text. If there is no translation, or
- * the domain isn't loaded, the original text is returned.
- *
- * @see yourls_translate() An alias of yourls_translate()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $domain Optional. Domain to retrieve the translated text
- * @return string Translated text
- */
-function yourls__( $text, $domain = 'default' ) {
- return yourls_translate( $text, $domain );
-}
-
-/**
- * Return a translated sprintf() string (mix yourls__() and sprintf() in one func)
- *
- * Instead of doing sprintf( yourls__( 'string %s' ), $arg ) you can simply use:
- * yourls_s( 'string %s', $arg )
- * This function accepts an arbitrary number of arguments:
- * - first one will be the string to translate, eg "hello %s my name is %s"
- * - following ones will be the sprintf arguments, eg "world" and "Ozh"
- * - if there are more arguments passed than needed, the last one will be used as the translation domain
- * This function will not accept a textdomain argument: do not use in plugins or outside YOURLS core.
- *
- * @see sprintf()
- * @since 1.6
- *
- * @param string $pattern Text to translate
- * @param string $arg1, $arg2... Optional: sprintf tokens, and translation domain
- * @return string Translated text
- */
-function yourls_s( $pattern ) {
- // Get pattern and pattern arguments
- $args = func_get_args();
- // If yourls_s() called by yourls_se(), all arguments are wrapped in the same array key
- if( count( $args ) == 1 && is_array( $args ) ) {
- $args = $args[0];
- }
- $pattern = $args[0];
-
- // get list of sprintf tokens (%s and such)
- $num_of_tokens = substr_count( $pattern, '%' ) - 2 * substr_count( $pattern, '%%' );
-
- $domain = 'default';
- // More arguments passed than needed for the sprintf? The last one will be the domain
- if( $num_of_tokens < ( count( $args ) - 1 ) ) {
- $domain = array_pop( $args );
- }
-
- // Translate text
- $args[0] = yourls__( $pattern, $domain );
-
- return call_user_func_array( 'sprintf', $args );
-}
-
-/**
- * Echo a translated sprintf() string (mix yourls__() and sprintf() in one func)
- *
- * Instead of doing printf( yourls__( 'string %s' ), $arg ) you can simply use:
- * yourls_se( 'string %s', $arg )
- * This function accepts an arbitrary number of arguments:
- * - first one will be the string to translate, eg "hello %s my name is %s"
- * - following ones will be the sprintf arguments, eg "world" and "Ozh"
- * - if there are more arguments passed than needed, the last one will be used as the translation domain
- *
- * @see yourls_s()
- * @see sprintf()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $arg1, $arg2... Optional: sprintf tokens, and translation domain
- * @return string Translated text
- */
-function yourls_se( $pattern ) {
- echo yourls_s( func_get_args() );
-}
-
-
-/**
- * Retrieves the translation of $text and escapes it for safe use in an attribute.
- * If there is no translation, or the domain isn't loaded, the original text is returned.
- *
- * @see yourls_translate() An alias of yourls_translate()
- * @see yourls_esc_attr()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $domain Optional. Domain to retrieve the translated text
- * @return string Translated text
- */
-function yourls_esc_attr__( $text, $domain = 'default' ) {
- return yourls_esc_attr( yourls_translate( $text, $domain ) );
-}
-
-/**
- * Retrieves the translation of $text and escapes it for safe use in HTML output.
- * If there is no translation, or the domain isn't loaded, the original text is returned.
- *
- * @see yourls_translate() An alias of yourls_translate()
- * @see yourls_esc_html()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $domain Optional. Domain to retrieve the translated text
- * @return string Translated text
- */
-function yourls_esc_html__( $text, $domain = 'default' ) {
- return yourls_esc_html( yourls_translate( $text, $domain ) );
-}
-
-/**
- * Displays the returned translated text from yourls_translate().
- *
- * @see yourls_translate() Echoes returned yourls_translate() string
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $domain Optional. Domain to retrieve the translated text
- */
-function yourls_e( $text, $domain = 'default' ) {
- echo yourls_translate( $text, $domain );
-}
-
-/**
- * Displays translated text that has been escaped for safe use in an attribute.
- *
- * @see yourls_translate() Echoes returned yourls_translate() string
- * @see yourls_esc_attr()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $domain Optional. Domain to retrieve the translated text
- */
-function yourls_esc_attr_e( $text, $domain = 'default' ) {
- echo yourls_esc_attr( yourls_translate( $text, $domain ) );
-}
-
-/**
- * Displays translated text that has been escaped for safe use in HTML output.
- *
- * @see yourls_translate() Echoes returned yourls_translate() string
- * @see yourls_esc_html()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $domain Optional. Domain to retrieve the translated text
- */
-function yourls_esc_html_e( $text, $domain = 'default' ) {
- echo yourls_esc_html( yourls_translate( $text, $domain ) );
-}
-
-/**
- * Retrieve translated string with gettext context
- *
- * Quite a few times, there will be collisions with similar translatable text
- * found in more than two places but with different translated context.
- *
- * By including the context in the pot file translators can translate the two
- * strings differently.
- *
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $context Context information for the translators
- * @param string $domain Optional. Domain to retrieve the translated text
- * @return string Translated context string without pipe
- */
-function yourls_x( $text, $context, $domain = 'default' ) {
- return yourls_translate_with_context( $text, $context, $domain );
-}
-
-/**
- * Displays translated string with gettext context
- *
- * @see yourls_x()
- * @since 1.6
- *
- * @param string $text Text to translate
- * @param string $context Context information for the translators
- * @param string $domain Optional. Domain to retrieve the translated text
- * @return string Translated context string without pipe
- */
-function yourls_ex( $text, $context, $domain = 'default' ) {
- echo yourls_x( $text, $context, $domain );
-}
-
-
-/**
- * Return translated text, with context, that has been escaped for safe use in an attribute
- *
- * @see yourls_translate() Return returned yourls_translate() string
- * @see yourls_esc_attr()
- * @see yourls_x()
- * @since 1.6
- *
- * @param string $single
- * @param string $context
- * @param string $domain Optional. Domain to retrieve the translated text
- * @internal param string $text Text to translate
- * @return string
- */
-function yourls_esc_attr_x( $single, $context, $domain = 'default' ) {
- return yourls_esc_attr( yourls_translate_with_context( $single, $context, $domain ) );
-}
-
-/**
- * Return translated text, with context, that has been escaped for safe use in HTML output
- *
- * @see yourls_translate() Return returned yourls_translate() string
- * @see yourls_esc_attr()
- * @see yourls_x()
- * @since 1.6
- *
- * @param string $single
- * @param string $context
- * @param string $domain Optional. Domain to retrieve the translated text
- * @internal param string $text Text to translate
- * @return string
- */
-function yourls_esc_html_x( $single, $context, $domain = 'default' ) {
- return yourls_esc_html( yourls_translate_with_context( $single, $context, $domain ) );
-}
-
-/**
- * Retrieve the plural or single form based on the amount.
- *
- * If the domain is not set in the $yourls_l10n list, then a comparison will be made
- * and either $plural or $single parameters returned.
- *
- * If the domain does exist, then the parameters $single, $plural, and $number
- * will first be passed to the domain's ngettext method. Then it will be passed
- * to the 'translate_n' filter hook along with the same parameters. The expected
- * type will be a string.
- *
- * @since 1.6
- * @uses $yourls_l10n Gets list of domain translated string (gettext_reader) objects
- * @uses yourls_apply_filters() Calls 'translate_n' hook on domains text returned,
- * along with $single, $plural, and $number parameters. Expected to return string.
- *
- * @param string $single The text that will be used if $number is 1
- * @param string $plural The text that will be used if $number is not 1
- * @param int $number The number to compare against to use either $single or $plural
- * @param string $domain Optional. The domain identifier the text should be retrieved in
- * @return string Either $single or $plural translated text
- */
-function yourls_n( $single, $plural, $number, $domain = 'default' ) {
- $translations = yourls_get_translations_for_domain( $domain );
- $translation = $translations->translate_plural( $single, $plural, $number );
- return yourls_apply_filters( 'translate_n', $translation, $single, $plural, $number, $domain );
-}
-
-/**
- * A hybrid of yourls_n() and yourls_x(). It supports contexts and plurals.
- *
- * @since 1.6
- * @see yourls_n()
- * @see yourls_x()
- *
- */
-function yourls_nx($single, $plural, $number, $context, $domain = 'default') {
- $translations = yourls_get_translations_for_domain( $domain );
- $translation = $translations->translate_plural( $single, $plural, $number, $context );
- return yourls_apply_filters( 'translate_nx', $translation, $single, $plural, $number, $context, $domain );
-}
-
-/**
- * Register plural strings in POT file, but don't translate them.
- *
- * Used when you want to keep structures with translatable plural strings and
- * use them later.
- *
- * Example:
- * $messages = array(
- * 'post' => yourls_n_noop('%s post', '%s posts'),
- * 'page' => yourls_n_noop('%s pages', '%s pages')
- * );
- * ...
- * $message = $messages[$type];
- * $usable_text = sprintf( yourls_translate_nooped_plural( $message, $count ), $count );
- *
- * @since 1.6
- * @param string $singular Single form to be i18ned
- * @param string $plural Plural form to be i18ned
- * @param string $domain Optional. The domain identifier the text will be retrieved in
- * @return array array($singular, $plural)
- */
-function yourls_n_noop( $singular, $plural, $domain = null ) {
- return array(
- 0 => $singular,
- 1 => $plural,
- 'singular' => $singular,
- 'plural' => $plural,
- 'context' => null,
- 'domain' => $domain
- );
-}
-
-/**
- * Register plural strings with context in POT file, but don't translate them.
- *
- * @since 1.6
- * @see yourls_n_noop()
- */
-function yourls_nx_noop( $singular, $plural, $context, $domain = null ) {
- return array(
- 0 => $singular,
- 1 => $plural,
- 2 => $context,
- 'singular' => $singular,
- 'plural' => $plural,
- 'context' => $context,
- 'domain' => $domain
- );
-}
-
-/**
- * Translate the result of yourls_n_noop() or yourls_nx_noop()
- *
- * @since 1.6
- * @param array $nooped_plural Array with singular, plural and context keys, usually the result of yourls_n_noop() or yourls_nx_noop()
- * @param int $count Number of objects
- * @param string $domain Optional. The domain identifier the text should be retrieved in. If $nooped_plural contains
- * a domain passed to yourls_n_noop() or yourls_nx_noop(), it will override this value.
- * @return string
- */
-function yourls_translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
- if ( $nooped_plural['domain'] )
- $domain = $nooped_plural['domain'];
-
- if ( $nooped_plural['context'] )
- return yourls_nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
- else
- return yourls_n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
-}
-
-/**
- * Loads a MO file into the domain $domain.
- *
- * If the domain already exists, the translations will be merged. If both
- * sets have the same string, the translation from the original value will be taken.
- *
- * On success, the .mo file will be placed in the $yourls_l10n global by $domain
- * and will be a MO object.
- *
- * @since 1.6
- * @uses $yourls_l10n Gets list of domain translated string objects
- *
- * @param string $domain Unique identifier for retrieving translated strings
- * @param string $mofile Path to the .mo file
- * @return bool True on success, false on failure
- */
-function yourls_load_textdomain( $domain, $mofile ) {
- global $yourls_l10n;
-
- $plugin_override = yourls_apply_filters( 'override_load_textdomain', false, $domain, $mofile );
-
- if ( true == $plugin_override ) {
- return true;
- }
-
- yourls_do_action( 'load_textdomain', $domain, $mofile );
-
- $mofile = yourls_apply_filters( 'load_textdomain_mofile', $mofile, $domain );
-
- if ( !is_readable( $mofile ) ) return false;
-
- $mo = new MO();
- if ( !$mo->import_from_file( $mofile ) ) return false;
-
- if ( isset( $yourls_l10n[$domain] ) )
- $mo->merge_with( $yourls_l10n[$domain] );
-
- $yourls_l10n[$domain] = &$mo;
-
- return true;
-}
-
-/**
- * Unloads translations for a domain
- *
- * @since 1.6
- * @param string $domain Textdomain to be unloaded
- * @return bool Whether textdomain was unloaded
- */
-function yourls_unload_textdomain( $domain ) {
- global $yourls_l10n;
-
- $plugin_override = yourls_apply_filters( 'override_unload_textdomain', false, $domain );
-
- if ( $plugin_override )
- return true;
-
- yourls_do_action( 'unload_textdomain', $domain );
-
- if ( isset( $yourls_l10n[$domain] ) ) {
- unset( $yourls_l10n[$domain] );
- return true;
- }
-
- return false;
-}
-
-/**
- * Loads default translated strings based on locale.
- *
- * Loads the .mo file in YOURLS_LANG_DIR constant path from YOURLS root. The
- * translated (.mo) file is named based on the locale.
- *
- * @since 1.6
- * @return bool True on success, false on failure
- */
-function yourls_load_default_textdomain() {
- $yourls_locale = yourls_get_locale();
-
- return yourls_load_textdomain( 'default', YOURLS_LANG_DIR . "/$yourls_locale.mo" );
-
-}
-
-/**
- * Returns the Translations instance for a domain. If there isn't one,
- * returns empty Translations instance.
- *
- * @param string $domain
- * @return object A Translation instance
- */
-function yourls_get_translations_for_domain( $domain ) {
- global $yourls_l10n;
- if ( !isset( $yourls_l10n[$domain] ) ) {
- $yourls_l10n[$domain] = new NOOP_Translations;
- }
- return $yourls_l10n[$domain];
-}
-
-/**
- * Whether there are translations for the domain
- *
- * @since 1.6
- * @param string $domain
- * @return bool Whether there are translations
- */
-function yourls_is_textdomain_loaded( $domain ) {
- global $yourls_l10n;
- return isset( $yourls_l10n[$domain] );
-}
-
-/**
- * Translates role name. Unused.
- *
- * Unused function for the moment, we'll see when there are roles.
- * From the WP source: Since the role names are in the database and
- * not in the source there are dummy gettext calls to get them into the POT
- * file and this function properly translates them back.
- *
- * @since 1.6
- */
-function yourls_translate_user_role( $name ) {
- return yourls_translate_with_context( $name, 'User role' );
-}
-
-/**
- * Get all available languages (*.mo files) in a given directory. The default directory is YOURLS_LANG_DIR.
- *
- * @since 1.6
- *
- * @param string $dir A directory in which to search for language files. The default directory is YOURLS_LANG_DIR.
- * @return array Array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.
- */
-function yourls_get_available_languages( $dir = null ) {
- $languages = array();
-
- $dir = is_null( $dir) ? YOURLS_LANG_DIR : $dir;
-
- foreach( (array) glob( $dir . '/*.mo' ) as $lang_file ) {
- $languages[] = basename( $lang_file, '.mo' );
- }
-
- return yourls_apply_filters( 'get_available_languages', $languages );
-}
-
-/**
- * Return integer number to format based on the locale.
- *
- * @since 1.6
- *
- * @param int $number The number to convert based on locale.
- * @param int $decimals Precision of the number of decimal places.
- * @return string Converted number in string format.
- */
-function yourls_number_format_i18n( $number, $decimals = 0 ) {
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- $formatted = number_format( $number, abs( intval( $decimals ) ), $yourls_locale_formats->number_format['decimal_point'], $yourls_locale_formats->number_format['thousands_sep'] );
- return yourls_apply_filters( 'number_format_i18n', $formatted );
-}
-
-/**
- * Return the date in localized format, based on timestamp.
- *
- * If the locale specifies the locale month and weekday, then the locale will
- * take over the format for the date. If it isn't, then the date format string
- * will be used instead.
- *
- * @since 1.6
- *
- * @param string $dateformatstring Format to display the date.
- * @param bool|int $unixtimestamp Optional. Unix timestamp.
- * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
- * @return string The date, translated if locale specifies it.
- */
-function yourls_date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- $i = $unixtimestamp;
-
- if ( false === $i ) {
- if ( ! $gmt )
- $i = yourls_current_time( 'timestamp' );
- else
- $i = time();
- // we should not let date() interfere with our
- // specially computed timestamp
- $gmt = true;
- }
-
- // store original value for language with untypical grammars
- // see http://core.trac.wordpress.org/ticket/9396
- $req_format = $dateformatstring;
-
- $datefunc = $gmt? 'gmdate' : 'date';
-
- if ( ( !empty( $yourls_locale_formats->month ) ) && ( !empty( $yourls_locale_formats->weekday ) ) ) {
- $datemonth = $yourls_locale_formats->get_month( $datefunc( 'm', $i ) );
- $datemonth_abbrev = $yourls_locale_formats->get_month_abbrev( $datemonth );
- $dateweekday = $yourls_locale_formats->get_weekday( $datefunc( 'w', $i ) );
- $dateweekday_abbrev = $yourls_locale_formats->get_weekday_abbrev( $dateweekday );
- $datemeridiem = $yourls_locale_formats->get_meridiem( $datefunc( 'a', $i ) );
- $datemeridiem_capital = $yourls_locale_formats->get_meridiem( $datefunc( 'A', $i ) );
-
- $dateformatstring = ' '.$dateformatstring;
- $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . yourls_backslashit( $dateweekday_abbrev ), $dateformatstring );
- $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . yourls_backslashit( $datemonth ), $dateformatstring );
- $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . yourls_backslashit( $dateweekday ), $dateformatstring );
- $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . yourls_backslashit( $datemonth_abbrev ), $dateformatstring );
- $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . yourls_backslashit( $datemeridiem ), $dateformatstring );
- $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . yourls_backslashit( $datemeridiem_capital ), $dateformatstring );
-
- $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
- }
- $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
- $timezone_formats_re = implode( '|', $timezone_formats );
- if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
-
- // TODO: implement a timezone option
- $timezone_string = yourls_get_option( 'timezone_string' );
- if ( $timezone_string ) {
- $timezone_object = timezone_open( $timezone_string );
- $date_object = date_create( null, $timezone_object );
- foreach( $timezone_formats as $timezone_format ) {
- if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
- $formatted = date_format( $date_object, $timezone_format );
- $dateformatstring = ' '.$dateformatstring;
- $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . yourls_backslashit( $formatted ), $dateformatstring );
- $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
- }
- }
- }
- }
- $j = @$datefunc( $dateformatstring, $i );
- // allow plugins to redo this entirely for languages with untypical grammars
- $j = yourls_apply_filters('date_i18n', $j, $req_format, $i, $gmt);
- return $j;
-}
-
-/**
- * Retrieve the current time based on specified type. Stolen from WP.
- *
- * The 'mysql' type will return the time in the format for MySQL DATETIME field.
- * The 'timestamp' type will return the current timestamp.
- *
- * If $gmt is set to either '1' or 'true', then both types will use GMT time.
- * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
- *
- * @since 1.6
- *
- * @param string $type Either 'mysql' or 'timestamp'.
- * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false.
- * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
- */
-function yourls_current_time( $type, $gmt = 0 ) {
- switch ( $type ) {
- case 'mysql':
- return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', time() + YOURLS_HOURS_OFFSET * 3600 );
- break;
- case 'timestamp':
- return ( $gmt ) ? time() : time() + YOURLS_HOURS_OFFSET * 3600;
- break;
- }
-}
-
-
-/**
- * Class that loads the calendar locale.
- *
- * @since 1.6
- */
-class YOURLS_Locale_Formats {
- /**
- * Stores the translated strings for the full weekday names.
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $weekday;
-
- /**
- * Stores the translated strings for the one character weekday names.
- *
- * There is a hack to make sure that Tuesday and Thursday, as well
- * as Sunday and Saturday, don't conflict. See init() method for more.
- *
- * @see YOURLS_Locale_Formats::init() for how to handle the hack.
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $weekday_initial;
-
- /**
- * Stores the translated strings for the abbreviated weekday names.
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $weekday_abbrev;
-
- /**
- * Stores the translated strings for the full month names.
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $month;
-
- /**
- * Stores the translated strings for the abbreviated month names.
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $month_abbrev;
-
- /**
- * Stores the translated strings for 'am' and 'pm'.
- *
- * Also the capitalized versions.
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $meridiem;
-
- /**
- * Stores the translated number format
- *
- * @since 1.6
- * @var array
- * @access private
- */
- var $number_format;
-
- /**
- * The text direction of the locale language.
- *
- * Default is left to right 'ltr'.
- *
- * @since 1.6
- * @var string
- * @access private
- */
- var $text_direction = 'ltr';
-
- /**
- * Sets up the translated strings and object properties.
- *
- * The method creates the translatable strings for various
- * calendar elements. Which allows for specifying locale
- * specific calendar names and text direction.
- *
- * @since 1.6
- * @access private
- */
- function init() {
- // The Weekdays
- $this->weekday[0] = /* //translators: weekday */ yourls__( 'Sunday' );
- $this->weekday[1] = /* //translators: weekday */ yourls__( 'Monday' );
- $this->weekday[2] = /* //translators: weekday */ yourls__( 'Tuesday' );
- $this->weekday[3] = /* //translators: weekday */ yourls__( 'Wednesday' );
- $this->weekday[4] = /* //translators: weekday */ yourls__( 'Thursday' );
- $this->weekday[5] = /* //translators: weekday */ yourls__( 'Friday' );
- $this->weekday[6] = /* //translators: weekday */ yourls__( 'Saturday' );
-
- // The first letter of each day. The _%day%_initial suffix is a hack to make
- // sure the day initials are unique.
- $this->weekday_initial[yourls__( 'Sunday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'S_Sunday_initial' );
- $this->weekday_initial[yourls__( 'Monday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'M_Monday_initial' );
- $this->weekday_initial[yourls__( 'Tuesday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'T_Tuesday_initial' );
- $this->weekday_initial[yourls__( 'Wednesday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'W_Wednesday_initial' );
- $this->weekday_initial[yourls__( 'Thursday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'T_Thursday_initial' );
- $this->weekday_initial[yourls__( 'Friday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'F_Friday_initial' );
- $this->weekday_initial[yourls__( 'Saturday' )] = /* //translators: one-letter abbreviation of the weekday */ yourls__( 'S_Saturday_initial' );
-
- foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
- $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
- }
-
- // Abbreviations for each day.
- $this->weekday_abbrev[ yourls__( 'Sunday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Sun' );
- $this->weekday_abbrev[ yourls__( 'Monday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Mon' );
- $this->weekday_abbrev[ yourls__( 'Tuesday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Tue' );
- $this->weekday_abbrev[ yourls__( 'Wednesday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Wed' );
- $this->weekday_abbrev[ yourls__( 'Thursday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Thu' );
- $this->weekday_abbrev[ yourls__( 'Friday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Fri' );
- $this->weekday_abbrev[ yourls__( 'Saturday' ) ] = /* //translators: three-letter abbreviation of the weekday */ yourls__( 'Sat' );
-
- // The Months
- $this->month['01'] = /* //translators: month name */ yourls__( 'January' );
- $this->month['02'] = /* //translators: month name */ yourls__( 'February' );
- $this->month['03'] = /* //translators: month name */ yourls__( 'March' );
- $this->month['04'] = /* //translators: month name */ yourls__( 'April' );
- $this->month['05'] = /* //translators: month name */ yourls__( 'May' );
- $this->month['06'] = /* //translators: month name */ yourls__( 'June' );
- $this->month['07'] = /* //translators: month name */ yourls__( 'July' );
- $this->month['08'] = /* //translators: month name */ yourls__( 'August' );
- $this->month['09'] = /* //translators: month name */ yourls__( 'September' );
- $this->month['10'] = /* //translators: month name */ yourls__( 'October' );
- $this->month['11'] = /* //translators: month name */ yourls__( 'November' );
- $this->month['12'] = /* //translators: month name */ yourls__( 'December' );
-
- // Abbreviations for each month. Uses the same hack as above to get around the
- // 'May' duplication.
- $this->month_abbrev[ yourls__( 'January' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Jan_January_abbreviation' );
- $this->month_abbrev[ yourls__( 'February' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Feb_February_abbreviation' );
- $this->month_abbrev[ yourls__( 'March' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Mar_March_abbreviation' );
- $this->month_abbrev[ yourls__( 'April' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Apr_April_abbreviation' );
- $this->month_abbrev[ yourls__( 'May' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'May_May_abbreviation' );
- $this->month_abbrev[ yourls__( 'June' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Jun_June_abbreviation' );
- $this->month_abbrev[ yourls__( 'July' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Jul_July_abbreviation' );
- $this->month_abbrev[ yourls__( 'August' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Aug_August_abbreviation' );
- $this->month_abbrev[ yourls__( 'September' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Sep_September_abbreviation' );
- $this->month_abbrev[ yourls__( 'October' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Oct_October_abbreviation' );
- $this->month_abbrev[ yourls__( 'November' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Nov_November_abbreviation' );
- $this->month_abbrev[ yourls__( 'December' ) ] = /* //translators: three-letter abbreviation of the month */ yourls__( 'Dec_December_abbreviation' );
-
- foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
- $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
- }
-
- // The Meridiems
- $this->meridiem['am'] = yourls__( 'am' );
- $this->meridiem['pm'] = yourls__( 'pm' );
- $this->meridiem['AM'] = yourls__( 'AM' );
- $this->meridiem['PM'] = yourls__( 'PM' );
-
- // Numbers formatting
- // See http://php.net/number_format
-
- /* //translators: $thousands_sep argument for http://php.net/number_format, default is , */
- $trans = yourls__( 'number_format_thousands_sep' );
- $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
-
- /* //translators: $dec_point argument for http://php.net/number_format, default is . */
- $trans = yourls__( 'number_format_decimal_point' );
- $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
-
- // Set text direction.
- if ( isset( $GLOBALS['text_direction'] ) )
- $this->text_direction = $GLOBALS['text_direction'];
- /* //translators: 'rtl' or 'ltr'. This sets the text direction for YOURLS. */
- elseif ( 'rtl' == yourls_x( 'ltr', 'text direction' ) )
- $this->text_direction = 'rtl';
- }
-
- /**
- * Retrieve the full translated weekday word.
- *
- * Week starts on translated Sunday and can be fetched
- * by using 0 (zero). So the week starts with 0 (zero)
- * and ends on Saturday with is fetched by using 6 (six).
- *
- * @since 1.6
- * @access public
- *
- * @param int $weekday_number 0 for Sunday through 6 Saturday
- * @return string Full translated weekday
- */
- function get_weekday( $weekday_number ) {
- return $this->weekday[ $weekday_number ];
- }
-
- /**
- * Retrieve the translated weekday initial.
- *
- * The weekday initial is retrieved by the translated
- * full weekday word. When translating the weekday initial
- * pay attention to make sure that the starting letter does
- * not conflict.
- *
- * @since 1.6
- * @access public
- *
- * @param string $weekday_name
- * @return string
- */
- function get_weekday_initial( $weekday_name ) {
- return $this->weekday_initial[ $weekday_name ];
- }
-
- /**
- * Retrieve the translated weekday abbreviation.
- *
- * The weekday abbreviation is retrieved by the translated
- * full weekday word.
- *
- * @since 1.6
- * @access public
- *
- * @param string $weekday_name Full translated weekday word
- * @return string Translated weekday abbreviation
- */
- function get_weekday_abbrev( $weekday_name ) {
- return $this->weekday_abbrev[ $weekday_name ];
- }
-
- /**
- * Retrieve the full translated month by month number.
- *
- * The $month_number parameter has to be a string
- * because it must have the '0' in front of any number
- * that is less than 10. Starts from '01' and ends at
- * '12'.
- *
- * You can use an integer instead and it will add the
- * '0' before the numbers less than 10 for you.
- *
- * @since 1.6
- * @access public
- *
- * @param string|int $month_number '01' through '12'
- * @return string Translated full month name
- */
- function get_month( $month_number ) {
- return $this->month[ sprintf( '%02s', $month_number ) ];
- }
-
- /**
- * Retrieve translated version of month abbreviation string.
- *
- * The $month_name parameter is expected to be the translated or
- * translatable version of the month.
- *
- * @since 1.6
- * @access public
- *
- * @param string $month_name Translated month to get abbreviated version
- * @return string Translated abbreviated month
- */
- function get_month_abbrev( $month_name ) {
- return $this->month_abbrev[ $month_name ];
- }
-
- /**
- * Retrieve translated version of meridiem string.
- *
- * The $meridiem parameter is expected to not be translated.
- *
- * @since 1.6
- * @access public
- *
- * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version.
- * @return string Translated version
- */
- function get_meridiem( $meridiem ) {
- return $this->meridiem[ $meridiem ];
- }
-
- /**
- * Global variables are deprecated. For backwards compatibility only.
- *
- * @deprecated For backwards compatibility only.
- * @access private
- *
- * @since 1.6
- */
- function register_globals() {
- $GLOBALS['weekday'] = $this->weekday;
- $GLOBALS['weekday_initial'] = $this->weekday_initial;
- $GLOBALS['weekday_abbrev'] = $this->weekday_abbrev;
- $GLOBALS['month'] = $this->month;
- $GLOBALS['month_abbrev'] = $this->month_abbrev;
- }
-
- /**
- * Constructor which calls helper methods to set up object variables
- *
- * @uses YOURLS_Locale_Formats::init()
- * @uses YOURLS_Locale_Formats::register_globals()
- * @since 1.6
- *
- * @return YOURLS_Locale_Formats
- */
- function __construct() {
- $this->init();
- $this->register_globals();
- }
-
- /**
- * Checks if current locale is RTL.
- *
- * @since 1.6
- * @return bool Whether locale is RTL.
- */
- function is_rtl() {
- return 'rtl' == $this->text_direction;
- }
-}
-
-/**
- * Loads a custom translation file (for a plugin, a theme, a public interface...)
- *
- * The .mo file should be named based on the domain with a dash, and then the locale exactly,
- * eg 'myplugin-pt_BR.mo'
- *
- * @since 1.6
- *
- * @param string $domain Unique identifier (the "domain") for retrieving translated strings
- * @param string $path Full path to directory containing MO files.
- * @return bool True on success, false on failure
- */
-function yourls_load_custom_textdomain( $domain, $path ) {
- $locale = yourls_apply_filters( 'load_custom_textdomain', yourls_get_locale(), $domain );
- $mofile = trim( $path, '/' ) . '/'. $domain . '-' . $locale . '.mo';
-
- return yourls_load_textdomain( $domain, $mofile );
-}
-
-/**
- * Checks if current locale is RTL. Stolen from WP.
- *
- * @since 1.6
- * @return bool Whether locale is RTL.
- */
-function yourls_is_rtl() {
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- return $yourls_locale_formats->is_rtl();
-}
-
-/**
- * Return translated weekday abbreviation (3 letters, eg 'Fri' for 'Friday')
- *
- * The $weekday var can be a textual string ('Friday'), a integer (0 to 6) or an empty string
- * If $weekday is an empty string, the function returns an array of all translated weekday abbrev
- *
- * @since 1.6
- * @param mixed $weekday A full textual weekday, eg "Friday", or an integer (0 = Sunday, 1 = Monday, .. 6 = Saturday)
- * @return mixed Translated weekday abbreviation, eg "Ven" (abbrev of "Vendredi") for "Friday" or 5, or array of all weekday abbrev
- */
-function yourls_l10n_weekday_abbrev( $weekday = '' ){
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- if( $weekday === '' )
- return $yourls_locale_formats->weekday_abbrev;
-
- if( is_int( $weekday ) ) {
- $day = $yourls_locale_formats->weekday[ $weekday ];
- return $yourls_locale_formats->weekday_abbrev[ $day ];
- } else {
- return $yourls_locale_formats->weekday_abbrev[ yourls__( $weekday ) ];
- }
-}
-
-/**
- * Return translated weekday initial (1 letter, eg 'F' for 'Friday')
- *
- * The $weekday var can be a textual string ('Friday'), a integer (0 to 6) or an empty string
- * If $weekday is an empty string, the function returns an array of all translated weekday initials
- *
- * @since 1.6
- * @param mixed $weekday A full textual weekday, eg "Friday", an integer (0 = Sunday, 1 = Monday, .. 6 = Saturday) or empty string
- * @return mixed Translated weekday initial, eg "V" (initial of "Vendredi") for "Friday" or 5, or array of all weekday initials
- */
-function yourls_l10n_weekday_initial( $weekday = '' ){
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- if( $weekday === '' )
- return $yourls_locale_formats->weekday_initial;
-
- if( is_int( $weekday ) ) {
- $weekday = $yourls_locale_formats->weekday[ $weekday ];
- return $yourls_locale_formats->weekday_initial[ $weekday ];
- } else {
- return $yourls_locale_formats->weekday_initial[ yourls__( $weekday ) ];
- }
-}
-
-/**
- * Return translated month abbrevation (3 letters, eg 'Nov' for 'November')
- *
- * The $month var can be a textual string ('November'), a integer (1 to 12), a two digits strings ('01' to '12), or an empty string
- * If $month is an empty string, the function returns an array of all translated abbrev months ('January' => 'Jan', ...)
- *
- * @since 1.6
- * @param mixed $month Empty string, a full textual weekday, eg "November", or an integer (1 = January, .., 12 = December)
- * @return mixed Translated month abbrev (eg "Nov"), or array of all translated abbrev months
- */
-function yourls_l10n_month_abbrev( $month = '' ){
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- if( $month === '' )
- return $yourls_locale_formats->month_abbrev;
-
- if( intval( $month ) > 0 ) {
- $month = $yourls_locale_formats->month[ $month ];
- return $yourls_locale_formats->month_abbrev[ $month ];
- } else {
- return $yourls_locale_formats->month_abbrev[ yourls__( $month ) ];
- }
-}
-
-/**
- * Return array of all translated months
- *
- * @since 1.6
- * @return array Array of all translated months
- */
-function yourls_l10n_months(){
- global $yourls_locale_formats;
- if( !isset( $yourls_locale_formats ) )
- $yourls_locale_formats = new YOURLS_Locale_Formats();
-
- return $yourls_locale_formats->month;
-}
diff --git a/sources/includes/functions-plugins.php b/sources/includes/functions-plugins.php
deleted file mode 100644
index 2a5c0eb..0000000
--- a/sources/includes/functions-plugins.php
+++ /dev/null
@@ -1,581 +0,0 @@
- $function_name,
- 'accepted_args' => $accepted_args,
- 'type' => $type,
- );
-}
-
-/**
- * Hooks a function on to a specific action.
- *
- * Actions are the hooks that YOURLS launches at specific points
- * during execution, or when specific events occur. Plugins can specify that
- * one or more of its PHP functions are executed at these points, using the
- * Action API.
- *
- * @param string $hook The name of the action to which the $function_to_add is hooked.
- * @param callback $function_name The name of the function you wish to be called.
- * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
- * @param int $accepted_args optional. The number of arguments the function accept (default 1).
- */
-function yourls_add_action( $hook, $function_name, $priority = 10, $accepted_args = 1 ) {
- return yourls_add_filter( $hook, $function_name, $priority, $accepted_args, 'action' );
-}
-
-
-
-/**
- * Build Unique ID for storage and retrieval.
- *
- * Simply using a function name is not enough, as several functions can have the same name when they are enclosed in classes.
- *
- * @global array $yourls_filters storage for all of the filters
- * @param string $hook hook to which the function is attached
- * @param string|array $function used for creating unique id
- * @param int|bool $priority used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
- * @return string unique ID for usage as array key
- */
-function yourls_filter_unique_id( $hook, $function, $priority ) {
- global $yourls_filters;
-
- // If function then just skip all of the tests and not overwrite the following.
- if ( is_string( $function ) )
- return $function;
- // Object Class Calling
- else if ( is_object( $function[0] ) ) {
- $obj_idx = get_class( $function[0] ) . $function[1];
- if ( !isset( $function[0]->_yourls_filters_id ) ) {
- if ( false === $priority )
- return false;
- $count = isset( $yourls_filters[ $hook ][ $priority ]) ? count( (array)$yourls_filters[ $hook ][ $priority ] ) : 0;
- $function[0]->_yourls_filters_id = $count;
- $obj_idx .= $count;
- unset( $count );
- } else
- $obj_idx .= $function[0]->_yourls_filters_id;
- return $obj_idx;
- }
- // Static Calling
- else if ( is_string( $function[0] ) )
- return $function[0].$function[1];
-
-}
-
-/**
- * Performs a filtering operation on a YOURLS element or event.
- *
- * Typical use:
- *
- * 1) Modify a variable if a function is attached to hook 'yourls_hook'
- * $yourls_var = "default value";
- * $yourls_var = yourls_apply_filter( 'yourls_hook', $yourls_var );
- *
- * 2) Trigger functions is attached to event 'yourls_event'
- * yourls_apply_filter( 'yourls_event' );
- * (see yourls_do_action() )
- *
- * Returns an element which may have been filtered by a filter.
- *
- * @global array $yourls_filters storage for all of the filters
- * @param string $hook the name of the YOURLS element or action
- * @param mixed $value the value of the element before filtering
- * @return mixed
- */
-function yourls_apply_filter( $hook, $value = '' ) {
- global $yourls_filters;
- if ( !isset( $yourls_filters[ $hook ] ) )
- return $value;
-
- $args = func_get_args();
-
- // Sort filters by priority
- ksort( $yourls_filters[ $hook ] );
-
- // Loops through each filter
- reset( $yourls_filters[ $hook ] );
- do {
- foreach( (array) current( $yourls_filters[ $hook ] ) as $the_ ) {
- if ( !is_null( $the_['function'] ) ){
- $args[1] = $value;
- $count = $the_['accepted_args'];
- if ( is_null( $count ) ) {
- $_value = call_user_func_array( $the_['function'], array_slice( $args, 1 ) );
- } else {
- $_value = call_user_func_array( $the_['function'], array_slice( $args, 1, (int) $count ) );
- }
- }
- if( $the_['type'] == 'filter' )
- $value = $_value;
- }
-
- } while ( next( $yourls_filters[ $hook ] ) !== false );
-
- if( $the_['type'] == 'filter' )
- return $value;
-}
-
-/**
- * Alias for yourls_apply_filter because I never remember if it's _filter or _filters
- *
- * Plus, semantically, it makes more sense. There can be several filters. I should have named it
- * like this from the very start. Duh.
- *
- * @since 1.6
- *
- * @param string $hook the name of the YOURLS element or action
- * @param mixed $value the value of the element before filtering
- * @return mixed
- */
-function yourls_apply_filters( $hook, $value = '' ) {
- return yourls_apply_filter( $hook, $value );
-}
-
-
-/**
- * Performs an action triggered by a YOURLS event.
-*
- * @param string $hook the name of the YOURLS action
- * @param mixed $arg action arguments
- */
-function yourls_do_action( $hook, $arg = '' ) {
- global $yourls_actions;
-
- // Keep track of actions that are "done"
- if ( !isset( $yourls_actions ) )
- $yourls_actions = array();
- if ( !isset( $yourls_actions[ $hook ] ) )
- $yourls_actions[ $hook ] = 1;
- else
- ++$yourls_actions[ $hook ];
-
- $args = array();
- if ( is_array( $arg ) && 1 == count( $arg ) && isset( $arg[0] ) && is_object( $arg[0] ) ) // array(&$this)
- $args[] =& $arg[0];
- else
- $args[] = $arg;
- for ( $a = 2; $a < func_num_args(); $a++ )
- $args[] = func_get_arg( $a );
-
- yourls_apply_filter( $hook, $args );
-}
-
-/**
-* Retrieve the number times an action is fired.
-*
-* @param string $hook Name of the action hook.
-* @return int The number of times action hook $hook is fired
-*/
-function yourls_did_action( $hook ) {
- global $yourls_actions;
- if ( !isset( $yourls_actions ) || !isset( $yourls_actions[ $hook ] ) )
- return 0;
- return $yourls_actions[ $hook ];
-}
-
-/**
- * Removes a function from a specified filter hook.
- *
- * This function removes a function attached to a specified filter hook. This
- * method can be used to remove default functions attached to a specific filter
- * hook and possibly replace them with a substitute.
- *
- * To remove a hook, the $function_to_remove and $priority arguments must match
- * when the hook was added.
- *
- * @global array $yourls_filters storage for all of the filters
- * @param string $hook The filter hook to which the function to be removed is hooked.
- * @param callback $function_to_remove The name of the function which should be removed.
- * @param int $priority optional. The priority of the function (default: 10).
- * @param int $accepted_args optional. The number of arguments the function accepts (default: 1).
- * @return boolean Whether the function was registered as a filter before it was removed.
- */
-function yourls_remove_filter( $hook, $function_to_remove, $priority = 10, $accepted_args = 1 ) {
- global $yourls_filters;
-
- $function_to_remove = yourls_filter_unique_id( $hook, $function_to_remove, $priority );
-
- $remove = isset( $yourls_filters[ $hook ][ $priority ][ $function_to_remove ] );
-
- if ( $remove === true ) {
- unset ( $yourls_filters[$hook][$priority][$function_to_remove] );
- if ( empty( $yourls_filters[$hook][$priority] ) )
- unset( $yourls_filters[$hook] );
- }
- return $remove;
-}
-
-
-/**
- * Check if any filter has been registered for a hook.
- *
- * @global array $yourls_filters storage for all of the filters
- * @param string $hook The name of the filter hook.
- * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
- * @return int|boolean Optionally returns the priority on that hook for the specified function.
- */
-function yourls_has_filter( $hook, $function_to_check = false ) {
- global $yourls_filters;
-
- $has = !empty( $yourls_filters[ $hook ] );
- if ( false === $function_to_check || false == $has ) {
- return $has;
- }
- if ( !$idx = yourls_filter_unique_id( $hook, $function_to_check, false ) ) {
- return false;
- }
-
- foreach ( (array) array_keys( $yourls_filters[ $hook ] ) as $priority ) {
- if ( isset( $yourls_filters[ $hook ][ $priority ][ $idx ] ) )
- return $priority;
- }
- return false;
-}
-
-function yourls_has_action( $hook, $function_to_check = false ) {
- return yourls_has_filter( $hook, $function_to_check );
-}
-
-/**
- * Return number of active plugins
- *
- * @return integer Number of activated plugins
- */
-function yourls_has_active_plugins( ) {
- global $ydb;
-
- if( !property_exists( $ydb, 'plugins' ) || !$ydb->plugins )
- $ydb->plugins = array();
-
- return count( $ydb->plugins );
-}
-
-
-/**
- * List plugins in /user/plugins
- *
- * @global object $ydb Storage of mostly everything YOURLS needs to know
- * @return array Array of [/plugindir/plugin.php]=>array('Name'=>'Ozh', 'Title'=>'Hello', )
- */
-function yourls_get_plugins( ) {
- $plugins = (array) glob( YOURLS_PLUGINDIR .'/*/plugin.php');
-
- if( !$plugins )
- return array();
-
- foreach( $plugins as $key => $plugin ) {
- $_plugin = yourls_plugin_basename( $plugin );
- $plugins[ $_plugin ] = yourls_get_plugin_data( $plugin );
- unset( $plugins[ $key ] );
- }
-
- return $plugins;
-}
-
-/**
- * Check if a plugin is active
- *
- * @param string $plugin Physical path to plugin file
- * @return bool
- */
-function yourls_is_active_plugin( $plugin ) {
- if( !yourls_has_active_plugins( ) )
- return false;
-
- global $ydb;
- $plugin = yourls_plugin_basename( $plugin );
-
- return in_array( $plugin, $ydb->plugins );
-
-}
-
-/**
- * Parse a plugin header
- *
- * @param string $file Physical path to plugin file
- * @return array Array of 'Field'=>'Value' from plugin comment header lines of the form "Field: Value"
- */
-function yourls_get_plugin_data( $file ) {
- $fp = fopen( $file, 'r' ); // assuming $file is readable, since yourls_load_plugins() filters this
- $data = fread( $fp, 8192 ); // get first 8kb
- fclose( $fp );
-
- // Capture all the header within first comment block
- if( !preg_match( '!.*?/\*(.*?)\*/!ms', $data, $matches ) )
- return array();
-
- // Capture each line with "Something: some text"
- unset( $data );
- $lines = preg_split( "[\n|\r]", $matches[1] );
- unset( $matches );
-
- $plugin_data = array();
- foreach( $lines as $line ) {
- if( !preg_match( '!(.*?):\s+(.*)!', $line, $matches ) )
- continue;
-
- list( $null, $field, $value ) = array_map( 'trim', $matches);
- $plugin_data[ $field ] = $value;
- }
-
- return $plugin_data;
-}
-
-// Include active plugins
-function yourls_load_plugins() {
- // Don't load plugins when installing or updating
- if( yourls_is_installing() OR yourls_is_upgrading() )
- return;
-
- $active_plugins = yourls_get_option( 'active_plugins' );
- if( false === $active_plugins )
- return;
-
- global $ydb;
- $ydb->plugins = array();
-
- foreach( (array)$active_plugins as $key=>$plugin ) {
- if( yourls_validate_plugin_file( YOURLS_PLUGINDIR.'/'.$plugin ) ) {
- include_once( YOURLS_PLUGINDIR.'/'.$plugin );
- $ydb->plugins[] = $plugin;
- unset( $active_plugins[$key] );
- }
- }
-
- // $active_plugins should be empty now, if not, a plugin could not be find: remove it
- if( count( $active_plugins ) ) {
- yourls_update_option( 'active_plugins', $ydb->plugins );
- $message = yourls_n( 'Could not find and deactivated plugin :', 'Could not find and deactivated plugins :', count( $active_plugins ) );
- $missing = ''.join( ' , ', $active_plugins ).' ';
- yourls_add_notice( $message .' '. $missing );
- }
-}
-
-/**
- * Check if a file is safe for inclusion (well, "safe", no guarantee)
- *
- * @param string $file Full pathname to a file
- * @return bool
- */
-function yourls_validate_plugin_file( $file ) {
- if (
- false !== strpos( $file, '..' )
- OR
- false !== strpos( $file, './' )
- OR
- 'plugin.php' !== substr( $file, -10 ) // a plugin must be named 'plugin.php'
- OR
- !is_readable( $file )
- )
- return false;
-
- return true;
-}
-
-/**
- * Activate a plugin
- *
- * @param string $plugin Plugin filename (full or relative to plugins directory)
- * @return mixed string if error or true if success
- */
-function yourls_activate_plugin( $plugin ) {
- // validate file
- $plugin = yourls_plugin_basename( $plugin );
- $plugindir = yourls_sanitize_filename( YOURLS_PLUGINDIR );
- if( !yourls_validate_plugin_file( $plugindir.'/'.$plugin ) )
- return yourls__( 'Not a valid plugin file' );
-
- // check not activated already
- global $ydb;
- if( yourls_has_active_plugins() && in_array( $plugin, $ydb->plugins ) )
- return yourls__( 'Plugin already activated' );
-
- // attempt activation. TODO: uber cool fail proof sandbox like in WP.
- ob_start();
- include_once( YOURLS_PLUGINDIR.'/'.$plugin );
- if ( ob_get_length() > 0 ) {
- // there was some output: error
- $output = ob_get_clean();
- return yourls_s( 'Plugin generated unexpected output. Error was: %s ', $output );
- }
-
- // so far, so good: update active plugin list
- $ydb->plugins[] = $plugin;
- yourls_update_option( 'active_plugins', $ydb->plugins );
- yourls_do_action( 'activated_plugin', $plugin );
- yourls_do_action( 'activated_' . $plugin );
-
- return true;
-}
-
-/**
- * Deactivate a plugin
- *
- * @param string $plugin Plugin filename (full relative to plugins directory)
- * @return mixed string if error or true if success
- */
-function yourls_deactivate_plugin( $plugin ) {
- $plugin = yourls_plugin_basename( $plugin );
-
- // Check plugin is active
- if( !yourls_is_active_plugin( $plugin ) )
- return yourls__( 'Plugin not active' );
-
- // Deactivate the plugin
- global $ydb;
- $key = array_search( $plugin, $ydb->plugins );
- if( $key !== false ) {
- array_splice( $ydb->plugins, $key, 1 );
- }
-
- yourls_update_option( 'active_plugins', $ydb->plugins );
- yourls_do_action( 'deactivated_plugin', $plugin );
- yourls_do_action( 'deactivated_' . $plugin );
-
- return true;
-}
-
-/**
- * Return the path of a plugin file, relative to the plugins directory
- */
-function yourls_plugin_basename( $file ) {
- $file = yourls_sanitize_filename( $file );
- $plugindir = yourls_sanitize_filename( YOURLS_PLUGINDIR );
- $file = str_replace( $plugindir, '', $file );
- return trim( $file, '/' );
-}
-
-/**
- * Return the URL of the directory a plugin
- */
-function yourls_plugin_url( $file ) {
- $url = YOURLS_PLUGINURL . '/' . yourls_plugin_basename( $file );
- if( yourls_is_ssl() or yourls_needs_ssl() )
- $url = str_replace( 'http://', 'https://', $url );
- return yourls_apply_filter( 'plugin_url', $url, $file );
-}
-
-/**
- * Display list of links to plugin admin pages, if any
- */
-function yourls_list_plugin_admin_pages() {
- global $ydb;
-
- if( !property_exists( $ydb, 'plugin_pages' ) || !$ydb->plugin_pages )
- return;
-
- $plugin_links = array();
- foreach( (array)$ydb->plugin_pages as $plugin => $page ) {
- $plugin_links[ $plugin ] = array(
- 'url' => yourls_admin_url( 'plugins.php?page='.$page['slug'] ),
- 'anchor' => $page['title'],
- );
- }
- return $plugin_links;
-}
-
-/**
- * Register a plugin administration page
- */
-function yourls_register_plugin_page( $slug, $title, $function ) {
- global $ydb;
-
- if( !property_exists( $ydb, 'plugin_pages' ) || !$ydb->plugin_pages )
- $ydb->plugin_pages = array();
-
- $ydb->plugin_pages[ $slug ] = array(
- 'slug' => $slug,
- 'title' => $title,
- 'function' => $function,
- );
-}
-
-/**
- * Handle plugin administration page
- *
- */
-function yourls_plugin_admin_page( $plugin_page ) {
- global $ydb;
-
- // Check the plugin page is actually registered
- if( !isset( $ydb->plugin_pages[$plugin_page] ) ) {
- yourls_die( yourls__( 'This page does not exist. Maybe a plugin you thought was activated is inactive?' ), yourls__( 'Invalid link' ) );
- }
-
- // Draw the page itself
- yourls_do_action( 'load-' . $plugin_page);
- yourls_html_head( 'plugin_page_' . $plugin_page, $ydb->plugin_pages[$plugin_page]['title'] );
- yourls_html_logo();
- yourls_html_menu();
-
- call_user_func( $ydb->plugin_pages[$plugin_page]['function'] );
-
- yourls_html_footer();
-
- die();
-}
-
-
-/**
- * Callback function: Sort plugins
- *
- * @link http://php.net/uasort
- *
- * @param array $plugin_a
- * @param array $plugin_b
- * @return int 0, 1 or -1, see uasort()
- */
-function yourls_plugins_sort_callback( $plugin_a, $plugin_b ) {
- $orderby = yourls_apply_filters( 'plugins_sort_callback', 'Plugin Name' );
- $order = yourls_apply_filters( 'plugins_sort_callback', 'ASC' );
-
- $a = $plugin_a[$orderby];
- $b = $plugin_b[$orderby];
-
- if ( $a == $b )
- return 0;
-
- if ( 'DESC' == $order )
- return ( $a < $b ) ? 1 : -1;
- else
- return ( $a < $b ) ? -1 : 1;
-}
diff --git a/sources/includes/functions-upgrade.php b/sources/includes/functions-upgrade.php
deleted file mode 100644
index 0cdd5f1..0000000
--- a/sources/includes/functions-upgrade.php
+++ /dev/null
@@ -1,348 +0,0 @@
-query( $sql );
- echo "Updating table structure. Please wait...
";
-}
-
-/************************** 1.4.3 -> 1.5 **************************/
-
-/**
- * Main func for upgrade from 1.4.3 to 1.5
- *
- */
-function yourls_upgrade_to_15( ) {
- // Create empty 'active_plugins' entry in the option if needed
- if( yourls_get_option( 'active_plugins' ) === false )
- yourls_add_option( 'active_plugins', array() );
- echo "Enabling the plugin API. Please wait...
";
-
- // Alter URL table to store titles
- global $ydb;
- $table_url = YOURLS_DB_TABLE_URL;
- $sql = "ALTER TABLE `$table_url` ADD `title` TEXT AFTER `url`;";
- $ydb->query( $sql );
- echo "Updating table structure. Please wait...
";
-
- // Update .htaccess
- yourls_create_htaccess();
- echo "Updating .htaccess file. Please wait...
";
-}
-
-/************************** 1.4.1 -> 1.4.3 **************************/
-
-/**
- * Main func for upgrade from 1.4.1 to 1.4.3
- *
- */
-function yourls_upgrade_to_143( ) {
- // Check if we have 'keyword' (borked install) or 'shorturl' (ok install)
- global $ydb;
- $table_log = YOURLS_DB_TABLE_LOG;
- $sql = "SHOW COLUMNS FROM `$table_log`";
- $cols = $ydb->get_results( $sql );
- if ( $cols[2]->Field == 'keyword' ) {
- $sql = "ALTER TABLE `$table_log` CHANGE `keyword` `shorturl` VARCHAR( 200 ) BINARY;";
- $ydb->query( $sql );
- }
- echo "Structure of existing tables updated. Please wait...
";
-}
-
-/************************** 1.4 -> 1.4.1 **************************/
-
-/**
- * Main func for upgrade from 1.4 to 1.4.1
- *
- */
-function yourls_upgrade_to_141( ) {
- // Kill old cookies from 1.3 and prior
- setcookie('yourls_username', null, time() - 3600 );
- setcookie('yourls_password', null, time() - 3600 );
- // alter table URL
- yourls_alter_url_table_to_141();
- // recreate the htaccess file if needed
- yourls_create_htaccess();
-}
-
-/**
- * Alter table URL to 1.4.1
- *
- */
-function yourls_alter_url_table_to_141() {
- global $ydb;
- $table_url = YOURLS_DB_TABLE_URL;
- $alter = "ALTER TABLE `$table_url` CHANGE `keyword` `keyword` VARCHAR( 200 ) BINARY, CHANGE `url` `url` TEXT BINARY ";
- $ydb->query( $alter );
- echo "Structure of existing tables updated. Please wait...
";
-}
-
-
-/************************** 1.3 -> 1.4 **************************/
-
-/**
- * Main func for upgrade from 1.3-RC1 to 1.4
- *
- */
-function yourls_upgrade_to_14( $step ) {
-
- switch( $step ) {
- case 1:
- // create table log & table options
- // update table url structure
- // update .htaccess
- yourls_create_tables_for_14(); // no value returned, assuming it went OK
- yourls_alter_url_table_to_14(); // no value returned, assuming it went OK
- $clean = yourls_clean_htaccess_for_14(); // returns bool
- $create = yourls_create_htaccess(); // returns bool
- if ( !$create )
- echo "Please create your .htaccess file (I could not do it for you). Please refer to http://yourls.org/htaccess .";
- yourls_redirect_javascript( yourls_admin_url( "upgrade.php?step=2&oldver=1.3&newver=1.4&oldsql=100&newsql=200" ), $create );
- break;
-
- case 2:
- // convert each link in table url
- yourls_update_table_to_14();
- break;
-
- case 3:
- // update table url structure part 2: recreate indexes
- yourls_alter_url_table_to_14_part_two();
- // update version & db_version & next_id in the option table
- // attempt to drop YOURLS_DB_TABLE_NEXTDEC
- yourls_update_options_to_14();
- // Now upgrade to 1.4.1
- yourls_redirect_javascript( yourls_admin_url( "upgrade.php?step=1&oldver=1.4&newver=1.4.1&oldsql=200&newsql=210" ) );
- break;
- }
-}
-
-/**
- * Update options to reflect new version
- *
- */
-function yourls_update_options_to_14() {
- yourls_update_option( 'version', '1.4' );
- yourls_update_option( 'db_version', '200' );
-
- if( defined('YOURLS_DB_TABLE_NEXTDEC') ) {
- global $ydb;
- $table = YOURLS_DB_TABLE_NEXTDEC;
- $next_id = $ydb->get_var("SELECT `next_id` FROM `$table`");
- yourls_update_option( 'next_id', $next_id );
- @$ydb->query( "DROP TABLE `$table`" );
- } else {
- yourls_update_option( 'next_id', 1 ); // In case someone mistakenly deleted the next_id constant or table too early
- }
-}
-
-/**
- * Create new tables for YOURLS 1.4: options & log
- *
- */
-function yourls_create_tables_for_14() {
- global $ydb;
-
- $queries = array();
-
- $queries[YOURLS_DB_TABLE_OPTIONS] =
- 'CREATE TABLE IF NOT EXISTS `'.YOURLS_DB_TABLE_OPTIONS.'` ('.
- '`option_id` int(11) unsigned NOT NULL auto_increment,'.
- '`option_name` varchar(64) NOT NULL default "",'.
- '`option_value` longtext NOT NULL,'.
- 'PRIMARY KEY (`option_id`,`option_name`),'.
- 'KEY `option_name` (`option_name`)'.
- ');';
-
- $queries[YOURLS_DB_TABLE_LOG] =
- 'CREATE TABLE IF NOT EXISTS `'.YOURLS_DB_TABLE_LOG.'` ('.
- '`click_id` int(11) NOT NULL auto_increment,'.
- '`click_time` datetime NOT NULL,'.
- '`shorturl` varchar(200) NOT NULL,'.
- '`referrer` varchar(200) NOT NULL,'.
- '`user_agent` varchar(255) NOT NULL,'.
- '`ip_address` varchar(41) NOT NULL,'.
- '`country_code` char(2) NOT NULL,'.
- 'PRIMARY KEY (`click_id`),'.
- 'KEY `shorturl` (`shorturl`)'.
- ');';
-
- foreach( $queries as $query ) {
- $ydb->query( $query ); // There's no result to be returned to check if table was created (except making another query to check table existence, which we'll avoid)
- }
-
- echo "
New tables created. Please wait...
";
-
-}
-
-/**
- * Alter table structure, part 1 (change schema, drop index)
- *
- */
-function yourls_alter_url_table_to_14() {
- global $ydb;
- $table = YOURLS_DB_TABLE_URL;
-
- $alters = array();
- $results = array();
- $alters[] = "ALTER TABLE `$table` CHANGE `id` `keyword` VARCHAR( 200 ) NOT NULL";
- $alters[] = "ALTER TABLE `$table` CHANGE `url` `url` TEXT NOT NULL";
- $alters[] = "ALTER TABLE `$table` DROP PRIMARY KEY";
-
- foreach ( $alters as $query ) {
- $ydb->query( $query );
- }
-
- echo "Structure of existing tables updated. Please wait...
";
-}
-
-/**
- * Alter table structure, part 2 (recreate indexes after the table is up to date)
- *
- */
-function yourls_alter_url_table_to_14_part_two() {
- global $ydb;
- $table = YOURLS_DB_TABLE_URL;
-
- $alters = array();
- $alters[] = "ALTER TABLE `$table` ADD PRIMARY KEY ( `keyword` )";
- $alters[] = "ALTER TABLE `$table` ADD INDEX ( `ip` )";
- $alters[] = "ALTER TABLE `$table` ADD INDEX ( `timestamp` )";
-
- foreach ( $alters as $query ) {
- $ydb->query( $query );
- }
-
- echo "New table index created
";
-}
-
-/**
- * Convert each link from 1.3 (id) to 1.4 (keyword) structure
- *
- */
-function yourls_update_table_to_14() {
- global $ydb;
- $table = YOURLS_DB_TABLE_URL;
-
- // Modify each link to reflect new structure
- $chunk = 45;
- $from = isset($_GET['from']) ? intval( $_GET['from'] ) : 0 ;
- $total = yourls_get_db_stats();
- $total = $total['total_links'];
-
- $sql = "SELECT `keyword`,`url` FROM `$table` WHERE 1=1 ORDER BY `url` ASC LIMIT $from, $chunk ;";
-
- $rows = $ydb->get_results($sql);
-
- $count = 0;
- $queries = 0;
- foreach( $rows as $row ) {
- $keyword = $row->keyword;
- $url = $row->url;
- $newkeyword = yourls_int2string( $keyword );
- $ydb->query("UPDATE `$table` SET `keyword` = '$newkeyword' WHERE `url` = '$url';");
- if( $ydb->result === true ) {
- $queries++;
- } else {
- echo "Huho... Could not update rown with url='$url', from keyword '$keyword' to keyword '$newkeyword'
"; // Find what went wrong :/
- }
- $count++;
- }
-
- // All done for this chunk of queries, did it all go as expected?
- $success = true;
- if( $count != $queries ) {
- $success = false;
- $num = $count - $queries;
- echo "$num error(s) occured while updating the URL table :(
";
- }
-
- if ( $count == $chunk ) {
- // there are probably other rows to convert
- $from = $from + $chunk;
- $remain = $total - $from;
- echo "Converted $chunk database rows ($remain remaining). Continuing... Please do not close this window until it's finished!
";
- yourls_redirect_javascript( yourls_admin_url( "upgrade.php?step=2&oldver=1.3&newver=1.4&oldsql=100&newsql=200&from=$from" ), $success );
- } else {
- // All done
- echo 'All rows converted! Please wait...
';
- yourls_redirect_javascript( yourls_admin_url( "upgrade.php?step=3&oldver=1.3&newver=1.4&oldsql=100&newsql=200" ), $success );
- }
-
-}
-
-/**
- * Clean .htaccess as it existed before 1.4. Returns boolean
- *
- */
-function yourls_clean_htaccess_for_14() {
- $filename = YOURLS_ABSPATH.'/.htaccess';
-
- $result = false;
- if( is_writeable( $filename ) ) {
- $contents = implode( '', file( $filename ) );
- // remove "ShortURL" block
- $contents = preg_replace( '/# BEGIN ShortURL.*# END ShortURL/s', '', $contents );
- // comment out deprecated RewriteRule
- $find = 'RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]';
- $replace = "# You can safely remove this 5 lines block -- it's no longer used in YOURLS\n".
- "# $find";
- $contents = str_replace( $find, $replace, $contents );
-
- // Write cleaned file
- $f = fopen( $filename, 'w' );
- fwrite( $f, $contents );
- fclose( $f );
-
- $result = true;
- }
-
- return $result;
-}
-
diff --git a/sources/includes/functions-xml.php b/sources/includes/functions-xml.php
deleted file mode 100644
index 1415ba4..0000000
--- a/sources/includes/functions-xml.php
+++ /dev/null
@@ -1,81 +0,0 @@
-text="";
- $this->text.= $this->array_transform($array);
- $this->text .=" ";
- return $this->text;
- }
-
- function array_transform($array){
- //global $array_text;
- foreach($array as $key => $value){
- if(!is_array($value)){
- //BEGIN code mod by Doug Vanderweide, 13 Jan 2011
- //does $value contain html entities?
- if(strlen($value) != strlen(htmlentities($value))) {
- //if so, encode as CDATA
- $value = "";
- }
- $this->text .= "<$key>$value$key>";
- //END code mod
- } else {
- $this->text.="<$key>";
- $this->array_transform($value);
- $this->text.="$key>";
- }
- }
- //return $array_text;
-
- }
- /*Transform an XML string to associative array "XML Parser Functions"*/
- function xml2array($xml){
- $this->depth=-1;
- $this->xml_parser = xml_parser_create();
- xml_set_object($this->xml_parser, $this);
- xml_parser_set_option ($this->xml_parser,XML_OPTION_CASE_FOLDING,0);//Don't put tags uppercase
- xml_set_element_handler($this->xml_parser, "startElement", "endElement");
- xml_set_character_data_handler($this->xml_parser,"characterData");
- xml_parse($this->xml_parser,$xml,true);
- xml_parser_free($this->xml_parser);
- return $this->arrays[0];
-
- }
- function startElement($parser, $name, $attrs)
- {
- $this->keys[]=$name; //We add a key
- $this->node_flag=1;
- $this->depth++;
- }
- function characterData($parser,$data)
- {
- $key=end($this->keys);
- $this->arrays[$this->depth][$key]=$data;
- $this->node_flag=0; //So that we don't add as an array, but as an element
- }
- function endElement($parser, $name)
- {
- $key=array_pop($this->keys);
- //If $node_flag==1 we add as an array, if not, as an element
- if($this->node_flag==1){
- $this->arrays[$this->depth][$key]=$this->arrays[$this->depth+1];
- unset($this->arrays[$this->depth+1]);
- }
- $this->node_flag=1;
- $this->depth--;
- }
-
-}//End of the class
-
diff --git a/sources/includes/functions.php b/sources/includes/functions.php
deleted file mode 100644
index 10dca4d..0000000
--- a/sources/includes/functions.php
+++ /dev/null
@@ -1,2256 +0,0 @@
- HTTP_X_FORWARDED_FOR > HTTP_CLIENT_IP > HTTP_VIA > REMOTE_ADDR
- $headers = array( 'X-Forwarded-For', 'HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_VIA', 'REMOTE_ADDR' );
- foreach( $headers as $header ) {
- if ( !empty( $_SERVER[ $header ] ) ) {
- $ip = $_SERVER[ $header ];
- break;
- }
- }
-
- // headers can contain multiple IPs (X-Forwarded-For = client, proxy1, proxy2). Take first one.
- if ( strpos( $ip, ',' ) !== false )
- $ip = substr( $ip, 0, strpos( $ip, ',' ) );
-
- return yourls_apply_filter( 'get_IP', yourls_sanitize_ip( $ip ) );
-}
-
-/**
- * Get next id a new link will have if no custom keyword provided
- *
- */
-function yourls_get_next_decimal() {
- return yourls_apply_filter( 'get_next_decimal', (int)yourls_get_option( 'next_id' ) );
-}
-
-/**
- * Update id for next link with no custom keyword
- *
- */
-function yourls_update_next_decimal( $int = '' ) {
- $int = ( $int == '' ) ? yourls_get_next_decimal() + 1 : (int)$int ;
- $update = yourls_update_option( 'next_id', $int );
- yourls_do_action( 'update_next_decimal', $int, $update );
- return $update;
-}
-
-/**
- * Delete a link in the DB
- *
- */
-function yourls_delete_link_by_keyword( $keyword ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_delete_link_by_keyword', null, $keyword );
- if ( null !== $pre )
- return $pre;
-
- global $ydb;
-
- $table = YOURLS_DB_TABLE_URL;
- $keyword = yourls_escape( yourls_sanitize_string( $keyword ) );
- $delete = $ydb->query("DELETE FROM `$table` WHERE `keyword` = '$keyword';");
- yourls_do_action( 'delete_link', $keyword, $delete );
- return $delete;
-}
-
-/**
- * SQL query to insert a new link in the DB. Returns boolean for success or failure of the inserting
- *
- */
-function yourls_insert_link_in_db( $url, $keyword, $title = '' ) {
- global $ydb;
-
- $url = yourls_escape( yourls_sanitize_url( $url ) );
- $keyword = yourls_escape( yourls_sanitize_keyword( $keyword ) );
- $title = yourls_escape( yourls_sanitize_title( $title ) );
-
- $table = YOURLS_DB_TABLE_URL;
- $timestamp = date('Y-m-d H:i:s');
- $ip = yourls_get_IP();
- $insert = $ydb->query("INSERT INTO `$table` (`keyword`, `url`, `title`, `timestamp`, `ip`, `clicks`) VALUES('$keyword', '$url', '$title', '$timestamp', '$ip', 0);");
-
- yourls_do_action( 'insert_link', (bool)$insert, $url, $keyword, $title, $timestamp, $ip );
-
- return (bool)$insert;
-}
-
-/**
- * Check if a URL already exists in the DB. Return NULL (doesn't exist) or an object with URL informations.
- *
- */
-function yourls_url_exists( $url ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_url_exists', false, $url );
- if ( false !== $pre )
- return $pre;
-
- global $ydb;
- $table = YOURLS_DB_TABLE_URL;
- $url = yourls_escape( yourls_sanitize_url( $url) );
- $url_exists = $ydb->get_row( "SELECT * FROM `$table` WHERE `url` = '".$url."';" );
-
- return yourls_apply_filter( 'url_exists', $url_exists, $url );
-}
-
-/**
- * Add a new link in the DB, either with custom keyword, or find one
- *
- */
-function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_add_new_link', false, $url, $keyword, $title );
- if ( false !== $pre )
- return $pre;
-
- $url = yourls_encodeURI( $url );
- $url = yourls_escape( yourls_sanitize_url( $url ) );
- if ( !$url || $url == 'http://' || $url == 'https://' ) {
- $return['status'] = 'fail';
- $return['code'] = 'error:nourl';
- $return['message'] = yourls__( 'Missing or malformed URL' );
- $return['errorCode'] = '400';
- return yourls_apply_filter( 'add_new_link_fail_nourl', $return, $url, $keyword, $title );
- }
-
- // Prevent DB flood
- $ip = yourls_get_IP();
- yourls_check_IP_flood( $ip );
-
- // Prevent internal redirection loops: cannot shorten a shortened URL
- if( yourls_get_relative_url( $url ) ) {
- if( yourls_is_shorturl( $url ) ) {
- $return['status'] = 'fail';
- $return['code'] = 'error:noloop';
- $return['message'] = yourls__( 'URL is a short URL' );
- $return['errorCode'] = '400';
- return yourls_apply_filter( 'add_new_link_fail_noloop', $return, $url, $keyword, $title );
- }
- }
-
- yourls_do_action( 'pre_add_new_link', $url, $keyword, $title );
-
- $strip_url = stripslashes( $url );
- $return = array();
-
- // duplicates allowed or new URL => store it
- if( yourls_allow_duplicate_longurls() || !( $url_exists = yourls_url_exists( $url ) ) ) {
-
- if( isset( $title ) && !empty( $title ) ) {
- $title = yourls_sanitize_title( $title );
- } else {
- $title = yourls_get_remote_title( $url );
- }
- $title = yourls_apply_filter( 'add_new_title', $title, $url, $keyword );
-
- // Custom keyword provided
- if ( $keyword ) {
-
- yourls_do_action( 'add_new_link_custom_keyword', $url, $keyword, $title );
-
- $keyword = yourls_escape( yourls_sanitize_string( $keyword ) );
- $keyword = yourls_apply_filter( 'custom_keyword', $keyword, $url, $title );
- if ( !yourls_keyword_is_free( $keyword ) ) {
- // This shorturl either reserved or taken already
- $return['status'] = 'fail';
- $return['code'] = 'error:keyword';
- $return['message'] = yourls_s( 'Short URL %s already exists in database or is reserved', $keyword );
- } else {
- // all clear, store !
- yourls_insert_link_in_db( $url, $keyword, $title );
- $return['url'] = array('keyword' => $keyword, 'url' => $strip_url, 'title' => $title, 'date' => date('Y-m-d H:i:s'), 'ip' => $ip );
- $return['status'] = 'success';
- $return['message'] = /* //translators: eg "http://someurl/ added to DB" */ yourls_s( '%s added to database', yourls_trim_long_string( $strip_url ) );
- $return['title'] = $title;
- $return['html'] = yourls_table_add_row( $keyword, $url, $title, $ip, 0, time() );
- $return['shorturl'] = YOURLS_SITE .'/'. $keyword;
- }
-
- // Create random keyword
- } else {
-
- yourls_do_action( 'add_new_link_create_keyword', $url, $keyword, $title );
-
- $timestamp = date( 'Y-m-d H:i:s' );
- $id = yourls_get_next_decimal();
- $ok = false;
- do {
- $keyword = yourls_int2string( $id );
- $keyword = yourls_apply_filter( 'random_keyword', $keyword, $url, $title );
- if ( yourls_keyword_is_free($keyword) ) {
- if( @yourls_insert_link_in_db( $url, $keyword, $title ) ){
- // everything ok, populate needed vars
- $return['url'] = array('keyword' => $keyword, 'url' => $strip_url, 'title' => $title, 'date' => $timestamp, 'ip' => $ip );
- $return['status'] = 'success';
- $return['message'] = /* //translators: eg "http://someurl/ added to DB" */ yourls_s( '%s added to database', yourls_trim_long_string( $strip_url ) );
- $return['title'] = $title;
- $return['html'] = yourls_table_add_row( $keyword, $url, $title, $ip, 0, time() );
- $return['shorturl'] = YOURLS_SITE .'/'. $keyword;
- }else{
- // database error, couldnt store result
- $return['status'] = 'fail';
- $return['code'] = 'error:db';
- $return['message'] = yourls_s( 'Error saving url to database' );
- }
- $ok = true;
- }
- $id++;
- } while ( !$ok );
- @yourls_update_next_decimal( $id );
- }
-
- // URL was already stored
- } else {
-
- yourls_do_action( 'add_new_link_already_stored', $url, $keyword, $title );
-
- $return['status'] = 'fail';
- $return['code'] = 'error:url';
- $return['url'] = array( 'keyword' => $url_exists->keyword, 'url' => $strip_url, 'title' => $url_exists->title, 'date' => $url_exists->timestamp, 'ip' => $url_exists->ip, 'clicks' => $url_exists->clicks );
- $return['message'] = /* //translators: eg "http://someurl/ already exists" */ yourls_s( '%s already exists in database', yourls_trim_long_string( $strip_url ) );
- $return['title'] = $url_exists->title;
- $return['shorturl'] = YOURLS_SITE .'/'. $url_exists->keyword;
- }
-
- yourls_do_action( 'post_add_new_link', $url, $keyword, $title );
-
- $return['statusCode'] = 200; // regardless of result, this is still a valid request
- return yourls_apply_filter( 'add_new_link', $return, $url, $keyword, $title );
-}
-
-
-/**
- * Edit a link
- *
- */
-function yourls_edit_link( $url, $keyword, $newkeyword='', $title='' ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_edit_link', null, $keyword, $url, $keyword, $newkeyword, $title );
- if ( null !== $pre )
- return $pre;
-
- global $ydb;
-
- $table = YOURLS_DB_TABLE_URL;
- $url = yourls_escape (yourls_sanitize_url( $url ) );
- $keyword = yourls_escape( yourls_sanitize_string( $keyword ) );
- $title = yourls_escape( yourls_sanitize_title( $title ) );
- $newkeyword = yourls_escape( yourls_sanitize_string( $newkeyword ) );
- $strip_url = stripslashes( $url );
- $strip_title = stripslashes( $title );
- $old_url = $ydb->get_var( "SELECT `url` FROM `$table` WHERE `keyword` = '$keyword';" );
-
- // Check if new URL is not here already
- if ( $old_url != $url && !yourls_allow_duplicate_longurls() ) {
- $new_url_already_there = intval($ydb->get_var("SELECT COUNT(keyword) FROM `$table` WHERE `url` = '$url';"));
- } else {
- $new_url_already_there = false;
- }
-
- // Check if the new keyword is not here already
- if ( $newkeyword != $keyword ) {
- $keyword_is_ok = yourls_keyword_is_free( $newkeyword );
- } else {
- $keyword_is_ok = true;
- }
-
- yourls_do_action( 'pre_edit_link', $url, $keyword, $newkeyword, $new_url_already_there, $keyword_is_ok );
-
- // All clear, update
- if ( ( !$new_url_already_there || yourls_allow_duplicate_longurls() ) && $keyword_is_ok ) {
- $update_url = $ydb->query( "UPDATE `$table` SET `url` = '$url', `keyword` = '$newkeyword', `title` = '$title' WHERE `keyword` = '$keyword';" );
- if( $update_url ) {
- $return['url'] = array( 'keyword' => $newkeyword, 'shorturl' => YOURLS_SITE.'/'.$newkeyword, 'url' => $strip_url, 'display_url' => yourls_trim_long_string( $strip_url ), 'title' => $strip_title, 'display_title' => yourls_trim_long_string( $strip_title ) );
- $return['status'] = 'success';
- $return['message'] = yourls__( 'Link updated in database' );
- } else {
- $return['status'] = 'fail';
- $return['message'] = /* //translators: "Error updating http://someurl/ (Shorturl: http://sho.rt/blah)" */ yourls_s( 'Error updating %s (Short URL: %s)', yourls_trim_long_string( $strip_url ), $keyword ) ;
- }
-
- // Nope
- } else {
- $return['status'] = 'fail';
- $return['message'] = yourls__( 'URL or keyword already exists in database' );
- }
-
- return yourls_apply_filter( 'edit_link', $return, $url, $keyword, $newkeyword, $title, $new_url_already_there, $keyword_is_ok );
-}
-
-/**
- * Update a title link (no checks for duplicates etc..)
- *
- */
-function yourls_edit_link_title( $keyword, $title ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_edit_link_title', null, $keyword, $title );
- if ( null !== $pre )
- return $pre;
-
- global $ydb;
-
- $keyword = yourls_escape( yourls_sanitize_keyword( $keyword ) );
- $title = yourls_escape( yourls_sanitize_title( $title ) );
-
- $table = YOURLS_DB_TABLE_URL;
- $update = $ydb->query("UPDATE `$table` SET `title` = '$title' WHERE `keyword` = '$keyword';");
-
- return $update;
-}
-
-
-/**
- * Check if keyword id is free (ie not already taken, and not reserved). Return bool.
- *
- */
-function yourls_keyword_is_free( $keyword ) {
- $free = true;
- if ( yourls_keyword_is_reserved( $keyword ) or yourls_keyword_is_taken( $keyword ) )
- $free = false;
-
- return yourls_apply_filter( 'keyword_is_free', $free, $keyword );
-}
-
-/**
- * Check if a keyword is taken (ie there is already a short URL with this id). Return bool.
- *
- */
-function yourls_keyword_is_taken( $keyword ) {
-
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_keyword_is_taken', false, $keyword );
- if ( false !== $pre )
- return $pre;
-
- global $ydb;
- $keyword = yourls_escape( yourls_sanitize_keyword( $keyword ) );
- $taken = false;
- $table = YOURLS_DB_TABLE_URL;
- $already_exists = $ydb->get_var( "SELECT COUNT(`keyword`) FROM `$table` WHERE `keyword` = '$keyword';" );
- if ( $already_exists )
- $taken = true;
-
- return yourls_apply_filter( 'keyword_is_taken', $taken, $keyword );
-}
-
-
-/**
- * Connect to DB
- *
- */
-function yourls_db_connect() {
- global $ydb;
-
- if ( !defined( 'YOURLS_DB_USER' )
- or !defined( 'YOURLS_DB_PASS' )
- or !defined( 'YOURLS_DB_NAME' )
- or !defined( 'YOURLS_DB_HOST' )
- ) yourls_die ( yourls__( 'Incorrect DB config, or could not connect to DB' ), yourls__( 'Fatal error' ), 503 );
-
- // Are we standalone or in the WordPress environment?
- if ( class_exists( 'wpdb', false ) ) {
- /* TODO: should we deprecate this? Follow WP dev in that area */
- $ydb = new wpdb( YOURLS_DB_USER, YOURLS_DB_PASS, YOURLS_DB_NAME, YOURLS_DB_HOST );
- } else {
- yourls_set_DB_driver();
- }
-
- // Check if connection attempt raised an error. It seems that only PDO does, though.
- if ( $ydb->last_error )
- yourls_die( $ydb->last_error, yourls__( 'Fatal error' ), 503 );
-
- if ( defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG === true )
- $ydb->show_errors = true;
-
- return $ydb;
-}
-
-/**
- * Return XML output.
- *
- */
-function yourls_xml_encode( $array ) {
- require_once( YOURLS_INC.'/functions-xml.php' );
- $converter= new yourls_array2xml;
- return $converter->array2xml( $array );
-}
-
-/**
- * Return array of all information associated with keyword. Returns false if keyword not found. Set optional $use_cache to false to force fetching from DB
- *
- */
-function yourls_get_keyword_infos( $keyword, $use_cache = true ) {
- global $ydb;
- $keyword = yourls_escape( yourls_sanitize_string( $keyword ) );
-
- yourls_do_action( 'pre_get_keyword', $keyword, $use_cache );
-
- if( isset( $ydb->infos[$keyword] ) && $use_cache == true ) {
- return yourls_apply_filter( 'get_keyword_infos', $ydb->infos[$keyword], $keyword );
- }
-
- yourls_do_action( 'get_keyword_not_cached', $keyword );
-
- $table = YOURLS_DB_TABLE_URL;
- $infos = $ydb->get_row( "SELECT * FROM `$table` WHERE `keyword` = '$keyword'" );
-
- if( $infos ) {
- $infos = (array)$infos;
- $ydb->infos[ $keyword ] = $infos;
- } else {
- $ydb->infos[ $keyword ] = false;
- }
-
- return yourls_apply_filter( 'get_keyword_infos', $ydb->infos[$keyword], $keyword );
-}
-
-/**
- * Return (string) selected information associated with a keyword. Optional $notfound = string default message if nothing found
- *
- */
-function yourls_get_keyword_info( $keyword, $field, $notfound = false ) {
-
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_get_keyword_info', false, $keyword, $field, $notfound );
- if ( false !== $pre )
- return $pre;
-
- $keyword = yourls_sanitize_string( $keyword );
- $infos = yourls_get_keyword_infos( $keyword );
-
- $return = $notfound;
- if ( isset( $infos[ $field ] ) && $infos[ $field ] !== false )
- $return = $infos[ $field ];
-
- return yourls_apply_filter( 'get_keyword_info', $return, $keyword, $field, $notfound );
-}
-
-/**
- * Return title associated with keyword. Optional $notfound = string default message if nothing found
- *
- */
-function yourls_get_keyword_title( $keyword, $notfound = false ) {
- return yourls_get_keyword_info( $keyword, 'title', $notfound );
-}
-
-/**
- * Return long URL associated with keyword. Optional $notfound = string default message if nothing found
- *
- */
-function yourls_get_keyword_longurl( $keyword, $notfound = false ) {
- return yourls_get_keyword_info( $keyword, 'url', $notfound );
-}
-
-/**
- * Return number of clicks on a keyword. Optional $notfound = string default message if nothing found
- *
- */
-function yourls_get_keyword_clicks( $keyword, $notfound = false ) {
- return yourls_get_keyword_info( $keyword, 'clicks', $notfound );
-}
-
-/**
- * Return IP that added a keyword. Optional $notfound = string default message if nothing found
- *
- */
-function yourls_get_keyword_IP( $keyword, $notfound = false ) {
- return yourls_get_keyword_info( $keyword, 'ip', $notfound );
-}
-
-/**
- * Return timestamp associated with a keyword. Optional $notfound = string default message if nothing found
- *
- */
-function yourls_get_keyword_timestamp( $keyword, $notfound = false ) {
- return yourls_get_keyword_info( $keyword, 'timestamp', $notfound );
-}
-
-/**
- * Update click count on a short URL. Return 0/1 for error/success.
- *
- */
-function yourls_update_clicks( $keyword, $clicks = false ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_update_clicks', false, $keyword, $clicks );
- if ( false !== $pre )
- return $pre;
-
- global $ydb;
- $keyword = yourls_escape( yourls_sanitize_string( $keyword ) );
- $table = YOURLS_DB_TABLE_URL;
- if ( $clicks !== false && is_int( $clicks ) && $clicks >= 0 )
- $update = $ydb->query( "UPDATE `$table` SET `clicks` = $clicks WHERE `keyword` = '$keyword'" );
- else
- $update = $ydb->query( "UPDATE `$table` SET `clicks` = clicks + 1 WHERE `keyword` = '$keyword'" );
-
- yourls_do_action( 'update_clicks', $keyword, $update, $clicks );
- return $update;
-}
-
-/**
- * Return array of stats. (string)$filter is 'bottom', 'last', 'rand' or 'top'. (int)$limit is the number of links to return
- *
- */
-function yourls_get_stats( $filter = 'top', $limit = 10, $start = 0 ) {
- global $ydb;
-
- switch( $filter ) {
- case 'bottom':
- $sort_by = 'clicks';
- $sort_order = 'asc';
- break;
- case 'last':
- $sort_by = 'timestamp';
- $sort_order = 'desc';
- break;
- case 'rand':
- case 'random':
- $sort_by = 'RAND()';
- $sort_order = '';
- break;
- case 'top':
- default:
- $sort_by = 'clicks';
- $sort_order = 'desc';
- break;
- }
-
- // Fetch links
- $limit = intval( $limit );
- $start = intval( $start );
- if ( $limit > 0 ) {
-
- $table_url = YOURLS_DB_TABLE_URL;
- $results = $ydb->get_results( "SELECT * FROM `$table_url` WHERE 1=1 ORDER BY `$sort_by` $sort_order LIMIT $start, $limit;" );
-
- $return = array();
- $i = 1;
-
- foreach ( (array)$results as $res ) {
- $return['links']['link_'.$i++] = array(
- 'shorturl' => YOURLS_SITE .'/'. $res->keyword,
- 'url' => $res->url,
- 'title' => $res->title,
- 'timestamp'=> $res->timestamp,
- 'ip' => $res->ip,
- 'clicks' => $res->clicks,
- );
- }
- }
-
- $return['stats'] = yourls_get_db_stats();
-
- $return['statusCode'] = 200;
-
- return yourls_apply_filter( 'get_stats', $return, $filter, $limit, $start );
-}
-
-/**
- * Return array of stats. (string)$filter is 'bottom', 'last', 'rand' or 'top'. (int)$limit is the number of links to return
- *
- */
-function yourls_get_link_stats( $shorturl ) {
- global $ydb;
-
- $table_url = YOURLS_DB_TABLE_URL;
- $shorturl = yourls_escape( yourls_sanitize_keyword( $shorturl ) );
-
- $res = $ydb->get_row( "SELECT * FROM `$table_url` WHERE keyword = '$shorturl';" );
- $return = array();
-
- if( !$res ) {
- // non existent link
- $return = array(
- 'statusCode' => 404,
- 'message' => 'Error: short URL not found',
- );
- } else {
- $return = array(
- 'statusCode' => 200,
- 'message' => 'success',
- 'link' => array(
- 'shorturl' => YOURLS_SITE .'/'. $res->keyword,
- 'url' => $res->url,
- 'title' => $res->title,
- 'timestamp'=> $res->timestamp,
- 'ip' => $res->ip,
- 'clicks' => $res->clicks,
- )
- );
- }
-
- return yourls_apply_filter( 'get_link_stats', $return, $shorturl );
-}
-
-/**
- * Get total number of URLs and sum of clicks. Input: optional "AND WHERE" clause. Returns array
- *
- * IMPORTANT NOTE: make sure arguments for the $where clause have been sanitized and yourls_escape()'d
- * before calling this function.
- *
- */
-function yourls_get_db_stats( $where = '' ) {
- global $ydb;
- $table_url = YOURLS_DB_TABLE_URL;
-
- $totals = $ydb->get_row( "SELECT COUNT(keyword) as count, SUM(clicks) as sum FROM `$table_url` WHERE 1=1 $where" );
- $return = array( 'total_links' => $totals->count, 'total_clicks' => $totals->sum );
-
- return yourls_apply_filter( 'get_db_stats', $return, $where );
-}
-
-/**
- * Get number of SQL queries performed
- *
- */
-function yourls_get_num_queries() {
- global $ydb;
-
- return yourls_apply_filter( 'get_num_queries', $ydb->num_queries );
-}
-
-/**
- * Returns a sanitized a user agent string. Given what I found on http://www.user-agents.org/ it should be OK.
- *
- */
-function yourls_get_user_agent() {
- if ( !isset( $_SERVER['HTTP_USER_AGENT'] ) )
- return '-';
-
- $ua = strip_tags( html_entity_decode( $_SERVER['HTTP_USER_AGENT'] ));
- $ua = preg_replace('![^0-9a-zA-Z\':., /{}\(\)\[\]\+@&\!\?;_\-=~\*\#]!', '', $ua );
-
- return yourls_apply_filter( 'get_user_agent', substr( $ua, 0, 254 ) );
-}
-
-/**
- * Redirect to another page
- *
- */
-function yourls_redirect( $location, $code = 301 ) {
- yourls_do_action( 'pre_redirect', $location, $code );
- $location = yourls_apply_filter( 'redirect_location', $location, $code );
- $code = yourls_apply_filter( 'redirect_code', $code, $location );
- // Redirect, either properly if possible, or via Javascript otherwise
- if( !headers_sent() ) {
- yourls_status_header( $code );
- header( "Location: $location" );
- } else {
- yourls_redirect_javascript( $location );
- }
- die();
-}
-
-/**
- * Set HTTP status header
- *
- */
-function yourls_status_header( $code = 200 ) {
- if( headers_sent() )
- return;
-
- $protocol = $_SERVER['SERVER_PROTOCOL'];
- if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
- $protocol = 'HTTP/1.0';
-
- $code = intval( $code );
- $desc = yourls_get_HTTP_status( $code );
-
- @header ("$protocol $code $desc"); // This causes problems on IIS and some FastCGI setups
- yourls_do_action( 'status_header', $code );
-}
-
-/**
- * Redirect to another page using Javascript. Set optional (bool)$dontwait to false to force manual redirection (make sure a message has been read by user)
- *
- */
-function yourls_redirect_javascript( $location, $dontwait = true ) {
- yourls_do_action( 'pre_redirect_javascript', $location, $dontwait );
- $location = yourls_apply_filter( 'redirect_javascript', $location, $dontwait );
- if( $dontwait ) {
- $message = yourls_s( 'if you are not redirected after 10 seconds, please click here ', $location );
- echo <<
- window.location="$location";
-
- ($message)
-REDIR;
- } else {
- echo '' . yourls_s( 'Please click here ', $location ) . '
';
- }
- yourls_do_action( 'post_redirect_javascript', $location );
-}
-
-/**
- * Return a HTTP status code
- *
- */
-function yourls_get_HTTP_status( $code ) {
- $code = intval( $code );
- $headers_desc = array(
- 100 => 'Continue',
- 101 => 'Switching Protocols',
- 102 => 'Processing',
-
- 200 => 'OK',
- 201 => 'Created',
- 202 => 'Accepted',
- 203 => 'Non-Authoritative Information',
- 204 => 'No Content',
- 205 => 'Reset Content',
- 206 => 'Partial Content',
- 207 => 'Multi-Status',
- 226 => 'IM Used',
-
- 300 => 'Multiple Choices',
- 301 => 'Moved Permanently',
- 302 => 'Found',
- 303 => 'See Other',
- 304 => 'Not Modified',
- 305 => 'Use Proxy',
- 306 => 'Reserved',
- 307 => 'Temporary Redirect',
-
- 400 => 'Bad Request',
- 401 => 'Unauthorized',
- 402 => 'Payment Required',
- 403 => 'Forbidden',
- 404 => 'Not Found',
- 405 => 'Method Not Allowed',
- 406 => 'Not Acceptable',
- 407 => 'Proxy Authentication Required',
- 408 => 'Request Timeout',
- 409 => 'Conflict',
- 410 => 'Gone',
- 411 => 'Length Required',
- 412 => 'Precondition Failed',
- 413 => 'Request Entity Too Large',
- 414 => 'Request-URI Too Long',
- 415 => 'Unsupported Media Type',
- 416 => 'Requested Range Not Satisfiable',
- 417 => 'Expectation Failed',
- 422 => 'Unprocessable Entity',
- 423 => 'Locked',
- 424 => 'Failed Dependency',
- 426 => 'Upgrade Required',
-
- 500 => 'Internal Server Error',
- 501 => 'Not Implemented',
- 502 => 'Bad Gateway',
- 503 => 'Service Unavailable',
- 504 => 'Gateway Timeout',
- 505 => 'HTTP Version Not Supported',
- 506 => 'Variant Also Negotiates',
- 507 => 'Insufficient Storage',
- 510 => 'Not Extended'
- );
-
- if ( isset( $headers_desc[$code] ) )
- return $headers_desc[$code];
- else
- return '';
-}
-
-
-/**
- * Log a redirect (for stats)
- *
- */
-function yourls_log_redirect( $keyword ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_log_redirect', false, $keyword );
- if ( false !== $pre )
- return $pre;
-
- if ( !yourls_do_log_redirect() )
- return true;
-
- global $ydb;
- $table = YOURLS_DB_TABLE_LOG;
-
- $keyword = yourls_escape( yourls_sanitize_string( $keyword ) );
- $referrer = ( isset( $_SERVER['HTTP_REFERER'] ) ? yourls_escape( yourls_sanitize_url( $_SERVER['HTTP_REFERER'] ) ) : 'direct' );
- $ua = yourls_escape( yourls_get_user_agent() );
- $ip = yourls_escape( yourls_get_IP() );
- $location = yourls_escape( yourls_geo_ip_to_countrycode( $ip ) );
-
- return $ydb->query( "INSERT INTO `$table` (click_time, shorturl, referrer, user_agent, ip_address, country_code) VALUES (NOW(), '$keyword', '$referrer', '$ua', '$ip', '$location')" );
-}
-
-/**
- * Check if we want to not log redirects (for stats)
- *
- */
-function yourls_do_log_redirect() {
- return ( !defined( 'YOURLS_NOSTATS' ) || YOURLS_NOSTATS != true );
-}
-
-/**
- * Converts an IP to a 2 letter country code, using GeoIP database if available in includes/geo/
- *
- * @since 1.4
- * @param string $ip IP or, if empty string, will be current user IP
- * @param string $defaut Default string to return if IP doesn't resolve to a country (malformed, private IP...)
- * @return string 2 letter country code (eg 'US') or $default
- */
-function yourls_geo_ip_to_countrycode( $ip = '', $default = '' ) {
- // Allow plugins to short-circuit the Geo IP API
- $location = yourls_apply_filter( 'shunt_geo_ip_to_countrycode', false, $ip, $default ); // at this point $ip can be '', check if your plugin hooks in here
- if ( false !== $location )
- return $location;
-
- if ( $ip == '' )
- $ip = yourls_get_IP();
-
- // Use IPv4 or IPv6 DB & functions
- if( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {
- $db = 'GeoIP.dat';
- $func = 'geoip_country_code_by_addr';
- } else {
- $db = 'GeoIPv6.dat';
- $func = 'geoip_country_code_by_addr_v6';
- }
-
- if ( !file_exists( YOURLS_INC . '/geo/' . $db ) || !file_exists( YOURLS_INC .'/geo/geoip.inc' ) )
- return $default;
-
- require_once( YOURLS_INC . '/geo/geoip.inc' );
- $gi = geoip_open( YOURLS_INC . '/geo/' . $db, GEOIP_STANDARD );
- try {
- $location = call_user_func( $func, $gi, $ip );
- } catch ( Exception $e ) {
- $location = '';
- }
- geoip_close( $gi );
-
- if( '' == $location )
- $location = $default;
-
- return yourls_apply_filter( 'geo_ip_to_countrycode', $location, $ip, $default );
-}
-
-/**
- * Converts a 2 letter country code to long name (ie AU -> Australia)
- *
- */
-function yourls_geo_countrycode_to_countryname( $code ) {
- // Allow plugins to short-circuit the Geo IP API
- $country = yourls_apply_filter( 'shunt_geo_countrycode_to_countryname', false, $code );
- if ( false !== $country )
- return $country;
-
- // Load the Geo class if not already done
- if( !class_exists( 'GeoIP', false ) ) {
- $temp = yourls_geo_ip_to_countrycode( '127.0.0.1' );
- }
-
- if( class_exists( 'GeoIP', false ) ) {
- $geo = new GeoIP;
- $id = $geo->GEOIP_COUNTRY_CODE_TO_NUMBER[ $code ];
- $long = $geo->GEOIP_COUNTRY_NAMES[ $id ];
- return $long;
- } else {
- return false;
- }
-}
-
-/**
- * Return flag URL from 2 letter country code
- *
- */
-function yourls_geo_get_flag( $code ) {
- if( file_exists( YOURLS_INC.'/geo/flags/flag_'.strtolower($code).'.gif' ) ) {
- $img = yourls_match_current_protocol( YOURLS_SITE.'/includes/geo/flags/flag_'.( strtolower( $code ) ).'.gif' );
- } else {
- $img = false;
- }
- return yourls_apply_filter( 'geo_get_flag', $img, $code );
-}
-
-
-/**
- * Check if an upgrade is needed
- *
- */
-function yourls_upgrade_is_needed() {
- // check YOURLS_DB_VERSION exist && match values stored in YOURLS_DB_TABLE_OPTIONS
- list( $currentver, $currentsql ) = yourls_get_current_version_from_sql();
- if( $currentsql < YOURLS_DB_VERSION )
- return true;
-
- return false;
-}
-
-/**
- * Get current version & db version as stored in the options DB. Prior to 1.4 there's no option table.
- *
- */
-function yourls_get_current_version_from_sql() {
- $currentver = yourls_get_option( 'version' );
- $currentsql = yourls_get_option( 'db_version' );
-
- // Values if version is 1.3
- if( !$currentver )
- $currentver = '1.3';
- if( !$currentsql )
- $currentsql = '100';
-
- return array( $currentver, $currentsql);
-}
-
-/**
- * Read an option from DB (or from cache if available). Return value or $default if not found
- *
- * Pretty much stolen from WordPress
- *
- * @since 1.4
- * @param string $option Option name. Expected to not be SQL-escaped.
- * @param mixed $default Optional value to return if option doesn't exist. Default false.
- * @return mixed Value set for the option.
- */
-function yourls_get_option( $option_name, $default = false ) {
- global $ydb;
-
- // Allow plugins to short-circuit options
- $pre = yourls_apply_filter( 'shunt_option_'.$option_name, false );
- if ( false !== $pre )
- return $pre;
-
- // If option not cached already, get its value from the DB
- if ( !isset( $ydb->option[$option_name] ) ) {
- $table = YOURLS_DB_TABLE_OPTIONS;
- $option_name = yourls_escape( $option_name );
- $row = $ydb->get_row( "SELECT `option_value` FROM `$table` WHERE `option_name` = '$option_name' LIMIT 1" );
- if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
- $value = $row->option_value;
- } else { // option does not exist, so we must cache its non-existence
- $value = $default;
- }
- $ydb->option[ $option_name ] = yourls_maybe_unserialize( $value );
- }
-
- return yourls_apply_filter( 'get_option_'.$option_name, $ydb->option[$option_name] );
-}
-
-/**
- * Read all options from DB at once
- *
- * The goal is to read all option at once and then populate array $ydb->option, to prevent further
- * SQL queries if we need to read an option value later.
- * It's also a simple check whether YOURLS is installed or not (no option = assuming not installed)
- *
- * @since 1.4
- */
-function yourls_get_all_options() {
- global $ydb;
-
- // Allow plugins to short-circuit all options. (Note: regular plugins are loaded after all options)
- $pre = yourls_apply_filter( 'shunt_all_options', false );
- if ( false !== $pre )
- return $pre;
-
- $table = YOURLS_DB_TABLE_OPTIONS;
-
- $allopt = $ydb->get_results( "SELECT `option_name`, `option_value` FROM `$table` WHERE 1=1" );
-
- foreach( (array)$allopt as $option ) {
- $ydb->option[ $option->option_name ] = yourls_maybe_unserialize( $option->option_value );
- }
-
- if( property_exists( $ydb, 'option' ) ) {
- $ydb->option = yourls_apply_filter( 'get_all_options', $ydb->option );
- $ydb->installed = true;
- } else {
- // Zero option found: assume YOURLS is not installed
- $ydb->installed = false;
- }
-}
-
-/**
- * Update (add if doesn't exist) an option to DB
- *
- * Pretty much stolen from WordPress
- *
- * @since 1.4
- * @param string $option Option name. Expected to not be SQL-escaped.
- * @param mixed $newvalue Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
- * @return bool False if value was not updated, true otherwise.
- */
-function yourls_update_option( $option_name, $newvalue ) {
- global $ydb;
- $table = YOURLS_DB_TABLE_OPTIONS;
-
- $option_name = trim( $option_name );
- if ( empty( $option_name ) )
- return false;
-
- // Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3
- if ( is_object( $newvalue ) )
- $newvalue = clone $newvalue;
-
- $option_name = yourls_escape( $option_name );
-
- $oldvalue = yourls_get_option( $option_name );
-
- // If the new and old values are the same, no need to update.
- if ( $newvalue === $oldvalue )
- return false;
-
- if ( false === $oldvalue ) {
- yourls_add_option( $option_name, $newvalue );
- return true;
- }
-
- $_newvalue = yourls_escape( yourls_maybe_serialize( $newvalue ) );
-
- yourls_do_action( 'update_option', $option_name, $oldvalue, $newvalue );
-
- $ydb->query( "UPDATE `$table` SET `option_value` = '$_newvalue' WHERE `option_name` = '$option_name'" );
-
- if ( $ydb->rows_affected == 1 ) {
- $ydb->option[ $option_name ] = $newvalue;
- return true;
- }
- return false;
-}
-
-/**
- * Add an option to the DB
- *
- * Pretty much stolen from WordPress
- *
- * @since 1.4
- * @param string $option Name of option to add. Expected to not be SQL-escaped.
- * @param mixed $value Optional option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
- * @return bool False if option was not added and true otherwise.
- */
-function yourls_add_option( $name, $value = '' ) {
- global $ydb;
- $table = YOURLS_DB_TABLE_OPTIONS;
-
- $name = trim( $name );
- if ( empty( $name ) )
- return false;
-
- // Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3
- if ( is_object( $value ) )
- $value = clone $value;
-
- $name = yourls_escape( $name );
-
- // Make sure the option doesn't already exist
- if ( false !== yourls_get_option( $name ) )
- return false;
-
- $_value = yourls_escape( yourls_maybe_serialize( $value ) );
-
- yourls_do_action( 'add_option', $name, $_value );
-
- $ydb->query( "INSERT INTO `$table` (`option_name`, `option_value`) VALUES ('$name', '$_value')" );
- $ydb->option[ $name ] = $value;
- return true;
-}
-
-
-/**
- * Delete an option from the DB
- *
- * Pretty much stolen from WordPress
- *
- * @since 1.4
- * @param string $option Option name to delete. Expected to not be SQL-escaped.
- * @return bool True, if option is successfully deleted. False on failure.
- */
-function yourls_delete_option( $name ) {
- global $ydb;
- $table = YOURLS_DB_TABLE_OPTIONS;
- $name = yourls_escape( $name );
-
- // Get the ID, if no ID then return
- $option = $ydb->get_row( "SELECT option_id FROM `$table` WHERE `option_name` = '$name'" );
- if ( is_null( $option ) || !$option->option_id )
- return false;
-
- yourls_do_action( 'delete_option', $name );
-
- $ydb->query( "DELETE FROM `$table` WHERE `option_name` = '$name'" );
- unset( $ydb->option[ $name ] );
- return true;
-}
-
-
-/**
- * Serialize data if needed. Stolen from WordPress
- *
- * @since 1.4
- * @param mixed $data Data that might be serialized.
- * @return mixed A scalar data
- */
-function yourls_maybe_serialize( $data ) {
- if ( is_array( $data ) || is_object( $data ) )
- return serialize( $data );
-
- if ( yourls_is_serialized( $data, false ) )
- return serialize( $data );
-
- return $data;
-}
-
-/**
- * Check value to find if it was serialized. Stolen from WordPress
- *
- * @since 1.4
- * @param mixed $data Value to check to see if was serialized.
- * @param bool $strict Optional. Whether to be strict about the end of the string. Defaults true.
- * @return bool False if not serialized and true if it was.
- */
-function yourls_is_serialized( $data, $strict = true ) {
- // if it isn't a string, it isn't serialized
- if ( ! is_string( $data ) )
- return false;
- $data = trim( $data );
- if ( 'N;' == $data )
- return true;
- $length = strlen( $data );
- if ( $length < 4 )
- return false;
- if ( ':' !== $data[1] )
- return false;
- if ( $strict ) {
- $lastc = $data[ $length - 1 ];
- if ( ';' !== $lastc && '}' !== $lastc )
- return false;
- } else {
- $semicolon = strpos( $data, ';' );
- $brace = strpos( $data, '}' );
- // Either ; or } must exist.
- if ( false === $semicolon && false === $brace )
- return false;
- // But neither must be in the first X characters.
- if ( false !== $semicolon && $semicolon < 3 )
- return false;
- if ( false !== $brace && $brace < 4 )
- return false;
- }
- $token = $data[0];
- switch ( $token ) {
- case 's' :
- if ( $strict ) {
- if ( '"' !== $data[ $length - 2 ] )
- return false;
- } elseif ( false === strpos( $data, '"' ) ) {
- return false;
- }
- // or else fall through
- case 'a' :
- case 'O' :
- return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
- case 'b' :
- case 'i' :
- case 'd' :
- $end = $strict ? '$' : '';
- return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
- }
- return false;
-}
-
-/**
- * Unserialize value only if it was serialized. Stolen from WP
- *
- * @since 1.4
- * @param string $original Maybe unserialized original, if is needed.
- * @return mixed Unserialized data can be any type.
- */
-function yourls_maybe_unserialize( $original ) {
- if ( yourls_is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
- return @unserialize( $original );
- return $original;
-}
-
-/**
- * Determine if the current page is private
- *
- */
-function yourls_is_private() {
- $private = false;
-
- if ( defined('YOURLS_PRIVATE') && YOURLS_PRIVATE == true ) {
-
- // Allow overruling for particular pages:
-
- // API
- if( yourls_is_API() ) {
- if( !defined('YOURLS_PRIVATE_API') || YOURLS_PRIVATE_API != false )
- $private = true;
-
- // Infos
- } elseif( yourls_is_infos() ) {
- if( !defined('YOURLS_PRIVATE_INFOS') || YOURLS_PRIVATE_INFOS !== false )
- $private = true;
-
- // Others
- } else {
- $private = true;
- }
-
- }
-
- return yourls_apply_filter( 'is_private', $private );
-}
-
-/**
- * Show login form if required
- *
- */
-function yourls_maybe_require_auth() {
- if( yourls_is_private() ) {
- yourls_do_action( 'require_auth' );
- require_once( YOURLS_INC.'/auth.php' );
- } else {
- yourls_do_action( 'require_no_auth' );
- }
-}
-
-/**
- * Allow several short URLs for the same long URL ?
- *
- */
-function yourls_allow_duplicate_longurls() {
- // special treatment if API to check for WordPress plugin requests
- if( yourls_is_API() ) {
- if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'plugin' )
- return false;
- }
- return ( defined( 'YOURLS_UNIQUE_URLS' ) && YOURLS_UNIQUE_URLS == false );
-}
-
-/**
- * Return array of keywords that redirect to the submitted long URL
- *
- * @since 1.7
- * @param string $longurl long url
- * @param string $sort Optional ORDER BY order (can be 'keyword', 'title', 'timestamp' or'clicks')
- * @param string $order Optional SORT order (can be 'ASC' or 'DESC')
- * @return array array of keywords
- */
-function yourls_get_longurl_keywords( $longurl, $sort = 'none', $order = 'ASC' ) {
- global $ydb;
- $longurl = yourls_escape( yourls_sanitize_url( $longurl ) );
- $table = YOURLS_DB_TABLE_URL;
- $query = "SELECT `keyword` FROM `$table` WHERE `url` = '$longurl'";
-
- // Ensure sort is a column in database (@TODO: update verification array if database changes)
- if ( in_array( $sort, array('keyword','title','timestamp','clicks') ) ) {
- $query .= " ORDER BY '".$sort."'";
- if ( in_array( $order, array( 'ASC','DESC' ) ) ) {
- $query .= " ".$order;
- }
- }
- return yourls_apply_filter( 'get_longurl_keywords', $ydb->get_col( $query ), $longurl );
-}
-
-/**
- * Check if an IP shortens URL too fast to prevent DB flood. Return true, or die.
- *
- */
-function yourls_check_IP_flood( $ip = '' ) {
-
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_check_IP_flood', false, $ip );
- if ( false !== $pre )
- return $pre;
-
- yourls_do_action( 'pre_check_ip_flood', $ip ); // at this point $ip can be '', check it if your plugin hooks in here
-
- // Raise white flag if installing or if no flood delay defined
- if(
- ( defined('YOURLS_FLOOD_DELAY_SECONDS') && YOURLS_FLOOD_DELAY_SECONDS === 0 ) ||
- !defined('YOURLS_FLOOD_DELAY_SECONDS') ||
- yourls_is_installing()
- )
- return true;
-
- // Don't throttle logged in users
- if( yourls_is_private() ) {
- if( yourls_is_valid_user() === true )
- return true;
- }
-
- // Don't throttle whitelist IPs
- if( defined( 'YOURLS_FLOOD_IP_WHITELIST' ) && YOURLS_FLOOD_IP_WHITELIST ) {
- $whitelist_ips = explode( ',', YOURLS_FLOOD_IP_WHITELIST );
- foreach( (array)$whitelist_ips as $whitelist_ip ) {
- $whitelist_ip = trim( $whitelist_ip );
- if ( $whitelist_ip == $ip )
- return true;
- }
- }
-
- $ip = ( $ip ? yourls_sanitize_ip( $ip ) : yourls_get_IP() );
- $ip = yourls_escape( $ip );
-
- yourls_do_action( 'check_ip_flood', $ip );
-
- global $ydb;
- $table = YOURLS_DB_TABLE_URL;
-
- $lasttime = $ydb->get_var( "SELECT `timestamp` FROM $table WHERE `ip` = '$ip' ORDER BY `timestamp` DESC LIMIT 1" );
- if( $lasttime ) {
- $now = date( 'U' );
- $then = date( 'U', strtotime( $lasttime ) );
- if( ( $now - $then ) <= YOURLS_FLOOD_DELAY_SECONDS ) {
- // Flood!
- yourls_do_action( 'ip_flood', $ip, $now - $then );
- yourls_die( yourls__( 'Too many URLs added too fast. Slow down please.' ), yourls__( 'Forbidden' ), 403 );
- }
- }
-
- return true;
-}
-
-/**
- * Check if YOURLS is installing
- *
- * @return bool
- * @since 1.6
- */
-function yourls_is_installing() {
- $installing = defined( 'YOURLS_INSTALLING' ) && YOURLS_INSTALLING == true;
- return yourls_apply_filter( 'is_installing', $installing );
-}
-
-/**
- * Check if YOURLS is upgrading
- *
- * @return bool
- * @since 1.6
- */
-function yourls_is_upgrading() {
- $upgrading = defined( 'YOURLS_UPGRADING' ) && YOURLS_UPGRADING == true;
- return yourls_apply_filter( 'is_upgrading', $upgrading );
-}
-
-
-/**
- * Check if YOURLS is installed
- *
- * Checks property $ydb->installed that is created by yourls_get_all_options()
- *
- * See inline comment for updating from 1.3 or prior.
- *
- */
-function yourls_is_installed() {
- global $ydb;
- $is_installed = ( property_exists( $ydb, 'installed' ) && $ydb->installed == true );
- return yourls_apply_filter( 'is_installed', $is_installed );
-
- /* Note: this test won't work on YOURLS 1.3 or older (Aug 2009...)
- Should someone complain that they cannot upgrade directly from
- 1.3 to 1.7: first, laugh at them, then ask them to install 1.6 first.
- */
-}
-
-/**
- * Generate random string of (int)$length length and type $type (see function for details)
- *
- */
-function yourls_rnd_string ( $length = 5, $type = 0, $charlist = '' ) {
- $str = '';
- $length = intval( $length );
-
- // define possible characters
- switch ( $type ) {
-
- // custom char list, or comply to charset as defined in config
- case '0':
- $possible = $charlist ? $charlist : yourls_get_shorturl_charset() ;
- break;
-
- // no vowels to make no offending word, no 0/1/o/l to avoid confusion between letters & digits. Perfect for passwords.
- case '1':
- $possible = "23456789bcdfghjkmnpqrstvwxyz";
- break;
-
- // Same, with lower + upper
- case '2':
- $possible = "23456789bcdfghjkmnpqrstvwxyzBCDFGHJKMNPQRSTVWXYZ";
- break;
-
- // all letters, lowercase
- case '3':
- $possible = "abcdefghijklmnopqrstuvwxyz";
- break;
-
- // all letters, lowercase + uppercase
- case '4':
- $possible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- break;
-
- // all digits & letters lowercase
- case '5':
- $possible = "0123456789abcdefghijklmnopqrstuvwxyz";
- break;
-
- // all digits & letters lowercase + uppercase
- case '6':
- $possible = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- break;
-
- }
-
- $i = 0;
- while ($i < $length) {
- $str .= substr( $possible, mt_rand( 0, strlen( $possible )-1 ), 1 );
- $i++;
- }
-
- return yourls_apply_filter( 'rnd_string', $str, $length, $type, $charlist );
-}
-
-/**
- * Return salted string
- *
- */
-function yourls_salt( $string ) {
- $salt = defined('YOURLS_COOKIEKEY') ? YOURLS_COOKIEKEY : md5(__FILE__) ;
- return yourls_apply_filter( 'yourls_salt', md5 ($string . $salt), $string );
-}
-
-/**
- * Add a query var to a URL and return URL. Completely stolen from WP.
- *
- * Works with one of these parameter patterns:
- * array( 'var' => 'value' )
- * array( 'var' => 'value' ), $url
- * 'var', 'value'
- * 'var', 'value', $url
- * If $url omitted, uses $_SERVER['REQUEST_URI']
- *
- */
-function yourls_add_query_arg() {
- $ret = '';
- if ( is_array( func_get_arg(0) ) ) {
- if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )
- $uri = $_SERVER['REQUEST_URI'];
- else
- $uri = @func_get_arg( 1 );
- } else {
- if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )
- $uri = $_SERVER['REQUEST_URI'];
- else
- $uri = @func_get_arg( 2 );
- }
-
- $uri = str_replace( '&', '&', $uri );
-
-
- if ( $frag = strstr( $uri, '#' ) )
- $uri = substr( $uri, 0, -strlen( $frag ) );
- else
- $frag = '';
-
- if ( preg_match( '|^https?://|i', $uri, $matches ) ) {
- $protocol = $matches[0];
- $uri = substr( $uri, strlen( $protocol ) );
- } else {
- $protocol = '';
- }
-
- if ( strpos( $uri, '?' ) !== false ) {
- $parts = explode( '?', $uri, 2 );
- if ( 1 == count( $parts ) ) {
- $base = '?';
- $query = $parts[0];
- } else {
- $base = $parts[0] . '?';
- $query = $parts[1];
- }
- } elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) {
- $base = $uri . '?';
- $query = '';
- } else {
- $base = '';
- $query = $uri;
- }
-
- parse_str( $query, $qs );
- $qs = yourls_urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
- if ( is_array( func_get_arg( 0 ) ) ) {
- $kayvees = func_get_arg( 0 );
- $qs = array_merge( $qs, $kayvees );
- } else {
- $qs[func_get_arg( 0 )] = func_get_arg( 1 );
- }
-
- foreach ( (array) $qs as $k => $v ) {
- if ( $v === false )
- unset( $qs[$k] );
- }
-
- $ret = http_build_query( $qs );
- $ret = trim( $ret, '?' );
- $ret = preg_replace( '#=(&|$)#', '$1', $ret );
- $ret = $protocol . $base . $ret . $frag;
- $ret = rtrim( $ret, '?' );
- return $ret;
-}
-
-/**
- * Navigates through an array and encodes the values to be used in a URL. Stolen from WP, used in yourls_add_query_arg()
- *
- */
-function yourls_urlencode_deep( $value ) {
- $value = is_array( $value ) ? array_map( 'yourls_urlencode_deep', $value ) : urlencode( $value );
- return $value;
-}
-
-/**
- * Remove arg from query. Opposite of yourls_add_query_arg. Stolen from WP.
- *
- */
-function yourls_remove_query_arg( $key, $query = false ) {
- if ( is_array( $key ) ) { // removing multiple keys
- foreach ( $key as $k )
- $query = yourls_add_query_arg( $k, false, $query );
- return $query;
- }
- return yourls_add_query_arg( $key, false, $query );
-}
-
-/**
- * Return a time-dependent string for nonce creation
- *
- */
-function yourls_tick() {
- return ceil( time() / YOURLS_NONCE_LIFE );
-}
-
-/**
- * Create a time limited, action limited and user limited token
- *
- */
-function yourls_create_nonce( $action, $user = false ) {
- if( false == $user )
- $user = defined( 'YOURLS_USER' ) ? YOURLS_USER : '-1';
- $tick = yourls_tick();
- return substr( yourls_salt($tick . $action . $user), 0, 10 );
-}
-
-/**
- * Create a nonce field for inclusion into a form
- *
- */
-function yourls_nonce_field( $action, $name = 'nonce', $user = false, $echo = true ) {
- $field = ' ';
- if( $echo )
- echo $field."\n";
- return $field;
-}
-
-/**
- * Add a nonce to a URL. If URL omitted, adds nonce to current URL
- *
- */
-function yourls_nonce_url( $action, $url = false, $name = 'nonce', $user = false ) {
- $nonce = yourls_create_nonce( $action, $user );
- return yourls_add_query_arg( $name, $nonce, $url );
-}
-
-/**
- * Check validity of a nonce (ie time span, user and action match).
- *
- * Returns true if valid, dies otherwise (yourls_die() or die($return) if defined)
- * if $nonce is false or unspecified, it will use $_REQUEST['nonce']
- *
- */
-function yourls_verify_nonce( $action, $nonce = false, $user = false, $return = '' ) {
- // get user
- if( false == $user )
- $user = defined( 'YOURLS_USER' ) ? YOURLS_USER : '-1';
-
- // get current nonce value
- if( false == $nonce && isset( $_REQUEST['nonce'] ) )
- $nonce = $_REQUEST['nonce'];
-
- // what nonce should be
- $valid = yourls_create_nonce( $action, $user );
-
- if( $nonce == $valid ) {
- return true;
- } else {
- if( $return )
- die( $return );
- yourls_die( yourls__( 'Unauthorized action or expired link' ), yourls__( 'Error' ), 403 );
- }
-}
-
-/**
- * Converts keyword into short link (prepend with YOURLS base URL)
- *
- */
-function yourls_link( $keyword = '' ) {
- $link = YOURLS_SITE . '/' . yourls_sanitize_keyword( $keyword );
- return yourls_apply_filter( 'yourls_link', $link, $keyword );
-}
-
-/**
- * Converts keyword into stat link (prepend with YOURLS base URL, append +)
- *
- */
-function yourls_statlink( $keyword = '' ) {
- $link = YOURLS_SITE . '/' . yourls_sanitize_keyword( $keyword ) . '+';
- if( yourls_is_ssl() )
- $link = str_replace( 'http://', 'https://', $link );
- return yourls_apply_filter( 'yourls_statlink', $link, $keyword );
-}
-
-/**
- * Check if we'll need interface display function (ie not API or redirection)
- *
- */
-function yourls_has_interface() {
- if( yourls_is_API() or yourls_is_GO() )
- return false;
- return true;
-}
-
-/**
- * Check if we're in API mode. Returns bool
- *
- */
-function yourls_is_API() {
- if ( defined( 'YOURLS_API' ) && YOURLS_API == true )
- return true;
- return false;
-}
-
-/**
- * Check if we're in Ajax mode. Returns bool
- *
- */
-function yourls_is_Ajax() {
- if ( defined( 'YOURLS_AJAX' ) && YOURLS_AJAX == true )
- return true;
- return false;
-}
-
-/**
- * Check if we're in GO mode (yourls-go.php). Returns bool
- *
- */
-function yourls_is_GO() {
- if ( defined( 'YOURLS_GO' ) && YOURLS_GO == true )
- return true;
- return false;
-}
-
-/**
- * Check if we're displaying stats infos (yourls-infos.php). Returns bool
- *
- */
-function yourls_is_infos() {
- if ( defined( 'YOURLS_INFOS' ) && YOURLS_INFOS == true )
- return true;
- return false;
-}
-
-/**
- * Check if we're in the admin area. Returns bool
- *
- */
-function yourls_is_admin() {
- if ( defined( 'YOURLS_ADMIN' ) && YOURLS_ADMIN == true )
- return true;
- return false;
-}
-
-/**
- * Check if the server seems to be running on Windows. Not exactly sure how reliable this is.
- *
- */
-function yourls_is_windows() {
- return defined( 'DIRECTORY_SEPARATOR' ) && DIRECTORY_SEPARATOR == '\\';
-}
-
-/**
- * Check if SSL is required. Returns bool.
- *
- */
-function yourls_needs_ssl() {
- if ( defined('YOURLS_ADMIN_SSL') && YOURLS_ADMIN_SSL == true )
- return true;
- return false;
-}
-
-/**
- * Return admin link, with SSL preference if applicable.
- *
- */
-function yourls_admin_url( $page = '' ) {
- $admin = YOURLS_SITE . '/admin/' . $page;
- if( yourls_is_ssl() or yourls_needs_ssl() )
- $admin = str_replace('http://', 'https://', $admin);
- return yourls_apply_filter( 'admin_url', $admin, $page );
-}
-
-/**
- * Return YOURLS_SITE or URL under YOURLS setup, with SSL preference
- *
- */
-function yourls_site_url( $echo = true, $url = '' ) {
- $url = yourls_get_relative_url( $url );
- $url = trim( YOURLS_SITE . '/' . $url, '/' );
-
- // Do not enforce (checking yourls_need_ssl() ) but check current usage so it won't force SSL on non-admin pages
- if( yourls_is_ssl() )
- $url = str_replace( 'http://', 'https://', $url );
- $url = yourls_apply_filter( 'site_url', $url );
- if( $echo )
- echo $url;
- return $url;
-}
-
-/**
- * Check if SSL is used, returns bool. Stolen from WP.
- *
- */
-function yourls_is_ssl() {
- $is_ssl = false;
- if ( isset( $_SERVER['HTTPS'] ) ) {
- if ( 'on' == strtolower( $_SERVER['HTTPS'] ) )
- $is_ssl = true;
- if ( '1' == $_SERVER['HTTPS'] )
- $is_ssl = true;
- } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
- $is_ssl = true;
- }
- return yourls_apply_filter( 'is_ssl', $is_ssl );
-}
-
-/**
- * Get a remote page title
- *
- * This function returns a string: either the page title as defined in HTML, or the URL if not found
- * The function tries to convert funky characters found in titles to UTF8, from the detected charset.
- * Charset in use is guessed from HTML meta tag, or if not found, from server's 'content-type' response.
- *
- * @param string $url URL
- * @return string Title (sanitized) or the URL if no title found
- */
-function yourls_get_remote_title( $url ) {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_get_remote_title', false, $url );
- if ( false !== $pre )
- return $pre;
-
- $url = yourls_sanitize_url( $url );
-
- // Only deal with http(s)://
- if( !in_array( yourls_get_protocol( $url ), array( 'http://', 'https://' ) ) )
- return $url;
-
- $title = $charset = false;
-
- $response = yourls_http_get( $url ); // can be a Request object or an error string
- if( is_string( $response ) ) {
- return $url;
- }
-
- // Page content. No content? Return the URL
- $content = $response->body;
- if( !$content )
- return $url;
-
- // look for . No title found? Return the URL
- if ( preg_match('/(.*?)<\/title>/is', $content, $found ) ) {
- $title = $found[1];
- unset( $found );
- }
- if( !$title )
- return $url;
-
- // Now we have a title. We'll try to get proper utf8 from it.
-
- // Get charset as (and if) defined by the HTML meta tag. We should match
- //
- // or and all possible variations: see https://gist.github.com/ozh/7951236
- if ( preg_match( '/ ]*charset\s*=["\' ]*([a-zA-Z0-9\-_]+)/is', $content, $found ) ) {
- $charset = $found[1];
- unset( $found );
- } else {
- // No charset found in HTML. Get charset as (and if) defined by the server response
- $_charset = current( $response->headers->getValues( 'content-type' ) );
- if( preg_match( '/charset=(\S+)/', $_charset, $found ) ) {
- $charset = trim( $found[1], ';' );
- unset( $found );
- }
- }
-
- // Conversion to utf-8 if what we have is not utf8 already
- if( strtolower( $charset ) != 'utf-8' && function_exists( 'mb_convert_encoding' ) ) {
- // We use @ to remove warnings because mb_ functions are easily bitching about illegal chars
- if( $charset ) {
- $title = @mb_convert_encoding( $title, 'UTF-8', $charset );
- } else {
- $title = @mb_convert_encoding( $title, 'UTF-8' );
- }
- }
-
- // Remove HTML entities
- $title = html_entity_decode( $title, ENT_QUOTES, 'UTF-8' );
-
- // Strip out evil things
- $title = yourls_sanitize_title( $title );
-
- return yourls_apply_filter( 'get_remote_title', $title, $url );
-}
-
-/**
- * Quick UA check for mobile devices. Return boolean.
- *
- */
-function yourls_is_mobile_device() {
- // Strings searched
- $mobiles = array(
- 'android', 'blackberry', 'blazer',
- 'compal', 'elaine', 'fennec', 'hiptop',
- 'iemobile', 'iphone', 'ipod', 'ipad',
- 'iris', 'kindle', 'opera mobi', 'opera mini',
- 'palm', 'phone', 'pocket', 'psp', 'symbian',
- 'treo', 'wap', 'windows ce', 'windows phone'
- );
-
- // Current user-agent
- $current = strtolower( $_SERVER['HTTP_USER_AGENT'] );
-
- // Check and return
- $is_mobile = ( str_replace( $mobiles, '', $current ) != $current );
- return yourls_apply_filter( 'is_mobile_device', $is_mobile );
-}
-
-/**
- * Get request in YOURLS base (eg in 'http://site.com/yourls/abcd' get 'abdc')
- *
- */
-function yourls_get_request() {
- // Allow plugins to short-circuit the whole function
- $pre = yourls_apply_filter( 'shunt_get_request', false );
- if ( false !== $pre )
- return $pre;
-
- static $request = null;
-
- yourls_do_action( 'pre_get_request', $request );
-
- if( $request !== null )
- return $request;
-
- // Ignore protocol & www. prefix
- $root = str_replace( array( 'https://', 'http://', 'https://www.', 'http://www.' ), '', YOURLS_SITE );
- // Case insensitive comparison of the YOURLS root to match both http://Sho.rt/blah and http://sho.rt/blah
- $request = preg_replace( "!$root/!i", '', $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 1 );
-
- // Unless request looks like a full URL (ie request is a simple keyword) strip query string
- if( !preg_match( "@^[a-zA-Z]+://.+@", $request ) ) {
- $request = current( explode( '?', $request ) );
- }
-
- return yourls_apply_filter( 'get_request', $request );
-}
-
-/**
- * Change protocol to match current scheme used (http or https)
- *
- */
-function yourls_match_current_protocol( $url, $normal = 'http://', $ssl = 'https://' ) {
- if( yourls_is_ssl() )
- $url = str_replace( $normal, $ssl, $url );
- return yourls_apply_filter( 'match_current_protocol', $url );
-}
-
-/**
- * Fix $_SERVER['REQUEST_URI'] variable for various setups. Stolen from WP.
- *
- */
-function yourls_fix_request_uri() {
-
- $default_server_values = array(
- 'SERVER_SOFTWARE' => '',
- 'REQUEST_URI' => '',
- );
- $_SERVER = array_merge( $default_server_values, $_SERVER );
-
- // Fix for IIS when running with PHP ISAPI
- if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
-
- // IIS Mod-Rewrite
- if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
- $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
- }
- // IIS Isapi_Rewrite
- else if ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
- $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
- } else {
- // Use ORIG_PATH_INFO if there is no PATH_INFO
- if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
- $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
-
- // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
- if ( isset( $_SERVER['PATH_INFO'] ) ) {
- if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
- $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
- else
- $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
- }
-
- // Append the query string if it exists and isn't null
- if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
- $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
- }
- }
- }
-}
-
-/**
- * Shutdown function, runs just before PHP shuts down execution. Stolen from WP
- *
- */
-function yourls_shutdown() {
- yourls_do_action( 'shutdown' );
-}
-
-/**
- * Auto detect custom favicon in /user directory, fallback to YOURLS favicon, and echo/return its URL
- *
- */
-function yourls_favicon( $echo = true ) {
- static $favicon = null;
- if( $favicon !== null )
- return $favicon;
-
- $custom = null;
- // search for favicon.(gif|ico|png|jpg|svg)
- foreach( array( 'gif', 'ico', 'png', 'jpg', 'svg' ) as $ext ) {
- if( file_exists( YOURLS_USERDIR. '/favicon.' . $ext ) ) {
- $custom = 'favicon.' . $ext;
- break;
- }
- }
-
- if( $custom ) {
- $favicon = yourls_site_url( false, YOURLS_USERURL . '/' . $custom );
- } else {
- $favicon = yourls_site_url( false ) . '/images/favicon.gif';
- }
- if( $echo )
- echo $favicon;
- return $favicon;
-}
-
-/**
- * Check for maintenance mode. If yes, die. See yourls_maintenance_mode(). Stolen from WP.
- *
- */
-function yourls_check_maintenance_mode() {
-
- $file = YOURLS_ABSPATH . '/.maintenance' ;
- if ( !file_exists( $file ) || yourls_is_upgrading() || yourls_is_installing() )
- return;
-
- global $maintenance_start;
-
- include_once( $file );
- // If the $maintenance_start timestamp is older than 10 minutes, don't die.
- if ( ( time() - $maintenance_start ) >= 600 )
- return;
-
- // Use any /user/maintenance.php file
- if( file_exists( YOURLS_USERDIR.'/maintenance.php' ) ) {
- include_once( YOURLS_USERDIR.'/maintenance.php' );
- die();
- }
-
- // https://www.youtube.com/watch?v=Xw-m4jEY-Ns
- $title = yourls__( 'Service temporarily unavailable' );
- $message = yourls__( 'Our service is currently undergoing scheduled maintenance.' ) . "\n" .
- yourls__( 'Things should not last very long, thank you for your patience and please excuse the inconvenience' );
- yourls_die( $message, $title , 503 );
-
-}
-
-/**
- * Return current admin page, or null if not an admin page
- *
- * @return mixed string if admin page, null if not an admin page
- * @since 1.6
- */
-function yourls_current_admin_page() {
- if( yourls_is_admin() ) {
- $current = substr( yourls_get_request(), 6 );
- if( $current === false )
- $current = 'index.php'; // if current page is http://sho.rt/admin/ instead of http://sho.rt/admin/index.php
-
- return $current;
- }
- return null;
-}
-
-/**
- * Check if a URL protocol is allowed
- *
- * Checks a URL against a list of whitelisted protocols. Protocols must be defined with
- * their complete scheme name, ie 'stuff:' or 'stuff://' (for instance, 'mailto:' is a valid
- * protocol, 'mailto://' isn't, and 'http:' with no double slashed isn't either
- *
- * @since 1.6
- *
- * @param string $url URL to be check
- * @param array $protocols Optional. Array of protocols, defaults to global $yourls_allowedprotocols
- * @return boolean true if protocol allowed, false otherwise
- */
-function yourls_is_allowed_protocol( $url, $protocols = array() ) {
- if( ! $protocols ) {
- global $yourls_allowedprotocols;
- $protocols = $yourls_allowedprotocols;
- }
-
- $protocol = yourls_get_protocol( $url );
- return yourls_apply_filter( 'is_allowed_protocol', in_array( $protocol, $protocols ), $url, $protocols );
-}
-
-/**
- * Get protocol from a URL (eg mailto:, http:// ...)
- *
- * @since 1.6
- *
- * @param string $url URL to be check
- * @return string Protocol, with slash slash if applicable. Empty string if no protocol
- */
-function yourls_get_protocol( $url ) {
- preg_match( '!^[a-zA-Z0-9\+\.-]+:(//)?!', $url, $matches );
- /*
- http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
- The scheme name consists of a sequence of characters beginning with a letter and followed by any
- combination of letters, digits, plus ("+"), period ("."), or hyphen ("-"). Although schemes are
- case-insensitive, the canonical form is lowercase and documents that specify schemes must do so
- with lowercase letters. It is followed by a colon (":").
- */
- $protocol = ( isset( $matches[0] ) ? $matches[0] : '' );
- return yourls_apply_filter( 'get_protocol', $protocol, $url );
-}
-
-/**
- * Get relative URL (eg 'abc' from 'http://sho.rt/abc')
- *
- * Treat indifferently http & https. If a URL isn't relative to the YOURLS install, return it as is
- * or return empty string if $strict is true
- *
- * @since 1.6
- * @param string $url URL to relativize
- * @param bool $strict if true and if URL isn't relative to YOURLS install, return empty string
- * @return string URL
- */
-function yourls_get_relative_url( $url, $strict = true ) {
- $url = yourls_sanitize_url( $url );
-
- // Remove protocols to make it easier
- $noproto_url = str_replace( 'https:', 'http:', $url );
- $noproto_site = str_replace( 'https:', 'http:', YOURLS_SITE );
-
- // Trim URL from YOURLS root URL : if no modification made, URL wasn't relative
- $_url = str_replace( $noproto_site . '/', '', $noproto_url );
- if( $_url == $noproto_url )
- $_url = ( $strict ? '' : $url );
-
- return yourls_apply_filter( 'get_relative_url', $_url, $url );
-}
-
-/**
- * Marks a function as deprecated and informs when it has been used. Stolen from WP.
- *
- * There is a hook deprecated_function that will be called that can be used
- * to get the backtrace up to what file and function called the deprecated
- * function.
- *
- * The current behavior is to trigger a user error if YOURLS_DEBUG is true.
- *
- * This function is to be used in every function that is deprecated.
- *
- * @since 1.6
- * @uses yourls_do_action() Calls 'deprecated_function' and passes the function name, what to use instead,
- * and the version the function was deprecated in.
- * @uses yourls_apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do
- * trigger or false to not trigger error.
- *
- * @param string $function The function that was called
- * @param string $version The version of WordPress that deprecated the function
- * @param string $replacement Optional. The function that should have been called
- */
-function yourls_deprecated_function( $function, $version, $replacement = null ) {
-
- yourls_do_action( 'deprecated_function', $function, $replacement, $version );
-
- // Allow plugin to filter the output error trigger
- if ( YOURLS_DEBUG && yourls_apply_filters( 'deprecated_function_trigger_error', true ) ) {
- if ( ! is_null( $replacement ) )
- trigger_error( sprintf( yourls__('%1$s is deprecated since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
- else
- trigger_error( sprintf( yourls__('%1$s is deprecated since version %2$s with no alternative available.'), $function, $version ) );
- }
-}
-
-/**
- * Return the value if not an empty string
- *
- * Used with array_filter(), to remove empty keys but not keys with value 0 or false
- *
- * @since 1.6
- * @param mixed $val Value to test against ''
- * @return bool True if not an empty string
- */
-function yourls_return_if_not_empty_string( $val ) {
- return( $val !== '' );
-}
-
-/**
- * Add a message to the debug log
- *
- * When in debug mode ( YOURLS_DEBUG == true ) the debug log is echoed in yourls_html_footer()
- * Log messages are appended to $ydb->debug_log array, which is instanciated within class ezSQLcore_YOURLS
- *
- * @since 1.7
- * @param string $msg Message to add to the debug log
- * @return string The message itself
- */
-function yourls_debug_log( $msg ) {
- global $ydb;
- $ydb->debug_log[] = $msg;
- return $msg;
-}
-
-/**
- * Explode a URL in an array of ( 'protocol' , 'slashes if any', 'rest of the URL' )
- *
- * Some hosts trip up when a query string contains 'http://' - see http://git.io/j1FlJg
- * The idea is that instead of passing the whole URL to a bookmarklet, eg index.php?u=http://blah.com,
- * we pass it by pieces to fool the server, eg index.php?proto=http:&slashes=//&rest=blah.com
- *
- * Known limitation: this won't work if the rest of the URL itself contains 'http://', for example
- * if rest = blah.com/file.php?url=http://foo.com
- *
- * Sample returns:
- *
- * with 'mailto:jsmith@example.com?subject=hey' :
- * array( 'protocol' => 'mailto:', 'slashes' => '', 'rest' => 'jsmith@example.com?subject=hey' )
- *
- * with 'http://example.com/blah.html' :
- * array( 'protocol' => 'http:', 'slashes' => '//', 'rest' => 'example.com/blah.html' )
- *
- * @since 1.7
- * @param string $url URL to be parsed
- * @param array $array Optional, array of key names to be used in returned array
- * @return mixed false if no protocol found, array of ('protocol' , 'slashes', 'rest') otherwise
- */
-function yourls_get_protocol_slashes_and_rest( $url, $array = array( 'protocol', 'slashes', 'rest' ) ) {
- $proto = yourls_get_protocol( $url );
-
- if( !$proto or count( $array ) != 3 )
- return false;
-
- list( $null, $rest ) = explode( $proto, $url, 2 );
-
- list( $proto, $slashes ) = explode( ':', $proto );
-
- return array( $array[0] => $proto . ':', $array[1] => $slashes, $array[2] => $rest );
-}
-
diff --git a/sources/includes/geo/GeoIP.dat b/sources/includes/geo/GeoIP.dat
deleted file mode 100644
index 43fba25..0000000
Binary files a/sources/includes/geo/GeoIP.dat and /dev/null differ
diff --git a/sources/includes/geo/GeoIPv6.dat b/sources/includes/geo/GeoIPv6.dat
deleted file mode 100644
index a99e7f6..0000000
Binary files a/sources/includes/geo/GeoIPv6.dat and /dev/null differ
diff --git a/sources/includes/geo/README.md b/sources/includes/geo/README.md
deleted file mode 100644
index 58a40e6..0000000
--- a/sources/includes/geo/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-GeoIP package for YOURLS
-========================
-
-What the hell?
---------------
-
-Text files from this package (GeoIP.dat and geoip.inc) are provided free by
-MaxMind. Accuracy is 99.5% so don't sweat it if you get unrealistic results.
-
-If unsure, you can always get the latest version of the GeoIP database
-from the following URL: http://www.maxmind.com/app/geolitecountry
-(look for a link pointing to a file named "GeoIP.dat.gz")
-
-Flag files from this package come from various sources. Feel free to copy and
-redistribute them just as I'm doing :)
-
-How to install this package
----------------------------
-
-* In directory "includes", create a subdirectory "geo", so you have the
-following directory structure:
-
- [yourls_root]
- +--admin
- +--[other directories...]
- +--includes
- +--geo
-
-* Put the content of this package (files GeoIP.dat and geoip.inc) into
-the freshly created "geo" subdirectory
diff --git a/sources/includes/geo/flags/flag_.gif b/sources/includes/geo/flags/flag_.gif
deleted file mode 100644
index 6aed16e..0000000
Binary files a/sources/includes/geo/flags/flag_.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_a1.gif b/sources/includes/geo/flags/flag_a1.gif
deleted file mode 100644
index f6e15ef..0000000
Binary files a/sources/includes/geo/flags/flag_a1.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_a2.gif b/sources/includes/geo/flags/flag_a2.gif
deleted file mode 100644
index f6e15ef..0000000
Binary files a/sources/includes/geo/flags/flag_a2.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ac.gif b/sources/includes/geo/flags/flag_ac.gif
deleted file mode 100644
index 1e675c9..0000000
Binary files a/sources/includes/geo/flags/flag_ac.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ad.gif b/sources/includes/geo/flags/flag_ad.gif
deleted file mode 100644
index 0e5fc84..0000000
Binary files a/sources/includes/geo/flags/flag_ad.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ae.gif b/sources/includes/geo/flags/flag_ae.gif
deleted file mode 100644
index a918961..0000000
Binary files a/sources/includes/geo/flags/flag_ae.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_af.gif b/sources/includes/geo/flags/flag_af.gif
deleted file mode 100644
index a346b27..0000000
Binary files a/sources/includes/geo/flags/flag_af.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ag.gif b/sources/includes/geo/flags/flag_ag.gif
deleted file mode 100644
index 13d218d..0000000
Binary files a/sources/includes/geo/flags/flag_ag.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ai.gif b/sources/includes/geo/flags/flag_ai.gif
deleted file mode 100644
index e35c316..0000000
Binary files a/sources/includes/geo/flags/flag_ai.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_al.gif b/sources/includes/geo/flags/flag_al.gif
deleted file mode 100644
index 96be1ad..0000000
Binary files a/sources/includes/geo/flags/flag_al.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_am.gif b/sources/includes/geo/flags/flag_am.gif
deleted file mode 100644
index 1ba4423..0000000
Binary files a/sources/includes/geo/flags/flag_am.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_an.gif b/sources/includes/geo/flags/flag_an.gif
deleted file mode 100644
index 3a0f4d9..0000000
Binary files a/sources/includes/geo/flags/flag_an.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ao.gif b/sources/includes/geo/flags/flag_ao.gif
deleted file mode 100644
index dc05e9e..0000000
Binary files a/sources/includes/geo/flags/flag_ao.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ap.gif b/sources/includes/geo/flags/flag_ap.gif
deleted file mode 100644
index a30fff6..0000000
Binary files a/sources/includes/geo/flags/flag_ap.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_aq.gif b/sources/includes/geo/flags/flag_aq.gif
deleted file mode 100644
index 0fed156..0000000
Binary files a/sources/includes/geo/flags/flag_aq.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ar.gif b/sources/includes/geo/flags/flag_ar.gif
deleted file mode 100644
index 6d86a4c..0000000
Binary files a/sources/includes/geo/flags/flag_ar.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_as.gif b/sources/includes/geo/flags/flag_as.gif
deleted file mode 100644
index 228c734..0000000
Binary files a/sources/includes/geo/flags/flag_as.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_at.gif b/sources/includes/geo/flags/flag_at.gif
deleted file mode 100644
index 284e42a..0000000
Binary files a/sources/includes/geo/flags/flag_at.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_au.gif b/sources/includes/geo/flags/flag_au.gif
deleted file mode 100644
index 6b3c09b..0000000
Binary files a/sources/includes/geo/flags/flag_au.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_aw.gif b/sources/includes/geo/flags/flag_aw.gif
deleted file mode 100644
index 457ce16..0000000
Binary files a/sources/includes/geo/flags/flag_aw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ax.gif b/sources/includes/geo/flags/flag_ax.gif
deleted file mode 100644
index b5e3a75..0000000
Binary files a/sources/includes/geo/flags/flag_ax.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_az.gif b/sources/includes/geo/flags/flag_az.gif
deleted file mode 100644
index f8827a8..0000000
Binary files a/sources/includes/geo/flags/flag_az.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ba.gif b/sources/includes/geo/flags/flag_ba.gif
deleted file mode 100644
index 3fc70ea..0000000
Binary files a/sources/includes/geo/flags/flag_ba.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bb.gif b/sources/includes/geo/flags/flag_bb.gif
deleted file mode 100644
index c37a61f..0000000
Binary files a/sources/includes/geo/flags/flag_bb.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bd.gif b/sources/includes/geo/flags/flag_bd.gif
deleted file mode 100644
index 1b20dac..0000000
Binary files a/sources/includes/geo/flags/flag_bd.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_be.gif b/sources/includes/geo/flags/flag_be.gif
deleted file mode 100644
index 21b0c69..0000000
Binary files a/sources/includes/geo/flags/flag_be.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bf.gif b/sources/includes/geo/flags/flag_bf.gif
deleted file mode 100644
index 1b4b1d4..0000000
Binary files a/sources/includes/geo/flags/flag_bf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bg.gif b/sources/includes/geo/flags/flag_bg.gif
deleted file mode 100644
index a620896..0000000
Binary files a/sources/includes/geo/flags/flag_bg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bh.gif b/sources/includes/geo/flags/flag_bh.gif
deleted file mode 100644
index 6da7214..0000000
Binary files a/sources/includes/geo/flags/flag_bh.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bi.gif b/sources/includes/geo/flags/flag_bi.gif
deleted file mode 100644
index b91c9e3..0000000
Binary files a/sources/includes/geo/flags/flag_bi.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bj.gif b/sources/includes/geo/flags/flag_bj.gif
deleted file mode 100644
index 184b5a4..0000000
Binary files a/sources/includes/geo/flags/flag_bj.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bl.gif b/sources/includes/geo/flags/flag_bl.gif
deleted file mode 100644
index 17538cf..0000000
Binary files a/sources/includes/geo/flags/flag_bl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bm.gif b/sources/includes/geo/flags/flag_bm.gif
deleted file mode 100644
index 7faceb0..0000000
Binary files a/sources/includes/geo/flags/flag_bm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bn.gif b/sources/includes/geo/flags/flag_bn.gif
deleted file mode 100644
index 7d330a4..0000000
Binary files a/sources/includes/geo/flags/flag_bn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bo.gif b/sources/includes/geo/flags/flag_bo.gif
deleted file mode 100644
index 626649e..0000000
Binary files a/sources/includes/geo/flags/flag_bo.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_br.gif b/sources/includes/geo/flags/flag_br.gif
deleted file mode 100644
index 361fe5e..0000000
Binary files a/sources/includes/geo/flags/flag_br.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bs.gif b/sources/includes/geo/flags/flag_bs.gif
deleted file mode 100644
index 2969ce8..0000000
Binary files a/sources/includes/geo/flags/flag_bs.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bt.gif b/sources/includes/geo/flags/flag_bt.gif
deleted file mode 100644
index 0e64420..0000000
Binary files a/sources/includes/geo/flags/flag_bt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bv.gif b/sources/includes/geo/flags/flag_bv.gif
deleted file mode 100644
index 79eb1c3..0000000
Binary files a/sources/includes/geo/flags/flag_bv.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bw.gif b/sources/includes/geo/flags/flag_bw.gif
deleted file mode 100644
index 849349a..0000000
Binary files a/sources/includes/geo/flags/flag_bw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bx.gif b/sources/includes/geo/flags/flag_bx.gif
deleted file mode 100644
index 17538cf..0000000
Binary files a/sources/includes/geo/flags/flag_bx.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_by.gif b/sources/includes/geo/flags/flag_by.gif
deleted file mode 100644
index 6712ad1..0000000
Binary files a/sources/includes/geo/flags/flag_by.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_bz.gif b/sources/includes/geo/flags/flag_bz.gif
deleted file mode 100644
index fab38e8..0000000
Binary files a/sources/includes/geo/flags/flag_bz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ca.gif b/sources/includes/geo/flags/flag_ca.gif
deleted file mode 100644
index 777c3b7..0000000
Binary files a/sources/includes/geo/flags/flag_ca.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cc.gif b/sources/includes/geo/flags/flag_cc.gif
deleted file mode 100644
index 4fc21e6..0000000
Binary files a/sources/includes/geo/flags/flag_cc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cd.gif b/sources/includes/geo/flags/flag_cd.gif
deleted file mode 100644
index 58afe00..0000000
Binary files a/sources/includes/geo/flags/flag_cd.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cf.gif b/sources/includes/geo/flags/flag_cf.gif
deleted file mode 100644
index ddc219c..0000000
Binary files a/sources/includes/geo/flags/flag_cf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cg.gif b/sources/includes/geo/flags/flag_cg.gif
deleted file mode 100644
index 8096c94..0000000
Binary files a/sources/includes/geo/flags/flag_cg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ch.gif b/sources/includes/geo/flags/flag_ch.gif
deleted file mode 100644
index bdf616a..0000000
Binary files a/sources/includes/geo/flags/flag_ch.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ci.gif b/sources/includes/geo/flags/flag_ci.gif
deleted file mode 100644
index 1aa43fd..0000000
Binary files a/sources/includes/geo/flags/flag_ci.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ck.gif b/sources/includes/geo/flags/flag_ck.gif
deleted file mode 100644
index 6e704f3..0000000
Binary files a/sources/includes/geo/flags/flag_ck.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cl.gif b/sources/includes/geo/flags/flag_cl.gif
deleted file mode 100644
index 03ffacb..0000000
Binary files a/sources/includes/geo/flags/flag_cl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cm.gif b/sources/includes/geo/flags/flag_cm.gif
deleted file mode 100644
index 0f579d5..0000000
Binary files a/sources/includes/geo/flags/flag_cm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cn.gif b/sources/includes/geo/flags/flag_cn.gif
deleted file mode 100644
index d1c350b..0000000
Binary files a/sources/includes/geo/flags/flag_cn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_co.gif b/sources/includes/geo/flags/flag_co.gif
deleted file mode 100644
index 0ff4ad2..0000000
Binary files a/sources/includes/geo/flags/flag_co.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cr.gif b/sources/includes/geo/flags/flag_cr.gif
deleted file mode 100644
index 2e3626d..0000000
Binary files a/sources/includes/geo/flags/flag_cr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cs.gif b/sources/includes/geo/flags/flag_cs.gif
deleted file mode 100644
index 57a2ca2..0000000
Binary files a/sources/includes/geo/flags/flag_cs.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cu.gif b/sources/includes/geo/flags/flag_cu.gif
deleted file mode 100644
index 545fa21..0000000
Binary files a/sources/includes/geo/flags/flag_cu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cv.gif b/sources/includes/geo/flags/flag_cv.gif
deleted file mode 100644
index 7645ad8..0000000
Binary files a/sources/includes/geo/flags/flag_cv.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cx.gif b/sources/includes/geo/flags/flag_cx.gif
deleted file mode 100644
index 4dac86a..0000000
Binary files a/sources/includes/geo/flags/flag_cx.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cy.gif b/sources/includes/geo/flags/flag_cy.gif
deleted file mode 100644
index 9b33f3a..0000000
Binary files a/sources/includes/geo/flags/flag_cy.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_cz.gif b/sources/includes/geo/flags/flag_cz.gif
deleted file mode 100644
index 334c528..0000000
Binary files a/sources/includes/geo/flags/flag_cz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_de.gif b/sources/includes/geo/flags/flag_de.gif
deleted file mode 100644
index 4a7cff4..0000000
Binary files a/sources/includes/geo/flags/flag_de.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_dj.gif b/sources/includes/geo/flags/flag_dj.gif
deleted file mode 100644
index 69efdc4..0000000
Binary files a/sources/includes/geo/flags/flag_dj.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_dk.gif b/sources/includes/geo/flags/flag_dk.gif
deleted file mode 100644
index 1d20035..0000000
Binary files a/sources/includes/geo/flags/flag_dk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_dm.gif b/sources/includes/geo/flags/flag_dm.gif
deleted file mode 100644
index dc1e2b9..0000000
Binary files a/sources/includes/geo/flags/flag_dm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_do.gif b/sources/includes/geo/flags/flag_do.gif
deleted file mode 100644
index b94f549..0000000
Binary files a/sources/includes/geo/flags/flag_do.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_dz.gif b/sources/includes/geo/flags/flag_dz.gif
deleted file mode 100644
index 3ff2317..0000000
Binary files a/sources/includes/geo/flags/flag_dz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ec.gif b/sources/includes/geo/flags/flag_ec.gif
deleted file mode 100644
index a555bf4..0000000
Binary files a/sources/includes/geo/flags/flag_ec.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ee.gif b/sources/includes/geo/flags/flag_ee.gif
deleted file mode 100644
index 95c3e98..0000000
Binary files a/sources/includes/geo/flags/flag_ee.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_eg.gif b/sources/includes/geo/flags/flag_eg.gif
deleted file mode 100644
index 55463de..0000000
Binary files a/sources/includes/geo/flags/flag_eg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_eh.gif b/sources/includes/geo/flags/flag_eh.gif
deleted file mode 100644
index fe8d445..0000000
Binary files a/sources/includes/geo/flags/flag_eh.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_er.gif b/sources/includes/geo/flags/flag_er.gif
deleted file mode 100644
index 23350fd..0000000
Binary files a/sources/includes/geo/flags/flag_er.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_es.gif b/sources/includes/geo/flags/flag_es.gif
deleted file mode 100644
index 83c3019..0000000
Binary files a/sources/includes/geo/flags/flag_es.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_et.gif b/sources/includes/geo/flags/flag_et.gif
deleted file mode 100644
index 6b5ff0c..0000000
Binary files a/sources/includes/geo/flags/flag_et.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_eu.gif b/sources/includes/geo/flags/flag_eu.gif
deleted file mode 100644
index bf2d3ce..0000000
Binary files a/sources/includes/geo/flags/flag_eu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fi.gif b/sources/includes/geo/flags/flag_fi.gif
deleted file mode 100644
index e3d9574..0000000
Binary files a/sources/includes/geo/flags/flag_fi.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fj.gif b/sources/includes/geo/flags/flag_fj.gif
deleted file mode 100644
index 6db8bea..0000000
Binary files a/sources/includes/geo/flags/flag_fj.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fk.gif b/sources/includes/geo/flags/flag_fk.gif
deleted file mode 100644
index c537dfc..0000000
Binary files a/sources/includes/geo/flags/flag_fk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fm.gif b/sources/includes/geo/flags/flag_fm.gif
deleted file mode 100644
index 60110f4..0000000
Binary files a/sources/includes/geo/flags/flag_fm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fo.gif b/sources/includes/geo/flags/flag_fo.gif
deleted file mode 100644
index 3301bc2..0000000
Binary files a/sources/includes/geo/flags/flag_fo.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fr.gif b/sources/includes/geo/flags/flag_fr.gif
deleted file mode 100644
index 75a2345..0000000
Binary files a/sources/includes/geo/flags/flag_fr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_fx.gif b/sources/includes/geo/flags/flag_fx.gif
deleted file mode 100644
index 75a2345..0000000
Binary files a/sources/includes/geo/flags/flag_fx.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ga.gif b/sources/includes/geo/flags/flag_ga.gif
deleted file mode 100644
index a10762f..0000000
Binary files a/sources/includes/geo/flags/flag_ga.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gb.gif b/sources/includes/geo/flags/flag_gb.gif
deleted file mode 100644
index b44b08f..0000000
Binary files a/sources/includes/geo/flags/flag_gb.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gd.gif b/sources/includes/geo/flags/flag_gd.gif
deleted file mode 100644
index 1ebe6de..0000000
Binary files a/sources/includes/geo/flags/flag_gd.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ge.gif b/sources/includes/geo/flags/flag_ge.gif
deleted file mode 100644
index edb7356..0000000
Binary files a/sources/includes/geo/flags/flag_ge.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gf.gif b/sources/includes/geo/flags/flag_gf.gif
deleted file mode 100644
index 5725cb8..0000000
Binary files a/sources/includes/geo/flags/flag_gf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gg.gif b/sources/includes/geo/flags/flag_gg.gif
deleted file mode 100644
index 88efe2d..0000000
Binary files a/sources/includes/geo/flags/flag_gg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gh.gif b/sources/includes/geo/flags/flag_gh.gif
deleted file mode 100644
index 9fa4d13..0000000
Binary files a/sources/includes/geo/flags/flag_gh.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gi.gif b/sources/includes/geo/flags/flag_gi.gif
deleted file mode 100644
index 94073d7..0000000
Binary files a/sources/includes/geo/flags/flag_gi.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gl.gif b/sources/includes/geo/flags/flag_gl.gif
deleted file mode 100644
index 686983f..0000000
Binary files a/sources/includes/geo/flags/flag_gl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gm.gif b/sources/includes/geo/flags/flag_gm.gif
deleted file mode 100644
index 7816462..0000000
Binary files a/sources/includes/geo/flags/flag_gm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gn.gif b/sources/includes/geo/flags/flag_gn.gif
deleted file mode 100644
index eab57a3..0000000
Binary files a/sources/includes/geo/flags/flag_gn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gp.gif b/sources/includes/geo/flags/flag_gp.gif
deleted file mode 100644
index 0324f5b..0000000
Binary files a/sources/includes/geo/flags/flag_gp.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gq.gif b/sources/includes/geo/flags/flag_gq.gif
deleted file mode 100644
index db4fa1e..0000000
Binary files a/sources/includes/geo/flags/flag_gq.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gr.gif b/sources/includes/geo/flags/flag_gr.gif
deleted file mode 100644
index b20ce21..0000000
Binary files a/sources/includes/geo/flags/flag_gr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gs.gif b/sources/includes/geo/flags/flag_gs.gif
deleted file mode 100644
index 11e1d23..0000000
Binary files a/sources/includes/geo/flags/flag_gs.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gt.gif b/sources/includes/geo/flags/flag_gt.gif
deleted file mode 100644
index 214d2d5..0000000
Binary files a/sources/includes/geo/flags/flag_gt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gu.gif b/sources/includes/geo/flags/flag_gu.gif
deleted file mode 100644
index cf2431e..0000000
Binary files a/sources/includes/geo/flags/flag_gu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gw.gif b/sources/includes/geo/flags/flag_gw.gif
deleted file mode 100644
index 91f38bc..0000000
Binary files a/sources/includes/geo/flags/flag_gw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_gy.gif b/sources/includes/geo/flags/flag_gy.gif
deleted file mode 100644
index 63f9da9..0000000
Binary files a/sources/includes/geo/flags/flag_gy.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_hk.gif b/sources/includes/geo/flags/flag_hk.gif
deleted file mode 100644
index aab5f67..0000000
Binary files a/sources/includes/geo/flags/flag_hk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_hm.gif b/sources/includes/geo/flags/flag_hm.gif
deleted file mode 100644
index 1b25e04..0000000
Binary files a/sources/includes/geo/flags/flag_hm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_hn.gif b/sources/includes/geo/flags/flag_hn.gif
deleted file mode 100644
index 30e88ea..0000000
Binary files a/sources/includes/geo/flags/flag_hn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_hr.gif b/sources/includes/geo/flags/flag_hr.gif
deleted file mode 100644
index b4cc470..0000000
Binary files a/sources/includes/geo/flags/flag_hr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ht.gif b/sources/includes/geo/flags/flag_ht.gif
deleted file mode 100644
index f1b9609..0000000
Binary files a/sources/includes/geo/flags/flag_ht.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_hu.gif b/sources/includes/geo/flags/flag_hu.gif
deleted file mode 100644
index 78a5724..0000000
Binary files a/sources/includes/geo/flags/flag_hu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_id.gif b/sources/includes/geo/flags/flag_id.gif
deleted file mode 100644
index 8b288fa..0000000
Binary files a/sources/includes/geo/flags/flag_id.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ie.gif b/sources/includes/geo/flags/flag_ie.gif
deleted file mode 100644
index 4ec0ae2..0000000
Binary files a/sources/includes/geo/flags/flag_ie.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_il.gif b/sources/includes/geo/flags/flag_il.gif
deleted file mode 100644
index c6dc6b5..0000000
Binary files a/sources/includes/geo/flags/flag_il.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_im.gif b/sources/includes/geo/flags/flag_im.gif
deleted file mode 100644
index 4115d7d..0000000
Binary files a/sources/includes/geo/flags/flag_im.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_in.gif b/sources/includes/geo/flags/flag_in.gif
deleted file mode 100644
index a1c16ee..0000000
Binary files a/sources/includes/geo/flags/flag_in.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_io.gif b/sources/includes/geo/flags/flag_io.gif
deleted file mode 100644
index c2d8e85..0000000
Binary files a/sources/includes/geo/flags/flag_io.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_iq.gif b/sources/includes/geo/flags/flag_iq.gif
deleted file mode 100644
index c6283c2..0000000
Binary files a/sources/includes/geo/flags/flag_iq.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ir.gif b/sources/includes/geo/flags/flag_ir.gif
deleted file mode 100644
index f1e66af..0000000
Binary files a/sources/includes/geo/flags/flag_ir.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_is.gif b/sources/includes/geo/flags/flag_is.gif
deleted file mode 100644
index 23e9c6f..0000000
Binary files a/sources/includes/geo/flags/flag_is.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_it.gif b/sources/includes/geo/flags/flag_it.gif
deleted file mode 100644
index a6c5173..0000000
Binary files a/sources/includes/geo/flags/flag_it.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_je.gif b/sources/includes/geo/flags/flag_je.gif
deleted file mode 100644
index 45e2bc8..0000000
Binary files a/sources/includes/geo/flags/flag_je.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_jm.gif b/sources/includes/geo/flags/flag_jm.gif
deleted file mode 100644
index f56aebf..0000000
Binary files a/sources/includes/geo/flags/flag_jm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_jo.gif b/sources/includes/geo/flags/flag_jo.gif
deleted file mode 100644
index aef7cb9..0000000
Binary files a/sources/includes/geo/flags/flag_jo.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_jp.gif b/sources/includes/geo/flags/flag_jp.gif
deleted file mode 100644
index b645bc8..0000000
Binary files a/sources/includes/geo/flags/flag_jp.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ke.gif b/sources/includes/geo/flags/flag_ke.gif
deleted file mode 100644
index 657c531..0000000
Binary files a/sources/includes/geo/flags/flag_ke.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kg.gif b/sources/includes/geo/flags/flag_kg.gif
deleted file mode 100644
index 7c433f1..0000000
Binary files a/sources/includes/geo/flags/flag_kg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kh.gif b/sources/includes/geo/flags/flag_kh.gif
deleted file mode 100644
index 9149a67..0000000
Binary files a/sources/includes/geo/flags/flag_kh.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ki.gif b/sources/includes/geo/flags/flag_ki.gif
deleted file mode 100644
index a805123..0000000
Binary files a/sources/includes/geo/flags/flag_ki.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_km.gif b/sources/includes/geo/flags/flag_km.gif
deleted file mode 100644
index e9d076d..0000000
Binary files a/sources/includes/geo/flags/flag_km.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kn.gif b/sources/includes/geo/flags/flag_kn.gif
deleted file mode 100644
index a26b0ae..0000000
Binary files a/sources/includes/geo/flags/flag_kn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kp.gif b/sources/includes/geo/flags/flag_kp.gif
deleted file mode 100644
index ede846a..0000000
Binary files a/sources/includes/geo/flags/flag_kp.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kr.gif b/sources/includes/geo/flags/flag_kr.gif
deleted file mode 100644
index fb33719..0000000
Binary files a/sources/includes/geo/flags/flag_kr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kw.gif b/sources/includes/geo/flags/flag_kw.gif
deleted file mode 100644
index 2124471..0000000
Binary files a/sources/includes/geo/flags/flag_kw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ky.gif b/sources/includes/geo/flags/flag_ky.gif
deleted file mode 100644
index 04941c9..0000000
Binary files a/sources/includes/geo/flags/flag_ky.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_kz.gif b/sources/includes/geo/flags/flag_kz.gif
deleted file mode 100644
index 8ff39eb..0000000
Binary files a/sources/includes/geo/flags/flag_kz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_la.gif b/sources/includes/geo/flags/flag_la.gif
deleted file mode 100644
index 19457e0..0000000
Binary files a/sources/includes/geo/flags/flag_la.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lb.gif b/sources/includes/geo/flags/flag_lb.gif
deleted file mode 100644
index fe9916c..0000000
Binary files a/sources/includes/geo/flags/flag_lb.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lc.gif b/sources/includes/geo/flags/flag_lc.gif
deleted file mode 100644
index 9a0f59c..0000000
Binary files a/sources/includes/geo/flags/flag_lc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_le.gif b/sources/includes/geo/flags/flag_le.gif
deleted file mode 100644
index 01359f1..0000000
Binary files a/sources/includes/geo/flags/flag_le.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_li.gif b/sources/includes/geo/flags/flag_li.gif
deleted file mode 100644
index 2eb3447..0000000
Binary files a/sources/includes/geo/flags/flag_li.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lk.gif b/sources/includes/geo/flags/flag_lk.gif
deleted file mode 100644
index ceb8ea7..0000000
Binary files a/sources/includes/geo/flags/flag_lk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lr.gif b/sources/includes/geo/flags/flag_lr.gif
deleted file mode 100644
index 1ef24ac..0000000
Binary files a/sources/includes/geo/flags/flag_lr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ls.gif b/sources/includes/geo/flags/flag_ls.gif
deleted file mode 100644
index 317807b..0000000
Binary files a/sources/includes/geo/flags/flag_ls.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lt.gif b/sources/includes/geo/flags/flag_lt.gif
deleted file mode 100644
index 36ccb43..0000000
Binary files a/sources/includes/geo/flags/flag_lt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lu.gif b/sources/includes/geo/flags/flag_lu.gif
deleted file mode 100644
index a59189b..0000000
Binary files a/sources/includes/geo/flags/flag_lu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_lv.gif b/sources/includes/geo/flags/flag_lv.gif
deleted file mode 100644
index 9fd8286..0000000
Binary files a/sources/includes/geo/flags/flag_lv.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ly.gif b/sources/includes/geo/flags/flag_ly.gif
deleted file mode 100644
index a0c2593..0000000
Binary files a/sources/includes/geo/flags/flag_ly.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ma.gif b/sources/includes/geo/flags/flag_ma.gif
deleted file mode 100644
index 65103cb..0000000
Binary files a/sources/includes/geo/flags/flag_ma.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mc.gif b/sources/includes/geo/flags/flag_mc.gif
deleted file mode 100644
index 8793e78..0000000
Binary files a/sources/includes/geo/flags/flag_mc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_md.gif b/sources/includes/geo/flags/flag_md.gif
deleted file mode 100644
index 786b52b..0000000
Binary files a/sources/includes/geo/flags/flag_md.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_me.gif b/sources/includes/geo/flags/flag_me.gif
deleted file mode 100644
index b16cb42..0000000
Binary files a/sources/includes/geo/flags/flag_me.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mf.gif b/sources/includes/geo/flags/flag_mf.gif
deleted file mode 100644
index 92df540..0000000
Binary files a/sources/includes/geo/flags/flag_mf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mg.gif b/sources/includes/geo/flags/flag_mg.gif
deleted file mode 100644
index 3395a60..0000000
Binary files a/sources/includes/geo/flags/flag_mg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mh.gif b/sources/includes/geo/flags/flag_mh.gif
deleted file mode 100644
index 34ca289..0000000
Binary files a/sources/includes/geo/flags/flag_mh.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mk.gif b/sources/includes/geo/flags/flag_mk.gif
deleted file mode 100644
index 5b7bef8..0000000
Binary files a/sources/includes/geo/flags/flag_mk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ml.gif b/sources/includes/geo/flags/flag_ml.gif
deleted file mode 100644
index ffda1e1..0000000
Binary files a/sources/includes/geo/flags/flag_ml.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mm.gif b/sources/includes/geo/flags/flag_mm.gif
deleted file mode 100644
index 0d5ec53..0000000
Binary files a/sources/includes/geo/flags/flag_mm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mn.gif b/sources/includes/geo/flags/flag_mn.gif
deleted file mode 100644
index efa313c..0000000
Binary files a/sources/includes/geo/flags/flag_mn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mo.gif b/sources/includes/geo/flags/flag_mo.gif
deleted file mode 100644
index 0f12662..0000000
Binary files a/sources/includes/geo/flags/flag_mo.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mp.gif b/sources/includes/geo/flags/flag_mp.gif
deleted file mode 100644
index c030d42..0000000
Binary files a/sources/includes/geo/flags/flag_mp.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mq.gif b/sources/includes/geo/flags/flag_mq.gif
deleted file mode 100644
index 36bcc68..0000000
Binary files a/sources/includes/geo/flags/flag_mq.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mr.gif b/sources/includes/geo/flags/flag_mr.gif
deleted file mode 100644
index 7730e71..0000000
Binary files a/sources/includes/geo/flags/flag_mr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ms.gif b/sources/includes/geo/flags/flag_ms.gif
deleted file mode 100644
index 02cf19d..0000000
Binary files a/sources/includes/geo/flags/flag_ms.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mt.gif b/sources/includes/geo/flags/flag_mt.gif
deleted file mode 100644
index 3b79dc9..0000000
Binary files a/sources/includes/geo/flags/flag_mt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mu.gif b/sources/includes/geo/flags/flag_mu.gif
deleted file mode 100644
index edf2440..0000000
Binary files a/sources/includes/geo/flags/flag_mu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mv.gif b/sources/includes/geo/flags/flag_mv.gif
deleted file mode 100644
index 007e53c..0000000
Binary files a/sources/includes/geo/flags/flag_mv.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mw.gif b/sources/includes/geo/flags/flag_mw.gif
deleted file mode 100644
index 35d63d7..0000000
Binary files a/sources/includes/geo/flags/flag_mw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mx.gif b/sources/includes/geo/flags/flag_mx.gif
deleted file mode 100644
index 3e7700f..0000000
Binary files a/sources/includes/geo/flags/flag_mx.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_my.gif b/sources/includes/geo/flags/flag_my.gif
deleted file mode 100644
index 91ae016..0000000
Binary files a/sources/includes/geo/flags/flag_my.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_mz.gif b/sources/includes/geo/flags/flag_mz.gif
deleted file mode 100644
index fc22320..0000000
Binary files a/sources/includes/geo/flags/flag_mz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_na.gif b/sources/includes/geo/flags/flag_na.gif
deleted file mode 100644
index 4bd510f..0000000
Binary files a/sources/includes/geo/flags/flag_na.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_nc.gif b/sources/includes/geo/flags/flag_nc.gif
deleted file mode 100644
index cdd13a9..0000000
Binary files a/sources/includes/geo/flags/flag_nc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ne.gif b/sources/includes/geo/flags/flag_ne.gif
deleted file mode 100644
index a611f61..0000000
Binary files a/sources/includes/geo/flags/flag_ne.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_nf.gif b/sources/includes/geo/flags/flag_nf.gif
deleted file mode 100644
index ebf68d8..0000000
Binary files a/sources/includes/geo/flags/flag_nf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ng.gif b/sources/includes/geo/flags/flag_ng.gif
deleted file mode 100644
index 81832c6..0000000
Binary files a/sources/includes/geo/flags/flag_ng.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ni.gif b/sources/includes/geo/flags/flag_ni.gif
deleted file mode 100644
index f783990..0000000
Binary files a/sources/includes/geo/flags/flag_ni.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_nl.gif b/sources/includes/geo/flags/flag_nl.gif
deleted file mode 100644
index 1469462..0000000
Binary files a/sources/includes/geo/flags/flag_nl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_no.gif b/sources/includes/geo/flags/flag_no.gif
deleted file mode 100644
index dbd2cbe..0000000
Binary files a/sources/includes/geo/flags/flag_no.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_np.gif b/sources/includes/geo/flags/flag_np.gif
deleted file mode 100644
index 8f288fb..0000000
Binary files a/sources/includes/geo/flags/flag_np.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_nr.gif b/sources/includes/geo/flags/flag_nr.gif
deleted file mode 100644
index 626775d..0000000
Binary files a/sources/includes/geo/flags/flag_nr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_nu.gif b/sources/includes/geo/flags/flag_nu.gif
deleted file mode 100644
index 1d515ab..0000000
Binary files a/sources/includes/geo/flags/flag_nu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_nz.gif b/sources/includes/geo/flags/flag_nz.gif
deleted file mode 100644
index e151943..0000000
Binary files a/sources/includes/geo/flags/flag_nz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_o1.gif b/sources/includes/geo/flags/flag_o1.gif
deleted file mode 100644
index f6e15ef..0000000
Binary files a/sources/includes/geo/flags/flag_o1.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_om.gif b/sources/includes/geo/flags/flag_om.gif
deleted file mode 100644
index a7e0fca..0000000
Binary files a/sources/includes/geo/flags/flag_om.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pa.gif b/sources/includes/geo/flags/flag_pa.gif
deleted file mode 100644
index 814280b..0000000
Binary files a/sources/includes/geo/flags/flag_pa.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pe.gif b/sources/includes/geo/flags/flag_pe.gif
deleted file mode 100644
index 19a0219..0000000
Binary files a/sources/includes/geo/flags/flag_pe.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pf.gif b/sources/includes/geo/flags/flag_pf.gif
deleted file mode 100644
index b1e1b95..0000000
Binary files a/sources/includes/geo/flags/flag_pf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pg.gif b/sources/includes/geo/flags/flag_pg.gif
deleted file mode 100644
index 4fe58b0..0000000
Binary files a/sources/includes/geo/flags/flag_pg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ph.gif b/sources/includes/geo/flags/flag_ph.gif
deleted file mode 100644
index eb38107..0000000
Binary files a/sources/includes/geo/flags/flag_ph.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pk.gif b/sources/includes/geo/flags/flag_pk.gif
deleted file mode 100644
index 6b64562..0000000
Binary files a/sources/includes/geo/flags/flag_pk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pl.gif b/sources/includes/geo/flags/flag_pl.gif
deleted file mode 100644
index 08397c1..0000000
Binary files a/sources/includes/geo/flags/flag_pl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pm.gif b/sources/includes/geo/flags/flag_pm.gif
deleted file mode 100644
index 38556aa..0000000
Binary files a/sources/includes/geo/flags/flag_pm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pn.gif b/sources/includes/geo/flags/flag_pn.gif
deleted file mode 100644
index fe10ca0..0000000
Binary files a/sources/includes/geo/flags/flag_pn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pr.gif b/sources/includes/geo/flags/flag_pr.gif
deleted file mode 100644
index 14c2bcc..0000000
Binary files a/sources/includes/geo/flags/flag_pr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ps.gif b/sources/includes/geo/flags/flag_ps.gif
deleted file mode 100644
index 7828b5c..0000000
Binary files a/sources/includes/geo/flags/flag_ps.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pt.gif b/sources/includes/geo/flags/flag_pt.gif
deleted file mode 100644
index 5704a0c..0000000
Binary files a/sources/includes/geo/flags/flag_pt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_pw.gif b/sources/includes/geo/flags/flag_pw.gif
deleted file mode 100644
index dccaa30..0000000
Binary files a/sources/includes/geo/flags/flag_pw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_py.gif b/sources/includes/geo/flags/flag_py.gif
deleted file mode 100644
index 414916d..0000000
Binary files a/sources/includes/geo/flags/flag_py.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_qa.gif b/sources/includes/geo/flags/flag_qa.gif
deleted file mode 100644
index b1c4c09..0000000
Binary files a/sources/includes/geo/flags/flag_qa.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_re.gif b/sources/includes/geo/flags/flag_re.gif
deleted file mode 100644
index 75a2345..0000000
Binary files a/sources/includes/geo/flags/flag_re.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ro.gif b/sources/includes/geo/flags/flag_ro.gif
deleted file mode 100644
index 5fdc82c..0000000
Binary files a/sources/includes/geo/flags/flag_ro.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_rs.gif b/sources/includes/geo/flags/flag_rs.gif
deleted file mode 100644
index ffa8e7f..0000000
Binary files a/sources/includes/geo/flags/flag_rs.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ru.gif b/sources/includes/geo/flags/flag_ru.gif
deleted file mode 100644
index 81c864f..0000000
Binary files a/sources/includes/geo/flags/flag_ru.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_rw.gif b/sources/includes/geo/flags/flag_rw.gif
deleted file mode 100644
index 20d662a..0000000
Binary files a/sources/includes/geo/flags/flag_rw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sa.gif b/sources/includes/geo/flags/flag_sa.gif
deleted file mode 100644
index cc9c030..0000000
Binary files a/sources/includes/geo/flags/flag_sa.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sb.gif b/sources/includes/geo/flags/flag_sb.gif
deleted file mode 100644
index 20a3df2..0000000
Binary files a/sources/includes/geo/flags/flag_sb.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sc.gif b/sources/includes/geo/flags/flag_sc.gif
deleted file mode 100644
index 464772c..0000000
Binary files a/sources/includes/geo/flags/flag_sc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sd.gif b/sources/includes/geo/flags/flag_sd.gif
deleted file mode 100644
index 1f7ca27..0000000
Binary files a/sources/includes/geo/flags/flag_sd.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_se.gif b/sources/includes/geo/flags/flag_se.gif
deleted file mode 100644
index 4096b9a..0000000
Binary files a/sources/includes/geo/flags/flag_se.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sg.gif b/sources/includes/geo/flags/flag_sg.gif
deleted file mode 100644
index b4d4f13..0000000
Binary files a/sources/includes/geo/flags/flag_sg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sh.gif b/sources/includes/geo/flags/flag_sh.gif
deleted file mode 100644
index 1e675c9..0000000
Binary files a/sources/includes/geo/flags/flag_sh.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_si.gif b/sources/includes/geo/flags/flag_si.gif
deleted file mode 100644
index 7401d6d..0000000
Binary files a/sources/includes/geo/flags/flag_si.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sj.gif b/sources/includes/geo/flags/flag_sj.gif
deleted file mode 100644
index 2280015..0000000
Binary files a/sources/includes/geo/flags/flag_sj.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sk.gif b/sources/includes/geo/flags/flag_sk.gif
deleted file mode 100644
index ea8da1e..0000000
Binary files a/sources/includes/geo/flags/flag_sk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sl.gif b/sources/includes/geo/flags/flag_sl.gif
deleted file mode 100644
index 474ddc3..0000000
Binary files a/sources/includes/geo/flags/flag_sl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sm.gif b/sources/includes/geo/flags/flag_sm.gif
deleted file mode 100644
index b93599d..0000000
Binary files a/sources/includes/geo/flags/flag_sm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sn.gif b/sources/includes/geo/flags/flag_sn.gif
deleted file mode 100644
index 9029d6b..0000000
Binary files a/sources/includes/geo/flags/flag_sn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_so.gif b/sources/includes/geo/flags/flag_so.gif
deleted file mode 100644
index 472e077..0000000
Binary files a/sources/includes/geo/flags/flag_so.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sr.gif b/sources/includes/geo/flags/flag_sr.gif
deleted file mode 100644
index 66b31af..0000000
Binary files a/sources/includes/geo/flags/flag_sr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_st.gif b/sources/includes/geo/flags/flag_st.gif
deleted file mode 100644
index f9af3c1..0000000
Binary files a/sources/includes/geo/flags/flag_st.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_su.gif b/sources/includes/geo/flags/flag_su.gif
deleted file mode 100644
index 8e869be..0000000
Binary files a/sources/includes/geo/flags/flag_su.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sv.gif b/sources/includes/geo/flags/flag_sv.gif
deleted file mode 100644
index af84d2d..0000000
Binary files a/sources/includes/geo/flags/flag_sv.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sy.gif b/sources/includes/geo/flags/flag_sy.gif
deleted file mode 100644
index d225175..0000000
Binary files a/sources/includes/geo/flags/flag_sy.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_sz.gif b/sources/includes/geo/flags/flag_sz.gif
deleted file mode 100644
index a6361fd..0000000
Binary files a/sources/includes/geo/flags/flag_sz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tc.gif b/sources/includes/geo/flags/flag_tc.gif
deleted file mode 100644
index b80c5d3..0000000
Binary files a/sources/includes/geo/flags/flag_tc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_td.gif b/sources/includes/geo/flags/flag_td.gif
deleted file mode 100644
index cb45de6..0000000
Binary files a/sources/includes/geo/flags/flag_td.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tf.gif b/sources/includes/geo/flags/flag_tf.gif
deleted file mode 100644
index 75a2345..0000000
Binary files a/sources/includes/geo/flags/flag_tf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tg.gif b/sources/includes/geo/flags/flag_tg.gif
deleted file mode 100644
index 07dfe68..0000000
Binary files a/sources/includes/geo/flags/flag_tg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_th.gif b/sources/includes/geo/flags/flag_th.gif
deleted file mode 100644
index 82e55c0..0000000
Binary files a/sources/includes/geo/flags/flag_th.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tj.gif b/sources/includes/geo/flags/flag_tj.gif
deleted file mode 100644
index 7dce531..0000000
Binary files a/sources/includes/geo/flags/flag_tj.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tk.gif b/sources/includes/geo/flags/flag_tk.gif
deleted file mode 100644
index 3b75bb0..0000000
Binary files a/sources/includes/geo/flags/flag_tk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tl.gif b/sources/includes/geo/flags/flag_tl.gif
deleted file mode 100644
index c8395e4..0000000
Binary files a/sources/includes/geo/flags/flag_tl.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tm.gif b/sources/includes/geo/flags/flag_tm.gif
deleted file mode 100644
index d188e87..0000000
Binary files a/sources/includes/geo/flags/flag_tm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tn.gif b/sources/includes/geo/flags/flag_tn.gif
deleted file mode 100644
index 2d0851c..0000000
Binary files a/sources/includes/geo/flags/flag_tn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_to.gif b/sources/includes/geo/flags/flag_to.gif
deleted file mode 100644
index 162a66f..0000000
Binary files a/sources/includes/geo/flags/flag_to.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tp.gif b/sources/includes/geo/flags/flag_tp.gif
deleted file mode 100644
index a16be20..0000000
Binary files a/sources/includes/geo/flags/flag_tp.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tr.gif b/sources/includes/geo/flags/flag_tr.gif
deleted file mode 100644
index 7c4926e..0000000
Binary files a/sources/includes/geo/flags/flag_tr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tt.gif b/sources/includes/geo/flags/flag_tt.gif
deleted file mode 100644
index e5190e1..0000000
Binary files a/sources/includes/geo/flags/flag_tt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tv.gif b/sources/includes/geo/flags/flag_tv.gif
deleted file mode 100644
index 304ba6f..0000000
Binary files a/sources/includes/geo/flags/flag_tv.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tw.gif b/sources/includes/geo/flags/flag_tw.gif
deleted file mode 100644
index 5dc317a..0000000
Binary files a/sources/includes/geo/flags/flag_tw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_tz.gif b/sources/includes/geo/flags/flag_tz.gif
deleted file mode 100644
index ac0d697..0000000
Binary files a/sources/includes/geo/flags/flag_tz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ua.gif b/sources/includes/geo/flags/flag_ua.gif
deleted file mode 100644
index 04a9dd1..0000000
Binary files a/sources/includes/geo/flags/flag_ua.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ug.gif b/sources/includes/geo/flags/flag_ug.gif
deleted file mode 100644
index 6fb4451..0000000
Binary files a/sources/includes/geo/flags/flag_ug.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_uk.gif b/sources/includes/geo/flags/flag_uk.gif
deleted file mode 100644
index b44b08f..0000000
Binary files a/sources/includes/geo/flags/flag_uk.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_um.gif b/sources/includes/geo/flags/flag_um.gif
deleted file mode 100644
index 130052f..0000000
Binary files a/sources/includes/geo/flags/flag_um.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_us.gif b/sources/includes/geo/flags/flag_us.gif
deleted file mode 100644
index 130052f..0000000
Binary files a/sources/includes/geo/flags/flag_us.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_uy.gif b/sources/includes/geo/flags/flag_uy.gif
deleted file mode 100644
index b0284f8..0000000
Binary files a/sources/includes/geo/flags/flag_uy.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_uz.gif b/sources/includes/geo/flags/flag_uz.gif
deleted file mode 100644
index 16e6ea5..0000000
Binary files a/sources/includes/geo/flags/flag_uz.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_va.gif b/sources/includes/geo/flags/flag_va.gif
deleted file mode 100644
index 0bfc62a..0000000
Binary files a/sources/includes/geo/flags/flag_va.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_vc.gif b/sources/includes/geo/flags/flag_vc.gif
deleted file mode 100644
index d306960..0000000
Binary files a/sources/includes/geo/flags/flag_vc.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ve.gif b/sources/includes/geo/flags/flag_ve.gif
deleted file mode 100644
index 0b80760..0000000
Binary files a/sources/includes/geo/flags/flag_ve.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_vg.gif b/sources/includes/geo/flags/flag_vg.gif
deleted file mode 100644
index 7a003c8..0000000
Binary files a/sources/includes/geo/flags/flag_vg.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_vi.gif b/sources/includes/geo/flags/flag_vi.gif
deleted file mode 100644
index 1f14ed1..0000000
Binary files a/sources/includes/geo/flags/flag_vi.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_vn.gif b/sources/includes/geo/flags/flag_vn.gif
deleted file mode 100644
index a48c113..0000000
Binary files a/sources/includes/geo/flags/flag_vn.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_vu.gif b/sources/includes/geo/flags/flag_vu.gif
deleted file mode 100644
index 8435856..0000000
Binary files a/sources/includes/geo/flags/flag_vu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_wf.gif b/sources/includes/geo/flags/flag_wf.gif
deleted file mode 100644
index 188f8d5..0000000
Binary files a/sources/includes/geo/flags/flag_wf.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ws.gif b/sources/includes/geo/flags/flag_ws.gif
deleted file mode 100644
index 6440bd2..0000000
Binary files a/sources/includes/geo/flags/flag_ws.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_ye.gif b/sources/includes/geo/flags/flag_ye.gif
deleted file mode 100644
index ea105b6..0000000
Binary files a/sources/includes/geo/flags/flag_ye.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_yt.gif b/sources/includes/geo/flags/flag_yt.gif
deleted file mode 100644
index 96f6afb..0000000
Binary files a/sources/includes/geo/flags/flag_yt.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_yu.gif b/sources/includes/geo/flags/flag_yu.gif
deleted file mode 100644
index e43f905..0000000
Binary files a/sources/includes/geo/flags/flag_yu.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_za.gif b/sources/includes/geo/flags/flag_za.gif
deleted file mode 100644
index ad0d7a0..0000000
Binary files a/sources/includes/geo/flags/flag_za.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_zm.gif b/sources/includes/geo/flags/flag_zm.gif
deleted file mode 100644
index dc8c142..0000000
Binary files a/sources/includes/geo/flags/flag_zm.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_zr.gif b/sources/includes/geo/flags/flag_zr.gif
deleted file mode 100644
index aff7fad..0000000
Binary files a/sources/includes/geo/flags/flag_zr.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_zw.gif b/sources/includes/geo/flags/flag_zw.gif
deleted file mode 100644
index 9369ae0..0000000
Binary files a/sources/includes/geo/flags/flag_zw.gif and /dev/null differ
diff --git a/sources/includes/geo/flags/flag_zz.gif b/sources/includes/geo/flags/flag_zz.gif
deleted file mode 100644
index 746812f..0000000
Binary files a/sources/includes/geo/flags/flag_zz.gif and /dev/null differ
diff --git a/sources/includes/geo/geoip.inc b/sources/includes/geo/geoip.inc
deleted file mode 100644
index 448563b..0000000
--- a/sources/includes/geo/geoip.inc
+++ /dev/null
@@ -1,768 +0,0 @@
- 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
-"AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "CW" => 10, "AO" => 11,
-"AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
-"AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
-"BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
-"BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
-"BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
-"CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
-"CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
-"CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
-"DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
-"ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
-"FM" => 72, "FO" => 73, "FR" => 74, "SX" => 75, "GA" => 76, "GB" => 77,
-"GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
-"GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
-"GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
-"HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
-"IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
-"IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
-"KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
-"KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
-"LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
-"LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
-"MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
-"MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
-"MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
-"NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
-"NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
-"PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
-"PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
-"PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
-"RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
-"SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
-"SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
-"SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
-"TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
-"TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
-"UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
-"VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
-"VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
-"ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
-"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
-"MF" => 252, "BQ" => 253, "SS" => 254
-);
- var $GEOIP_COUNTRY_CODES = array(
- "","AP","EU","AD","AE","AF","AG","AI","AL","AM","CW",
- "AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB",
- "BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO",
- "BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD",
- "CF","CG","CH","CI","CK","CL","CM","CN","CO","CR",
- "CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO",
- "DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ",
- "FK","FM","FO","FR","SX","GA","GB","GD","GE","GF",
- "GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT",
- "GU","GW","GY","HK","HM","HN","HR","HT","HU","ID",
- "IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO",
- "JP","KE","KG","KH","KI","KM","KN","KP","KR","KW",
- "KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT",
- "LU","LV","LY","MA","MC","MD","MG","MH","MK","ML",
- "MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV",
- "MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI",
- "NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF",
- "PG","PH","PK","PL","PM","PN","PR","PS","PT","PW",
- "PY","QA","RE","RO","RU","RW","SA","SB","SC","SD",
- "SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO",
- "SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH",
- "TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW",
- "TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE",
- "VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA",
- "ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE",
- "BL","MF", "BQ", "SS", "O1" );
- var $GEOIP_COUNTRY_CODES3 = array(
- "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","CUW",
- "AGO","ATA","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB",
- "BGD","BEL","BFA","BGR","BHR","BDI","BEN","BMU","BRN","BOL",
- "BRA","BHS","BTN","BVT","BWA","BLR","BLZ","CAN","CCK","COD",
- "CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI",
- "CUB","CPV","CXR","CYP","CZE","DEU","DJI","DNK","DMA","DOM",
- "DZA","ECU","EST","EGY","ESH","ERI","ESP","ETH","FIN","FJI",
- "FLK","FSM","FRO","FRA","SXM","GAB","GBR","GRD","GEO","GUF",
- "GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","SGS","GTM",
- "GUM","GNB","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN",
- "IRL","ISR","IND","IOT","IRQ","IRN","ISL","ITA","JAM","JOR",
- "JPN","KEN","KGZ","KHM","KIR","COM","KNA","PRK","KOR","KWT",
- "CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
- "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI",
- "MMR","MNG","MAC","MNP","MTQ","MRT","MSR","MLT","MUS","MDV",
- "MWI","MEX","MYS","MOZ","NAM","NCL","NER","NFK","NGA","NIC",
- "NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER","PYF",
- "PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW",
- "PRY","QAT","REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN",
- "SWE","SGP","SHN","SVN","SJM","SVK","SLE","SMR","SEN","SOM",
- "SUR","STP","SLV","SYR","SWZ","TCA","TCD","ATF","TGO","THA",
- "TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN",
- "TZA","UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN",
- "VGB","VIR","VNM","VUT","WLF","WSM","YEM","MYT","SRB","ZAF",
- "ZMB","MNE","ZWE","A1","A2","O1","ALA","GGY","IMN","JEY",
- "BLM","MAF", "BES", "SSD", "O1"
- );
- var $GEOIP_COUNTRY_NAMES = array(
- "","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Curacao",
- "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
- "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
- "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
- "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
- "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
- "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
- "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","Sint Maarten (Dutch part)","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
- "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
- "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
- "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
- "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
- "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
- "Luxembourg","Latvia","Libya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
- "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
- "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
- "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
- "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
- "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
- "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
- "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
- "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
- "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
- "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
- "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
- "Saint Barthelemy","Saint Martin", "Bonaire, Saint Eustatius and Saba",
- "South Sudan", "Other"
-);
-
- var $GEOIP_CONTINENT_CODES = array(
- "--", "AS","EU","EU","AS","AS","NA","NA","EU","AS","NA",
- "AF","AN","SA","OC","EU","OC","NA","AS","EU","NA",
- "AS","EU","AF","EU","AS","AF","AF","NA","AS","SA",
- "SA","NA","AS","AN","AF","EU","NA","NA","AS","AF",
- "AF","AF","EU","AF","OC","SA","AF","AS","SA","NA",
- "NA","AF","AS","AS","EU","EU","AF","EU","NA","NA",
- "AF","SA","EU","AF","AF","AF","EU","AF","EU","OC",
- "SA","OC","EU","EU","NA","AF","EU","NA","AS","SA",
- "AF","EU","NA","AF","AF","NA","AF","EU","AN","NA",
- "OC","AF","SA","AS","AN","NA","EU","NA","EU","AS",
- "EU","AS","AS","AS","AS","AS","EU","EU","NA","AS",
- "AS","AF","AS","AS","OC","AF","NA","AS","AS","AS",
- "NA","AS","AS","AS","NA","EU","AS","AF","AF","EU",
- "EU","EU","AF","AF","EU","EU","AF","OC","EU","AF",
- "AS","AS","AS","OC","NA","AF","NA","EU","AF","AS",
- "AF","NA","AS","AF","AF","OC","AF","OC","AF","NA",
- "EU","EU","AS","OC","OC","OC","AS","NA","SA","OC",
- "OC","AS","AS","EU","NA","OC","NA","AS","EU","OC",
- "SA","AS","AF","EU","EU","AF","AS","OC","AF","AF",
- "EU","AS","AF","EU","EU","EU","AF","EU","AF","AF",
- "SA","AF","NA","AS","AF","NA","AF","AN","AF","AS",
- "AS","OC","AS","AF","OC","AS","EU","NA","OC","AS",
- "AF","EU","AF","OC","NA","SA","AS","EU","NA","SA",
- "NA","NA","AS","OC","OC","OC","AS","AF","EU","AF",
- "AF","EU","AF","--","--","--","EU","EU","EU","EU",
- "NA","NA","NA", "AF", "--"
-);
-}
-} // class_exists
-
-if( !function_exists('geoip_load_shared_mem') ) {
-function geoip_load_shared_mem ($file) {
-
- $fp = fopen($file, "rb");
- if (!$fp) {
- print "error opening $file: $php_errormsg\n";
- exit;
- }
- $s_array = fstat($fp);
- $size = $s_array['size'];
- if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
- shmop_delete ($shmid);
- shmop_close ($shmid);
- }
- $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
- shmop_write ($shmid, fread($fp, $size), 0);
- shmop_close ($shmid);
-}
-} // function_exists
-
-if( !function_exists('_setup_segments') ) {
-function _setup_segments($gi){
- $gi->databaseType = GEOIP_COUNTRY_EDITION;
- $gi->record_length = STANDARD_RECORD_LENGTH;
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
- $offset = @shmop_size ($gi->shmid) - 3;
- for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
- $delim = @shmop_read ($gi->shmid, $offset, 3);
- $offset += 3;
- if ($delim == (chr(255).chr(255).chr(255))) {
- $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
- $offset++;
-
- if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
- } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
- } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
- ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
- || ($gi->databaseType == GEOIP_ORG_EDITION)
- || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
- || ($gi->databaseType == GEOIP_ISP_EDITION)
- || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
- || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
- || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)
- || ($gi->databaseType == GEOIP_ASNUM_EDITION)
- || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
- $gi->databaseSegments = 0;
- $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
- for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
- $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
- }
- if (($gi->databaseType == GEOIP_ORG_EDITION)
- || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
- || ($gi->databaseType == GEOIP_ISP_EDITION)
- || ($gi->databaseType == GEOIP_ISP_EDITION_V6)) {
- $gi->record_length = ORG_RECORD_LENGTH;
- }
- }
- break;
- } else {
- $offset -= 4;
- }
- }
- if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
- ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
- ($gi->databaseType == GEOIP_PROXY_EDITION)||
- ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
- $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
- }
- } else {
- $filepos = ftell($gi->filehandle);
- fseek($gi->filehandle, -3, SEEK_END);
- for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
- $delim = fread($gi->filehandle,3);
- if ($delim == (chr(255).chr(255).chr(255))){
- $gi->databaseType = ord(fread($gi->filehandle,1));
- if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
- }
- else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
- } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
- || ($gi->databaseType == GEOIP_ORG_EDITION)
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
- || ($gi->databaseType == GEOIP_ISP_EDITION)
- || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
- || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
- || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
- || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
- || ($gi->databaseType == GEOIP_ASNUM_EDITION)
- || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
- $gi->databaseSegments = 0;
- $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
- for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
- $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
- }
- if ( ( $gi->databaseType == GEOIP_ORG_EDITION )
- || ( $gi->databaseType == GEOIP_DOMAIN_EDITION )
- || ( $gi->databaseType == GEOIP_ISP_EDITION )
- || ( $gi->databaseType == GEOIP_ORG_EDITION_V6 )
- || ( $gi->databaseType == GEOIP_DOMAIN_EDITION_V6 )
- || ( $gi->databaseType == GEOIP_ISP_EDITION_V6 )) {
- $gi->record_length = ORG_RECORD_LENGTH;
- }
- }
- break;
- } else {
- fseek($gi->filehandle, -4, SEEK_CUR);
- }
- }
- if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
- ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
- ($gi->databaseType == GEOIP_PROXY_EDITION)||
- ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
- $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
- }
- fseek($gi->filehandle,$filepos,SEEK_SET);
- }
- return $gi;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_open' ) ) {
-function geoip_open($filename, $flags) {
- $gi = new GeoIP;
- $gi->flags = $flags;
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
- $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
- } else {
- $gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" );
- if ($gi->flags & GEOIP_MEMORY_CACHE) {
- $s_array = fstat($gi->filehandle);
- $gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
- }
- }
-
- $gi = _setup_segments($gi);
- return $gi;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_close' ) ) {
-function geoip_close($gi) {
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
- return true;
- }
-
- return fclose($gi->filehandle);
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_id_by_name_v6' ) ) {
-function geoip_country_id_by_name_v6($gi, $name) {
- $rec = dns_get_record($name, DNS_AAAA);
- if ( !$rec ) {
- return false;
- }
- $addr = $rec[0]["ipv6"];
- if (!$addr || $addr == $name) {
- return false;
- }
- return geoip_country_id_by_addr_v6($gi, $addr);
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_id_by_name' ) ) {
-function geoip_country_id_by_name($gi, $name) {
- $addr = gethostbyname($name);
- if (!$addr || $addr == $name) {
- return false;
- }
- return geoip_country_id_by_addr($gi, $addr);
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_code_by_name_v6' ) ) {
-function geoip_country_code_by_name_v6($gi, $name) {
- $country_id = geoip_country_id_by_name_v6($gi,$name);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_code_by_name' ) ) {
-function geoip_country_code_by_name($gi, $name) {
- $country_id = geoip_country_id_by_name($gi,$name);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_name_by_name_v6' ) ) {
-function geoip_country_name_by_name_v6($gi, $name) {
- $country_id = geoip_country_id_by_name_v6($gi,$name);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_name_by_name' ) ) {
-function geoip_country_name_by_name($gi, $name) {
- $country_id = geoip_country_id_by_name($gi,$name);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_id_by_addr_v6' ) ) {
-function geoip_country_id_by_addr_v6($gi, $addr) {
- $ipnum = inet_pton($addr);
- return _geoip_seek_country_v6($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_id_by_addr' ) ) {
-function geoip_country_id_by_addr($gi, $addr) {
- $ipnum = ip2long($addr);
- return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_code_by_addr_v6' ) ) {
-function geoip_country_code_by_addr_v6($gi, $addr) {
- $country_id = geoip_country_id_by_addr_v6($gi,$addr);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_code_by_addr' ) ) {
-function geoip_country_code_by_addr($gi, $addr) {
- if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
- $record = geoip_record_by_addr($gi,$addr);
- if ( $record !== false ) {
- return $record->country_code;
- }
- } else {
- $country_id = geoip_country_id_by_addr($gi,$addr);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
- }
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_name_by_addr_v6' ) ) {
-function geoip_country_name_by_addr_v6($gi, $addr) {
- $country_id = geoip_country_id_by_addr_v6($gi,$addr);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( 'geoip_country_name_by_addr' ) ) {
-function geoip_country_name_by_addr($gi, $addr) {
- if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
- $record = geoip_record_by_addr($gi,$addr);
- return $record->country_name;
- } else {
- $country_id = geoip_country_id_by_addr($gi,$addr);
- if ($country_id !== false) {
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
- }
- }
- return false;
-}
-} // function_exists
-
-if( !function_exists( '_geoip_seek_country_v6' ) ) {
-function _geoip_seek_country_v6($gi, $ipnum) {
-
- # arrays from unpack start with offset 1
- # yet another php mystery. array_merge work around
- # this broken behaviour
- $v6vec = array_merge(unpack( "C16", $ipnum));
-
- $offset = 0;
- for ($depth = 127; $depth >= 0; --$depth) {
- if ($gi->flags & GEOIP_MEMORY_CACHE) {
- // workaround php's broken substr, strpos, etc handling with
- // mbstring.func_overload and mbstring.internal_encoding
- $enc = mb_internal_encoding();
- mb_internal_encoding('ISO-8859-1');
-
- $buf = substr($gi->memory_buffer,
- 2 * $gi->record_length * $offset,
- 2 * $gi->record_length);
-
- mb_internal_encoding($enc);
- } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
- $buf = @shmop_read ($gi->shmid,
- 2 * $gi->record_length * $offset,
- 2 * $gi->record_length );
- } else {
- fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
- or die("fseek failed");
- $buf = fread($gi->filehandle, 2 * $gi->record_length);
- }
- $x = array(0,0);
- for ($i = 0; $i < 2; ++$i) {
- for ($j = 0; $j < $gi->record_length; ++$j) {
- $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
- }
- }
-
- $bnum = 127 - $depth;
- $idx = $bnum >> 3;
- $b_mask = 1 << ( $bnum & 7 ^ 7 );
- if (($v6vec[$idx] & $b_mask) > 0) {
- if ($x[1] >= $gi->databaseSegments) {
- return $x[1];
- }
- $offset = $x[1];
- } else {
- if ($x[0] >= $gi->databaseSegments) {
- return $x[0];
- }
- $offset = $x[0];
- }
- }
- trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
- return false;
-}
-} // function_exists
-
-if( !function_exists( '_geoip_seek_country' ) ) {
-function _geoip_seek_country($gi, $ipnum) {
- $offset = 0;
- for ($depth = 31; $depth >= 0; --$depth) {
- if ($gi->flags & GEOIP_MEMORY_CACHE) {
- // workaround php's broken substr, strpos, etc handling with
- // mbstring.func_overload and mbstring.internal_encoding
- $enc = mb_internal_encoding();
- mb_internal_encoding('ISO-8859-1');
-
- $buf = substr($gi->memory_buffer,
- 2 * $gi->record_length * $offset,
- 2 * $gi->record_length);
-
- mb_internal_encoding($enc);
- } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
- $buf = @shmop_read ($gi->shmid,
- 2 * $gi->record_length * $offset,
- 2 * $gi->record_length );
- } else {
- fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
- or die("fseek failed");
- $buf = fread($gi->filehandle, 2 * $gi->record_length);
- }
- $x = array(0,0);
- for ($i = 0; $i < 2; ++$i) {
- for ($j = 0; $j < $gi->record_length; ++$j) {
- $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
- }
- }
- if ($ipnum & (1 << $depth)) {
- if ($x[1] >= $gi->databaseSegments) {
- return $x[1];
- }
- $offset = $x[1];
- } else {
- if ($x[0] >= $gi->databaseSegments) {
- return $x[0];
- }
- $offset = $x[0];
- }
- }
- trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
- return false;
-}
-} // function_exists
-
-if( !function_exists( '_common_get_org' ) ) {
-function _common_get_org($gi, $seek_org){
- $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
- $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
- } else {
- fseek($gi->filehandle, $record_pointer, SEEK_SET);
- $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
- }
- // workaround php's broken substr, strpos, etc handling with
- // mbstring.func_overload and mbstring.internal_encoding
- $enc = mb_internal_encoding();
- mb_internal_encoding('ISO-8859-1');
- $org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
- mb_internal_encoding($enc);
- return $org_buf;
-}
-} // function_exists
-
-if( !function_exists( '_get_org_v6' ) ) {
-function _get_org_v6($gi,$ipnum){
- $seek_org = _geoip_seek_country_v6($gi,$ipnum);
- if ($seek_org == $gi->databaseSegments) {
- return NULL;
- }
- return _common_get_org($gi, $seek_org);
-}
-} // function_exists
-
-if( !function_exists( '_get_org' ) ) {
-function _get_org($gi,$ipnum){
- $seek_org = _geoip_seek_country($gi,$ipnum);
- if ($seek_org == $gi->databaseSegments) {
- return NULL;
- }
- return _common_get_org($gi, $seek_org);
-}
-} // function_exists
-
-
-
-if( !function_exists( 'geoip_name_by_addr_v6' ) ) {
-function geoip_name_by_addr_v6 ($gi,$addr) {
- if ($addr == NULL) {
- return 0;
- }
- $ipnum = inet_pton($addr);
- return _get_org_v6($gi, $ipnum);
-}
-} // function_exists
-
-if( !function_exists( 'geoip_name_by_addr' ) ) {
-function geoip_name_by_addr ($gi,$addr) {
- if ($addr == NULL) {
- return 0;
- }
- $ipnum = ip2long($addr);
- return _get_org($gi, $ipnum);
-}
-} // function_exists
-
-if( !function_exists( 'geoip_org_by_addr' ) ) {
-function geoip_org_by_addr ($gi,$addr) {
- return geoip_name_by_addr($gi, $addr);
-}
-} // function_exists
-
-if( !function_exists( '_get_region' ) ) {
-function _get_region($gi,$ipnum){
- if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
- $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
- if ($seek_region >= 1000){
- $country_code = "US";
- $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
- } else {
- $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
- $region = "";
- }
- return array ($country_code,$region);
- } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
- $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
- //print $seek_region;
- if ($seek_region < US_OFFSET){
- $country_code = "";
- $region = "";
- } else if ($seek_region < CANADA_OFFSET) {
- $country_code = "US";
- $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
- } else if ($seek_region < WORLD_OFFSET) {
- $country_code = "CA";
- $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
- } else {
- $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
- $region = "";
- }
- return array ($country_code,$region);
- }
-}
-} // function_exists
-
-if( !function_exists( 'geoip_region_by_addr' ) ) {
-function geoip_region_by_addr ($gi,$addr) {
- if ($addr == NULL) {
- return 0;
- }
- $ipnum = ip2long($addr);
- return _get_region($gi, $ipnum);
-}
-} // function_exists
-
-if( !function_exists( 'getdnsattributes' ) ) {
-function getdnsattributes ($l,$ip){
- $r = new Net_DNS_Resolver();
- $r->nameservers = array("ws1.maxmind.com");
- $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
- $str = is_object($p->answer[0])?$p->answer[0]->string():'';
- $str = substr( $str, 1, -1 );
- return $str;
-}
-} // function_exists
diff --git a/sources/includes/load-yourls.php b/sources/includes/load-yourls.php
deleted file mode 100644
index e808835..0000000
--- a/sources/includes/load-yourls.php
+++ /dev/null
@@ -1,186 +0,0 @@
-Cannot find config.php .
Please read the readme.html to learn how to install YOURLS
' );
-}
-require_once( YOURLS_CONFIGFILE );
-
-// Check if config.php was properly updated for 1.4
-if( !defined( 'YOURLS_DB_PREFIX' ) )
- die( 'Your config.php does not contain all the required constant definitions.
Please check config-sample.php and update your config accordingly, there are new stuffs!
' );
-
-
-// Define core constants that have not been user defined in config.php
-
-// physical path of YOURLS root
-if( !defined( 'YOURLS_ABSPATH' ) )
- define( 'YOURLS_ABSPATH', str_replace( '\\', '/', dirname( dirname( __FILE__ ) ) ) );
-
-// physical path of includes directory
-if( !defined( 'YOURLS_INC' ) )
- define( 'YOURLS_INC', YOURLS_ABSPATH.'/includes' );
-
-// physical path of user directory
-if( !defined( 'YOURLS_USERDIR' ) )
- define( 'YOURLS_USERDIR', YOURLS_ABSPATH.'/user' );
-
-// URL of user directory
-if( !defined( 'YOURLS_USERURL' ) )
- define( 'YOURLS_USERURL', YOURLS_SITE.'/user' );
-
-// physical path of translations directory
-if( !defined( 'YOURLS_LANG_DIR' ) )
- define( 'YOURLS_LANG_DIR', YOURLS_USERDIR.'/languages' );
-
-// physical path of plugins directory
-if( !defined( 'YOURLS_PLUGINDIR' ) )
- define( 'YOURLS_PLUGINDIR', YOURLS_USERDIR.'/plugins' );
-
-// URL of plugins directory
-if( !defined( 'YOURLS_PLUGINURL' ) )
- define( 'YOURLS_PLUGINURL', YOURLS_USERURL.'/plugins' );
-
-// physical path of pages directory
-if( !defined( 'YOURLS_PAGEDIR' ) )
- define('YOURLS_PAGEDIR', YOURLS_ABSPATH.'/pages' );
-
-// table to store URLs
-if( !defined( 'YOURLS_DB_TABLE_URL' ) )
- define( 'YOURLS_DB_TABLE_URL', YOURLS_DB_PREFIX.'url' );
-
-// table to store options
-if( !defined( 'YOURLS_DB_TABLE_OPTIONS' ) )
- define( 'YOURLS_DB_TABLE_OPTIONS', YOURLS_DB_PREFIX.'options' );
-
-// table to store hits, for stats
-if( !defined( 'YOURLS_DB_TABLE_LOG' ) )
- define( 'YOURLS_DB_TABLE_LOG', YOURLS_DB_PREFIX.'log' );
-
-// minimum delay in sec before a same IP can add another URL. Note: logged in users are not throttled down.
-if( !defined( 'YOURLS_FLOOD_DELAY_SECONDS' ) )
- define( 'YOURLS_FLOOD_DELAY_SECONDS', 15 );
-
-// comma separated list of IPs that can bypass flood check.
-if( !defined( 'YOURLS_FLOOD_IP_WHITELIST' ) )
- define( 'YOURLS_FLOOD_IP_WHITELIST', '' );
-
-// life span of an auth cookie in seconds (60*60*24*7 = 7 days)
-if( !defined( 'YOURLS_COOKIE_LIFE' ) )
- define( 'YOURLS_COOKIE_LIFE', 60*60*24*7 );
-
-// life span of a nonce in seconds
-if( !defined( 'YOURLS_NONCE_LIFE' ) )
- define( 'YOURLS_NONCE_LIFE', 43200 ); // 3600 * 12
-
-// if set to true, disable stat logging (no use for it, too busy servers, ...)
-if( !defined( 'YOURLS_NOSTATS' ) )
- define( 'YOURLS_NOSTATS', false );
-
-// if set to true, force https:// in the admin area
-if( !defined( 'YOURLS_ADMIN_SSL' ) )
- define( 'YOURLS_ADMIN_SSL', false );
-
-// if set to true, verbose debug infos. Will break things. Don't enable.
-if( !defined( 'YOURLS_DEBUG' ) )
- define( 'YOURLS_DEBUG', false );
-
-// Error reporting
-if( defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG == true ) {
- error_reporting( -1 );
-} else {
- error_reporting( E_ERROR | E_PARSE );
-}
-
-// Include all functions
-require_once( YOURLS_INC.'/version.php' );
-require_once( YOURLS_INC.'/functions.php');
-require_once( YOURLS_INC.'/functions-plugins.php' );
-require_once( YOURLS_INC.'/functions-formatting.php' );
-require_once( YOURLS_INC.'/functions-api.php' );
-require_once( YOURLS_INC.'/functions-kses.php' );
-require_once( YOURLS_INC.'/functions-l10n.php' );
-require_once( YOURLS_INC.'/functions-compat.php' );
-require_once( YOURLS_INC.'/functions-html.php' );
-require_once( YOURLS_INC.'/functions-http.php' );
-require_once( YOURLS_INC.'/functions-infos.php' );
-
-// Load auth functions if needed
-if( yourls_is_private() ) {
- require_once( YOURLS_INC.'/functions-auth.php' );
-}
-
-// Load locale
-yourls_load_default_textdomain();
-
-// Check if we are in maintenance mode - if yes, it will die here.
-yourls_check_maintenance_mode();
-
-// Fix REQUEST_URI for IIS
-yourls_fix_request_uri();
-
-// If request for an admin page is http:// and SSL is required, redirect
-if( yourls_is_admin() && yourls_needs_ssl() && !yourls_is_ssl() ) {
- if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
- yourls_redirect( preg_replace( '|^http://|', 'https://', $_SERVER['REQUEST_URI'] ) );
- exit();
- } else {
- yourls_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
- exit();
- }
-}
-
-// Create the YOURLS object $ydb that will contain everything we globally need
-global $ydb;
-
-// Allow drop-in replacement for the DB engine
-if( file_exists( YOURLS_USERDIR.'/db.php' ) ) {
- require_once( YOURLS_USERDIR.'/db.php' );
-} else {
- require_once( YOURLS_INC.'/class-mysql.php' );
- yourls_db_connect();
-}
-
-// Allow early inclusion of a cache layer
-if( file_exists( YOURLS_USERDIR.'/cache.php' ) )
- require_once( YOURLS_USERDIR.'/cache.php' );
-
-// Read options right from start
-yourls_get_all_options();
-
-// Register shutdown function
-register_shutdown_function( 'yourls_shutdown' );
-
-// Core now loaded
-yourls_do_action( 'init' ); // plugins can't see this, not loaded yet
-
-// Check if need to redirect to install procedure
-if( !yourls_is_installed() && !yourls_is_installing() ) {
- yourls_redirect( yourls_admin_url( 'install.php' ), 302 );
-}
-
-// Check if upgrade is needed (bypassed if upgrading or installing)
-if ( !yourls_is_upgrading() && !yourls_is_installing() ) {
- if ( yourls_upgrade_is_needed() ) {
- yourls_redirect( YOURLS_SITE .'/admin/upgrade.php', 302 );
- }
-}
-
-// Init all plugins
-yourls_load_plugins();
-yourls_do_action( 'plugins_loaded' );
-
-// Is there a new version of YOURLS ?
-yourls_new_core_version_notice();
-
-if( yourls_is_admin() )
- yourls_do_action( 'admin_init' );
-
diff --git a/sources/includes/phpass/PasswordHash.php b/sources/includes/phpass/PasswordHash.php
deleted file mode 100644
index 12958c7..0000000
--- a/sources/includes/phpass/PasswordHash.php
+++ /dev/null
@@ -1,253 +0,0 @@
- in 2004-2006 and placed in
-# the public domain. Revised in subsequent years, still public domain.
-#
-# There's absolutely no warranty.
-#
-# The homepage URL for this framework is:
-#
-# http://www.openwall.com/phpass/
-#
-# Please be sure to update the Version line if you edit this file in any way.
-# It is suggested that you leave the main version number intact, but indicate
-# your project name (after the slash) and add your own revision information.
-#
-# Please do not change the "private" password hashing method implemented in
-# here, thereby making your hashes incompatible. However, if you must, please
-# change the hash type identifier (the "$P$") to something different.
-#
-# Obviously, since this code is in the public domain, the above are not
-# requirements (there can be none), but merely suggestions.
-#
-class PasswordHash {
- var $itoa64;
- var $iteration_count_log2;
- var $portable_hashes;
- var $random_state;
-
- function PasswordHash($iteration_count_log2, $portable_hashes)
- {
- $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-
- if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
- $iteration_count_log2 = 8;
- $this->iteration_count_log2 = $iteration_count_log2;
-
- $this->portable_hashes = $portable_hashes;
-
- $this->random_state = microtime();
- if (function_exists('getmypid'))
- $this->random_state .= getmypid();
- }
-
- function get_random_bytes($count)
- {
- $output = '';
- if (is_readable('/dev/urandom') &&
- ($fh = @fopen('/dev/urandom', 'rb'))) {
- $output = fread($fh, $count);
- fclose($fh);
- }
-
- if (strlen($output) < $count) {
- $output = '';
- for ($i = 0; $i < $count; $i += 16) {
- $this->random_state =
- md5(microtime() . $this->random_state);
- $output .=
- pack('H*', md5($this->random_state));
- }
- $output = substr($output, 0, $count);
- }
-
- return $output;
- }
-
- function encode64($input, $count)
- {
- $output = '';
- $i = 0;
- do {
- $value = ord($input[$i++]);
- $output .= $this->itoa64[$value & 0x3f];
- if ($i < $count)
- $value |= ord($input[$i]) << 8;
- $output .= $this->itoa64[($value >> 6) & 0x3f];
- if ($i++ >= $count)
- break;
- if ($i < $count)
- $value |= ord($input[$i]) << 16;
- $output .= $this->itoa64[($value >> 12) & 0x3f];
- if ($i++ >= $count)
- break;
- $output .= $this->itoa64[($value >> 18) & 0x3f];
- } while ($i < $count);
-
- return $output;
- }
-
- function gensalt_private($input)
- {
- $output = '$P$';
- $output .= $this->itoa64[min($this->iteration_count_log2 +
- ((PHP_VERSION >= '5') ? 5 : 3), 30)];
- $output .= $this->encode64($input, 6);
-
- return $output;
- }
-
- function crypt_private($password, $setting)
- {
- $output = '*0';
- if (substr($setting, 0, 2) == $output)
- $output = '*1';
-
- $id = substr($setting, 0, 3);
- # We use "$P$", phpBB3 uses "$H$" for the same thing
- if ($id != '$P$' && $id != '$H$')
- return $output;
-
- $count_log2 = strpos($this->itoa64, $setting[3]);
- if ($count_log2 < 7 || $count_log2 > 30)
- return $output;
-
- $count = 1 << $count_log2;
-
- $salt = substr($setting, 4, 8);
- if (strlen($salt) != 8)
- return $output;
-
- # We're kind of forced to use MD5 here since it's the only
- # cryptographic primitive available in all versions of PHP
- # currently in use. To implement our own low-level crypto
- # in PHP would result in much worse performance and
- # consequently in lower iteration counts and hashes that are
- # quicker to crack (by non-PHP code).
- if (PHP_VERSION >= '5') {
- $hash = md5($salt . $password, TRUE);
- do {
- $hash = md5($hash . $password, TRUE);
- } while (--$count);
- } else {
- $hash = pack('H*', md5($salt . $password));
- do {
- $hash = pack('H*', md5($hash . $password));
- } while (--$count);
- }
-
- $output = substr($setting, 0, 12);
- $output .= $this->encode64($hash, 16);
-
- return $output;
- }
-
- function gensalt_extended($input)
- {
- $count_log2 = min($this->iteration_count_log2 + 8, 24);
- # This should be odd to not reveal weak DES keys, and the
- # maximum valid value is (2**24 - 1) which is odd anyway.
- $count = (1 << $count_log2) - 1;
-
- $output = '_';
- $output .= $this->itoa64[$count & 0x3f];
- $output .= $this->itoa64[($count >> 6) & 0x3f];
- $output .= $this->itoa64[($count >> 12) & 0x3f];
- $output .= $this->itoa64[($count >> 18) & 0x3f];
-
- $output .= $this->encode64($input, 3);
-
- return $output;
- }
-
- function gensalt_blowfish($input)
- {
- # This one needs to use a different order of characters and a
- # different encoding scheme from the one in encode64() above.
- # We care because the last character in our encoded string will
- # only represent 2 bits. While two known implementations of
- # bcrypt will happily accept and correct a salt string which
- # has the 4 unused bits set to non-zero, we do not want to take
- # chances and we also do not want to waste an additional byte
- # of entropy.
- $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
-
- $output = '$2a$';
- $output .= chr(ord('0') + $this->iteration_count_log2 / 10);
- $output .= chr(ord('0') + $this->iteration_count_log2 % 10);
- $output .= '$';
-
- $i = 0;
- do {
- $c1 = ord($input[$i++]);
- $output .= $itoa64[$c1 >> 2];
- $c1 = ($c1 & 0x03) << 4;
- if ($i >= 16) {
- $output .= $itoa64[$c1];
- break;
- }
-
- $c2 = ord($input[$i++]);
- $c1 |= $c2 >> 4;
- $output .= $itoa64[$c1];
- $c1 = ($c2 & 0x0f) << 2;
-
- $c2 = ord($input[$i++]);
- $c1 |= $c2 >> 6;
- $output .= $itoa64[$c1];
- $output .= $itoa64[$c2 & 0x3f];
- } while (1);
-
- return $output;
- }
-
- function HashPassword($password)
- {
- $random = '';
-
- if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
- $random = $this->get_random_bytes(16);
- $hash =
- crypt($password, $this->gensalt_blowfish($random));
- if (strlen($hash) == 60)
- return $hash;
- }
-
- if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
- if (strlen($random) < 3)
- $random = $this->get_random_bytes(3);
- $hash =
- crypt($password, $this->gensalt_extended($random));
- if (strlen($hash) == 20)
- return $hash;
- }
-
- if (strlen($random) < 6)
- $random = $this->get_random_bytes(6);
- $hash =
- $this->crypt_private($password,
- $this->gensalt_private($random));
- if (strlen($hash) == 34)
- return $hash;
-
- # Returning '*' on error is safe here, but would _not_ be safe
- # in a crypt(3)-like function used _both_ for generating new
- # hashes and for validating passwords against existing hashes.
- return '*';
- }
-
- function CheckPassword($password, $stored_hash)
- {
- $hash = $this->crypt_private($password, $stored_hash);
- if ($hash[0] == '*')
- $hash = crypt($password, $stored_hash);
-
- return $hash == $stored_hash;
- }
-}
-
-?>
diff --git a/sources/includes/phpass/README.md b/sources/includes/phpass/README.md
deleted file mode 100644
index ba4f4e8..0000000
--- a/sources/includes/phpass/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-phpass
-======
-
-**phpass** (pronounced "pH pass") is a portable public domain password hashing framework
-
-**phpass** can be found here : http://openwall.com/phpass/
diff --git a/sources/includes/phpass/test.php b/sources/includes/phpass/test.php
deleted file mode 100644
index 2f4a41c..0000000
--- a/sources/includes/phpass/test.php
+++ /dev/null
@@ -1,72 +0,0 @@
-HashPassword($correct);
-
-print 'Hash: ' . $hash . "\n";
-
-$check = $t_hasher->CheckPassword($correct, $hash);
-if ($check) $ok++;
-print "Check correct: '" . $check . "' (should be '1')\n";
-
-$wrong = 'test12346';
-$check = $t_hasher->CheckPassword($wrong, $hash);
-if (!$check) $ok++;
-print "Check wrong: '" . $check . "' (should be '0' or '')\n";
-
-unset($t_hasher);
-
-# Force the use of weaker portable hashes.
-$t_hasher = new PasswordHash(8, TRUE);
-
-$hash = $t_hasher->HashPassword($correct);
-
-print 'Hash: ' . $hash . "\n";
-
-$check = $t_hasher->CheckPassword($correct, $hash);
-if ($check) $ok++;
-print "Check correct: '" . $check . "' (should be '1')\n";
-
-$check = $t_hasher->CheckPassword($wrong, $hash);
-if (!$check) $ok++;
-print "Check wrong: '" . $check . "' (should be '0' or '')\n";
-
-# A correct portable hash for 'test12345'.
-# Please note the use of single quotes to ensure that the dollar signs will
-# be interpreted literally. Of course, a real application making use of the
-# framework won't store password hashes within a PHP source file anyway.
-# We only do this for testing.
-$hash = '$P$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0';
-
-print 'Hash: ' . $hash . "\n";
-
-$check = $t_hasher->CheckPassword($correct, $hash);
-if ($check) $ok++;
-print "Check correct: '" . $check . "' (should be '1')\n";
-
-$check = $t_hasher->CheckPassword($wrong, $hash);
-if (!$check) $ok++;
-print "Check wrong: '" . $check . "' (should be '0' or '')\n";
-
-if ($ok == 6)
- print "All tests have PASSED\n";
-else
- print "Some tests have FAILED\n";
-
-?>
diff --git a/sources/includes/pomo/entry.php b/sources/includes/pomo/entry.php
deleted file mode 100644
index 2408c91..0000000
--- a/sources/includes/pomo/entry.php
+++ /dev/null
@@ -1,78 +0,0 @@
- $value) {
- $this->$varname = $value;
- }
- if (isset($args['plural'])) $this->is_plural = true;
- if (!is_array($this->translations)) $this->translations = array();
- if (!is_array($this->references)) $this->references = array();
- if (!is_array($this->flags)) $this->flags = array();
- }
-
- /**
- * Generates a unique key for this entry
- *
- * @return string|bool the key or false if the entry is empty
- */
- function key() {
- if (is_null($this->singular)) return false;
- // prepend context and EOT, like in MO files
- return is_null($this->context)? $this->singular : $this->context.chr(4).$this->singular;
- }
-
- function merge_with(&$other) {
- $this->flags = array_unique( array_merge( $this->flags, $other->flags ) );
- $this->references = array_unique( array_merge( $this->references, $other->references ) );
- if ( $this->extracted_comments != $other->extracted_comments ) {
- $this->extracted_comments .= $other->extracted_comments;
- }
-
- }
-}
-endif;
\ No newline at end of file
diff --git a/sources/includes/pomo/mo.php b/sources/includes/pomo/mo.php
deleted file mode 100644
index a206da1..0000000
--- a/sources/includes/pomo/mo.php
+++ /dev/null
@@ -1,257 +0,0 @@
-is_resource())
- return false;
- return $this->import_from_reader($reader);
- }
-
- function export_to_file($filename) {
- $fh = fopen($filename, 'wb');
- if ( !$fh ) return false;
- $res = $this->export_to_file_handle( $fh );
- fclose($fh);
- return $res;
- }
-
- function export() {
- $tmp_fh = fopen("php://temp", 'r+');
- if ( !$tmp_fh ) return false;
- $this->export_to_file_handle( $tmp_fh );
- rewind( $tmp_fh );
- return stream_get_contents( $tmp_fh );
- }
-
- function is_entry_good_for_export( $entry ) {
- if ( empty( $entry->translations ) ) {
- return false;
- }
-
- if ( !array_filter( $entry->translations ) ) {
- return false;
- }
-
- return true;
- }
-
- function export_to_file_handle($fh) {
- $entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) );
- ksort($entries);
- $magic = 0x950412de;
- $revision = 0;
- $total = count($entries) + 1; // all the headers are one entry
- $originals_lenghts_addr = 28;
- $translations_lenghts_addr = $originals_lenghts_addr + 8 * $total;
- $size_of_hash = 0;
- $hash_addr = $translations_lenghts_addr + 8 * $total;
- $current_addr = $hash_addr;
- fwrite($fh, pack('V*', $magic, $revision, $total, $originals_lenghts_addr,
- $translations_lenghts_addr, $size_of_hash, $hash_addr));
- fseek($fh, $originals_lenghts_addr);
-
- // headers' msgid is an empty string
- fwrite($fh, pack('VV', 0, $current_addr));
- $current_addr++;
- $originals_table = chr(0);
-
- foreach($entries as $entry) {
- $originals_table .= $this->export_original($entry) . chr(0);
- $length = strlen($this->export_original($entry));
- fwrite($fh, pack('VV', $length, $current_addr));
- $current_addr += $length + 1; // account for the NULL byte after
- }
-
- $exported_headers = $this->export_headers();
- fwrite($fh, pack('VV', strlen($exported_headers), $current_addr));
- $current_addr += strlen($exported_headers) + 1;
- $translations_table = $exported_headers . chr(0);
-
- foreach($entries as $entry) {
- $translations_table .= $this->export_translations($entry) . chr(0);
- $length = strlen($this->export_translations($entry));
- fwrite($fh, pack('VV', $length, $current_addr));
- $current_addr += $length + 1;
- }
-
- fwrite($fh, $originals_table);
- fwrite($fh, $translations_table);
- return true;
- }
-
- function export_original($entry) {
- //TODO: warnings for control characters
- $exported = $entry->singular;
- if ($entry->is_plural) $exported .= chr(0).$entry->plural;
- if (!is_null($entry->context)) $exported = $entry->context . chr(4) . $exported;
- return $exported;
- }
-
- function export_translations($entry) {
- //TODO: warnings for control characters
- return implode(chr(0), $entry->translations);
- }
-
- function export_headers() {
- $exported = '';
- foreach($this->headers as $header => $value) {
- $exported.= "$header: $value\n";
- }
- return $exported;
- }
-
- function get_byteorder($magic) {
- // The magic is 0x950412de
-
- // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
- $magic_little = (int) - 1794895138;
- $magic_little_64 = (int) 2500072158;
- // 0xde120495
- $magic_big = ((int) - 569244523) & 0xFFFFFFFF;
- if ($magic_little == $magic || $magic_little_64 == $magic) {
- return 'little';
- } else if ($magic_big == $magic) {
- return 'big';
- } else {
- return false;
- }
- }
-
- function import_from_reader($reader) {
- $endian_string = MO::get_byteorder($reader->readint32());
- if (false === $endian_string) {
- return false;
- }
- $reader->setEndian($endian_string);
-
- $endian = ('big' == $endian_string)? 'N' : 'V';
-
- $header = $reader->read(24);
- if ($reader->strlen($header) != 24)
- return false;
-
- // parse header
- $header = unpack("{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header);
- if (!is_array($header))
- return false;
-
- extract( $header );
-
- // support revision 0 of MO format specs, only
- if ($revision != 0)
- return false;
-
- // seek to data blocks
- $reader->seekto($originals_lenghts_addr);
-
- // read originals' indices
- $originals_lengths_length = $translations_lenghts_addr - $originals_lenghts_addr;
- if ( $originals_lengths_length != $total * 8 )
- return false;
-
- $originals = $reader->read($originals_lengths_length);
- if ( $reader->strlen( $originals ) != $originals_lengths_length )
- return false;
-
- // read translations' indices
- $translations_lenghts_length = $hash_addr - $translations_lenghts_addr;
- if ( $translations_lenghts_length != $total * 8 )
- return false;
-
- $translations = $reader->read($translations_lenghts_length);
- if ( $reader->strlen( $translations ) != $translations_lenghts_length )
- return false;
-
- // transform raw data into set of indices
- $originals = $reader->str_split( $originals, 8 );
- $translations = $reader->str_split( $translations, 8 );
-
- // skip hash table
- $strings_addr = $hash_addr + $hash_length * 4;
-
- $reader->seekto($strings_addr);
-
- $strings = $reader->read_all();
- $reader->close();
-
- for ( $i = 0; $i < $total; $i++ ) {
- $o = unpack( "{$endian}length/{$endian}pos", $originals[$i] );
- $t = unpack( "{$endian}length/{$endian}pos", $translations[$i] );
- if ( !$o || !$t ) return false;
-
- // adjust offset due to reading strings to separate space before
- $o['pos'] -= $strings_addr;
- $t['pos'] -= $strings_addr;
-
- $original = $reader->substr( $strings, $o['pos'], $o['length'] );
- $translation = $reader->substr( $strings, $t['pos'], $t['length'] );
-
- if ('' === $original) {
- $this->set_headers($this->make_headers($translation));
- } else {
- $entry = &$this->make_entry($original, $translation);
- $this->entries[$entry->key()] = &$entry;
- }
- }
- return true;
- }
-
- /**
- * Build a Translation_Entry from original string and translation strings,
- * found in a MO file
- *
- * @static
- * @param string $original original string to translate from MO file. Might contain
- * 0x04 as context separator or 0x00 as singular/plural separator
- * @param string $translation translation string from MO file. Might contain
- * 0x00 as a plural translations separator
- */
- function &make_entry($original, $translation) {
- $entry = new Translation_Entry();
- // look for context
- $parts = explode(chr(4), $original);
- if (isset($parts[1])) {
- $original = $parts[1];
- $entry->context = $parts[0];
- }
- // look for plural original
- $parts = explode(chr(0), $original);
- $entry->singular = $parts[0];
- if (isset($parts[1])) {
- $entry->is_plural = true;
- $entry->plural = $parts[1];
- }
- // plural translations are also separated by \0
- $entry->translations = explode(chr(0), $translation);
- return $entry;
- }
-
- function select_plural_form($count) {
- return $this->gettext_select_plural_form($count);
- }
-
- function get_plural_forms_count() {
- return $this->_nplurals;
- }
-}
-endif;
\ No newline at end of file
diff --git a/sources/includes/pomo/po.php b/sources/includes/pomo/po.php
deleted file mode 100644
index 6082d7a..0000000
--- a/sources/includes/pomo/po.php
+++ /dev/null
@@ -1,384 +0,0 @@
-headers as $header => $value) {
- $header_string.= "$header: $value\n";
- }
- $poified = PO::poify($header_string);
- if ($this->comments_before_headers)
- $before_headers = $this->prepend_each_line(rtrim($this->comments_before_headers)."\n", '# ');
- else
- $before_headers = '';
- return rtrim("{$before_headers}msgid \"\"\nmsgstr $poified");
- }
-
- /**
- * Exports all entries to PO format
- *
- * @return string sequence of mgsgid/msgstr PO strings, doesn't containt newline at the end
- */
- function export_entries() {
- //TODO sorting
- return implode("\n\n", array_map(array('PO', 'export_entry'), $this->entries));
- }
-
- /**
- * Exports the whole PO file as a string
- *
- * @param bool $include_headers whether to include the headers in the export
- * @return string ready for inclusion in PO file string for headers and all the enrtries
- */
- function export($include_headers = true) {
- $res = '';
- if ($include_headers) {
- $res .= $this->export_headers();
- $res .= "\n\n";
- }
- $res .= $this->export_entries();
- return $res;
- }
-
- /**
- * Same as {@link export}, but writes the result to a file
- *
- * @param string $filename where to write the PO string
- * @param bool $include_headers whether to include tje headers in the export
- * @return bool true on success, false on error
- */
- function export_to_file($filename, $include_headers = true) {
- $fh = fopen($filename, 'w');
- if (false === $fh) return false;
- $export = $this->export($include_headers);
- $res = fwrite($fh, $export);
- if (false === $res) return false;
- return fclose($fh);
- }
-
- /**
- * Text to include as a comment before the start of the PO contents
- *
- * Doesn't need to include # in the beginning of lines, these are added automatically
- */
- function set_comment_before_headers( $text ) {
- $this->comments_before_headers = $text;
- }
-
- /**
- * Formats a string in PO-style
- *
- * @static
- * @param string $string the string to format
- * @return string the poified string
- */
- function poify($string) {
- $quote = '"';
- $slash = '\\';
- $newline = "\n";
-
- $replaces = array(
- "$slash" => "$slash$slash",
- "$quote" => "$slash$quote",
- "\t" => '\t',
- );
-
- $string = str_replace(array_keys($replaces), array_values($replaces), $string);
-
- $po = $quote.implode("${slash}n$quote$newline$quote", explode($newline, $string)).$quote;
- // add empty string on first line for readbility
- if (false !== strpos($string, $newline) &&
- (substr_count($string, $newline) > 1 || !($newline === substr($string, -strlen($newline))))) {
- $po = "$quote$quote$newline$po";
- }
- // remove empty strings
- $po = str_replace("$newline$quote$quote", '', $po);
- return $po;
- }
-
- /**
- * Gives back the original string from a PO-formatted string
- *
- * @static
- * @param string $string PO-formatted string
- * @return string enascaped string
- */
- function unpoify($string) {
- $escapes = array('t' => "\t", 'n' => "\n", '\\' => '\\');
- $lines = array_map('trim', explode("\n", $string));
- $lines = array_map(array('PO', 'trim_quotes'), $lines);
- $unpoified = '';
- $previous_is_backslash = false;
- foreach($lines as $line) {
- preg_match_all('/./u', $line, $chars);
- $chars = $chars[0];
- foreach($chars as $char) {
- if (!$previous_is_backslash) {
- if ('\\' == $char)
- $previous_is_backslash = true;
- else
- $unpoified .= $char;
- } else {
- $previous_is_backslash = false;
- $unpoified .= isset($escapes[$char])? $escapes[$char] : $char;
- }
- }
- }
- return $unpoified;
- }
-
- /**
- * Inserts $with in the beginning of every new line of $string and
- * returns the modified string
- *
- * @static
- * @param string $string prepend lines in this string
- * @param string $with prepend lines with this string
- */
- function prepend_each_line($string, $with) {
- $php_with = var_export($with, true);
- $lines = explode("\n", $string);
- // do not prepend the string on the last empty line, artefact by explode
- if ("\n" == substr($string, -1)) unset($lines[count($lines) - 1]);
- $res = implode("\n", array_map(create_function('$x', "return $php_with.\$x;"), $lines));
- // give back the empty line, we ignored above
- if ("\n" == substr($string, -1)) $res .= "\n";
- return $res;
- }
-
- /**
- * Prepare a text as a comment -- wraps the lines and prepends #
- * and a special character to each line
- *
- * @access private
- * @param string $text the comment text
- * @param string $char character to denote a special PO comment,
- * like :, default is a space
- */
- function comment_block($text, $char=' ') {
- $text = wordwrap($text, PO_MAX_LINE_LEN - 3);
- return PO::prepend_each_line($text, "#$char ");
- }
-
- /**
- * Builds a string from the entry for inclusion in PO file
- *
- * @static
- * @param object &$entry the entry to convert to po string
- * @return string|bool PO-style formatted string for the entry or
- * false if the entry is empty
- */
- function export_entry(&$entry) {
- if (is_null($entry->singular)) return false;
- $po = array();
- if (!empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
- if (!empty($entry->extracted_comments)) $po[] = PO::comment_block($entry->extracted_comments, '.');
- if (!empty($entry->references)) $po[] = PO::comment_block(implode(' ', $entry->references), ':');
- if (!empty($entry->flags)) $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
- if (!is_null($entry->context)) $po[] = 'msgctxt '.PO::poify($entry->context);
- $po[] = 'msgid '.PO::poify($entry->singular);
- if (!$entry->is_plural) {
- $translation = empty($entry->translations)? '' : $entry->translations[0];
- $po[] = 'msgstr '.PO::poify($translation);
- } else {
- $po[] = 'msgid_plural '.PO::poify($entry->plural);
- $translations = empty($entry->translations)? array('', '') : $entry->translations;
- foreach($translations as $i => $translation) {
- $po[] = "msgstr[$i] ".PO::poify($translation);
- }
- }
- return implode("\n", $po);
- }
-
- function import_from_file($filename) {
- $f = fopen($filename, 'r');
- if (!$f) return false;
- $lineno = 0;
- while (true) {
- $res = $this->read_entry($f, $lineno);
- if (!$res) break;
- if ($res['entry']->singular == '') {
- $this->set_headers($this->make_headers($res['entry']->translations[0]));
- } else {
- $this->add_entry($res['entry']);
- }
- }
- PO::read_line($f, 'clear');
- if ( false === $res ) {
- return false;
- }
- if ( ! $this->headers && ! $this->entries ) {
- return false;
- }
- return true;
- }
-
- function read_entry($f, $lineno = 0) {
- $entry = new Translation_Entry();
- // where were we in the last step
- // can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural
- $context = '';
- $msgstr_index = 0;
- $is_final = create_function('$context', 'return $context == "msgstr" || $context == "msgstr_plural";');
- while (true) {
- $lineno++;
- $line = PO::read_line($f);
- if (!$line) {
- if (feof($f)) {
- if ($is_final($context))
- break;
- elseif (!$context) // we haven't read a line and eof came
- return null;
- else
- return false;
- } else {
- return false;
- }
- }
- if ($line == "\n") continue;
- $line = trim($line);
- if (preg_match('/^#/', $line, $m)) {
- // the comment is the start of a new entry
- if ($is_final($context)) {
- PO::read_line($f, 'put-back');
- $lineno--;
- break;
- }
- // comments have to be at the beginning
- if ($context && $context != 'comment') {
- return false;
- }
- // add comment
- $this->add_comment_to_entry($entry, $line);;
- } elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) {
- if ($is_final($context)) {
- PO::read_line($f, 'put-back');
- $lineno--;
- break;
- }
- if ($context && $context != 'comment') {
- return false;
- }
- $context = 'msgctxt';
- $entry->context .= PO::unpoify($m[1]);
- } elseif (preg_match('/^msgid\s+(".*")/', $line, $m)) {
- if ($is_final($context)) {
- PO::read_line($f, 'put-back');
- $lineno--;
- break;
- }
- if ($context && $context != 'msgctxt' && $context != 'comment') {
- return false;
- }
- $context = 'msgid';
- $entry->singular .= PO::unpoify($m[1]);
- } elseif (preg_match('/^msgid_plural\s+(".*")/', $line, $m)) {
- if ($context != 'msgid') {
- return false;
- }
- $context = 'msgid_plural';
- $entry->is_plural = true;
- $entry->plural .= PO::unpoify($m[1]);
- } elseif (preg_match('/^msgstr\s+(".*")/', $line, $m)) {
- if ($context != 'msgid') {
- return false;
- }
- $context = 'msgstr';
- $entry->translations = array(PO::unpoify($m[1]));
- } elseif (preg_match('/^msgstr\[(\d+)\]\s+(".*")/', $line, $m)) {
- if ($context != 'msgid_plural' && $context != 'msgstr_plural') {
- return false;
- }
- $context = 'msgstr_plural';
- $msgstr_index = $m[1];
- $entry->translations[$m[1]] = PO::unpoify($m[2]);
- } elseif (preg_match('/^".*"$/', $line)) {
- $unpoified = PO::unpoify($line);
- switch ($context) {
- case 'msgid':
- $entry->singular .= $unpoified; break;
- case 'msgctxt':
- $entry->context .= $unpoified; break;
- case 'msgid_plural':
- $entry->plural .= $unpoified; break;
- case 'msgstr':
- $entry->translations[0] .= $unpoified; break;
- case 'msgstr_plural':
- $entry->translations[$msgstr_index] .= $unpoified; break;
- default:
- return false;
- }
- } else {
- return false;
- }
- }
- if (array() == array_filter($entry->translations, create_function('$t', 'return $t || "0" === $t;'))) {
- $entry->translations = array();
- }
- return array('entry' => $entry, 'lineno' => $lineno);
- }
-
- function read_line($f, $action = 'read') {
- static $last_line = '';
- static $use_last_line = false;
- if ('clear' == $action) {
- $last_line = '';
- return true;
- }
- if ('put-back' == $action) {
- $use_last_line = true;
- return true;
- }
- $line = $use_last_line? $last_line : fgets($f);
- $line = ( "\r\n" == substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line;
- $last_line = $line;
- $use_last_line = false;
- return $line;
- }
-
- function add_comment_to_entry(&$entry, $po_comment_line) {
- $first_two = substr($po_comment_line, 0, 2);
- $comment = trim(substr($po_comment_line, 2));
- if ('#:' == $first_two) {
- $entry->references = array_merge($entry->references, preg_split('/\s+/', $comment));
- } elseif ('#.' == $first_two) {
- $entry->extracted_comments = trim($entry->extracted_comments . "\n" . $comment);
- } elseif ('#,' == $first_two) {
- $entry->flags = array_merge($entry->flags, preg_split('/,\s*/', $comment));
- } else {
- $entry->translator_comments = trim($entry->translator_comments . "\n" . $comment);
- }
- }
-
- function trim_quotes($s) {
- if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
- if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
- return $s;
- }
-}
-endif;
diff --git a/sources/includes/pomo/streams.php b/sources/includes/pomo/streams.php
deleted file mode 100644
index 7cda3ac..0000000
--- a/sources/includes/pomo/streams.php
+++ /dev/null
@@ -1,209 +0,0 @@
-
- *
- * @version $Id: streams.php 718 2012-10-31 00:32:02Z nbachiyski $
- * @package pomo
- * @subpackage streams
- */
-
-if ( !class_exists( 'POMO_Reader', false ) ):
-class POMO_Reader {
-
- var $endian = 'little';
- var $_post = '';
-
- function POMO_Reader() {
- $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr');
- $this->_pos = 0;
- }
-
- /**
- * Sets the endianness of the file.
- *
- * @param $endian string 'big' or 'little'
- */
- function setEndian($endian) {
- $this->endian = $endian;
- }
-
- /**
- * Reads a 32bit Integer from the Stream
- *
- * @return mixed The integer, corresponding to the next 32 bits from
- * the stream of false if there are not enough bytes or on error
- */
- function readint32() {
- $bytes = $this->read(4);
- if (4 != $this->strlen($bytes))
- return false;
- $endian_letter = ('big' == $this->endian)? 'N' : 'V';
- $int = unpack($endian_letter, $bytes);
- return array_shift($int);
- }
-
- /**
- * Reads an array of 32-bit Integers from the Stream
- *
- * @param integer count How many elements should be read
- * @return mixed Array of integers or false if there isn't
- * enough data or on error
- */
- function readint32array($count) {
- $bytes = $this->read(4 * $count);
- if (4*$count != $this->strlen($bytes))
- return false;
- $endian_letter = ('big' == $this->endian)? 'N' : 'V';
- return unpack($endian_letter.$count, $bytes);
- }
-
-
- function substr($string, $start, $length) {
- if ($this->is_overloaded) {
- return mb_substr($string, $start, $length, 'ascii');
- } else {
- return substr($string, $start, $length);
- }
- }
-
- function strlen($string) {
- if ($this->is_overloaded) {
- return mb_strlen($string, 'ascii');
- } else {
- return strlen($string);
- }
- }
-
- function str_split($string, $chunk_size) {
- if (!function_exists('str_split')) {
- $length = $this->strlen($string);
- $out = array();
- for ($i = 0; $i < $length; $i += $chunk_size)
- $out[] = $this->substr($string, $i, $chunk_size);
- return $out;
- } else {
- return str_split( $string, $chunk_size );
- }
- }
-
-
- function pos() {
- return $this->_pos;
- }
-
- function is_resource() {
- return true;
- }
-
- function close() {
- return true;
- }
-}
-endif;
-
-if ( !class_exists( 'POMO_FileReader', false ) ):
-class POMO_FileReader extends POMO_Reader {
- function POMO_FileReader($filename) {
- parent::POMO_Reader();
- $this->_f = fopen($filename, 'rb');
- }
-
- function read($bytes) {
- return fread($this->_f, $bytes);
- }
-
- function seekto($pos) {
- if ( -1 == fseek($this->_f, $pos, SEEK_SET)) {
- return false;
- }
- $this->_pos = $pos;
- return true;
- }
-
- function is_resource() {
- return is_resource($this->_f);
- }
-
- function feof() {
- return feof($this->_f);
- }
-
- function close() {
- return fclose($this->_f);
- }
-
- function read_all() {
- $all = '';
- while ( !$this->feof() )
- $all .= $this->read(4096);
- return $all;
- }
-}
-endif;
-
-if ( !class_exists( 'POMO_StringReader', false ) ):
-/**
- * Provides file-like methods for manipulating a string instead
- * of a physical file.
- */
-class POMO_StringReader extends POMO_Reader {
-
- var $_str = '';
-
- function POMO_StringReader($str = '') {
- parent::POMO_Reader();
- $this->_str = $str;
- $this->_pos = 0;
- }
-
-
- function read($bytes) {
- $data = $this->substr($this->_str, $this->_pos, $bytes);
- $this->_pos += $bytes;
- if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
- return $data;
- }
-
- function seekto($pos) {
- $this->_pos = $pos;
- if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
- return $this->_pos;
- }
-
- function length() {
- return $this->strlen($this->_str);
- }
-
- function read_all() {
- return $this->substr($this->_str, $this->_pos, $this->strlen($this->_str));
- }
-
-}
-endif;
-
-if ( !class_exists( 'POMO_CachedFileReader', false ) ):
-/**
- * Reads the contents of the file in the beginning.
- */
-class POMO_CachedFileReader extends POMO_StringReader {
- function POMO_CachedFileReader($filename) {
- parent::POMO_StringReader();
- $this->_str = file_get_contents($filename);
- if (false === $this->_str)
- return false;
- $this->_pos = 0;
- }
-}
-endif;
-
-if ( !class_exists( 'POMO_CachedIntFileReader', false ) ):
-/**
- * Reads the contents of the file in the beginning.
- */
-class POMO_CachedIntFileReader extends POMO_CachedFileReader {
- function POMO_CachedIntFileReader($filename) {
- parent::POMO_CachedFileReader($filename);
- }
-}
-endif;
\ No newline at end of file
diff --git a/sources/includes/pomo/translations.php b/sources/includes/pomo/translations.php
deleted file mode 100644
index 9bbd65a..0000000
--- a/sources/includes/pomo/translations.php
+++ /dev/null
@@ -1,275 +0,0 @@
-key();
- if (false === $key) return false;
- $this->entries[$key] = &$entry;
- return true;
- }
-
- function add_entry_or_merge($entry) {
- if (is_array($entry)) {
- $entry = new Translation_Entry($entry);
- }
- $key = $entry->key();
- if (false === $key) return false;
- if (isset($this->entries[$key]))
- $this->entries[$key]->merge_with($entry);
- else
- $this->entries[$key] = &$entry;
- return true;
- }
-
- /**
- * Sets $header PO header to $value
- *
- * If the header already exists, it will be overwritten
- *
- * TODO: this should be out of this class, it is gettext specific
- *
- * @param string $header header name, without trailing :
- * @param string $value header value, without trailing \n
- */
- function set_header($header, $value) {
- $this->headers[$header] = $value;
- }
-
- function set_headers($headers) {
- foreach($headers as $header => $value) {
- $this->set_header($header, $value);
- }
- }
-
- function get_header($header) {
- return isset($this->headers[$header])? $this->headers[$header] : false;
- }
-
- function translate_entry(&$entry) {
- $key = $entry->key();
- return isset($this->entries[$key])? $this->entries[$key] : false;
- }
-
- function translate($singular, $context=null) {
- $entry = new Translation_Entry(array('singular' => $singular, 'context' => $context));
- $translated = $this->translate_entry($entry);
- return ($translated && !empty($translated->translations))? $translated->translations[0] : $singular;
- }
-
- /**
- * Given the number of items, returns the 0-based index of the plural form to use
- *
- * Here, in the base Translations class, the common logic for English is implemented:
- * 0 if there is one element, 1 otherwise
- *
- * This function should be overrided by the sub-classes. For example MO/PO can derive the logic
- * from their headers.
- *
- * @param integer $count number of items
- */
- function select_plural_form($count) {
- return 1 == $count? 0 : 1;
- }
-
- function get_plural_forms_count() {
- return 2;
- }
-
- function translate_plural($singular, $plural, $count, $context = null) {
- $entry = new Translation_Entry(array('singular' => $singular, 'plural' => $plural, 'context' => $context));
- $translated = $this->translate_entry($entry);
- $index = $this->select_plural_form($count);
- $total_plural_forms = $this->get_plural_forms_count();
- if ($translated && 0 <= $index && $index < $total_plural_forms &&
- is_array($translated->translations) &&
- isset($translated->translations[$index]))
- return $translated->translations[$index];
- else
- return 1 == $count? $singular : $plural;
- }
-
- /**
- * Merge $other in the current object.
- *
- * @param Object &$other Another Translation object, whose translations will be merged in this one
- * @return void
- **/
- function merge_with(&$other) {
- foreach( $other->entries as $entry ) {
- $this->entries[$entry->key()] = $entry;
- }
- }
-
- function merge_originals_with(&$other) {
- foreach( $other->entries as $entry ) {
- if ( !isset( $this->entries[$entry->key()] ) )
- $this->entries[$entry->key()] = $entry;
- else
- $this->entries[$entry->key()]->merge_with($entry);
- }
- }
-}
-
-class Gettext_Translations extends Translations {
- /**
- * The gettext implementation of select_plural_form.
- *
- * It lives in this class, because there are more than one descendand, which will use it and
- * they can't share it effectively.
- *
- */
- function gettext_select_plural_form($count) {
- if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) {
- list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
- $this->_nplurals = $nplurals;
- $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
- }
- return call_user_func($this->_gettext_select_plural_form, $count);
- }
-
- function nplurals_and_expression_from_header($header) {
- if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
- $nplurals = (int)$matches[1];
- $expression = trim($this->parenthesize_plural_exression($matches[2]));
- return array($nplurals, $expression);
- } else {
- return array(2, 'n != 1');
- }
- }
-
- /**
- * Makes a function, which will return the right translation index, according to the
- * plural forms header
- */
- function make_plural_form_function($nplurals, $expression) {
- $expression = str_replace('n', '$n', $expression);
- $func_body = "
- \$index = (int)($expression);
- return (\$index < $nplurals)? \$index : $nplurals - 1;";
- return create_function('$n', $func_body);
- }
-
- /**
- * Adds parantheses to the inner parts of ternary operators in
- * plural expressions, because PHP evaluates ternary oerators from left to right
- *
- * @param string $expression the expression without parentheses
- * @return string the expression with parentheses added
- */
- function parenthesize_plural_exression($expression) {
- $expression .= ';';
- $res = '';
- $depth = 0;
- for ($i = 0; $i < strlen($expression); ++$i) {
- $char = $expression[$i];
- switch ($char) {
- case '?':
- $res .= ' ? (';
- $depth++;
- break;
- case ':':
- $res .= ') : (';
- break;
- case ';':
- $res .= str_repeat(')', $depth) . ';';
- $depth= 0;
- break;
- default:
- $res .= $char;
- }
- }
- return rtrim($res, ';');
- }
-
- function make_headers($translation) {
- $headers = array();
- // sometimes \ns are used instead of real new lines
- $translation = str_replace('\n', "\n", $translation);
- $lines = explode("\n", $translation);
- foreach($lines as $line) {
- $parts = explode(':', $line, 2);
- if (!isset($parts[1])) continue;
- $headers[trim($parts[0])] = trim($parts[1]);
- }
- return $headers;
- }
-
- function set_header($header, $value) {
- parent::set_header($header, $value);
- if ('Plural-Forms' == $header) {
- list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
- $this->_nplurals = $nplurals;
- $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
- }
- }
-}
-endif;
-
-if ( !class_exists( 'NOOP_Translations', false ) ):
-/**
- * Provides the same interface as Translations, but doesn't do anything
- */
-class NOOP_Translations {
- var $entries = array();
- var $headers = array();
-
- function add_entry($entry) {
- return true;
- }
-
- function set_header($header, $value) {
- }
-
- function set_headers($headers) {
- }
-
- function get_header($header) {
- return false;
- }
-
- function translate_entry(&$entry) {
- return false;
- }
-
- function translate($singular, $context=null) {
- return $singular;
- }
-
- function select_plural_form($count) {
- return 1 == $count? 0 : 1;
- }
-
- function get_plural_forms_count() {
- return 2;
- }
-
- function translate_plural($singular, $plural, $count, $context = null) {
- return 1 == $count? $singular : $plural;
- }
-
- function merge_with(&$other) {
- }
-}
-endif;
diff --git a/sources/includes/version.php b/sources/includes/version.php
deleted file mode 100644
index 4f02681..0000000
--- a/sources/includes/version.php
+++ /dev/null
@@ -1,12 +0,0 @@
-'+msg+'',
- delay: delay,
- animationSpeed: "normal",
- close: closeme,
- cls: type
- });
- return true;
-}
-
-// Unused for now
-function logout() {
- $.ajax({
- type: "POST",
- url: ajaxurl,
- data: {action:'logout'},
- success: function() {
- window.parent.location.href = window.parent.location.href;
- }
- });
-}
-
-// Begin the spinning animation & disable a button
-function add_loading(el) {
- $(el).attr("disabled", "disabled").addClass('disabled').addClass('loading');
-}
-
-// End spinning animation
-function end_loading(el) {
- $(el).removeClass('loading');
-}
-
-// Un-disable an element
-function end_disable(el) {
- $(el).removeAttr("disabled").removeClass('disabled');
-}
-
-// Trim long string
-function trim_long_string( string, length) {
- var newstring = string;
- length = length || 60;
- if ( newstring.length > length ) {
- newstring = newstring.substr(0, (length - 5) ) + '[...]';
- }
- return newstring;
-}
-
-// Get the var=xxx from a query string
-function get_var_from_query( url, varname, default_val ) {
- if( varname == undefined ) {
- varname = 'nonce';
- }
- if( default_val == undefined ) {
- default_val = '';
- }
-
- // Split the url on '?' and get only the params (which is element 1)
- url = url.split('?')[1];
- // Now split those params on '&' so we can get each one individually (Ex. param_var=param_value)
- url = url.split('&');
- // Now we have to find the varname in that array using methods that IE likes (Curse you IE!!!)
- var i=0;
- for( i=0; i' + data.url.display_title + '' + data.url.display_url + ' ';
- } else {
- var display_link = '' + data.url.display_url + ' ';
- }
-
- $("#url-" + id).html(display_link);
- $("#keyword-" + id).html('' + data.url.keyword + ' ');
- $("#timestamp-" + id).html(data.url.date);
- $("#edit-" + id).fadeOut(200, function(){
- $('#main_table tbody').trigger("update");
- });
- $('#keyword_'+id).val( newkeyword );
- $('#statlink-'+id).attr( 'href', data.url.shorturl+'+' );
- }
- feedback(data.message, data.status);
- end_loading("#edit-close-" + id);
- end_disable("#actions-" + id + ' .button');
- }
- );
-}
-
-// Prettify table with odd & even rows
-function zebra_table() {
- $("#main_table tbody tr:even").removeClass('odd').addClass('even');
- $("#main_table tbody tr:odd").removeClass('even').addClass('odd');
- $('#main_table tbody').trigger("update");
-}
-
-// Ready to add another URL
-function add_link_reset() {
- $('#add-url').val('http://').focus();
- $('#add-keyword').val('');
-}
-
-// Increment URL counters
-function increment_counter() {
- $('.increment').each(function(){
- $(this).html( parseInt($(this).html()) + 1);
- });
-}
-
-// Decrement URL counters
-function decrement_counter() {
- $('.increment').each(function(){
- $(this).html( parseInt($(this).html()) - 1 );
- });
-}
-
-// Toggle Share box
-function toggle_share(id) {
- if( $('#share-button-'+id).hasClass('disabled') ) {
- return false;
- }
- var link = $('#url-'+id+' a:first');
- var longurl = link.attr('href');
- var title = link.attr('title');
- var shorturl = $('#keyword-'+id+' a:first').attr('href');
-
- toggle_share_fill_boxes( longurl, shorturl, title );
-}
-
-// When "Search" is clicked, split search text to beat servers which don't like query string with "http://"
-// See https://github.com/YOURLS/YOURLS/issues/1576
-function split_search_text_before_search() {
- // Add 2 hidden fields and populate them with parts of search text
- $(" ").appendTo('#filter_form');
- $(" ").appendTo('#filter_form');
- var search = get_protocol_slashes_and_rest( $('#filter_form input[name=search]').val() );
- $('#filter_form input[name=search]').val( search.rest );
- $('#filter_form input[name=search_protocol]').val( search.protocol );
- $('#filter_form input[name=search_slashes]').val( search.slashes );
-}
-
diff --git a/sources/js/jquery-1.3.2.min.js b/sources/js/jquery-1.3.2.min.js
deleted file mode 100644
index b1ae21d..0000000
--- a/sources/js/jquery-1.3.2.min.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * jQuery JavaScript Library v1.3.2
- * http://jquery.com/
- *
- * Copyright (c) 2009 John Resig
- * Dual licensed under the MIT and GPL licenses.
- * http://docs.jquery.com/License
- *
- * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
- * Revision: 6246
- */
-(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+">"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf(""," "]||!O.indexOf("",""]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,""]||!O.indexOf(""," "]||(!O.indexOf(""," "]||!O.indexOf(""," "]||!o.support.htmlSerialize&&[1,"div","
"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
-/*
- * Sizzle CSS Selector Engine - v0.9.3
- * Copyright 2009, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- * More information: http://sizzlejs.com/
- */
-(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return UT[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V ";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML=" ";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="
";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="
";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(Fa text ';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("
").append(M.responseText.replace(/');
- window.open(url, 'ff','toolbar=no,width=500,height=350');
- break;
- case 'fb':
- //var url = $('#share_fb').attr('href');
- window.open( url, 'fb','toolbar=no,width=1000,height=550');
- break;
- case 'tw':
- //var url = $('#share_tw').attr('href');
- window.open(url, 'tw','toolbar=no,width=800,height=550');
- break;
- }
- return false;
-}
-
-function init_clipboard() {
- $('#copylink').click(function(){
- $(this).select();
- })
-
- $('#copylink').zclip({
- path: zclipurl,
- copy: $('#copylink').val(),
- afterCopy:function(){
- html_pulse( '#copybox h2, #copybox h3', 'Copied!' );
- }
- });
-};
-
diff --git a/sources/pages/examplepage.php b/sources/pages/examplepage.php
deleted file mode 100644
index 057c10f..0000000
--- a/sources/pages/examplepage.php
+++ /dev/null
@@ -1,23 +0,0 @@
-$url";
- die();
-}
-
-// Display page content. Any PHP, HTML and YOURLS function can go here.
-$url = YOURLS_SITE . '/examplepage';
-
-yourls_html_head( 'examplepage', 'Example page' );
-
-?>
-
-This is an example page. Its URL is simply
-
-
-
-
-
-
-YOURLS has nothing for you to see here.
-
-
\ No newline at end of file
diff --git a/sources/readme.html b/sources/readme.html
deleted file mode 100644
index 9b0ce2e..0000000
--- a/sources/readme.html
+++ /dev/null
@@ -1,830 +0,0 @@
-
-
-
-
-
- YOURLS: Your Own URL Shortener
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
About YOURLS
-
-
What is YOURLS
-
YOURLS stands for Your Own URL Shortener . It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or bitly).
-
-
Running your own URL shortener is fun, geeky and useful: you own your data and don't depend on third party services. It's also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.
-
-
YOURLS Features
-
- Free and Open Source software.
- Private (your links only) or Public (everybody can create short links, fine for an intranet)
- Sequential or custom URL keyword
- Handy bookmarklets to easily shorten and share links
- Awesome stats : historical click reports, referrers tracking, visitors geo-location
- Neat Ajaxed interface
- Terrific Plugin architecture to easily implement new features
- Cool developer API
- Full jsonp support
- Friendly installer
- Sample files to create your own public interface and more
-
-
-
Screenshots
-
-
-
Main admin dashboard
-
-
-
Stats for each short URL
-
-
-
See a live example of YOURLS stats on http://yourls.org/cookie+
-
-
-
Download
-
-
Download YOURLS from Github
-
You can follow YOURLS' development on the commit history and get current development build
-
-
Credits
-
-
YOURLS is made by:
-
-
Keep up to date: follow Ozh and read the official YOURLS Blog
-
-
-
-
-
Fresh Install
-
- Unzip the YOURLS archive
- Copy user/config-sample.php
to user/config.php
- Open user/config.php
with a raw text editor (like Notepad) and fill in the required settings
- Upload the unzipped files to your domain public_html
or www
folder
- Create a new database (see Configuration – you can also use an existing one)
- Point your browser to http://yoursite.com/admin/
-
-
-
Upgrade
-
- Backup the database!
- Unzip the YOURLS archive
- Upload files to your server, overwriting your existing install
- Point your browser to http://yoursite.com/admin/
- Tip: you can now move your config.php
file to the /user
directory
-
-
-
Upgrade from YOURLS 1.3 or earlier
-
- Backup the database!
- Make a copy of your config.php
- Delete all files including .htaccess
in YOURLS root directory
- Unzip the YOURLS archive, upload the files
- Copy config-sample.php
to config.php
and fill in details. Don't start with your old config file , use the new sample config file.
- In your new config.php
, add the defines for YOURLS_DB_TABLE_URL
and YOURLS_DB_TABLE_NEXTDEC
you had in your previous config file
- Point your browser to http://yoursite.com/admin/
and follow instructions
- After upgrade is well and over, remove the define YOURLS_DB_TABLE_NEXTDEC
from your config file
-
-
-
-
-
-
-
Configuration (in user/config.php
)
-
MySQL settings
-
- YOURLS_DB_USER
- your MySQL username
- Example: 'joe'
- YOURLS_DB_PASS
- your MySQL password
- Example: 'MySeCreTPaSsW0rd'
- YOURLS_DB_NAME
:
- The database name
- Example: 'yourls'
- YOURLS_DB_HOST
- The database host
- Example: 'localhost'
- YOURLS_DB_PREFIX
- The name prefix for all the tables YOURLS will need
- Example: 'yourls_'
-
-
-
Site options
-
- YOURLS_SITE
- Your (short) domain URL, no trailing slash, lowercase. If you pick the non-www version of your domain, don't use the www version in your browser (and vice-versa)
- Example: 'http://ozh.in'
- YOURLS_HOURS_OFFSET
- Timezone GMT offset
- Example: '-5'
- YOURLS_PRIVATE
- Private means the admin area will be protected with login/pass as defined below. See Private or Public for more.
- Example: 'true'
- YOURLS_UNIQUE_URLS
- Allow multiple short URLs for a same long URL
- Set to true to allow only one pair of shortURL/longURL (default YOURLS behavior), or to false to allow creation of multiple short URLs pointing to the same long URL (as bit.ly does)
- Example: 'true'
- YOURLS_COOKIEKEY
- A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: generate a unique one at http://yourls.org/cookie
- Example: 'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm'
- yourls_user_passwords
- A list of username(s) and password(s) allowed to access the site if private
- Passwords can either be in plain text, or encrypted: see http://yourls.org/userpassword for more information
- Example: 'joe' => 'mypassword'
-
-
-
URL Shortening settings
-
- YOURLS_URL_CONVERT
- URL shortening method: base 36 or 62 . See FAQ for more explanations
- yourls_reserved_URL
- A list of reserved keywords that won't be used as short URLs. Define here negative, unwanted or potentially misleading keywords
- Example: 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', 'gay'
-
-
-
Optional settings
-
- YOURLS_PRIVATE_INFOS
- If YOURLS_PRIVATE
is set to true , you can still make stat pages public. To do so, define with:
- define('YOURLS_PRIVATE_INFOS', false);
-
- YOURLS_PRIVATE_API
- If YOURLS_PRIVATE
is set to true , you can still make your API public. To do so, define with:
- define('YOURLS_PRIVATE_API', false);
- YOURLS_NOSTATS
- If YOURLS_NOSTATS
is set to true , redirects won't be logged and there will be not stats available.
-
-
-
-
Advanced settings
-
You can install YOURLS behind a firewall or a proxy: see Proxy Support
-
File includes/load-yourls.php
contains a few more undocumented but self explanatory and commented settings. Add them to your own config.php
if you know what you're doing.
-
-
-
-
-
Plugins for YOURLS
-
-
Plugins?
-
Plugins are additional PHP scripts that extend the functionalities or features of YOURLS. The core of YOURLS is designed to be as light as possible and avoid bloat (implementing functions not everybody needs) and to allow for easy customization.
-
Using the plugin architecture, you can add new features to YOURLS without having to modify core files. This way, your changes won't be lost when you upgrade your YOURLS installation and you can easily activate and deactivate a plugin from the admin interface.
-
There's a growing number of plugins available: check the Plugin list .
-
-
Documentation
-
Several sample plugins are included in the archive. Read the source and learn the concept. It's easy and fun!
-
Check the plugin API documentation to learn more
-
-
-
-
-
-
YOURLS' API
-
-
Features
-
- Generate or get existing short URLs, with sequential or custom keyword
- Get some statistics about your links: top clicked links, least clicked links, newest links
- Output format: JSON, XML, or simple raw text
- Authentify either with login/password or using a secure passwordless mechanism
-
-
-
Usage
-
You need to send parameters to http://yoursite.com/yourls-api.php
either via GET
or POST
(remember to URL encode parameters if via GET). These parameters are:
-
- A valid username
/ password
pair, or your signature
(see Passwordless API requests )
- The requested action
: "shorturl" (get short URL for a link), "expand" (get long URL of a shorturl), "url-stats" (get stats about one short URL), "stats" (get stats about your links) or "db-stats" (get global link and click count)
- With action = "shorturl" :
-
- the url
to shorten
- optional keyword
and title
for custom short URLs
- output format
: either "jsonp" , "json" , "xml" or "simple"
-
-
- With action = "expand" :
-
- the shorturl
to expand (can be either 'abc' or 'http://site/abc')
- output format
: either "jsonp" , "json" , "xml" or "simple"
-
-
- With action = "url-stats" :
-
- the shorturl
for which to get stats (can be either 'abc' or 'http://site/abc')
- output format
: either "jsonp" , "json" or "xml"
-
-
- With action = "stats" :
-
- the filter
: either "top" , "bottom" , "rand" or "last"
- the limit
(maximum number of links to return)
- output format
: either "jsonp" , "json" or "xml"
-
-
- With action = "db-stats" :
-
- output format
: either "jsonp" , "json" or "xml"
-
-
-
-
-
Sample return
-
<result>
- <url>
- <keyword>shorter</keyword>
- <url>http://somereallylongurlyouneedtoshrink.com/</url>
- <title>The Page Title</title>
- <date>2009-06-23 18:08:07</date>
- <ip>127.0.0.1</ip>
- </url>
- <status>success</status>
- <message>http://somereallylongurlyouneedtoshrink.com/ (ID: shorter) added to database</message>
- <title>The Page Title</title>
- <shorturl>http://yoursite.com/shorter</shorturl>
- <statusCode>200</statusCode>
-</result>
-
-
Sample file
-
There's a sample file included that serves as an example on how to play with the API
-
-
Expand the API
-
You can easily implement custom API actions with a plugin. See the plugin list for examples.
-
-
-
-
-
-
-
FAQ
-
-
Server requirements
-
- A server with mod_rewrite enabled
- At least PHP 5.2
- At least MYSQL 4.1
- Note : YOURLS can also run on Nginx and Cherokee
-
-
-
Server recommendations
-
-
-
Limitations
-
- Maximum length of custom keyword is 200 characters
- That makes about 8 sexdecillions of centillions of available URLs (seriously . That's a 355 digits number).
-
-
-
Difference Between Base 36 And Base 62 Encoding
-
- Base 36 encoding uses 0123456789abcdefghijklmnopqrstuvwxyz
for short URLs
- Base 62 encoding uses 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
- Stick to one setting, don't change after you've created links as it will change all your short URLs!
- Base 36 is the default and should be picked if you're not sure.
-
-
-
Getting a short domain name for your YOURLS install
-
- Unless you plan on making it public and as popular as bit.ly, any shared hosting will be fine. Ozh runs all his YOURLS instance on Dreamhost and it works just great.
- Domainr is a fun search tool that might inspire and help you
- Aim for exotic top level domains (.in, .im, .li ...), they're often cheap and a lot are still available. Gandi is a pretty comprehensive registrar, for instance.
-
-
-
YOURLS needs its own .htaccess
-
- You cannot install YOURLS and, say, WordPress, in the same directory. Both need to handle URLs differently and need their own .htaccess file.
- If you want to install YOURLS on the same domain than your blog, give it its own (short) subdirectory, such as yourblog.com/s/ (for "short") or yourblog.com/x/ (for "exit")
-
-
-
If YOURLS generates 404 for your short URLs
-
- Make sure mod_rewrite is enabled with your Apache server
- Make sure your .htaccess file looks like this one
- Eventually, check your server Apache configuration allows use of .htaccess (AllowOverride All directive, ask your server admin)
-
-
-
There is no index page at the root of the install
-
- Indeed. It's intented. It's up to the user to make what they need. Some will redirect the root to a different place, some make a public interface for anyone to shorten links, some make a portfolio. You make it.
- If you want to make a public interface and run your own little bitly.com, there's a sample file provided as an example: sample-public-front-page.txt
. This implies important issues to deal with: spam, performance and security. Read Public Shortening for important information.
-
-
-
Uppercase letters in short URLs are eaten up, eg "OmgOzh
" becomes "mgzh
" !
-
- Indeed. It's intented if you selected Base 36 (see above). Letters that don't belong to the character set, eg @#!
or ABC
, are removed.
- If you want to force lowercase, you'll need a plugin .
-
-
-
Feedback, feature requests and bug reporting
-
- Please don't get in touch directly by mail or Twitter. Please .
- Check the Road Map for future features.
- Read all the wiki documents .
- Search in all the issues , open and closed.
- Eventually raise a new issue. To do so, please read the contribute guidelines . Thanks!
-
-
-
-
-
-
-
-
-
Community
-
-
YOURLS is open source, so the community of users plays a great role in its development, by contributing, helping others or giving feedback that helps improve the software.
-
-
Resources
-
- The official YOURLS blog , for news, hints and showcase.
- The wiki : advanced documentation, plugins, tips and more
- Follow @YOURLS for hardcore development, and @Ozh for tips and news (and random geekiness too)
-
-
-
Showcase
-
-
Here are a few examples of sites running YOURLS with a unique design or concept
-
- http://oe.cd/
- OECD's internal URL shortener with a neat interface and private features
-
- http://xib.me/
- A nicely styled YOURLS public interface
-
- http://rml.me/
- A personal URL shortener front page showing new links and most clicked links
-
- http://vt802.us/
- Defined as "The World's First Vermont-centric URL Shortener"
-
- http://yourwish.es/
- Easily share an Amazon wishlist
-
- http://vbly.us
- Public YOURLS setup and early adopter, run by famous sex writer Violet Blue as "the internet's first and only sex-positive url shortener", once taken down by Libya (story )
-
-
-
YOURLS and other platforms or frameworks
-
- WordPress
- There are numerous WordPress plugin with YOURLS support. YOURLS Link Creator is recommended.
-
- Drupal
- Allows for the automatic creation of short urls using a YOURLS installation
-
- Perl
- WWW-Shorten-Yourls is a Perl module to shorten URLs using YOURLS
-
- Ruby
- A Ruby wrapper for the YOURLS API
-
- Python
- A Python client for YOURLS
-
- VB .Net
- A VB .Net 4.0 wrapper for the YOURLS API
-
- Javascript
- JavaScript bindings for the YOURLS API to leverage JSONP support
-
- CakePHP
- Plugin which integrates CakePHP with Yourls
-
- status.net
- A plugin for status.net to use YOURLS
-
- Sharetronix
- A YOURLS addon for Sharetronix
-
-
-
-
YOURLS works with your favorite sofware or device
-
-
-
More stuff to do with YOURLS
-
-
- Infinity Squared
- ∞² is a public page theme for YOURLS to help you design your own public interface
-
- John Girvin's page
- Example index page listing all the URLs held in a YOURLS database
-
- http://screenr.com/nTs
- A screencast explaining how to setup YOURLS
-
- YOURLS: Short URL Widget
- Creates a fully configurable widget that outputs the short URL to the current post or page
-
- YOURLS Widget for WordPress
- This widget adds a convenient short URL service into your sidebar. Check the above link for a live example
-
- Twitter Tools & YOURLS
- Companion plugin for Alex King's Twitter Tool for WordPress, that enables YOURLS support
-
- Export URLS as text list
- A simple script to list all URLs, one per line, in plain text (for using as an indexer config file, for example)
-
- YOURLS featured on Lifehacker
-
-
-
"Celebrity endorsements", sort of.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sources/sample-public-api.txt b/sources/sample-public-api.txt
deleted file mode 100644
index c3e1974..0000000
--- a/sources/sample-public-api.txt
+++ /dev/null
@@ -1,13 +0,0 @@
- markup and all CSS & JS files
-yourls_html_head();
-
-// Display title
-echo "YOURLS - Your Own URL Shortener \n";
-
-// Display left hand menu
-yourls_html_menu() ;
-
-// Part to be executed if FORM has been submitted
-if ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ) {
-
- // Display result message of short link creation
- if( isset( $message ) ) {
- echo "$message ";
- }
-
- if( $status == 'success' ) {
- // Include the Copy box and the Quick Share box
- yourls_share_box( $url, $shorturl, $title, $text );
-
- // Initialize clipboard -- requires js/share.js and js/jquery.zclip.min.js to be properly loaded in the
- echo "\n";
- }
-
-// Part to be executed when no form has been submitted
-} else {
-
- $site = YOURLS_SITE;
-
- // Display the form
- echo <<Enter a new URL to shorten
-
-HTML;
-
-}
-
-?>
-
-Bookmarklets
-
-Bookmark these links:
-
-
-
-Default
-
-Custom
-
-Popup
-
-Custom Popup
-
-
-
-Please note
-
-Be aware that a public interface will attract spammers. You are strongly advised to install anti spam plugins and any appropriate counter measure to deal with this issue.
-
- $url,
- 'keyword' => $keyword,
- 'title' => $title,
- 'format' => $format,
- 'action' => 'shorturl',
- 'username' => $username,
- 'password' => $password
- ) );
-
-// Fetch and return content
-$data = curl_exec($ch);
-curl_close($ch);
-
-// Do something with the result. Here, we just echo it.
-echo $data;
-
diff --git a/sources/sample-robots.txt b/sources/sample-robots.txt
deleted file mode 100644
index be16b0c..0000000
--- a/sources/sample-robots.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-User-agent: *
-Disallow: /admin
-Disallow: /css
-Disallow: /images
-Disallow: /includes
-Disallow: /js
-Disallow: /pages
-Disallow: /user
-
diff --git a/sources/user/config-sample.php b/sources/user/config-sample.php
deleted file mode 100644
index 4466633..0000000
--- a/sources/user/config-sample.php
+++ /dev/null
@@ -1,91 +0,0 @@
- 'password',
- 'username2' => 'password2' // You can have one or more 'login'=>'password' lines
- );
-
-/** Debug mode to output some internal information
- ** Default is false for live site. Enable when coding or before submitting a new issue */
-define( 'YOURLS_DEBUG', false );
-
-/*
- ** URL Shortening settings
- */
-
-/** URL shortening method: 36 or 62 */
-define( 'YOURLS_URL_CONVERT', 36 );
-/*
- * 36: generates all lowercase keywords (ie: 13jkm)
- * 62: generates mixed case keywords (ie: 13jKm or 13JKm)
- * Stick to one setting. It's best not to change after you've started creating links.
- */
-
-/**
-* Reserved keywords (so that generated URLs won't match them)
-* Define here negative, unwanted or potentially misleading keywords.
-*/
-$yourls_reserved_URL = array(
- 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', 'gay',
-);
-
-/*
- ** Personal settings would go after here.
- */
-
diff --git a/sources/user/index.html b/sources/user/index.html
deleted file mode 100644
index cfce37c..0000000
--- a/sources/user/index.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-YOURLS has nothing for you to see here.
-
-
\ No newline at end of file
diff --git a/sources/user/languages/index.html b/sources/user/languages/index.html
deleted file mode 100644
index 7116f76..0000000
--- a/sources/user/languages/index.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-YOURLS has nothing for you to see here.
-
-
\ No newline at end of file
diff --git a/sources/user/plugins/hyphens-in-urls/README.md b/sources/user/plugins/hyphens-in-urls/README.md
deleted file mode 100644
index ba72883..0000000
--- a/sources/user/plugins/hyphens-in-urls/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Hyphens in URLs
-===============
-This is a core plugin, bundled with YOURLS.
-Don't modify this plugin. Instead, copy its folder
-and modify your own copy. This way, your code won't
-be overwritten when you upgrade YOURLS.
\ No newline at end of file
diff --git a/sources/user/plugins/hyphens-in-urls/plugin.php b/sources/user/plugins/hyphens-in-urls/plugin.php
deleted file mode 100644
index 3803412..0000000
--- a/sources/user/plugins/hyphens-in-urls/plugin.php
+++ /dev/null
@@ -1,19 +0,0 @@
-http://sho.rt/hello-world)
-Version: 1.0
-Author: Ozh
-Author URI: http://ozh.org/
-*/
-
-// No direct call
-if( !defined( 'YOURLS_ABSPATH' ) ) die();
-
-yourls_add_filter( 'get_shorturl_charset', 'ozh_hyphen_in_charset' );
-function ozh_hyphen_in_charset( $in ) {
- return $in.'-';
-}
-
-
diff --git a/sources/user/plugins/index.html b/sources/user/plugins/index.html
deleted file mode 100644
index cfce37c..0000000
--- a/sources/user/plugins/index.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-YOURLS has nothing for you to see here.
-
-
\ No newline at end of file
diff --git a/sources/user/plugins/random-bg/README.md b/sources/user/plugins/random-bg/README.md
deleted file mode 100644
index f3867fa..0000000
--- a/sources/user/plugins/random-bg/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Random Background
-=================
-This is a sample plugin, for illustration purpose.
-Don't modify this plugin. Instead, copy its folder
-and modify your own copy. This way, your code won't
-be overwritten when you upgrade YOURLS.
\ No newline at end of file
diff --git a/sources/user/plugins/random-bg/img/bg_ants.png b/sources/user/plugins/random-bg/img/bg_ants.png
deleted file mode 100644
index 1b736b0..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_ants.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_boobs.png b/sources/user/plugins/random-bg/img/bg_boobs.png
deleted file mode 100644
index 09d2dd4..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_boobs.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_circles.png b/sources/user/plugins/random-bg/img/bg_circles.png
deleted file mode 100644
index 27c2884..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_circles.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_cross.png b/sources/user/plugins/random-bg/img/bg_cross.png
deleted file mode 100644
index 3129cdd..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_cross.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_diag.png b/sources/user/plugins/random-bg/img/bg_diag.png
deleted file mode 100644
index f3c5fb7..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_diag.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_fuzzy.png b/sources/user/plugins/random-bg/img/bg_fuzzy.png
deleted file mode 100644
index 6850ca4..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_fuzzy.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_fuzzy_bits.png b/sources/user/plugins/random-bg/img/bg_fuzzy_bits.png
deleted file mode 100644
index 91ff805..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_fuzzy_bits.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_life.png b/sources/user/plugins/random-bg/img/bg_life.png
deleted file mode 100644
index 7d3e54f..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_life.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/img/bg_yourls.png b/sources/user/plugins/random-bg/img/bg_yourls.png
deleted file mode 100644
index d96cde8..0000000
Binary files a/sources/user/plugins/random-bg/img/bg_yourls.png and /dev/null differ
diff --git a/sources/user/plugins/random-bg/plugin.php b/sources/user/plugins/random-bg/plugin.php
deleted file mode 100644
index e0c1ef1..0000000
--- a/sources/user/plugins/random-bg/plugin.php
+++ /dev/null
@@ -1,27 +0,0 @@
-
- body {background:#e3f3ff url($rnd) repeat;}
-
-
-CSS;
-}
-
diff --git a/sources/user/plugins/sample-page/README.md b/sources/user/plugins/sample-page/README.md
deleted file mode 100644
index 5bba6de..0000000
--- a/sources/user/plugins/sample-page/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Sample Page
-===========
-This is a sample plugin, for illustration purpose.
-Don't modify this plugin. Instead, copy its folder
-and modify your own copy. This way, your code won't
-be overwritten when you upgrade YOURLS.
\ No newline at end of file
diff --git a/sources/user/plugins/sample-page/plugin.php b/sources/user/plugins/sample-page/plugin.php
deleted file mode 100644
index 717961d..0000000
--- a/sources/user/plugins/sample-page/plugin.php
+++ /dev/null
@@ -1,63 +0,0 @@
-Sample Plugin Administration Page
- This plugin stores an integer in the option database
-
-
-HTML;
-}
-
-// Update option in database
-function ozh_yourls_samplepage_update_option() {
- $in = $_POST['test_option'];
-
- if( $in ) {
- // Validate test_option. ALWAYS validate and sanitize user input.
- // Here, we want an integer
- $in = intval( $in);
-
- // Update value in database
- yourls_update_option( 'test_option', $in );
- }
-}
\ No newline at end of file
diff --git a/sources/user/plugins/sample-plugin/README.md b/sources/user/plugins/sample-plugin/README.md
deleted file mode 100644
index 720c698..0000000
--- a/sources/user/plugins/sample-plugin/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Sample Plugin
-=============
-This is a sample plugin, for illustration purpose.
-Don't modify this plugin. Instead, copy its folder
-and modify your own copy. This way, your code won't
-be overwritten when you upgrade YOURLS.
\ No newline at end of file
diff --git a/sources/user/plugins/sample-plugin/plugin.php b/sources/user/plugins/sample-plugin/plugin.php
deleted file mode 100644
index c4769c3..0000000
--- a/sources/user/plugins/sample-plugin/plugin.php
+++ /dev/null
@@ -1,61 +0,0 @@
-Plugin API documentation for more details.
-Version: 0.1
-Author: Ozh
-Author URI: http://ozh.org/
-*/
-
-// No direct call
-if( !defined( 'YOURLS_ABSPATH' ) ) die();
-
-/* Example of an action
- *
- * We're going to add an entry to the menu.
- *
- * The menu is drawn by function yourls_html_menu() in file includes/functions-html.php.
- * Right before the function outputs the closing , notice the following function call:
- * yourls_do_action( 'admin_menu' );
- * This function says: "hey, for your information, I've just done something called 'admin menu', thought I'd let you know..."
- *
- * We're going to hook into this action and add our menu entry
- */
-
-yourls_add_action( 'admin_menu', 'ozh_sample_add_menu' );
-/* This says: when YOURLS does action 'admin_menu', call function 'ozh_sample_add_menu'
- */
-
-function ozh_sample_add_menu() {
- echo 'Ozh ';
-}
-/* And that's it. Activate the plugin and notice the new menu entry.
- */
-
-
-
-/* Example of a filter
- *
- * We're going to modify the of pages in the admin area
- *
- * The tag is generated by function yourls_html_head() in includes/functions-html.php
- * Notice the following function call:
- * $title = yourls_apply_filter( 'html_title', 'YOURLS: Your Own URL Shortener' );
- * This function means: give $title the value "YOURLS: Your Own URL Shortener", unless a
- * filter modifies this value.
- *
- * We're going to hook into this filter and modify this value.
- */
-
-yourls_add_filter( 'html_title', 'ozh_sample_change_title' );
-/* This says: when filter 'html_title' is triggered, send its value to function 'ozh_sample_change_title'
- * and use what this function will return.
- */
-
-function ozh_sample_change_title( $value ) {
- $value = $value . ' (we have hacked this title)';
- return $value; // a filter *always* has to return a value
-}
-/* And that's it. Activate the plugin and notice how the page title changes */
-
diff --git a/sources/user/plugins/sample-toolbar/README.md b/sources/user/plugins/sample-toolbar/README.md
deleted file mode 100644
index a7bae40..0000000
--- a/sources/user/plugins/sample-toolbar/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Sample Toolbar
-==============
-This is a sample plugin, for illustration purpose.
-Don't modify this plugin. Instead, copy its folder
-and modify your own copy. This way, your code won't
-be overwritten when you upgrade YOURLS.
\ No newline at end of file
diff --git a/sources/user/plugins/sample-toolbar/css/toolbar.css b/sources/user/plugins/sample-toolbar/css/toolbar.css
deleted file mode 100644
index 59c7607..0000000
--- a/sources/user/plugins/sample-toolbar/css/toolbar.css
+++ /dev/null
@@ -1,79 +0,0 @@
-body {
- margin:0;
- overflow:hidden;
- background-color:#fff;
- font-size:12px;
- font-family: Verdana, Arial;
- padding:35px 0 0;
-}
-
-#yourls-frame {
- width: 100%;
- height:100%;
- z-index: 1;
-}
-
-#yourls-bar {
- font-family: Verdana, Arial;
- font-size: 12px;
- position:absolute;
- top:0;
- height:35px;
- width:100%;
- background:#e3f3ff url(../img/toolbar_bg.png) repeat-x bottom center;
- color:#2A85B3;
- -moz-box-shadow: 0 1px 5px rgba(0,0,0,0.5);
- -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
- z-index: 900000;
-}
-
-#yourls-bar a {
- text-decoration:none;
- color:#2A85B3;
-}
-
-#yourls-bar a:hover {
- text-decoration:underline;
-}
-
-#yourls-about, #yourls-topsy, #yourls-delicious, #yourls-selfclose {
- margin-left:10px;
- float:left;
- display:block;
- top:5px;
- position:relative;
-}
-
-#yourls-about a {
- background:transparent url(../img/favicon.gif) center left no-repeat;
- padding-left:20px;
- color:inherit;
- font-weight:bold;
-}
-
-#yourls-topsy {
- width:300px;
-}
-
-#yourls-selfclose {
- float:right;
- margin-right:10px;
-}
-
-#yourls-once {
- display:block;
- text-indent:-9999px;
- background:transparent url(../img/close_button.gif) center center no-repeat;
- width:20px;
- height:20px;
- float:left;
-}
-
-#yourls-always {
- display:none;
- text-indent:-9999px;
- background:transparent url(../img/close_button_red.gif) center center no-repeat;
- width:20px;
- height:20px;
- float:left;
-}
diff --git a/sources/user/plugins/sample-toolbar/img/close_button.gif b/sources/user/plugins/sample-toolbar/img/close_button.gif
deleted file mode 100644
index 95d286c..0000000
Binary files a/sources/user/plugins/sample-toolbar/img/close_button.gif and /dev/null differ
diff --git a/sources/user/plugins/sample-toolbar/img/close_button_red.gif b/sources/user/plugins/sample-toolbar/img/close_button_red.gif
deleted file mode 100644
index b443f12..0000000
Binary files a/sources/user/plugins/sample-toolbar/img/close_button_red.gif and /dev/null differ
diff --git a/sources/user/plugins/sample-toolbar/img/favicon.gif b/sources/user/plugins/sample-toolbar/img/favicon.gif
deleted file mode 100644
index 8681802..0000000
Binary files a/sources/user/plugins/sample-toolbar/img/favicon.gif and /dev/null differ
diff --git a/sources/user/plugins/sample-toolbar/img/toolbar_bg.png b/sources/user/plugins/sample-toolbar/img/toolbar_bg.png
deleted file mode 100644
index 0fb3cec..0000000
Binary files a/sources/user/plugins/sample-toolbar/img/toolbar_bg.png and /dev/null differ
diff --git a/sources/user/plugins/sample-toolbar/js/toolbar.js b/sources/user/plugins/sample-toolbar/js/toolbar.js
deleted file mode 100644
index bfa249a..0000000
--- a/sources/user/plugins/sample-toolbar/js/toolbar.js
+++ /dev/null
@@ -1,22 +0,0 @@
-
-// If javascript is enabled, display the button
-document.getElementById('yourls-always').style.display = 'block';
-
-// When button clicked, store a cookie that says the user doesn't want a toolbar
-document.getElementById('yourls-always').onclick = yourls_cookie_no_toolbar_please;
-function yourls_cookie_no_toolbar_please() {
- var exdate=new Date();
- exdate.setDate( exdate.getDate()+365 ); // store 365 days
- document.cookie = "yourls_no_toolbar=1;expires="+exdate.toUTCString() ;
-}
-
-// Get the number of delicious bookmarks
-function yourls_get_books(json) {
- if( json.length ) {
- var books = json[0].total_posts.toString();
- if( books ) {
- document.getElementById('yourls-delicious-link').innerHTML = ' '+books+' bookmarks';
- }
- }
-}
-
diff --git a/sources/user/plugins/sample-toolbar/plugin.php b/sources/user/plugins/sample-toolbar/plugin.php
deleted file mode 100644
index ed0745c..0000000
--- a/sources/user/plugins/sample-toolbar/plugin.php
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
- $pagetitle — YOURLS
-
-
-
-
-
-
-
-
-
-
- Short link powered by
YOURLS and created $created. $hits.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-PAGE;
-
- // Don't forget to die, to interrupt the flow of normal events (ie redirecting to long URL)
- die();
-}
\ No newline at end of file
diff --git a/sources/yourls-api.php b/sources/yourls-api.php
deleted file mode 100644
index fda4af9..0000000
--- a/sources/yourls-api.php
+++ /dev/null
@@ -1,51 +0,0 @@
- 'yourls_api_action_shorturl',
- 'stats' => 'yourls_api_action_stats',
- 'db-stats' => 'yourls_api_action_db_stats',
- 'url-stats' => 'yourls_api_action_url_stats',
- 'expand' => 'yourls_api_action_expand',
- 'version' => 'yourls_api_action_version',
-);
-$api_actions = yourls_apply_filters( 'api_actions', $api_actions );
-
-// Register API actions
-foreach( (array) $api_actions as $_action => $_callback ) {
- yourls_add_filter( 'api_action_' . $_action, $_callback, 99 );
-}
-
-// Try requested API method. Properly registered actions should return an array.
-$return = yourls_apply_filter( 'api_action_' . $action, false );
-if ( false === $return ) {
- $return = array(
- 'errorCode' => 400,
- 'message' => 'Unknown or missing "action" parameter',
- 'simple' => 'Unknown or missing "action" parameter',
- );
-}
-
-if( isset( $_REQUEST['callback'] ) )
- $return['callback'] = $_REQUEST['callback'];
-
-$format = ( isset( $_REQUEST['format'] ) ? $_REQUEST['format'] : 'xml' );
-
-yourls_api_output( $format, $return );
-
-die();
\ No newline at end of file
diff --git a/sources/yourls-go.php b/sources/yourls-go.php
deleted file mode 100644
index 1f7530d..0000000
--- a/sources/yourls-go.php
+++ /dev/null
@@ -1,45 +0,0 @@
-get_results( yourls_apply_filter( 'stat_query_referrer', $query ) );
-
- // Loop through all results and build list of referrers, countries and hits per day
- foreach( (array)$rows as $row ) {
- if ( $row->referrer == 'direct' ) {
- $direct = $row->count;
- continue;
- }
-
- $host = yourls_get_domain( $row->referrer );
- if( !array_key_exists( $host, $referrers ) )
- $referrers[$host] = array( );
- if( !array_key_exists( $row->referrer, $referrers[$host] ) ) {
- $referrers[$host][$row->referrer] = $row->count;
- $notdirect += $row->count;
- } else {
- $referrers[$host][$row->referrer] += $row->count;
- $notdirect += $row->count;
- }
- }
-
- // Sort referrers. $referrer_sort is a array of most frequent domains
- arsort( $referrers );
- $referrer_sort = array();
- $number_of_sites = count( array_keys( $referrers ) );
- foreach( $referrers as $site => $urls ) {
- if( count($urls) > 1 || $number_of_sites == 1 )
- $referrer_sort[$site] = array_sum( $urls );
- }
- arsort($referrer_sort);
-
-
- // *** Countries ***
- $query = "SELECT `country_code`, COUNT(*) AS `count` FROM `$table` WHERE `shorturl` $keyword_range GROUP BY `country_code`;";
- $rows = $ydb->get_results( yourls_apply_filter( 'stat_query_country', $query ) );
-
- // Loop through all results and build list of countries and hits
- foreach( (array)$rows as $row ) {
- if ("$row->country_code")
- $countries["$row->country_code"] = $row->count;
- }
-
- // Sort countries, most frequent first
- if ( $countries )
- arsort( $countries );
-
-
- // *** Dates : array of $dates[$year][$month][$day] = number of clicks ***
- $query = "SELECT
- DATE_FORMAT(`click_time`, '%Y') AS `year`,
- DATE_FORMAT(`click_time`, '%m') AS `month`,
- DATE_FORMAT(`click_time`, '%d') AS `day`,
- COUNT(*) AS `count`
- FROM `$table`
- WHERE `shorturl` $keyword_range
- GROUP BY `year`, `month`, `day`;";
- $rows = $ydb->get_results( yourls_apply_filter( 'stat_query_dates', $query ) );
-
- // Loop through all results and fill blanks
- foreach( (array)$rows as $row ) {
- if( !array_key_exists($row->year, $dates ) )
- $dates[$row->year] = array();
- if( !array_key_exists( $row->month, $dates[$row->year] ) )
- $dates[$row->year][$row->month] = array();
- if( !array_key_exists( $row->day, $dates[$row->year][$row->month] ) )
- $dates[$row->year][$row->month][$row->day] = $row->count;
- else
- $dates[$row->year][$row->month][$row->day] += $row->count;
- }
-
- // Sort dates, chronologically from [2007][12][24] to [2009][02][19]
- ksort( $dates );
- foreach( $dates as $year=>$months ) {
- ksort( $dates[$year] );
- foreach( $months as $month=>$day ) {
- ksort( $dates[$year][$month] );
- }
- }
-
- // Get $list_of_days, $list_of_months, $list_of_years
- reset( $dates );
- if( $dates ) {
- extract( yourls_build_list_of_days( $dates ) );
- }
-
-
- // *** Last 24 hours : array of $last_24h[ $hour ] = number of click ***
- $query = "SELECT
- DATE_FORMAT(`click_time`, '%H %p') AS `time`,
- COUNT(*) AS `count`
- FROM `$table`
- WHERE `shorturl` $keyword_range AND `click_time` > (CURRENT_TIMESTAMP - INTERVAL 1 DAY)
- GROUP BY `time`;";
- $rows = $ydb->get_results( yourls_apply_filter( 'stat_query_last24h', $query ) );
-
- $_last_24h = array();
- foreach( (array)$rows as $row ) {
- if ( $row->time )
- $_last_24h[ "$row->time" ] = $row->count;
- }
-
- $now = intval( date('U') );
- for ($i = 23; $i >= 0; $i--) {
- $h = date('H A', $now - ($i * 60 * 60) );
- // If the $last_24h doesn't have all the hours, insert missing hours with value 0
- $last_24h[ $h ] = array_key_exists( $h, $_last_24h ) ? $_last_24h[ $h ] : 0 ;
- }
- unset( $_last_24h );
-
- // *** Queries all done, phew ***
-
- // Filter all this junk if applicable. Be warned, some are possibly huge datasets.
- $referrers = yourls_apply_filter( 'pre_yourls_info_referrers', $referrers );
- $referrer_sort = yourls_apply_filter( 'pre_yourls_info_referrer_sort', $referrer_sort );
- $direct = yourls_apply_filter( 'pre_yourls_info_direct', $direct );
- $notdirect = yourls_apply_filter( 'pre_yourls_info_notdirect', $notdirect );
- $dates = yourls_apply_filter( 'pre_yourls_info_dates', $dates );
- $list_of_days = yourls_apply_filter( 'pre_yourls_info_list_of_days', $list_of_days );
- $list_of_months = yourls_apply_filter( 'pre_yourls_info_list_of_months', $list_of_months );
- $list_of_years = yourls_apply_filter( 'pre_yourls_info_list_of_years', $list_of_years );
- $last_24h = yourls_apply_filter( 'pre_yourls_info_last_24h', $last_24h );
- $countries = yourls_apply_filter( 'pre_yourls_info_countries', $countries );
-
- // I can haz debug data
- /**
- echo "";
- echo "referrers: "; print_r( $referrers );
- echo "referrer sort: "; print_r( $referrer_sort );
- echo "direct: $direct\n";
- echo "notdirect: $notdirect\n";
- echo "dates: "; print_r( $dates );
- echo "list of days: "; print_r( $list_of_days );
- echo "list_of_months: "; print_r( $list_of_months );
- echo "list_of_years: "; print_r( $list_of_years );
- echo "last_24h: "; print_r( $last_24h );
- echo "countries: "; print_r( $countries );
- die();
- /**/
-
-}
-
-yourls_html_head( 'infos', yourls_s( 'Statistics for %s', YOURLS_SITE.'/'.$keyword ) );
-yourls_html_logo();
-yourls_html_menu();
-?>
-
-
-
-:
- 1 )
- echo ' ';
-} ?>
-:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- yourls__( 'Last 24 hours' ),
- '7' => yourls__( 'Last 7 days' ),
- '30' => yourls__( 'Last 30 days' ),
- 'all'=> yourls__( 'All time' ),
- );
-
- // Which graph to generate ?
- $do_all = $do_30 = $do_7 = $do_24 = false;
- $hits_all = array_sum( $list_of_days );
- $hits_30 = array_sum( array_slice( $list_of_days, -30 ) );
- $hits_7 = array_sum( array_slice( $list_of_days, -7 ) );
- $hits_24 = array_sum( $last_24h );
- if( $hits_all > 0 )
- $do_all = true; // graph for all days range
- if( $hits_30 > 0 && count( array_slice( $list_of_days, -30 ) ) == 30 )
- $do_30 = true; // graph for last 30 days
- if( $hits_7 > 0 && count( array_slice( $list_of_days, -7 ) ) == 7 )
- $do_7 = true; // graph for last 7 days
- if( $hits_24 > 0 )
- $do_24 = true; // graph for last 24 hours
-
- // Which graph to display ?
- $display_all = $display_30 = $display_7 = $display_24 = false;
- if( $do_24 ) {
- $display_24 = true;
- } elseif ( $do_7 ) {
- $display_7 = true;
- } elseif ( $do_30 ) {
- $display_30 = true;
- } elseif ( $do_all ) {
- $display_all = true;
- }
- ?>
-
-
-
-
-
- $graphtitle ) {
- if( ${'do_'.$graph} == true ) {
- $display = ( ${'display_'.$graph} === true ? 'display:block' : 'display:none' );
- echo "";
- echo '
' . yourls_s( 'Number of hits : %s' , $graphtitle ) . ' ';
- switch( $graph ) {
- case '24':
- yourls_stats_line( $last_24h, "stat_line_$graph" );
- break;
-
- case '7':
- case '30':
- $slice = array_slice( $list_of_days, intval( $graph ) * -1 );
- yourls_stats_line( $slice, "stat_line_$graph" );
- unset( $slice );
- break;
-
- case 'all':
- yourls_stats_line( $list_of_days, "stat_line_$graph" );
- break;
- }
- echo "\n";
- }
- } ?>
-
-
-
-
-
-
-
-
- $graphtitle ) {
- if ( ${'do_'.$graph} ) {
- $link = "$graphtitle ";
- } else {
- $link = $graphtitle;
- }
- $stat = '';
- if( ${'do_'.$graph} ) {
- switch( $graph ) {
- case '7':
- case '30':
- $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / intval( $graph ) ) * 100 ) / 100 );
- break;
- case '24':
- $stat = yourls_s( '%s per hour', round( ( ${'hits_'.$graph} / 24 ) * 100 ) / 100 );
- break;
- case 'all':
- if( $ago > 0 )
- $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / $ago ) * 100 ) / 100 );
- }
- }
- $hits = sprintf( yourls_n( '%s hit', '%s hits', ${'hits_'.$graph} ), ${'hits_'.$graph} );
- echo "$link $hits $stat \n";
- }
- ?>
-
-
-
-
-
- %1$s hit on %2$s', '%1$s hits on %2$s', $best['max'] ), $best['max'], yourls_date_i18n( "F j, Y", strtotime( $best['day'] ) ) ); ?>.
-
-
- $months ) {
- $css_year = ( $year == $best_time['year'] ? 'best_year' : '' );
- if( count( $list_of_years ) > 1 ) {
- $li = "" . yourls_s( 'Year %s', $year ) . ' ';
- $display = 'none';
- } else {
- $li = yourls_s( 'Year %s', $year );
- $display = 'block';
- }
- echo "$li ";
- echo "";
- foreach( $months as $month=>$days ) {
- $css_month = ( ( $month == $best_time['month'] && ( $css_year == 'best_year' ) ) ? 'best_month' : '' );
- $monthname = yourls_date_i18n( "F", mktime( 0, 0, 0, $month, 1 ) );
- if( count( $list_of_months ) > 1 ) {
- $li = "$monthname ";
- $display = 'none';
- } else {
- $li = "$monthname";
- $display = 'block';
- }
- echo "$li ";
- echo "";
- foreach( $days as $day=>$hits ) {
- $class = ( $hits == $best['max'] ? 'class="bestday"' : '' );
- echo "$day: " . sprintf( yourls_n( '1 hit', '%s hits', $hits ), $hits ) ." \n";
- }
- echo " \n";
- }
- echo " \n";
- }
- ?>
-
-
-
-
-
-
-
-
-
- ' . yourls__( 'No traffic yet. Get some clicks first!' ) . '';
- } ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $count ) {
- echo " $code (".yourls_geo_countrycode_to_countryname( $code ) . ') : ' . sprintf( yourls_n( '1 hit', '%s hits', $count ), $count ) . " \n";
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
- ' . yourls__( 'No country data.' ) . '';
- } ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1 )
- $referrer_sort[ yourls__( 'Others' ) ] = count( $referrers );
- yourls_stats_pie( $referrer_sort, 5, '440x220', 'stat_tab_source_ref' );
- unset( $referrer_sort['Others'] );
- ?>
-
-
- $count ) {
- $i++;
- $favicon = yourls_get_favicon_url( $site );
- echo " $site: $count " . yourls__( '(details)' ) . " \n";
- echo "";
- foreach( $referrers[$site] as $url => $count ) {
- echo ""; yourls_html_link($url); echo ": $count \n";
- }
- echo " \n";
- unset( $referrers[$site] );
- }
- // Any referrer left? Group in "various"
- if ( $referrers ) {
- echo "" . yourls__( 'Various:' ) . " ". count( $referrers ). " " . yourls__( '(details)' ) . " \n";
- echo "";
- foreach( $referrers as $url ) {
- echo ""; yourls_html_link(key($url)); echo ": 1 \n";
- }
- echo " \n";
- }
- ?>
-
-
-
-
-
-
-
- $direct, yourls__( 'Referrers' ) => $notdirect ), 5, '440x220', 'stat_tab_source_direct' );
- ?>
- %s hit', '%s hits', $direct ), $direct ); ?>
- %s hit', '%s hits', $notdirect ), $notdirect ); ?>
-
-
-
-
-
-
-
- ' . yourls__( 'No referrer data.' ) . '';
- } ?>
-
-
-
-
-
-
-
-
-
- ' . yourls__( 'Short link' ) . '', '' . yourls__( 'Quick Share' ) . ' '); ?>
-
-
-
-
-
-
-
diff --git a/sources/yourls-loader.php b/sources/yourls-loader.php
deleted file mode 100644
index 1e588d5..0000000
--- a/sources/yourls-loader.php
+++ /dev/null
@@ -1,66 +0,0 @@
-&us=&ur=
- yourls_redirect( yourls_add_query_arg( $parse , yourls_admin_url( 'index.php' ) ), 302 );
- exit;
- }
-}
-
-// Past this point this is a request the loader could not understand
-yourls_do_action( 'loader_failed', $request );
-yourls_redirect( YOURLS_SITE, 302 );
-exit;