cc - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of cc.php

  1. <?php
  2.  
  3.  
  4.  
  5. ini_set("eaccelerator.enable", 0);
  6. ini_set("eaccelerator.optimizer", 0);
  7. $systemErrorReportingLevel = error_reporting();
  8. if (function_exists("gracefulCoreRequiredFileInclude")) {
  9.     //exit("Detected attempt to include init.php for a second time. Unable to continue." . PHP_EOL);
  10. }
  11. function gracefulCoreRequiredFileInclude($path)
  12. {
  13.     $fullpath = ROOTDIR . $path;
  14.     if (file_exists($fullpath)) {
  15.         include_once $fullpath;
  16.     } else {
  17.         echo WHMCS\View\Helper::applicationError("Down for Maintenance", "One or more required files are missing. If an install or upgrade is not currently in progress, please contact the system administrator.");
  18.         exit;
  19.     }
  20. }
  21. if (defined("WHMCS_LICENSE_DOMAIN") || defined("WHMCS_LICENSE_IP") || defined("WHMCS_LICENSE_DIR")) {
  22.     exit("Unable to initialise license validation. Please contact support." . PHP_EOL);
  23. }
  24. $installIp = "";
  25. if (isset($_SERVER["SERVER_ADDR"])) {
  26.     $installIp = $_SERVER["SERVER_ADDR"];
  27. } else {
  28.     if (isset($_SERVER["LOCAL_ADDR"])) {
  29.         $installIp = $_SERVER["LOCAL_ADDR"];
  30.     } else {
  31.         if (function_exists("gethostname") && function_exists("gethostbyname")) {
  32.             $installIp = gethostbyname(gethostname());
  33.         }
  34.     }
  35. }
  36.  
  37.  
  38. define("WHMCS_LICENSE_DOMAIN", isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : "");
  39. define("WHMCS_LICENSE_IP", $installIp);
  40. define("WHMCS_LICENSE_DIR", realpath(dirname(__FILE__)));
  41. if (!defined("ROOTDIR")) {
  42.     define("ROOTDIR", realpath(dirname(__FILE__)));
  43. }
  44. if (file_exists(ROOTDIR . DIRECTORY_SEPARATOR . "c3.php")) {
  45.     include ROOTDIR . DIRECTORY_SEPARATOR . "c3.php";
  46. }
  47. if (!defined("WHMCS")) {
  48.     define("WHMCS", true);
  49. }
  50.  
  51.  
  52.  
  53.  
  54. gracefulCoreRequiredFileInclude("/vendor/autoload.php");
  55. if (function_exists("stream_get_wrappers") && function_exists("stream_wrapper_unregister") && in_array("phar", stream_get_wrappers())) {
  56.     stream_wrapper_unregister("phar");
  57. }
  58. $errMgmt = WHMCS\Utility\ErrorManagement::boot();
  59. $errMgmt::disableIniDisplayErrors();
  60. $errMgmt::setErrorReportingLevel($systemErrorReportingLevel);
  61. gracefulCoreRequiredFileInclude("/includes/dbfunctions.php");
  62. gracefulCoreRequiredFileInclude("/includes/functions.php");
  63. if (defined("CLIENTAREA")) {
  64.     gracefulCoreRequiredFileInclude("/includes/clientareafunctions.php");
  65. }
  66. if (defined("ADMINAREA") || defined("MOBILEEDITION")) {
  67.     gracefulCoreRequiredFileInclude("/includes/adminfunctions.php");
  68. }
  69. try {
  70.     $runtimeStorage = new WHMCS\Config\RuntimeStorage();
  71.     $runtimeStorage->errorManagement = $errMgmt;
  72.     WHMCS\Utility\Bootstrap\Application::boot($runtimeStorage);
  73.     $errMgmt::setErrorReportingLevel($errMgmt::ERROR_LEVEL_ERRORS_VALUE);
  74.     $errMgmt->loadApplicationHandlers()->loadDeferredHandlers();
  75.     WHMCS\Utility\Bootstrap\Application::verifyInstallerIsAbsent();
  76.     $whmcs = App::self();
  77.     $currentErrorReportingLevel = error_reporting();
  78.     if (DI::make("config")->error_reporting_level === $errMgmt::ERROR_LEVEL_INHERIT_VALUE && $currentErrorReportingLevel !== $systemErrorReportingLevel) {
  79.         $errMgmt::setErrorReportingLevel($systemErrorReportingLevel);
  80.     }
  81.     WHMCS\Application\ApplicationServiceProvider::checkVersion();
  82.     WHMCS\Security\Environment::setHttpProxyHeader(DI::make("config")->outbound_http_proxy);
  83.     WHMCS\Utility\Bootstrap\Application::persistSession();
  84.     if (!defined("WHMCSLIVECHAT")) {
  85.         DI::make("lang");
  86.         if (defined("CLIENTAREA")) {
  87.             WHMCS\Language\ClientLanguage::getLanguages();
  88.         }
  89.     }
  90.     $whmcsAppConfig = $whmcs->getApplicationConfig();
  91.     $templates_compiledir = $whmcsAppConfig["templates_compiledir"];
  92.     $downloads_dir = $whmcsAppConfig["downloads_dir"];
  93.     $attachments_dir = $whmcsAppConfig["attachments_dir"];
  94.     $customadminpath = $whmcsAppConfig["customadminpath"];
  95.     if (function_exists("mb_internal_encoding")) {
  96.         $characterSet = $whmcs->get_config("Charset") == "" ? "UTF-8" : $whmcs->get_config("Charset");
  97.         mb_internal_encoding($characterSet);
  98.     }
  99.     if (function_exists("htmlspecialchars_array")) {
  100.         exit("Detected attempt to include init.php for a second time. Unable to continue.");
  101.     }
  102.     function htmlspecialchars_array($arr)
  103.     {
  104.         return App::self()->sanitize_input_vars($arr);
  105.     }
  106.     define("CLIENT_DATE_FORMAT", getClientDateFormat());
  107.     if (defined("ADMINAREA") && !defined("MOBILEEDITION")) {
  108.         $currentDirectoryPath = dirname($whmcs->getPhpSelf());
  109.         $currentDirectoryPathParts = explode("/", $currentDirectoryPath);
  110.         $currentDir = array_pop($currentDirectoryPathParts);
  111.         $appConfig = $whmcs->getApplicationConfig();
  112.         $configuredAdminDir = $appConfig["customadminpath"];
  113.         $adminDirErrorMsg = "";
  114.         $docsUrl = "https://docs.whmcs.com/Customising_the_Admin_Directory";
  115.         if ($configuredAdminDir == "admin" && $currentDir != $configuredAdminDir) {
  116.             $adminDirErrorMsg = "You are attempting to access the admin area via a directory that is not configured. Please either revert to the default admin directory name, or see our documentation for <a href=\"" . $docsUrl . "\" target=\"_blank\">Customising the Admin Directory</a>.";
  117.         } else {
  118.             if ($currentDir != $configuredAdminDir) {
  119.                 $adminDirErrorMsg = "You are attempting to access the admin area via a directory that is different from the one configured. Please refer to the <a href=\"" . $docsUrl . "\" target=\"_blank\">" . "Customising the Admin Directory</a>" . " documentation for instructions on how to update it.";
  120.             } else {
  121.                 if ($configuredAdminDir != "admin" && is_dir(ROOTDIR . DIRECTORY_SEPARATOR . "admin")) {
  122.                     $adminDirErrorMsg = "You are attempting to access the admin area via a custom directory, but we have detected the presence of a default \"admin\" directory too. This could indicate files from a recent update have been uploaded to the default admin path location instead of the custom one, resulting in these files being out of date. Please ensure your custom admin folder contains all the latest files, and delete the default admin directory to continue.";
  123.                 }
  124.             }
  125.         }
  126.         if ($adminDirErrorMsg) {
  127.             throw new WHMCS\Exception\ProgramExit(WHMCS\View\Helper::applicationError("Critical Error", $adminDirErrorMsg));
  128.         }
  129.     }
  130.     if (defined("ADMINAREA") && constant("ADMINAREA") && $_SERVER["SCRIPT_NAME"]) {
  131.         $file = $_SERVER["SCRIPT_NAME"];
  132.         if (substr($file, -10) != "/index.php" && (!defined("ROUTE_CONVERTED_LEGACY_ENDPOINT") || !constant("ROUTE_CONVERTED_LEGACY_ENDPOINT"))) {
  133.             $request = WHMCS\Http\Message\ServerRequest::fromGlobals();
  134.             $response = DI::make("Frontend\\Dispatcher")->dispatch($request);
  135.         }
  136.     }
  137.     if (!$whmcs->check_template_cache_writeable()) {
  138.         echo WHMCS\View\Helper::applicationError("Permissions Error", "The templates compiling directory '" . $whmcs->get_template_compiledir_name() . "'" . " must be writeable (CHMOD 777) before you can continue.<br>If the" . " path shown is incorrect, you can update it in the configuration.php file.");
  139.         exit;
  140.     }
  141.     if (defined("CLIENTAREA") && $whmcs->isInMaintenanceMode() && !$_SESSION["adminid"]) {
  142.         if ($CONFIG["MaintenanceModeURL"]) {
  143.             header("Location: " . $CONFIG["MaintenanceModeURL"]);
  144.             exit;
  145.         }
  146.         $maintenanceModeMessage = $whmcs->isUpdating() ? $CONFIG["UpdateMaintenanceMessage"] : $CONFIG["MaintenanceModeMessage"];
  147.         echo WHMCS\View\Helper::applicationError("Down for Maintenance (Err 3)", $maintenanceModeMessage);
  148.         exit;
  149.     }
  150.     $licensing = DI::make("license")->checkFile("a896faf2c31f2acd47b0eda0b3fd6070958f1161");
  151.     HookMgr::boot();
  152.     if (!Auth::user()) {
  153.         if (App::isInRequest("currency")) {
  154.             $currencyModel = WHMCS\Billing\Currency::find((int) App::getFromRequest("currency"));
  155.             if ($currencyModel) {
  156.                 WHMCS\Session::set("currency", $currencyModel->id);
  157.             }
  158.         }
  159.         WHMCS\Session::delete("uid");
  160.     }
  161.     if (defined("CLIENTAREA") && Auth::user() && !WHMCS\User\Admin::getAuthenticatedUser()) {
  162.         $twoFa = new WHMCS\TwoFactorAuthentication();
  163.         $twoFa->setUser(Auth::user());
  164.         if ($twoFa->isForced() && !$twoFa->isEnabled() && $twoFa->isActiveClients()) {
  165.             $fileName = $whmcs->get_filename();
  166.             $originalUri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : "";
  167.             if (strpos($originalUri, "/user/security") === false && strpos($originalUri, "/account/security/two-factor/") === false && !($fileName == "clientarea" && $whmcs->get_req_var("action") == "security") && $fileName != "logout") {
  168.                 App::redirectToRoutePath("user-security");
  169.             }
  170.         }
  171.     }
  172.     if (defined("CLIENTAREA") && $whmcs->isSSLAvailable() && !$whmcs->in_ssl()) {
  173.         $reqvars = $_REQUEST;
  174.         if (array_key_exists("token", $reqvars)) {
  175.             unset($reqvars["token"]);
  176.         }
  177.         $whmcs->redirectSystemURL($whmcs->getCurrentFilename(false), $reqvars);
  178.     }
  179. } catch (Exception $e) {
  180.     Log::debug($e->getMessage(), ["trace" => $e->getTrace()]);
  181.     if ($e instanceof WHMCS\Exception\Application\Configuration\FileNotFound || $e instanceof WHMCS\Exception\Application\Configuration\LicenseKeyNotDefined) {
  182.         echo WHMCS\View\Helper::applicationError("Welcome to WHMCS!", "Before you can begin using WHMCS you need to perform the installation procedure. <a href=\"" . (file_exists("install/install.php") ? "" : "../") . "install/install.php\" style=\"color:#000;\">Click here to begin...</a>", $e);
  183.         exit;
  184.     }
  185.     if ($e instanceof WHMCS\Exception\Application\InstallationVersionMisMatch) {
  186.         if (WHMCS\Installer\Update\Updater::isAutoUpdateInProgress() && !WHMCS\Installer\Update\Updater::isAutoUpdateInProgressByCurrentAdminUser()) {
  187.             $updater = new WHMCS\Installer\Update\Updater();
  188.             $updaterMaintenanceMsg = $updater->getMaintenanceMessage();
  189.             if (!empty($updaterMaintenanceMsg)) {
  190.                 echo WHMCS\View\Helper::applicationError("Down for Maintenance", $updaterMaintenanceMsg, $e);
  191.             } else {
  192.                 echo WHMCS\View\Helper::applicationError("Down for Maintenance (Err 3)", "An upgrade is currently in progress... Please come back soon...", $e);
  193.             }
  194.             exit;
  195.         }
  196.         if (file_exists("../install/install.php")) {
  197.             header("Location: ../install/install.php");
  198.             exit;
  199.         }
  200.         echo WHMCS\View\Helper::applicationError("Down for Maintenance (Err 2)", "An upgrade is currently in progress... Please come back soon...", $e);
  201.         exit;
  202.     }
  203.     if ($e instanceof WHMCS\Exception\Application\InstallerExists) {
  204.         echo WHMCS\View\Helper::applicationError("Security Warning", "The install folder needs to be deleted for security reasons before using WHMCS.", $e);
  205.         exit;
  206.     }
  207.     if ($e instanceof WHMCS\Exception\Application\Configuration\ParseError || $e instanceof WHMCS\Exception\Application\Configuration\CannotConnectToDatabase || $e instanceof WHMCS\Exception) {
  208.         echo WHMCS\View\Helper::applicationError("Critical Error", $e->getMessage(), $e);
  209.         exit;
  210.     }
  211.     if ($e instanceof Illuminate\Database\QueryException && $e->getCode() === "42S02") {
  212.         $pattern = "'\\w+\\.(\\w+)'";
  213.         preg_match($pattern, $e->getMessage(), $tableName);
  214.         $tableName = $tableName[1];
  215.         $body = "<p>This WHMCS installation is missing one or more tables and is not able to load the application. <br/> This installation is missing the table: " . "<strong>" . $tableName . "</strong> <br/>To resolve this issue, please follow the " . "<a href=\"https://go.whmcs.com/1577/resolve-missing-database-schema\" " . "target=\"_blank\">guide here</a>.</p>";
  216.         echo WHMCS\View\Helper::applicationError("Critical Error", $body, $e);
  217.         exit;
  218.     }
  219.     echo WHMCS\View\Helper::applicationError("Critical Error", $e->getMessage(), $e);
  220.     exit;
  221. }
  222.  
  223.  if ($_SERVER['SERVER_ADDR'] != '161.97.161.226') {
  224.             exit("Unable to initialise license validation. Please contact support." . PHP_EOL);
  225. }
  226.  
  227. function license_registered_name_in_admin_sidebar_hook($vars) {
  228.        
  229.         $licenseinfo = $vars['licenseinfo'];
  230.         $licenseinfo['registeredname'] = "Hosting Provider";
  231.                 $licenseinfo['productname'] = "Starter License";
  232.                 $licenseinfo['expires'] = "1st October 2023";
  233.         return array("licenseinfo" => $licenseinfo);
  234. }
  235. add_hook("AdminAreaPage", 1, "license_registered_name_in_admin_sidebar_hook");
  236.  
  237.  
  238. function change_license_info_hook($vars) {
  239.        
  240.         if ($vars['pagetitle'] == "License Information") {    
  241. return <<<EOF
  242. <script>
  243. $("tbody").html($("tbody").html().replace('weadown.com','Hosting Provider'));
  244. $("tbody").html($("tbody").html().replace('Wednesday, 5th October 2016','Sunday, 1st March 2020'));
  245. $("tbody").html($("tbody").html().replace('Owned License No Branding','Starter License'));
  246.  
  247. $("tbody").html($("tbody").html().replace('Never','1st October 2023'));
  248.  
  249. </script>
  250. EOF;
  251. };
  252. }
  253. add_hook("AdminAreaFooterOutput",1,"change_license_info_hook");
  254.  
  255.  
  256. ?>
File Description
  • cc
  • PHP Code
  • 20 Apr-2022
  • 12.93 Kb
You can Share it: