Пример #1
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $flow = Nexista_Flow::Singleton('Nexista_Flow');
     $file_path = Nexista_Path::parseInlineFlow($this->params['xsl']);
     $xslfile = NX_PATH_APPS . $file_path;
     if (!is_file($xslfile)) {
         Nexista_Error::init('XSL Action - file unavailable: ' . $xslfile, NX_ERROR_FATAL);
     }
     $xsl = new DomDocument('1.0', 'UTF-8');
     $xsl->substituteEntities = false;
     $xsl->resolveExternals = false;
     $xslfilecontents .= file_get_contents($xslfile);
     $xsl->loadXML($xslfilecontents);
     $xsl->documentURI = $xslfile;
     $use_xslt_cache = "yes";
     if ($use_xslt_cache != "yes" || !class_exists('xsltCache')) {
         $xslHandler = new XsltProcessor();
     } else {
         $xslHandler = new xsltCache();
     }
     $xslHandler->importStyleSheet($xsl);
     $my_output = $xslHandler->transformToXML($flow->flowDocument);
     if ($my_output === false) {
         Nexista_Error::init('XSL Action - Error processing XSL file: ' . $xslfile, NX_ERROR_FATAL);
         return false;
     }
     $new_node = $this->params['new_node'];
     Nexista_Flow::add($new_node, $my_output);
     return true;
 }
Пример #2
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $recipient = Nexista_Path::parseInlineFlow($this->params['recipient']);
     $sender = Nexista_Path::parseInlineFlow($this->params['sender']);
     $subject = "Subject: " . Nexista_Path::parseInlineFlow($this->params['subject']) . "\n";
     $body = Nexista_Flow::getbypath($this->params['body']);
     $host = Nexista_Path::parseInlineFlow($this->params['host']);
     if (require 'Net/SMTP.php') {
         $smtp = new Net_SMTP($host);
         $e = $smtp->connect();
         $smtp->mailFrom($sender);
         $disclosed_recipients = "To: ";
         if (is_array($recipient)) {
             foreach ($recipient as $to) {
                 if (PEAR::isError($res = $smtp->rcptTo($to))) {
                     die("Unable to add recipients {$to}: " . $res->getMessage() . "\n");
                 }
                 $disclosed_recipients .= $to;
             }
         } else {
             if (PEAR::isError($res = $smtp->rcptTo($recipient))) {
                 die("Unable to add single recipient {$recipient} for {$host}: " . $res->getMessage() . "\n");
             }
             $disclosed_recipients .= $recipient;
         }
         $disclosed_recipients .= "\n";
         $headers = $disclosed_recipients . $subject;
         $smtp->data($headers . "\r\n" . $body);
         $smtp->disconnect();
     } else {
         // try using mail()
     }
 }
Пример #3
0
 /**
  * Processes raw data files and throws them in stream
  *
  *
  * @param   string      name of file
  * @param   string      file content, returned by ref
  * @return  boolean     function success
  */
 public function process($src, &$result)
 {
     if (!($result = file_get_contents(Nexista_Path::parseInlineFlow($src)))) {
         return false;
     }
     return true;
 }
Пример #4
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $header = $this->params['header'];
     $value = Nexista_Path::parseInlineFlow($this->params['value']);
     // Can't use literal commas in the params section
     $value = str_replace(';', ',', $value);
     header($header . ': ' . $value);
 }
Пример #5
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $xpath = $this->params['var1'];
     $node = Nexista_Flow::find($xpath);
     $length = $this->params['var2'];
     $pad = Nexista_Path::parseInlineFlow($this->params['var3']);
     $type = $this->params['var4'];
     foreach ($node as $str) {
         $str->nodeValue = htmlspecialchars(str_pad($str->nodeValue, $length, $pad, STR_PAD_RIGHT), ENT_NOQUOTES, 'UTF-8', false);
     }
 }
Пример #6
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $destination = $_SERVER['PHP_SELF'] . '?' . NX_ID . '=' . Nexista_Path::parseInlineFlow($this->params['url']);
     $appendSession = isset($this->params['session']) ? $this->params['session'] : null;
     if ($appendSession) {
         $destination .= '&' . SESSID;
     }
     session_write_close();
     header('Location: ' . $destination);
     exit;
 }
Пример #7
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $destination = isset($this->params['url']) ? Nexista_Path::parseInlineFlow($this->params['url']) : null;
     $appendSession = isset($this->params['session']) ? $this->params['session'] : null;
     if (is_null($destination) and isset($_SERVER['HTTP_REFERER'])) {
         $destination = $_SERVER['HTTP_REFERER'];
     }
     if ($appendSession) {
         $destination .= '&' . SESSID;
     }
     session_write_close();
     header('Location: ' . $destination);
     exit;
 }
Пример #8
0
 /**
  * Returns a string based on given protocol://path 
  *
  * @param string $path     path to resolve/render
  * @param string $protocol (optional) default protocol if none given
  *
  * @return string value of variable
  */
 public static function get($path, $protocol = 'string')
 {
     switch ($protocol) {
         case 'flow':
             $result = Nexista_Flow::getByPath($path);
             break;
         default:
             $result = Nexista_Path::parseInlineFlow($path);
     }
     if (!is_null($result)) {
         return $result;
     } else {
         return false;
     }
 }
Пример #9
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     // if using a single node, use {}'s in sitemap
     // if referencing a nodeset, don't use {}'s
     $xpath1 = $this->params['var1'];
     $res1 = Nexista_Flow::find($xpath1);
     $xpath2 = $this->params['var2'];
     $res2 = Nexista_Flow::find($xpath2);
     $xpath3 = $this->params['var3'];
     $res3 = Nexista_Flow::find($xpath3);
     $i = 0;
     if ($res3->item(0)) {
         if ($res3->length === 1) {
             // there is a node, replace it, since its only one, res1 must
             // only be one as well
             $res3->item(0)->nodeValue = Nexista_Path::parseInlineFlow($this->params['var1']) . Nexista_Path::parseInlineFlow($this->params['var2']);
             return true;
         } elseif ($res3->length > 1) {
             // res3 is an array, so res3 is too
             foreach ($res1 as $str) {
                 if ($res2->length > 1 || $res2->length === 1) {
                     $res3->item($i)->nodeValue = $res1->item($i)->nodeValue . $res2->item($i)->nodeValue;
                 } else {
                     $res3->item($i)->nodeValue = $str->nodeValue . Nexista_Path::parseInlineFlow($this->params['var2']);
                 }
                 $i++;
             }
             return true;
         } else {
             // create a new node
             $new_node = $this->params['var3'];
             Nexista_Flow::add($new_node, $res1 . $res2);
             return true;
         }
     }
     return false;
 }
Пример #10
0
 /**
  * Applies action
  *
  * @return  boolean     success
  */
 protected function main()
 {
     // For now, limit calls to the same domain and protocol.
     $mydomain = $_SERVER['SERVER_NAME'];
     if (isset($_SERVER['HTTPS'])) {
         $protocol = "https://";
     } else {
         $protocol = "http://";
     }
     $url = $this->params['url'];
     $the_params = $this->params['params'];
     $my_params = Nexista_Flow::getByPath($the_params, "ASSOC");
     $target_node = $this->params['target_node'];
     //print_r($my_params);
     if (is_array($my_params)) {
         foreach ($my_params as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $my_key => $my_value) {
                     //Only adds the query piece if its not already there.
                     //tried array_unique earlier but it didn't work with
                     //array of arrays.
                     $query_piece = "&" . urlencode($my_key) . "[]=" . urlencode($my_value);
                     if (strpos($query_string, $query_piece) === false) {
                         $query_string .= $query_piece;
                     }
                 }
             } else {
                 $query_string = "&" . urlencode($key) . "=" . urlencode($value);
             }
         }
     }
     //echo $query_string;
     $url .= $query_string;
     if (!strpos($url, "www.")) {
         $url = $protocol . $mydomain . $url;
     } else {
     }
     // Quick hack to allow overriding above logic with complete,
     // off-domain url
     if (strstr($this->params['url'], 'http://')) {
         $url = Nexista_Path::parseInlineFlow($this->params['url']);
     }
     if (strstr($_GET['myurl'], 'http://')) {
         $url = $_GET['myurl'];
     }
     if (function_exists(curl_init)) {
         session_write_close();
         $mysession = session_name() . '=' . session_id();
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_COOKIE, $mysession);
         curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
         curl_setopt($ch, CURLOPT_VERBOSE, 1);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_POST, 0);
         curl_setopt($ch, CURLOPT_TIMEOUT, 120);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $xml = curl_exec($ch);
         if (curl_errno($ch)) {
             print curl_error($ch);
             exit;
         } else {
             curl_close($ch);
         }
     } else {
         $xml = "<{$target_node}>Curl PHP extension is not available.</{$target_node}>";
     }
     $config = array('indent' => true, 'output-xml' => true, 'wrap' => 0);
     // Tidy
     if (class_exists('tidy')) {
         $tidy = new tidy();
         $tidy->parseString($xml, $config, 'utf8');
         $tidy->cleanRepair();
         $xml = $tidy;
     }
     if (1 == 2) {
         // Should result be added to flow as XML?
         $doc = new DOMDocument('1.0', 'UTF-8');
         $doc->loadXML($xml);
         $flow = Nexista_Flow::singleton('Nexista_Flow');
         //import new doc into flow recursively
         $new = $flow->flowDocument->importNode($doc->documentElement, 1);
         //append back to node as parsed xml now
         $flow->root->appendChild($new);
     } else {
         Nexista_Flow::add($target_node, $xml);
     }
 }