Exemplo n.º 1
0
 public static function delete($path)
 {
     // In case the file is marked read-only
     @chmod($path, 0777);
     if (is_dir($path)) {
         $dir = opendir($path);
         while ($dir !== false && ($file = readdir($dir)) !== false) {
             if ($file != '.' && $file != '..') {
                 WT_File::delete($path . DIRECTORY_SEPARATOR . $file);
             }
         }
         closedir($dir);
         @rmdir($path);
     } else {
         @unlink($path);
     }
     return !file_exists($path);
 }
Exemplo n.º 2
0
        // Create the unzipped GEDCOM on disk, so we can ZIP it.
        $stream = fopen($temp_dir . $download_filename, "w");
        export_gedcom(WT_GEDCOM, $stream, $exportOptions);
        fclose($stream);
        // Create a ZIP file containing the GEDCOM file.
        $comment = "Created by " . WT_WEBTREES . " " . WT_VERSION . " on " . date("r") . ".";
        $archive = new PclZip($temp_dir . $zip_file);
        $v_list = $archive->add($temp_dir . $download_filename, PCLZIP_OPT_COMMENT, $comment, PCLZIP_OPT_REMOVE_PATH, $temp_dir);
        if ($v_list == 0) {
            echo "Error : " . $archive->errorInfo(true);
        } else {
            header('Content-Type: application/zip');
            header('Content-Disposition: attachment; filename="' . $zip_file . '"');
            header('Content-length: ' . filesize($temp_dir . $zip_file));
            readfile($temp_dir . $zip_file);
            WT_File::delete($temp_dir);
        }
    } else {
        Zend_Session::writeClose();
        header('Content-Type: text/plain; charset=UTF-8');
        header('Content-Disposition: attachment; filename="' . $download_filename . '"');
        // Stream the GEDCOM file straight to the browser.
        // We could open "php://compress.zlib" to create a .gz file or "php://compress.bzip2" to create a .bz2 file
        $stream = fopen('php://output', 'w');
        export_gedcom(WT_GEDCOM, $stream, $exportOptions);
        fclose($stream);
    }
    exit;
}
$controller->pageHeader();
?>
Exemplo n.º 3
0
    echo '<br>', WT_I18N::translate('The file %s was deleted.', '<span dir="ltr">' . $lock_file . '</span>'), $icon_success;
} else {
    echo '<br>', WT_I18N::translate('The file %s could not be deleted.', '<span dir="ltr">' . $lock_file . '</span>'), $icon_failure;
}
echo '</li>';
flush();
////////////////////////////////////////////////////////////////////////////////
// Clean up
////////////////////////////////////////////////////////////////////////////////
echo '<li>', WT_I18N::translate('Delete temporary files…');
reset_timeout();
if (WT_File::delete($zip_dir)) {
    echo '<br>', WT_I18N::translate('The folder %s was deleted.', '<span dir="auto">' . $zip_dir . '</span>'), $icon_success;
} else {
    echo '<br>', WT_I18N::translate('The folder %s could not be deleted.', '<span dir="auto">' . $zip_dir . '</span>'), $icon_failure;
}
if (WT_File::delete($zip_file)) {
    echo '<br>', WT_I18N::translate('The file %s was deleted.', '<span dir="auto">' . $zip_file . '</span>'), $icon_success;
} else {
    echo '<br>', WT_I18N::translate('The file %s could not be deleted.', '<span dir="auto">' . $zip_file . '</span>'), $icon_failure;
}
echo '</li>';
echo '</ul>';
echo '<p>', WT_I18N::translate('The upgrade is complete.'), '</p>';
// Reset the time limit, as timeouts in this script could leave the upgrade incomplete.
function reset_timeout()
{
    if (!ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
        set_time_limit(ini_get('max_execution_time'));
    }
}
Exemplo n.º 4
0
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->addInlineJavascript('jQuery("#x").accordion({heightStyle: "content"});')->addInlineJavascript('jQuery("#tree_stats").accordion();')->addInlineJavascript('jQuery("#changes").accordion();')->addInlineJavascript('jQuery("#content_container").css("visibility", "visible");')->setPageTitle(WT_I18N::translate('Administration'))->pageHeader();
// Check for updates
$latest_version_txt = fetch_latest_version();
if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
    list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
} else {
    // Cannot determine the latest version
    $latest_version = '';
}
// Delete old files (if we can).
$old_files = array();
foreach (old_paths() as $path) {
    if (file_exists($path)) {
        if (!WT_File::delete($path)) {
            // We may be unable to delete it.  If so, tell the user to delete it manually.
            $old_files[] = $path;
        }
    }
}
// Total number of users
$total_users = User::count();
// Total number of administrators
$total_administrators = WT_DB::prepare("SELECT COUNT(*) FROM `##user_setting` WHERE setting_name='canadmin' AND setting_value=1")->fetchOne();
// Total numbers of managers
$total_managers = WT_DB::prepare("SELECT gs.setting_value, COUNT(*)" . " FROM `##gedcom_setting` gs" . " JOIN `##user_gedcom_setting` ugs USING (gedcom_id)" . " WHERE ugs.setting_name = 'canedit' AND ugs.setting_value='admin'" . " AND   gs.setting_name ='title'" . " GROUP BY gedcom_id" . " ORDER BY gs.setting_value")->fetchAssoc();
// Number of users who have not verified their email address
$unverified = WT_DB::prepare("SELECT COUNT(*) FROM `##user_setting` WHERE setting_name='verified' AND setting_value=0")->fetchOne();
// Number of users whose accounts are not approved by an administrator
$unapproved = WT_DB::prepare("SELECT COUNT(*) FROM `##user_setting` WHERE setting_name='verified_by_admin' AND setting_value=0")->fetchOne();