3 // should be in import folder... need to know where this is used though...
5 require_once 'ConvertStyle.php';
7 class Pman_Core_ImportMailMessage extends Pman_Core_ConvertStyle
11 if (HTML_FlexyFramework::get()->cli) {
14 $this->authUser = $this->getAuthUser();
15 if (!$this->authUser) {
25 return $this->jerr("not allowed");
30 if(isset($_REQUEST['_convertToPlain']))
32 require_once 'System.php';
33 $tmpdir = System::mktemp("-d convertPlain");
34 $path = $tmpdir . '/' . time() . '.html';
36 if(isset($_REQUEST['_check_unsubscribe'])){
37 libxml_use_internal_errors (true);
38 $doc = new DOMDocument('1.0', 'UTF-8');
39 $doc->loadHTML($_REQUEST['bodytext']);
40 $xpath = new DOMXpath($doc);
41 foreach ($xpath->query('//a[@href]') as $a) {
42 $href = $a->getAttribute('href');
44 if(!preg_match('/^#unsubscribe/', $href)){
47 $a->parentNode->replaceChild($doc->createTextNode($a->nodeValue . ' {unsubscribe_link}'), $a);
50 $_REQUEST['bodytext'] = $doc->saveHTML();
51 libxml_use_internal_errors (false);
54 if(!file_exists($path)){
55 file_put_contents($path, $_REQUEST['bodytext']);
57 require_once 'File/Convert.php';
58 $fc = new File_Convert($path, 'text/html');
59 $plain = $fc->convert('text/plain');
60 $this->jok(file_get_contents($plain));
64 if(isset($_REQUEST['importUrl']))
66 $this->checkHeader($_REQUEST['importUrl']);
67 $data = $this->convertStyle($_REQUEST['importUrl'], '', true);
74 $htmlFile = DB_DataObject::factory('images');
75 $htmlFile->setFrom(array(
77 'ontable' =>'crm_mailing_list_message'
79 $htmlFile->onUpload(false);
81 if($htmlFile->mimetype != 'text/html')
83 $this->jerr('accept html file only!');
85 if(!file_exists($htmlFile->getStoreName()))
87 $this->jerr('update failed!');
90 $data = $this->convertStyle('', $htmlFile->getStoreName(), false);
94 unlink($htmlFile->getStoreName()) or die('Unable to delete the file');