Exemple #1
0
 function kfmFile()
 {
     global $kfm;
     if (func_num_args() == 1) {
         $this->id = (int) func_get_arg(0);
         parent::__construct();
         $filedata = db_fetch_row("SELECT id,name,directory FROM " . KFM_DB_PREFIX . "files WHERE id=" . $this->id);
         $this->name = $filedata['name'];
         $this->parent = $filedata['directory'];
         $dir = kfmDirectory::getInstance($this->parent);
         $this->dir = $dir;
         $this->directory = $dir->path();
         $this->path = $this->directory . '/' . $filedata['name'];
         if (!$this->exists()) {
             //				$this->error(kfm_lang('File cannot be found')); // removed because it is causing false errors
             $this->delete();
             return false;
         }
         $this->writable = $this->isWritable();
         $this->ctime = filemtime($this->path) + $GLOBALS['kfm_server_hours_offset'] * 3600;
         $this->modified = strftime($kfm->setting('date_format') . ' ' . $kfm->setting('time_format'), filemtime($this->path));
         $mimetype = Mimetype::get($this->path);
         $pos = strpos($mimetype, ';');
         $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos);
         $this->type = trim(substr(strstr($this->mimetype, '/'), 1));
     }
 }
Exemple #2
0
 function kfmSession($key = '')
 {
     global $kfm;
     parent::__construct();
     $create = 1;
     if ($key == '' && isset($_COOKIE['kfm_cookie']) && strlen($_COOKIE['kfm_cookie']) == 32) {
         $key = $_COOKIE['kfm_cookie'];
     }
     if ($key != '' && strlen($key) == 32) {
         $res = db_fetch_row("SELECT id FROM " . KFM_DB_PREFIX . "session WHERE cookie='" . $key . "'");
         if (is_array($res) && count($res)) {
             $create = 0;
             $this->id = $res['id'];
             $this->isNew = false;
             $kfm->db->query("UPDATE " . KFM_DB_PREFIX . "session SET last_accessed='" . date('Y-m-d G:i:s') . "' WHERE id='" . $this->id . "'");
         }
     }
     if ($create) {
         $kfm->db->query("INSERT INTO " . KFM_DB_PREFIX . "session (last_accessed) VALUES ('" . date('Y-m-d G:i:s') . "')");
         $this->id = $kfm->db->lastInsertId(KFM_DB_PREFIX . 'session', 'id');
         $key = md5($this->id);
         $kfm->db->query("UPDATE " . KFM_DB_PREFIX . "session SET cookie='" . $key . "' WHERE id=" . $this->id);
         $this->isNew = true;
         $this->setMultiple(array('cwd_id' => 1, 'language' => '', 'user_id' => 1, 'username' => '', 'password' => '', 'loggedin' => 0, 'theme' => false));
     }
     $this->key = $key;
     $this->vars = array();
     setcookie('kfm_cookie', $key, 0, '/');
 }
Exemple #3
0
 function kfmFile()
 {
     if (func_num_args() == 1) {
         $this->id = (int) func_get_arg(0);
         parent::__construct();
         $filedata = db_fetch_row("SELECT id,name,directory FROM " . KFM_DB_PREFIX . "files WHERE id=" . $this->id);
         if ($filedata === false) {
             return false;
         }
         // does not exist in database
         $this->name = $filedata['name'];
         $this->parent = $filedata['directory'];
         $dir = kfmDirectory::getInstance($this->parent);
         $this->dir = $dir;
         $this->directory = $dir->path();
         $this->path = $this->directory . '/' . $filedata['name'];
         if (!$this->exists()) {
             $this->delete();
             return false;
         }
         $this->writable = $this->isWritable();
         $this->ctime = filemtime($this->path) + $GLOBALS['kfm_server_hours_offset'] * 3600;
         $this->modified = strftime($GLOBALS['kfm']->setting('date_format') . ' ' . $GLOBALS['kfm']->setting('time_format'), filemtime($this->path));
         require_once $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/Core_getMimeType.php';
         $mimetype = Core_getMimeType($this->path);
         $pos = strpos($mimetype, ';');
         $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos);
         $this->type = trim(substr(strstr($this->mimetype, '/'), 1));
     }
 }
Exemple #4
0
 function kfmDirectory($id = 1)
 {
     parent::__construct();
     $this->id = $id;
     if (!$id) {
         return;
     }
     $res = db_fetch_row("SELECT * FROM " . KFM_DB_PREFIX . "directories WHERE id=" . $this->id);
     if (!$res) {
         return $this->id = 0;
     }
     $this->name = $res['name'];
     $this->pid = $res['parent'];
     $this->path = $this->getPath();
 }
Exemple #5
0
 function __construct($id = 1)
 {
     parent::__construct();
     $this->id = $id;
     if (!$id) {
         return;
     }
     $res = db_fetch_row("SELECT * FROM " . KFM_DB_PREFIX . "directories WHERE id=" . $this->id);
     if (!$res) {
         return $this->id = 0;
     }
     $this->name = $res['name'];
     $this->pid = (int) $res['parent'];
     $this->maxWidth = (int) $res['maxwidth'];
     $this->maxHeight = (int) $res['maxheight'];
 }
Exemple #6
0
 function kfmSession($key = '')
 {
     global $kfm;
     parent::__construct();
     $create = 1;
     if ($GLOBALS['kfm_do_not_save_session']) {
         $this->key = 'fake';
         $this->vars = array();
         return;
     }
     if ($key == '' && isset($_COOKIE['kfm_cookie']) && strlen($_COOKIE['kfm_cookie']) == 32) {
         $key = $_COOKIE['kfm_cookie'];
     }
     if ($key != '' && strlen($key) == 32) {
         $res = db_fetch_row("SELECT id FROM " . KFM_DB_PREFIX . "session WHERE cookie='" . $key . "'");
         if (is_array($res) && count($res)) {
             $create = 0;
             $this->id = $res['id'];
             $this->isNew = false;
             $kfm->db->query("UPDATE " . KFM_DB_PREFIX . "session SET last_accessed='" . date('Y-m-d G:i:s') . "' WHERE id='" . $this->id . "'");
             // { clean up expired session data
             $old_sessions = db_fetch_all("SELECT id FROM " . KFM_DB_PREFIX . "session WHERE last_accessed<'" . date('Y-m-d G:i:s', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))) . "'");
             if ($old_sessions && count($old_sessions)) {
                 $old_done = 0;
                 foreach ($old_sessions as $r) {
                     if ($old_done++ == 10) {
                         break;
                     }
                     $kfm->db->query('DELETE FROM ' . KFM_DB_PREFIX . 'session_vars WHERE session_id=' . $r['id']);
                     $kfm->db->query('DELETE FROM ' . KFM_DB_PREFIX . 'session WHERE id=' . $r['id']);
                 }
             }
             // }
         }
     }
     if ($create) {
         $kfm->db->query("INSERT INTO " . KFM_DB_PREFIX . "session (last_accessed) VALUES ('" . date('Y-m-d G:i:s') . "')");
         $this->id = $kfm->db->lastInsertId(KFM_DB_PREFIX . 'session', 'id');
         $key = md5($this->id);
         $kfm->db->query("UPDATE " . KFM_DB_PREFIX . "session SET cookie='" . $key . "' WHERE id=" . $this->id);
         $this->isNew = true;
         $this->setMultiple(array('cwd_id' => 1, 'language' => '', 'user_id' => 1, 'username' => '', 'password' => '', 'loggedin' => 0, 'theme' => false));
     }
     $this->key = $key;
     $this->vars = array();
     setcookie('kfm_cookie', $key, 0, '/');
 }