NameSilo

Help Converting fopen to curl!

Spacemail by SpaceshipSpacemail by Spaceship
Watch

dsforsaken

Account Closed
Impact
11
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;

            }




and this also

i get a url file-acess disabled in server message

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


thanks a ton!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
class.curl.php
PHP:
<?php

class CURL {
	var $callback = false;

	function setCallback($func_name) {
	   $this->callback = $func_name;
	}
	
	function doRequest($method, $url, $vars) {
	   $ch = curl_init();
	   curl_setopt($ch, CURLOPT_URL, $url);
	   curl_setopt($ch, CURLOPT_HEADER, 1);
	   curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
	   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	   curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
	   curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
	   if ($method == 'POST') {
		   curl_setopt($ch, CURLOPT_POST, 1);
		   curl_setopt($ch, CURLOPT_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');

(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.)
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back