Codeigniter URL rewrite in Web.config in sub directory on Windows IIS server

Web.config in Main Root Folder as you want.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
	  		<clear />
			<rule name="MainFolder" patternSyntax="Wildcard">
				<match url="*"/>
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
					</conditions>
				<action type="Rewrite" url="index.php"/>
			</rule>
		</rules>
    </rewrite>
  </system.webServer>
</configuration>



Web.config in Sub Folder as you want.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
	  		<clear />
			<rule name="SubFolder" stopProcessing="true">
				<match url=".*" />
					<conditions>
						<add input="{HTTP_HOST}" pattern="^(www.)?youranotherdomain.com" />
						<add input="{PATH_INFO}" pattern="^/" negate="true" />
					</conditions>
				<action type="Rewrite" url="\your\sub\domain\directory\path\{R:0}" />
			</rule>

			<rule name="SubFolder" patternSyntax="Wildcard">
				<match url="*"/>
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
					</conditions>
				<action type="Rewrite" url="index.php"/>
			</rule></rules>
    </rewrite>
  </system.webServer>
</configuration>

			

codeigniter active record join function

function get_all_records($table,$where,$join_table,$join_criteria,$order,$order_by=’desc’,$limit=null,$start=null){
$this->db->where($where);
if($join_table){
$this->db->join($join_table,$join_criteria);
}

if(isset($limit) && isset($start)){
$this->db->limit($limit,$start);
}else if(isset($limit)){
$this->db->limit($limit);
}

$query = $this->db->order_by($order,$order_by)->get($table);
if ($query->num_rows() > 0){
return $query->result();
} else{
return NULL;
}
}

get mac address in php

function get_mac_address(){

ob_start(); // Turn on output buffering

system(‘ipconfig /all’); //Execute external program to display output

$mycom=ob_get_contents(); // Capture the output into a variable

ob_clean(); // Clean (erase) the output buffer

//echo $mycom;

$findme = “Physical”;

$pmac = strpos($mycom, $findme); // Find the position of Physical text

$mac=substr($mycom,($pmac+36),17); // Get Physical Address
return trim($mac);
}

generate otp in php

function generateOTP($length = 6, $chars = ‘1234567890’){
$chars_length = (strlen($chars) – 1);
$string = $chars{rand(0, $chars_length)};
for ($i = 1; $i < $length; $i = strlen($string))
{
$r = $chars{rand(0, $chars_length)};
if ($r != $string{$i – 1}) $string .= $r;
}
return $string;
}

SEO Friendly URLs with PHP

function convert_seo_title($title){
$title = mysql_real_escape_string(trim($title)); /* clean string */
$title = preg_replace(‘/[^A-Za-z0-9]/’, ‘ ‘, $title); /* remove special characters */
$title = preg_replace(‘!\s+!’, ‘ ‘, $title); /* multiple space to single dash */
$title = str_replace(” “,”-“,$title);
$title = strtolower($title); /* convert all lowercash */
return $title;
}
function revert_seo_title($title){
$title = str_replace(“-“,” “,$title);
$title = ucwords($title);
return $title;
}

codeignitor send mail function for windows server

function send_mail($from,$to,$subject,$content,$cc=null,$reply_to=null,$attechments=null){
$this->load->library(’email’);
$config[‘protocol’] = “smtp”;
$config[‘smtp_host’] = SMTP_SERVER;
$config[‘smtp_port’] = SMTP_PORT;
$config[‘smtp_user’] = SMTP_USER;
$config[‘smtp_pass’] = SMTP_PASS;
$config[‘charset’] = “utf-8”;
$config[‘mailtype’] = “html”;
$config[‘newline’] = “\r\n”;

$this->email->initialize($config);
$this->email->from($from,SMTP_FROM_NAME);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($content);

if($attechments){
$this->email->attach($attechments);
}

if($reply_to){
$this->email->reply_to($reply_to);
}

if($cc){
$this->email->cc($cc);
}

$mail_send = $this->email->send();
//echo $this->email->print_debugger();

if($mail_send){
return 1;
}else{
return 0;
}
}

codeigniter windows server sendmail function

function send_mail($from,$to,$subject,$content,$cc=null,$reply_to=null,$attechments=null){
$this->load->library(’email’);
$config[‘protocol’] = “smtp”;
$config[‘smtp_host’] = SMTP_SERVER;
$config[‘smtp_port’] = SMTP_PORT;
$config[‘smtp_user’] = SMTP_USER;
$config[‘smtp_pass’] = SMTP_PASS;
$config[‘charset’] = “utf-8”;
$config[‘mailtype’] = “html”;
$config[‘newline’] = “\r\n”;

$this->email->initialize($config);
$this->email->from($from,SMTP_FROM_NAME);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($content);

if($attechments){
$this->email->attach($attechments);
}

if($reply_to){
$this->email->reply_to($reply_to);
}

if($cc){
$this->email->cc($cc);
}

$mail_send = $this->email->send();
//echo $this->email->print_debugger();

if($mail_send){
return 1;
}else{
return 0;
}
}