Last active
December 7, 2017 17:39
-
-
Save gbutiri/b073e5224bb80c7b6d1ea6a45a3f0ba3 to your computer and use it in GitHub Desktop.
CodeIgniter - Tokenizer Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Tokenizer { | |
public $dataIn = ""; | |
public $response_header = ""; | |
function __construct($linkIn = '', $link = true) { | |
if ($link) { | |
$arrContextOptions=array( | |
"ssl"=>array( | |
"verify_peer"=>false, | |
"verify_peer_name"=>false, | |
), | |
); | |
$this->dataIn = @file_get_contents($linkIn, false, stream_context_create($arrContextOptions)); | |
if (isset($http_response_header)) { | |
$this->response_header = $http_response_header; | |
} else { | |
$this->response_header = '?'; | |
} | |
} else { | |
$this->dataIn = $linkIn; | |
} | |
} | |
public function eraseTo($target) { | |
$token_pos = strpos($this->dataIn,$target); | |
$token_found = false; | |
if ($token_pos === false) { | |
$token_found = false; | |
$this->dataIn = substr_replace($this->dataIn, "", 0, strlen($this->dataIn)); | |
} else { | |
$token_found = true; | |
$this->dataIn = substr_replace($this->dataIn, "", 0, $token_pos+strlen($target)); | |
} | |
return $token_found; | |
} | |
public function getTo($target) { | |
$token_pos = strpos($this->dataIn,$target); | |
if ($token_pos === false) { | |
return substr($this->dataIn, 0, strlen($this->dataIn)); | |
} else { | |
return substr($this->dataIn, 0, $token_pos); | |
} | |
} | |
public function getToEnd() { | |
return substr($this->dataIn, 0, strlen($this->dataIn)); | |
} | |
public function find($target) { | |
$token_pos = strpos($this->dataIn,$target); | |
return $token_pos; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment