function TemplateReplace($content, $bodycontent, $template_path, $useraccount, $packageinfo, $quotainfo, $permissionset, $personalinfo) { include 'conf/zcnf.php'; include 'lang/' . GetSystemOption('zpanel_lang') . '.php'; $fileContents = str_replace('{{usage:domains}}', GetQuotaUsages('domains', $useraccount['ac_id_pk']), $content); $fileContents = str_replace('{{usage:subdomains}}', GetQuotaUsages('subdomains', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:parkeddomains}}', GetQuotaUsages('parkeddomains', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:mailboxes}}', GetQuotaUsages('mailboxes', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:forwarders}}', GetQuotaUsages('forwarders', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:distlists}}', GetQuotaUsages('distlists', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:ftpaccounts}}', GetQuotaUsages('ftpaccounts', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:mysql}}', GetQuotaUsages('mysql', $useraccount['ac_id_pk']), $fileContents); $fileContents = str_replace('{{usage:diskspace}}', FormatFileSize(GetQuotaUsages('diskspace', $useraccount['ac_id_pk'])), $fileContents); $fileContents = str_replace('{{usage:bandwidth}}', FormatFileSize(GetQuotaUsages('bandwidth', $useraccount['ac_id_pk'])), $fileContents); $fileContents = str_replace('{{quota:domains}}', $quotainfo['qt_domains_in'], $fileContents); $fileContents = str_replace('{{quota:subdomains}}', $quotainfo['qt_subdomains_in'], $fileContents); $fileContents = str_replace('{{quota:parkeddomains}}', $quotainfo['qt_parkeddomains_in'], $fileContents); $fileContents = str_replace('{{quota:mailboxes}}', $quotainfo['qt_mailboxes_in'], $fileContents); $fileContents = str_replace('{{quota:forwarders}}', $quotainfo['qt_fowarders_in'], $fileContents); $fileContents = str_replace('{{quota:distlists}}', $quotainfo['qt_distlists_in'], $fileContents); $fileContents = str_replace('{{quota:ftpaccounts}}', $quotainfo['qt_ftpaccounts_in'], $fileContents); $fileContents = str_replace('{{quota:mysql}}', $quotainfo['qt_mysql_in'], $fileContents); $fileContents = str_replace('{{quota:diskspace}}', FormatFileSize($quotainfo['qt_diskspace_bi']), $fileContents); $fileContents = str_replace('{{quota:bandwidth}}', FormatFileSize($quotainfo['qt_bandwidth_bi']), $fileContents); $fileContents = str_replace('{{progbar:diskspace}}', "<img src=\"inc/zProgressBar.php?used=" . GetQuotaUsages('diskspace', $useraccount['ac_id_pk']) . "&total=" . $quotainfo['qt_diskspace_bi'] . "\">", $fileContents); $fileContents = str_replace('{{progbar:bandwidth}}', "<img src=\"inc/zProgressBar.php?used=" . GetQuotaUsages('bandwidth', $useraccount['ac_id_pk']) . "&total=" . $quotainfo['qt_bandwidth_bi'] . "\">", $fileContents); $fileContents = str_replace('{{server:company}}', GetSystemOption('sever_company'), $fileContents); $fileContents = str_replace('{{server:serverip}}', $_SERVER['SERVER_ADDR'], $fileContents); $fileContents = str_replace('{{server:userip}}', $_SERVER['REMOTE_ADDR'], $fileContents); $fileContents = str_replace('{{server:uptime}}', GetServerUptime(), $fileContents); $fileContents = str_replace('{{server:verapache}}', ShowApacheVersion(), $fileContents); $fileContents = str_replace('{{server:verphp}}', ShowPHPVersion(), $fileContents); $fileContents = str_replace('{{server:verkernal}}', ShowKernelVersion(ShowServerPlatform()), $fileContents); $fileContents = str_replace('{{server:vermysql}}', ShowMySQLVersion(), $fileContents); $fileContents = str_replace('{{server:veros}}', ShowServerPlatform(), $fileContents); $fileContents = str_replace('{{server:osname}}', ShowServerOSName(), $fileContents); $fileContents = str_replace('{{server:oslogo}}', "<img src=\"lib/emblems/os_icons/" . ShowServerOSName() . ".png\" title=\"This server is running " . ShowServerOSName() . "\">", $fileContents); $fileContents = str_replace('{{server:verzpanel}}', GetSystemOption('zpanel_version'), $fileContents); $fileContents = str_replace('{{link:home}}', "<a href=\"./\">" . $lang['215'] . "</a>", $fileContents); $fileContents = str_replace('{{link:logout}}', "<a href=\"./login.php?logout\">" . $lang['216'] . "</a>", $fileContents); $fileContents = str_replace('{{zp:templatepath}}', $template_path, $fileContents); $fileContents = str_replace('{{account:username}}', $useraccount['ac_user_vc'], $fileContents); $fileContents = str_replace('{{account:email}}', $personalinfo['ap_email_vc'], $fileContents); $fileContents = str_replace('{{account:created}}', date(GetSystemOption('zpanel_df'), $useraccount['ac_created_ts']), $fileContents); $fileContents = str_replace('{{account:fullname}}', $personalinfo['ap_fullname_vc'], $fileContents); $fileContents = str_replace('{{package:name}}', $packageinfo['pk_name_vc'], $fileContents); $fileContents = str_replace('{{account:type}}', ShowAccountType($permissionset), $fileContents); $fileContents = str_replace('{{zp:content}}', $bodycontent, $fileContents); return $fileContents; }
$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)... $file = GetSystemOption('temp_dir') . $backupname . ".zip";
function GetServerUptime() { # DESCRIPTION: Checks and converts a given value. # FUNCTION RELEASE: 5.0.0 # FUNCTION AUTHOR: Bobby Allen (ballen@zpanel.co.uk) if (ShowServerPlatform() == "Linux") { #BEGIN UPTIME $uptime = trim(exec("cat /proc/uptime")); $uptime = explode(" ", $uptime); $uptime = $uptime[0]; $day = 86400; $days = floor($uptime / $day); $utdelta = $uptime - $days * $day; $hour = 3600; $hours = floor($utdelta / $hour); $utdelta -= $hours * $hour; $minute = 60; $minutes = floor($utdelta / $minute); $days = CheckForNullValue($days != 1, $days . ' days', $days . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } elseif (ShowServerPlatform() == "Windows") { $pagefile = "" . GetSystemOption('windows_drive') . ":\\pagefile.sys"; $upsince = filemtime($pagefile); $gettime = time() - filemtime($pagefile); $days = floor($gettime / (24 * 3600)); $gettime = $gettime - $days * (24 * 3600); $hours = floor($gettime / 3600); $gettime = $gettime - $hours * 3600; $minutes = floor($gettime / 60); $gettime = $gettime - $minutes * 60; $seconds = $gettime; $days = CheckForNullValue($days != 1, $days . ' days', $days . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } elseif (ShowServerPlatform() == "FreeBSD") { $uptime = explode(" ", exec("/sbin/sysctl -n kern.boottime")); $uptime = str_replace(",", "", $uptime[3]); $uptime = time() - $uptime; $min = $uptime / 60; $hours = $min / 60; $days = floor($hours / 24); $hours = floor($hours - $days * 24); $minutes = floor($min - $days * 60 * 24 - $hours * 60); $days = CheckForNullValue($days != 1, $days . ' days', $days . ' day'); $hours = CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour'); $minutes = CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute'); $fretval = $days . ", " . $hours . ", " . $minutes . ""; } else { $fretval = "Unsupported Operating System"; } return $fretval; }
function zapi_vhsub_add($apache_conf, $domain, $alias, $admin_email, $home_dir, $flags, $alogs, $handlers, $errorpages, $extra, $directory_index) { $new_file = implode('', file($apache_conf)); $new_file .= "\r\n# DOMAIN: {$domain}\r\n<virtualhost *:80>\r\nServerName {$domain}\r\n{$alias}\r\nServerAdmin " . $admin_email . "\r\nDocumentRoot \"" . $home_dir . "\"\r\n{$flags}\r\n{$alogs}\r\n<Directory />\r\nOptions FollowSymLinks Indexes\r\nAllowOverride All\r\nOrder Allow,Deny\r\nAllow from all\r\n</Directory>\r\n{$handlers}\r\n{$errorpages}\r\n{$extra}\r\n" . $directory_index . "\r\n</virtualhost>\r\n# END DOMAIN: {$domain}"; $editfile = fopen($apache_conf, "w"); if (ShowServerPlatform() != "Windows") { $new_file = str_replace("\r", "", $new_file); } fwrite($editfile, $new_file); fclose($editfile); return; }
} } 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']) . "");