/** * Function uploads a JS file into the specified folder * * * @return void */ function uploadJsFile() { if (isset($_FILES['js_file']['tmp_name'])) { $spath = $_FILES['js_file']['tmp_name']; $dpath = ROOT_FOLDER . 'userpage/script/' . $_FILES['js_file']['name']; $file = new Lib_FileOperations(); $file->uploadFile($spath, $dpath); } }
/** * Function updates the changes in the site logo into the database * * * @return string */ function updateSiteLogo() { $imagetypes = array('image/jpeg', 'image/pjpeg', 'image/bmp', 'image/gif', 'image/png', 'image/x-png'); $filetypename = $_FILES['logo']['type']; $file = explode("/", $_FILES['logo']['type']); if (count($file) > 2 || !in_array($_FILES['logo']['type'], $imagetypes)) { return '<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> Invalid image file format</div>'; } include 'classes/Lib/FileOperations.php'; include "classes/Lib/ThumbImage.php"; if ($_FILES['logo']['name'] != '') { $sfile = $_FILES['logo']['tmp_name']; $dbpath = "images/logo/" . date("Y-m-d-His") . $_FILES['logo']['name']; $file = new Lib_FileOperations(); $file->uploadFile($sfile, ROOT_FOLDER . $dbpath); list($img_w, $img_h, $type, $attr) = getimagesize($sfile); if ($img_h > 70) { return '<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button>The Height of the logo should be lessthan or equal to 70px to suit properly.</div>'; } if ($img_w > 253) { new Lib_ThumbImage('thumb', ROOT_FOLDER . $dbpath, ROOT_FOLDER . "images/logo", 253); } $sql = "UPDATE admin_settings_table SET set_value='" . $dbpath . "' where set_name='Site Logo'"; $query = new Bin_Query(); if ($query->updateQuery($sql)) { return '<div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> Logo updated Successfully</div>'; } else { return '<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> Error while updating logo!</div>'; } } else { return '<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> Invalid image file.Please try again !</div>'; } }
/** * Function gets a zip file and checks whether it is a zip compression archive or not * * * @return string */ private function uploadZipFile() { if ($_POST['skinname'] == '') { return '<div class="alert alert-error"> <button data-dismiss="alert" class="close" type="button">×</button> Please Enter The Skin Name</div>'; } else { $tsvfilename = $_FILES['zip_file']['name']; $legal_extentions = array("zip"); $file = explode(".", $_FILES['zip_file']['name']); if (count($file) > 2 || $file[1] != 'zip') { return '<div class="alert alert-error"> <button data-dismiss="alert" class="close" type="button">×</button> The file you are attempting to upload is not supported by this server</div>'; } $file_ext = strtolower(end(explode(".", $_FILES['zip_file']['name']))); if (!in_array($file_ext, $legal_extentions)) { return '<div class="alert alert-error"> <button data-dismiss="alert" class="close" type="button">×</button> The file you are attempting to upload is not supported by this server</div>'; } if (isset($_FILES['zip_file']['tmp_name'])) { $spath = $_FILES['zip_file']['tmp_name']; if ($_POST['skinname'] != '') { if ($_FILES['zip_file']['type'] == 'application/zip' || $_FILES['zip_file']['type'] == 'application/x-zip-compressed') { $dpath = ROOT_FOLDER . "assets/css/" . $_POST['skinname'] . ".zip"; $file = new Lib_FileOperations(); $file->uploadFile($spath, $dpath); return $this->extractZip($dpath); } else { return '<div class="alert alert-error"> <button data-dismiss="alert" class="close" type="button">×</button> Please Upload Zip File</div>'; } } } } }