当前位置: 首页>>代码示例>>PHP>>正文


PHP RMUtilities::delete_directory方法代码示例

本文整理汇总了PHP中RMUtilities::delete_directory方法的典型用法代码示例。如果您正苦于以下问题:PHP RMUtilities::delete_directory方法的具体用法?PHP RMUtilities::delete_directory怎么用?PHP RMUtilities::delete_directory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RMUtilities的用法示例。


在下文中一共展示了RMUtilities::delete_directory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xoops_module_pre_uninstall_galleries

function xoops_module_pre_uninstall_galleries($mod)
{
    $dir = RMUtilities::module_config('galleries', 'storedir');
    if (is_dir($dir)) {
        RMUtilities::delete_directory($dir);
    }
    return true;
}
开发者ID:laiello,项目名称:bitcero-modules,代码行数:8,代码来源:uninstall.php

示例2: delete

 public function delete()
 {
     //Eliminamos las imágenes
     $sql = "SELECT * FROM " . $this->db->prefix('gs_images') . " WHERE owner='" . $this->uid() . "'";
     $result = $this->db->query($sql);
     while ($rows = $this->db->fetchArray($result)) {
         $img = new GSImage();
         $img->assignVars($rows);
         $img->delete();
     }
     RMUtilities::delete_directory($this->filesPath());
     //Eliminamos los albumes
     $sql = "SELECT * FROM " . $this->db->prefix('gs_sets') . " WHERE owner='" . $this->uid() . "'";
     $result = $this->db->query($sql);
     while ($rows = $this->db->fetchArray($result)) {
         $set = new GSSet();
         $set->assignVars($rows);
         $set->delete();
     }
     return $this->deleteFromTable();
 }
开发者ID:laiello,项目名称:bitcero-modules,代码行数:21,代码来源:gsuser.class.php

示例3: download_file

function download_file()
{
    global $xoopsLogger, $rmTpl, $runFiles, $xoopsSecurity;
    $xoopsLogger->activated = false;
    $url = RMHttpRequest::post('url', 'string', '');
    $cred = RMHttpRequest::post('credentials', 'string', '');
    $type = RMHttpRequest::post('type', 'string', '');
    $dir = RMHttpRequest::post('dir', 'string', '');
    $ftpdata = RMHttpRequest::post('ftp', 'string', '');
    if ($url == '') {
        jsonReturn(__('Invalid parameters!', 'rmcommon'));
    }
    // Request access
    $query = explode("?", $url);
    $query[1] = ($query[1] != '' ? $query[1] . '&' : '') . 'action=identity' . ($cred != '' ? '&l=' . $cred : '');
    $response = json_decode(RMHttpRequest::load_url($query[0], $query[1], true), true);
    //$response = json_decode(file_get_contents($url.'&), true);
    if ($response['error'] == 1) {
        jsonReturn($response['message']);
    }
    //jsonReturn($response['data']['url']);
    if (!is_dir(XOOPS_CACHE_PATH . '/updates/')) {
        mkdir(XOOPS_CACHE_PATH . '/updates/', 511);
    }
    if (!file_put_contents(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip', file_get_contents($response['data']['url']))) {
        jsonReturn(__('Unable to download update file!', 'rmcommon'));
    }
    // Get files list
    $details = json_decode(RMHttpRequest::load_url($url . '&action=update-details', '', true), true);
    if ($details['error'] == 1) {
        jsonReturn($details['message']);
    }
    $hash = $details['data']['hash'];
    $file_hash = md5_file(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip');
    if ($hash != $file_hash) {
        @unlink(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip');
        jsonReturn(__('The package file could be corrupted. Aborting!', 'rmcommon'));
    }
    // Extract files
    $zip = new ZipArchive();
    $res = $zip->open(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip');
    if ($res !== TRUE) {
        jsonReturn(__('ERROR: unable to open downloaded zip file!', 'rmcommon'));
    }
    $rmUtil = RMUtilities::get();
    $source = XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir;
    if (is_dir($source)) {
        $rmUtil->delete_directory($source);
    }
    $zip->extractTo($source);
    $zip->close();
    // Delete downloaded zip
    unlink(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip');
    // Prepare to copy files
    $target = XOOPS_ROOT_PATH . '/modules/';
    if ($type == 'plugin') {
        $target .= 'rmcommon/plugins/' . $dir;
    } else {
        $target .= $dir;
    }
    if (!is_dir($target)) {
        jsonReturn(sprintf(__('Target path "%s" does not exists!', 'rmcommon'), $target));
    }
    /**
     * When rmcommon is the module to be updated then we need
     * to make a backup before to delete files
     */
    $excluded = array();
    if ($dir == 'rmcommon') {
        $excluded = array($target . '/plugins');
    }
    if (is_writable($target) && !empty($target)) {
        $target = str_replace('\\', '/', $target);
        // Deletes dir content to replace with new files
        RMUtilities::delete_directory($target, false, $excluded);
        // Copy new files
        $source = rtrim(str_replace('\\', '/', $source), '/');
        $odir = opendir($source);
        while (($file = readdir($odir)) !== false) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            @rename($source . '/' . $file, $target . '/' . $file);
        }
        closedir($odir);
        RMUtilities::delete_directory($source);
    } else {
        if ($ftpdata == '') {
            jsonReturn(__('FTP configuration not specified!', 'rmcommon'));
        }
        parse_str($ftpdata);
        if ($ftp_server == '' || $ftp_user == '' || $ftp_pass == '') {
            jsonReturn(__('FTP configuration not valid!', 'rmcommon'));
        }
        $target = str_replace('\\', '/', $target);
        global $ftpConfig;
        $ftpConfig->server = $ftp_server;
        $ftpConfig->user = $ftp_user;
        $ftpConfig->pass = $ftp_pass;
        $ftpConfig->dir = $ftp_dir;
//.........这里部分代码省略.........
开发者ID:JustineBABY,项目名称:rmcommon,代码行数:101,代码来源:updates.php

示例4: xoops_module_update_rmcommon

function xoops_module_update_rmcommon($mod, $prev)
{
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SHOW TABLES LIKE '" . $db->prefix("rmc_bkmod") . "'");
    if ($db->getRowsNum($result) > 0) {
        /**
         * Update old tables
         */
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_bkmod") . '` TO  `' . $db->prefix("mod_rmcommon_blocks_assignations") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_blocks") . '` TO  `' . $db->prefix("mod_rmcommon_blocks") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_blocks_positions") . '` TO  `' . $db->prefix("mod_rmcommon_blocks_positions") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_comments") . '` TO  `' . $db->prefix("mod_rmcommon_comments") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_comusers") . '` TO  `' . $db->prefix("mod_rmcommon_comments_assignations") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_images") . '` TO  `' . $db->prefix("mod_rmcommon_images") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_img_cats") . '` TO  `' . $db->prefix("mod_rmcommon_images_categories") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_plugins") . '` TO  `' . $db->prefix("mod_rmcommon_plugins") . '` ;');
        $db->queryF('RENAME TABLE `' . $db->prefix("rmc_settings") . '` TO  `' . $db->prefix("mod_rmcommon_settings") . '` ;');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_blocks_assignations") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_blocks") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_blocks_positions") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_comments") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_comments_assignations") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_images") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_images_categories") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_plugins") . '` ENGINE = INNODB');
        $db->queryF('ALTER TABLE  `' . $db->prefix("mod_rmcommon_settings") . '` ENGINE = INNODB');
    }
    $result = $db->query("SHOW TABLES LIKE '" . $db->prefix("mod_rmcommon_notifications") . "'");
    if ($db->getRowsNum($result) <= 0) {
        /**
         * Create notifications table if not exists
         */
        $sql = 'CREATE TABLE `' . $db->prefix("mod_rmcommon_notifications") . '` (
                `id_notification` int(11) NOT NULL AUTO_INCREMENT,
                  `event` varchar(50) NOT NULL,
                  `element` varchar(50) NOT NULL,
                  `params` varchar(50) NOT NULL,
                  `uid` int(11) NOT NULL,
                  `type` varchar(10) NOT NULL DEFAULT \'module\',
                  `date` datetime NOT NULL
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;';
        $db->queryF($sql);
        $sql = 'ALTER TABLE `' . $db->prefix("mod_rmcommon_notifications") . '`
                ADD PRIMARY KEY (`id_notification`), ADD KEY `event` (`event`), ADD KEY `element` (`element`), ADD KEY `uid` (`uid`);';
        $db->queryF($sql);
        $sql = 'ALTER TABLE `' . $db->prefix("mod_rmcommon_notifications") . '`
                MODIFY `id_notification` int(11) NOT NULL AUTO_INCREMENT;COMMIT;';
        $db->queryF($sql);
    }
    // Change theme from TwoP6 to Helium
    $sql = "UPDATE " . $db->prefix("config") . " SET conf_value='helium' WHERE conf_modid=" . $mod->getVar('mid') . " AND conf_name='theme'";
    $db->queryF($sql);
    // Prepare welcome screen
    $domain = preg_replace("/http:\\/\\/|https:\\/\\//", '', XOOPS_URL);
    setcookie("rmcwelcome", 1, time() + 365 * 86400, '/', $domain);
    // Move system theme to right dir
    $target = XOOPS_ROOT_PATH . '/modules/system/themes/redmexico';
    $source = XOOPS_ROOT_PATH . '/modules/rmcommon/redmexico';
    if (!is_dir($source)) {
        return true;
    }
    global $msgs;
    if (!is_writable($target)) {
        $msgs[] = '<span class="text-danger">' . __('System theme "redmexico" could not move to destination directory (modules/system/themes). Please do it manually in order to get Common Utilities working correctly.', 'rmcommon') . '</span>';
        return true;
    }
    // Deletes dir content to replace with new files
    RMUtilities::delete_directory($target, false);
    $odir = opendir($source);
    while (($file = readdir($odir)) !== false) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        @rename($source . '/' . $file, $target . '/' . $file);
    }
    closedir($odir);
    RMUtilities::delete_directory($source);
    return true;
}
开发者ID:txmodxoops,项目名称:rmcommon,代码行数:79,代码来源:install.php


注:本文中的RMUtilities::delete_directory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。