Level 1
Sorry for the messy file. Source
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
How do I make Codeigniter to Laravel?
//verify file
if($this->input->post('verify_file')) {
$uri = $this->db->get_where("listings", array("listingID" => $listingID, 'list_uID' => $userID));
if($uri->num_rows()) {
$uri = $uri->row();
//try reading the file
$file = 'http://' . $uri->listing_url . '/verify_' . $listingID . '.txt';
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
if ($contents) {
if($contents != md5('verify-' . $listingID)) {
echo div_class("Error : File doesn't contain the validation code");
exit;
}else{
$_POST['verified'] = 'Y';
unset($_POST['verify_file']);
}
}// if contenst
} // if num rows
}// if verify file
// verify by meta tags
if( $this->input->post( 'verify_meta' ) ) {
$uri = $this->db->get_where("listings",
array("listingID" => $listingID, 'list_uID' => $userID));
if($uri->num_rows()) {
$uri = $uri->row();
//try reading the file
$file = 'http://' . $uri->listing_url;
$tags = get_meta_tags( $file );
if( count( $tags ) ) {
if( isset( $tags[ 'marketplace-site-verification' ] ) ) {
$_POST['verified'] = 'Y';
}else{
die(div_class("Error: We couldn't find meta tag 'marketplace-site-verification'"));
}
}else{
die( div_class("No meta tags detected.") );
}
}
unset( $_POST[ 'verify_meta' ] );
unset( $_POST[ 'sbMeta' ] );
}
// verify by DNS TXT Record
if( $this->input->post( 'verify_dns' ) ) {
$uri = $this->db->get_where("listings",
array("listingID" => $listingID, 'list_uID' => $userID));
if($uri->num_rows()) {
$uri = $uri->row();
//try reading the file
$file = 'http://' . $uri->listing_url;
$dns = dns_get_record( $uri->listing_url, DNS_TXT );
if( count( $dns ) ) {
$found = false;
$entries = '';
foreach( $dns as $entry ) {
if( $entry[ 'type' ] == 'txt' AND $entry[ 'txt' ] == 'marketplace-site-verification-' . $listingID ) {
$_POST['verified'] = 'Y';
$found = true;
}
$entries .= 'TXT: ' . $entry[ 'txt' ] . '<br/>';
}
if( !$found ) {
echo div_class("Error: We couldn't TXT entry 'marketplace-site-verification'");
echo div_class('Following entries were found<br/>' . $entries, 'alert alert-info');
exit;
}
}else{
die( div_class("No TXT DNS tags detected. Try again later as it may take up to 24 hours for DNS entries to propagate depending on your provider.") );
}
}
unset( $_POST[ 'verify_dns' ] );
unset( $_POST[ 'sbDNS' ] );
}
/*
* Verify file generate
*/
public function verify_file() {
ob_start();
if(!$this->loggedIn)
{
redirect('/users/login');
exit;
}
$id = $this->uri->segment(3);
$id = abs(intval($id));
if(!$id) die("Invalid Listing ID");
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="verify_'.$id.'.txt"');
echo md5('verify-' . $id);
ob_end_flush();
}
Model
class ValidateURL extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
public function isValidURL($url) {
if($url == NULL OR empty($url)) return false;
$ch = curl_init($url);
if (false === $ch)
{
return false;
}
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
$data = curl_exec($ch);
curl_close($ch);
if($data) return true;
if(!$data) return false;
}
public function websiteListed($url) {
$url = $this->dbURLify($url);
$rs = $this->db->get_where("listings", array("listing_url" => $url));
return count($rs->result());
}
public function dbURLify($url) {
return str_replace(array("http://", "https://", "www."), array("","",""), $url);
}
}
Please or to participate in this conversation.