[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/core/ -> url_api.php (source)

   1  <?php
   2  # MantisBT - A PHP based bugtracking system
   3  
   4  # MantisBT is free software: you can redistribute it and/or modify
   5  # it under the terms of the GNU General Public License as published by
   6  # the Free Software Foundation, either version 2 of the License, or
   7  # (at your option) any later version.
   8  #
   9  # MantisBT is distributed in the hope that it will be useful,
  10  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  # GNU General Public License for more details.
  13  #
  14  # You should have received a copy of the GNU General Public License
  15  # along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * URL API
  19   *
  20   * Provides means for simplifying remote URL operations.
  21   *
  22   * @package CoreAPI
  23   * @subpackage URLAPI
  24   * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
  25   * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  26   * @link http://www.mantisbt.org
  27   */
  28  
  29  /**
  30   * Retrieve the contents of a remote URL.
  31   * First tries using built-in PHP modules, then
  32   * attempts system calls as last resort.
  33   * @param string URL
  34   * @return string URL contents
  35   */
  36  function url_get( $p_url ) {
  37  
  38      # Generic PHP call
  39      if( ini_get_bool( 'allow_url_fopen' ) ) {
  40          return @file_get_contents( $p_url );
  41      }
  42  
  43      # Use the PHP cURL extension
  44      if( function_exists( 'curl_init' ) ) {
  45          $t_curl = curl_init( $p_url );
  46          curl_setopt( $t_curl, CURLOPT_RETURNTRANSFER, true );
  47  
  48          $t_data = curl_exec( $t_curl );
  49          curl_close( $t_curl );
  50  
  51          return $t_data;
  52      }
  53  
  54      # Last resort system call
  55      $t_url = escapeshellarg( $p_url );
  56      return shell_exec( 'curl ' . $t_url );
  57  }


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7