Example #1
0
} else {
    $resault = exec(GetSystemOption('7z_exe') . " -r9 " . GetSystemOption('temp_dir') . $backupname . " " . $homedir . "/*");
    @chmod(GetSystemOption('temp_dir') . $backupname . ".zip", 0777);
}
# Now lets backup all MySQL datbases for the user and add them to the archive...
$sql = "SELECT * FROM z_mysql WHERE my_acc_fk=" . $useraccount['ac_id_pk'] . " AND my_deleted_ts IS NULL";
$mysql = DataExchange("r", $z_db_name, $sql);
$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');
Example #2
0
# Generates Webalizer stats for the domain!                                                                                         #
#####################################################################################################################################
$sql = "SELECT * FROM z_vhosts LEFT JOIN z_accounts ON z_vhosts.vh_acc_fk=z_accounts.ac_id_pk WHERE vh_deleted_ts IS NULL";
$domains = DataExchange("r", $z_db_name, $sql);
$row_domains = mysql_fetch_assoc($domains);
$totalRows_domains = DataExchange("t", $z_db_name, $sql);
if ($totalRows_domains > 0) {
    do {
        # Check to ensure folders exists ready for the webalizer reports etc....
        if (!file_exists(GetSystemOption('webalizer_reps') . $row_domains['ac_user_vc'] . "")) {
            @mkdir(GetSystemOption('webalizer_reps') . $row_domains['ac_user_vc'] . "", 777);
        }
        if (!file_exists(GetSystemOption('webalizer_reps') . $row_domains['ac_user_vc'] . "/" . $row_domains['vh_name_vc'])) {
            @mkdir(GetSystemOption('webalizer_reps') . $row_domains['ac_user_vc'] . "/" . $row_domains['vh_name_vc'], 777);
        }
        $runcommand = ChangeSafeSlashesToWin(GetSystemOption('webalizer_exe') . " -o " . GetSystemOption('webalizer_reps') . $row_domains['ac_user_vc'] . "/" . $row_domains['vh_name_vc'] . " -d -F clf -n " . $row_domains['vh_name_vc'] . "  " . GetSystemOption('logfile_dir') . $row_domains['ac_user_vc'] . "/" . $row_domains['vh_name_vc'] . "-access.log");
        system($runcommand);
        echo "<br>" . $runcommand;
    } while ($row_domains = mysql_fetch_assoc($domains));
    TriggerLog(1, $b = "> Webalizer domain statistics have been generated.");
}
#####################################################################################################################################
# Just log to say that the ZPanel daemon has finished doing its tasks...                                                            #
#####################################################################################################################################
TriggerLog(1, $b = "= ZPanel daemon finished execution....");
#####################################################################################################################################
# Send data to a zCommander server if one has been specified! - Added in ZPanel 5.1.0                                               #
#####################################################################################################################################
if (GetSystemOption('zms_host') != "") {
    # Get hosting resource totals...
    $sql = "SELECT COUNT(*) AS tvalue FROM z_accounts WHERE ac_deleted_ts IS NULL;";
Example #3
0
    if ($_POST['inAccess'] == 'RO') {
        $permissionset = "<Option Name=\"FileRead\">1</Option>\r\n\t<Option Name=\"FileWrite\">0</Option>\r\n\t<Option Name=\"FileDelete\">0</Option>\r\n\t<Option Name=\"FileAppend\">0</Option>\r\n\t<Option Name=\"DirCreate\">0</Option>\r\n\t<Option Name=\"DirDelete\">0</Option>\r\n\t<Option Name=\"DirList\">1</Option>\r\n\t<Option Name=\"DirSubdirs\">1</Option>";
        $accessmode = "Read access";
    }
    if ($_POST['inAccess'] == 'WO') {
        $permissionset = "<Option Name=\"FileRead\">0</Option>\r\n\t<Option Name=\"FileWrite\">1</Option>\r\n\t<Option Name=\"FileDelete\">0</Option>\r\n\t<Option Name=\"FileAppend\">0</Option>\r\n\t<Option Name=\"DirCreate\">1</Option>\r\n\t<Option Name=\"DirDelete\">0</Option>\r\n\t<Option Name=\"DirList\">0</Option>\r\n\t<Option Name=\"DirSubdirs\"0</Option>";
        $accessmode = "Write access";
    }
    if ($_POST['inAccess'] == 'RW') {
        $permissionset = "<Option Name=\"FileRead\">1</Option>\r\n\t<Option Name=\"FileWrite\">1</Option>\r\n\t<Option Name=\"FileDelete\">1</Option>\r\n\t<Option Name=\"FileAppend\">1</Option>\r\n\t<Option Name=\"DirCreate\">1</Option>\r\n\t<Option Name=\"DirDelete\">1</Option>\r\n\t<Option Name=\"DirList\">1</Option>\r\n\t<Option Name=\"DirSubdirs\">1</Option>";
        $accessmode = "Full access";
    }
    $permission = "ALL";
    $status = 1;
    # Call the API!
    $api_resault = zapi_ftpaccount_add(GetSystemOption('filezilla_root'), $username, $password, GetSystemOption('zpanel_version'), ChangeSafeSlashesToWin(GetSystemOption('hosted_dir') . $useraccount['ac_user_vc'] . $homedirectoy_to_use), $permissionset);
    if ($api_resault == false) {
        # FTP account was not added!
    } else {
        $reboot = system($filezilla_reload);
    }
    # If all has gone well we need to now create the domain in the database...
    $sql = "INSERT INTO z_ftpaccounts (ft_acc_fk,\r\n\t\t\t\t\t\t\t\t\t\tft_user_vc,\r\n\t\t\t\t\t\t\t\t\t\tft_directory_vc,\r\n\t\t\t\t\t\t\t\t\t\tft_access_vc,\r\n\t\t\t\t\t\t\t\t\t\tft_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', $username) . "',\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\t'" . Cleaner('i', $access_type) . "',\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 FTP account has been added by the user (" . Cleaner('i', $username) . ").");
    header("location: " . GetNormalModuleURL($returnurl) . "&r=ok");
    exit;
}
if ($_POST['inAction'] == 'reset') {
    $sql = "SELECT * FROM z_ftpaccounts WHERE ft_user_vc='" . $_POST['inAccount'] . "' AND ft_acc_fk=" . $acc_fk . " AND ft_deleted_ts IS NULL";
Example #4
0
 # Create the domain logs folder read for Apache...
 zapi_filesystem_add(GetSystemOption('logfile_dir') . $username . "/");
 # Create a default FTP account if set in the system options...
 if (GetSystemOption('auto_ftpuser') == "true") {
     # Get the current account ID for the new user...
     $acc_fk = $clientid['ac_id_pk'];
     $password = $_POST['inPassword'];
     $access_type = "RW";
     $homedirectoy_to_use = "/";
     # Just need to check that an account doesnt already exist with the same username....
     $sql = "SELECT * FROM z_ftpaccounts WHERE ft_user_vc='" . Cleaner('i', $username) . "' AND ft_deleted_ts IS NULL";
     $existsftp = DataExchange("t", $z_db_name, $sql);
     $permissionset = "\t\t<Option Name=\"FileRead\">1</Option>\r\n\t\t<Option Name=\"FileWrite\">1</Option>\r\n\t\t<Option Name=\"FileDelete\">1</Option>\r\n\t\t<Option Name=\"FileAppend\">1</Option>\r\n\t\t<Option Name=\"DirCreate\">1</Option>\r\n\t\t<Option Name=\"DirDelete\">1</Option>\r\n\t\t<Option Name=\"DirList\">1</Option>\r\n\t\t<Option Name=\"DirSubdirs\">1</Option>";
     if ($existsftp < 1) {
         if (ShowServerPlatform() == 'Windows') {
             zapi_ftpaccount_add(GetSystemOption('filezilla_root'), $username, $password, GetSystemOption('zpanel_version'), ChangeSafeSlashesToWin(GetSystemOption('hosted_dir') . $username), $permissionset);
         } else {
             zapi_ftpaccount_add(GetSystemOption('filezilla_root'), $username, $password, GetSystemOption('zpanel_version'), ChangeWinSlashesToNIX(GetSystemOption('hosted_dir') . $username), $permissionset);
         }
         # If all has gone well we need to now create the domain in the database...
         $sql = "INSERT INTO z_ftpaccounts (ft_acc_fk,\r\n\t\t\t\t\t\t\t\t\t\t\tft_user_vc,\r\n\t\t\t\t\t\t\t\t\t\t\tft_directory_vc,\r\n\t\t\t\t\t\t\t\t\t\t\tft_access_vc,\r\n\t\t\t\t\t\t\t\t\t\t\tft_created_ts) VALUES (\r\n\t\t\t\t\t\t\t\t\t\t" . $acc_fk . ",\r\n\t\t\t\t\t\t\t\t\t\t'" . Cleaner('i', $username) . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . Cleaner('i', "/") . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . Cleaner('i', "RW") . "',\r\n\t\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 FTP account has been created for the new user (" . Cleaner('i', $username) . ").");
     } else {
         TriggerLog($useraccount['ac_id_pk'], $b = "> Could not auto create new FTP user (" . Cleaner('i', $username) . ") as a duplicate account exists on the server.");
     }
 }
 # Send the user account details via. email (if requested)...
 if ($_POST['inSWE'] == 1) {
     if ($_POST['inEmailAddress'] != '') {
Example #5
0
 } else {
     if (!is_file(RemoveDoubleSlash(GetSystemOption('hosted_dir') . $useraccount['ac_user_vc'] . '/' . $_POST['inScript']))) {
         //echo GetSystemOption('hosted_dir').$useraccount['ac_user_vc'].'/'.$_POST['inScript'];
         header("location: " . GetNormalModuleURL($returnurl) . "&r=noexists");
         exit;
     }
 }
 # If the user submitted a 'new' request then we will simply add the cron task to the database...
 $sql = "INSERT INTO z_cronjobs (ct_acc_fk,\r\n\t\t\t\t\t\t\t\t\tct_script_vc,\r\n\t\t\t\t\t\t\t\t\tct_description_tx,\r\n\t\t\t\t\t\t\t\t\tct_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', $_POST['inScript']) . "',\r\n\t\t\t\t\t\t\t\t\t'" . Cleaner('i', $_POST['inDescription']) . "',\r\n\t\t\t\t\t\t\t\t\t" . time() . ")";
 DataExchange("w", $z_db_name, $sql);
 # Now we are going to pull back the cron ID to use it as an ancor point.
 $sql = "SELECT * FROM z_cronjobs WHERE ct_acc_fk=" . $acc_fk . " ORDER BY ct_id_pk DESC";
 $cronid = DataExchange("l", $z_db_name, $sql);
 # Call the API function!
 if (ShowServerPlatform() == 'Windows') {
     $api_resault = zapi_cronjob_add(GetSystemOption('cron_file'), $cronid['ct_id_pk'], $_POST['inTiming'], ChangeSafeSlashesToWin(GetSystemOption('php_exer')), RemoveDoubleSlash(ChangeSafeSlashesToWin(GetSystemOption('hosted_dir') . $useraccount['ac_user_vc'] . '/' . $_POST['inScript'])));
 } else {
     $api_resault = zapi_cronjob_add(GetSystemOption('cron_file'), $cronid['ct_id_pk'], $_POST['inTiming'], GetSystemOption('php_exer'), RemoveDoubleSlash(GetSystemOption('hosted_dir') . $useraccount['ac_user_vc'] . '/' . $_POST['inScript']));
 }
 if ($api_resault == false) {
     # The cronjob was not added for some reason!
     # We will remove the cron id from the database so it will not show as active.
     $sql = "UPDATE z_cronjobs SET ct_deleted_ts=" . time() . " WHERE ct_id_pk=" . $cronid['ct_id_pk'] . "";
     DataExchange("w", $z_db_name, $sql);
     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");