<?php
include_once 'includes.php';
//include_once 'oauth_redirection.php';
include_once '../includes/getExtension.php';

$valid_formats = array("jpg", "png", "gif", "bmp","jpeg","PNG","JPG","JPEG","GIF","BMP");
if(isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST") {
	$name = $_FILES['scriptLogo']['name'];
	$size = $_FILES['scriptLogo']['size'];
	$actual_image_name='';
	$ext = getExtension($name);
	if(in_array($ext,$valid_formats)) {
	if($size<(1024*3072)) {
	   $actual_image_name = 'logo_'.time().".".$ext;
	   $tmp = $_FILES['scriptLogo']['tmp_name'];
	   if(move_uploaded_file($tmp, $admin_path.$actual_image_name)) {
	      $settings=$MatAdmin->ScriptLogoChange($actual_image_name);
	      if($settings) {
			 echo 'Logo was changed Successfully!';
		   }
           } else {
	         $msg="<span class='error'>Failed.</span>";
		   }
		   } else {
			 $msg="<span class='error'>Image file size max 300 KB</span>";
		   }
	       } else {
		     $msg="<span class='error'>Invalid file format.</span>";
		  }
		  }		
?>