Classes browser, ftp et hta n'ont plus alternc_html en dur
This commit is contained in:
parent
9ec9177350
commit
04462b0cf3
|
@ -84,7 +84,7 @@ while (list($key,$val)=each($r))
|
||||||
<td><label for="del_<?php echo $val["id"]; ?>"><?php echo $val["login"] ?></label>
|
<td><label for="del_<?php echo $val["id"]; ?>"><?php echo $val["login"] ?></label>
|
||||||
<input type='hidden' name='names[<?php echo $val['id'];?>]' value='<?php echo $val["login"] ?>' >
|
<input type='hidden' name='names[<?php echo $val['id'];?>]' value='<?php echo $val["login"] ?>' >
|
||||||
</td>
|
</td>
|
||||||
<td><code><?php echo substr(str_replace(ALTERNC_HTML,'',$val["dir"]),strlen($mem->user['login'])+3) ?></code></td>
|
<td><code><?php echo str_replace(getuserpath(),'', $val["dir"]) ?></code></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ require_once(dirname(__FILE__)."/local.php");
|
||||||
// Define constants from vars of /etc/alternc/local.sh
|
// Define constants from vars of /etc/alternc/local.sh
|
||||||
// The you can't choose where is the AlternC Panel
|
// The you can't choose where is the AlternC Panel
|
||||||
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
|
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
|
||||||
define('ALTERNC_HTML', "$L_ALTERNC_LOC");
|
define('ALTERNC_HTML', "$L_ALTERNC_HTML");
|
||||||
define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
|
define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
|
||||||
define('ALTERNC_PANEL', "/usr/lib/alternc/panel");
|
define('ALTERNC_PANEL', "/usr/lib/alternc/panel");
|
||||||
define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");
|
define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");
|
||||||
|
|
|
@ -218,10 +218,8 @@ function checkuserpath($path) {
|
||||||
* @args string $user the username, if null will use the global $mem. no
|
* @args string $user the username, if null will use the global $mem. no
|
||||||
* security checks performed on path
|
* security checks performed on path
|
||||||
* @returns string the actual absolute path
|
* @returns string the actual absolute path
|
||||||
* @see $L_ALTERNC_LOC
|
|
||||||
*/
|
*/
|
||||||
function getuserpath($user = null) {
|
function getuserpath($user = null) {
|
||||||
global $L_ALTERNC_LOC;
|
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
global $mem;
|
global $mem;
|
||||||
$user = $mem->user['login'];
|
$user = $mem->user['login'];
|
||||||
|
|
|
@ -570,7 +570,7 @@ class m_bro {
|
||||||
* @return boolean != 0 on error
|
* @return boolean != 0 on error
|
||||||
*/
|
*/
|
||||||
function ExtractFile($file, $dest=null) {
|
function ExtractFile($file, $dest=null) {
|
||||||
global $err,$cuid,$mem,$L_ALTERNC_LOC;
|
global $err,$cuid,$mem;
|
||||||
$file = $this->convertabsolute($file,0);
|
$file = $this->convertabsolute($file,0);
|
||||||
if (is_null($dest)) {
|
if (is_null($dest)) {
|
||||||
$dest = dirname($file);
|
$dest = dirname($file);
|
||||||
|
@ -889,7 +889,7 @@ class m_bro {
|
||||||
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
||||||
*/
|
*/
|
||||||
function DownloadZ($dir="") {
|
function DownloadZ($dir="") {
|
||||||
global $mem,$L_ALTERNC_LOC;
|
global $mem;
|
||||||
header("Content-Disposition: attachment; filename=".$mem->user["login"].".Z");
|
header("Content-Disposition: attachment; filename=".$mem->user["login"].".Z");
|
||||||
header("Content-Type: application/x-Z");
|
header("Content-Type: application/x-Z");
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
|
@ -905,7 +905,7 @@ class m_bro {
|
||||||
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
||||||
*/
|
*/
|
||||||
function DownloadTGZ($dir="") {
|
function DownloadTGZ($dir="") {
|
||||||
global $mem,$L_ALTERNC_LOC;
|
global $mem;
|
||||||
header("Content-Disposition: attachment; filename=".$mem->user["login"].".tgz");
|
header("Content-Disposition: attachment; filename=".$mem->user["login"].".tgz");
|
||||||
header("Content-Type: application/x-tgz");
|
header("Content-Type: application/x-tgz");
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
|
@ -921,7 +921,7 @@ class m_bro {
|
||||||
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
||||||
*/
|
*/
|
||||||
function DownloadTBZ($dir="") {
|
function DownloadTBZ($dir="") {
|
||||||
global $mem,$L_ALTERNC_LOC;
|
global $mem;
|
||||||
header("Content-Disposition: attachment; filename=".$mem->user["login"].".tar.bz2");
|
header("Content-Disposition: attachment; filename=".$mem->user["login"].".tar.bz2");
|
||||||
header("Content-Type: application/x-bzip2");
|
header("Content-Type: application/x-bzip2");
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
|
@ -937,7 +937,7 @@ class m_bro {
|
||||||
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
* @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
|
||||||
*/
|
*/
|
||||||
function DownloadZIP($dir="") {
|
function DownloadZIP($dir="") {
|
||||||
global $mem,$L_ALTERNC_LOC;
|
global $mem;
|
||||||
header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip");
|
header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip");
|
||||||
header("Content-Type: application/x-zip");
|
header("Content-Type: application/x-zip");
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
|
@ -1012,7 +1012,7 @@ class m_bro {
|
||||||
*@param : le chemin destination du tarball produit.
|
*@param : le chemin destination du tarball produit.
|
||||||
*/
|
*/
|
||||||
function alternc_export_data($dir){
|
function alternc_export_data($dir){
|
||||||
global $mem,$L_ALTERNC_LOC,$err;
|
global $mem,$err;
|
||||||
$err->log("bro","export_data");
|
$err->log("bro","export_data");
|
||||||
$dir.="html/";
|
$dir.="html/";
|
||||||
if(!is_dir($dir)){
|
if(!is_dir($dir)){
|
||||||
|
|
|
@ -106,15 +106,12 @@ class m_ftp {
|
||||||
* @return array Retourne le tableau des comptes ou FALSE si une erreur s'est produite.
|
* @return array Retourne le tableau des comptes ou FALSE si une erreur s'est produite.
|
||||||
*/
|
*/
|
||||||
function get_list() {
|
function get_list() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid, $bro;
|
||||||
$err->log("ftp","get_list");
|
$err->log("ftp","get_list");
|
||||||
$r=array();
|
$r=array();
|
||||||
$db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' ORDER BY name;");
|
$db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' ORDER BY name;");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
// On passe /var/alternc/html/u/user
|
|
||||||
// FIXME: utiliser getuserpath()
|
|
||||||
$tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match); /* " */
|
|
||||||
$r[]=array(
|
$r[]=array(
|
||||||
"id"=>$db->f("id"),
|
"id"=>$db->f("id"),
|
||||||
"login"=>$db->f("name"),
|
"login"=>$db->f("name"),
|
||||||
|
@ -142,8 +139,10 @@ class m_ftp {
|
||||||
$db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' AND id='$id';");
|
$db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' AND id='$id';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
// FIXME: utiliser getuserpath
|
|
||||||
$tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match);
|
$regexp="/^".preg_quote(getuserpath(),"/")."\/(.*)$/";
|
||||||
|
$tr=preg_match($regexp, $db->f("homedir"),$match);
|
||||||
|
|
||||||
$lg=explode("_",$db->f("name"));
|
$lg=explode("_",$db->f("name"));
|
||||||
if ((!is_array($lg)) || (count($lg)!=2)) {
|
if ((!is_array($lg)) || (count($lg)!=2)) {
|
||||||
$lg[0]=$db->f("name");
|
$lg[0]=$db->f("name");
|
||||||
|
|
|
@ -74,7 +74,7 @@ class m_hta {
|
||||||
* @return boolean TRUE if the folder has been protected, or FALSE if an error occurred
|
* @return boolean TRUE if the folder has been protected, or FALSE if an error occurred
|
||||||
*/
|
*/
|
||||||
function CreateDir($dir) {
|
function CreateDir($dir) {
|
||||||
global $mem,$bro,$err,$L_ALTERNC_LOC;
|
global $mem,$bro,$err;
|
||||||
$err->log("hta","createdir",$dir);
|
$err->log("hta","createdir",$dir);
|
||||||
$absolute=$bro->convertabsolute($dir,0);
|
$absolute=$bro->convertabsolute($dir,0);
|
||||||
if (!$absolute) {
|
if (!$absolute) {
|
||||||
|
@ -117,16 +117,16 @@ class m_hta {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ListDir(){
|
function ListDir(){
|
||||||
global$err,$mem,$L_ALTERNC_LOC;
|
global$err,$mem;
|
||||||
$err->log("hta","listdir");
|
$err->log("hta","listdir");
|
||||||
$sortie=array();
|
$sortie=array();
|
||||||
$absolute="$L_ALTERNC_LOC/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"];
|
$absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"];
|
||||||
exec("find $absolute -name .htpasswd|sort",$sortie);
|
exec("find $absolute -name .htpasswd|sort",$sortie);
|
||||||
if(!count($sortie)){
|
if(!count($sortie)){
|
||||||
$err->raise("hta",_("No protected folder"));
|
$err->raise("hta",_("No protected folder"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$pattern="/^".preg_quote($L_ALTERNC_LOC,"/")."\/html\/.\/[^\/]*\/(.*)\/\.htpasswd/";
|
$pattern="/^".preg_quote(ALTERNC_HTML,"/")."\/.\/[^\/]*\/(.*)\/\.htpasswd/";
|
||||||
for($i=0;$i<count($sortie);$i++){
|
for($i=0;$i<count($sortie);$i++){
|
||||||
preg_match($pattern,$sortie[$i],$matches);
|
preg_match($pattern,$sortie[$i],$matches);
|
||||||
$tmpm=isset($matches[1])?$matches[1]:'';
|
$tmpm=isset($matches[1])?$matches[1]:'';
|
||||||
|
@ -142,9 +142,9 @@ class m_hta {
|
||||||
* @return TRUE if the folder is protected, or FALSE if it is not
|
* @return TRUE if the folder is protected, or FALSE if it is not
|
||||||
*/
|
*/
|
||||||
function is_protected($dir){
|
function is_protected($dir){
|
||||||
global $mem,$err,$L_ALTERNC_LOC;
|
global $mem,$err;
|
||||||
$err->log("hta","is_protected",$dir);
|
$err->log("hta","is_protected",$dir);
|
||||||
$absolute="$L_ALTERNC_LOC/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
|
$absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
|
||||||
$sortie=array();
|
$sortie=array();
|
||||||
if (file_exists("$absolute/.htpasswd")){
|
if (file_exists("$absolute/.htpasswd")){
|
||||||
return true;
|
return true;
|
||||||
|
@ -162,9 +162,9 @@ class m_hta {
|
||||||
* @return array An array containing the list of logins from the .htpasswd file, or FALSE
|
* @return array An array containing the list of logins from the .htpasswd file, or FALSE
|
||||||
*/
|
*/
|
||||||
function get_hta_detail($dir) {
|
function get_hta_detail($dir) {
|
||||||
global $mem,$err,$L_ALTERNC_LOC;
|
global $mem,$err;
|
||||||
$err->log("hta","get_hta_detail");
|
$err->log("hta","get_hta_detail");
|
||||||
$absolute="$L_ALTERNC_LOC/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
|
$absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
|
||||||
if (file_exists("$absolute/.htaccess")) {
|
if (file_exists("$absolute/.htaccess")) {
|
||||||
/* if (!_reading_htaccess($absolute)) {
|
/* if (!_reading_htaccess($absolute)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue