?> </label> <input type='hidden' name='names[<?php echo $val['id']; ?> ]' value='<?php echo $val["login"]; ?> ' /> </td> <td> <a href="bro_main.php?R=<?php echo urlencode(str_replace(getuserpath(), '', $val["dir"])); ?> "><code><?php echo str_replace(getuserpath(), '', $val["dir"]); ?> </code></a> <?php if (!file_exists($val['dir'])) { echo " <span class=\"alerte\">" . _("Directory not found") . "</span>"; } ?> </td> </tr> <?php } ?> </table> <p><input type="submit" name="submit" class="inb delete" value="<?php __("Delete checked accounts");
/** Returns the details of a user's database. * $dbn is the name of the database (after the _) or nothing for the database "$user" * @return string returns an associative array as follow : * "db" => Name of the database * "bck" => Current bckup mode * "dir" => Backup directory * "size" => Size of the database (in bytes) * "pass" => Password of the user * "history" => Number of backup we keep * "gzip" => Does we compress the dumps ? * Returns FALSE if the user has no database of if the database does not exist. */ function get_mysql_details($dbn) { global $db, $err, $bro, $mem, $cuid; $root = getuserpath(); $err->log("mysql", "get_mysql_details"); $pos = strpos($dbn, '_'); if ($pos === false) { $dbname = $dbn; } else { $dbncomp = explode('_', $dbn); $dbname = $dbn; $dbn = $dbncomp[1]; } $size = $this->get_db_size($dbname); $db->query("SELECT login,pass,db, bck_mode, bck_gzip, bck_dir, bck_history FROM db WHERE uid='{$cuid}' AND db='{$dbname}';"); if (!$db->num_rows()) { $err->raise("mysql", _("Database %s not found"), $dbn); return array("enabled" => false); } $db->next_record(); list($dbu, $dbn) = split_mysql_database_name($db->f("db")); return array("enabled" => true, "login" => $db->f("login"), "db" => $db->f("db"), "name" => $dbn, "bck" => $db->f("bck_mode"), "dir" => substr($db->f("bck_dir"), strlen($root)), "size" => $size, "pass" => $db->f("pass"), "history" => $db->f("bck_history"), "gzip" => $db->f("bck_gzip")); }
/** * Generate apache configuration. * Die if a specific FQDN have 2 vhost conf. * * */ function generate_apacheconf($p = null) { // Get the parameters $lst = $this->generation_parameters($p); $gdt = $this->generation_domains_type(); // Initialize duplicate check $check_dup = array(); $ret = "## AlternC Generated conf\n"; foreach ($lst as $p) { // Check if duplicate if (in_array($p['fqdn'], $check_dup)) { die("Error: duplicate fqdn : " . $p['fqdn']); } else { $check_dup[] = $p['fqdn']; } // Get the needed template $tpl = $gdt[$p['type']]['tpl']; // Replace needed vars $tpl = strtr($tpl, array("%%LOGIN%%" => $p['login'], "%%fqdn%%" => $p['fqdn'], "%%document_root%%" => getuserpath($p['login']) . $p['valeur'], "%%account_root%%" => getuserpath($p['login']), "%%redirect%%" => $p['valeur'], "%%UID%%" => $p['uid'], "%%GID%%" => $p['uid'], "%%mail_account%%" => $p['mail'], "%%user%%" => "FIXME")); // Security check if ($p['uid'] < 1999) { // if UID is not an AlternC uid $ret .= "# ERROR: Sub_id: " . $p['sub_id'] . "- The uid seem to be dangerous\n"; continue; } // Return the conf $ret .= "# Sub_id: " . $p['sub_id'] . "\n" . $tpl; } return $ret; }
_subbrowse($curdir, $next, $level + 1); } } } /** * @param string $curdir */ function browseforfolder($curdir) { global $maxlevel, $root, $brlist; $maxlevel = 0; $brlist = array(array("dir" => "/", "level" => 0, "put" => ife($curdir == "/", "", "/"))); _subbrowse($curdir, 0, 1); return $brlist; } $root = getuserpath(); // pour utiliser 'la ou est browseforfolder', mettre dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"]); if (substr($file, 0, 1) != "/") { $file = "/" . $file; } if (substr($file, -1) != "/") { $file .= "/"; } if (!$file) { $file = "/"; } $errbrowsefold = 0; /* Erreur lors de la création d'un dossier */ $brlist = array(); /* Liste des dossiers ... */ $maxlevel = 0;
/** Deletes an account * Deletes the specified account. Prevents any manipulation of the account if * the account $mid is not super-admin. * * @global m_err $err * @global m_quota $quota * @global array $classes * @global int $cuid * @global m_mem $mem * @global m_dom $dom * @global m_hooks $hooks * @global m_action $action * @param int $uid The uid number of the account * @return boolean Returns FALSE if an error occurs, TRUE if not. */ function del_mem($uid) { global $err, $quota, $classes, $cuid, $mem, $dom, $hooks, $action; $err->log("admin", "del_mem", $uid); if (!$this->enabled) { $err->raise("admin", _("-- Only administrators can access this page! --")); return false; } $db = new DB_System(); $tt = $this->get($uid); $mem->su($uid); // This script may take a long time on big accounts, let's give us some time ... Fixes 1132 @set_time_limit(0); // WE MUST call m_dom before all others because of conflicts ... $dom->hook_admin_del_member(); # New way of deleting or backup delted user html folders using action class $path = getuserpath($tt['login']); $action->archive($path); $hooks->invoke("alternc_del_member"); $hooks->invoke("hook_admin_del_member"); if ($db->query("DELETE FROM membres WHERE uid='{$uid}';") && $db->query("DELETE FROM local WHERE uid='{$uid}';")) { $mem->unsu(); // If this user was (one day) an administrator one, he may have a list of his own accounts. Let's associate those accounts to nobody as a creator. $db->query("UPDATE membres SET creator=2000 WHERE creator='{$uid}';"); return true; } else { $err->raise("admin", _("Account not found")); $mem->unsu(); return false; } }
/** * Function d'exportation des données appelé par la classe m_export via un hooks * * @global m_mem $mem * @global m_err $err * @param string $dir Le chemin destination du tarball produit * @return boolean|null */ function alternc_export_data($dir) { global $mem, $err; $err->log("bro", "export_data"); $dir .= "html/"; if (!is_dir($dir)) { if (!mkdir($dir)) { $err->raise("bro", _("Cannot create the requested directory. Please check the permissions")); } } $timestamp = date("H:i:s"); // relacher le lock global sinon ce download va geler alternc pour // tout le monde alternc_shutdown(); if (exec("/bin/tar cvf - " . getuserpath() . "/ | gzip -9c > " . $dir . "/" . $mem->user['login'] . "_html_" . $timestamp . ".tar.gz")) { $err->log("bro", "export_data_succes"); } else { $err->log("bro", "export_data_failed"); } }
/** Retourne TRUE si $dir possède un compte FTP * @param string $dir Dossier à tester, relatif à la racine du compte courant * @return boolean retourne TRUE si $dir à un compte FTP, FALSE sinon. */ function is_ftp($dir) { global $mem, $db, $err; $err->log("ftp", "is_ftp", $dir); if (substr($dir, 0, 1) == "/") { $dir = substr($dir, 1); } $db->query("SELECT id FROM ftpusers WHERE homedir='" . getuserpath() . "/{$dir}';"); if ($db->num_rows()) { $db->next_record(); return $db->f("id"); } else { return false; } }
/** * * @global m_mem $mem * @param string $path * @return int * return 0 if the path is not in the user's space * return 1 if this is a directory * return 2 if this is a regular file */ function checkuserpath($path) { global $mem; $user = $mem->user["login"]; $usar = substr($user, 0, 1); if (substr($path, 0, 1) != "/") { $path = "/" . $path; } $rpath = realpath(ALTERNC_HTML . "/{$usar}/{$user}{$path}"); if (!$rpath) { // if file or directory does not exist return 1; // FIXME is it safe to say OK in this case ? } $userpath = getuserpath(); if (strpos($rpath, $userpath) === 0) { if (is_dir(ALTERNC_HTML . "/{$usar}/{$user}{$path}")) { return 1; } if (is_file(ALTERNC_HTML . "/{$usar}/{$user}{$path}")) { return 2; } } return 0; }