<?php

include "kartouche/config.php";
include "../includes/fns.php";
checklg($lg);
include "../includes/trans.php";
include "../includes/header.php";
echo "<div class=\"content\">";
dbconnect();
$found = get_dir_files("exports_orig/testing_utf");
reset($found);
//loop through the top level in the $found array
while (list($dir_name, $dir_value) = each($found)) {
    if (is_array($dir_value)) {
        // loop through the next level in the $found array
        while (list($file_name, $file_value) = each($dir_value)) {
            // ignore the dirs
            if ($file_value == "file") {
                // note that msgconv must be fed the full path to the file
                // also note that the server must be able to write to the files - ie they must have permissions of at least 666
                $result = `/usr/bin/msgconv exports_orig/testing_utf/{$file_name} -t UTF-8 -o exports_orig/testing_utf/{$file_name}`;
                echo "Converted {$file_name} to UTF-8<br>";
            }
        }
    }
}
echo "</div>";
include "../includes/footer.php";
include "../includes/fns.php";
checklg($lg);
include "../includes/trans.php";
include "../includes/header.php";
echo "<div class=\"content\">";
dbconnect();
// $path needs to refer to a dir within the gwein dir - it is recommended that a symlink named something
// like "cvstemplates" is made to the templates idr of the cvs download
// other paths can be used, but note that if this is done the line
// "list ($path,$kde_dir)=explode("/",$dir_name);" needs to be adjusted too, because the path
// is split at each slash, and only the second, ie the one after the first slash ("home" in the case of
// something like "/home/kevin/public_html/kartouche") will get put into the $kde_dir variable
// the line would need to be amended to build an array from the exploded pieces, with these then
// being reassembled to give an appropriate tablename; there's enough of that around already,
// so for an easy life I suggest the symlink
$found = get_dir_files($path);
reset($found);
//loop through the top level in the $found array
while (list($dir_name, $dir_value) = each($found)) {
    if (is_array($dir_value)) {
        // loop through the next level in the $found array
        while (list($file_name, $file_value) = each($dir_value)) {
            // ignore the dirs
            if ($file_value == "file") {
                // set up a name to report progress to the user
                $import_file = $dir_name . "/" . $file_name;
                // split $path off the top level info to leave just the kde dir
                // note that this assumes a flat dir structure of only two levels
                list($path, $kde_dir) = explode("/", $dir_name);
                // replace a hyphen in the filename with two underlines
                // a hyphen is not a legal character in a MySQL tablename
Exemple #3
0
function get_dir_files($dir)
{
    if (is_file($dir)) {
        return array($dir);
    }
    $files = array();
    if (is_dir($dir) && ($dir_p = opendir($dir))) {
        $ds = DIRECTORY_SEPARATOR;
        while (($filename = readdir($dir_p)) !== false) {
            if ($filename == '.' || $filename == '..') {
                continue;
            }
            $filetype = filetype($dir . $ds . $filename);
            if ($filetype == 'dir') {
                $files = array_merge($files, get_dir_files($dir . $ds . $filename));
            } elseif ($filetype == 'file') {
                $files[] = $dir . $ds . $filename;
            }
        }
        closedir($dir_p);
    }
    return $files;
}
Exemple #4
0
function get_dir_files($dir)
{
    if (!is_dir($dir)) {
        return false;
    }
    $hd = opendir($dir);
    while (false !== ($file = readdir($hd))) {
        if ($file != '.' && $file != '..') {
            $path = $dir . '/' . $file;
            if (is_dir($path)) {
                get_dir_files($path);
            } else {
                $arr = array('real_url' => ICON_URL . $file, 'url' => '<MATEURL>' . $file);
                $ret[] = $arr;
            }
        }
    }
    return $ret;
}
Exemple #5
0
function get_dir_files($path)
{
    $chosen_dir = opendir($path);
    while ($file_name = readdir($chosen_dir)) {
        if ($file_name != "." and $file_name != "..") {
            $file_type = filetype($path . "/" . $file_name);
            $found[$path][$file_name] = $file_type;
            if ($file_type == "dir" and $file_name != "CVS" and $file_name != "docs") {
                $file_array = get_dir_files($path . "/" . $file_name);
                $found = array_merge($found, $file_array);
            }
        }
    }
    closedir($chosen_dir);
    if (!isset($found)) {
        $found = array();
    }
    return $found;
}
Exemple #6
0
/**
 * 选择本次需要升级的版本
 */
function choose_version()
{
    global $pw_version;
    $current_version = 0;
    $update_version = 0;
    //获取data下的lock文件
    $lockfiles = get_dir_files("./data");
    is_array($lockfiles) || ($lockfiles = array());
    foreach ($lockfiles as $k => $v) {
        if (strpos($v, ".lock") === false) {
            unset($lockfiles[$k]);
        } else {
            $lockfiles[$k] = "./data/{$v}";
        }
    }
    //升级脚本根据data下的lock文件判断当前pw版本,仅以data目录下的最近一次的lock文件为判断依据,判断最近一次lock文件的内容查看升级是否成功
    foreach ($pw_version as $k => $v) {
        in_array($v['lockfile'], $lockfiles) && ($current_version = $k);
    }
    $pw_db = PW_DB::getInstance();
    if (!$current_version || $current_version == 1) {
        //没检测到lock文件,没有执行过升级,或升级后删除lock文件 || 只执行过第一版的升级
        $sql = "SHOW TABLES LIKE '{$pw_db->dbpre}bbs_forum_life'";
        $pw_db->query($sql) && ($current_version = 1);
        $sql = "SHOW TABLES LIKE '{$pw_db->dbpre}fresh_site'";
        $pw_db->query($sql) && ($current_version = 2);
        $update_version = $current_version + 1;
    } else {
        //存在lock文件,用户执行过升级
        isset($pw_version[++$current_version]) && ($update_version = $current_version);
    }
    return $update_version;
}