undefined method createConnection()

Started on the old forum in December 2011 · view the original in the archive · old links redirect here

15 replies · 930 views · started 14 years ago · 1 min read

7 participants
atef Developer · 224 posts #1

hello, i tried this class

<?php

class gombile
{ 

var $serverHost = "gateway.mig33.com"; 
var $serverPort = 25; 
var $filePath = "/member2/t.php";
var $username = null;
var $userdef = "cah_gombile";
var $_cookie = null;
var $fp_handle = null;
var $_respon = null;
var $_debug = true;
var $_debugMsg = array();
var $inRoom = false;
var $isPV = false; 
var $startKick = false;
var $kickMe = false; 

function Login($usr, $pwd, $rem=false, $inv=false, $ret=false){
$cookie = is_null($this->_cookie)?"": $this->_cookie; 
$usr = urlencode($usr);
$pwd = urlencode($pwd);

$params = "cmd=login&username=$usr&password=$pwd"; 
$params .= ($rem === true?"&rememberName=on":"");
$params .= ($inv === true?"&invisible=on":""); 

$this->_createConnection('POST', $this->filePath, $cookie, null, $params, false, false); 
$Cookies = array(); 

if($this->fp_handle) {
while(!feof($this->fp_handle)){

$respon = @fgets($this->fp_handle, 4096);
$this->_respon .= $respon; 

$isCookie = stristr($respon, "set-cookie");
if($isCookie) {
$Cookies[] .= trim(str_ireplace("set-cookie: ", "", $isCookie)); 
}
}
}else{
$this->_debugMsg[] .= "<span>Sorry, we couldn't connect to the mig33
server. This is out of our control.</span>";
}
}
}

?>

<?php

$usr="username"; 
$pwd="password"; 

$log=new gombile; 

echo $log->Login($usr, $pwd, false, false, false);

?>

I got this error Fatal error: Call to undefined method gombile::_createConnection() in / home/u338851794/public_html/ mig/class.php on line 33

I googled it and find nothing.. Please how to solve this error its yunas class Thanks

atef Developer · 224 posts #2

here is the fully class but its showing a blank page please i tired searching and trying someone help please 🙁

<?php

class gombile
{ 

var $serverHost = "gateway.mig33.com"; 
var $serverPort = 25; 
var $filePath = "/member2/t.php";
var $username = null;
var $userdef = "cah_gombile";
var $_cookie = null;
var $fp_handle = null;
var $_respon = null;
var $_debug = true;
var $_debugMsg = array();
var $inRoom = false;
var $isPV = false; 
var $startKick = false;
var $kickMe = false; 

function _createConnection($method = 'GET', $file = '/', $referer = null,
                        $cookie = null, $content = null, $close = true)
   {
      $this->fp_handle = @fsockopen ($this->serverHost, 80, $errno, $errstr, 100);
      if(!$this->fp_handle) {
         exit("can not connect to $this->serverHost");
      }
      
      $method = strtoupper($method);
      if(!in_array($method, array('GET', 'POST')) || is_null($content)) {
         $method = 'GET';
      }
      
      if(is_null($referer)) {
         $referer = $this->serverHost;
      }
      
      if(is_null($cookie)) {
         $cookie = $this->_cookie;
      }
      
      $data = "$method $file HTTP/1.1\n";
      $data.= "Accept: */*\n";
      $data.= "Accept-Language: fa\n";
      $data.= "Referer: $referer/\n";
      $data.= "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\n";
      $data.= "Accept-Encoding: gzip, deflate\n";
      $data.= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Avant Browser [avantbrowser.com]; .NET CLR 1.1.4322)\n";
      $data.= "Host: $this->serverHost\n";
      $data.= "Connection: Keep-Alive\n";
      $data.= "Cache-Control: no-cache\n";
      $data.= "Cookie: $cookie\n";
      
      if($method == 'POST') {
         $length = strlen($content);
         $data.= "Content-Length: $length\n\n";
         $data.= $content;
      } else {
         $data.= "\n";
      }
      
      @fputs ($this->fp_handle, $data);
      if($close) @fclose($this->fp_handle);
   }

function Login($usr, $pwd, $rem=false, $inv=false, $ret=false){
$cookie = is_null($this->_cookie)?"": $this->_cookie; 
$usr = urlencode($usr);
$pwd = urlencode($pwd);

$params = "cmd=login&username=$usr&password=$pwd"; 
$params .= ($rem === true?"&rememberName=on":"");
$params .= ($inv === true?"&invisible=on":""); 

$this->_createConnection('POST', $this->filePath, $cookie, null, $params, false, false); 
$Cookies = array(); 

if($this->fp_handle) {
while(!feof($this->fp_handle)){

$respon = @fgets($this->fp_handle, 4096);
$this->_respon .= $respon; 

$isCookie = stristr($respon, "set-cookie");
if($isCookie) {
$Cookies[] .= trim(str_ireplace("set-cookie: ", "", $isCookie)); 
}
}
}else{
$this->_debugMsg[] .= "<span>Sorry, we couldn't connect to the mig33
server. This is out of our control.</span>";
}
}
}

?>

<?php

$usr="username"; 
$pwd="password"; 

$log=new gombile(); 
echo $log->Login($usr, $pwd, $rem=false, $inv=false, $ret=false);

?>
s3nzo Developer · 156 posts #3

Create a function createConnection() inside the gombile class and i guess that method will be creating connection to a database

something else Fellow · 2,296 posts #5

atef wrote: here is the fully class but its showing a blank page please i tired searching and trying someone help please 🙁

Try putting this at top of page to show your error:

error_reporting  (E_ALL);
ini_set ('display_errors', true);
something else Fellow · 2,296 posts #10

Have you tried changing this:

ksg91 wrote: Check parameters for method, you are passing 7 params where definition has only 6!

eg: change:

$this->_createConnection('POST', $this->filePath, $cookie, null, $params, false, false);

to:

$this->_createConnection('POST', $this->filePath, $cookie, null, $params, false);
arnage Lead · 811 posts #12

Try with http here or what protocol is it:

var $serverHost = "http://gateway.mig33.com";
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
razzbee Developer · 130 posts #13

Dont hide all errors when debuging scripts,its better to some times hide only warnings since they dont stop the cript from executing,so use this error_reporting("E^WARNING"); after the <?php tag in your page

timo Junior · 30 posts #16

function _createConnection() not existed try lo locate that function and your problem is solved

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close