Esempio n. 1
0
    // Grab a list of image files and folders in the uploads so we can clean empty folders
    $content = get_files($config['basedir'] . 'plog-content/uploads', false, true);
    $files = $content['files'];
    $folders = $content['folders'];
    // Build a list of unique directories from the filenames
    $directories = array();
    foreach ($files as $file) {
        $dirname = dirname($file);
        if (!in_array($dirname, $directories)) {
            $directories[md5($dirname)] = $dirname;
        }
    }
    // clean up empty directories - compare our original $folders array to the new unique $directories array
    foreach ($folders as $folder) {
        if (!in_array($folder, $directories)) {
            kill_dir($folder);
        }
    }
    if (count($files) == 0) {
        $output .= "\n\n\t\t" . '<div class="actions width-700">' . plog_tr('No images found in the <strong>plog-content/uploads/</strong> directory. To mass import pictures into your gallery, simply:') . '
			<ul>
				<li><strong>' . plog_tr('Open an FTP connection</strong> to your website') . '</li>
				<li>' . plog_tr('Transfer images you wish to publish to the <strong>plog-content/uploads/</strong> directory') . '</li>
				<li>' . plog_tr('Optionally, you can create folders within that directory to import in groups') . '</li>
			</ul>
		</div>' . "\n";
    }
    // Here we will check which group of pictures we are editing, grouped by directory
    if (!isset($_GET['directory']) && count($directories) > 0) {
        $output .= "\n\n\t\t" . '<div class="actions width-700"><strong>' . plog_tr('Choose a directory you wish to import from') . ':</strong>';
        $output .= "\n\t\t\t" . '<ul style="list-style-type: none;">';
function cleanup_files($files, $folders)
{
    global $config;
    $output = array();
    $errors = array();
    // Delete the files first
    foreach ($files as $file) {
        if (file_exists($file)) {
            if (kill_file($file)) {
                $output[] = plog_tr('Plogger found and deleted the file') . ': ' . $file;
            } else {
                $errors[] = plog_tr('Plogger could not delete the file') . ': ' . $file;
            }
        }
    }
    // Remove the folders since there should be no files in them
    foreach ($folders as $folder) {
        if (file_exists($folder)) {
            if (kill_dir($folder)) {
                $output[] = plog_tr('Plogger found and deleted the folder') . ': ' . $folder;
            } else {
                $errors[] = plog_tr('Plogger could not delete the folder') . ': ' . $folder;
            }
        }
    }
    return array('errors' => $errors, 'output' => $output);
}
Esempio n. 3
0
function filemgr($cmd, $stroka, $path, $fileforaction, $mask, $pid)
{
    // is a part filemgr- fileio
    //hidekey ("pid",$pid);
    global $defaultpath, $protect, $prauth, $ADM, $pr, $sd;
    //..,$file
    global $filemgrmod, $daysleft, $codekey, $noscreenmode, $maxmgrs, $OSTYPE, $coreredir;
    global $multiaction, $scriptpath, $scriptpath;
    if ($codekey == 4) {
        needupgrade();
    }
    $file = $fileforaction;
    global $filscheader, $filscdata, $filscplevel, $filsccount, $languageprofile;
    if ($filscdata) {
        if ($filsccount < 1) {
            echo "Filemgr don't have configured scripts<br>";
        } else {
            echo "";
        }
        //additional keys by   filescript.cfg and starting it
        // 4.3.4добавлено: cmsg не отрабатывает теперь значения начинающиеся с точки
        // filescript для генерации кнопок исполнения скриптов ,  заданных администраторами.
        // dbscore - исправлена ошибка из за которой иногда не вычислялся count
        //версия конфигов при создании конфигурации теперь берется из ядра
        //..+++if (!$unauthorized) { //незарегистрированные в любом случае не будут видеть список пользователей ресурса в раздаче.
        // теперь репозитории работать будут раздельно, проприетарная версия будет отличатся только возможностью подключать специальные модули.
        //если вы не планируете их заказывать можно использоватьобычную версию.
        $keylanguage = 1;
        //if not detected;  function detectlanguageidfromheader
        for ($i = 0; $i < 30; $i++) {
            //echo "DEBUG ibane $filscheader[$i],  languageprofile=$languageprofile<br>";
            // echo  "iDEBUG (".substr($filscheader[$i],0,6)."==".substr($languageprofile,0,6).") <br>";
            if (substr($filscheader[$i], 0, 6) == substr($languageprofile, 0, 6)) {
                $keylanguage = $i;
            }
            // теперь хрен открутится, правда ограничились 6 знаками но пофиг , главное ?  не пролезет
            // if (strpos ($filscheader[$i],$languageprofile)) $keylanguage=$i;
            // ну вот почему всегда вместо простой функции приходится городить черт знает что.
            //  if ($filscheader[$i]==$languageprofile) $keylanguage=$i; // придется сделать по дебильному - ибо // что за ? - откуда оно взялось блджад!!!!
        }
        if ($keylanguage == 29) {
            $keylanguage = 1;
        }
        //if
    }
    //..потом добавим проверку на дебильный символ в конце любой строки с утф...вообще бы в парсере как то опознавание глючны файлов сделать
    if ($filscdata) {
        //echo "<br>DEBUG Script:$cmd Key=$keylanguage Lang=$languageprofile Selected=".$filscheader[$keylanguage]."<br>";
        for ($i = 1; $i < $filsccount; $i++) {
            // echo "debug $i = $filscdata[$i][$keylanguage]   , key=[$keylanguage]<br>";
            // plevel checking NOT added!!!!  graphical icon NOT released!  CFG OPT FUTURE disable all scripts not added
            //echo "  if (".$filscdata[$i][$keylanguage]."==$cmd) <br>";
            if ($filscdata[$i][$keylanguage] . $pid === $cmd) {
                $plevelrequired = $filscdata[$i][3];
                $directcommand = $filscdata[$i][2];
                if ($debug) {
                    echo "DEBUG Command= {$directcommand} (rightsreq={$plevelrequired})<br>";
                }
            }
            //path2 redirector?
            if (strlen($directcommand) < 2) {
                continue;
            }
            $massivedynamics = 0;
            if ($debug) {
                echo "DEBUG for (i=1;i<" . strlen($directcommand) . ");{$i}++) {<br>";
            }
            $parsedcommand = $directcommand;
            //echo "здесь должен быть выход ибо сцуко виснет ";
            for ($i = 1; $i < strlen($directcommand) + 5; $i++) {
                $a1 = strpos($directcommand, "%", $i + 0) + 1;
                if ($a1) {
                    $massivedynamics++;
                    $a2 = strpos($directcommand, "%", 0 + $a1 + 1);
                    //this is first   просто это первый , общественный российский.
                    //echo "Try to corrent schetckik -LAAA!!!$i+$a2-1!!!!!!!new $i==$a2!!!!!!!!!!!!!!!!;<br>       ";
                    $oldi = $i;
                    //$i=$i+($a2-1);  почти верно
                    $i = $a2;
                    //echo "old i=$oldi  new i=$i<br>";
                    if ($oldi > $i) {
                        //echo "Logic error, breaking cycling<br>";
                        $i = $oldi;
                        $i = 100500;
                        continue;
                    }
                    $firstcoord[$massivedynamics] = $a1;
                    $lastcoord[$massivedynamics] = $a2;
                    $cut = substr($directcommand, $a1, $a2 - $a1);
                    $cutnow[$massivedynamics] = $cut;
                    $cutwprc = substr($directcommand, $a1 - 1, $a2 - $a1 + 2);
                    $cutwpercent[$massivedynamics] = $cutwprc;
                    $md = $massivedynamics;
                    if ($debug) {
                        echo "DEBUG Parse [{$i}] param=:: f=" . $firstcoord[$md] . " ; a2-l=" . $lastcoord[$md] . ";- is cut=" . $cutnow[$md] . " = %%::<blu>" . $cutwpercent[$md] . "</blu> = <grn>" . ${$cut} . "</grn><br>";
                    }
                    $replaceto = ${$cut};
                    // fukken shit - admin.php?/   а где все остальное?  крап$parsedcommand=str_replace ($parsedcommand, $cutwprc,$replaceto, $count=1);
                    $parsedcommand = str_replace($cutwprc, $replaceto, $parsedcommand, $count = 2);
                }
                //al@al-desktop:/media# mencoder
                //mencoder: relocation error: mencoder: symbol codec_wav_tags, version LIBAVFORMAT_52 not defined in file libavformat.so.52 with link time reference
            }
        }
        if ($debug) {
            echo "DEBUG Parsed command :: {$parsedcommand}<br>";
        }
        if ($parsedcommand) {
            echo " executing (if you enable system () of course )...<br>";
            $x = system($parsedcommand);
            //ping
            $f = fopen("_logs/cmd.log", "w");
            if ($f) {
                fwrite($f, $x);
            }
            fclose($f);
            lprint("5MIN");
            if ($debug) {
                echo "DEBUG {$x}";
            }
        }
        //    ob_flush () ;
        ////exit;
    }
    //echo "ACTION:cmd=$cmd,str ok,path ok,file=$fileforaction,pid=$pid>";// -+++-
    $path = str_replace("\\\\", "\\", $path);
    // проверка на вшивость -
    //$path=str_replace ("/","\\",$path);
    if ($cmd == cmsg("FMG_CPY_F") and $prauth[$ADM][12]) {
        global $path2;
        copy($path . $fileforaction, $path2 . $fileforaction);
        echo "copy({$path}{$fileforaction},{$path2});";
        echo cmsg("CP_END");
    }
    if ($cmd == cmsg("FMG_MOV_F") and $prauth[$ADM][12]) {
        global $path2;
        copy($path . $fileforaction, $path2 . $fileforaction);
        unlink($path . $fileforaction);
        echo cmsg("MOV_END");
    }
    if ($pr[101]) {
        if ($cmd == cmsg("FMG_DOWNLOAD") and $prauth[$ADM][9]) {
            ob_clean();
            $err = sendfile($path . "/" . $fileforaction);
        }
    }
    //костыль, ибо на некоторых тупых компьютерах почему то пропадает косая и соответственно файл скачать невозможно. куда она пропадает никто не знает.
    if ($cmd == cmsg("FMG_DOWNLOAD") and $prauth[$ADM][9]) {
        ob_clean();
        $err = sendfile($path . $fileforaction);
    }
    if ($cmd == cmsg("FMG_UPLOAD") and $prauth[$ADM][36] or $cmd == cmsg("FMG_DUMP_UPLOAD") and $prauth[$ADM][36]) {
        $path = del_endslash($path);
        //	if ($codekey==7) demo ();
        //<input type="hidden" name="MAX_FILE_SIZE" value="8000000000">
        ?>
<form enctype="multipart/form-data" action="filemgr.php" method="post">
	<input name=userfile type=file class=buttonS> <input type=Submit name=go class=buttonS>
	<input type = hidden name = path value ="<?php 
        echo $path;
        ?>
"><?php 
        hidekey("pid", $pid);
        if ($cmd == cmsg("FMG_DUMP_UPLOAD")) {
            echo "Dump loading.<br>";
        }
        echo "</form>";
        hidekey("write", $cmd);
        exit;
        //moved from non-function zone
    }
    //возможно сюда присобачим кнопку удаления из админки точнее ссылки с нее из w.php :)
    //if (($cmd==cmsg("FMG_UNSHARE"))and($prauth[$ADM][36])) {    echo "not implemented";}
    if ($cmd == cmsg("FMG_SHARE") and $prauth[$ADM][36] or $coreredir == "SH_UPDD_FL") {
        $path = del_endslash($path);
        // -- SHARE STEP 1 --
        if ($multiaction) {
            global $filearrcount;
            // 0
            if ($filearrcount > 0) {
                exit;
            }
            // disables FMG_SHARE for cycle executing;  only one action allowed for one or multiaction files.
            global $fileforaction;
            $filearrcount = count($fileforaction);
        }
        // праздник главное вовремя закончить  тогда он ьудет долго помниться как приятное событие
        // multiaction==1  CFG OPT FUTURE  должен добавлять много файлов по идее, однако пока отрабатывается по файлу за раз.
        if ($multiaction) {
            echo "Multiaction mode.  Selected files={$filearrcount}<br>";
        }
        //..if ($multiaction==1) {global $filearrcount;$stroka.=$filearrcount;};
        if (!$multiaction) {
            $file = $path . "/" . $fileforaction;
        }
        if ($multiaction) {
            for ($a = 0; $a < $filearrcount; $a++) {
                $file[$a] = $path . "/" . $fileforaction[$a];
                echo "File {$a}: {$fileforaction[$a]}<br>;";
            }
            $filelistmassive = base64_encode(implode($fileforaction, "¦"));
            //список и число объектов надо передать вместе с multiaction
        }
        //лучше всего массив с файлами передать в виде одной переменной
        if ($coreredir == "SH_UPDD_FL") {
            // maybe
            if (!$multiaction) {
                global $destinationfilename, $filesizeinmb;
                $file = $destinationfilename;
            }
            if ($multiaction) {
                global $destinationfilename, $filesizeinmb;
                echo "SH_UPDD_FL unimplemented<br>";
                echo "I dont know where i take destfilename {$destinationfilename} -- {$file} (file)<bR>";
                //   $file=$destinationfilename;
            }
        }
        ?>
<form enctype="multipart/form-data" action="filemgr.php" method="post"><?php 
        if (!$multiaction) {
            echo "File: {$file}<br>";
        }
        //Sif (!$multiaction) {   echo "File: $file<br>";}
        lprint(GEN_OPT);
        echo "<br>";
        radio("share", "#GENLNK_UNREG", "GENLNK_UNREG");
        echo "<br>";
        radio("share", "FMG_UNSHARE", "FMG_UNSHARE");
        echo "<br>";
        if (!$pr[70]) {
            radio("share", "GENLNK_REG", "GENLNK_REG");
            if ($ADM < 1) {
                lprint("FILE_UNAUTH_NOTE");
            }
            echo "<br>";
            if ($ADM > 0) {
                radio("share", "GEN_PLVL_USR", "GEN_PLVL_USR");
                echo "<select name=groupplevels>";
                for ($a = 0; $a < 10; $a++) {
                    echo "<option>" . $a;
                }
                echo "</select>";
                //if ($ADM<1) lprint ("FILE_UNAUTH_NOTE"); - check unauthorized access
                echo "<br>";
                //незарегистрированные в любом случае не будут видеть список пользователей ресурса в раздаче.
                radio("share", "GENLNK_USR", "GENLNK_USR");
                echo "<br>";
                echo "<select name=\"username[]\" multiple size=15>";
                for ($a = 1; $a < count($prauth); $a++) {
                    echo "<option>" . $prauth[$a][0] . "";
                    $cnt++;
                }
                echo "</select>";
            }
            echo "<br>";
        }
        lprint(COMM);
        inputtext("commfile", 15, $commfile);
        echo "<br>";
        if ($prauth[$ADM][2]) {
            checkbox(1, "yes");
            lprint(GEN_FL_EPX);
        } else {
            hidekey("yes", 1);
        }
        checkbox(1, "srchen");
        lprint(GEN_FILENSRCH);
        echo "<br>";
        if ($coreredir == "SH_UPDD_FL") {
            hidekey("coreredir", "step2");
        }
        if (!$multiaction) {
            hidekey("file", $file);
        }
        if ($multiaction) {
            hidekey("multiactionsign", $multiaction);
            hidekey("file", $filelistmassive);
            $path = add_endslash($path);
            hidekey("pathmulti", base64_encode($path));
            hidekey("filelistmassive", $filelistmassive);
            //посылаем дважды на пробу   и каждый раз нихрена нет почему то  какого ???
            hidekey("filearrcount", $filearrcount);
        }
        submitkey("go", "FMG_SHARE");
        // кнопка раздать файл
        hidekey("pid", $pid);
        ?>
</form>
<?php 
        echo " ";
        hidekey("write", $cmd);
        if ($multiaction == 1) {
            exit;
        }
        //   !
        ////moved from non-function zone -- SHARE STEP 1 -- ENDING
        //ЭТО ОКончание первого шага раздачи
    }
    //
    //	echo "Мы получили из пред сессии  $cmd $fileforaction!<br> <BR>";   ikonki mlya !
    //echo "<br>".cmsg ("FMG_MHLP")."<br>";  ХЕЛП ОТКЛЮЧЕН
    if ($noscreenmode == false) {
        echo "";
    }
    //тут пишем команды и выполняем их
    //echo "628_Failure-- protect::";print_r ($protect); неправильно обрабатывался массив  почему то вместо него шла переменная о_О CFG OPT FUTURE
    if (is_Array($protect)) {
        if (!$prauth[$ADM][38]) {
            $protect[] = "*.php";
        }
    }
    // скрываем файлы скрипта чтобы их никто не стер.
    //$protect[]="*.key";// не снимать комментарий - безопасность снизится до 0
    //if ($OSTYPE=="LINUX") if (($sd[10])AND($ADM==0)) $path=$path."/";  //bug with unregistered users  folder lost /
    //if ($OSTYPE=="WINDOWS") if (($sd[10])AND($ADM==0)) $path=$path."\\";
    if ($OSTYPE == "WINDOWS") {
        if ($cmd == cmsg("FMG_ENTER") and $prauth[$ADM][7]) {
            $path = $path . $fileforaction . "\\";
        }
    }
    if ($OSTYPE == "LINUX") {
        if ($cmd == cmsg("FMG_ENTER") and $prauth[$ADM][7]) {
            $path = $path . $fileforaction . "/";
        }
    }
    if ($OSTYPE == "WINDOWS") {
        if ($cmd == cmsg("FMG_DRV") and $prauth[$ADM][8]) {
            $path = $stroka . ":/";
        }
    }
    if ($OSTYPE == "LINUX") {
        if ($cmd == cmsg("FMG_DRV") and $prauth[$ADM][8]) {
            $path = "/media/{$stroka}/";
        }
    }
    if ($OSTYPE == "LINUXALT") {
        if ($cmd == cmsg("FMG_DRV") and $prauth[$ADM][8]) {
            $path = "/mnt/{$stroka}/";
        }
    }
    //CFG OPT FUTURE
    if ($OSTYPE == "WINDOWS") {
        if ($cmd == cmsg("FMG_EXIT") and $prauth[$ADM][7]) {
            $path = dirname($path) . "\\";
        }
    }
    //$path=folderupdir ($path);
    if ($OSTYPE == "LINUX") {
        if ($cmd == cmsg("FMG_EXIT") and $prauth[$ADM][7]) {
            $path = dirname($path) . "/";
        }
    }
    if ($cmd == cmsg("FMG_SRCH") and $prauth[$ADM][7]) {
        $file = $path . $fileforaction;
        // далее скрипт рассчитан на эту переменную, к томуже массив стереть надо:)
        $a = searchplus($file, $fileforaction, $stroka);
        if ($pr[12]) {
            $act = "FILEMGR_SRCH {$cmd} {$file} word={$stroka}";
            logwrite($act);
        }
        // логируемся
        //if ($a==false) die ("<br>Ошибка!Файл $file не найден!!!.<br>");
        echo " <form action=filemgr.php method=post>";
        hidekey("pid", $pid);
        hidekey("write", $cmd);
        submitkey("cmd" . $pid, "FMG_RESET");
        echo "</form>";
        exit;
    }
    //If ($prauth[$ADM][2]==true) {
    // blocked commands
    if ($cmd == cmsg("FMG_MKDIR") and $prauth[$ADM][12]) {
        //if ($codekey==7) demo ();
        if ($multiaction == 1) {
            global $filearrcount;
            $stroka .= $filearrcount;
        }
        $err = mkdir($path . $stroka);
    }
    //if ($cmd==cmsg("FMG_DELALL")) $err=rmdir ($path.$fileforaction);
    if ($cmd == cmsg("FMG_JOINFIL") and $prauth[$ADM][12]) {
        if ($codekey == 7) {
            demo();
        }
        $err = joinfiles($path, $mask, $protect, $stroka);
    }
    if ($cmd == cmsg("FMG_DELALL") and $prauth[$ADM][13]) {
        // rmdir теперь  полное удаление (!)
        if ($codekey == 7) {
            demo();
        }
        if ($prauth[$ADM][5] == true) {
            if ($stroka == "accept") {
                $err = kill_dir($path . $fileforaction);
            } else {
                echo "Вы не сказали accept";
            }
        } else {
            msgexiterror("notright", "", "disable");
            exit;
        }
        // круто удаляет отключим
    }
    if ($cmd == cmsg("FMG_EXECUTE") and $prauth[$ADM][8]) {
        if ($codekey == 7) {
            demo();
        }
        echo cmsg("FMG_MOD_IN") . "<br>";
        require $filemgrmod;
        echo cmsg("FMG_MOD_OUT") . "<br>";
    }
    if ($OSTYPE == "LINUX") {
        if ($cmd == cmsg("FMG_UNRAR") and $prauth[$ADM][12]) {
            $file = $path . $fileforaction;
            //rar_open rar_list PHP by standart is unsupported!!!
            $unrared = substr($fileforaction, 0, strrpos($fileforaction, '.'));
            // elf  elfkz  удаляем расширение рар
            @mkdir($path . $unrared);
            echo "Creating folder {$unrared}<br>";
            $extractionpoint = $path . $unrared;
            echo "Extracting to " . $extractionpoint . ";<br>";
            $zip = system("unrar x \"{$file}\" \"{$extractionpoint}\"");
            echo "<br>Result={$zip}  ";
            //echo '"unrar e \"'.$file.'\" \"'.$extractionpoint.'\""'; echo " <br>";
        }
    }
    if ($OSTYPE == "LINUX") {
        if ($cmd == cmsg("FMG_RAR") and $prauth[$ADM][12]) {
            $file = $path . $fileforaction;
            //rar_open rar_list PHP by standart is unsupported!!!
            $unrared = substr($fileforaction, 0, strrpos($fileforaction, '.'));
            // elf  elfkz  удаляем расширение рар
            // @mkdir ($path.$unrared);
            // echo "Creating folder $unrared<br>";
            $extractionpoint = $path . $unrared;
            echo "Archiving to  to " . $fileforaction . ".rar;<br>";
            $zip = system("rar a \"{$fileforaction}\".rar \"{$file}\"");
            echo "<br>Result={$zip}  ";
            //echo '"unrar e \"'.$file.'\" \"'.$extractionpoint.'\""'; echo " <br>";
        }
    }
    if ($cmd == cmsg("FMG_UNZIP") and $prauth[$ADM][12]) {
        $file = $path . $fileforaction;
        //rar_open rar_list PHP by standart is unsupported!!!
        $zip = zip_open($file);
        $unrared = substr($fileforaction, 0, strrpos($fileforaction, '.'));
        // elf  elfkz  удаляем расширение рар
        @mkdir($path . $unrared);
        if ($zip) {
            while ($zip_entry = zip_read($zip)) {
                echo "Name: " . zip_entry_name($zip_entry) . "\n";
                echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "\n";
                echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "\n";
                echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "\n";
                if (zip_entry_open($zip, $zip_entry, "r")) {
                    echo "File Contents:\n";
                    $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                    //echo "$buf\n";
                    $x = fopen($path . zip_entry_name($zip_entry), "w");
                    @fwrite($x, $buf);
                    @fclose($x);
                    zip_entry_close($zip_entry);
                }
                echo "\n";
            }
            zip_close($zip);
        }
    }
    if ($cmd == cmsg("FMG_TEST")) {
        //at this moment start new script
        echo cmsg("FMG_MOD_IN") . "<br>";
        require "mp3runonce.php";
        echo cmsg("FMG_MOD_OUT") . "<br>";
    }
    if ($cmd == cmsg("FMG_DEL") and $prauth[$ADM][13]) {
        if ($codekey == 7) {
            demo();
        }
        @($err1 = unlink($path . $fileforaction));
        @($err2 = rmdir($path . $fileforaction));
    }
    if ($cmd == cmsg("FMG_NEW") and $prauth[$ADM][12]) {
        //if ($codekey==7) demo ();
        //echo "ibane ug if ($multiaction==1) {global $filearrcount;$stroka.=$filearrcount;};<br>";
        if ($multiaction == 1) {
            global $filearrcount;
            $stroka .= $filearrcount;
        }
        @($err = fopen($path . $stroka, "r"));
        if ($err == false) {
            $err = fopen($path . $stroka, "a");
        }
    }
    if ($cmd == cmsg("FMG_REN") and $prauth[$ADM][12]) {
        if ($codekey == 7) {
            demo();
        }
        if ($multiaction == 1) {
            global $filearrcount;
            $stroka .= $filearrcount;
        }
        $err = rename($path . $fileforaction, $path . $stroka);
    }
    if ($cmd == cmsg("FMG_EDIT") and $prauth[$ADM][12]) {
        if ($codekey == 7) {
            demo();
        }
        $err = simpleedit($path . $fileforaction, $stroka);
    }
    if ($pr[12]) {
        $act = "FILEMGR_CMD {$cmd} {$file}({$path} {$fileforaction}) word={$stroka}";
        if ($cmd) {
            if ($cmd !== cmsg("FMG_ENTER") and $cmd !== cmsg("FMG_EXIT")) {
                logwrite($act);
            }
        }
    }
    // логируемся
    // } else { echo "<br><font color=red id=errfnt>".cmsg ("LIM")."</font>".cmsg ("FMG_HLP2");}
    #selectin files using  fileio.php
    if (!$path or $cmd == cmsg("FMG_RESET")) {
        $path = $defaultpath;
        $mask = "*.*";
        $file = "";
        $stroka = "";
    }
    //$path=str_replace ("//","/",$path);проверка на вшивость -
    if ($err) {
        echo "{$err} <br>";
    }
    //global disables visual menu for executing action
    if (!$multiaction) {
        // start menu show
        // маска для файла может быть поиск по части имени и поиск по формату
        //выделить обращение к директории и режим парсинга (маска)
        //насчет маски - возможно стоит ее добавить в поисковик МЕ
        if ($pid == 1) {
            if ($pr[86]) {
                if ($pr[87] or $prauth[$ADM][7]) {
                    //либо право на чтение у юзера, либо разрешение искать всем.
                    echo "<br><form action=filemgr.php method=post>";
                    lprint("SRCH_FILE");
                    inputtxt("searchfilenew", 30);
                    submitkey("start", "DALEE");
                    echo "</form>";
                    if ($searchfilenew) {
                        echo $searchfilenew;
                    }
                }
            }
        }
        echo "<form action=filemgr.php method=post>";
        hidekey("write", $cmd);
        //выделить отдельно модуль создания меню выбора файла.
        $file = getdirdata($path, $mask, $protect);
        //print_r ($file);
        if ($file) {
            asort($file);
        }
        $dircnt = count($file);
        if ($ADM > 0) {
            echo "<font color=blue>{$path}</font><br>";
        }
        hidekey("pid", $pid);
        // cобственно это и мешает многооконной идее ))   вроде теперь кое-
        for ($a = 1; $a < $maxmgrs + 1; $a++) {
            // save pid data
            $strokaname = "stroka" . $a;
            $pathname = "path" . $a;
            $fileforactionname = "fileforaction" . $a;
            $maskname = "mask" . $a;
            global ${$strokaname}, ${$pathname}, ${$fileforactionname}, ${$maskname};
            ${$pathname} = str_replace("\\\\", "\\", ${$pathname});
            ${$pathname} = str_replace("\\\\", "\\", ${$pathname});
            if ($OSTYPE == "WINDOWS") {
                $path = str_replace("\\\\", "\\", $path);
            }
            // проверка на вшивость -
            if ($OSTYPE == "LINUX") {
                $path = str_replace("\\\\", "\\", $path);
            }
            // проверка на вшивость -xc
            hidekey("stroka" . $a, ${$strokaname});
            hidekey("mask" . $a, ${$maskname});
            hidekey("path" . $a, ${$pathname});
            hidekey("fileforaction" . $a, ${$fileforactionname});
        }
        //lprint ("FMG_CREATE");
        if ($ADM > 0) {
            inputtext("stroka" . $pid, 15, $stroka);
        }
        //<textarea type = text name=stroka<?=$pid  cols= 15 rows=1 wrap=NONE><?=$stroka; </textarea>
        if ($ADM > 0) {
            $hidefolder = $prauth[$ADM][52];
        } else {
            $hidefolder = $pr[73];
        }
        if (!$hidefolder) {
            lprint("FMG_MASK");
            inputtext("mask" . $pid, 15, $mask);
        }
        //<textarea type = text name=mask<?=$pid  cols= 7 rows=1 wrap=NONE><?=$mask; </textarea> <?
        if ($noscreenmode) {
            if ($prauth[$ADM][7]) {
                //FMG.pid удален
                echo "generate cmd{$pid}<br>";
                //$cmdx="cmd".$pid;
                //работает но передает только вторую букву [1] FIXED?
                submitkey("cmd", "FMG_SRCH");
                submitkey("cmd", "FMG_ENTER");
                submitkey("cmd", "FMG_EXIT");
            }
            if ($prauth[$ADM][8]) {
                submitkey("cmd", "FMG_DRV");
                if ($filemgrmod and $prauth[$ADM][2] == true) {
                    submitkey("cmd", "FMG_EXECUTE");
                }
            }
            if ($prauth[$ADM][12]) {
                submitkey("cmd", "FMG_MKDIR");
                submitkey("cmd", "FMG_JOINFIL");
                submitkey("cmd", "FMG_UNZIP");
                submitkey("cmd", "FMG_TEST");
                if ($OSTYPE == "LINUX") {
                    submitkey("cmd", "FMG_UNRAR");
                }
                if ($OSTYPE == "LINUX") {
                    submitkey("cmd", "FMG_RAR");
                }
                submitkey("cmd", "FMG_REN");
                submitkey("cmd", "FMG_EDIT");
                submitkey("cmd", "FMG_NEW");
            }
            if ($prauth[$ADM][13]) {
                submitkey("cmd", "FMG_DELALL");
                submitkey("cmd", "FMG_DEL");
            }
            if ($prauth[$ADM][9]) {
                submitkey("cmd", "FMG_DOWNLOAD");
            }
            if ($prauth[$ADM][36]) {
                submitkey("cmd", "FMG_UPLOAD");
            }
            if ($prauth[$ADM][54]) {
                submitkey("cmd", "FMG_SHARE");
                //	 submitkey ("cmd","FMG_UNSHARE");
            }
            if (!$pr[75]) {
                submitkey("cmd", "FMG_REF");
                submitkey("cmd", "FMG_RESET");
            }
            if (!$hidefolder) {
                submitkey("cmd", "FMG_MASKAPPLY");
            }
            //scripting showkey mechanism
            if ($filscdata) {
                echo "<br>Configured scripts:<br>";
                for ($i = 1; $i < $filsccount; $i++) {
                    // echo "debug $i = $filscdata[$i][$keylanguage]   , key=[$keylanguage]<br>";
                    if ($filscdata[$i][$keylanguage] == "") {
                        continue;
                    }
                    submitkey("cmd", "." . $filscdata[$i][$keylanguage]);
                }
                //  fwrite ($a,"ID¦NAME¦Script¦Plevel¦keynames-icon¦russian¦english¦f1_russian¦f1_english¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦".$addOSenter);
                /*.*1¦mencoder %path%%file% -oac mp3lame -ovc x264 -o %path%%file%.avi¦0¦0¦перекодить в h264¦encode h264¦0¦0¦0¦0¦0
                2¦mencoder %path%%file% -oac mp3lame -ovc mpg -o %path%%file%.avi¦0¦0¦перекодить в mpeg¦encode mpeg¦0¦0¦0¦0¦0¦0
                */
            }
        }
        if ($noscreenmode == false) {
            if ($prauth[$ADM][7]) {
                submitimg("cmd" . $pid, "FMG_SRCH", "_ico/target.png");
                submitimg("cmd" . $pid, "FMG_ENTER", "_ico/openfolder.png");
                submitimg("cmd" . $pid, "FMG_EXIT", "_ico/folderup.png");
            }
            if ($prauth[$ADM][8]) {
                submitimg("cmd" . $pid, "FMG_DRV", "_ico/drv.png");
                submitimg("cmd" . $pid, "FMG_EXECUTE", "_ico/execute.png");
            }
            if ($prauth[$ADM][12]) {
                submitimg("cmd" . $pid, "FMG_MKDIR", "_ico/newfolder.png");
                submitimg("cmd" . $pid, "FMG_REN", "_ico/rename.png");
                submitimg("cmd" . $pid, "FMG_EDIT", "_ico/editfmg.png");
                submitimg("cmd" . $pid, "FMG_NEW", "_ico/newfile.png");
                submitimg("cmd" . $pid, "FMG_JOINFIL", "_ico/joinfiles.png");
                submitimg("cmd" . $pid, "FMG_UNZIP", "_ico/backup.png");
                submitimg("cmd" . $pid, "FMG_TEST", "_ico/apply_f2.png");
                if ($OSTYPE === "LINUX") {
                    submitimg("cmd" . $pid, "FMG_UNRAR", "_ico/backup.png");
                }
                if ($OSTYPE === "LINUX") {
                    submitimg("cmd" . $pid, "FMG_RAR", "_ico/backup.png");
                }
            }
            if ($prauth[$ADM][13]) {
                if ($prauth[$ADM][5] == true) {
                    submitimg("cmd" . $pid, "FMG_DELALL", "_ico/removefolder.png");
                }
                submitimg("cmd" . $pid, "FMG_DEL", "_ico/removefile.png");
            }
            if ($prauth[$ADM][9]) {
                submitimg("cmd" . $pid, "FMG_DOWNLOAD", "_ico/download.png");
            }
            if ($prauth[$ADM][36]) {
                if (!$pr[75]) {
                    submitimg("cmd" . $pid, "FMG_UPLOAD", "_ico/upload.png");
                }
                if ($pr[75]) {
                    submitimg("cmd" . $pid, "FMG_UPLOAD", "_ico/uploadalt.png");
                }
            }
            if ($prauth[$ADM][54]) {
                submitimg("cmd" . $pid, "FMG_SHARE", "_ico/w_accept.png");
                //submitimg ("cmd".$pid,"FMG_UNSHARE","_ico/w_close.png");
            }
            if (!$pr[75]) {
                submitimg("cmd" . $pid, "FMG_REF", "_ico/refresh.png");
                submitimg("cmd" . $pid, "FMG_RESET", "_ico/reset.png");
            }
            if (!$hidefolder) {
                submitimg("cmd" . $pid, "FMG_MASKAPPLY", "_ico/stargreen.png");
            }
        }
        if ($pid == 1 and $prauth[$ADM][12]) {
            // только 1 раз исполняется этот блок .  на 1 пиде.
            echo "<br>";
            echo cmsg("FMG2");
            submitimg("cmd" . $pid, "FMG_CPY_F", "_ico/copyfile.png");
            echo " ";
            submitimg("cmd" . $pid, "FMG_MOV_F", "_ico/movefile.png");
            echo " ";
            //submitimg ("cmd".$pid,"FMG_CPY_FLD","_ico/copyfolder.png");echo " ";
            submitimg("cmd" . $pid, "FMG_MOV_FLD", "_ico/movefolder.png");
            echo " ";
        }
        ?>
 <input type = hidden name = path<?php 
        echo $pid;
        ?>
 value ="<?php 
        echo $path;
        ?>
" >
<?php 
        if ($hidefolder) {
            unset($file);
        }
        //no filelist
        if ($file) {
            echo "<BR>" . cmsg("FMG_FILDB") . ":<select name =fileforaction" . $pid . "[] multiple size = " . $prauth[$ADM][49] . ">";
            sort($file);
            //нет реакции... print_r ($file); echo "Rewefkowe";
            for ($a = 0; $a < $dircnt; $a++) {
                if ($file[$a][0] === ".") {
                    continue;
                }
                if ($file[$a][0] === "..") {
                    continue;
                }
                if ($file[$a][0] === false) {
                    continue;
                }
                if ($file[$a][1]) {
                    $dir = "==>";
                } else {
                    $dir = "";
                }
                $fsizer = "";
                if ($dir !== "==>") {
                    $fsize = $file[$a][2];
                    // settype ($fsizer,"string");
                    if ($fsize < 1024) {
                        $fsizer = "[" . round($fsize, 1) . "b]";
                    }
                    if ($fsize < 1) {
                        $fsizer = "";
                    }
                    if ($fsize > 1024) {
                        $fsizer = "[" . round($fsize / 1024, 1) . "Kb]";
                    }
                    if ($fsize > 1024 * 1024) {
                        $fsizer = "[" . round($fsize / 1024 / 1024, 2) . "Mb]";
                    }
                    if ($fsize > 1024 * 1024 * 1024) {
                        $fsizer = "[" . round($fsize / 1024 / 1024 / 1024, 2) . "Gb]";
                    }
                }
                //$filesizemb=$file[$a][2]/1024;
                echo "<option value=\"" . $file[$a][0] . "\">" . $dir . $file[$a][0] . "" . $fsizer . "</option>";
            }
            // size (".$file[$a][2].")
            if ($pr[11] == 1) {
                //protected cmds
            }
            echo "</select></form>";
        }
        echo "<br>";
        $dbsdiskfree = round((int) (@disk_free_space($path) / (1024 * 1024 * 1024)), 1);
        $dbsdisktotal = (int) (@disk_total_space($path) / (1024 * 1024 * 1024));
        if ($pid == 1) {
            if ($ADM) {
                echo "Selected : Free " . $dbsdiskfree . "Gb ";
            }
            // сделать переключатель дисков или что то вроде указателя
            if ($ADM) {
                echo "\\" . $dbsdisktotal . "Gb<br>";
            }
            $disks = explode(",", $pr[79]);
            for ($a = 0; $a < count($disks); $a++) {
                $diskfree[$a] = round(@disk_free_space($disks[$a]) / (1024 * 1024 * 1024), 1);
                //Gb
                $disktotal[$a] = round(@disk_total_space($disks[$a]) / (1024 * 1024 * 1024), 1);
                //Gb
                if (!$pr[80]) {
                    echo "Disk " . $a . ":: " . $diskfree[$a] . "Gb \\ " . $disktotal[$a] . "Gb.<br>";
                }
                $avgfree = $avgfree + $diskfree[$a];
                $avgtotal = $avgtotal + $disktotal[$a];
            }
            $avgfree = $avgfree;
            $avgtotal = $avgtotal;
            echo " Summary :Free " . $avgfree . "Gb ";
            echo "\\" . $avgtotal . "Gb";
            echo "<br>";
        }
        //only pid 1 shows
    }
    // start menu show
}
function delete_album($del_id)
{
    global $config;
    $sql = "SELECT c.name AS collection_name, a.name AS album_name, a.id AS album_id, c.path AS collection_path, a.path AS album_path\n\t\tFROM " . PLOGGER_TABLE_PREFIX . "albums a, " . PLOGGER_TABLE_PREFIX . "collections c\n\t\tWHERE c.id = a.parent_id AND a.id = '{$del_id}'";
    $result = run_query($sql);
    $album = $result->fetch();
    if (!$album) {
        return array('errors' => plog_tr('No such album'));
    }
    // First delete all pictures registered with this album
    $sql = 'SELECT * FROM ' . PLOGGER_TABLE_PREFIX . 'pictures WHERE parent_album = ' . $album['album_id'];
    $result = run_query($sql);
    while ($row = $result->fetch()) {
        delete_picture($row['id']);
    }
    // XXX: un-register album
    $query = "DELETE FROM " . PLOGGER_TABLE_PREFIX . "albums WHERE \"id\"= '" . $album['album_id'] . "'";
    run_query($query);
    // Finally try to delete the directory itself. It will succeed, if there are no files left inside it ..
    // If there are then .. how did they get there? Probably not through Plogger and in this case do we
    // really want to delete those?
    $source_album_name = SmartStripSlashes($album['album_path']);
    $source_collection_name = SmartStripSlashes($album['collection_path']);
    // Delete any thumbnails for the album
    $album_thumb_directory = $config['basedir'] . 'plog-content/thumbs/' . $source_collection_name . '/' . $source_album_name;
    if (file_exists($album_thumb_directory)) {
        kill_dir($album_thumb_directory);
    }
    // Check to see if the album_directory is a real directory and then try to delete it
    $album_directory = $config['basedir'] . 'plog-content/images/' . $source_collection_name . '/' . $source_album_name;
    if (is_dir($album_directory)) {
        if (!kill_dir($album_directory)) {
            return array('errors' => plog_tr('Album directory still contains files after all pictures have been deleted.'));
        }
    } else {
        return array('errors' => plog_tr('Album has invalid path, not deleting directory.'));
    }
    return array();
}
function fix_open_perms($dirs, $action = 'rename')
{
    if (!empty($dirs)) {
        foreach ($dirs as $key => $dir) {
            if ($action == 'delete') {
                kill_dir(PLOGGER_DIR . 'plog-content/' . $key);
            } else {
                @rename(PLOGGER_DIR . 'plog-content/' . $key, PLOGGER_DIR . 'plog-content/' . $key . '-old');
            }
            makeDirs(PLOGGER_DIR . 'plog-content/' . $key);
        }
    }
}