protected function makeStat($stat) { if ($stat['parent_id']) { $stat['phash'] = $this->encode($stat['parent_id']); } else { $stat['phash'] = null; } if ($stat['mime'] == 'directory') { unset($stat['width']); unset($stat['height']); } else { unset($stat['dirs']); } $this->setAuthByPerm($stat); $name = $stat['name']; if ($stat['mime'] !== 'directory') { if (strpos($this->options['URL'], '?') === false) { $stat['url'] = $this->options['URL'] . $stat['file_id'] . '/' . rawurlencode($name); // Use pathinfo "index.php/[id]/[name] } else { $stat['url'] = $this->options['URL'] . $stat['file_id'] . '&' . rawurlencode($name); } } else { $stat['url'] = null; } if (!empty($stat['local_path'])) { $stat['_localalias'] = 1; $stat['alias'] = $stat['local_path']; $stat['write'] = 0; } if (isset($stat['uid'])) { $stat['owner'] = xoops_elFinder::getUnameByUid($stat['uid']); $stat['tooltip'] = 'Owner: ' . $stat['owner']; } unset($stat['file_id'], $stat['parent_id'], $stat['gid'], $stat['home_of'], $stat['local_path']); if (empty($stat['isowner'])) { unset($stat['perm'], $stat['uid'], $stat['gids']); } if (empty($stat['isowner']) || $stat['mime'] !== 'directory') { unset($stat['umask']); } if ($stat['mime'] !== 'directory') { unset($stat['filter']); } return $stat; }
/** * Return stat for given path. * Stat contains following fields: * - (int) size file size in b. required * - (int) ts file modification time in unix time. required * - (string) mime mimetype. required for folders, others - optionally * - (bool) read read permissions. required * - (bool) write write permissions. required * - (bool) locked is object locked. optionally * - (bool) hidden is object hidden. optionally * - (string) alias for symlinks - link target path relative to root path. optionally * - (string) target for symlinks - link target path. optionally * * If file does not exists - returns empty array or false. * * @param string $path file path * @return array|false * @author Dmitry (dio) Levashov * @author Naoki Sawada **/ protected function _stat($path) { if ($path === '_') { $cid = $lid = 0; } else { list($cid, $lid) = explode('_', substr($path, 1), 2); list($lid) = explode('.', $lid); list($lid, $cnt) = array_pad(explode('_', $lid), 2, ''); if ($cnt) { $cnt = (int)$cnt; } } $stat_def = array( 'size' => 0, 'ts' => 0, 'mime' => '', 'dirs' => 0, 'read' => true, 'write' => false, 'locked' => true, 'hidden' => false ); if (! $cid) { $stat['name'] = (! empty($this->options['alias'])? $this->options['alias'] : 'untitle'); $stat['mime'] = 'directory'; $stat['dirs'] = true; $stat = array_merge($stat_def, $stat); return $stat; } elseif (! $lid) { // cat (dirctory) $sql = 'SELECT c.pid, c.cid, c.title as name , s.pid as dirs ' . 'FROM '.$this->tbc.' AS c ' . 'LEFT JOIN '.$this->tbc.' AS s ON c.cid=s.pid ' . 'WHERE c.cid="'.$cid.'" LIMIT 1'; $res = $this->query($sql); if ($res) { $stat = $this->db->fetchArray($res); $stat = array_merge($stat_def, $stat); $stat['mime'] = 'directory'; $stat['dirs'] = $stat['dirs']? 1 : 0; if (! $stat['pid']) { $stat['phash'] = $this->encode('_'); } else { $stat['phash'] = $this->encode('_'.$stat['pid'].'_'); } unset($stat['cid'], $stat['pid']); return $stat; } } elseif ($cid) { // photos $sql = 'SELECT submitter as uid, lid, concat( lid, "'.($cnt? ('_' . $cnt) : '').'.", ext'.$cnt.' ) AS id, res_x'.$cnt.' AS width, res_y'.$cnt.' AS height, `date` AS ts, concat( title, "'.($cnt? ('_' . $cnt) : '').'.", ext'.$cnt.' ) AS name FROM '.$this->tbf.' WHERE lid="'.$lid.'" AND status>0 LIMIT 1'; $res = $this->query($sql); if ($res) { $stat = $this->db->fetchArray($res); $stat = array_merge($stat_def, $stat); $stat['phash'] = $this->encode('_'.$cid.'_'); $stat['url'] = $this->options['URL'].$stat['id']; $realpath = realpath($this->options['filePath'].$stat['id']); $stat['size'] = filesize($realpath); $stat['mime'] = $this->mimetypeInternalDetect($stat['id']); $stat['simg'] = trim($this->options['smallImg'], '/'); $stat['tooltip'] = 'Owner: ' . xoops_elFinder::getUnameByUid($stat['uid']); unset($stat['lid'], $stat['id']); return $stat; } } return array(); }
/** * Prepare driver before mount volume. * Connect to db, check required tables and fetch root path * * @return bool * @author Dmitry (dio) Levashov **/ protected function init() { $this->mydirname = $mydirname = $this->options['mydirname']; $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; if (!file_exists($langmanpath)) { return false; } require_once $langmanpath; $langman =& D3LanguageManager::getInstance(); $langman->read('main.php', $mydirname, 'd3diary'); $d3dTrustDir = XOOPS_TRUST_PATH . '/modules/d3diary'; include_once $d3dTrustDir . '/class/d3diaryConf.class.php'; $this->d3dConf =& D3diaryConf::getInstance($mydirname, 0, 'photolist'); if (!is_object($this->d3dConf)) { return false; } xoops_elFinder::dbSetCharset('utf8'); // make catgory tree $func =& $this->d3dConf->func; $uid = $this->d3dConf->uid; $cat = $func->get_categories($uid, $uid); $this->catTree = array(); $this->catTree['root'] = array('subcats' => array()); $pcid = 'root'; foreach ($cat as $_cat) { if (100 <= $_cat['blogtype'] || $_cat['subcat'] && !$_cat['num']) { continue; } $this->catTree[$_cat['cid']] = array('subcats' => array(), 'num' => $_cat['num'], 'name' => $_cat['cname'], 'pcid' => $_cat['subcat'] && $pcid ? $pcid : 'root'); if ($_cat['subcat']) { if ($pcid !== 'root') { $this->catTree[$pcid]['subcats'][$_cat['cid']] = $_cat['cname']; } } else { if ($pcid !== 'root' && !$this->catTree[$pcid]['subcats'] && !$this->catTree[$pcid]['num']) { // no entry unset($this->catTree[$this->catTree[$pcid]['pcid']]['subcats'][$pcid], $this->catTree[$pcid]); } $pcid = $_cat['cid']; $this->catTree['root']['subcats'][$pcid] = $_cat['cname']; } } if (!isset($this->options['extAnother']) || strtolower($this->options['extAnother']) !== 'off') { if (!isset($this->catTree[0])) { $this->catTree[0] = array('subcats' => array(), 'name' => _MD_NOCNAME, 'pcid' => 'root'); $this->catTree['root']['subcats'][0] = $this->strToUTF8(_MD_NOCNAME); } $this->catTree[0]['name'] = $this->strToUTF8($this->catTree[0]['name']); $this->catTree[-1] = array('subcats' => array(), 'name' => 'Another', 'pcid' => 0); $this->catTree[0]['subcats'][-1] = 'Another'; } if (is_null($this->options['syncChkAsTs'])) { $this->options['syncChkAsTs'] = true; } return true; }
// google drive if ($php54 && !empty($config['googleapi_id']) && !empty($config['googleapi_secret'])) { //require dirname(__FILE__) . '/class/xelFinderFlysystemGoogleDriveNetmount.php'; elFinder::$netDrivers['googledrive'] = 'GoogleDrive'; define('ELFINDER_GOOGLEDRIVE_CLIENTID', $config['googleapi_id']); define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', $config['googleapi_secret']); } // one drive if (!empty($config['onedriveapi_id']) && !empty($config['onedriveapi_secret'])) { elFinder::$netDrivers['onedrive'] = 'OneDrive'; define('ELFINDER_ONEDRIVE_CLIENTID', $config['onedriveapi_id']); define('ELFINDER_ONEDRIVE_CLIENTSECRET', $config['onedriveapi_secret']); } // load xoops_elFinder include_once dirname(__FILE__) . '/class/xoops_elFinder.class.php'; $xoops_elFinder = new xoops_elFinder($mydirname); $xoops_elFinder->setConfig($config); $xoops_elFinder->setLogfile($debug ? XOOPS_TRUST_PATH . '/cache/elfinder.log.txt' : ''); // Access control include_once dirname(__FILE__) . '/class/xelFinderAccess.class.php'; // get user roll $userRoll = $xoops_elFinder->getUserRoll(); $isAdmin = $userRoll['isAdmin']; // Get volumes if (isset($_SESSION['XELFINDER_RF_' . $mydirname]) && $_SESSION['XELFINDER_CFG_HASH_' . $mydirname] === $config_MD5) { $rootConfig = unserialize(base64_decode($_SESSION['XELFINDER_RF_' . $mydirname])); } else { $memberUid = $userRoll['uid']; $memberGroups = $userRoll['mygids']; $inSpecialGroup = $userRoll['inSpecialGroup']; // set umask
foreach ($check_dir as $dir) { $dir = rtrim($dir, '/'); if (is_writable($dir)) { $dir .= ' (<span style="color:green;font-weight:bold;">OK</span>)'; } else { $dir .= ' (<span style="color:red;font-weight:bold;">NG</span>)'; } $dir_res[] = $dir; } $dir_res = '<ul><li>' . join('</li><li>', $dir_res) . '</li></ul>'; if (isset($_POST) && !empty($_POST['session_table_fix'])) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $db->query('ALTER TABLE `' . $db->prefix('session') . '` CHANGE `sess_data` `sess_data` MEDIUMBLOB NOT NULL'); } include_once XOOPS_TRUST_PATH . '/modules/xelfinder/class/xoops_elFinder.class.php'; $xelf = new xoops_elFinder($mydirname); $stype = $xelf->getSessionTableType(); if ($stype !== 'mediumblob' && $stype !== 'longblob') { $form = '<form method="post" style="display:inline;"><input type="hidden" name="session_table_fix" value="1"><input type="submit" value="Change"></form>'; $sResult = 'Session table type is "' . $stype . '" (<span style="color:red;font-weight:bold;">Recomend change type to "mediumblob"</span>' . $form . ')'; } else { $sResult = 'Session table type is "' . $stype . '" (<span style="color:green;font-weight:bold;">OK</span>)'; } xoops_cp_header(); include dirname(__FILE__) . '/mymenu.php'; echo '<h3>' . $xoopsModule->getVar('name') . '</h3>'; echo '<h4>Writable check results</h4>'; echo $dir_res; echo '<h4>Session table check results</h4>'; echo '<div>' . $sResult . '</div>'; xoops_cp_footer();
/** * Sets the default client character set * * @param string $charset * @return bool */ public static function dbSetCharset($charset = 'utf8') { static $link = null; if (is_null($link)) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $link = is_object($db->conn) && get_class($db->conn) === 'mysqli' ? $db->conn : false; } self::$dbCharset = $charset; if ($link) { return mysqli_set_charset($link, $charset); } else { return mysql_set_charset($charset); } }
$target = isset($_GET['target']) ? preg_match('/^[a-zA-Z0-9_:.-]+$/', $_GET['target']) ? $_GET['target'] : '' : ''; $callback = isset($_GET['cb']) ? preg_match('/^[a-zA-Z0-9_]+$/', $_GET['cb']) ? $_GET['cb'] : '' : 'bbcode'; $callback = 'getFileCallback_' . $callback; $siteimg = empty($_GET['si']) && empty($use_bbcode_siteimg) ? 0 : 1; $admin = isset($_GET['admin']) ? 1 : 0; $myurl = XOOPS_MODULE_URL . '/' . $mydirname; $elfurl = XOOPS_URL . '/common/elfinder'; $modules_basename = trim(str_replace(XOOPS_URL, '', XOOPS_MODULE_URL), '/'); $module_handler =& xoops_gethandler('module'); $xelfinderModule = $module_handler->getByDirname($mydirname); $xelfVer = $xelfinderModule->getVar('version'); $config_handler =& xoops_gethandler('config'); $config = $config_handler->getConfigsByCat(0, $xelfinderModule->getVar('mid')); // load xoops_elFinder include_once dirname(__FILE__) . '/class/xoops_elFinder.class.php'; $xoops_elFinder = new xoops_elFinder($mydirname); $xoops_elFinder->setConfig($config); $conector_url = $conn_is_ext = ''; if (!empty($config['connector_url'])) { $conector_url = $config['connector_url']; !$config['conn_url_is_ext'] || ($conn_is_ext = 1); } $managerJs = ''; $_plugin_dir = dirname(__FILE__) . '/plugins/'; $_js_cache_path = $_js_cache_times = array(); foreach (explode("\n", $config['volume_setting']) as $_vol) { $_vol = trim($_vol); if (!$_vol || $_vol[0] === '#') { continue; } list(, $_plugin, $_dirname) = explode(':', $_vol);