PHP Merging files not working - php

Merging files isn't working anymore and I'm not sure why. I'm not getting any on-screen errors so I checked my error log and this is what I see:
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP 1. {main}() /home/toolplas/public_html/main/phplib/edit_workorder.php:0, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Warning: Invalid argument supplied for foreach() in /home/toolplas/public_html/main/phplib/edit_workorder.php on line 50, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Stack trace:, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP 1. {main}() /home/toolplas/public_html/main/phplib/edit_workorder.php:0, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Notice: Undefined index: affect in /home/toolplas/public_html/main/phplib/edit_workorder.php on line 80, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Stack trace:, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP 1. {main}() /home/toolplas/public_html/main/phplib/edit_workorder.php:0, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Notice: Undefined index: file in /home/toolplas/public_html/main/phplib/edit_workorder.php on line 282, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Stack trace:, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP 1. {main}() /home/toolplas/public_html/main/phplib/edit_workorder.php:0, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Warning: Invalid argument supplied for foreach() in /home/toolplas/public_html/main/phplib/edit_workorder.php on line 282, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Stack trace:, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP 1. {main}() /home/toolplas/public_html/main/phplib/edit_workorder.php:0, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/toolplas/public_html/main/edit_workorder.php on line 176, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP Stack trace:, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
[Tue Mar 18 09:06:08 2014] [error] [client 10.0.50.12] PHP 1. {main}() /home/toolplas/public_html/main/edit_workorder.php:0, referer: https://new.tps.com/edit_workorder.php?job_num=1000&id=4173
Its not specific to one Work Order as its happening to all of them and I'm not sure why its no longer working.
Here's the code:
if(isset($wo['files_to_merge'])){
//$prev_files = $_POST['file'];
//$files = $_FILES['file'];
$folder = "/home/toolplas/public_html/main/pdf/temp/WO$wo_id/";
if(!file_exists($folder)){
mkdir($folder);
}
$files = array();
if(isset($_POST['file'])){
foreach($_POST['file'] as $key => $item){
$files[] = array('order' => $key, 'filename' => $item);
}
}
/*foreach($_FILES['file']['name'] as $key => $item){
$name = date('U') . preg_replace('/[^\w\._]+/', '', basename($item));
if(move_uploaded_file($_FILES['file']['tmp_name'][$key], $folder . $name)){
$files[] = array('order' => $key, 'filename' => $name);
} else {
debug('File Not Uploaded ' . $name);
}
}*/
foreach($_FILES['file']['error'] as $key => $error){
$tmp_name= $_FILES['file']['tmp_name'][$key];
$name = date('U') . preg_replace('/[^\w\._]+/', '', basename($_FILES['file']['name'][$key]));
if($error == UPLOAD_ERR_OK){
move_uploaded_file($tmp_name, $folder . $name);
$files[] = array('order' => $key, 'filename' => $name);
} else {
debug("Cannot Move File: $tmp_name -> $name");
debug("File Error: $error");
}
}
$sql = "DELETE FROM workorder_files WHERE workorder_id = $wo_id;";
echo $sql;
mysqli_query($dbc3, $sql) or die("Query 11: " . mysqli_error($dbc3));
foreach($files as $file){
$sql = "INSERT INTO workorder_files(workorder_id, filename, `order`) VALUES($wo_id, '" . $file['filename'] . "', " . $file['order'] . ");";
mysqli_query($dbc3, $sql) or die("Query 12: " . mysqli_error($dbc3));
}
//print_r($_FILES);
}
Employees told me it was working fine Friday and over the weekend.
This is what the form looks like,
HTML:
<tr>
<th>Files To Merge?</th>
<td><input type="checkbox" class='files_to_merge' id="files_to_merge" name='workorder[files_to_merge]' {% if files is not empty %}checked='checked'{% endif %} />{{ functions.alert('More to the right') }}</td>
</tr>
<tr>
<th>Posted By</th>
<td>{{ user.name }}<input readonly="readonly" type="hidden" name="workorder[user]" value="{{ user.id }}" /></td>
</tr>

Related

receive null as response from get_nodes_list proxmox php api

im trying to use Proxmox's PHP Api to create new container but when i'm trying to send request to do so i receive this in error log of apache:
----------------------------------------------
FULL RESPONSE:\n\nHTTP/1.1 200 OK\r\nCache-Control: max-age=0\r\nConnection: Keep-Alive\r\nDate: Sat, 21 Oct 2017 19:12:24 GMT\r\nPragma: no-cache\r\nServer: pve-api-daemon/3.0\r\nContent-Length: 197\r\nContent-Type: application/json;charset=UTF-8\r\nExpires: Sat, 21 Oct 2017 19:12:24 GMT\r\n\r\n{"data":[{"maxdisk":1890533244928,"type":"node","id":"node/px2","disk":2463367168,"maxmem":8335933440,"uptime":270689,"cpu":0.0131703340463503,"maxcpu":4,"node":"px2","mem":4635709440,"level":""}]}\n\nEND FULL RESPONSE\n\nHeaders:\n\nHTTP/1.1 200 OK\r\nCache-Control: max-age=0\r\nConnection: Keep-Alive\r\nDate: Sat, 21 Oct 2017 19:12:24 GMT\r\nPragma: no-cache\r\nServer: pve-api-daemon/3.0\r\nContent-Length: 197\r\nContent-Type: application/json;charset=UTF-8\r\nExpires: Sat, 21 Oct 2017 19:12:24 GMT\n\nEnd Headers\n\nData:\n\n{"data":[{"maxdisk":1890533244928,"type":"node","id":"node/px2","disk":2463367168,"maxmem":8335933440,"uptime":270689,"cpu":0.0131703340463503,"maxcpu":4,"node":"px2","mem":4635709440,"level":""}]}\n\nEnd Data\n\nRESPONSE ARRAY:\n\narray (\n 'data' => \n array (\n 0 => \n array (\n 'maxdisk' => 1890533244928,\n 'type' => 'node',\n 'id' => 'node/px2',\n 'disk' => 2463367168,\n 'maxmem' => 8335933440,\n 'uptime' => 270689,\n 'cpu' => 0.013170334046350299,\n 'maxcpu' => 4,\n 'node' => 'px2',\n 'mem' => 4635709440,\n 'level' => '',\n ),\n ),\n)\n\nEND RESPONSE ARRAY\n----------------------------------------------
[:error] [pid 9148:tid 924] [client ::1:58574] ----------------------------------------------\nFULL RESPONSE:\n\nHTTP/1.1 200 OK\r\nCache-Control: max-age=0\r\nConnection: Keep-Alive\r\nDate: Sat, 21 Oct 2017 19:12:24 GMT\r\nPragma: no-cache\r\nServer: pve-api-daemon/3.0\r\nContent-Length: 197\r\nContent-Type: application/json;charset=UTF-8\r\nExpires: Sat, 21 Oct 2017 19:12:24 GMT\r\n\r\n{"data":[{"uptime":270689,"disk":2463367168,"maxmem":8335933440,"id":"node/px2","type":"node","maxdisk":1890533244928,"level":"","mem":4635709440,"node":"px2","maxcpu":4,"cpu":0.0131703340463503}]}\n\nEND FULL RESPONSE\n\nHeaders:\n\nHTTP/1.1 200 OK\r\nCache-Control: max-age=0\r\nConnection: Keep-Alive\r\nDate: Sat, 21 Oct 2017 19:12:24 GMT\r\nPragma: no-cache\r\nServer: pve-api-daemon/3.0\r\nContent-Length: 197\r\nContent-Type: application/json;charset=UTF-8\r\nExpires: Sat, 21 Oct 2017 19:12:24 GMT\n\nEnd Headers\n\nData:\n\n{"data":[{"uptime":270689,"disk":2463367168,"maxmem":8335933440,"id":"node/px2","type":"node","maxdisk":1890533244928,"level":"","mem":4635709440,"node":"px2","maxcpu":4,"cpu":0.0131703340463503}]}\n\nEnd Data\n\nRESPONSE ARRAY:\n\narray (\n 'data' => \n array (\n 0 => \n array (\n 'uptime' => 270689,\n 'disk' => 2463367168,\n 'maxmem' => 8335933440,\n 'id' => 'node/px2',\n 'type' => 'node',\n 'maxdisk' => 1890533244928,\n 'level' => '',\n 'mem' => 4635709440,\n 'node' => 'px2',\n 'maxcpu' => 4,\n 'cpu' => 0.013170334046350299,\n ),\n ),\n)\n\nEND RESPONSE ARRAY\n----------------------------------------------
[:error] [pid 9148:tid 924] [client ::1:58574] ----------------------------------------------\nFULL RESPONSE:\n\nHTTP/1.1 501 Method 'POST /nodes/px2/openvz' not implemented\r\nCache-Control: max-age=0\r\nConnection: close\r\nDate: Sat, 21 Oct 2017 19:12:24 GMT\r\nPragma: no-cache\r\nServer: pve-api-daemon/3.0\r\nContent-Length: 13\r\nContent-Type: application/json;charset=UTF-8\r\nExpires: Sat, 21 Oct 2017 19:12:24 GMT\r\n\r\n{"data":null}\n\nEND FULL RESPONSE\n\nHeaders:\n\nHTTP/1.1 501 Method 'POST /nodes/px2/openvz' not implemented\r\nCache-Control: max-age=0\r\nConnection: close\r\nDate: Sat, 21 Oct 2017 19:12:24 GMT\r\nPragma: no-cache\r\nServer: pve-api-daemon/3.0\r\nContent-Length: 13\r\nContent-Type: application/json;charset=UTF-8\r\nExpires: Sat, 21 Oct 2017 19:12:24 GMT\n\nEnd Headers\n\nData:\n\n{"data":null}\n\nEnd Data\n\nRESPONSE ARRAY:\n\narray (\n 'data' => NULL,\n)\n\nEND RESPONSE ARRAY\n----------------------------------------------
[:error] [pid 9148:tid 924] [client ::1:58574] This API Request Failed.\nHTTP Response - 501\nHTTP Error - HTTP/1.1 501 Method 'POST /nodes/px2/openvz' not implemented
I've only one Node called px2, when i call function to get nodes list as a response i get NULL. So i tried to put node name into path manually, but then received these errors in error.log
I'm using Proxmox v5.0-30, and as API i'm using this: https://github.com/CpuID/pve2-api-php-client
--- EDIT:
The Code used to create container:
<?php
require ('pve-1/pve2_api.class.php');
$pve2 = new PVE2_API("10.11.12.89", "root", "pam", "password");
$pve2->login();
if ($pve2->login()) {
# Get first node name.
$nodes = $pve2->get_node_list();
$first_node = $nodes[0];
unset($nodes);
$vm
# Create a VZ container on the first node in the cluster.
$new_container_settings = array();
$new_container_settings['ostemplate'] = "local:vztmpl/ubuntu-16.04-standard_16.04-1_amd64.tar.gz";
$new_container_settings['vmid'] = "7777";
$new_container_settings['cpus'] = "2";
$new_container_settings['description'] = "106(test-container)";
$new_container_settings['disk'] = "8";
$new_container_settings['hostname'] = "testapi.domain.tld";
$new_container_settings['memory'] = "1024";
$new_container_settings['nameserver'] = "10.11.12.233";
print_r($new_container_settings);
print("---------------------------\n");
var_dump($pve2->post("/nodes/px2/openvz", $new_container_settings));
print("\n\n");
} else {
print("Login to Proxmox Host failed.\n");
exit;
}

PHP error handling- Undefined offset

I've checked my apache error logs, and I see multiple messages like this:
client 108.162.246.190] PHP Notice: Undefined offset: 4 in /var/www/html/search.php on line 142
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 5 in /var/www/html/search.php on line 142
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 5 in /var/www/html/search.php on line 143
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 6 in /var/www/html/search.php on line 142
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 6 in /var/www/html/search.php on line 143
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 7 in /var/www/html/search.php on line 142
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 7 in /var/www/html/search.php on line 143
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 8 in /var/www/html/search.php on line 142
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 8 in /var/www/html/search.php on line 143
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 9 in /var/www/html/search.php on line 142
[Tue Dec 31 00:17:48 2013] [error] [client 108.162.246.190] PHP Notice: Undefined offset: 9 in /var/www/html/search.php on line 143
And code around 142-143 lines looks like this (the actual 142-143 lines are implode ones):
if ($nuorodoshut != NULL)
{
foreach ($nuorodoshut as $key => $nuorodahut)
{
$keywords = explode(' ', $qsvarus);
$title[$key] = preg_replace('/\b('.implode('|', $keywords).')\b(?![^<]*[>])/i', '<b>$0</b>', $title[$key]);
$infoo[$key] = preg_replace('/\b('.implode('|', $keywords).')\b(?![^<]*[>])/i', '<b>$0</b>', $infoo[$key]);
echo '<tr><td><h3>';
echo str_replace('<a href="/', '<a href="/host/', $nuorodahut->innertext) . '</h3>';
echo $aprasymashut[$key]->innertext . '<br>';
}
}
I just can't handle this error. Any help would be appreciated
The error messages are telling you that there's no $title[$key] and $infoo[$key] when $key is 5 - 9. If these two arrays should have all the same indexes as $nuorodoshut, then something is wrong in the creation of the arrays.
If it's OK that they shouldn't have these elements, you need to check this before you try using the values, e.g.
$title[$key] = isset($title[$key]) ? preg_replace('/\b('.implode('|', $keywords).')\b(?![^<]*[>])/i', '<b>$0</b>', $title[$key]) : '';
$infoo[$key] = isset($infoo[$key]) ? preg_replace('/\b('.implode('|', $keywords).')\b(?![^<]*[>])/i', '<b>$0</b>', $infoo[$key]) : '';

Unable to send email using PHP Pear

I tried to send email using pear. Here is my code
<?php
require_once "/usr/share/pear/Mail.php";
require_once "/usr/share/pear/Mail/mime.php";
$to = "Info <info#mydomain.com>";
$subject = "Contact Form - mydomain.com\r\n\r\n";
$host = "smtp.zoho.com";
$username = "noreply#mydomain.com";
$password = "abc#123";
$port = "465";
//Sender Details
$sender_name = $_POST['name'];
$from = $_POST['name']." <".$_POST['email'].">";
$sender_phone = $_POST['phone'];
//Create Message
$body = $_POST['message'];
//$body = wordwrap($body, 70, "\r\n");
$body = $body . "\r\n" . "Phone: " .$sender_phone;
if($sender_name != "" && $_POST['email'] != "" && $body != "" && $sender_phone != "")
{
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Reply-To: ' => $from);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
header("Location:contact-us.php?mcode=1");
}
}
else
{
header("Location:contact-us.php?mcode=2");
}
?>
Now this code gives me the following error in browser:
When I checked my php error_log i found this:
[Tue Dec 17 08:46:56 2013] [notice] child pid 7416 exit signal Segmentation fault (11)
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: name in /var/www/html/contact-us-process.php on line 14
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace:
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: name in /var/www/html/contact-us-process.php on line 15
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace:
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: email in /var/www/html/contact-us-process.php on line 15
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace:
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: phone in /var/www/html/contact-us-process.php on line 16
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace:
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: message in /var/www/html/contact-us-process.php on line 19
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace:
[Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0
[Tue Dec 17 08:47:45 2013] [notice] child pid 6887 exit signal Segmentation fault (11)
[Tue Dec 17 08:50:26 2013] [notice] child pid 7414 exit signal Segmentation fault (11)
[Tue Dec 17 09:35:48 2013] [error] [client 117.198.124.73] File does not exist: /var/www/html/favicon.ico
[Tue Dec 17 09:39:46 2013] [notice] child pid 8617 exit signal Segmentation fault (11)
I am using Rackspace cloud with Zoho email system.
When I did:
[root#mydomain /]# find -name Mail.php
./usr/share/pear/Mail.php
Thats why I directly included it in php file,
Also when I did,
[root#mydomain /]# find -name mime.php
./usr/share/pear/Mail/mime.php
So I used require_once "/usr/share/pear/Mail/mime.php", However this was there in an example, I am not so sure why I used this line.
What could be the possible reason for this and how i can solve it ?
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "username"; // SMTP account username example
$mail->Password = "password"; // SMTP account password example
You can find more about PHPMailer here: https://code.google.com/a/apache-extras.org/p/phpmailer/

php error_log weirdness

i have a global variable debug_smart404 in my smart404.php code:
$debug_smart404 = intval(get_option('debug_smart404' ));
error_log("smart404_redirect: debug_smart404 =" . ( $debug_smart404 ) );
which i use numerous places:
if ( $debug_smart404 > 4 ) # lotsa debug!
{
error_log("smart404_redirect: take_1st_match=" . ( $take_1st_match ? "yes" : "no" ) );
error_log("smart404_redirect: take_exact_match=" . ( $take_exact_match ? "yes" : "no" ) );
error_log("smart404_redirect: search_whole_uri=" . ( $search_whole_uri ? "yes" : "no" ) );
error_log("smart404_redirect: walk_uri=" . ( $walk_uri ? "yes" : "no" ) );
error_log("smart404_redirect: ignored_patterns_input=" . $patterns );
error_log("smart404_redirect: ignored_patterns_array=" . join($patterns_array,",") );
error_log("smart404_redirect: search_groups=" . join($search_groups,","));
}
while ( TRUE )
{
error_log("smart404_redirect:inside while: debug_smart404 =" . ( $debug_smart404 ) );
...
if ( $debug_smart404 > 3 ) # less debug
{
error_log("smart404_redirect: search_words=" . $search_words);
}
...
if ( $debug_smart404 > 0 ) {
error_log("smart404_redirect: uri=" . $uri . "= #matches=" . $mct);
}
...
} #end while...
so when i set debug_smart404 == 5, i get the expected output for the instances outside the while:
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: debug_smart404 =5
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: take_1st_match=yes
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: take_exact_match=yes
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: search_whole_uri=no
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: walk_uri=yes
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: ignored_patterns_input=wp-.*\r\n(ing|s|er|est)$\r\nprivate/.*
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: ignored_patterns_array=#wp-.*#i,#(ing|s|er|est)$#i,#private/.*#i,#/(trackback|feed|(comment-)?page-?[0-9]*)/?$#i,#\\.(html|php)$#i,#/?\\?.*#i
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect: search_groups=pages,posts,categories
[Thu Mar 14 08:32:42 2013] [error] [client xx.xx.xx.xx] smart404_redirect:inside while: debug_smart404 =5
but note that the error_log output inside the while loop's if statements is missing...but only on my production server (a netsol vps)
it works fine on my test server (lighttpd):
2013-03-14 08:26:40: (mod_fastcgi.c.2711) FastCGI-stderr: smart404_redirect: debug_smart404 =5
smart404_redirect: take_1st_match=no
smart404_redirect: take_exact_match=no
smart404_redirect: search_whole_uri=yes
smart404_redirect: walk_uri=yes
smart404_redirect: ignored_patterns_input=wp-.*
(ing|s|er|est)$
private/.*
smart404_redirect: ignored_patterns_array=#wp-.*#i,#(ing|s|er|est)$#i,#private/.*#i,#/(trackback|feed|(comment-)?page-?[0-9]*)/?$#i,#\.(html|php)$#i,#/?\?.*#i
smart404_redirect: search_groups=pages,posts,categories
smart404_redirect:inside while: debug_smart404 =5
smart404_redirect: search_words=cavitronix.com xxx zzzxxxx
smart404_redirect: uri=/cavitronix.com//xxx/zzzxxxx= #matches=0
wtf??? running php5 on both, and it used to work on vps (debug=1 output here)-:
[Thu Mar 14 06:32:55 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/how-it-works= #matches=1
[Thu Mar 14 06:41:32 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/videos/e2c-overview/private/awstats/current/new.html= #matches=10
[Thu Mar 14 06:53:38 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/current/previous.html= #matches=3
[Thu Mar 14 06:54:47 2013] [error] [client xx.xx.xx.xx] smart404_redirect: uri=/press-releases= #matches=3
or is this some feature of netsol's vps hackery?
The error log inside the while IS printed; your own paste of the error log from production server shows it "inside while: debug_smart404 =5"
You have missed a lot of code behind that '...'. Is it possible that your code gets inside the while loop, but then (on production) either quickly breaks out/or continues, BEFORE it reaches the other error log statements. Can you rule that out positively?

php move_uploaded_file forcely gives new name

I am trying to upload file using php, code snippt
$upload_path = "/var/upload/" . $_FILES['mfile']['name'];
if(move_uploaded_file($_FILES['mfile']['tmp_name'], $upload_path))
echo "file uploaded";
else
echo "upload failed";
Note: that /var/upload directory exists and has 777 permission.
The code prints "upload failed"
When I check /var/upload directory, there is file f_505bf77bd8a0f_mypdf.pdf. What went wrong?
Added log ( as per requested by loler):
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: showdebug in /Volumes/data/htdocs/ebeu/upload.php on line 558, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: showdebug in /Volumes/data/htdocs/ebeu/upload.php on line 559, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: accessories in /var/www/my/web/folder/myupload.php on line 21, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: pmaterial in /var/www/my/web/folder/myupload.php on line 27, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: occupation_bwc in /var/www/my/web/folder/myupload.php on line 33, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: occupation_bwc in /var/www/my/web/folder/myupload.php on line 75, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: occupation_spec in /var/www/my/web/folder/myupload.php on line 75, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined index: babycarrier in /var/www/my/web/folder/myupload.php on line 78, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: accessories_all in /var/www/my/web/folder/myupload.php on line 79, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice: Undefined variable: pmaterials_all in /var/www/my/web/folder/myupload.php on line 80, referer: http://localhost/upload/test/upload.php
Added var_dump($_FILES)
array(1) {
["mfile"]=>
array(5) {
["name"]=>
string(23) "mypdf.pdf"
["type"]=>
string(15) "application/pdf"
["tmp_name"]=>
string(26) "/var/tmp/phpUl6k50"
["error"]=>
int(0)
["size"]=>
int(478704)
}
}
Try this code for upload your files..
if (file_exists("/var/upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/var/upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/var/upload/" . $_FILES["file"]["name"];
}
In your var_dump() there $_FILES["file"]["name"] length is 23, but it should be 9. so try to trim this string. instead of
$upload_path = "/var/upload/" . $_FILES['mfile']['name'];
try to write
$upload_path = "/var/upload/" . trim($_FILES['mfile']['name']);

Categories