[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/ -> functions-deprecated.php (source)

   1  <?php
   2  /**
   3   * Deprecated functions from past YOURLS versions. Don't use them, as they may be
   4   * removed in a later version. Use the newer alternatives instead.
   5   *
   6   * Note to devs: when deprecating a function, move it here. Then check all the places
   7   * in core that might be using it, including core plugins.
   8   *
   9   * Usage :  yourls_deprecated_function( 'function_name', 'version', 'replacement' );
  10   * Output:  "{function_name} is deprecated since version {version}! Use {replacement} instead."
  11   *
  12   * Usage :  yourls_deprecated_function( 'function_name', 'version' );
  13   * Output:  "{function_name} is deprecated since version {version} with no alternative available."
  14   *
  15   * @see yourls_deprecated_function()
  16   */
  17  
  18  // @codeCoverageIgnoreStart
  19  
  20  /**
  21   * Plugin activation sandbox
  22   *
  23   * @since 1.8.3
  24   * @deprecated 1.9.2
  25   * @param string $pluginfile Plugin filename (full path)
  26   * @return string|true  string if error or true if success
  27   */
  28  function yourls_activate_plugin_sandbox( $pluginfile ) {
  29      yourls_deprecated_function( __FUNCTION__, '1.9.1', 'yourls_include_file_sandbox');
  30      return yourls_include_file_sandbox($pluginfile);
  31  }
  32  
  33  /**
  34   * Return current admin page, or null if not an admin page. Was not used anywhere.
  35   *
  36   * @return mixed string if admin page, null if not an admin page
  37   * @since 1.6
  38   * @deprecated 1.9.1
  39   */
  40  function yourls_current_admin_page() {
  41      yourls_deprecated_function( __FUNCTION__, '1.9.1' );
  42      if( yourls_is_admin() ) {
  43          $current = substr( yourls_get_request(), 6 );
  44          if( $current === false )
  45              $current = 'index.php'; // if current page is http://sho.rt/admin/ instead of http://sho.rt/admin/index.php
  46  
  47          return $current;
  48      }
  49      return null;
  50  }
  51  
  52  /**
  53   * PHP emulation of JS's encodeURI
  54   *
  55   * @link https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
  56   * @deprecated 1.9.1
  57   * @param string $url
  58   * @return string
  59   */
  60  function yourls_encodeURI($url) {
  61      yourls_deprecated_function( __FUNCTION__, '1.9.1', '' );
  62      // Decode URL all the way
  63      $result = yourls_rawurldecode_while_encoded( $url );
  64      // Encode once
  65      $result = strtr( rawurlencode( $result ), array (
  66          '%3B' => ';', '%2C' => ',', '%2F' => '/', '%3F' => '?', '%3A' => ':', '%40' => '@',
  67          '%26' => '&', '%3D' => '=', '%2B' => '+', '%24' => '$', '%21' => '!', '%2A' => '*',
  68          '%27' => '\'', '%28' => '(', '%29' => ')', '%23' => '#',
  69      ) );
  70      // @TODO:
  71      // Known limit: this will most likely break IDN URLs such as http://www.académie-française.fr/
  72      // To fully support IDN URLs, advocate use of a plugin.
  73      return yourls_apply_filter( 'encodeURI', $result, $url );
  74  }
  75  
  76  /**
  77   * Check if a file is a plugin file
  78   *
  79   * @deprecated 1.8.3
  80   */
  81  function yourls_validate_plugin_file( $file ) {
  82      yourls_deprecated_function( __FUNCTION__, '1.8.3', 'yourls_is_a_plugin_file' );
  83      return yourls_is_a_plugin_file($file);
  84  }
  85  
  86  /**
  87   * Return a unique(ish) hash for a string to be used as a valid HTML id
  88   *
  89   * @deprecated 1.8.3
  90   */
  91  function yourls_string2htmlid( $string ) {
  92      yourls_deprecated_function( __FUNCTION__, '1.8.3', 'yourls_unique_element_id' );
  93      return yourls_apply_filter( 'string2htmlid', 'y'.abs( crc32( $string ) ) );
  94  }
  95  
  96  /**
  97   * Get search text from query string variables search_protocol, search_slashes and search
  98   *
  99   * Some servers don't like query strings containing "(ht|f)tp(s)://". A javascript bit
 100   * explodes the search text into protocol, slashes and the rest (see JS function
 101   * split_search_text_before_search()) and this function glues pieces back together
 102   * See issue https://github.com/YOURLS/YOURLS/issues/1576
 103   *
 104   * @since 1.7
 105   * @deprecated 1.8.2
 106   * @return string Search string
 107   */
 108  function yourls_get_search_text() {
 109      yourls_deprecated_function( __FUNCTION__, '1.8.2', 'YOURLS\Views\AdminParams::get_search' );
 110      $view_params = new YOURLS\Views\AdminParams();
 111      return $view_params->get_search();
 112  }
 113  
 114  /**
 115   * Retrieve the current time based on specified type. Stolen from WP.
 116   *
 117   * The 'mysql' type will return the time in the format for MySQL DATETIME field.
 118   * The 'timestamp' type will return the current timestamp.
 119   *
 120   * If $gmt is set to either '1' or 'true', then both types will use GMT time.
 121   * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
 122   *
 123   * @since 1.6
 124   * @deprecated 1.7.10
 125   *
 126   * @param string $type Either 'mysql' or 'timestamp'.
 127   * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false.
 128   * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
 129   */
 130  function yourls_current_time( $type, $gmt = 0 ) {
 131      yourls_deprecated_function( __FUNCTION__, '1.7.10', 'yourls_get_timestamp' );
 132      switch ( $type ) {
 133          case 'mysql':
 134              return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', yourls_get_timestamp( time() ));
 135          case 'timestamp':
 136              return ( $gmt ) ? time() : yourls_get_timestamp( time() );
 137      }
 138  }
 139  
 140  /**
 141   * Lowercase scheme and domain of an URI - see issues 591, 1630, 1889
 142   *
 143   * Renamed to yourls_normalize_uri() in 1.7.10 because the function now does more than just
 144   * lowercasing the scheme and domain.
 145   *
 146   * @deprecated 1.7.10
 147   *
 148   */
 149  function yourls_lowercase_scheme_domain( $url ) {
 150      yourls_deprecated_function( __FUNCTION__, '1.7.10', 'yourls_normalize_uri' );
 151      return yourls_normalize_uri( $url );
 152  }
 153  
 154  /**
 155   * The original string sanitize function
 156   *
 157   * @deprecated 1.7.10
 158   *
 159   */
 160  function yourls_sanitize_string( $string, $restrict_to_shorturl_charset = false ) {
 161      yourls_deprecated_function( __FUNCTION__, '1.7.10', 'yourls_sanitize_keyword' );
 162      return yourls_sanitize_keyword( $string, $restrict_to_shorturl_charset );
 163  }
 164  
 165  /**
 166   * Return favicon URL (either default or custom)
 167   *
 168   * @deprecated 1.7.10
 169   *
 170   */
 171  function yourls_favicon( $echo = true ) {
 172      yourls_deprecated_function( __FUNCTION__, '1.7.10', 'yourls_get_yourls_favicon_url' );
 173      return yourls_get_yourls_favicon_url( $echo );
 174  }
 175  
 176  /**
 177   * Return array of stats for a given keyword
 178   *
 179   * @deprecated 1.7.10
 180   *
 181   */
 182  function yourls_get_link_stats( $url ) {
 183      yourls_deprecated_function( __FUNCTION__, '1.7.10', 'yourls_get_keyword_stats' );
 184      return yourls_get_keyword_stats( $url );
 185  }
 186  
 187  /**
 188   * Check if a long URL already exists in the DB. Return NULL (doesn't exist) or an object with URL informations.
 189   *
 190   * @since 1.5.1
 191   * @deprecated 1.7.10
 192   *
 193   */
 194  function yourls_url_exists( $url ) {
 195      yourls_deprecated_function( __FUNCTION__, '1.7.10', 'yourls_long_url_exists' );
 196      return yourls_long_url_exists( $url );
 197  }
 198  
 199  /**
 200   * Return word or words if more than one
 201   *
 202   */
 203  function yourls_plural( $word, $count=1 ) {
 204      yourls_deprecated_function( __FUNCTION__, '1.6', 'yourls_n' );
 205      return $word . ($count > 1 ? 's' : '');
 206  }
 207  
 208  /**
 209   * Return list of all shorturls associated to the same long URL. Returns NULL or array of keywords.
 210   *
 211   */
 212  function yourls_get_duplicate_keywords( $longurl ) {
 213      yourls_deprecated_function( __FUNCTION__, '1.7', 'yourls_get_longurl_keywords' );
 214      if( !yourls_allow_duplicate_longurls() )
 215          return NULL;
 216      return yourls_apply_filter( 'get_duplicate_keywords', yourls_get_longurl_keywords ( $longurl ), $longurl );
 217  }
 218  
 219  /**
 220   * Make sure a integer is safe
 221   *
 222   * Note: this function is dumb and dumbly named since it does not intval(). DO NOT USE.
 223   *
 224   */
 225  function yourls_intval( $int ) {
 226      yourls_deprecated_function( __FUNCTION__, '1.7', 'yourls_sanitize_int' );
 227      return yourls_escape( $int );
 228  }
 229  
 230  /**
 231   * Get remote content via a GET request using best transport available
 232   *
 233   */
 234  function yourls_get_remote_content( $url,  $maxlen = 4096, $timeout = 5 ) {
 235      yourls_deprecated_function( __FUNCTION__, '1.7', 'yourls_http_get_body' );
 236      return yourls_http_get_body( $url );
 237  }
 238  
 239  /**
 240   * Alias for yourls_apply_filter because I never remember if it's _filter or _filters
 241   *
 242   * At first I thought it made semantically more sense but thinking about it, I was wrong. It's one filter.
 243   * There may be several function hooked into it, but it still the same one filter.
 244   *
 245   * @since 1.6
 246   * @deprecated 1.7.1
 247   *
 248   * @param string $hook the name of the YOURLS element or action
 249   * @param mixed $value the value of the element before filtering
 250   * @return mixed
 251   */
 252  function yourls_apply_filters( $hook, $value = '' ) {
 253      yourls_deprecated_function( __FUNCTION__, '1.7.1', 'yourls_apply_filter' );
 254      return yourls_apply_filter( $hook, $value );
 255  }
 256  
 257  /**
 258   * Check if we'll need interface display function (ie not API or redirection)
 259   *
 260   */
 261  function yourls_has_interface() {
 262      yourls_deprecated_function( __FUNCTION__, '1.7.1' );
 263      if( yourls_is_API() or yourls_is_GO() )
 264          return false;
 265      return true;
 266  }
 267  
 268  /**
 269   * Check if a proxy is defined for HTTP requests
 270   *
 271   * @uses YOURLS_PROXY
 272   * @since 1.7
 273   * @deprecated 1.7.1
 274   * @return bool true if a proxy is defined, false otherwise
 275   */
 276  function yourls_http_proxy_is_defined() {
 277      yourls_deprecated_function( __FUNCTION__, '1.7.1', 'yourls_http_get_proxy' );
 278      return yourls_apply_filter( 'http_proxy_is_defined', defined( 'YOURLS_PROXY' ) );
 279  }
 280  
 281  /**
 282   * Displays translated string with gettext context
 283   *
 284   * This function has been renamed yourls_xe() for consistency with other *e() functions
 285   *
 286   * @see yourls_x()
 287   * @since 1.6
 288   * @deprecated 1.7.1
 289   *
 290   * @param string $text Text to translate
 291   * @param string $context Context information for the translators
 292   * @param string $domain Optional. Domain to retrieve the translated text
 293   * @return string Translated context string without pipe
 294   */
 295  function yourls_ex( $text, $context, $domain = 'default' ) {
 296      yourls_deprecated_function( __FUNCTION__, '1.7.1', 'yourls_xe' );
 297      echo yourls_xe( $text, $context, $domain );
 298  }
 299  
 300  /**
 301   * Escape a string or an array of strings before DB usage. ALWAYS escape before using in a SQL query. Thanks.
 302   *
 303   * Deprecated in 1.7.3 because we moved onto using PDO and using built-in escaping functions, instead of
 304   * rolling our own.
 305   *
 306   * @deprecated 1.7.3
 307   * @param string|array $data string or array of strings to be escaped
 308   * @return string|array escaped data
 309   */
 310  function yourls_escape( $data ) {
 311      yourls_deprecated_function( __FUNCTION__, '1.7.3', 'PDO' );
 312      if( is_array( $data ) ) {
 313          foreach( $data as $k => $v ) {
 314              if( is_array( $v ) ) {
 315                  $data[ $k ] = yourls_escape( $v );
 316              } else {
 317                  $data[ $k ] = yourls_escape_real( $v );
 318              }
 319          }
 320      } else {
 321          $data = yourls_escape_real( $data );
 322      }
 323  
 324      return $data;
 325  }
 326  
 327  /**
 328   * "Real" escape. This function should NOT be called directly. Use yourls_escape() instead.
 329   *
 330   * This function uses a "real" escape if possible, using PDO, MySQL or MySQLi functions,
 331   * with a fallback to a "simple" addslashes
 332   * If you're implementing a custom DB engine or a custom cache system, you can define an
 333   * escape function using filter 'custom_escape_real'
 334   *
 335   * @since 1.7
 336   * @deprecated 1.7.3
 337   * @param string $a string to be escaped
 338   * @return string escaped string
 339   */
 340  function yourls_escape_real( $string ) {
 341      yourls_deprecated_function( __FUNCTION__, '1.7.3', 'PDO' );
 342      global $ydb;
 343      if( isset( $ydb ) && ( $ydb instanceof \YOURLS\Database\YDB ) )
 344          return $ydb->escape( $string );
 345  
 346      // YOURLS DB classes have been bypassed by a custom DB engine or a custom cache layer
 347      return yourls_apply_filter( 'custom_escape_real', addslashes( $string ), $string );
 348  }
 349  
 350  // @codeCoverageIgnoreEnd


Generated: Fri Mar 28 05:10:25 2025 Cross-referenced by PHPXref 0.7.1