If you run this alone, it works, but in chat I always get just "[nick] <i>/izpoved</i>".
Messages are in utf-8, but containing special characters. I can print whole grouphug website into chat, but not a single char goes
trought when parsing izpovedi.rumenavrtnica.com.
Why? Code alone does work.
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
require(dirname(__FILE__).'/../htmlParser/simple_html_dom.php');
class pfcCommand_izpoved extends pfcCommand
{
var $usage = "/izpoved";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$contents = file_get_contents('http://izpovedi.rumenavrtnica.com/random.php');
// echo $contents;
$html = new simple_html_dom();
$html->load($contents);
// echo $html;
$div = $html->find('[class*=confession]', 0);
// echo $div;
$inner = $div->innertext;
$html->load($inner);
$p = $html->find('[class*=confession_content]', 0);
// echo $p;
$text = $p->plaintext;
// $message = $text;
$message = preg_replace('/[^(x20-x7F)]*/','', $message);
$ct->write($recipient, "*me*", $this->name, $u->getNickname().": <i>/izpoved</i>:".$message);
}
}
?>
You need: http://sourceforge.net/projects/simplehtmldom/