Пример #1
0
                    echo "<option value=" . $file . " selected=selected>" . $file . "</option>\n";
                } else {
                    echo "<option value=" . $file . ">" . $file . "</option>\n";
                }
            }
        }
    }
    closedir($handle);
}
echo "</select></td></tr>";
echo "<tr>\r\n<th>" . $lang['226'] . "</th>\r\n<td><select name=\"inTranslation\" id=\"inTranslation\">";
$handle = @opendir(GetSystemOption('zpanel_root') . "lang");
$chkdir = GetSystemOption('zpanel_root') . "lang/";
if (!$handle) {
    # Log an error as the folder cannot be opened...
    TriggerLog($useraccount['ac_id_pk'], $b = "Was unable to read the Language packs in (" . $chkdir . "), please ensure this folder exists.");
} else {
    while ($file = readdir($handle)) {
        if ($file != "." && $file != ".." && strstr($file, '.php') && !strstr($file, '_override')) {
            if (str_replace(".php", "", $file) == GetSystemOption('zpanel_lang')) {
                echo "<option value=" . str_replace(".php", "", $file) . " selected=selected>" . str_replace(".php", "", $file) . "</option>\n";
            } else {
                echo "<option value=" . str_replace(".php", "", $file) . ">" . str_replace(".php", "", $file) . "</option>\n";
            }
        }
    }
    closedir($handle);
}
echo "</select></td></tr>";
echo "<tr><td ><input type=\"hidden\" name=\"inReturn\" value=\"" . GetFullURL() . "\"><input type=\"submit\" name=\"inSaveTemplate\"value=\"" . $lang['18'] . "\"></td><td></td></tr>";
echo "</table></form>";
Пример #2
0
$row_mysql = mysql_fetch_assoc($mysql);
$totalmysql = DataExchange("t", $z_db_name, $sql);
if ($totalmysql > 0) {
    do {
        $bkcommand = GetSystemOption('mysqldump_exe') . " -h " . $z_db_host . " -u " . $z_db_user . " -p" . $z_db_pass . " --no-create-db " . $row_mysql['my_name_vc'] . " > " . GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql";
        passthru($bkcommand);
        # Add it to the ZIP archive...
        if (ShowServerPlatform() == "Windows") {
            $resault = exec(ChangeSafeSlashesToWin(GetSystemOption('7z_exe') . " u " . GetSystemOption('temp_dir') . $backupname . ".zip " . GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"));
        } else {
            $resault = exec(GetSystemOption('7z_exe') . " " . GetSystemOption('temp_dir') . $backupname . "  " . GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
        }
        unlink(GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
    } while ($row_mysql = mysql_fetch_assoc($mysql));
}
TriggerLog($useraccount['ac_id_pk'], "User full hosting account backup was created.");
if (ShowServerPlatform() == "Windows") {
    # Now we send the output (Windows)...
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Cache-Control: private', false);
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename=' . $backupname . '.zip');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize(GetSystemOption('temp_dir') . $backupname . '.zip ') . '');
    readfile(GetSystemOption('temp_dir') . $backupname . ".zip ");
    unlink(GetSystemOption('temp_dir') . $backupname . ".zip ");
    exit;
} else {
    # Now we send the output (POSIX)...
Пример #3
0
function restartApache()
{
    if (IsWindows() == true) {
        $last_line = exec("C:\\ZPanel\\bin\\apache\\bin\\httpd.exe -k restart -n \"Apache\"", $return);
        TriggerLog(1, $b = "Usage Limiter - Apache restart returned : " . print_r($return) . " : " . $last_line);
    } else {
        $last_line = system("/etc/zpanel/bin/zsudo service " . GetSystemOption('lsn_apache') . " graceful");
        TriggerLog(1, $b = "Usage Limiter - Apache graceful returned : " . $last_line);
    }
}
Пример #4
0
    $obFA->Name = $ExMessageAccount;
    $obFA->MinutesBetweenFetch = $ExMessagecheck;
    $obFA->Port = $ExMessagePort;
    $obFA->ProcessMIMERecipients = $ExMessageMIME;
    $obFA->ProcessMIMEDate = '1';
    $obFA->ServerAddress = $ExMessageAddress;
    $obFA->ServerType = '1';
    $obFA->Username = $ExMessageUser;
    $obFA->UseAntiVirus = '0';
    $obFA->UseAntiSpam = '0';
    $obFA->EnableRouteRecipients = '0';
    $obFA->DaysToKeepMessages = $ExMessageOption;
    $obFA->UseSSL = $ExMessageSSL;
    $Password = $ExMessagePass;
    if (strlen($Password) > 0) {
        $obFA->Password = $Password;
    }
    $obFA->Save();
    $faid = $obFA->ID;
    # Log the action in the database...
    TriggerLog($useraccount['ac_id_pk'], $b = "Added external email acount " . $ExMessageUser . " for mailbox: " . $Usermailbox . "");
    #Life is good, lets inform the user all is ok...
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
if ($_POST['inAction'] == 'filter_mailbox') {
    # Filter the mailbox listing
    $filter = Cleaner('i', $_POST['inFilter']);
    header("location: " . $returnurl . "&r=off&rfilter=" . $filter . "");
    exit;
}
Пример #5
0
    exit;
}
if ($_POST['inAction'] == 'delete') {
    # User has choosen to delete the task...
    do {
        #Check to make sure this isnt a password reset...
        if (isset($_POST['inReset_' . $rowftpaccounts['ft_id_pk']])) {
            header("location: " . GetNormalModuleURL($returnurl) . "&reset=" . $rowftpaccounts['ft_user_vc'] . "");
            exit;
        }
        # Ok so lets just go and delete the FTP account now...
        if (isset($_POST['inDelete_' . $rowftpaccounts['ft_id_pk']])) {
            # Call the API!
            $api_resault = zapi_ftpaccount_remove(GetSystemOption('filezilla_root'), $rowftpaccounts['ft_user_vc']);
            if ($api_resault == false) {
                # The cronjob was not added for some reason!
                TriggerLog($useraccount['ac_id_pk'], $b = "FTP user (" . $rowftpaccounts['ft_user_vc'] . ") could not be fully deleted.");
            } else {
                TriggerLog($useraccount['ac_id_pk'], $b = "FTP user (" . $rowftpaccounts['ft_user_vc'] . ") has been deleted.");
                $reboot = system($filezilla_reload);
            }
            # Remove the FTP account from the MySQL database now..
            $sql = "UPDATE z_ftpaccounts SET ft_deleted_ts=" . time() . " WHERE ft_id_pk=" . $rowftpaccounts['ft_id_pk'] . "";
            DataExchange("w", $z_db_name, $sql);
            # Log the action in the database...
            TriggerLog($useraccount['ac_id_pk'], $b = "User FTP account ID: " . $rowftpaccounts['ft_id_pk'] . " was deleted.");
        }
    } while ($rowftpaccounts = mysql_fetch_assoc($listftpaccounts));
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
Пример #6
0
                    } else {
                        TriggerLog($useraccount['ac_id_pk'], $b = "FTP user (" . $rowftpaccounts['ft_user_vc'] . ") has been deleted.");
                        #$reboot = system($filezilla_reload);
                    }
                    $total_deleted = $total_deleted + 1;
                } while ($rowftpaccounts = mysql_fetch_assoc($listftpaccounts));
                # Then obviously we should go and reload FileZilla's configuration.... Due to removal of FTP accounts!
            }
            $sql = "UPDATE z_ftpaccounts SET ft_deleted_ts=" . time() . " WHERE ft_acc_fk=" . $rowclients['ac_id_pk'] . " AND ft_deleted_ts IS NULL";
            DataExchange("w", $z_db_name, $sql);
            TriggerLog($useraccount['ac_id_pk'], $b = "User account ID: " . $rowclients['ac_id_pk'] . " (" . $total_deleted . "x FTP accounts)  has been deleted!");
            # Delete the user's home directory!
            zapi_filesystem_remove(GetSystemOption('hosted_dir') . $rowclients['ac_user_vc'] . "/");
            TriggerLog($useraccount['ac_id_pk'], $b = "User account ID: " . $rowclients['ac_id_pk'] . " (Home directory and contents for \"" . $rowclients['ac_user_vc'] . "\")  has been deleted!");
            # Delete the user's ZPanel login account
            $sql = "UPDATE z_accounts SET ac_deleted_ts=" . time() . " WHERE ac_id_pk=" . $rowclients['ac_id_pk'] . "";
            $packageid = DataExchange("w", $z_db_name, $sql);
            TriggerLog($useraccount['ac_id_pk'], $b = "User account ID: " . $rowclients['ac_id_pk'] . " (ZPanel login account \"" . $rowclients['ac_user_vc'] . "\")  has been deleted!");
            TriggerLog($useraccount['ac_id_pk'], $b = "User account ID: " . $rowclients['ac_id_pk'] . " has been deleted!");
        }
    } while ($rowclients = mysql_fetch_assoc($listclients));
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
# We reload the FTP server here as there will be the requirement to do so...
if (ShowServerPlatform() == "Windows") {
    $filezilla_reload = GetSystemOption('filezilla_root') . "FileZilla server.exe /reload-config";
} else {
    $filezilla_reload = "/etc/zpanel/bin/zsudo service " . GetSystemOption('lsn_proftpd') . " reload";
}
$reboot = system($filezilla_reload);
Пример #7
0
$newpass = Cleaner("i", $_POST['inNewPass']);
$conpass = Cleaner("i", $_POST['inConPass']);
$doresetmysql = Cleaner("i", $_POST['inResMySQL']);
$returnurl = $_POST['inReturnURL'];
if (md5($current_pass) != $useraccount['ac_pass_vc'] || empty($newpass)) {
    # Current password does not match!
    $endonerror = "&r=error";
} else {
    if ($newpass == $conpass) {
        # Check that the new password matches the confirmation box.
        if ($doresetmysql != '1') {
            # User has selected to update ZPanel account password only!
            $sql = "UPDATE z_accounts SET ac_pass_vc='" . md5($newpass) . "' WHERE ac_id_pk=" . $acc_fk . "";
            DataExchange("w", $z_db_name, $sql);
            TriggerLog($acc_fk, "User has updated their ZPanel account password.");
            $endonerror = "&r=ok";
        } else {
            # User has selected to change both passwords.
            $sql = "UPDATE z_accounts SET ac_pass_vc='" . md5($newpass) . "' WHERE ac_id_pk=" . $acc_fk . "";
            DataExchange("w", $z_db_name, $sql);
            zapi_mysqluser_setpass($useraccount['ac_user_vc'], $newpass, $zdb);
            TriggerLog($acc_fk, "User has updated both their ZPanel and MySQL account passwords.");
            $endonerror = "&r=ok-both";
        }
    } else {
        $endonerror = "&r=error";
    }
}
$returnurl = GetNormalModuleURL($returnurl) . "" . $endonerror . "";
header("location: " . $returnurl . "");
exit;
Пример #8
0
function zapi_shadow_user($username, $userid, $adminname)
{
    # Register the session variables for the user that the admin is shadowing....
    TriggerLog($userid, $b = "User (" . $useraccount['ac_user_vc'] . ") shadowing user (" . $username . ") connecting...");
    $_SESSION['zUsername'] = $username;
    $_SESSION['zUserID'] = $userid;
    header("location: ./");
    exit;
}
Пример #9
0
                    $sql = "UPDATE z_settings SET st_value_tx='http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "' WHERE st_name_vc='login_url';";
                    DataExchange("w", $z_db_name, $sql);
                    header("location: ./index.php");
                    exit;
                } else {
                    $_SESSION['zUsername'] = NULL;
                    $_SESSION['zUserID'] = NULL;
                    unset($_SESSION['zUsername']);
                    unset($_SESSION['zUserID']);
                    header("location: ./login.php?error=noadmin");
                    exit;
                }
            } elseif ($lockdown_option != 1) {
                $_SESSION['zUsername'] = $checklogin['ac_user_vc'];
                $_SESSION['zUserID'] = $checklogin['ac_id_pk'];
                TriggerLog($checklogin['ac_id_pk'], "User has logged into ZPanel.");
                $sql = "UPDATE z_settings SET st_value_tx='http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "' WHERE st_name_vc='login_url';";
                DataExchange("w", $z_db_name, $sql);
                header("location: ./index.php");
                exit;
            }
        } else {
            $_SESSION['zUsername'] = NULL;
            $_SESSION['zUserID'] = NULL;
            unset($_SESSION['zUsername']);
            unset($_SESSION['zUserID']);
            header("location: ./login.php?error=nologin");
            exit;
        }
    }
}
Пример #10
0
        TriggerLog($useraccount['ac_id_pk'], $b = "Was unable to write to the crontab file (" . GetSystemOption('cron_file') . "), check that the file is not read-only and that the file path in the ZPanel settings is correct.");
        header("location: " . GetNormalModuleURL($returnurl) . "&r=error");
        exit;
    }
    # Now we add some infomation to the system log.
    TriggerLog($useraccount['ac_id_pk'], $b = "New cron job has been added by user (" . Cleaner('i', $_POST['inScript']) . ")\rDescription:-\r" . Cleaner('i', $_POST['inDescription']) . "");
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
if ($_POST['inAction'] == 'delete') {
    # User has choosen to delete the task...
    do {
        if (isset($_POST['inDelete_' . $rowtasks['ct_id_pk']])) {
            # Call the API function!
            $api_resault = zapi_cronjob_remove(GetSystemOption('cron_file'), $rowtasks['ct_id_pk']);
            if ($api_resault == false) {
                # The cronjob was not deleted for some reason!
                TriggerLog($useraccount['ac_id_pk'], $b = "Was unable to write to the crontab file (" . GetSystemOption('cron_file') . "), check that the file is not read-only and that the file path in the ZPanel settings is correct.");
                header("location: " . GetNormalModuleURL($returnurl) . "&r=error");
                exit;
            }
            # Do all other account deleted related stuff here!!!
            $sql = "UPDATE z_cronjobs SET ct_deleted_ts=" . time() . " WHERE ct_id_pk=" . $rowtasks['ct_id_pk'] . "";
            DataExchange("w", $z_db_name, $sql);
            # Log the action in the database...
            TriggerLog($useraccount['ac_id_pk'], $b = "User cron job ID: " . $rowtasks['ct_id_pk'] . " was deleted.");
        }
    } while ($rowtasks = mysql_fetch_assoc($listtasks));
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
Пример #11
0
    # Call the API!
    zapi_vhparked_add(GetSystemOption('apache_vhost'), $domain, GetSystemOption('parking_path'));
    # If all has gone well we need to now create the domain in the database...
    $sql = "INSERT INTO z_vhosts (vh_acc_fk,\r\n\t\t\t\t\t\t\t\t\tvh_name_vc,\r\n\t\t\t\t\t\t\t\t\tvh_directory_vc,\r\n\t\t\t\t\t\t\t\t\tvh_type_in,\r\n\t\t\t\t\t\t\t\t\tvh_created_ts) VALUES (\r\n\t\t\t\t\t\t\t\t\t" . $acc_fk . ",\r\n\t\t\t\t\t\t\t\t\t'" . Cleaner('i', $domain) . "',\r\n\t\t\t\t\t\t\t\t\t'" . Cleaner('i', $homedirectoy_to_use) . "',\r\n\t\t\t\t\t\t\t\t\t3,\r\n\t\t\t\t\t\t\t\t\t" . time() . ")";
    DataExchange("w", $z_db_name, $sql);
    # Now we add some infomation to the system log.
    TriggerLog($useraccount['ac_id_pk'], $b = "New parked domain has been added by the user (" . Cleaner('i', $_POST['inDomain']) . ").");
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
if ($_POST['inAction'] == 'delete') {
    # User has choosen to delete the task...
    do {
        if (isset($_POST['inDelete_' . $rowdomains['vh_id_pk']])) {
            # Log the action in the database...
            TriggerLog($useraccount['ac_id_pk'], $b = "User domain vhost ID: " . $rowdomains['ct_id_pk'] . " was deleted.");
            # Call the API
            zapi_vhost_remove(GetSystemOption('apache_vhost'), $rowdomains['vh_name_vc']);
            # Check to see if version IS Windows (If so use the default hMailServer and create domain) - Otherwise we skip it!
            if (ShowServerPlatform() == 'Windows') {
                # Lets now go and try removing the domain from hMailServer (if configured in the ZPanel system settings:-
                $hmaildatabase = GetSystemOption('hmailserver_db');
                if (GetSystemOption('hmailserver_db') != "") {
                    # Lets delete all hMailServer accounts...
                    $sql = "SELECT domainid FROM hm_domains WHERE domainname='" . $rowdomains['vh_name_vc'] . "'";
                    $hmdomainid = DataExchange("l", $hmaildatabase, $sql);
                    $hmisdomain = DataExchange("t", $hmaildatabase, $sql);
                    $domain_id = $hmdomainid['domainid'];
                    # Lets delete the domain (if it exists in the hMailServer database....
                    if ($hmisdomain > 0) {
                        # Delete the domain now...
Пример #12
0
        DataExchange("w", $z_db_name, $sql);
        # Now we have to add the entry to the cron file.
        # Now we add some infomation to the system log.
        TriggerLog($useraccount['ac_id_pk'], $b = "New MySQL database added by user (" . Cleaner('i', $_POST['inDatabase']) . ").");
        header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    } else {
        header("location: " . GetNormalModuleURL($returnurl) . "&r=exists");
    }
    exit;
}
if ($_POST['inAction'] == 'delete') {
    # User has choosen to delete the task...
    do {
        if (isset($_POST['inDelete_' . $rowmysql['my_id_pk']])) {
            # Ok so lets drop the MySQL database...
            $api_resault = zapi_mysqldb_remove($rowmysql['my_name_vc'], $zdb);
            if ($api_resault == false) {
                # The cronjob was not added for some reason!
                TriggerLog($useraccount['ac_id_pk'], $b = "Unable to remove mysql database (" . $rowmysql['my_name_vc'] . ").");
            }
            # Log the action in the database...
            TriggerLog($useraccount['ac_id_pk'], $b = "User MySQL Database ID: " . $rowmysql['my_id_pk'] . " was deleted.");
            # Do all other account deleted related stuff here!!!
            $sql = "UPDATE z_mysql SET my_deleted_ts=" . time() . " WHERE my_id_pk=" . $rowmysql['my_id_pk'] . "";
            DataExchange("w", $z_db_name, $sql);
            # Now we do the rest, which is to go and delete the cron entry from the file...
        }
    } while ($rowmysql = mysql_fetch_assoc($listmysql));
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
Пример #13
0
    if ($inUseFT == 1) {
        $inUseFT = "On";
    } else {
        $inUseFT = "Off";
    }
    if (!file_exists(GetSystemOption('mod_bw') . "mod_bw/")) {
        mkdir(GetSystemOption('mod_bw') . "mod_bw/", 0777);
        if (ShowServerPlatform() != "Windows") {
            @chmod(GetSystemOption('mod_bw') . "mod_bw/", 0777);
        }
    }
    $file = GetSystemOption('mod_bw') . "mod_bw/mod_bw_" . $rowpackages['pk_name_vc'] . ".conf";
    if ($inUseFT == "On") {
        $body = "BandwidthModule " . $inUseBT . "\r\nForceBandWidthModule " . $inUseBT . "\r\nBandwidth all " . $inMaxBW . "\r\nMinBandwidth all " . $inMinBW . "\r\nMaxConnection all " . $inMaxCon . "\r\nLargeFileLimit * " . $inDLsize . " " . $inDLspeed . "\r\nBandWidthError 510";
    } else {
        $body = "BandwidthModule " . $inUseBT . "\r\nForceBandWidthModule " . $inUseBT . "\r\nBandwidth all " . $inMaxBW . "\r\nMinBandwidth all " . $inMinBW . "\r\nMaxConnection all " . $inMaxCon . "\r\nBandWidthError 510";
    }
    $fp = @fopen($file, 'w');
    fwrite($fp, $body);
    fclose($fp);
    if (ShowServerPlatform() != "Windows") {
        @chmod($file, 0777);
    }
    # Log the package as modified so the daemon will make changes to vhosts.
    $sql = "UPDATE z_quotas SET qt_modified_in = 1 WHERE qt_id_pk = " . $inQuotaID . "";
    DataExchange("w", $z_db_name, $sql);
    # Now we add some infomation to the system log.
    TriggerLog($useraccount['ac_id_pk'], $b = "Bandwidth Throttle settings updated for package id: " . qt_id_pk . " ");
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}