hsPanel, eli kotisivumuokkain, kansioiden ja tiedostojen käsittelyyn.
Skripti on yhdestä tiedostossa, jotta sen käyttöönotto olisi helpompaa.
kuvat ja käyttöohjeet löytyy täältä (ja ainakin viimeisin versio)
http://koti.mbnet.fi/harpakka/m_hspanel.php
Ominaisuudet:
*Kansioiden ja tiedostojen luonti
*Kansioiden ja tiedostojen listaus
**Sekä "listauskansion" vaihto
*Kohteiden
**Poistaminen (vahvistus)
**Muokkaaminen
**Siirtäminen
**Nimeäminen
**Chmodaaminen
*Upload
Safemode aiheuttaa tietenkin ongelmia, yllätys sinänsä, mm. itse luotuun kansioon ei voi luodu tiedostoja.
->ehotuksia?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi">
<head>
<title>hsPanel v.1.7</title>
<style type="text/css">
body {
padding: 10%;
padding-left: 15%;
padding-right: 15%;
}
.c_table {
width: 100%;
}
.c_td {
padding: 2px;
border: 1px #CCCCCC solid;
font-size: 11px;
font-family: arial;
color: #333333;
}
.l_file {
padding: 2px;
border: 1px #CCCCCC solid;
font-size: 11px;
font-family: arial;
background-color: transparent;
}
.l_dir {
padding: 2px;
border: 1px #CCCCCC solid;
font-size: 11px;
font-family: arial;
background-color: #FFFFC6;
}
input {
font-size: 11px;
font-family: arial;
color: #333333;
padding: 2px;
background-color: #EEEEEE;
}
form {
display: inline;
margin: 0px;
font-size: 11px;
font-family: arial;
color: #333333;
}
.hlight {
font-weight: bold;
color: #000000;
}
a:link {
text-decoration: underline;
color: #333333;
}
a:visited {
text-decoration: underline;
color: #333333;
}
a:active {
text-decoration: underline;
color: #333333;
}
a:hover {
text-decoration: none;
color: #777777;
}
</style>
</head>
<body>
<?php
//http://koti.mbnet.fi/harpakka/m_hspanel.php
//get muuttujat
$act = $_GET['act'];
$dir = $_GET['dir'];
$obj = $_GET['obj'];
$ver = $_GET['ver'];
$x = $_GET['x'];
///post muuttujat
$act2 = $_POST['act2'];
$dir2 = $_POST['dir2'];
$obj2 = $_POST['obj2'];
$x2 = $_POST['x2'];
//katsotaan ettei muuttujia ole lähetetty postina
if ( !isset($act) ) { $act=$act2; }
if ( !isset($dir) ) { $dir=$dir2; }
if ( !isset($obj) ) { $obj=$obj2; }
if ( !isset($x) ) { $x=$x2; }
//tämän tiedoston nimi
$thisfile = $_SERVER['PHP_SELF'];
//jos listauskansiota ei ole, asetetaan sellainen
if ( $dir==null )
{
$dir = "./";
}
//katsotaan että nimi päättyy kauttaviivaan
elseif ( $dir[strlen($dir)-1] != "/" )
{
$dir = "$dir/";
}
//tutkitaan onko kohde tiedosto vai kansio
function vertype($dir,$obj)
{
if ( is_file("$dir{$obj}") == true )
{
return "tiedosto";
}
else
{
return "kansio";
}
}
//pyöristetään tiedoston koko
function roundsize($dir,$obj,$type)
{
if ( $type == 1 )
{
if ( filesize("$dir{$obj}") >= 1024 )
{
$size = "".round(filesize("$dir{$obj}")/1024, 1)."KB";
}
if ( filesize("$dir{$obj}") >= 1048576 )
{
$size = "".round(filesize("$dir{$obj}")/1024/1024, 1)."MB";
}
if ( filesize("$dir{$obj}") < 1024)
{
$size = "".filesize("$dir{$obj}")."B";
}
return $size;
}
else
{
if ( $obj >= 1024 )
{
$size = "".round($obj/1024, 1)."KB";
}
if ( $obj >= 1048576 )
{
$size = "".round($obj/1024/1024, 1)."MB";
}
if ( $obj < 1024)
{
$size = "".$obj."B";
}
return $size;
}
}
//hakemiston tyhjentäjä ja poistaja
function rmvdir($dir)
{
$opendir = opendir("$dir");
while ($file = readdir($opendir))
{
if ( $file != "." && $file != ".." )
{
if ( is_file("$dir{$file}") == true )
{
unlink("$dir{$file}");
}
else
{
rmvdir("$dir{$file}/");
}
if ( is_dir("$dir{$file}") == true )
{
rmdir("$dir{$file}");
}
}
}
}
//haetaan chmod arvo
function chmodv($dir,$obj)
{
return substr(sprintf("%o", fileperms("$dir{$obj}")), -3);
}
//tiedoston/kansion poisto
if ( $act=="rmv" && $ver != "En" && isset($obj) )
{
if ( isset($ver) )
{
if ( is_file("$dir{$obj}") == true )
{
//poistetaan tiedosto
unlink("$dir{$obj}");
}
else
{
//kutsutaan funktiota tyhjentämään kansio
rmvdir("$dir{$obj}/");
//poistetaan kansio
rmdir("$dir{$obj}");
}
}
else
{
//katsotaan onko tiedosto vai kansio
$type = vertype($dir,$obj);
echo "<form method=\"get\" action=\"$thisfile\">\n";
echo "<input type=\"hidden\" name=\"act\" value=\"rmv\" />\n";
echo "<input type=\"hidden\" name=\"dir\" value=\"$dir\" />\n";
echo "<input type=\"hidden\" name=\"obj\" value=\"$obj\" />\n";
echo "Haluatko varmasti poistaa {$type}n $obj: \n";
echo "<input type=\"submit\" name=\"ver\" value=\"Kyllä\" />\n";
echo "<input type=\"submit\" name=\"ver\" value=\"En\" />\n";
echo "</form>\n";
}
}
//tehdään uusi kansio
elseif ( $act=="newdir" && isset($x) )
{
mkdir("$dir{$x}");
}
//tehdään uusi tiedosto
elseif ( $act=="newfile" && isset($x) )
{
$handle = fopen("$dir{$x}", "w");
fclose($handle);
}
//tiedoston siirto
elseif ( $act=="mov" && isset($obj) )
{
if ( isset($x) )
{
//katsotaan että nimi päättyy kauttaviivaan
if ( $x[strlen($x)-1] != "/" )
{
$x = "$x/";
}
//kopioidaan tiedosto ja poistetaan alkuperäinen mikäli se onnistui
copy("$dir{$obj}", "$dir{$x}{$obj}");
if ( file_exists("$dir{$x}{$obj}")==true )
{
unlink("$dir{$obj}");
}
}
else {
//katsotaan onko tiedosto vai kansio
$type = vertype($dir,$obj);
echo "<form method=\"get\" action=\"$thisfile\">\n";
echo "<input type=\"hidden\" name=\"act\" value=\"mov\" />\n";
echo "<input type=\"hidden\" name=\"dir\" value=\"$dir\" />\n";
echo "<input type=\"hidden\" name=\"obj\" value=\"$obj\" />\n";
echo "Kansio johon $type $obj siirretään: <input type=\"text\" name=\"x\" value=\"kansio/\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Siirrä\" />\n";
echo "</form>\n";
}
}
//kansion/tiedoston uudelleennimeäminen
elseif ( $act=="rnm" && isset($obj) )
{
if ( isset($x) )
{
rename("$dir{$obj}", "$dir{$x}");
}
else {
//katsotaan onko tiedosto vai kansio
$type = vertype($dir,$obj);
$type = ucfirst($type);
echo "<form method=\"get\" action=\"$thisfile\">\n";
echo "<input type=\"hidden\" name=\"act\" value=\"rnm\" />\n";
echo "<input type=\"hidden\" name=\"dir\" value=\"$dir\" />\n";
echo "<input type=\"hidden\" name=\"obj\" value=\"$obj\" />\n";
echo "{$type}n $obj uusi nimi: <input type=\"text\" name=\"x\" value=\"nimi\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Nimeä\" />\n";
echo "</form>\n";
}
}
//chmodaus
elseif ( $act=="chm" && isset($obj) )
{
//chmodataan kohde
if ( isset($x) )
{
$x = octdec($x);
chmod("$dir{$obj}", $x);
}
//haetaan uusi/vanha chmod arvo
$chmodv = chmodv($dir,$obj);
//katsotaan onko tiedosto vai kansio
$type = vertype($dir,$obj);
$type = ucfirst($type);
echo "<form method=\"get\" action=\"$thisfile\">\n";
echo "<input type=\"hidden\" name=\"act\" value=\"chm\" />\n";
echo "<input type=\"hidden\" name=\"dir\" value=\"$dir\" />\n";
echo "<input type=\"hidden\" name=\"obj\" value=\"$obj\" />\n";
echo "{$type}n $obj CHMOD -arvo: <input type=\"text\" name=\"x\" value=\"$chmodv\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Aseta\" />\n";
echo "</form>\n";
}
//siirretään upattu tiedosto avattuun kansioon
elseif ( $act=="upload" )
{
move_uploaded_file($_FILES['x2']['tmp_name'], "{$dir}".$_FILES['x2']['name']."");
}
//tiedoston muokkaus
elseif ( $act=="edt" && isset($obj) )
{
//kirjoitetaan uusi tieto
if ( isset($x) )
{
$handle = fopen("$dir{$obj}", "w");
$x = stripslashes($x);
fwrite($handle, $x);
fclose($handle);
}
echo "<form method=\"post\" action=\"$thisfile\">\n";
echo "<input type=\"hidden\" name=\"act2\" value=\"edt\" />\n";
echo "<input type=\"hidden\" name=\"dir2\" value=\"$dir\" />\n";
echo "<input type=\"hidden\" name=\"obj2\" value=\"$obj\" />\n";
echo "<textarea name=\"x2\" rows=\"25\" cols=\"60\">\n";
//haetaan tiedoston sisältö
$data = file("$dir{$obj}");
for ( $i=0; $i<count($data); $i++ )
{
echo htmlentities($data[$i]);
}
echo "</textarea>\n";
echo "$obj\n";
echo "<br />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Muokkaa\" />\n";
echo "<input type=\"reset\" name=\"reset\" value=\"Kumoa\" />\n";
echo "</form>\n";
}
echo "<table class=\"c_table\" style=\"margin-bottom: 10px\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"c_td\" style=\"text-align: center\">\n";
echo "<form method=\"get\" action=\"$thisfile\">\n";
echo "<input type=\"text\" name=\"dir\" value=\"$dir\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Vaihda kansiota\" />\n";
echo "</form>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table class=\"c_table\" cellpadding=\"0\" cellspacing=\"0\">\n";
//haetaan tiedostot/kansiot
$opendir = opendir("$dir");
while ($file = readdir($opendir))
{
if ( $file != "." && $file != ".." )
{
$filelist[] = $file;
}
}
//jos tiedostolista ei ole tyhjä, järjestellään se
if ( $filelist != null )
{
sort($filelist);
}
$a_files = 0; //tiedostojen määrä
$a_files_size = 0; //kaikkien tiedostojen koko
$a_dirs = 0; //kansioiden määrä
for ( $i=0; $i<count($filelist); $i++ )
{
//jos tiedosto...
if ( is_file("$dir{$filelist[$i]}") == true )
{
$type = "Tiedosto";
$a_files = $a_files + 1;
$a_files_size = $a_files_size + filesize("$dir{$filelist[$i]}");
$size = roundsize($dir,$filelist[$i],1);
$css_type = "l_file";
}
//muutoin...
else
{
$type = "Kansio";
$a_dirs = $a_dirs + 1;
$size = "-";
$css_type = "l_dir";
}
//haetaan chmod arvo
$chmodv = chmodv($dir,$filelist[$i]);
echo "<tr>\n";
echo "<td class=\"$css_type\" style=\"width: 55%\"><a href=\"$dir{$filelist[$i]}\" target=\"new\">$filelist[$i]</a></td>\n";
echo "<td class=\"$css_type\" style=\" text-align: right\">$type</td>\n";
echo "<td class=\"$css_type\" style=\" text-align: right\">$size</td>\n";
echo "<td class=\"$css_type\" style=\" text-align: right\">$chmodv</td>\n";
echo "<td class=\"$css_type\" style=\" text-align: right\">\n";
if ( is_dir("$dir{$filelist[$i]}")==true )
{
echo "<a href=\"?dir={$dir}$filelist[$i]/\">A</a>\n";
}
echo "<a href=\"?act=rmv&dir=$dir&obj=$filelist[$i]\">P</a>\n";
if ( is_file("$dir{$filelist[$i]}")==true )
{
echo "<a href=\"?act=edt&dir=$dir&obj=$filelist[$i]\">M</a>\n";
echo "<a href=\"?act=mov&dir=$dir&obj=$filelist[$i]\">S</a>\n";
}
echo "<a href=\"?act=rnm&dir=$dir&obj=$filelist[$i]\">N</a>\n";
echo "<a href=\"?act=chm&dir=$dir&obj=$filelist[$i]\">C</a>\n";
echo "</td>\n";
echo "</tr>\n";
}
//pyöristetään kaikkien tiedostojen koko
$a_files_size = roundsize(0,$a_files_size,0);
echo "<tr>\n";
echo "<td colspan=\"5\" class=\"c_td\" style=\"text-align: right\">\n";
echo "Tiedostoja $a_files, kansioita $a_dirs, vievät tilaa: $a_files_size";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
?>
<table class="c_table" style="margin-top: 10px" cellpadding="0" cellspacing="0">
<tr>
<td class="c_td" style="text-align: center">
<form method="get" action="<?php echo $thisfile; ?>">
<input type="hidden" name="act" value="newfile" />
<input type="hidden" name="dir" value="<?php echo $dir; ?>" />
<input type="text" name="x" value="Uusi tiedosto" />
<input type="submit" name="submit" value="Luo" />
</form>
</td>
<td class="c_td" style="text-align: center">
<form method="post" action="<?php echo $thisfile; ?>" enctype="multipart/form-data">
<input type="hidden" name="act2" value="upload" />
<input type="hidden" name="dir2" value="<?php echo $dir; ?>" />
<input type="file" name="x2" />
<input type="submit" name="submit" value="Upload" />
</form>
</td>
<td class="c_td" style="text-align: center">
<form method="get" action="<?php echo $thisfile; ?>">
<input type="hidden" name="act" value="newdir" />
<input type="hidden" name="dir" value="<?php echo $dir; ?>" />
<input type="text" name="x" value="Uusi kansio" />
<input type="submit" name="submit" value="Luo" />
</form>
</td>
</tr>
<tr>
<td class="c_td">
<a href="<?php echo $thisfile; ?>">Takaisin alkuun</a>
</td>
<td class="c_td" colspan="3" style="text-align: right">
<span class="hlight">A</span>vaa,
<span class="hlight">P</span>oista,
<span class="hlight">M</span>uokkaa,
<span class="hlight">S</span>iirrä,
<span class="hlight">N</span>imeä,
<span class="hlight">C</span>hmodaa
</td>
</tr>
</table>
</body>
</html>Natcasesortti ei jostain syystä toiminut (miksiköhän?, joten oli tyydyttävä tavalliseen sorttiin.
cPanel ei ole hyvä nimi http://cpanel.net/
Ei niin.. vaihdettu
Tiedoston luonti ei onnistu koulun koneella.
EDIT
Samaa warning viestiä heittää mbnetiski.
Tiedosto että kansio jossa se on pitää chmodata 777. Unohtui tuo kansio mainita tuolla..
Entä jos tiedosto on päähakemistossa?
Yksi pieni huono juttu tuossa ainakin on. Sillä voi tutkia vaikka koko koneen jos pistää hakemiston hakusanaksi "/".
Mahtaako tähän olla ratkaisua kellään?
Ratkaisu safe_mode-ongelmaan on luoda hakemisto php:n ftp-funktioiden kautta. Toinen vaihtoehto on tehdä perl-kikkare, joka vaihtaa hakemiston UID:n haluamaksesi.
Miten tuon voi suojata salasanalla? Jos suojaan .htaccess-tiedostolla, ei sivuille pääse kuin salasanan avulla ja jos laitan muokkaimen omaan kansioonsa pystyn muokkaamaan sillä vain sen kansion tiedostoja, en varsinaisia sivuja.
lainaus:
Miten tuon voi suojata salasanalla? Jos suojaan .htaccess-tiedostolla, ei sivuille pääse kuin salasanan avulla ja jos laitan muokkaimen omaan kansioonsa pystyn muokkaamaan sillä vain sen kansion tiedostoja, en varsinaisia sivuja.
Asettamalla tämä ohjelma esim. admin hakemistoon. Lähtöpolun, josta alaspäin selataan, voi määritellä dir-muuttujassa.
lainaus:
Miten tuon voi suojata salasanalla? Jos suojaan .htaccess-tiedostolla, ei sivuille pääse kuin salasanan avulla ja jos laitan muokkaimen omaan kansioonsa pystyn muokkaamaan sillä vain sen kansion tiedostoja, en varsinaisia sivuja.
GLWeb'istä (glweb.org) löytyy pari kappaletta hyviä salasanasuojauksia ja ne toimivat. Jos haluat tiedostoa muokata niin laita sille 777 oikeudet :D
löysin bugin. Jos palvelin on jouluserver ja domain hankittu ja tekee vaikka niin et oma osoite on http://sivu.net ja tekee silleen, et on sivu http://toinen.sivu.net ja tuon toinen.sivu.net kotikansio (yleensä www) on jjj ja ton sivu.net on www. Tuo koodi on tuolla jjj kansiossa ja sitten laittaa kansioksi .. ja ottaa sieltä kansion www ja sieltä avaa jonkun tiedoston (nyt tiedosto on esim.html) niinku sivuna, ei mukattavana, niin se menee huppista keikkaa osoitteeseen http://toinen.sivu.net/www/esim.html
Aika pahasti
Ei toimi linkki kuviin ja käyttöohjeisiin.
Aihe on jo aika vanha, joten et voi enää vastata siihen.