Jump to content

ohno

Members
  • Posts

    127
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ohno

  1. I wasn't sure if this should be in the JS/AJAX section or PHP,as the JS part seems OK I guess here! I have this at the very top of my script : - // Get the data from the AJAX request $searchQuery = isset($_POST['searchQuery']) ? $_POST['searchQuery'] : ''; $sessionid = isset($_POST['sessionid']) ? $_POST['sessionid'] : ''; // Declare as global variables // tried, no change // global $searchQuery, $sessionid; // Log the data to a text file $logData = "Received data from JavaScript:\n"; $logData .= "Search Query: " . $searchQuery . "\n"; $logData .= "Session ID: " . $sessionid . "\n\n"; $logFilePath = __DIR__ . '/log.txt'; file_put_contents($logFilePath, $logData, FILE_APPEND); This is working fine as I have checked the log file, so the payload is received OK. I then have this code lower down in my script : // Check if $searchQuery and $sessionid are not empty if (!empty($searchQuery) && !empty($sessionid)) { // Check if the sessionid from the database matches the sessionid from the AJAX payload if ($data['sessionid'] == $sessionid) { echo '<td class="center">***** ' . $searchQuery . ' *****</td>'; } else { echo '<td class="center">No search query available</td>'; } } else { echo '<td class="center">Missing search query or session ID</td>'; } // End With the above I get nothing, If I hard code a `sessionid` and a search term it appears in my HTML table for the correct user. Ie, with this it "works" : $searchQuery = 'This is where the data should appear!!'; $sessionid = '28if81v4amdsl7qlh5f5ktvc1r'; // Check if $searchQuery and $sessionid are not empty if (!empty($searchQuery) && !empty($sessionid)) { // Check if the sessionid from the database matches the sessionid from the AJAX payload if ($data['sessionid'] == $sessionid) { echo '<td class="center">***** ' . $searchQuery . ' *****</td>'; } else { echo '<td class="center">No search query available</td>'; } } else { echo '<td class="center">Missing search query or session ID</td>'; } // End Why can I not use the variables set at the top of my page? Or, how can I fix this?! Thanks for any help
  2. This works with all error scenarios..but doesn't actually update the database when the correct file is selected! <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $site_root = 'https://'.$_SERVER['SERVER_NAME']; // check maximum upload size $max_upload = (int)(ini_get('upload_max_filesize')); $max_post = (int)(ini_get('post_max_size')); $max_size = min($max_upload, $max_post); $max_size_bytes = $max_size * 1024 * 1024; // server size in bytes $style = ' <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> <style> .button { background-color: #00A5FF; border-radius: 4px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } </style> <title>ERROR DETECTED!</title> '; $postMaxSize = trim(ini_get('post_max_size')); if (strlen($postMaxSize)>0) { $postMaxSizeValue = substr($postMaxSize, 0, -1); $postMaxSizeUnit = strtolower(substr($postMaxSize, -1)); $postMaxSize = 0; if (false !== filter_var($postMaxSizeValue, FILTER_VALIDATE_INT, array('options' => array( 'min_range' => 0)))) { switch ($postMaxSizeUnit) { case 'g': $postMaxSizeValue*=1024; case 'm': $postMaxSizeValue*=1024; case 'k': $postMaxSizeValue*=1024; break; default: if ($postMaxSizeUnit>='0' && $postMaxSizeUnit<='9') { $postMaxSizeValue = (int) $postMaxSizeValue.$postMaxSizeUnit; } else { $postMaxSizeValue = 0; } } $postMaxSize = $postMaxSizeValue; } } else { $postMaxSize = 0; } if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $postMaxSize) { echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>The uploaded file exceeds the maximum post file size. Maximum post file size allowed is ".$max_post." MB (".$postMaxSize." bytes)<br><br />Increase 'post_max_size' setting on the server!</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit(1); } // display maximum upload size echo "<center><b>Maximum Upload File Size: $max_upload MB</b></center>"; echo "<center><b>Maximum Post Size: $max_post MB</b></center>"; echo "<center><b>Maximum Size Bytes: $max_size_bytes</b></center>"; if (isset($_FILES["file"])) { $fileName = $_FILES["file"]["tmp_name"]; $fileType = $_FILES["file"]["type"]; $allowedTypes = array('text/csv', 'application/vnd.ms-excel'); if ($_FILES["file"]["error"] !== UPLOAD_ERR_OK) { $error_message = ''; switch ($_FILES["file"]["error"]) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error_message = "The uploaded file exceeds the maximum file size. Maximum file size allowed is $max_size MB<br />Increase 'upload_max_filesize' setting on the server!"; break; case UPLOAD_ERR_PARTIAL: $error_message = "The uploaded file was only partially uploaded."; break; case UPLOAD_ERR_NO_FILE: $error_message = "No file selected, no file was uploaded."; break; case UPLOAD_ERR_NO_TMP_DIR: $error_message = "Missing a temporary folder."; break; case UPLOAD_ERR_CANT_WRITE: $error_message = "Failed to write file to disk."; break; case UPLOAD_ERR_EXTENSION: $error_message = "File upload stopped by extension."; break; default: $error_message = "Unknown upload error."; break; } echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with nnerror: ".$error_message."</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } else if (!in_array($fileType, $allowedTypes)) { echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with error: Only CSV files are allowed</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } else { $file = fopen($fileName, "r"); } } class ImportController { private $conn; // getting connection in constructor function __construct($conn) { $this->conn = $conn; } // function for reading csv file public function index() { $fileName = ""; // if there is any file if(isset($_FILES['file'])) { // reading tmp_file name $fileName = $_FILES["file"]["tmp_name"]; } $counter = 0; // if file size is not empty if (isset($_FILES["file"]) && $_FILES["file"]["size"] > 0) { $file = fopen($fileName, "r"); // eliminating the first row of CSV file fgetcsv($file); ?> <table class="table"> <thead> <th> IP From </th> <th> IP To </th> <th> Country Code </th> <th> Country Name </th> <th> Response </th> </thead> <?php // prepare the statement $stmt = $this->conn->prepare("REPLACE INTO ip2location (ip_from, ip_to, country_code, country_name) VALUES (?, ?, ?, ?)"); while (($column = fgetcsv($file, 10000, ",")) !== FALSE) { $counter++; // assigning csv column to a variable $ip_from = $column[0]; $ip_to = $column[1]; $country_code = $column[2]; $country_name = $column[3]; // bind the values to the statement parameters and execute $stmt->bind_param("ssss", $ip_from, $ip_to, $country_code, $country_name); $result = $stmt->execute(); if($result == 1): ?> <tr> <td> <?php echo $ip_from; ?> </td> <td> <?php echo $ip_to; ?> </td> <td> <?php echo $country_code; ?> </td> <td> <?php echo $country_name; ?> </td> <td> <?php echo "<label class='text-success'>Success </label> " .date('d-m-Y H:i:s');?> </td> </tr> <?php endif; } $stmt->close(); // close the statement ?> </table> <?php } } } ?> <!DOCTYPE html> <html> <head> <style> .button { background-color: #00A5FF; border-radius: 4px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } </style> <title>Import IP Location Database CSV</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> </head> <body> <p style="text-align:center">Upload New Cart IP Geo Tracking Database Here. This Will Import IP Info In CSV Format!</p> <div class="row"> <div class="col-md-10 offset-md-5"> <a href="https://lite.ip2location.com/ip2location-lite" target="_blank"><button class="button">Download New DB!</button></a> <a href="<?php echo $site_root; ?>/cartsystem/admin/orders.php"><button class="button">BACK!</button></a> </div> </div> <div class="container"> <form method="post" enctype="multipart/form-data"> <div class="row mt-5"> <div class="col-md-6 m-auto border shadow"> <label> Import Data - CAUTION! This Affects LIVE Site!</label> <div class="form-group"> <input type="file" name="file" class="form-control"> </div> <div class="form-group"> <button type="submit" name="import" class="btn btn-success"> Import Data </button> </div> </div> </div> <div class="row mt-4"> <div class="col-md-10 m-auto"> <?php if (isset($importResult)) { echo $importResult; } ?> </div> </div> </form> </div> </body> </html>
  3. I think I'll need to merge the two files to get this to work but not sure how? Current form page (I tried adding the error checking here, it didn't work) : - <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $site_root = 'https://'.$_SERVER['SERVER_NAME']; // including db config file include_once("../db-config.php"); // including import controller file include_once("../import-controller.php"); // creating object of DBController class $db = new DBController(); // calling connect() function using object $conn = $db->connect(); // creating object of import controller and passing connection object as a parameter $importCtrl = new ImportController($conn); ?> <!DOCTYPE html> <html> <head> <style> .button { background-color: #00A5FF; border-radius: 4px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } </style> <title>Import IP Location Database CSV</title> </head> <body> <p style="text-align:center">Upload New Cart IP Geo Tracking Database Here. This Will Import IP Info In CSV Format!</p> <div class="row"> <div class="col-md-10 offset-md-5"> <a href="https://lite.ip2location.com/ip2location-lite" target="_blank"><button class="button">Download New DB!</button></a> <a href="<?php echo $site_root; ?>/cartsystem/admin/orders.php"><button class="button">BACK!</button></a> </div> </div> <div class="container"> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { $file_size = $_FILES['file']['size']; $max_size = 1024 * 1024; // 1 MB if ($file_size > $max_size) { echo '<div class="alert alert-danger">The uploaded file is too large (max size: 1MB).</div>'; } else { $importResult = $importCtrl->index(); } } ?> <form method="post" enctype="multipart/form-data"> <div class="row mt-5"> <div class="col-md-6 m-auto border shadow"> <label> Import Data - CAUTION! This Affects LIVE Site!</label> <div class="form-group"> <input type="file" name="file" class="form-control"> </div> <div class="form-group"> <button type="submit" name="import" class="btn btn-success"> Import Data </button> </div> </div> </div> <div class="row mt-4"> <div class="col-md-10 m-auto"> <?php if (isset($importResult)) { echo $importResult; } ?> </div> </div> </form> </div> </body> </html> and the current import-controller file (again, with added error checking, again, it didn't work) <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $site_root = 'https://'.$_SERVER['SERVER_NAME']; // check maximum upload size $max_upload = (int)(ini_get('upload_max_filesize')); $max_post = (int)(ini_get('post_max_size')); $max_size = min($max_upload, $max_post); $max_size_bytes = $max_size * 1024 * 1024; // server size in bytes if ($_SERVER['REQUEST_METHOD'] === 'POST' && empty($_POST) && empty($_FILES)) { // Post data exceeds the maximum post size limit echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>Post data exceeds the maximum post size limit of $max_post MB. Please contact your server administrator to increase the limit.</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } // display maximum upload size echo "<center><b>Maximum Upload File Size: $max_upload MB</b></center>"; echo "<center><b>Maximum Post Size: $max_post MB</b></center>"; echo "<center><b>Maximum Size Bytes: $max_size_bytes</b></center>"; $style = '<style> .button { background-color: #00A5FF; border-radius: 4px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } </style> <title>ERROR DETECTED!</title> '; if (isset($_FILES["file"])) { $fileName = $_FILES["file"]["tmp_name"]; $fileType = $_FILES["file"]["type"]; $allowedTypes = array('text/csv', 'application/vnd.ms-excel'); if ($_FILES["file"]["error"] !== UPLOAD_ERR_OK) { $error_message = ''; switch ($_FILES["file"]["error"]) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error_message = "The uploaded file exceeds the maximum file size. Maximum file size allowed is $max_size MB"; break; case UPLOAD_ERR_PARTIAL: $error_message = "The uploaded file was only partially uploaded."; break; case UPLOAD_ERR_NO_FILE: $error_message = "No file selected, no file was uploaded."; break; case UPLOAD_ERR_NO_TMP_DIR: $error_message = "Missing a temporary folder."; break; case UPLOAD_ERR_CANT_WRITE: $error_message = "Failed to write file to disk."; break; case UPLOAD_ERR_EXTENSION: $error_message = "File upload stopped by extension."; break; default: $error_message = "Unknown upload error."; break; } echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with error: ".$error_message."</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } else if (!in_array($fileType, $allowedTypes)) { echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with error: Only CSV files are allowed</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } else if ($_FILES["file"]["size"] > $max_size * 1024 * 1024) { echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with error: The uploaded file exceeds the maximum file size. Maximum file size allowed is $max_size MB</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } else { $file = fopen($fileName, "r"); } } class ImportController { private $conn; // getting connection in constructor function __construct($conn) { $this->conn = $conn; } // function for reading csv file public function index() { $fileName = ""; // if there is any file if(isset($_FILES['file'])) { // reading tmp_file name $fileName = $_FILES["file"]["tmp_name"]; } $counter = 0; // if file size is not empty if (isset($_FILES["file"]) && $_FILES["file"]["size"] > 0) { $file = fopen($fileName, "r"); // eliminating the first row of CSV file fgetcsv($file); ?> <table class="table"> <thead> <th> IP From </th> <th> IP To </th> <th> Country Code </th> <th> Country Name </th> <th> Response </th> </thead> <?php // prepare the statement $stmt = $this->conn->prepare("REPLACE INTO ip2location (ip_from, ip_to, country_code, country_name) VALUES (?, ?, ?, ?)"); while (($column = fgetcsv($file, 10000, ",")) !== FALSE) { $counter++; // assigning csv column to a variable $ip_from = $column[0]; $ip_to = $column[1]; $country_code = $column[2]; $country_name = $column[3]; // bind the values to the statement parameters and execute $stmt->bind_param("ssss", $ip_from, $ip_to, $country_code, $country_name); $result = $stmt->execute(); if($result == 1): ?> <tr> <td> <?php echo $ip_from; ?> </td> <td> <?php echo $ip_to; ?> </td> <td> <?php echo $country_code; ?> </td> <td> <?php echo $country_name; ?> </td> <td> <?php echo "<label class='text-success'>Success </label> " .date('d-m-Y H:i:s');?> </td> </tr> <?php endif; } $stmt->close(); // close the statement ?> </table> <?php } } } ?> If anyone has the time to take a look and post what code is required it would be much appreciated!
  4. I have this code : - <?php $site_root = 'https://'.$_SERVER['SERVER_NAME']; // check maximum upload size $max_upload = (int)(ini_get('upload_max_filesize')); $max_post = (int)(ini_get('post_max_size')); $max_size = min($max_upload, $max_post); $max_size_bytes = $max_size * 1024 * 1024; // server size in bytes // display maximum upload size echo "<center><b>Maximum Upload File Size: $max_size MB</b></center>"; echo "<center><b>Maximum Post Size: $max_post MB</b></center>"; echo "<center><b>Maximum Size Bytes: $max_size_bytes</b></center>"; $style = '<style> .button { background-color: #00A5FF; border-radius: 4px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } </style> <title>ERROR DETECTED!</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> '; // error checking if (isset($_FILES["file"])) { $fileName = $_FILES["file"]["tmp_name"]; $fileType = $_FILES["file"]["type"]; $allowedTypes = array('text/csv', 'application/vnd.ms-excel'); if ($_FILES["file"]["error"] !== UPLOAD_ERR_OK) { echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with error: "; echo $style; switch ($_FILES["file"]["error"]) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: echo "The uploaded file exceeds the maximum file size. Maximum file size allowed is $max_size MB"; echo "<a href='javascript:window.history.back();'><button class='button'>BACK!</button></a>"; echo $style; break; case UPLOAD_ERR_PARTIAL: echo "The uploaded file was only partially uploaded."; echo "<a href='javascript:window.history.back();'><button class='button'>BACK!</button></a>"; echo $style; break; case UPLOAD_ERR_NO_FILE: echo "No file selected, no file was uploaded."; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; break; case UPLOAD_ERR_NO_TMP_DIR: echo "Missing a temporary folder."; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; break; case UPLOAD_ERR_CANT_WRITE: echo "Failed to write file to disk."; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; break; case UPLOAD_ERR_EXTENSION: echo "File upload stopped by extension."; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; break; default: echo "Unknown upload error."; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; break; } echo "</b></center>"; exit; } else if (!in_array($fileType, $allowedTypes)) { echo "<center><img src='".$site_root."/images/cartwarningred.png' alt='Error!' />&nbsp;&nbsp;<b>File upload failed with error: Only CSV files are allowed</b></center>"; echo "<center><a href='javascript:window.history.back();'><button class='button'>BACK!</button></a></center>"; echo $style; exit; } else { $file = fopen($fileName, "r"); } } class ImportController { // getting connection in constructor function __construct($conn) { $this->conn = $conn; } // function for reading csv file public function index() { $fileName = ""; // if there is any file if(isset($_FILES['file'])) { // reading tmp_file name $fileName = $_FILES["file"]["tmp_name"]; } $counter = 0; // if file size is not empty if (isset($_FILES["file"]) && $_FILES["file"]["size"] > 0) { $file = fopen($fileName, "r"); // eliminating the first row of CSV file fgetcsv($file); ?> <table class="table"> <thead> <th> IP From </th> <th> IP To </th> <th> Country Code </th> <th> Country Name </th> <th> Response </th> </thead> <?php // prepare the statement $stmt = $this->conn->prepare("REPLACE INTO ip2location (ip_from, ip_to, country_code, country_name) VALUES (?, ?, ?, ?)"); while (($column = fgetcsv($file, 10000, ",")) !== FALSE) { $counter++; // assigning csv column to a variable $ip_from = $column[0]; $ip_to = $column[1]; $country_code = $column[2]; $country_name = $column[3]; // bind the values to the statement parameters and execute $stmt->bind_param("ssss", $ip_from, $ip_to, $country_code, $country_name); $result = $stmt->execute(); if($result == 1): ?> <tr> <td> <?php echo $ip_from; ?> </td> <td> <?php echo $ip_to; ?> </td> <td> <?php echo $country_code; ?> </td> <td> <?php echo $country_name; ?> </td> <td> <?php echo "<label class='text-success'>Success </label> " .date('d-m-Y H:i:s');?> </td> </tr> <?php endif; } $stmt->close(); // close the statement ?> </table> <?php } } } ?> During testing if post_max_size is too small but upload_max_filesize is not it tries to upload but fails, I get no error. If post_max_size is OK but upload_max_filesize is not it tries to upload & correctly displays the error "The uploaded file exceeds the maximum file size." How can I get it to display an error if the post_max_size setting on the server is too small?
  5. How does this look? $hash = substr(md5(Server::$Response->Typing),0,5); if (!is_null($hash) && isset($_POST["p_gl_t"]) && $hash != $_POST["p_gl_t"] && strlen(Server::$Response->Typing) > 0) { Server::$Response->XML .= "<gl_typ h=\"".base64_encode($hash)."\">\r\n" . Server::$Response->Typing . "</gl_typ>\r\n"; }
  6. Working with the hosts, adding this to the file in question worked ini_set('error_reporting', E_ERROR); register_shutdown_function("fatal_handler"); function fatal_handler() { $error = error_get_last(); echo("<pre>"); print_r($error); } Found the issue in minutes (magic quotes!) and fixed the function.
  7. Not sure how I can check this? The error appears if a webpage with the chat icon is accessed/refreshed.
  8. This isn't my code, it's a third party chat system which I'm trying to get to work with PHP 8. I ALWAYS try & fix errors hence this thread!
  9. OK, changing the original file to this : - function CreateSignature() { $keys = ['HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_ACCEPT_CHARSET']; $sig = ''; foreach ($keys as $k) { $sig .= $_SERVER[$k] ?? ''; } //$sig = @$_SERVER["HTTP_USER_AGENT"].@$_SERVER["HTTP_ACCEPT"].@$_SERVER["HTTP_ACCEPT_LANGUAGE"].@$_SERVER["HTTP_ACCEPT_CHARSET"]; $this->Signature = md5(Communication::GetIP() . $sig); } Cleared that error, now the programs logs have this error : - 24.01.23 15:00:38 31.111.2.99 ERR# 2 Undefined array key "p_gl_t" /home/website/public_html/online-support/_lib/objects.internal.inc.php IN LINE 303 Line 303 : - if(($hash = substr(md5(Server::$Response->Typing),0,5)) != @$_POST["p_gl_t"] && strlen(Server::$Response->Typing) > 0) 😪
  10. I did but I still get : - Warning: Undefined array key "HTTP_ACCEPT_CHARSET" in /home/website/public_html/test.php on line 12 HTTP_ACCEPT_CHARSET
  11. The programs error log gives me this : - 24.01.23 13:48:36 31.111.2.99 ERR# 2 Undefined array key "HTTP_ACCEPT_CHARSET" /home/website/public_html/online-support/_lib/objects.global.users.inc.php IN LINE 2175 Using your code example: - Version 7.4.33 HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0 HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 HTTP_ACCEPT_LANGUAGE en-GB,en;q=0.5 HTTP_ACCEPT_CHARSET Version 8.0.26 HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0 HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 HTTP_ACCEPT_LANGUAGE en-GB,en;q=0.5 Warning: Undefined array key "HTTP_ACCEPT_CHARSET" HTTP_ACCEPT_CHARSET I don't seem to be able to suppress the error with @?
  12. Thanks, that's what I thought but unsure how to code it?
  13. Slowly working through errors when trying PHP 8, I'm getting Undefined array key "HTTP_ACCEPT_CHARSET", the code snippet in question : - function CreateSignature() { $sig = @$_SERVER["HTTP_USER_AGENT"].@$_SERVER["HTTP_ACCEPT"].@$_SERVER["HTTP_ACCEPT_LANGUAGE"].@$_SERVER["HTTP_ACCEPT_CHARSET"]; $this->Signature = md5(Communication::GetIP() . $sig); } I'm guessing the @ is the issue but how to fix?
  14. I added this to htaccess : - php_flag log_errors on php_flag display_errors on php_flag display_startup_errors on php_value error_reporting 2147483647 php_value error_log /home/site/public_html/var/php.error.log That made a log for other errors (that I already know about) but when running the script I'm trying to fix....NOTHING!
  15. Added the above to the php.ini file, still just get a white screen! Even tried adding php_flag display_errors 1 to the .htaccess file but still nothing.
  16. I've tried adding the above to a php.ini file I can see in the root, no change (just a white screen). I've contacted the hosts to make sure this is the correct file!
  17. I should add, I've added this to the PHP file in question : - ini_set("display_errors", "1"); ini_set("display_startup_errors", "1"); error_reporting(E_ALL); But still get no error report.
  18. The site also uses this script for customer comments : - <?php $installed = ''; if(!isset($configs_are_set_gb)) { include( dirname(__FILE__). "/configs.php"); } $rootPage = $_SERVER['PHP_SELF']; $thisPage = "/feedback.php"; $sql = "SELECT * FROM ".$TABLE["Options"]; $sql_result = sql_result($sql); $Options = mysqli_fetch_assoc($sql_result); mysqli_free_result($sql_result); $Options["gb_form"] = unserialize($Options["gb_form"]); $Options["gb_req"] = unserialize($Options["gb_req"]); $Options["gb_info"] = unserialize($Options["gb_info"]); $OptionsVis = unserialize($Options['visual']); $OptionsLang = unserialize($Options['language']); if(trim($Options['time_zone'])!='') { date_default_timezone_set(trim($Options['time_zone'])); } $cur_date = date('Y-m-d H:i:s'); if(!isset($_REQUEST["p"])) $_REQUEST["p"] = ''; if(!isset($_REQUEST["search"])) $_REQUEST["search"] = ''; if(!function_exists('lang_date')){ function lang_date($subject) { $search = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); $replace = array( ReadDB($GLOBALS['OptionsLang']['January']), ReadDB($GLOBALS['OptionsLang']['February']), ReadDB($GLOBALS['OptionsLang']['March']), ReadDB($GLOBALS['OptionsLang']['April']), ReadDB($GLOBALS['OptionsLang']['May']), ReadDB($GLOBALS['OptionsLang']['June']), ReadDB($GLOBALS['OptionsLang']['July']), ReadDB($GLOBALS['OptionsLang']['August']), ReadDB($GLOBALS['OptionsLang']['September']), ReadDB($GLOBALS['OptionsLang']['October']), ReadDB($GLOBALS['OptionsLang']['November']), ReadDB($GLOBALS['OptionsLang']['December']), ReadDB($GLOBALS['OptionsLang']['Monday']), ReadDB($GLOBALS['OptionsLang']['Tuesday']), ReadDB($GLOBALS['OptionsLang']['Wednesday']), ReadDB($GLOBALS['OptionsLang']['Thursday']), ReadDB($GLOBALS['OptionsLang']['Friday']), ReadDB($GLOBALS['OptionsLang']['Saturday']), ReadDB($GLOBALS['OptionsLang']['Sunday']) ); $lang_date = str_replace($search, $replace, $subject); return $lang_date; } } ///////////////////////////////////////////////// ////// checking for correct captcha and text confirmation starts ////// if (isset($_POST["act"]) and $_POST["act"]=='post_comment') { if($Options['captcha']=='nocap') { // if the option is set to no Captcha $testvariable = true; // test variable is set to true } else { $testvariable = false; // test variable is set to false } if($Options['captcha']=='recap') { // if the option is set to reCaptcha $privatekey = "removed"; if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { // test variable is set to true $testvariable = true; } else { # set the error code so that we can display it $error = $resp->error; $SysMessage = ReadDB($OptionsLang["Incorrect_verification_code"]); $_REQUEST["act"] = 'new'; } } else { $SysMessage = ReadDB($OptionsLang["Incorrect_verification_code"]); $_REQUEST["act"] = 'new'; } } elseif($Options['captcha']!='recap' and $Options['captcha']!='nocap') { // if is set to math or simple or very simple captcha option if (preg_match('/^'.$_SESSION['key'].'$/i', $_REQUEST['string'])) { // test variable is set $testvariable = true; } else { $SysMessage = ReadDB($OptionsLang["Incorrect_verification_code"]); $_REQUEST["act"] = 'new'; } } ////// checking for correct text confirmation code starts ////// if($Options['text_confirm']=='true') { // if the option is set to no Captcha $textconfirm = false; // test variable is set to true if(preg_match('/^'.$OptionsLang['verify_answer'].'$/i', $_REQUEST['verify_answer'])) { $textconfirm = true; // test variable is set to false } else { $SysMessage .= ReadDB($OptionsLang["Incorrect_text_confirm_code"]); $_REQUEST["act"] = 'new'; } } else { $textconfirm = true; // test variable is set to false } ////// checking for correct text confirmation code ends ////// } ////// checking for correct captcha and text confirmation ends ////// /////////////////////////////////////////////// if (isset($_POST["act"]) and $_POST["act"]=='post_comment') { if ($testvariable==true and $textconfirm==true) { // if test variables are set to true, then go to update database and send emails if ($Options["approval"]=='true') { $status = 'Not approved'; } else { $status = 'Approved'; } $WordAllowed = true; $BannedWords = explode(",", ReadDB($Options["ban_words"])); if (count($BannedWords)>0) { $checkComment = strtolower($_REQUEST["name"]." ".$_REQUEST["location"]." ".$_REQUEST["email"]." ".$_REQUEST["phone"]." ".$_REQUEST["comments"]); for($i=0;$i<count($BannedWords);$i++){ $banWord = trim($BannedWords[$i]); if (trim($BannedWords[$i])<>'') { if(preg_match("/".$banWord."/i", $checkComment)){ $WordAllowed = false; break; } } } } $IPAllowed = true; $BannedIPs = explode(",", ReadDB($Options["ban_ips"])); if (count($BannedIPs)>0) { $checkIP = strtolower($_SERVER["REMOTE_ADDR"]); for($i=0;$i<count($BannedIPs);$i++){ $banIP = trim($BannedIPs[$i]); if (trim($BannedIPs[$i])<>'') { if(preg_match("/".$banIP."/i", $checkIP)){ $IPAllowed = false; break; } } } } // check for required fields $emptyReqField = true; if(trim($_REQUEST["name"])=='') { $emptyReqField = false; } if (in_array("Location", $Options["gb_form"]) and in_array("Location", $Options["gb_req"]) and trim($_REQUEST["location"])=='') { $emptyReqField = false; } if (in_array("Email", $Options["gb_form"]) and in_array("Email", $Options["gb_req"]) and trim($_REQUEST["email"])=='') { $emptyReqField = false; } if (in_array("Phone", $Options["gb_form"]) and in_array("Phone", $Options["gb_req"]) and trim($_REQUEST["phone"])=='') { $emptyReqField = false; } if (in_array("Website", $Options["gb_form"]) and in_array("Website", $Options["gb_req"]) and trim($_REQUEST["website"])=='') { $emptyReqField = false; } if (in_array("Comments", $Options["gb_req"]) and trim($_REQUEST["comments"])=='') { $emptyReqField = false; } if($WordAllowed==false) { $SysMessage = ReadDB($OptionsLang["Banned_word_used"]); } elseif($IPAllowed==false) { $SysMessage = ReadDB($OptionsLang["Banned_ip_used"]); } elseif($emptyReqField==false) { $SysMessage = ReadDB($OptionsLang["required_fields"]); } else { $name = breakLongWords($_REQUEST["name"], 22, " "); $location = breakLongWords($_REQUEST["location"], 22, " "); $email = breakLongWords($_REQUEST["email"], 32, " "); $phone = breakLongWords($_REQUEST["phone"], 22, " "); $website = breakLongWords($_REQUEST["website"], 32, " "); $comments = substr($_REQUEST["comments"], 0, ($Options["char_limit"]+5)); $comments = breakLongWords($comments, 28, " "); $sql = "INSERT INTO ".$TABLE["Comments"]." SET `ipaddress` = '".SaveDB($_SERVER["REMOTE_ADDR"])."', `publish_date` = '".$cur_date."', `status` = '".$status."', `name` = '".SaveDB($name)."', `location` = '".SaveDB($location)."', `email` = '".SaveDB($email)."', `phone` = '".SaveDB($phone)."', `website` = '".SaveDB($website)."', `starsrate` = '".SaveDB($_REQUEST['starsrate'])."', `comments` = '".SaveDB($comments)."'"; $sql_result = sql_result($sql); $index_id = mysqli_insert_id($connGb); if (isset($_FILES["image"]) and is_uploaded_file($_FILES["image"]['tmp_name'])) { $filexpl = explode(".", $_FILES["image"]['name']); $format = end($filexpl); $formats = array("jpg","jpeg","JPG","png","PNG","gif","GIF"); if(in_array($format, $formats) and getimagesize($_FILES['image']['tmp_name'])) { $name = $_FILES['image']['name']; $name = str_replace(array(" ", "%20"), "_", $name); $name = $index_id . "_" . $name; $filePath = $CONFIG["server_path"].$CONFIG["upload_folder"] . $name; if (move_uploaded_file($_FILES["image"]['tmp_name'], $filePath)) { chmod($filePath, 0777); Resize_File($filePath, $OptionsVis["avat_width"], 0); $sql = "UPDATE ".$TABLE["Comments"]." SET `image` = '".$name."' WHERE id='".$index_id."'"; $sql_result = sql_result($sql); $message = ''; } else { $message = 'Cannot copy uploaded file to "'.$filePath.'". Try to set the right permissions (CHMOD 777) to "'.$CONFIG["upload_folder"].'" directory.'; } } else { $message = 'Uploaded file must be an image. File is not uploaded. '; } } else { /// $message = 'Image file is not uploaded. '; } $SysMessage = ReadDB($OptionsLang["Comment_Submitted"]); if($Options['approval']=='true') { $SysMessage .= ReadDB($OptionsLang["After_Approval_Admin"]); } $mailheader = "From: ".ReadDB($Options["email"])."\r\n"; $mailheader .= "Reply-To: ".ReadDB($Options["email"])."\r\n"; $mailheader .= "Content-type: text/html; charset=UTF-8\r\n"; $Message_body = ReadDB($OptionsLang["New_comment_posted"]).": <br />\r\n<br />\r\n"; $Message_body .= ReadDB($OptionsLang["Name"])." <b>".ReadDB($_REQUEST["name"])."</b> <br />\r\n"; if($_REQUEST["location"]!='') { $Message_body .= ReadDB($OptionsLang["Location"])." <b>".ReadDB($_REQUEST["location"])."</b> <br />\r\n"; } if($_REQUEST["email"]!='') { $Message_body .= ReadDB($OptionsLang["Email"])." <b>".ReadDB($_REQUEST["email"])."</b> <br />\r\n"; } if($_REQUEST["phone"]!='') { $Message_body .= ReadDB($OptionsLang["Phone"])." <b>".ReadDB($_REQUEST["phone"])."</b> <br />\r\n"; } if($_REQUEST["website"]!='') { $Message_body .= ReadDB($OptionsLang["Website"])." <b>".ReadDB($_REQUEST["website"])."</b> <br />\r\n <br />\r\n"; } $Message_body .= ReadDB($OptionsLang["Comments"])." <br />\r\n ".ReadDB(nl2br($_REQUEST["comments"]))."<br /><br /><br />"; $Message_body .= '<a href="'.$CONFIG["full_url"].'admin.php">'.$CONFIG["full_url"].'admin.php'.'</a><br /><br />'; mail(ReadDB($Options["email"]), ReadDB($OptionsLang["New_comment_posted"]), $Message_body, $mailheader); if($_REQUEST["email"]!='' and trim(ReadDB($OptionsLang["email_body"]))!='') { mail($_REQUEST["email"], ReadDB($OptionsLang["email_subject"]), ReadDB($OptionsLang["email_body"]), $mailheader); } unset($_REQUEST["name"]); unset($_REQUEST["location"]); unset($_REQUEST["email"]); unset($_REQUEST["phone"]); unset($_REQUEST["website"]); unset($_REQUEST["comments"]); unset($_SESSION['key']); echo '<script type="text/javascript">window.location.href="'.$thisPage.'?SysMessage='.urlencode($SysMessage).'#comments";</script>'; } } // end if test variable is set to true, then go to update database and send emails } ?> <?php include($CONFIG["server_path"]."styles/css_front_end.php"); ?> <div class="background_div"> <div class="front_wrapper"> <a name="gbform" id="gbform"></a> <?php if(isset($SysMessage) and trim($SysMessage)!='') { ?> <div class="system_message"><?php if(isset($SysMessage)) echo $SysMessage; ?></div> <?php } else { ?> <div class="system_message"><?php if(isset($_REQUEST['SysMessage'])) echo urldecode($_REQUEST['SysMessage']); ?></div> <?php } ?> <?php if ($_REQUEST["act"]=='new') { ?> <script type="text/javascript"> function trim(str, chars) { return ltrim(rtrim(str, chars), chars); } function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); } function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); } function checkForm(form){ var chekmail = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; var name, isOk = true; <?php if($Options['captcha']=='capmath' or $Options['captcha']=='cap' or $Options['captcha']=='vsc') { // if the option is set to Math or Simple or Very Simple Captcha ?> var string; <?php } ?> <?php if (in_array("Location", $Options["gb_form"]) and in_array("Location", $Options["gb_req"])) { ?> var location; <?php } ?> <?php if (in_array("Email", $Options["gb_form"]) and in_array("Email", $Options["gb_req"])) { ?> var email; <?php } ?> <?php if (in_array("Phone", $Options["gb_form"]) and in_array("Phone", $Options["gb_req"])) { ?> var phone; <?php } ?> <?php if (in_array("Website", $Options["gb_form"]) and in_array("Website", $Options["gb_req"])) { ?> var website; <?php } ?> <?php if (in_array("Comments", $Options["gb_req"])) { ?> var comments; <?php } ?> <?php if($Options['text_confirm']=='true') { // if the verification answer is empry ?> var verify_answer; <?php } ?> var message = ""; message = "<?php echo ReadDB($OptionsLang["required_fields"]); ?>"; name = form.name.value; name = trim(name); <?php if (in_array("Location", $Options["gb_form"]) and in_array("Location", $Options["gb_req"])) { ?> location = form.location.value; location = trim(location); <?php } ?> <?php if (in_array("Email", $Options["gb_form"]) and in_array("Email", $Options["gb_req"])) { ?> email = form.email.value; email = trim(email); <?php } ?> <?php if (in_array("Phone", $Options["gb_form"]) and in_array("Phone", $Options["gb_req"])) { ?> phone = form.phone.value; phone = trim(phone); <?php } ?> <?php if (in_array("Website", $Options["gb_form"]) and in_array("Website", $Options["gb_req"])) { ?> website = form.website.value; website = trim(website); <?php } ?> <?php if (in_array("Comments", $Options["gb_req"])) { ?> comments = form.comments.value; comments = trim(comments); <?php } ?> <?php if($Options['captcha']=='capmath' or $Options['captcha']=='cap' or $Options['captcha']=='vsc') { // if the option is set to Math or Simple or Very Simple Captcha ?> string = form.string.value; <?php } ?> <?php if($Options['text_confirm']=='true') { // if the verification answer is empry ?> verify_answer = form.verify_answer.value; <?php } ?> if (name.length==0){ form.name.focus(); isOk=false; } <?php if (in_array("Location", $Options["gb_form"]) and in_array("Location", $Options["gb_req"])) { ?> else if (location.length==0){ form.location.focus(); isOk=false; } <?php } ?> <?php if (in_array("Email", $Options["gb_form"]) and in_array("Email", $Options["gb_req"])) { ?> else if (email.length==0){ form.email.focus(); isOk=false; } else if (email.length>=5 && email.match(chekmail)==null){ message ="<?php echo ReadDB($OptionsLang["correct_email"]); ?>"; form.email.focus(); isOk=false; } <?php } ?> <?php if (in_array("Phone", $Options["gb_form"]) and in_array("Phone", $Options["gb_req"])) { ?> else if (phone.length==0){ form.phone.focus(); isOk=false; } <?php } ?> <?php if (in_array("Website", $Options["gb_form"]) and in_array("Website", $Options["gb_req"])) { ?> else if (website.length==0){ form.website.focus(); isOk=false; } <?php } ?> <?php if (in_array("Comments", $Options["gb_req"])) { ?> else if (comments.length==0){ form.comments.focus(); isOk=false; } <?php } ?> <?php if($Options['captcha']=='capmath' or $Options['captcha']=='cap' or $Options['captcha']=='vsc') { // if the option is set to Math or Simple or Very Simple Captcha ?> else if (string.length==0){ message ="<?php echo ReadDB($OptionsLang["field_code"]); ?>"; form.string.focus(); isOk=false; } <?php } ?> <?php if($Options['text_confirm']=='true') { // if the verification answer is empry ?> else if (verify_answer.length==0){ message ="<?php echo $OptionsLang["wrong_answer"]; ?>"; form.verify_answer.focus(); isOk=false; } <?php } ?> if (!isOk){ alert(message); return isOk; } else { return isOk; } } function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <script type="text/javascript"> var RecaptchaOptions = { theme : '<?php echo $Options['captcha_theme']; ?>' }; </script> <div class="back_link"> <a href="<?php echo $thisPage; ?>"><?php echo ReadDB($OptionsLang["Back_home"]); ?></a> </div> <div class="clear_nav"></div> <form action="<?php echo $rootPage; ?>" method="post" name="form1" enctype="multipart/form-data"> <input type="hidden" name="act" value="post_comment" /> <table class="table_comments"> <tr> <td colspan="2" class="form_header"><?php echo ReadDB($OptionsLang["Write_Your_Comment"]); ?></td> </tr> <tr> <td class="form_left"><?php echo ReadDB($OptionsLang["Form_Name"]); ?> *</td> <td class="form_right"><input type="text" name="name" maxlength="45" value="<?php echo $_REQUEST["name"]; ?>" class="form_fields form_field_55" /></td> </tr> <?php if (in_array("Location", $Options["gb_form"])) { ?> <tr> <td class="form_left"> <?php echo ReadDB($OptionsLang["Form_Location"]); ?> <?php if (in_array("Location", $Options["gb_form"]) and in_array("Location", $Options["gb_req"])) { ?>*<?php } ?> </td> <td class="form_right"> <input type="text" name="location" maxlength="45" value="<?php echo $_REQUEST["location"]; ?>" class="form_fields form_field_55" /> </td> </tr> <?php } ?> <?php if (in_array("Email", $Options["gb_form"])) { ?> <tr> <td class="form_left"> <?php echo ReadDB($OptionsLang["Form_Email"]); ?> <?php if (in_array("Email", $Options["gb_form"]) and in_array("Email", $Options["gb_req"])) { ?>*<?php } ?> </td> <td class="form_right"> <input type="text" name="email" maxlength="45" value="<?php echo $_REQUEST["email"]; ?>" class="form_fields form_field_55" /> <?php if(!in_array("Email", $Options["gb_info"])) { ?> <sub><?php echo ReadDB($OptionsLang["Form_Emails_hidden"]); ?></sub> <?php } ?> </td> </tr> <?php } ?> <?php if (in_array("Phone", $Options["gb_form"])) { ?> <tr> <td class="form_left"> <?php echo ReadDB($OptionsLang["Form_Phone"]); ?> <?php if (in_array("Phone", $Options["gb_form"]) and in_array("Phone", $Options["gb_req"])) { ?>*<?php } ?> </td> <td class="form_right"><input type="text" name="phone" maxlength="45" value="<?php echo $_REQUEST["phone"]; ?>" class="form_fields form_field_55" /></td> </tr> <?php } ?> <?php if (in_array("Website", $Options["gb_form"])) { ?> <tr> <td class="form_left"> <?php echo ReadDB($OptionsLang["Form_Website"]); ?> <?php if (in_array("Website", $Options["gb_form"]) and in_array("Website", $Options["gb_req"])) { ?>*<?php } ?> </td> <td class="form_right"><input type="text" name="website" maxlength="45" value="<?php echo $_REQUEST["website"]; ?>" class="form_fields form_field_55" /></td> </tr> <?php } ?> <?php if (in_array("Rate", $Options["gb_form"])) { ?> <tr> <td class="form_left"> <?php echo ReadDB($OptionsLang["Form_Rate"]); ?> <?php if (in_array("Rate", $Options["gb_form"]) and in_array("Rate", $Options["gb_req"])) { ?>*<?php } ?> </td> <td class="form_right"> <select name="starsrate" class="form_dd_field"> <option value="5"<?php if($_REQUEST["starsrate"]=="5") { echo ' selected="selected"'; } ?>>*****</option> <option value="4"<?php if($_REQUEST["starsrate"]=="4") { echo ' selected="selected"'; } ?>>****</option> <option value="3"<?php if($_REQUEST["starsrate"]=="3") { echo ' selected="selected"'; } ?>>***</option> <option value="2"<?php if($_REQUEST["starsrate"]=="2") { echo ' selected="selected"'; } ?>>**</option> <option value="1"<?php if($_REQUEST["starsrate"]=="1") { echo ' selected="selected"'; } ?>>*</option> </select> </td> </tr> <?php } ?> <tr> <td class="form_right" colspan="2"> <?php echo ReadDB($OptionsLang["Form_Comments"]); ?> <?php if (in_array("Comments", $Options["gb_req"])) { ?>*<?php } ?> <textarea name="comments" id="comments" class="form_fields form_textarea" rows="6" onKeyDown="limitText(this.form.comments,this.form.countdown,<?php echo $Options["char_limit"];?>);" onKeyUp="limitText(this.form.comments,this.form.countdown,<?php echo $Options["char_limit"];?>);" onclick="limitText(this.form.comments,this.form.countdown,<?php echo $Options["char_limit"];?>);" onmousemove="limitText(this.form.comments,this.form.countdown,<?php echo $Options["char_limit"];?>);"><?php echo $_REQUEST["comments"]; ?></textarea> <script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; } //--> </script> <?php if($Options["show_smilies"]!='no') {?> <div class="padd_left4"> <?php for($i=0; $i<=19; $i++) {?> <div class="smiliesBox"> <a href="javascript:void(0)" onclick="document.getElementById('comments').value += ' <?php echo $smilies[$i][0] ?> ';document.getElementById('comments').focus();return false;" title="<?php echo $smilies[$i][1] ?>"> <?php echo $smilies[$i][2] ?> </a> </div> <?php } ?> <?php if($Options["show_add_sm"]!='no') {?> <a href="javascript:void(0)" onclick="toggle_visibility('other_smilies');" class="more_smilies"><?php echo ReadDB($OptionsLang["Form_more"]); ?></a> <?php } ?> <div class="clearboth"></div> </div> <?php } ?> <?php if($Options["show_smilies"]!='no' and $Options["show_add_sm"]!='no') {?> <div class="more_smilies_box"> <div class="padd_left4" id="other_smilies" style="display: none;position:absolute;background:#FFF; border: solid 1px #dadada; border-radius:3px; z-index: 10000;"> <div class="more_smilies_float_box"> <?php $maxSmilies = count($smilies)-10; if($Options["show_cen_sm"]!='no') { $maxSmilies = count($smilies); } for($i=20; $i<=$maxSmilies; $i++) {?> <div class="smiliesBox"> <a href="javascript:void(0)" onclick="document.getElementById('comments').value += ' <?php echo $smilies[$i][0] ?> ';document.getElementById('comments').focus();return false;" title="<?php echo $smilies[$i][1] ?>"> <?php echo $smilies[$i][2] ?> </a> </div> <?php } ?> </div> <a class="close_more_smilies" href="javascript:void(0)" onclick="toggle_visibility('other_smilies');" title="close">&#10006;</a> <div class="clearboth"></div> </div> </div> <?php } ?> <div class="clearCount"></div> <span class="padd_left4 font_size11"><input readonly type="text" name="countdown" size="3" value="<?php echo $Options["char_limit"];?>" class="form_fields" /> <?php echo ReadDB($OptionsLang["characters_left"]); ?></span> </td> </tr> <?php if (in_array("Avatar", $Options["gb_form"])) { ?> <tr> <td class="form_left"><?php echo ReadDB($OptionsLang["Form_Avatar"]); ?></td> <td class="form_right"><input type="file" name="image" size="35" class="form_upload" /> <sub><?php echo ReadDB($OptionsLang["limit_mb"]); ?></sub></td> </tr> <?php } ?> <?php if($Options['captcha']!='nocap') { // if the option is set to no Captcha ?> <tr> <td class="form_left"><?php echo ReadDB($OptionsLang["Enter_verification_code"]); ?> *</td> <td class="form_right"> <?php if($Options['captcha']=='recap') { // if the option is set to reCaptcha $publickey = "6Lfk9L0SAAAAACp13Wlzz6WTanYxrcLBXyn7XNSJ"; echo recaptcha_get_html($publickey, $error); } elseif($Options['captcha']=='capmath') { ?> <img src="<?php echo $CONFIG["full_url"]; ?>captchamath.php" class="form_captcha_img" alt="Mathematical catpcha image" id="captcha" /> <div class="form_captcha_eq"> = </div> <input type="text" name="string" maxlength="3" class="form_captcha form_captcha_math" /> <?php } elseif($Options['captcha']=='cap') { ?> <img src="<?php echo $CONFIG["full_url"]; ?>captcha.php" class="form_captcha_img" alt="Simple catpcha image" /> <input type="text" name="string" class="form_captcha form_captcha_s" /> <?php } else { ?> <img src="<?php echo $CONFIG["full_url"]; ?>captchasimple.php" class="form_captcha_img" alt="Very catpcha image" /> <input type="text" name="string" maxlength="7" class="form_captcha form_captcha_s" /> <?php } ?> </td> </tr> <?php } ?> <?php if($Options['text_confirm']=='true') { // if the verification answer is empry ?> <tr> <td colspan="2" class="form_right"> <div class="form_verify_question"><?php echo ReadDB($OptionsLang["verify_question"]); ?> * </div> <div> <input type="text" name="verify_answer" class="form_verify_answer form_fields" size="10" autocomplete="off" /> </div> </td> </tr> </tr> <?php } ?> <tr> <td class="form_right" colspan="2">* - <?php echo ReadDB($OptionsLang["Required_fields"]); ?></td> </tr> <tr> <td class="form_left">&nbsp;</td> <td class="form_right"><input name="button" type="submit" value="<?php echo ReadDB($OptionsLang["Post_Comment"]); ?>" onclick="return checkForm(this.form)" class="submitbtn" /></td> </tr> </table> </form> <?php } else { ?> <div class="back_link"> <a href="<?php echo $thisPage; ?>?act=new#gbform"><?php echo ReadDB($OptionsLang["Post_New_Comment"]); ?></a> </div> <div class="clear_nav"></div> <?php if(isset($_REQUEST["p"]) and $_REQUEST["p"]!='') { $pageNum = (int) SafetyDB(urldecode($_REQUEST["p"])); if($pageNum<=0) $pageNum = 1; } else { $pageNum = 1; } if ($Options["comments_order"]=='OnTop') { $commentOrder = 'DESC'; } else { $commentOrder = 'ASC'; } $sql = "SELECT count(*) as total FROM ".$TABLE["Comments"]." WHERE status='Approved'"; $sql_result = sql_result($sql); $row = mysqli_fetch_array($sql_result); mysqli_free_result($sql_result); $count = $row["total"]; $total_pages = $row["total"]; $adjacents = 2; // the adjacents to the current page digid when some pages are hidden $limit = $Options["per_page"]; //how many items to show per page $page = ''; if(isset($_GET["p"]) and $_GET["p"]!='') { $page = (int) SafetyDB(urldecode($_GET["p"])); } if($page) { $start = ($page - 1) * $limit; //first item to display on this page } else { $start = 0; //if no page var is given, set start to 0 } /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 // pagination query and variables ends ?> <?php if($Options["show_comm_number"]=="yes") {?> <div class="visitors_signed"> <?php echo $count; ?> <?php echo ReadDB($OptionsLang["Visitors_signed"]); ?> </div> <?php } ?> <?php $sql = "SELECT * FROM ".$TABLE["Comments"]." WHERE status='Approved' ORDER BY publish_date " . $commentOrder." LIMIT " . ($pageNum-1)*$Options["per_page"] . "," . $Options["per_page"]; $sql_result = sql_result($sql); if (mysqli_num_rows($sql_result)>0) { while ($Comments = mysqli_fetch_array($sql_result)) { ?> <table class="table_comments"> <tr> <td class="form_header width_33"><?php echo ReadDB($OptionsLang["Posted_by"]); ?></td> <td class="form_header"><?php echo ReadDB($OptionsLang["Comments"]); ?></td> </tr> <tr> <td rowspan="2" class="comm_left"> <?php if(stripslashes($Comments["image"]) != "") { ?> <div class="padd_bott2"><img class="avatar_img" src="<?php echo $CONFIG["full_url"].$CONFIG["upload_folder"].ReadDB($Comments["image"]); ?>" /></div> <?php } elseif($OptionsVis["show_sample_avat"]=='yes') { ?> <div class="padd_bott2"><img class="avat_no_img" src="<?php echo $CONFIG["full_url"]; ?>images/no_image.png" /></div> <?php } ?> <div class="info_commenter"><?php echo ReadDB($OptionsLang["Name"]); ?> <?php echo ReadHTML($Comments["name"]); ?> </div> <?php if(trim($Comments["location"])!='' and in_array("Location", $Options["gb_info"])) { ?> <div class="info_commenter"> <?php echo ReadDB($OptionsLang["Location"]); ?> <?php echo ReadHTML($Comments["location"]); ?> </div> <?php } ?> <?php if(trim($Comments["email"])!='' and in_array("Email", $Options["gb_info"])) { ?> <div class="info_commenter"> <?php echo ReadDB($OptionsLang["Email"]); ?> <?php echo ReadHTML($Comments["email"]); ?> </div> <?php } ?> <?php if(trim($Comments["phone"])!='' and in_array("Phone", $Options["gb_info"])) { ?> <div class="info_commenter"> <?php echo ReadDB($OptionsLang["Phone"]); ?> <?php echo ReadHTML($Comments["phone"]); ?> </div> <?php } ?> <?php if(trim($Comments["website"])!='' and in_array("Website", $Options["gb_info"])) { ?> <div class="info_commenter"><?php echo ReadDB($OptionsLang["Website"]); ?> <?php if(in_array("clickable", $Options["gb_info"])) { echo hyperlink(ReadHTML($Comments["website"])); } else { echo ReadHTML($Comments["website"]); } ?> </div> <?php } ?> </td> <td class="comm_reply_td"> <div class="comm_text"> <?php echo smilies(nl2br(ReadHTML($Comments["comments"]))); ?> </div> <?php if(trim($Comments["reply"])!='') {?> <div class="reply_text"><?php echo ReadDB($OptionsLang["Reply"]); ?> <?php echo smilies(nl2br(ReadHTML($Comments["reply"]))); ?></div> <?php } ?> </td> </tr> <tr> <td class="stars_date_wrap_td"> <table class="table_stars_date"> <tr> <?php if($Comments["starsrate"]!='') {?> <td class="stars_td"> <div class="stars_wrap"> <?php for ($i=1;$i<=$Comments["starsrate"]; $i++) {?> <img src="<?php echo $CONFIG["full_url"]; ?>images/ratestar.png" width="<?php echo ((int)(substr($OptionsVis["date_size"],0,-2))+1);?>" alt="rating" /> <?php } ?> </div> </td> <?php } ?> <?php if($OptionsVis["show_date"]=='yes') {?> <td> <div class="date_style"> <?php echo ReadDB($OptionsLang["Posted_on"]); ?> <?php echo lang_date(date($OptionsVis["date_format"],strtotime($Comments["publish_date"]))); ?> </div> </td> <?php } ?> </tr> </table> </td> </tr> </table> <div class="dist_comments"></div> <?php } } else { ?> <?php echo ReadDB($OptionsLang["No_comments_posted"]); ?> <?php } ?> <!-- Pagination start here --> <div class="pagination_wrapper"> <?php // pagination starts. It can be shown wherever we need if($lastpage > 1) { // defining recurring url variables $paging_vars = "&amp;cat_id=".urlencode($_REQUEST["cat_id"])."&amp;search=".urlencode($_REQUEST["search"]); ?> <div class="pagination"> <?php //previous button starts if ($page > 1) { ?> <a class="next_prev" href="<?php echo $thisPage."?p=".$prev;?><?php echo $paging_vars; ?>"><?php echo $OptionsLang["Previous"];?></a> <?php } else { ?> <span class="disabled"><?php echo $OptionsLang["Previous"]; ?></span> <?php } //previous button ends //pages start if ($lastpage < 7 + ($adjacents * 2)) { //not enough pages to bother breaking it up for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) { ?> <span class="current"><?php echo $counter; ?></span> <?php } else { ?> <a href="<?php echo $thisPage."?p=".$counter; ?><?php echo $paging_vars; ?>"><?php echo $counter; ?></a> <?php } } } elseif($lastpage > 5 + ($adjacents * 2)) { //enough pages to hide some //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) { ?> <span class="current"><?php echo $counter; ?></span> <?php } else { ?> <a href="<?php echo $thisPage."?p=".$counter;?><?php echo $paging_vars; ?>"><?php echo $counter;?></a> <?php } } ?> ...<a href="<?php echo $thisPage."?p=".$lpm1; ?><?php echo $paging_vars; ?>"><?php echo $lpm1; ?></a> <a href="<?php echo $thisPage."?p=".$lastpage; ?><?php echo $paging_vars; ?>"><?php echo $lastpage; ?></a> <?php } elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { //in middle; hide some front and some back ?> <a href="<?php echo $thisPage; ?>?p=1<?php echo $paging_vars; ?>">1</a> <a href="<?php echo $thisPage; ?>?p=2<?php echo $paging_vars; ?>">2</a>... <?php for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) { ?> <span class="current"><?php echo $counter; ?></span> <?php } else { ?> <a href="<?php echo $thisPage."?p=".$counter; ?><?php echo $paging_vars; ?>"><?php echo $counter; ?></a> <?php } } ?> ...<a href="<?php echo $thisPage."?p=".$lpm1; ?><?php echo $paging_vars; ?>"><?php echo $lpm1; ?></a> <a href="<?php echo $thisPage."?p=".$lastpage; ?><?php echo $paging_vars; ?>"><?php echo $lastpage; ?></a> <?php } else { //close to end; only hide early pages ?> <a href="<?php echo $thisPage; ?>?p=1<?php echo $paging_vars; ?>">1</a> <a href="<?php echo $thisPage; ?>?p=2<?php echo $paging_vars; ?>">2</a>... <?php for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) { ?> <span class="current"><?php echo $counter; ?></span> <?php } else { ?> <a href="<?php echo $thisPage."?p=".$counter; ?><?php echo $paging_vars; ?>"><?php echo $counter; ?></a> <?php } } } } //next button if ($page < $counter - 1) { ?> <a class="next_prev" href="<?php echo $thisPage."?p=".$next; ?><?php echo $paging_vars; ?>"><?php echo $OptionsLang["Next"]; ?></a> <?php } else { ?> <span class="disabled"><?php echo $OptionsLang["Next"]; ?></span> <?php } ?> </div> <?php } // pagination ends ?> </div> <!-- Pagination end here --> <?php } ?> </div> </div> Can you see anything obvious why a new comment post does not work? (white screen, no error log). The developer is still in business so I guess I could contact them & see if they have a new script for later versions of PHP but just wondering if anything stands out as an easy fix! Thanks again.
  19. That works. So, if I'm understanding correctly the (custom) error handler is now ignoring deprecated messages? (so doing what the Smarty system is currently doing). Going forward, as this will be removed in PHP 9 Smarty will have to fix the issue? Thanks for your help, much appreciated.
  20. There is also this file (smarty_internal_errorhandler.php) <?php /** * Smarty error handler to fix new error levels in PHP8 for backwards compatibility * * @package Smarty * @subpackage PluginsInternal * @author Simon Wisselink * */ class Smarty_Internal_ErrorHandler { /** * Allows {$foo} where foo is unset. * @var bool */ public $allowUndefinedVars = true; /** * Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset. * @var bool */ public $allowUndefinedArrayKeys = true; private $previousErrorHandler = null; /** * Enable error handler to intercept errors */ public function activate() { /* Error muting is done because some people implemented custom error_handlers using https://php.net/set_error_handler and for some reason did not understand the following paragraph: It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator. */ $this->previousErrorHandler = set_error_handler([$this, 'handleError']); } /** * Disable error handler */ public function deactivate() { restore_error_handler(); $this->previousErrorHandler = null; } /** * Error Handler to mute expected messages * * @link https://php.net/set_error_handler * * @param integer $errno Error level * @param $errstr * @param $errfile * @param $errline * @param $errcontext * * @return bool */ public function handleError($errno, $errstr, $errfile, $errline, $errcontext = []) { if ($this->allowUndefinedVars && $errstr == 'Attempt to read property "value" on null') { return; // suppresses this error } if ($this->allowUndefinedArrayKeys && preg_match( '/^(Undefined array key|Trying to access array offset on value of type null)/', $errstr )) { return; // suppresses this error } // pass all other errors through to the previous error handler or to the default PHP error handler return $this->previousErrorHandler ? call_user_func($this->previousErrorHandler, $errno, $errstr, $errfile, $errline, $errcontext) : false; } }
  21. The site has this code for errors : - <?php // set the user error handler method to be tss_error_handler set_error_handler("error_handler", E_ALL); // error handler function function error_handler($errNo, $errStr, $errFile, $errLine) { // '@'-prepended expressions from the Mail class of the PEAR library // generate irrelevant warning messages that we choose to ignore // (errors_reporting() is set to 0 when such warnings are generated) if (error_reporting() == 0) return; /* the first two elements of the backtrace array are irrelevant: -DBG_Backtrace -outErrorHandler */ $backtrace = dbg_get_backtrace(2); // error message to be displayed, logged or mailed $error_message = "\nERRNO: $errNo \nTEXT: " . $errStr . " \n" . "LOCATION: " . $errFile . ", line " . $errLine . ", at " . date("F j, Y, g:i a") . "\nShowing backtrace:\n" . $backtrace . "\n\n"; // log the error, in case LOG_ERRORS is true if (LOG_ERRORS == true) { if (file_exists(LOG_ERRORS_FILE)) { error_log($error_message, 3, LOG_ERRORS_FILE); } else { file_put_contents(LOG_ERRORS_FILE, $error_message, FILE_APPEND); // email the first error details, in case SEND_ERROR_MAIL is true if (SEND_ERROR_MAIL == true) { error_log($error_message, 1, ERROR_EMAIL, "From: " . SENDMAIL_FROM . "\r\nTo: " . ERROR_EMAIL); } } } // warnings don't abort execution if IS_WARNING_FATAL is false // E_NOTICE and E_USER_NOTICE errors don't abort execution if (($errNo == E_WARNING && IS_WARNING_FATAL == false) || ($errNo == E_NOTICE || $errNo == E_USER_NOTICE)) { // if the error is non-fatal... show message only if DEBUGGING is true if (DEBUGGING == true) { echo "<pre>" . $error_message . "</pre>"; } } else { // if error is fatal... show error message if (DEBUGGING == true) { echo "<pre>" . $error_message . "</pre>"; } else { header ("Location: /site-error.php"); } // stop processing the request exit; } } // builds backtrace message function dbg_get_backtrace($irrelevantFirstEntries) { $s = ''; $MAXSTRLEN = 64; $traceArr = debug_backtrace(); for ($i = 0; $i < $irrelevantFirstEntries; $i++) { array_shift($traceArr); } $tabs = sizeof($traceArr) - 1; foreach($traceArr as $arr) { $tabs -= 1; if (isset($arr['class'])) { $s .= $arr['class'] . '.'; } $args = array(); if (!empty($arr['args'])) { foreach($arr['args']as $v) { if (is_null($v)) { $args[] = 'null'; } else if (is_array($v)) { $args[] = 'Array[' . sizeof($v).']'; } else if (is_object($v)) { $args[] = 'Object:' . get_class($v); } else if (is_bool($v)) { $args[] = $v ? 'true' : 'false'; } else { $v = (string)@$v; $str = htmlspecialchars(substr($v, 0, $MAXSTRLEN)); if (strlen($v) > $MAXSTRLEN) { $str .= '...'; } $args[] = "\"" . $str . "\""; } } } $s .= $arr['function'] . '(' . implode(', ', $args) . ')'; $Line = (isset($arr['line']) ? $arr['line']: "unknown"); $File = (isset($arr['file']) ? $arr['file']: "unknown"); $s .= sprintf(" # line %4d, file: %s", $Line, $File, $File); $s .= "\n"; } return $s; } ?>
  22. So I'm looking at updating a site for PHP 8.1, the template uses this for the current date : - {$smarty.now|date_format:"%Y"} Which is giving this error : - ERRNO: 8192 TEXT: Function strftime() is deprecated What's the best way to fix this? I thought Smarty 4.3.0 was PHP 8.1 ready? Someone suggested suppressing the error but I'd rather fix it than ignore it! Thanks for any help.
  23. I forgot to update this (found this thread while searching for something else!). I fixed it by changing line 601 to page = null;
  24. Sorted it, I think! RewriteEngine On RewriteCond %{REQUEST_URI} !^/admin/ RewriteCond %{DOCUMENT_ROOT}/site-error.php -f RewriteCond %{DOCUMENT_ROOT}/admin/maintenance.enable -f RewriteCond %{SCRIPT_FILENAME} !site-error.php RewriteRule .*$ /site-error.php [R=503,L] ErrorDocument 503 /site-error.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.