Пример #1
0
function kfm_api_removeFile($id)
{
    $f = kfmFile::getInstance($id);
    $p = $f->parent;
    $f->delete();
    return kfm_loadFiles($p);
}
Пример #2
0
 function delete()
 {
     global $kfm;
     if (!$GLOBALS['kfm_allow_file_delete']) {
         return $this->error(kfm_lang('permissionDeniedDeleteFile'));
     }
     if (!parent::delete()) {
         return false;
     }
     $this->deleteThumbs();
     $kfm->db->exec('DELETE FROM ' . KFM_DB_PREFIX . 'files_images WHERE file_id=' . $this->id);
     return !$this->hasErrors();
 }
Пример #3
0
$associations = db_fetch_all('SELECT extension, plugin FROM ' . KFM_DB_PREFIX . 'plugin_extensions WHERE user_id=1');
$kfm->addAssociations($associations);
// To javascript object
$ass_str = '{';
if (!isset($kfm->associations['all']) && isset($kfm_default_file_selection_handler)) {
    $kfm->associations['all'] = $kfm_default_file_selection_handler;
}
foreach ($kfm->associations as $ext => $plugin) {
    $ass_str .= '"' . $ext . '":"' . $plugin . '",';
}
$ass_str = rtrim($ass_str, ', ') . '}';
// }
// { startup selected files
if (isset($_GET['fid']) && $_GET['fid']) {
    /*{*/
    $f = kfmFile::getInstance($_GET['fid']);
    /*}*/
    if ($f) {
        $_GET['cwd'] = $f->parent;
        $kfm->setting('startup_selected_files', array($_GET['fid']));
    }
}
// }
//TODO:The next section should be reviewed (benjamin: I thing $_GET['startup_folder']) should be used in stead of this. (no directory id supported)
if (isset($_GET['cwd']) && (int) $_GET['cwd']) {
    $path = kfm_getDirectoryParentsArr($_GET['cwd']);
    $path[] = $_GET['cwd'];
    if (count($path) > 1) {
        $startup_sequence_array = $path;
        $kfm_startupfolder_id = $_GET['cwd'];
        $kfm_session->set('cwd_id', $kfm->setting('startupfolder_id'));
Пример #4
0
function kfm_rmMixed($files = array(), $directories = array())
{
    $filecount = 0;
    $dircount = 0;
    foreach ($files as $fid) {
        $file = kfmFile::getInstance($fid);
        if ($file->delete()) {
            $filecount++;
        }
    }
    foreach ($directories as $did) {
        $dir = new kfmDirectory($did);
        if ($dir->delete()) {
            $dircount++;
        }
    }
}
Пример #5
0
<?php

require 'initialise.php';
switch ($_REQUEST['action']) {
    case 'delete_file':
        // {
        $id = (int) $_REQUEST['id'];
        $file = kfmFile::getInstance($id);
        if ($file) {
            $file->delete();
            echo 'ok';
            exit;
        } else {
            die('file does not exist');
        }
        // }
}
Пример #6
0
 function getFiles()
 {
     $filesdb = db_fetch_all("select * from " . KFM_DB_PREFIX . "files where directory=" . $this->id);
     $fileshash = array();
     if (is_array($filesdb)) {
         foreach ($filesdb as $r) {
             $fileshash[$r['name']] = $r['id'];
         }
     }
     // { get files from directoryIterator, then sort them
     $tmp = array();
     foreach (new directoryIterator($this->path()) as $f) {
         if ($f->isDot()) {
             continue;
         }
         if (is_file($this->path() . $f) && kfmFile::checkName($f)) {
             $tmp[] = $f . '';
         }
     }
     natsort($tmp);
     // }
     // { load file details from database
     $files = array();
     foreach ($tmp as $filename) {
         if (!isset($fileshash[$filename])) {
             $fileshash[$filename] = kfmFile::addToDb($filename, $this->id);
         }
         $file = kfmFile::getInstance($fileshash[$filename]);
         if (!$file) {
             continue;
         }
         if ($file->isImage()) {
             $file = kfmImage::getInstance($fileshash[$filename]);
             if ($this->maxWidth > 0 && $this->maxHeight > 0 && ($file->width > $this->maxWidth || $file->height > $this->maxHeight)) {
                 $file->resize($this->maxWidth, $this->maxHeight);
             }
         }
         $files[] = $file;
         unset($fileshash[$filename]);
     }
     // }
     return $files;
 }
Пример #7
0
function _zip($filename, $files)
{
    global $kfm_session;
    $cwd_id = $kfm_session->get('cwd_id');
    $dir = kfmDirectory::getInstance($cwd_id);
    $cwd = $dir->path();
    if (!$kfm->setting('allow_file_create')) {
        return kfm_error(kfm_lang('permissionDeniedCreateFile'));
    }
    global $rootdir;
    if (!kfmFile::checkName($filename)) {
        return kfm_error(kfm_lang('illegalFileName', $filename));
    }
    $arr = array();
    foreach ($files as $f) {
        $file = kfmFile::getInstance($f);
        if (!$file) {
            return kfm_error(kfm_lang('missingFileInSelection'));
        }
        $arr[] = $file->path;
    }
    # try native system zip command
    $res = -1;
    $pdir = $cwd . '/';
    $zipfile = $pdir . $filename;
    for ($i = 0; $i < count($arr); ++$i) {
        $arr[$i] = str_replace($pdir, '', $arr[$i]);
    }
    exec('cd "' . escapeshellcmd($cwd) . '" && zip -D "' . escapeshellcmd($zipfile) . '" "' . join('" "', $arr) . '"', $arr, $res);
    if ($res) {
        return kfm_error(kfm_lang('noNativeZipCommand'));
    }
    return kfm_loadFiles($cwd_id);
}
Пример #8
0
 /**
  * Rename the file
  * @param string $newName new file name
  */
 function rename($newName)
 {
     if (!$GLOBALS['kfm']->setting('allow_file_edit')) {
         return $this->error(kfm_lang('permissionDeniedEditFile'));
     }
     if (!kfmFile::checkName($newName)) {
         return $this->error(kfm_lang('cannotRenameFromTo', $this->name, $newName));
     }
     $newFileAddress = $this->directory . $newName;
     if (file_exists($newFileAddress)) {
         return $this->error(kfm_lang('fileAlreadyExists'));
     }
     rename($this->path, $newFileAddress);
     $this->name = $newName;
     $this->path = $newFileAddress;
     $GLOBALS['kfm']->db->query("UPDATE " . KFM_DB_PREFIX . "files SET name='" . sql_escape($newName) . "' WHERE id=" . $this->id);
 }
Пример #9
0
<?php

require_once '../../initialise.php';
if (!isset($_GET['fid'])) {
    die('no fid given');
}
$f = new kfmFile($_GET['fid']);
?>
<html>
<head>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	plugins : "save,table,contextmenu,paste,layer,style,advlink,searchreplace",
	theme_advanced_buttons1: "save,code,undo,redo,cleanup,pastetext,pasteword,selectall,replace,help",
	theme_advanced_buttons2: "link,unlink,anchor,image,table,charmap,formatselect,fontselect,fontsizeselect,styleselect",
	theme_advanced_buttons3: "bold,italic,underline,strikethrough,bullist,numlist,outdent,indent,justifyleft,justifycenter,justifyright,justifyfull,sub,sup,forecolor,backcolor,removeformat,insertlayer,styleprops",
	theme_advanced_buttons1_add_before : "save,separator",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_path_location : "bottom",
	plugin_insertdate_dateFormat : "%Y-%m-%d",
	plugin_insertdate_timeFormat : "%H:%M:%S",
	extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
	file_browser_callback: 'kfmplugin_tiny_mce_select_file',
	convert_urls:false
});
function save_file(){
	parent.x_kfm_saveTextFile(<?php 
Пример #10
0
			,charmap_default: "arrows"
      ,is_multi_files: true
      ,EA_load_callback: "load_ea_files"
      ,EA_file_close_callback: "close_ea_file"
		});
		function save_document(id, content){
      var f = editAreaLoader.getCurrentFile("editareacontent");
			parent.x_kfm_saveTextFile(f.id, content, function(res){
        editAreaLoader.setFileEditedMode("editareacontent", String(f.id), false);
				//parent.kfm_pluginIframeMessage('document saved');	
			});
		}
    function load_ea_files(element_id){
      <?php 
foreach ($file_ids as $fid) {
    $f = kfmFile::getInstance($fid);
    print "\n        editAreaLoader.openFile('editareacontent', {id:{$fid},text:" . json_encode($f->getContent()) . ",syntax:'" . getSyntax($f->getExtension()) . "',title:'" . $f->name . "'});";
}
?>
    }
    function close_ea_file(f){
      jQuery.get("remove_file.php?fid="+f.id, function(res){eval(res);});
      return true;
    }
	</script>
<style type="text/css">
*{
	margin:0;
	padding:0;
}
</style>
Пример #11
0
 function addFile($file)
 {
     if (!$GLOBALS['kfm_allow_file_create']) {
         return $this->error(kfm_lang('permissionDeniedCreateFile'));
     }
     if (is_numeric($file)) {
         $file = kfmFile::getInstance($file);
     }
     if (!$this->isWritable()) {
         return $this->error(kfm_lang('fileNotCreatedDirUnwritable', $file->name));
     }
     copy($file->path, $this->path . '/' . $file->name);
     $id = $file->addToDb($file->name, $this->id);
     if ($file->isImage()) {
         $file = kfmImage::getInstance($file->id);
         $newFile = kfmImage::getInstance($id);
         $newFile->setCaption($file->caption);
     } else {
         $newFile = kfmFile::getInstance($id);
     }
     $newFile->setTags($file->getTags());
     return true;
 }