Example #1
0
 }
 if ($Settings->get('upload_maxkb') && $file->getSize() > $Settings->get('upload_maxkb') * 1024) {
     $message['text'] = '<span class="result_error">' . sprintf(T_('The file is too large: %s but the maximum allowed is %s.'), bytesreadable($file->getSize()), bytesreadable($Settings->get('upload_maxkb') * 1024)) . '</span>';
     out_echo($message, $specialchars);
     exit;
 }
 $newName = $file->getName();
 $oldName = $newName;
 // validate file name
 if ($error_filename = process_filename($newName)) {
     // Not a file name or not an allowed extension
     $message['text'] = '<span class="result_error"> ' . $error_filename . '</span>';
     out_echo($message, $specialchars);
     exit;
 }
 list($newFile, $oldFile_thumb) = check_file_exists($fm_FileRoot, $path, $newName);
 $newName = $newFile->get('name');
 // If everything is ok, save the file somewhere
 if (save_to_file($file->get_content(), $newFile->get_full_path(), 'wb')) {
     // Change to default chmod settings
     $newFile->chmod(NULL);
     // Refreshes file properties (type, size, perms...)
     $newFile->load_properties();
     // save file into the db
     $newFile->dbsave();
     // Prepare the uploaded file to the final format ( E.g. Resize and Rotate images )
     prepare_uploaded_files(array($newFile));
     $message = '';
     if (!empty($oldFile_thumb)) {
         $image_info = getimagesize($newFile->get_full_path());
         if ($image_info) {
Example #2
0
    }
    return False;
}
if (isset($_FILES) && !empty($_FILES) && $_FILES['cws_file']['size'] > 0) {
    // echo "<script>alert('File uploaded')</script>";
    $file_number = 1;
    $upload_dir = "cws/";
    $file_extension = strtolower(pathinfo($_FILES['cws_file']['name'], PATHINFO_EXTENSION));
    if ($file_extension == "cws") {
        // echo "<script>alert('cws')</script>";
        $filename = basename("cws/" . $_FILES['cws_file']['name'], "." . $file_extension);
        $printer_xml = simplexml_load_file("printer.xml");
        $cws_id = (int) $printer_xml->print_no + 1;
        $printer_xml->print_no = $cws_id;
        $printer_xml->asXML("printer.xml");
        while (check_file_exists(basename("cws/" . $filename, "." . $file_extension))) {
            $filename = basename($_FILES['cws_file']['name'], "." . $file_extension) . "_" . $file_number . "." . $file_extension;
            $file_number = $file_number + 1;
        }
        if (move_uploaded_file($_FILES['cws_file']['tmp_name'], $upload_dir . $cws_id . ".cws")) {
            echo "<script>alert('File uploaded successfully');\n      \$('#processing').hide();\n      </script>";
            $uploaded = 1;
            // echo "sudo chown pi:pi ".$file_upload_path;
            exec("mkdir cws/" . $cws_id);
            exec("sudo chmod -R 777 /var/www/html/cws/*");
            // system("mv $file_upload_path cws/".$filename);
            exec("sudo 7z e cws/" . $cws_id . ".cws -ocws/" . $cws_id . "/");
            $manifest_xml = simplexml_load_file("cws/" . $cws_id . "/manifest.xml");
            $slices_xml_element = $manifest_xml->Slices->children();
            $slices = count($slices_xml_element);
            $original_name = pathinfo($manifest_xml->GCode->name, PATHINFO_FILENAME);
Example #3
0
function get_css($entry)
{
    $include = check_file_exists(explode('+', $entry));
    return !empty($include) ? $include : default_css();
}
Example #4
0
			</label>
			
		
        </span>
	  </li>
	  
	  
	   <li> <span>
        <label class="field_width"><span class="required">&nbsp;</span>or Upload Image</label>
        </span> <span>
        <input type="file" name="page_featured_image" id="page_featured_image"  class="element file" onChange="uncheck_radio_button();"/>
       <!-- <input type="hidden" name="page_featured_image" id="page_featured_image" value="" />-->
        </span>
		
		 <?php 
if (check_file_exists($image_path . 'large/' . $featured_image) && $featured_flag == 1) {
    ?>
        <span id="response_image">
			<a href="<?php 
    echo base_url() . "media/images/page_management/large/" . $featured_image;
    ?>
" title="Image" rel="lightbox"><img src="<?php 
    echo base_url();
    ?>
images/backend/camera.jpg" border="0" title="View image" alt="View image" width="18" height="18" /></a>&nbsp;&nbsp;<a href="javascript:void(0);" title="Delete image" onclick="javascript:ajaxCallPassData('<?php 
    echo site_url($this->parent_controller);
    ?>
/ajax_call/delete_image','response_image','id=<?php 
    echo $id;
    ?>
&amp;image=<?php 
Example #5
0
/**
 * Copy file from source path to destination path (Used on import)
 *
 * @param string Path of source file
 * @param string FileRoot id string
 * @param string the upload dir relative path in the FileRoot
 * @param boolean Shall we check files add permission for current_User?
 * @return mixed NULL if import was impossible to complete for some reason (wrong fileroot ID, insufficient user permission, etc.)
 *               file ID of new inserted file in DB
 */
function copy_file($file_path, $root_ID, $path, $check_perms = true)
{
    global $current_User;
    $FileRootCache =& get_FileRootCache();
    $fm_FileRoot =& $FileRootCache->get_by_ID($root_ID, true);
    if (!$fm_FileRoot) {
        // fileRoot not found:
        return NULL;
    }
    if ($check_perms && (!isset($current_User) || $current_User->check_perm('files', 'add', false, $fm_FileRoot))) {
        // Permission check required but current User has no permission to upload:
        return NULL;
    }
    // Let's get into requested list dir...
    $non_canonical_list_path = $fm_FileRoot->ads_path . $path;
    // Dereference any /../ just to make sure, and CHECK if directory exists:
    $ads_list_path = get_canonical_path($non_canonical_list_path);
    // check if the upload dir exists
    if (!is_dir($ads_list_path)) {
        // Create path
        mkdir_r($ads_list_path);
    }
    // Get file name from full path:
    $newName = basename($file_path);
    // validate file name
    if ($error_filename = process_filename($newName, true)) {
        // Not a valid file name or not an allowed extension:
        // Abort import for this file:
        return NULL;
    }
    // Check if the imported file type is an image, and if is an image then try to fix the file extension based on mime type
    // If the mime type is a known mime type and user has right to import files with this kind of file type,
    // this part of code will check if the file extension is the same as admin defined for this file type, and will fix it if it isn't the same
    // Note: it will also change the jpeg extensions to jpg.
    // this image_info variable will be used again to get file thumb
    $image_info = getimagesize($file_path);
    if ($image_info) {
        // This is an image, validate mimetype vs. extension:
        $image_mimetype = $image_info['mime'];
        $FiletypeCache =& get_FiletypeCache();
        // Get correct file type based on mime type
        $correct_Filetype = $FiletypeCache->get_by_mimetype($image_mimetype, false, false);
        // Check if file type is known by us, and if it is allowed for upload.
        // If we don't know this file type or if it isn't allowed we don't change the extension! The current extension is allowed for sure.
        if ($correct_Filetype && $correct_Filetype->is_allowed()) {
            // A FileType with the given mime type exists in database and it is an allowed file type for current User
            // The "correct" extension is a plausible one, proceed...
            $correct_extension = array_shift($correct_Filetype->get_extensions());
            $path_info = pathinfo($newName);
            $current_extension = $path_info['extension'];
            // change file extension to the correct extension, but only if the correct extension is not restricted, this is an extra security check!
            if (strtolower($current_extension) != strtolower($correct_extension) && !in_array($correct_extension, $force_upload_forbiddenext)) {
                // change the file extension to the correct extension
                $old_name = $newName;
                $newName = $path_info['filename'] . '.' . $correct_extension;
            }
        }
    }
    // Get File object for requested target location:
    $oldName = strtolower($newName);
    list($newFile, $oldFile_thumb) = check_file_exists($fm_FileRoot, $path, $newName, $image_info);
    $newName = $newFile->get('name');
    if (!copy($file_path, $newFile->get_full_path())) {
        // Abort import for this file:
        return NULL;
    }
    // change to default chmod settings
    $newFile->chmod(NULL);
    // Refreshes file properties (type, size, perms...)
    $newFile->load_properties();
    // Store File object into DB:
    if ($newFile->dbsave()) {
        // Success
        return $newFile->ID;
    } else {
        // Failure
        return NULL;
    }
}
Example #6
0
             return True;
         }
     }
     return False;
 }
 $file_number = 1;
 $upload_dir = "/var/www/html/cws/";
 $file_extension = strtolower(pathinfo($file_source, PATHINFO_EXTENSION));
 if ($file_extension == "cws") {
     $filename = basename($file_source, "." . $file_extension);
     $printer_xml = simplexml_load_file("printer.xml");
     $cws_id = (int) $printer_xml->print_no + 1;
     // Deal with this later
     $printer_xml->print_no = $cws_id;
     $printer_xml->asXML("printer.xml");
     while (check_file_exists(basename($file_source, "." . $file_extension))) {
         $filename = basename($file_source, "." . $file_extension) . "_" . $file_number . "." . $file_extension;
         $file_number = $file_number + 1;
     }
     exec("sudo cp \"" . $file_source . "\" /var/www/html/cws/" . $cws_id . ".cws");
     $uploaded = 1;
     // echo "sudo chown pi:pi ".$file_upload_path;
     exec("mkdir cws/" . $cws_id);
     // system("mv $file_upload_path cws/".$filename);
     exec("sudo 7z e cws/" . $cws_id . ".cws -ocws/" . $cws_id . "/");
     exec("sudo chmod -R 777 /var/www/html/cws/*");
     $manifest_xml = simplexml_load_file("cws/" . $cws_id . "/manifest.xml");
     $slices_xml_element = $manifest_xml->Slices->children();
     $slices = count($slices_xml_element);
     $original_name = pathinfo($manifest_xml->GCode->name, PATHINFO_FILENAME);
     // echo "<script>alert('name:".$original_name."')</script>";
Example #7
0
            <?php 
    }
}
?>

        </tr>
        <tr>
            <th align="centre" class="nt">Featured Image

             <?php 
if (is_array($history) && count($history) > 0) {
    foreach ($history as $historyvalue) {
        ?>
											<td>
												<?php 
        $set_large_image = check_file_exists(ROOTBASEPATH . 'media/images/page_management/large/' . $historyvalue['featured_image_name']) ? 1 : 0;
        if ($set_large_image == 1) {
            ?>
																	<a href="<?php 
            echo base_url() . "media/images/page_management/large/" . $historyvalue['featured_image_name'];
            ?>
" title="DPCS image<?php 
            echo $historyvalue['featured_image_name'];
            ?>
" class="imginfo" rel="lightbox">
															<?php 
        }
        if ($set_large_image == 1) {
            ?>
															<img src="<?php 
            echo base_url();
Example #8
0
						<?php 
            echo $product_name;
            ?>
			</a>
		</div>
		<div class="wraptocenter"><span>&nbsp;</span>
				<a href="<?php 
            if (grant_access('easfv935')) {
                echo $sef_url;
            } else {
                echo "javascript:access_denied();";
            }
            ?>
">
			<?php 
            if (check_file_exists($image_path . 'medium/' . $product[$i]['image1'])) {
                ?>
					<img src="<?php 
                echo base_url();
                ?>
media/images/product/medium/<?php 
                echo $product[$i]['image1'];
                ?>
" alt="<?php 
                echo ucfirst($product[$i]["product_name"]);
                ?>
" title="<?php 
                echo ucfirst($product[$i]["product_name"]);
                ?>
" class="mar_auto" />
			<?php