PHPMailer warnings - php

I am currently gobsmacked and so ridiculously confused at the stupidity of this error. It honestly makes no sense to me.
So I have a network of 4 websites all using the same contact.php script which is pasted blow.
So on three of the sites, the script works perfectly. However on one of the sites, it keeps popping up errors. There shouldn't be any errors at all since they are on the same server and using exact same html files except for different content.
Warning: include(../../vip/boss/mailer/class.phpmailer.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 2
Warning: include(../../vip/boss/mailer/class.phpmailer.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 2
Warning: include() [function.include]: Failed opening '../../vip/boss/mailer/class.phpmailer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aap/public_html/justevents.net.au/quickcontact.php on line 2
Warning: include(../../vip/boss/mailer/class.smtp.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 3
Warning: include(../../vip/boss/mailer/class.smtp.php) [function.include]: failed to open stream: No such file or directory in /home/aap/public_html/justevents.net.au/quickcontact.php on line 3
Warning: include() [function.include]: Failed opening '../../vip/boss/mailer/class.smtp.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aap/public_html/justevents.net.au/quickcontact.php on line 3
Fatal error: Class 'PHPMailer' not found in /home/aap/public_html/justevents.net.au/quickcontact.php on line 27
Please Help Me
<?php
include("../../vip/boss/mailer/class.phpmailer.php");
include("../../vip/boss/mailer/class.smtp.php");
function heal($str) {
$injections = array('/(\n+)/i',
'/(\r+)/i',
'/(\t+)/i',
'/(%0A+)/i',
'/(%0D+)/i',
'/(%08+)/i',
'/(%09+)/i'
);
$str= preg_replace($injections,'',$str);
return str_replace('#','-AT-',$str);
}
$name = heal($_POSTname);
$email = str_replace('-AT-','#',heal($_POSTemail));
$message = heal(str_replace("\n",'<br>',$_POSTmessage));
$category = heal($_POSTcategory);
if(substr_count($email,'#')==1){
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "localhost";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = "autonote#justevents.net.au";
$mail->Password = "REDACTED";
$mail->From = "autonote#justevents..net.au";
$mail->FromName = $name;
$mail->Subject = $category.' Enquiry';
$mail->Body = $message;
$mail->WordWrap = 50;
$mail->AddAddress("admin#justevents..net.au","justevents. Enquiry");
$mail->AddReplyTo($email,$name);
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
header("LOCATION:quicksuccess.html");
}
}else{
echo 'There was an error, please try again. '.substr_count($email,'#');
}
?>

Use getcwd() on the calling file to debug this sort of errors.
As you can tell by the logs the documents are not in the path they were expected to be.
There is only one way to be sure, use an absolute path.
And then debug the situation with getcwd()...

Obviously the files you try to include can not be found. So the question is not only if you use the same php script in all four of them, but are they in the same directory? If not, do they have the same directory structure above them? You are using relative paths there for your include, so I guess you just have this version in a subdir or something, so it can not find the files to include from its working directory.

Related

Swiftmail parsing error

I recently moved to Swiftmailer as people have said good things about it. When I used a documentation on how to set it up, I'm getting a strange error. As if their code is wrong.
The error is showing :
Parse error: syntax error, unexpected '?' in Mailer\classes\Swift\Transport\EsmtpTransport.php on line 211
I haven't modified this file atoll and it's throwing that error.
I'm calling my username and password from my config file giving them a DEFINE PHP function.
My code being used is :
define("AUTHENTICATION_DONOTREDIRECT", 1);
require("../main_config.php");
$site_config = new site_config();
$from = $site_config->grabSiteSettings_manual($con, 'name');
require 'Mailer/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com',465,'ssl')->setUserName(gmail_mail)->setPassword(gmail_pass);
$swift = Swift_Message::newInstance($transport);
$content = "This is a test message.";
$message = Swift_Message::newInstance("This is a test email")
->setFrom('admin#admin.com')
->setTo('benzahdd55#outlook.com')
->setBody($content,'text/html')
->addPart(strip_tags($content),'text/plain');
$swift->send($message);
$myfile = fopen("loggy.txt", "w");
$txt = "success\n";
fwrite($myfile, $txt);
fclose($myfile);
I believe it's because of the new ?? syntax used in PHP 7. Are you running PHP 5?
You might want to downgrade to an older version or update that line and see if it works.

How do I include PHP required libs in an AWS EMR streaming cluster

I've created a PHP project that converts JSON format into AVRO format.
The original project requires PHP libs that I'm not sure how to add on EMR.
This is the stderr log received by EMR:
PHP Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in /mnt/var/lib/hadoop/tmp/nm-local-dir/usercache/hadoop/filecache/12/convert-json-to-avro.php on line 3
PHP Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /mnt/var/lib/hadoop/tmp/nm-local- dir/usercache/hadoop/filecache/12/convert-json-to-avro.php on line 3
log4j:WARN No appenders could be found for logger (amazon.emr.metrics.MetricsUtil).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
And here is the main code for the mapper:
#!/usr/bin/php
<?php
require_once 'vendor/autoload.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
$outputFile = __DIR__ . '/test_avro_out.avr';
$avroJsonSchema = file_get_contents(__DIR__ . '/HttpRequestEvent.avsc');
// Open $file_name for writing, using the given writer's schema
$avroWriter = AvroDataIO::open_file($outputFile, 'w', $avroJsonSchema);
$counter = 1;
while (($buf = fgets(STDIN)) !== false) {
try {
//replace ,null: with ,"null": to prevent map keys which are not strings.
$original = array("null:","userIp");
$replaceWith = array("\"null\":", "userIP");
$data = json_decode(str_replace($original, $replaceWith, $buf), true);
//print_r($buf);
if ($data === false || $data == null ) {
throw new InvalidArgumentException("Unable to parse JSON line");
}
$mapped = map_request_event($data);
var_dump($mapped);
//$avroWriter->append($mapped);
//echo json_encode($mapped), "\n";
} catch (Exception $ex) {
fprintf(STDERR, "Caught exception: %s\n", $ex->getMessage());
fprintf(STDERR, "Line num: %s\n",$counter);
fprintf(STDERR, "buf: %s\n", $buf);
}
$counter++;
}
$avroWriter->close();
Notice I'm using the require_once 'vendor/autoload.php'; which states that autoload.php is under the folder vendor.
What is the right way to load the vendor folder into the EMR cluster (there are needed files there)?
Should the require_once path change?
Thanks.
Following Guy's comment I've used a bash script similar to the one you can find here.
I've changed the require_once 'vendor/autoload.php' line in the code to point to the location where i dropped my files. (/home/hadoop/contents worked perfect).
lastly I've added an EMR bootstrap custom step where you can add the bash script so it can run before the PHP streaming step.

PHP fails when upgraded to 5.4

I am using PHP with MySQL to pull programs, courses, etc. on 2003 box with PHP 5.2. I am transferring my site to a new 2008 box with PHP 5.4 (because of injection exploits on database). My data still pulls to my site (programs, courses etc) from my new server.
The issue is I have a page that is for login and will not load (HTTP 500 error). I have traced back to section of code that kicks out and believe it is the session_start(). I know in 5.3 it changed and will now return false if it fails to start instead of the previous true.
I've tried echoing out what loads line by line with each variable since I can compare it with the two versions. I've tried starting the session at the beginning. Ending it before my code, etc. It seems simple, but I haven't got it to work yet.
Here's the beginning of my page "login-inc-header.php":
<?php
if(!isset($session_started)) $session_started = session_start();
// avoids duplicate pstings
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
ini_set("display_errors", "1");
if(!isset($requires)) $requires = "User";
include_once("includes/handleLogin.php");
include_once("../includes_app/db_settings.php");
?>
If I remove this block, The page will load just without my login boxes. Pages works perfect in version 5.2. Ideas?
My db_settings:
<?php
//$site_root = "/var/www/html/";
$site_root = "C:\\Inetpub\\wwwroot\\"; //changed 12-13-13 for new server
//$site_root = substr($_SERVER['PATH_TRANSLATED'], 0, (-1 * strlen($_SERVER['PATH_INFO'])));
$site_url = "http://10.20.251.60/";
include_once($site_root."includes_app/adodb/adodb.inc.php");
$db =& ADONewConnection('mysql');
$db->Connect("localhost", "####", "####", "####");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
// for mysql only...make sure we are NOT in strict mode
$db->Execute("SET sql_mode=''");
$tblprefix = "";
$extraFieldLabHours = true;
$extraFieldOBIHours = true;
$extraFieldsPrereqCoreq = true;
$extraFieldProgramRequirements = true;
$maxCourseCodeLength = 4;
$maxCoursePrefixLength = 4; // 11-05-10 added this line to fix prefix length
$exportReport[$site_url.'includes_app/html_word_export.php'] = "Export for Microsoft Word 2007";
$exportReport[$site_url.'includes_app/html_rtf_export.php'] = "Export for Adobe InDesign CS2";
$exportReport[$site_url.'directory/print.php'] = "Export Directory to HTML";
$sysadmin_email = "gntc#gntc.edu";
$extraModuleEmployeeDirectory = true;
$extraModuleCampusAlert = true;
$extraFieldAtAGlance = true;
$areas = array();
$configAreasResult = $db->Execute("SELECT dbName, displayName FROM ".$tblprefix."areas ORDER BY sequence");
while($configRow = $configAreasResult->fetchRow()) $areas[$configRow['dbName']] = $configRow['displayName'];
$program_types = array();
$configProgramTypesResult = $db->Execute("SELECT dbName, displayName FROM ".$tblprefix."program_types ORDER BY sequence");
while($configRow = $configProgramTypesResult->fetchRow()) $program_types[$configRow['dbName']] = $configRow['displayName'];
$extraFieldCampus = array();
$configCampusesResult = $db->Execute("SELECT displayName FROM ".$tblprefix."campuses ORDER BY sequence");
while($configRow = $configCampusesResult->fetchRow()) $extraFieldCampus[] = $configRow['displayName'];
$extraFieldEmployeeOfficeHours = true;
$extraFieldEmployeeBio = true;
$extraFieldEmployeePicture = true;
$extraFieldFoptNumRequirements = true;
$alternateTitleGeneralCoreCourses = "General Core Curriculum";
$alternateTitleOccupationalCourses = "Occupational Curriculum";
$extraModuleCampusAlert = true; // added on 3-10-10 to make campus alert feature work
$alternateTitleEmployeeEducation = "Credentials"; $showBannerID = true;
$deeperMenus = true;
$importModules = array();
$importModules['import_courses_xml.php'] = "Courses XML";
$importModules['import_employees_xml.php'] = "Employees XML";
$extraModuleDivisions = true;
$gntc_local_upload_dir = $site_root."uploads/";
$gntc_web_upload_dir = $site_url."uploads/";
$exportReport[$site_url.'includes_app/phone_sheet_csv.php'] = "Phone Sheet CSV";
?>
Log File:
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(includes/handleLogin.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\login\includes\header.php on line 8
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(): Failed opening 'includes/handleLogin.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\login\includes\header.php on line 8
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(../includes_app/db_settings.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\login\includes\header.php on line 9
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(): Failed opening '../includes_app/db_settings.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\login\includes\header.php on line 9
[16-Jan-2014 21:17:46 UTC] PHP Notice: Undefined variable: title in C:\inetpub\wwwroot\login\includes\header.php on line 16
[16-Jan-2014 21:17:46 UTC] PHP Notice: Undefined variable: title in C:\inetpub\wwwroot\login\includes\header.php on line 159
I noticed that this referenced PEAR, which in not installed by default like older versions. Could this be the issue?
You have put this as your site root
$site_root = "C:\\Inetpub\\wwwroot\\";
Try putting
$site_root = "http://yourhost/folder_name/"

Vanilla Settings Errors

http://reps.michebagshows.com/forums/
Recently, our customer forums popped up with this slew of errors from settings.php in the Vanilla forum software. We have no idea how this happened, as none of the files have been modified for months. Todd over at Vanilla suggested that the permissions changed, but those haven't been touched either. He then sent me to another user for help, who hasn't even logged in in a week.
How can this be fixed? We're getting quite a few complaints about it because the forums are the way our customers trade and discuss our product among each other.
Any help would be greatly appreciated, thank you.
Example errors:
Warning: include_once(/path/to/vanilla/appg/database.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 244
Warning: include_once() [function.include]: Failed opening '/path/to/vanilla/appg/database.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 244
Warning: include_once(/path/to/your/database/file.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 245
Warning: include_once() [function.include]: Failed opening '/path/to/your/database/file.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 245
Warning: include_once(/path/to/your/library/Framework/Framework.Functions.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 246
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Functions.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 246
Warning: include_once(/path/to/your/library/Framework/Framework.Class.Database.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 247
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.Database.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 247
Warning: include_once(/path/to/your/library/Framework/Framework.Class.MySQL.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 248
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.MySQL.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 248
Warning: include_once(/path/to/your/library/Framework/Framework.Class.SqlBuilder.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 249
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.SqlBuilder.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 249
Warning: include_once(/path/to/your/library/Framework/Framework.Class.MessageCollector.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 250
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.MessageCollector.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 250
Warning: include_once(/path/to/your/library/Framework/Framework.Class.ErrorManager.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 251
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.ErrorManager.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 251
Warning: include_once(/path/to/your/library/Framework/Framework.Class.ObjectFactory.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 252
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.ObjectFactory.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 252
Warning: include_once(/path/to/your/library/Framework/Framework.Class.StringManipulator.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 253
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.StringManipulator.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 253
Warning: include_once(/path/to/your/library/Framework/Framework.Class.Context.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 254
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.Context.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 254
Warning: include_once(/path/to/your/library/Framework/Framework.Class.Delegation.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 255
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Framework/Framework.Class.Delegation.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 255
Warning: include_once(/path/to/your/library/Vanilla/Vanilla.Functions.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 256
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/Vanilla/Vanilla.Functions.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 256
Warning: include_once(/path/to/your/library/People/People.Class.Authenticator.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 257
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/People/People.Class.Authenticator.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 257
Warning: include_once(/path/to/your/library/People/People.Class.Session.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 258
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/People/People.Class.Session.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 258
Warning: include_once(/path/to/your/library/People/People.Class.PasswordHash.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 259
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/People/People.Class.PasswordHash.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 259
Warning: include_once(/path/to/your/library/People/People.Class.User.php) [function.include-once]: failed to open stream: No such file or directory in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 260
Warning: include_once() [function.include]: Failed opening '/path/to/your/library/People/People.Class.User.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 260
Fatal error: Class 'Context' not found in /var/www/michebagshows.com/rep_forums/forums/appg/settings.php on line 262
Settings.php
<?php
/*
* Copyright 2003 Mark O'Sullivan
* This file is part of Vanilla.
* Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
* Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* The latest source code for Vanilla is available at www.lussumo.com
* Contact Mark O'Sullivan at mark [at] lussumo [dot] com
* Description: Global application constants
* ATTENTION: !DO NOT CHANGE ANYTHING IN THIS FILE!
* If you wish to override any configuration setting, do it in the
* conf/settings.php file. This file will be overwritten when you apply upgrades
* to Vanilla. The conf/settings.php file will NOT be overwritten.
*/
ob_start();
$Configuration = array();
// Database Settings
$Configuration['DATABASE_SERVER'] = 'MySQL';
$Configuration['DATABASE_TABLE_PREFIX'] = 'LUM_';
$Configuration['DATABASE_HOST'] = 'localhost';
$Configuration['DATABASE_NAME'] = 'your_vanilla_database_name';
$Configuration['DATABASE_USER'] = 'your_vanilla_database_user_name';
$Configuration['DATABASE_PASSWORD'] = 'your_vanilla_database_password';
$Configuration['FARM_DATABASE_HOST'] = '';
$Configuration['FARM_DATABASE_NAME'] = 'your_farm_database_name';
$Configuration['FARM_DATABASE_USER'] = 'your_farm_database_user_name';
$Configuration['FARM_DATABASE_PASSWORD'] = 'your_farm_database_password';
$Configuration['DATABASE_CHARACTER_ENCODING'] = '';
$Configuration['DATABASE_VERSION'] = '1';
// Path Settings
$Configuration['APPLICATION_PATH'] = '/path/to/vanilla/';
$Configuration['DATABASE_PATH'] = '/path/to/your/database/file.php';
$Configuration['LIBRARY_PATH'] = '/path/to/your/library/';
$Configuration['EXTENSIONS_PATH'] = '/path/to/your/extensions/';
$Configuration['LANGUAGES_PATH'] = '/path/to/your/languages/';
$Configuration['THEME_PATH'] = '/path/to/vanilla/themes/vanilla/';
$Configuration['BASE_URL'] = 'http://your.base.url/to/vanilla/';
$Configuration['DEFAULT_STYLE'] = '/vanilla/themes/vanilla/styles/default/';
$Configuration['WEB_ROOT'] = '/vanilla/';
$Configuration['SIGNIN_URL'] = 'people.php';
$Configuration['SIGNOUT_URL'] = 'people.php?PostBackAction=SignOutNow';
// People Settings
$Configuration['AUTHENTICATION_MODULE'] = 'People/People.Class.Authenticator.php';
$Configuration['AUTHENTICATION_CLASS'] = 'Authenticator';
$Configuration['SESSION_NAME'] = '';
$Configuration['COOKIE_USER_KEY'] = 'lussumocookieone';
$Configuration['COOKIE_VERIFICATION_KEY'] = 'lussumocookietwo';
$Configuration['SESSION_USER_IDENTIFIER'] = 'LussumoUserID';
$Configuration['COOKIE_DOMAIN'] = '.domain.com';
$Configuration['COOKIE_PATH'] = '/';
$Configuration['SUPPORT_EMAIL'] = 'support#domain.com';
$Configuration['SUPPORT_NAME'] = 'Support';
$Configuration['LOG_ALL_IPS'] = '0';
$Configuration['FORWARD_VALIDATED_USER_URL'] = './';
$Configuration['ALLOW_IMMEDIATE_ACCESS'] = '0';
$Configuration['DEFAULT_ROLE'] = '0';
$Configuration['APPROVAL_ROLE'] = '3';
$Configuration['SAFE_REDIRECT'] = 'people.php?PageAction=SignOutNow';
$Configuration['PEOPLE_USE_EXTENSIONS'] = '1';
$Configuration['DEFAULT_EMAIL_VISIBLE'] = '0';
$Configuration['PASSWORD_HASH_ITERATION'] = '8';
$Configuration['PASSWORD_HASH_PORTABLE'] = '1';
// Framework Settings
$Configuration['SMTP_HOST'] = '';
$Configuration['SMTP_USER'] = '';
$Configuration['SMTP_PASSWORD'] = '';
$Configuration['DEFAULT_EMAIL_MIME_TYPE'] = 'text/plain';
$Configuration['LANGUAGE'] = "English";
$Configuration['URL_BUILDING_METHOD'] = 'Standard'; // Standard or mod_rewrite
$Configuration['CHARSET'] = 'utf-8';
$Configuration['PAGE_EVENTS'] = array('Page_Init', 'Page_Render', 'Page_Unload');
$Configuration['PAGELIST_NUMERIC_TEXT'] = '0';
$Configuration['LIBRARY_NAMESPACE_ARRAY'] = array('Framework', 'People', 'Vanilla');
$Configuration['LIBRARY_INCLUDE_PATH'] = '%LIBRARY%';
$Configuration['DEFAULT_FORMAT_TYPE'] = 'Text';
$Configuration['FORMAT_TYPES'] = array('Text');
$Configuration['APPLICATION_TITLE'] = 'Vanilla';
$Configuration['BANNER_TITLE'] = 'Vanilla';
$Configuration['UPDATE_REMINDER'] = 'Monthly';
$Configuration['LAST_UPDATE'] = '';
$Configuration['HTTP_METHOD'] = 'http'; // Could alternately be https
// Vanilla Settings
$Configuration['ENABLE_WHISPERS'] = '0';
$Configuration['DISCUSSIONS_PER_PAGE'] = '30';
$Configuration['COMMENTS_PER_PAGE'] = '50';
$Configuration['SEARCH_RESULTS_PER_PAGE'] = '30';
$Configuration['ALLOW_NAME_CHANGE'] = '1';
$Configuration['ALLOW_EMAIL_CHANGE'] = '1';
$Configuration['ALLOW_PASSWORD_CHANGE'] = '1';
$Configuration['USE_REAL_NAMES'] = '1';
$Configuration['PUBLIC_BROWSING'] = '1';
$Configuration['USE_CATEGORIES'] = '1';
$Configuration['MAX_COMMENT_LENGTH'] = '5000';
$Configuration['MAX_TOPIC_WORD_LENGTH'] = '45';
$Configuration['DISCUSSION_POST_THRESHOLD'] = '3';
$Configuration['DISCUSSION_TIME_THRESHOLD'] = '60';
$Configuration['DISCUSSION_THRESHOLD_PUNISHMENT'] = '120';
$Configuration['COMMENT_POST_THRESHOLD'] = '5';
$Configuration['COMMENT_TIME_THRESHOLD'] = '60';
$Configuration['COMMENT_THRESHOLD_PUNISHMENT'] = '120';
$Configuration['UPDATE_URL'] = 'http://lussumo.com/updatecheck/default.php';
// Vanilla Control Positions
$Configuration['CONTROL_POSITION_HEAD'] = '100';
$Configuration['CONTROL_POSITION_MENU'] = '200';
$Configuration['CONTROL_POSITION_BANNER'] = '200';
$Configuration['CONTROL_POSITION_PANEL'] = '300';
$Configuration['CONTROL_POSITION_NOTICES'] = '400';
$Configuration['CONTROL_POSITION_BODY_ITEM'] = '500';
$Configuration['CONTROL_POSITION_FOOT'] = '600';
$Configuration['CONTROL_POSITION_PAGE_END'] = '700';
// Vanilla Tab Positions
$Configuration['TAB_POSITION_DISCUSSIONS'] = '10';
$Configuration['TAB_POSITION_CATEGORIES'] = '20';
$Configuration['TAB_POSITION_SEARCH'] = '30';
$Configuration['TAB_POSITION_SETTINGS'] = '40';
$Configuration['TAB_POSITION_ACCOUNT'] = '50';
// Url Rewriting Definitions
$Configuration['REWRITE_categories.php'] = 'categories/';
$Configuration['REWRITE_index.php'] = 'discussions/';
$Configuration['REWRITE_comments.php'] = 'discussion/';
$Configuration['REWRITE_search.php'] = 'search/';
$Configuration['REWRITE_account.php'] = 'account/';
$Configuration['REWRITE_settings.php'] = 'settings/';
$Configuration['REWRITE_post.php'] = 'post/';
$Configuration['REWRITE_people.php'] = 'people/';
$Configuration['REWRITE_extension.php'] = 'extension/';
// Default values for role permissions
// Standard Permissions
$Configuration['PERMISSION_SIGN_IN'] = '0';
$Configuration['PERMISSION_ADD_COMMENTS'] = '0';
$Configuration['PERMISSION_START_DISCUSSION'] = '0';
$Configuration['PERMISSION_HTML_ALLOWED'] = '0';
// Discussion Moderator Permissions
$Configuration['PERMISSION_SINK_DISCUSSIONS'] = '0';
$Configuration['PERMISSION_STICK_DISCUSSIONS'] = '0';
$Configuration['PERMISSION_HIDE_DISCUSSIONS'] = '0';
$Configuration['PERMISSION_CLOSE_DISCUSSIONS'] = '0';
$Configuration['PERMISSION_EDIT_DISCUSSIONS'] = '0';
$Configuration['PERMISSION_VIEW_HIDDEN_DISCUSSIONS'] = '0';
$Configuration['PERMISSION_EDIT_COMMENTS'] = '0';
$Configuration['PERMISSION_HIDE_COMMENTS'] = '0';
$Configuration['PERMISSION_VIEW_HIDDEN_COMMENTS'] = '0';
$Configuration['PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION'] = '0';
$Configuration['PERMISSION_ADD_CATEGORIES'] = '0';
$Configuration['PERMISSION_EDIT_CATEGORIES'] = '0';
$Configuration['PERMISSION_REMOVE_CATEGORIES'] = '0';
$Configuration['PERMISSION_SORT_CATEGORIES'] = '0';
$Configuration['PERMISSION_VIEW_ALL_WHISPERS'] = '0';
// User Moderator Permissions
$Configuration['PERMISSION_APPROVE_APPLICANTS'] = '0';
$Configuration['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'] = '0';
$Configuration['PERMISSION_CHANGE_USER_ROLE'] = '0';
$Configuration['PERMISSION_EDIT_USERS'] = '0';
$Configuration['PERMISSION_IP_ADDRESSES_VISIBLE'] = '0';
$Configuration['PERMISSION_MANAGE_REGISTRATION'] = '0';
$Configuration['PERMISSION_SORT_ROLES'] = '0';
$Configuration['PERMISSION_ADD_ROLES'] = '0';
$Configuration['PERMISSION_EDIT_ROLES'] = '0';
$Configuration['PERMISSION_REMOVE_ROLES'] = '0';
// Administrative Permissions
$Configuration['PERMISSION_CHECK_FOR_UPDATES'] = '0';
$Configuration['PERMISSION_CHANGE_APPLICATION_SETTINGS'] = '0';
$Configuration['PERMISSION_MANAGE_EXTENSIONS'] = '0';
$Configuration['PERMISSION_MANAGE_LANGUAGE'] = '0';
$Configuration['PERMISSION_MANAGE_THEMES'] = '0';
$Configuration['PERMISSION_MANAGE_STYLES'] = '0';
$Configuration['PERMISSION_ALLOW_DEBUG_INFO'] = '0';
// Default values for User Preferences
$Configuration['PREFERENCE_HtmlOn'] = '1';
$Configuration['PREFERENCE_ShowAppendices'] = '1';
$Configuration['PREFERENCE_ShowSavedSearches'] = '1';
$Configuration['PREFERENCE_ShowTextToggle'] = '1';
$Configuration['PREFERENCE_JumpToLastReadComment'] = '1';
$Configuration['PREFERENCE_ShowLargeCommentBox'] = '0';
$Configuration['PREFERENCE_ShowFormatSelector'] = '1';
$Configuration['PREFERENCE_ShowDeletedDiscussions'] = '0';
$Configuration['PREFERENCE_ShowDeletedComments'] = '0';
// Newbie settings
// Has Vanilla been installed (this will be set to true in conf/settings.php when setup completes)
$Configuration['SETUP_COMPLETE'] = '0';
$Configuration['ADDON_NOTICE'] = '1';
// Application versions
include(dirname(__FILE__) . '/version.php');
// Application Mode Constants
define('MODE_DEBUG', 'DEBUG');
define('MODE_RELEASE', 'RELEASE');
// Format type definitions
define('FORMAT_STRING_FOR_DISPLAY', 'DISPLAY');
define('FORMAT_STRING_FOR_DATABASE', 'DATABASE');
// PHP Settings
define('MAGIC_QUOTES_ON', get_magic_quotes_gpc());
// Self Url (should be hard-coded by each page - this is here just in case it was forgotten)
$Configuration['SELF_URL'] = #$_SERVER['PHP_SELF'];
// Include custom settings
include(dirname(__FILE__) . '/../conf/settings.php');
if ($Configuration['SETUP_COMPLETE'] == '0') {
header('Location: ./setup/index.php');
}
// Define a constant to prevent a register_globals attack on the configuration paths
define('IN_VANILLA', '1');
//upgrade database
if ($Configuration['DATABASE_VERSION'] < 2) {
include_once($Configuration['APPLICATION_PATH'].'appg/database.php');
include_once($Configuration['DATABASE_PATH']);
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Functions.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Database.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.'.$Configuration['DATABASE_SERVER'].'.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.SqlBuilder.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.MessageCollector.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.ErrorManager.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.ObjectFactory.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.StringManipulator.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Context.php');
include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Delegation.php');
include_once($Configuration['LIBRARY_PATH'].'Vanilla/Vanilla.Functions.php');
include_once($Configuration['LIBRARY_PATH'].$Configuration['AUTHENTICATION_MODULE']);
include_once($Configuration['LIBRARY_PATH'].'People/People.Class.Session.php');
include_once($Configuration['LIBRARY_PATH'].'People/People.Class.PasswordHash.php');
include_once($Configuration['LIBRARY_PATH'].'People/People.Class.User.php');
$Context = new Context($Configuration);
$Context->DatabaseTables = &$DatabaseTables;
$Context->DatabaseColumns = &$DatabaseColumns;
$Query = 'ALTER TABLE '
. GetTableName('User', $DatabaseTables, $Configuration["DATABASE_TABLE_PREFIX"])
. ' CHANGE ' . $DatabaseColumns['User']['Password'].' '
. $DatabaseColumns['User']['Password'] . ' VARBINARY( 34 ) NULL DEFAULT NULL';
if ($Context->Database->Execute($Query,'','','',0)) {
AddConfigurationSetting($Context, 'DATABASE_VERSION', '2');
}
unset($Context, $Query);
}
?>
conf/settings.php
<?php
// Application Settings
$Configuration['SETUP_TEST'] = '1';
$Configuration['APPLICATION_PATH'] = '/var/www/michebagshows.com/vanilla/';
$Configuration['DATABASE_PATH'] = '/var/www/michebagshows.com/vanilla/conf/database.php';
$Configuration['LIBRARY_PATH'] = '/var/www/michebagshows.com/vanilla/library/';
$Configuration['EXTENSIONS_PATH'] = '/var/www/michebagshows.com/vanilla/extensions/';
$Configuration['LANGUAGES_PATH'] = '/var/www/michebagshows.com/vanilla/languages/';
$Configuration['THEME_PATH'] = '/var/www/michebagshows.com/vanilla/themes/Blogger/';
$Configuration['DEFAULT_STYLE'] = '/themes/Blogger/styles/default/';
$Configuration['WEB_ROOT'] = '/';
$Configuration['BASE_URL'] = 'http://forums.michebagshows.com/';
$Configuration['FORWARD_VALIDATED_USER_URL'] = 'http://forums.michebagshows.com/';
$Configuration['SUPPORT_EMAIL'] = 'info#michebag.com';
$Configuration['SUPPORT_NAME'] = 'Miche Bag';
$Configuration['APPLICATION_TITLE'] = 'Miche Bag Distributor Forums';
$Configuration['BANNER_TITLE'] = 'Distributor Forums';
$Configuration['COOKIE_DOMAIN'] = 'forums.michebagshows.com';
$Configuration['COOKIE_PATH'] = '/';
$Configuration['SETUP_COMPLETE'] = '1';
$Configuration['DATABASE_VERSION'] = '2';
$Configuration['ADDON_NOTICE'] = '0';
$Configuration['SMTP_USER'] = 'admin';
$Configuration['SMTP_PASSWORD'] = 'm1ch3b4g';
$Configuration['DEFAULT_ROLE'] = '3';
$Configuration['ALLOW_IMMEDIATE_ACCESS'] = '1';
$Configuration['NOTIFI_ALLOW_ALL'] = '1';
$Configuration['NOTIFI_ALLOW_DISCUSSION'] = '1';
$Configuration['NOTIFI_ALLOW_CATEGORY'] = '1';
$Configuration['NOTIFI_AUTO_ALL'] = '0';
$Configuration['NOTIFI_INSTALL_V2_COMPLETE'] = '1';
$Configuration['PASSWORD_RESET_VERSION'] = '0.3';
$Configuration['LAST_UPDATE'] = '1265210955';
$Configuration['DEFAULT_PAGE_USE_RETURN'] = '';
$Configuration['DEFAULT_PAGE'] = 'categories.php';
$Configuration['PUBLIC_BROWSING'] = '0';
$Configuration['ATTACHMENTS_UPLOAD_PATH'] = '/var/www/michebagshows.com/vanilla/uploads/%year%/%month%/';
$Configuration['ATTACHMENTS_MAXIMUM_FILESIZE'] = '3512000';
$Configuration['ATTACHMENTS_VERSION'] = '2.1';
?>
#DaveRandom is right. Your config file (settings.php) has been overwritten or backed up from a state that is not configured, but it is a mystery to me how this could have happened by accident.
The proof is right here, and indicates that the forum doesn't think it has been configured yet:
$Configuration['SETUP_COMPLETE'] = '0';
Perhaps someone reinstalled the Vanilla software, or tried to perform some kind of update, and accidentally overwrote this important file.
settings.php usually contains all the site-specific configuration for your forum, such as database names and passwords, the root folders of your site's various applications, etc. This is the kind of thing that is built at setup time, when you first install your forum.
Unless you have a backup of this file, you're going to have to perform the setup again. Make sure you backup your database first.
So we found out what the problem was... It turns out our old programmer didn't transfer the rest of the files over to the right server. I wasn't even aware there was a transfer. But it's fixed now! Thank you guys for your help.

Create directories and write files using PHP from a sendmail pipe to program

I have a script that reads emails (with attachments) from a pipe and I'm trying to save the attachment(s) to disk for further processing. I've cobbled together some code from a few sites and for the life of me I cannot get the files to save. I'm using 777 as the chmod value so permissions don't seem to be a problem but I wanted to know if maybe I'm limited to certain PHP commands when using the command line processor rather than the browser. Also, I've even hardcoded the "include" directories in the event the file is not executed from the directory where it is located. Any help would be greatly appreciated!
#!/usr/bin/php
<?php
//debug
#ini_set ("display_errors", "1");
#error_reporting(E_ALL);
include('/var/www/simple_html_dom.php');
//include email parser
require_once('/var/www/rfc822_addresses.php');
require_once('/var/www/mime_parser.php');
// read email in from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
//create the email parser class
$mime=new mime_parser_class;
$mime->ignore_syntax_errors = 1;
$parameters=array(
'Data'=>$email,
);
$mime->Decode($parameters, $decoded);
//---------------------- GET EMAIL HEADER INFO -----------------------//
//get the name and email of the sender
$fromName = $decoded[0]['ExtractedAddresses']['from:'][0]['name'];
$fromEmail = $decoded[0]['ExtractedAddresses']['from:'][0]['address'];
//get the name and email of the recipient
$toEmail = $decoded[0]['ExtractedAddresses']['to:'][0]['address'];
$toName = $decoded[0]['ExtractedAddresses']['to:'][0]['name'];
//get the subject
$subject = $decoded[0]['Headers']['subject:'];
$removeChars = array('<','>');
//get the message id
$messageID = str_replace($removeChars,'',$decoded[0]['Headers']['message-id:']);
//get the reply id
//$replyToID = str_replace($removeChars,'',$decoded[0]['Headers']['in-reply-to:']);
//---------------------- FIND THE BODY -----------------------//
//get the message body
if(substr($decoded[0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Body'])){
$body = $decoded[0]['Body'];
} elseif(substr($decoded[0]['Parts'][0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Parts'][0]['Body'])) {
$body = $decoded[0]['Parts'][0]['Body'];
} elseif(substr($decoded[0]['Parts'][0]['Parts'][0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Parts'][0]['Parts'][0]['Body'])) {
$body = $decoded[0]['Parts'][0]['Parts'][0]['Body'];
}
$my_dir = base64_encode($fromEmail);
shell_exec('mkdir -p /var/www/tmp/' . $my_dir . ' -m 777');
//mkdir($_SERVER['DOCUMENT_ROOT'] . "tmp/" . $my_dir, 0777, true);
$target_path = "var/www/tmp/" . $my_dir;
//chdir($target_path);
//------------------------ ATTACHMENTS ------------------------------------//
//loop through email parts
foreach($decoded[0]['Parts'] as $part){
//check for attachments
if($part['Content-Disposition'] == 'attachment'){
//format file name (change spaces to underscore then remove anything that isn't a letter, number or underscore)
$filename = preg_replace('/[^0-9,a-z,\.,_]*/i','',str_replace(' ','_', $part['FileName']));
// write the data to the file
$fp = fopen($target_path . "/" . $filename, 'w');
$written = fwrite($fp,$part['Body']);
fclose($fp);
//add file to attachments array
$attachments[] = $part['FileName'];
}
}
$html = file_get_html($attachments);
Update: Thanks for the informative response...I've been trying to figure out how to run from the command line. I'm getting some errors now, but they still don't make much sense:
PHP Notice: Undefined index: name in /var/www/catcher.php on line 38
PHP Notice: Undefined index: Content-Disposition in /var/www/catcher.php on line 80
PHP Notice: Undefined index: Content-Disposition in /var/www/catcher.php on line 80
PHP Notice: Undefined variable: attachments in /var/www/catcher.php on line 97
PHP Warning: file_get_contents(): Filename cannot be empty in /var/www/simple_html_dom.php on line 39
I have already specified the full include path to the other files and the smmta user should have read access as the /var/www/ directory is 755.
Using 0777 permissions on the mkdir command in your script does not matter at all if the user that the script is running under cannot write to your target directory. So, if this script is running as used sendmail for example, make sure that this user can write to /var/www/tmp.
Some debugging tips: Get a complete e-mail and save it to a file. Figure out what user this script runs as (e.g. sendmail). Then execute the script manually from the commandline and watch for errors. E.g:
sudo -u sendmail /path/to/script.php < /path/to/saved-email.eml
Make sure you have error reporting turned on etc.
Edit: Looking at the errors you posted, it seems that the mime decoder cannot properly parse your message the way you're expecting it. You appear not to be doing any error checking, so instead you get notices and warnings about undefined indexes.
Check in the input and output of the decoder. Make sure the message is decoded the way you expect it to be.

Categories