| Server IP : 144.76.79.100 / Your IP : 216.73.216.103 [ Web Server : Apache System : Linux ch05.wehostwebserver.com 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64 User : razzlestore ( 1092) PHP Version : 8.2.29 Disable Function : NONE Domains : 343 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/public_html/application/helpers/ |
Upload File : |
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if(!function_exists('single_image_upload')){
function single_image_upload($image,$path,$type=""){
$_FILES['image']['name']= $image['name'];
$_FILES['image']['type']= $image['type'];
$_FILES['image']['tmp_name']= $image['tmp_name'];
$_FILES['image']['error']= $image['error'];
$_FILES['image']['size']= $image['size'];
if(!file_exists($path)){
mkdir($path, 0777, true);
}
$ci =& get_instance();
$config['upload_path'] = ''.$path.'';
if(!empty($type)){
$config['allowed_types'] = $type;
}
else{
$config['allowed_types'] = 'gif|jpg|png';
}
$ci->load->library('upload', $config);
$ci->upload->initialize($config);
if(!$ci->upload->do_upload('image')){
return array('error' => $ci->upload->display_errors());
}else{
$file_detail = $ci->upload->data();
return $file_detail['file_name'];
}
return FALSE;
}
}
if(!function_exists('multi_image_upload')){
function multi_image_upload($image,$index,$path,$type=""){
$_FILES['image']['name']= $image['name'][$index];
$_FILES['image']['type']= $image['type'][$index];
$_FILES['image']['tmp_name']= $image['tmp_name'][$index];
$_FILES['image']['error']= $image['error'][$index];
$_FILES['image']['size']= $image['size'][$index];
if(!file_exists($path)){
mkdir($path, 0777, true);
}
$ci =& get_instance();
$config['upload_path'] = ''.$path.'';
if(!empty($type)){
$config['allowed_types'] = $type;
}
else{
$config['allowed_types'] = 'gif|jpg|png';
}
$config['max_width'] = '400000';
$config['max_height'] = '400000';
$ci->load->library('upload', $config);
$ci->upload->initialize($config);
if(!$ci->upload->do_upload('image')){
return array('error' => $ci->upload->display_errors());
}else{
$file_detail = $ci->upload->data();
return $file_detail['file_name'];
}
return FALSE;
}
}
if(!function_exists('sitemap_generate')){
function sitemap_generate(){
$ci =& get_instance();
$lastmod = date("Y-m-d\Th:m:s+00:00");
$sitemap = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
$sitemap .= "<url>\n\t<loc>".base_url()."</loc>\n\t<lastmod>".$lastmod."</lastmod>\n\t<changefreq>daily</changefreq>\n\t<priority>1.0000</priority>\n</url>";
$sitemap .= "\n<url>\n\t<loc>".base_url('categories')."</loc>\n\t<lastmod>".$lastmod."</lastmod>\n\t<changefreq>daily</changefreq>\n\t<priority>0.8000</priority>\n</url>";
$data['select'] = 'store_slug';
$data['table'] = 'store';
$data['output_type'] = 'result';
$data['order_by'] = 'ASC';
$data['order_by_col'] = 'store_name';
$stores = $ci->general->get($data);
foreach($stores as $store){
$sitemap .= "\n<url>\n\t<loc>".base_url(str_replace('&','&',$store->store_slug))."</loc>\n\t<lastmod>".$lastmod."</lastmod>\n\t<changefreq>daily</changefreq>\n\t<priority>0.8000</priority>\n</url>";
}
$data['select'] = 'category_slug';
$data['table'] = 'category';
$data['output_type'] = 'result';
$data['order_by'] = 'ASC';
$data['order_by_col'] = 'category_name';
$categories = $ci->general->get($data);
foreach($categories as $category){
$sitemap .= "\n<url>\n\t<loc>".base_url('category/'.str_replace('&','&',$category->category_slug))."</loc>\n\t<lastmod>".$lastmod."</lastmod>\n\t<changefreq>daily</changefreq>\n\t<priority>0.8000</priority>\n</url>";
}
$sitemap .= "\n</urlset>";
$file = fopen(ROOT_DIR.'sitemap.xml', 'w');
fwrite($file, $sitemap);
fclose($file);
}
}
if(!function_exists('send_email')){
function send_email($subject,$body){
$ci =& get_instance();
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_port'] = '25';
$config['smtp_user'] = 'sales-leads@oneworldrental.com';
$config['smtp_pass'] = 'QN8xSt6SyA';
$config['mailtype'] = 'html';
$config['starttls'] = true;
$config['newline'] = '\r\n';
$ci->email->initialize($config);
$ci->email->from('sales-leads@oneworldrental.com',$ci->site_title);
$ci->email->to('sales@oneworldrental.com');
if(!empty($send_cc)){
$ci->email->cc($send_cc);
}
$ci->email->subject($subject);
$ci->email->message($body);
if($ci->email->send()){
return TRUE;
}else{
return FALSE;
}
exit;
}
}
if (!function_exists('limit_text'))
{
function limit_text($count,$text)
{
$result = strlen($text)>$count?substr($text, 0, $count).'...':$text;
return $result;
}
}
if (!function_exists('get_files_list'))
{
function get_files_list($directory)
{
if ($handle = opendir($directory)) {
$result = array();
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
array_push($result,$entry);
}
}
closedir($handle);
return $result;
}
}
}
if (!function_exists('get_templates'))
{
function get_templates()
{
$result = array();
$list = get_files_list('application/views/front/template');
foreach($list as $val){
array_push($result,str_replace('.php','',$val));
}
return $result;
}
}
if (!function_exists('get_list'))
{
function get_list($tabel="",$where="",$limit="",$order_col="",$order_by="",$like="",$group_by="")
{
$ci =& get_instance();
$records = $ci->general->get_list($tabel,$where,$limit,$order_col,$order_by,$like,$group_by);
if($records){
return $records;
}else{
return FALSE;
}
}
}
if (!function_exists('array_like'))
{
function array_like($data,$input)
{
$result = array_filter($data, function ($item) use ($input) {
if (stripos($item, $input) !== false) {
return true;
}
return false;
});
$match = $result;
$result = array_diff($data,$match);
return array_merge($match,$result);
}
}
if (!function_exists('get_id_by_slug'))
{
function get_id_by_slug($table,$slug)
{
$ci =& get_instance();
$temp = $ci->general->get_list($table,array(''.$table.'_slug'=>$slug));
if($temp){
foreach($temp as $tp){
$id = $table.'_id';
$result = $tp->$id;
}
return $result;
}else{
return FALSE;
}
}
}
if (!function_exists('form_item'))
{
function form_item($feild_name="", $field_type= "",$required = "",$record="",$options="",$custom_label_text = "")
{
$required_field = ($required == 'required')?'data-validation="required"':'';
$required_text = ($required == 'required')?'<small class="text-danger">( required )</small>':'';
$ci =& get_instance();
$html = '';
$value = '';
$label = '';
$image = '';
$label = str_replace($ci->uri->segment(2), '', $feild_name);
$label = str_replace('_', ' ', $label).' '.$required_text;
if(!empty($custom_label_text)){
$label = $custom_label_text;
}
if(!empty($record)){
$value = $record->$feild_name;
}
if($field_type == 'text'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<input type="text" class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.' value="'.$value.'">
'.form_error($feild_name).'
</div>';
}
if($field_type == 'datepicker'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<input type="datepicker" class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.' value="'.$value.'">
'.form_error($feild_name).'
</div>';
}
if($field_type == 'textarea'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<textarea class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.'>'.$value.'</textarea>
'.form_error($feild_name).'
</div>';
}
else if($field_type == 'textarea_editor'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<textarea class="form-control editor" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.'>'.$value.'</textarea>
'.form_error($feild_name).'
</div>';
}
else if($field_type == 'image'){
$image = !empty($value)?base_url('uploads/').$ci->uri->segment(2).'/'.$value:base_url('assets/admin/img/placeholder.png');
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<div class="input-group-btn">
<div class="image-upload">
<img src="'.$image.'">
<div class="file-btn">
<input type="file" id="'.$feild_name.'" name="'.$feild_name.'">
<input type="text" id="'.$feild_name.'" name="'.$feild_name.'" value="'.$value.'" hidden>
<label class="btn btn-info">Upload</label>
</div>
</div>
</div>
'.form_error($feild_name).'
</div>';
}
else if($field_type == 'option'){
$options_html = '<option value="">Select: '.ucwords($label).'</option>';
foreach ($options as $option_key => $option_value) {
if($value == $option_value){
$options_html .= '<option selected="selected" value="'.$option_value.'">'.$option_key.'</option>';
}
else{
$options_html .= '<option value="'.$option_value.'">'.$option_key.'</option>';
}
}
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<select class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.'>'.$options_html.'</select>
'.form_error($feild_name).'
</div>';
}
return $html;
}
}
if (!function_exists('form_item2'))
{
function form_item2($feild_name="", $field_type= "",$required = "",$record="",$options="")
{
$required_field = ($required == 'required')?'data-validation="required"':'';
$required_text = ($required == 'required')?'<small class="text-danger">( required )</small>':'';
$ci =& get_instance();
$html = '';
$value = '';
$label = '';
$image = '';
$label = str_replace($ci->uri->segment(2), '', $feild_name);
$label = str_replace('_', ' ', $label).' '.$required_text;
if(!empty($record)){
$value = $record->$feild_name;
}
if($field_type == 'text'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<input type="text" class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.' value="'.$value.'">
'.form_error($feild_name).'
</div>';
}
if($field_type == 'textarea'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<textarea class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.'>'.$value.'</textarea>
'.form_error($feild_name).'
</div>';
}
else if($field_type == 'textarea_editor'){
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<textarea class="form-control editor" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.'>'.$value.'</textarea>
'.form_error($feild_name).'
</div>';
}
else if($field_type == 'image'){
$image = !empty($value)?base_url('uploads/').$ci->uri->segment(2).'/'.$value:base_url('assets/admin/img/placeholder.png');
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<div class="input-group-btn">
<div class="image-upload">
<img src="'.$image.'">
<div class="file-btn">
<input type="file" id="'.$feild_name.'" name="'.$feild_name.'">
<input type="text" id="'.$feild_name.'" name="'.$feild_name.'" value="'.$value.'" hidden>
<label class="btn btn-info">Upload</label>
</div>
</div>
</div>
'.form_error($feild_name).'
</div>';
}
else if($field_type == 'option'){
$options_html = '<option value="">Select: '.ucwords($label).'</option>';
foreach ($options as $option_key => $option_value) {
if($value == $option_value){
$options_html .= '<option selected="selected" value="'.$option_value.'">'.$option_key.'</option>';
}
else{
$options_html .= '<option value="'.$option_value.'">'.$option_key.'</option>';
}
}
$html = '
<div class="form-group">
<label>'.ucwords($label).'</label>
<select class="form-control" id="'.$feild_name.'" name="'.$feild_name.'" '.$required_field.'>'.$options_html.'</select>
'.form_error($feild_name).'
</div>';
}
return $html;
}
}