Jump to content

Recommended Posts

Hello All,

Been learning php for last 1 week only :(

 

I have 2 php scripts out of which 1 has stopped working last week. 1 script binds to ldap and update a webpage which has some phone numbers. This is working fine through a cron. The other script is used to retrieve and display newsletter style emails on the same webpage (created in symfony and uses fck editor). Not sure whether you understand the issue but please feel free to ask further. I want 3 types of emails to be fetched and displayed on my homepage such as bulletin, socialnews etc.

 

This is the affected php (/home/lib/batch/newsletter.php):

#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/../../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
sfContext::createInstance($configuration);
// Remove the following lines if you don't use the database layer
$databaseManager = new sfDatabaseManager($configuration);
$databaseManager->loadConfiguration();
require_once 'Mail/mimeDecode.php';
require_once 'Mail/RFC822.php';
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$raw_email = file_get_contents("php://stdin");
$decoder = new Mail_mimeDecode($raw_email);
$structure = $decoder->decode($params);
# The timestamp of the sent email.
$timestamp = strtotime($structure->headers['date']);
# Check if its a mime encoded message or a plain text message
if (isset($structure->parts[0]))
{
# Mime encoded
$message = $structure->parts[0]->body;
}
else
{
# Plain text
$message = $structure->body;
}
$message = trim(strip_tags($message));
# If the message is blank then exit
if (strlen($message) == 0 )	 { die; }
$subject = str_replace("[bulletin] ","",$structure->headers['subject']);
$send_date = $structure->headers['date'];
$from_address_array = Mail_RFC822::parseAddressList($structure->headers['return-path']);
$from_address = trim(strtolower($from_address_array[0]->mailbox ."@". $from_address_array[0]->host));
foreach(Mail_RFC822::parseAddressList($structure->headers['to']) as $item)
{
$to = strtolower($item->mailbox);
break;
}
switch ($to)
{
case "bulletin":
$type = 1; # Bulletin
break;
case "seminars":
$type = 2; # Seminars
break;
case "socialnews":
$type = 3; # Seminars
break;
}
$notice = new Notice();
$notice->setNoticeTypeId($type);
$notice->setText($message);
$notice->setSubject($subject);
$notice->Save();
?>

 

# php -v
PHP 5.3.15-pl0-gentoo with Suhosin-Patch (cli) (built: Sep 4 2012 11:27:33)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

# equery b php
* Searching for php ...
dev-lang/php-5.3.15 (/usr/lib/php5.3/bin/php)
dev-lang/php-5.3.15 (/etc/php)
dev-lang/php-5.3.15 (/usr/lib/php5.3/include/php)
dev-php/PEAR-Archive_Tar-1.3.9 (/usr/share/php)
dev-php/PEAR-Console_Getopt-1.3.1 (/usr/share/php)
dev-php/PEAR-DB-1.7.14 (/usr/share/php)
dev-php/PEAR-PEAR-1.9.4 (/usr/share/php)
dev-php/PEAR-Structures_Graph-1.0.4 (/usr/share/php)
dev-php/PEAR-XML_Util-1.2.1-r2 (/usr/share/php)
dev-php/pecl-apc-3.1.9-r2 (/etc/php)
dev-php/pecl-apc-3.1.9-r2 (/usr/lib/php5.3/include/php)
dev-php/pecl-apc-3.1.9-r2 (/usr/share/php)


# ls --full-time /etc/php
total 0
drwxr-xr-x 2 root root 20 2012-07-28 18:03:38.999647793 +0100 apache2-php5
drwxr-xr-x 4 root root 47 2012-09-04 11:32:49.758142709 +0100 apache2-php5.3
drwxr-xr-x 4 root root 47 2012-09-04 11:32:49.707764554 +0100 cli-php5.3

 

 

I am using gentoo distro. Not sure whether this happened after some php update or the database table grew very big (one of the table had more than 3000 rows). I have got rid off the rows down to 3 and set the auto_increment option to 4. But that didn't help.

 

please help if you understand the problem or ask for more details.

Edited by midway

The size of your database shouldn't matter.

 

Scripts don't just stop working for no reason; something changed. And since you didn't mention altering any code, I'd say your guess about the server changing or updating is correct.

 

Do you get any errors? If not, turn on error reporting and post the error message.

The size of your database shouldn't matter.

 

Scripts don't just stop working for no reason; something changed. And since you didn't mention altering any code, I'd say your guess about the server changing or updating is correct.

 

Do you get any errors? If not, turn on error reporting and post the error message.

many thx TOA for the prompt reply. much appreciated.

 

1. I can add extra rows manually through phpmyadmin and the auto_increment is working fine too. so we can rule this out?

2. so my guess says that the above php script doesn't work because of a mismatch (update?) or some kind of missing file. Strange if it is an update because the other scripts are working fine.

 

When I try to run this lib batch php script manually, nothing happens, it just hangs and no error etc is given. Please guide me:-

 

1. how to find more errors related to this issue and

2. whether postfix needs to be running for above to work.

Edited by midway

this could be because postfix is not running (var/log/mail/current):

Oct 09 11:07:38 [postfix] fatal: chdir(//usr/lib/postfix): No such file or directory
		 - Last output repeated 2 times -
Oct 09 11:08:56 [postfix/postqueue] warning: Mail system is down -- accessing queue directly
Oct 09 11:08:56 [postfix/postqueue] fatal: execv //usr/lib/postfix/showq: No such file or directory

 

~ # tail -f /var/log/apache2/websiteaddress_error.log

[Tue Oct 09 14:34:54 2012] [error] [client 192.168.x.x] Empty module and/or action after parsing the URL "/favicon.ico" (/).
[Tue Oct 09 14:34:54 2012] [error] [client 192.168.x.x] PHP Fatal error: Uncaught exception 'sfError404Exception' with message 'Action "error/index" does not exist.' in /home/cache/frontend/prod/config/config_core_compile.yml.php:662\nStack trace:\n#0 /usr/share/php/symfony/exception/sfError404Exception.class.php(49): sfController->forward('error', 'index')\n#1 /home/cache/frontend/prod/config/config_core_compile.yml.php(2442): sfError404Exception->printStackTrace()\n#2 /usr/share/php/symfony/util/sfContext.class.php(159): sfFrontWebController->dispatch()\n#3 /home/web/index.php(6): sfContext->dispatch()\n#4 {main}\n thrown in /home/cache/frontend/prod/config/config_core_compile.yml.php on line 662

Edited by midway
/var/log/apache2/error_log:-
[notice] caught SIGTERM, shutting down
[notice] Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0j proxy_html/3.0.0 PHP/5.3.15-pl0-gentoo with Su$
[notice] caught SIGTERM, shutting down
[notice] Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0j proxy_html/3.0.1 PHP/5.3.15-pl0-gentoo with Su$
[notice] caught SIGTERM, shutting down
[notice] Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0j proxy_html/3.0.1 PHP/5.3.15-pl0-gentoo with Su$
[error] [client 192.168.x.x] PHP Warning: phpinfo() [<a href='function.phpinfo'>function.phpinfo</a>]:$
[error] [client 192.168.x.x] File does not exist: /var/localhost/htdocs/favicon.ico

Edited by midway

Looks like half your server is on strike :tease-01: Sorry to have humor at your expense.

 

I'm not that much of a server guy so I'm not sure what to tell you. Hopefully someone with more experience in that area can help out.

 

Sorry I'm not more help.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.