NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Help Converting fopen to curl!

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-04-2006, 12:45 PM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Jul 2005
Posts: 573
dsforsaken is a name known to alldsforsaken is a name known to alldsforsaken is a name known to alldsforsaken is a name known to alldsforsaken is a name known to alldsforsaken is a name known to all
 



Help Converting fopen to curl!


need help to convert 2 pieces of code

Code:
function cdb_build_links($console, $letter, $cdb_link_int) {

    Global $path_to_backend, $password, $username;

    $cdb_build_path = "$path_to_backend" . "client=2&console=" . urlencode($console) . "&letter=".urlencode($letter)."&username=".urlencode($username)."&password=".urlencode($password);
        

        $cdb_file = fopen ("$cdb_build_path", "r");

            if (!$cdb_file) {

                return "<p>Unable to connect to cheats database.\n";

                exit;

            }
            while (!feof ($cdb_file)) {

                $cdb_buffer .= fgets ($cdb_file, 1024);

            }
	    
            if (!strstr($cdb_buffer, '/||n||/') === 0) {

                return $cdb_buffer;

            }

????: NamePros.com http://www.namepros.com/programming/254348-help-converting-fopen-to-curl.html


and this also

i get a url file-acess disabled in server message

Code:
<? include($urlBase.'/Train/_module.php');?>

thanks a ton!
dsforsaken is offline  
Old 11-04-2006, 01:25 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
class.curl.php
PHP Code:
<?php

class CURL {
    var 
$callback false;

    function 
setCallback($func_name) {
       
$this->callback $func_name;
    }
    
    function 
doRequest($method$url$vars) {
       
$ch curl_init();
       
curl_setopt($chCURLOPT_URL$url);
       
curl_setopt($chCURLOPT_HEADER1);
????: NamePros.com http://www.namepros.com/showthread.php?t=254348
       
curl_setopt($chCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
       
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
       
curl_setopt($chCURLOPT_RETURNTRANSFER1);
       
curl_setopt($chCURLOPT_COOKIEJAR'cookie.txt');
       
curl_setopt($chCURLOPT_COOKIEFILE'cookie.txt');
       if (
$method == 'POST') {
           
curl_setopt($chCURLOPT_POST1);
           
curl_setopt($chCURLOPT_POSTFIELDS$vars);
       }
       
$data curl_exec($ch);
       
curl_close($ch);
       if (
$data) {
           if (
$this->callback) {
               
$callback $this->callback;
               
$this->callback false;
               return 
call_user_func($callback$data);
           } else {
               return 
$data;
           }
       } else {
//           return curl_error($ch);
       
}
    }
    
    function 
get($url) {
       return 
$this->doRequest('GET'$url'NULL');
    }
    
    function 
post($url$vars) {
       return 
$this->doRequest('POST'$url$vars);
    }
}

$curl = new CURL;

?>
your first file:
Code:
include('class.curl.php');

function cdb_build_links($console, $letter, $cdb_link_int) {

    Global $path_to_backend, $password, $username;

    $cdb_build_path = "$path_to_backend" . "client=2&console=" . urlencode($console) . "&letter=".urlencode($letter)."&username=".urlencode($username)."&password=".urlencode($password);

    $cbd_file = $curl->get($cbd_build_path);
    
    if (!strstr($cdb_buffer, '/||n||/') === 0) {
        return $cdb_buffer;
    }
You should be allowed to include the file in your second code. If it has PHP in it that you want to execute, I don't know if using CURL would work. You can try including class.curl.php and do $curl->get($urlBase.'/Train/_module.php');
????: NamePros.com http://www.namepros.com/showthread.php?t=254348

(Also: I don't like working with functions that much due to the private variables and other things like that. If you get an error with the $curl->get line, add global $curl; somewhere before it.)
Dan is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:46 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger