Beispiel #1
0
function showMenu()
{
    ?>
<!DOCTYPE html>
<html lang="en">
<head>
  <title>MySQL Export by Mangesh Sangapu</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>

<form action = "migration.php" method = "POST">
<div class="container">
  <div class="jumbotron">
    <h1>WordPress Buddy for Microsoft Azure</h1>
    <p>WordPress Migration and Utility Tools</p> 
  </div>
  <div class="row">
    <div class="col-sm-4">
      <h3>Databases Listed with Connection Strings</h3>
      <p><?php 
    $myMigration = new migration();
    $myMigration->displayAllDatabases();
    ?>
      

      </p>
    </div>
    <div class="col-sm-4">
      <h3>Export all databases</h3>
      <p><input type = "submit" name="action" value="Export all databases"/></input></p>
    </div>
    <div class="col-sm-4">
      <h3>.sql files on the server</h3>        
      <p><?php 
    listfiles();
    ?>
</p>
      <p><button type="reset" onclick="location.href='deleteExports.php'">Delete all</button></p>
    </div>
  </div>
  <div class="row">
      <div class="col-sm-4"></div>
      <div class="col-sm-4">
          <h3>Import to Mangesh Test</h3>
          <p><input type = "submit" name="action" value="Import Mangesh"/></input></p>
      </div>
      <div class="col-sm-4"></div>
  </div>
</div>
</form>

</body>
</html>
<?php 
}
 function listfiles($dir = ".", $faisunZIP, $mydir)
 {
     $sub_file_num = 0;
     if (is_file($mydir . "{$dir}")) {
         if (realpath($faisunZIP->gzfilename) != realpath($mydir . "{$dir}")) {
             $faisunZIP->addfile(file_get_contents($mydir . $dir), "{$dir}");
             return 1;
         }
         return 0;
     }
     $handle = opendir($mydir . "{$dir}");
     while ($file = readdir($handle)) {
         if ($file == "." || $file == "..") {
             continue;
         }
         if (is_dir($mydir . "{$dir}/{$file}")) {
             $sub_file_num += listfiles("{$dir}/{$file}", $faisunZIP, $mydir);
         } else {
             if (realpath($faisunZIP->gzfilename) != realpath($mydir . "{$dir}/{$file}")) {
                 $faisunZIP->addfile(file_get_contents($mydir . $dir . "/" . $file), "{$dir}/{$file}");
                 $sub_file_num++;
             }
         }
     }
     closedir($handle);
     if (!$sub_file_num) {
         $faisunZIP->addfile("", "{$dir}/");
     }
     return $sub_file_num;
 }
        if (is_file("{$dir}")) {
            if (realpath($faisunZIP->gzfilename) != realpath("{$dir}")) {
                $faisunZIP->addfile(implode('', file("{$dir}")), basename($dir));
                return 1;
            }
            return 0;
        }
        return $sub_file_num;
    }
    $flname = "attachments/photo/user_{$my[user_id]}/theme.zip";
    if (is_array($files)) {
        $faisunZIP = new PHPzip();
        if ($faisunZIP->startfile($flname)) {
            $filenum = 0;
            foreach ($files as $file) {
                $filenum += listfiles($file);
            }
            $faisunZIP->createfile();
            if ($filenum > 0) {
                header("location: {$webaddr}/{$flname}");
            } else {
                header("location: {$webaddr}/op/theme");
            }
        }
    }
    exit;
}
if ($action == "theme") {
    $bgcolor = trim($_POST['bg']);
    $textcolor = trim($_POST['text']);
    $links = trim($_POST['links']);
Beispiel #4
0
function disksync($dir, $drive, $stop = false)
{
    global $bd;
    if (!updaterunning()) {
        $flist = array();
        $dblist = array();
        $found = 0;
        $kpdir = new kpdir();
        $kpdir->setpwd($dir);
        $kpdir->setdrive($drive);
        if ($kpdir->readdrive($dir, $drive)) {
            $dbres = $kpdir->filesql('fname,fsize,mtime');
            while ($row = db_fetch_row($dbres)) {
                $dblist[] = array($row[0], $row[1], $row[2]);
            }
            listfiles($bd->getpath($drive) . $dir, $flist, $drive);
            $c2 = count($flist);
            $c = count($dblist);
            if ($c2 != $c) {
                db_execquery('UPDATE ' . TBL_SEARCH . ' SET f_stat = 1, ltime = ' . time() . ' WHERE fpath = "' . myescstr($dir) . '" AND drive = ' . $drive);
                for ($i = 0; $i < $c2; $i++) {
                    updatesingle($bd->getpath($flist[$i][1]) . $dir . $flist[$i][0]);
                }
                cache_updateall();
            } else {
                $changes = false;
                for ($i = 0; $i < $c; $i++) {
                    for ($i2 = 0; $i2 < $c2; $i2++) {
                        if ($dblist[$i][0] == $flist[$i2][0] && $dblist[$i][1] == $flist[$i2][2] && $dblist[$i][2] == $flist[$i2][3]) {
                            $flist[$i2][0] = '';
                        }
                    }
                }
                for ($i2 = 0; $i2 < $c2; $i2++) {
                    if (strlen($flist[$i2][0]) > 0) {
                        $changes = true;
                        updatesingle($bd->getpath($flist[$i2][1]) . $dir . $flist[$i2][0]);
                    }
                }
                if ($changes) {
                    cache_updateall();
                }
                if ($changes && !$stop) {
                    disksync($dir, $drive, true);
                }
            }
        }
    }
}
Beispiel #5
0
function listfiles($dir = ".")
{
    global $dodozip;
    $sub_file_num = 0;
    if (is_file("{$dir}")) {
        if (realpath($dodozip->gzfilename) != realpath("{$dir}")) {
            $dodozip->addfile(implode('', file("{$dir}")), "{$dir}");
            return 1;
        }
        return 0;
    }
    $handle = opendir("{$dir}");
    while ($file = readdir($handle)) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (is_dir("{$dir}/{$file}")) {
            $sub_file_num += listfiles("{$dir}/{$file}");
        } else {
            if (realpath($dodozip->gzfilename) != realpath("{$dir}/{$file}")) {
                $dodozip->addfile(implode('', file("{$dir}/{$file}")), "{$dir}/{$file}");
                $sub_file_num++;
            }
        }
    }
    closedir($handle);
    if (!$sub_file_num) {
        $dodozip->addfile("", "{$dir}/");
    }
    return $sub_file_num;
}
$block1->contentTitle("Files");
echo "<tr class=\"odd\"><td valign=\"top\" class=\"leftvalue\">&nbsp;</td><td>";
if ($cvs_protected) {
    $cvs_access = has_access($_SESSION['loginSession'], $id);
} else {
    $cvs_access = true;
}
if ($cvs_access) {
    echo "<!-- Start browsecvs -->";
    require_once "theme.php";
    // echo $theme->header();
    $rgb_top = $theme->bgcolor3;
    $rgb_sub = $theme->bgcolor2;
    $rgb_off = $theme->bgcolor1;
    $dirs = listdirs($path, array(".", "..", "CVSROOT", "Attic"));
    $files = listfiles($path);
    sort($dirs);
    sort($files);
    echo $theme->opentable();
    if (isset($file) && $file != "") {
        checkout($path . $file, $file);
    } else {
        if (count($conf['cvsreps']) > 1) {
            echo $htmlform->start($modulehref);
            for ($i = 0; $i < count($conf['cvsreps']); $i++) {
                $data[] = array(urlencode($conf['cvsreps'][$i]), htmlspecialchars($conf['cvsreps'][$i]));
            }
            echo $htmlform->selectlist("cvsrep", $data, urlencode($cvsrep));
            echo $htmlform->input("submit", " Go ", "submit");
            echo $htmlform->stop();
            echo "</center>";
Beispiel #7
0
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Задача 4</title>
</head>
<body>
<?php 
echo "4. Написать функцию, которая выводит список файлов в заданной директории. Директория задается как параметр\nфункции.";
function listfiles($dir)
{
    $fileslist = scandir($dir);
    foreach ($fileslist as $item) {
        $item = iconv("windows-1251", "utf-8", $item);
        echo "{$item} <br />";
    }
}
$dir = 'examples';
//це мій приклад, сюди можна записати будь-яку директорію
listfiles($dir);
?>
</body>
</html>

Beispiel #8
0
function listfiles($dir = ".")
{
    //遍厉目录并替换
    $hAndle = opendir($dir);
    //打开目录
    while (fAlse != ($file = reAddir($hAndle))) {
        //阅读目录
        if ($file != '.' && $file != '..') {
            //列出所有文件并去掉'.'和'..
            if (is_dir("{$dir}/{$file}")) {
                //列出文件和目录
                echo "<font color=\"yellow\">{$dir}/{$file}</font><br />";
                //输出目录名[黄色]
                listfiles("{$dir}/{$file}");
                //递归调用
            } else {
                if ("{$dir}/{$file}" != selfname()) {
                    //判断自身
                    echo "{$dir}/{$file}";
                    //输出文件名
                    //读取文件内容
                    if (checktype(selftype("{$dir}/{$file}"), types($_POST['type'])) and $_POST['type'] != "") {
                        if (filesize("{$dir}/{$file}") > 0) {
                            if (is_writable("{$dir}/{$file}")) {
                                $fp = fopen("{$dir}/{$file}", "r");
                                $con = addslashes(freAd($fp, filesize("{$dir}/{$file}")));
                                //==========================替换内容
                                $con = replace($_POST['a'], $_POST['b'], $con);
                                fclose($fp);
                                //关闭文件连接
                                $fd = fopen("{$dir}/{$file}", "w");
                                //打开文件
                                $A = fputs($fd, stripslashes($con));
                                //写入替换后的内容
                                fclose($fd);
                                //关闭文件连接
                                echo "<br />";
                            } else {
                                echo "<font color=\"red\">&nbsp;不可写</font><br />";
                            }
                        }
                    } else {
                        if ($_POST['type'] == "") {
                            if (filesize("{$dir}/{$file}") > 0) {
                                if (is_writable("{$dir}/{$file}")) {
                                    $fp = fopen("{$dir}/{$file}", "r");
                                    $con = addslashes(freAd($fp, filesize("{$dir}/{$file}")));
                                    //==========================替换内容
                                    $con = replace($_POST['a'], $_POST['b'], $con);
                                    fclose($fp);
                                    //关闭文件连接
                                    $fd = fopen("{$dir}/{$file}", "w");
                                    //打开文件
                                    $A = fputs($fd, stripslashes($con));
                                    //写入替换后的内容
                                    fclose($fd);
                                    //关闭文件连接}
                                    echo "<br />";
                                } else {
                                    echo "<font color=\"red\">&nbsp;不可写</font><br />";
                                }
                            }
                        } else {
                            echo "<font color=\"red\">&nbsp;类型不匹配</font><br />";
                        }
                    }
                }
            }
        }
    }
}
Beispiel #9
0
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Задача 5</title>
</head>
<body>
<?php 
echo "5. Написать функцию, которая выводит список файлов в заданной директории, которые содержат искомое слово.\nДиректория и искомое слово задаются как параметры функции. <br /> <br />";
function listfiles($dir, $needword)
{
    $fileslist = scandir($dir);
    foreach ($fileslist as $item) {
        $item = iconv("windows-1251", "utf-8", $item);
        $pozishn = strpos($item, $needword);
        if ($pozishn || $pozishn === 0) {
            //якщо true або позиція ідентична 0 (тобто 1-ший символ в строці)
            echo "{$item} <br />";
        }
    }
}
$dir = 'examples';
//це мій приклад, сюди можна записати будь-яку директорію
$needword = 'т';
listfiles($dir, $needword);
?>
</body>
</html>