Jump to content

My script isnt working correctly?


jamesxg1

Recommended Posts

Hiya peeps!

 

I have built this.

 

<?php

class extract {

	private $link;
	private $rec;

	public function __construct() {

	}

	public function __init($link, $rec = 0) {

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$link);
		curl_setopt($ch, CURLOPT_TIMEOUT, 50);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$this->_data = curl_exec($ch);
		curl_close($ch);

		$this->_emails = array();

		if($rec == 1) {
			if(preg_match_all('/((?:http|https):\/\/(?:www\.)*(?:[a-zA-Z0-9_\-]{1,15}\.+[a-zA-Z0-9_]{1,}){1,}(?:[a-zA-Z0-9_\/\.\-\?\&\:\%\,\!\;]*))/', $this->_data, $urls)) {
				foreach($urls[0] as $k => $v) {
					$this->__init($v, 1);
				}
			}
		}

		return $this->emails();
	}

	public function emails() {
		if(preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $this->_data, $emails, PREG_SET_ORDER)) {
			foreach($emails as $dk => $dv) {
				foreach($dv as $fk => $fv) {
					if(preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $fv)) {
						$this->_emails[] = $fv;
					}
				}
			}
		}
		return $this->_emails;
	}

	public function multi_unique($array) {
		foreach ($array as $k => $na) {
			$new[$k] = serialize($na);
			$uniq = array_unique($new);
		}
        
		foreach($uniq as $k => $ser) {
			$new1[$k] = unserialize($ser);
		}

		return $new1;
	}
}
$go = new extract();
$done = $go->__init($_POST['site'], $_POST['deep']);
print_r($done);
?>
<center><form action="#" method="post">
Site:<br /><input type="text" name="site"><br /><br />
Go-Deep:<br /><select name="deep"><option value="0" selected>No</option><option value="1">Yes</option></select><br /><br />
<input type="submit" name="submit">
</form></center>

 

It works, but only on one URL, I have setup a html page containing an email address and a link to another page containing an email address, so technically it should return two email addresses. But it doesn't, it only displayed the email address on the url that is inputted.

 

Does anyone have any idea why?

 

Many thanks,

 

James.

Link to comment
Share on other sites

So far this is as far as I've got, but I'm not getting any return now.

 

<?php

class extract {

	private $link;
	private $rec;

	public function __construct() {

	}

	public function __init($link, $rec = 0) {

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $link);
		curl_setopt($ch, CURLOPT_TIMEOUT, 50);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$this->_data = curl_exec($ch);
		curl_close($ch);

		if(!isset($this->_emails)) {
			$this->_emails = array();
		}
		$this->emails();

		if($rec == 1) {
			if(!isset($pageCount)) {
				$pageCount = 0;
			}
			if(preg_match_all('/((?:http|https):\/\/(?:www\.)*(?:[a-zA-Z0-9_\-]{1,15}\.+[a-zA-Z0-9_]{1,}){1,}(?:[a-zA-Z0-9_\/\.\-\?\&\:\%\,\!\;]*))/', $this->_data, $urls)) {
				$theCount = count($urls, COUNT_RECURSIVE);
				foreach($urls[0] as $k => $v) {
					if($theCount == $pageCount) {
						return $this->_emails;
					} else {
						$this->__init($v, 1);
					}
				}
			}
		} else {
			return $this->_emails;
		}
	}

	public function emails() {
		if(preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $this->_data, $emails, PREG_SET_ORDER)) {
			foreach($emails as $dk => $dv) {
				foreach($dv as $fk => $fv) {
					if(preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $fv)) {
						$this->_emails[] = $fv;
					}
				}
			}
		}
		return $this->_emails;
	}

	public function multi_unique($array) {
		foreach ($array as $k => $na) {
			$new[$k] = serialize($na);
			$uniq = array_unique($new);
		}
        
		foreach($uniq as $k => $ser) {
			$new1[$k] = unserialize($ser);
		}

		return $new1;
	}
}
$go = new extract();
$done = $go->__init($_POST['site'], $_POST['deep']);
print_r($done);
?>
<center><form action="#" method="post">
Site:<br /><input type="text" name="site"><br /><br />
Go-Deep:<br /><select name="deep"><option value="0" selected>No</option><option value="1">Yes</option></select><br /><br />
<input type="submit" name="submit">
</form></center>

 

Many thanks,

 

James.

Link to comment
Share on other sites

So far this is as far as I've got, but I'm not getting any return now.

 

<?php

class extract {

	private $link;
	private $rec;

	public function __construct() {

	}

	public function __init($link, $rec = 0) {

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $link);
		curl_setopt($ch, CURLOPT_TIMEOUT, 50);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$this->_data = curl_exec($ch);
		curl_close($ch);

		if(!isset($this->_emails)) {
			$this->_emails = array();
		}
		$this->emails();

		if($rec == 1) {
			if(!isset($pageCount)) {
				$pageCount = 0;
			}
			if(preg_match_all('/((?:http|https):\/\/(?:www\.)*(?:[a-zA-Z0-9_\-]{1,15}\.+[a-zA-Z0-9_]{1,}){1,}(?:[a-zA-Z0-9_\/\.\-\?\&\:\%\,\!\;]*))/', $this->_data, $urls)) {
				$theCount = count($urls, COUNT_RECURSIVE);
				foreach($urls[0] as $k => $v) {
                                                $pageCount++;
					if($theCount == $pageCount) {
						return $this->_emails;
					} else {
						$this->__init($v, 1);
					}
				}
			}
		} else {
			return $this->_emails;
		}
	}

	public function emails() {
		if(preg_match_all('/(\w+\.)*\w+@(\w+\.)*\w+(\w+\-\w+)*\.\w+/', $this->_data, $emails, PREG_SET_ORDER)) {
			foreach($emails as $dk => $dv) {
				foreach($dv as $fk => $fv) {
					if(preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $fv)) {
						$this->_emails[] = $fv;
					}
				}
			}
		}
		return $this->_emails;
	}

	public function multi_unique($array) {
		foreach ($array as $k => $na) {
			$new[$k] = serialize($na);
			$uniq = array_unique($new);
		}
        
		foreach($uniq as $k => $ser) {
			$new1[$k] = unserialize($ser);
		}

		return $new1;
	}
}
$go = new extract();
$done = $go->__init($_POST['site'], $_POST['deep']);
print_r($done);
?>
<center><form action="#" method="post">
Site:<br /><input type="text" name="site"><br /><br />
Go-Deep:<br /><select name="deep"><option value="0" selected>No</option><option value="1">Yes</option></select><br /><br />
<input type="submit" name="submit">
</form></center>

 

Many thanks,

 

James.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.