имеем изначальный пример
<?php
// script to access domain mail and gather content
// of mail intended for insertion into
// the site_content table.
// Variables:
// $uname: mailbox username
// $upass: mailbox password
// $mailserver: mail server to access
// $parent: the document ID to set as this document's parent (for Ditto call)
// $template: the template to use for this document
// to-do: make this a module and set these in the module configuration
$uname = '[email protected]';
$upass = 'password';
$mailserver = 'mail.domain.com';
$parent = 3;
$template = 3;
// connect to the mail server
$mbox = imap_open("{localhost:143}INBOX", $uname, $upass);
$listing = imap_search($mbox, "SUBJECT Submission");
if(imap_num_msg($mbox) > 0) {
foreach($listing as $msg) {
$message = imap_body($mbox, $msg);
$arr = explode("\n", $message); // break it up
$pagetitle = array_shift($arr); // shift off the first three lines
$createdby = array_shift($arr);
$introtext = array_shift($arr);
$content = implode("\n", $arr); // put the rest of it back together
// won't be needed when this is made into a module
include "manager/includes/config.inc.php";
$conn = mysql_connect($database_server, $database_user, $database_password) or die(mysql_error());
$db = mysql_select_db(trim($dbase, '`')) or die(mysql_error());
// clean it up
$pagetitle = mysql_real_escape_string(trim($pagetitle));
$introtext = mysql_real_escape_string(trim($introtext));
$content = mysql_real_escape_string(trim($content));
$createdby = mysql_real_escape_string(trim($createdby));
// get submitter's ID
$sql = "SELECT internalKey FROM " . $table_prefix . "user_attributes WHERE fullname = '$createdby'";
$res = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($res);
if($num == 1) { // there had better be one and only one
$createdby = mysql_result($res, 0);
$sql = "INSERT INTO " . $table_prefix . "site_content (pagetitle, introtext, content, parent, template, createdon, createdby) VALUES ('$pagetitle', '$introtext', '$content', $parent, $template, time(), $createdby)";
mysql_query($sql) or die(mysql_error());
}
}
}
меняю вот так
<?php
// script to access domain mail and gather content
// of mail intended for insertion into
// the site_content table.
// Variables:
// $uname: mailbox username
// $upass: mailbox password
// $mailserver: mail server to access
// $parent: the document ID to set as this document's parent (for Ditto call)
// $template: the template to use for this document
// to-do: make this a module and set these in the module configuration
$uname = 'kentastik';
$upass = '**********';
$mailserver = 'imap.yandex.ru';
$parent = 3;
$template = Minimal Template;
// connect to the mail server
$mbox = imap_open("{imap.yandex.ru}INBOX", $uname, $upass);
$listing = imap_search($mbox, "Извещение от сайта makePR.ru");
if(imap_num_msg($mbox) > 0) {
foreach($listing as $msg) {
$message = imap_body($mbox, $msg);
$arr = explode("\n", $message); // break it up
$pagetitle = array_shift($arr); // shift off the first three lines
$createdby = array_shift($arr);
$introtext = array_shift($arr);
$content = implode("\n", $arr); // put the rest of it back together
// won't be needed when this is made into a module
include "manager/includes/config.inc.php";
$conn = mysql_connect($database_server, $database_user, $database_password) or die(mysql_error());
$db = mysql_select_db(trim($dbase, '`')) or die(mysql_error());
// clean it up
$pagetitle = mysql_real_escape_string(trim($pagetitle));
$introtext = mysql_real_escape_string(trim($introtext));
$content = mysql_real_escape_string(trim($content));
$createdby = mysql_real_escape_string(trim($createdby));
// get submitter's ID
$sql = "SELECT internalKey FROM " . $table_prefix . "user_attributes WHERE fullname = '$createdby'";
$res = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($res);
if($num == 1) { // there had better be one and only one
$createdby = mysql_result($res, 0);
$sql = "INSERT INTO " . $table_prefix . "site_content (pagetitle, introtext, content, parent, template, createdon, createdby) VALUES ('$pagetitle', '$introtext', '$content', $parent, $template, time(), $createdby)";
mysql_query($sql) or die(mysql_error());
}
}
}
?>
выдает ошибку
« MODx Parse Error »MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: imap_open() [function.imap-open]: Couldn’t open stream {imap.yandex.ru}INBOX
Error type/ Nr.: Warning - 2
File: /home/k/kentastik/111.tw1.su/public_html/manager/includes/document.parser.class.inc.php(769) : eval()’d code
Line: 21
Parser timing
MySQL: 0.0033 s (4 Requests)
PHP: 0.2623 s
Total: 0.2657 s