system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
cmd: 

Direktori : /home/pfhr/public_html/admin/classes/Model/
Upload File :
Current File : /home/pfhr/public_html/admin/classes/Model/MSiteSettings.php

<?php

?>

<?PHP
class Model_MSiteSettings
{

	function showSiteSettings($Err)
	{
		$output=array();	
		$query = new Bin_Query();
		$sql_site = "SELECT * FROM sitesettings_table";
		if($query->executeQuery($sql_site))
		{
			
			for($i=0;$i<$query->totrows;$i++)
			{
				$fields[strtolower(str_replace(' ','_',$query->records[$i]['sitesettings_name']))] =  $query->records[$i]['sitesettings_value'];
			}		
			if(count($Err->messages) > 0)
			{
				$fields = $Err->values;
			}
				
		}
			
		return $fields;
	}
	
	function updateSiteSettings()
	{
		$query = new Bin_Query();
		$uploaded_path = '../uploadimages';
		$saved_path = 'uploadimages';
		if($_FILES['header']['size'] > 0)
		{
			$headerimage = $uploaded_path."/".$_FILES['Site_Logo']['name'];
			$savedpath = $saved_path."/".$_FILES['Site_Logo']['name'];
			move_uploaded_file($_FILES['Site_Logo']['tmp_name'],$headerimage);
		}
		else 
			 $headerimage = trim($_POST['header_image']);
			 
		     $getFields = new Bin_Query();	
		     $sql_query = "SELECT `sitesettings_value` FROM sitesettings_table WHERE sitesettings_id='3'";		
			 $getFields->executeQuery($sql_query);
			 $sitelogo = $getFields->records[0]['sitesettings_value'];
			 
			 $img1=$_FILES['site_logo']['name'];
			 
			 if(!empty($img1))
			 {
			   	
				srand();
				$rad1=substr(md5(rand(0,1000)),0,5); 
				$img1=urlencode($img1);
				$date_con=date("Y-m-d"); 
				$img_name1="$date_con"."_"."$rad1"."_"."$img1";
				$uploaddir="../uploadimages/$img_name1";
				echo $uploaddirdb="uploadimages/$img_name1";
				move_uploaded_file($_FILES['site_logo']['tmp_name'],$uploaddir);
				chmod ("$uploaddir",0755); 
			 }
			 else
			 {
			     $uploaddirdb=$sitelogo;
			 }
			 $i=1;
			 
			
		
					foreach($_POST as $key=>$item)
					{	
					
					   if($i<=12)	 
					   {
					     if($i==3 )
						 {
						 
						 $i=$i+1;
						 }
						
						    $sql = "UPDATE `sitesettings_table` SET `sitesettings_value`='".$item."' WHERE `sitesettings_id`='".$i."'";
						
							$query->updateQuery($sql); 
						
						  	$i++;
						 
						 if($i==13)
						 {
						    $sqls = "UPDATE `sitesettings_table` SET `sitesettings_value`='". $uploaddirdb."' WHERE `sitesettings_id`='3'";
			                 $query->updateQuery($sqls);
							 
							 $suc=1;
							 
						}	 
					
					}
					}
				
	
			if($suc == 1)
			{
				$_SESSION['message'] = 'Site Settings has been Updated Successfully';		
			}
			else
			{
				$_SESSION['message'] = 'Site Settings is not Updated';				
			}
		return true;
	}
	
}