Example #1
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $mytext = Nexista_Flow::getByPath($this->params['text']);
     $name = $this->params['name'];
     Nexista_Flow::add($name, $new_text);
     return true;
 }
Example #2
0
 /**
  * Applies action
  *
  * @return  boolean     success
  */
 protected function main()
 {
     $mode = 0775;
     //see if a path is given. we default to Nexista temp dir
     if (!($dest = Nexista_Path::get($this->params['dest'], 'flow'))) {
         $dest = empty($this->params['dest']) ? NX_PATH_TMP : trim($this->params['dest'], '/') . '/';
     }
     //websvn: stream wrapper
     if (strpos($dest, "websvn")) {
         require 'HTTP/WebDAV/Client.php';
     }
     if (!empty($_FILES[$this->params['file']]['tmp_name'])) {
         $name = $_FILES[$this->params['file']]['name'];
         $prefix = Nexista_Path::get($this->params['prefix'], "flow");
         if ($prefix != '') {
             $unique_id = $prefix;
             $name = $unique_id . "_" . $name;
         }
         if (!is_dir($dest)) {
             mkdir($dest, $mode, TRUE);
         }
         if (!move_uploaded_file($_FILES[$this->params['file']]['tmp_name'], $dest . $name)) {
             Nexista_Error::init('Upload action was unable to move uploaded file: ' . $name . '. Check ' . $dest . ' permissions', NX_ERROR_WARNING);
             return false;
         }
         //assign full destination path to flow as it can be useful
         $res = Nexista_Flow::find('//_files/file');
         if ($res->length === 1) {
             Nexista_Flow::add('new_dir', $dest, $res->item(0));
             Nexista_Flow::add('new_name', $dest . $name, $res->item(0));
         }
         //chmod($dest.$name,0644);
     }
     return true;
 }
Example #3
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $var = Nexista_Flow::find($this->params['var']);
     if (is_null($var) or is_array($var)) {
         return false;
     }
     switch (strtoupper($this->params['transtbl'])) {
         case 'HTML_ENTITIES':
             $trans_tbl = get_html_translation_table(HTML_ENTITIES);
             break;
             //for dealing with non xsl safe chars
         //for dealing with non xsl safe chars
         case 'XSL_ENTITIES':
             $trans_tbl = array(' ' => ' ');
             break;
         default:
             $trans_tbl = get_html_translation_table(HTML_ENTITIES);
             break;
     }
     if (!empty($this->params['reverse']) && $this->params['reverse'] === 'true') {
         $trans_tbl = array_flip($trans_tbl);
     }
     //write new data to Flow
     $var->item(0)->nodeValue = strtr($var->item(0)->nodeValue, $trans_tbl);
     return true;
 }
Example #4
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $mytext = Nexista_Path::get($this->params['text']);
     $new_text = strip_tags($mytext);
     Nexista_Flow::add('no_html_text', $new_text);
     return true;
 }
Example #5
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;
 }
Example #6
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()
     }
 }
Example #7
0
 /**
  * process xsl template with Flow xml
  *
  * @param   string      xsl source file
  * @return  string      xsl transformation output
  */
 public function process($xslfile)
 {
     $flow = Nexista_Flow::Singleton('Nexista_Flow');
     // The following can be used with the NYT xslt cache.
     $use_xslt_cache = "yes";
     if (!is_file($xslfile)) {
         Nexista_Error::init('XSL Handler - Error processing XSL file,
             it is unavailable: ' . $xslfile, NX_ERROR_FATAL);
     }
     if ($use_xslt_cache != "yes" || !class_exists('xsltCache')) {
         $xsl = new DomDocument('1.0', 'UTF-8');
         $xsl->substituteEntities = false;
         $xsl->resolveExternals = false;
         $xslfilecontents .= file_get_contents($xslfile);
         $xsl->loadXML($xslfilecontents);
         $xsl->documentURI = $xslfile;
         $xslHandler = new XsltProcessor();
         $xslHandler->importStyleSheet($xsl);
         if (4 == 3 && function_exists('setProfiling')) {
             $xslHandler->setProfiling("/tmp/xslt-profiling.txt");
         }
     } else {
         $xslHandler = new xsltCache();
         $xslHandler->importStyleSheet($xslfile);
     }
     $output = $xslHandler->transformToXML($flow->flowDocument);
     if ($output === false) {
         Nexista_Error::init('XSL Handler - Error processing XSL file: ' . $xslfile, NX_ERROR_FATAL);
     }
     return $output;
 }
Example #8
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $res = Nexista_Flow::find($this->params['var']);
     if ($res->length === 1) {
         $res->item(0)->nodeValue = "%" . $res->item(0)->nodeValue . "%";
         return true;
     }
     return false;
 }
Example #9
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $res = Nexista_Flow::find($this->params['var']);
     if ($res->length === 1) {
         $text = $res->item(0)->nodeValue;
         $res->item(0)->nodeValue = base64_encode(gzcompress($text, 6));
         return true;
     }
     return false;
 }
Example #10
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     include_once 'markdown.php';
     $xpath = $this->params['text'];
     $node = Nexista_Flow::find($xpath);
     foreach ($node as $item) {
         $item->nodeValue = Markdown($item->nodeValue);
     }
     return true;
 }
Example #11
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $res = Nexista_Flow::find($this->params['var']);
     if ($res->length === 1) {
         $text = $res->item(0)->nodeValue;
         $res->item(0)->nodeValue = htmlspecialchars(gzuncompress(base64_decode($text)));
         return true;
     }
     return false;
 }
Example #12
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $res = Nexista_Flow::find($this->params['var']);
     if (!empty($res)) {
         $chars = Nexista_Flow::getByPath($this->params['chars']);
         $res->item(0)->nodeValue = str_replace($chars, "", $res->item(0)->nodeValue);
         return true;
     } else {
         return false;
     }
 }
Example #13
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);
     }
 }
Example #14
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     include 'HTML/BBCodeParser.php';
     $mytext = Nexista_Flow::getByPath($this->params['text']);
     $name = $this->params['name'];
     $parser = new HTML_BBCodeParser();
     $parser->addFilters('Basic,Extended,Links,Images,Lists');
     $new_text = $parser->qParse($mytext);
     Nexista_Flow::add($name, $new_text);
     return true;
 }
Example #15
0
 /**
  * Applies filter
  *
  * @return  boolean success
  * @access  private
  */
 function main()
 {
     // Right now this filter only converts from 12 to 24 hour time formats.
     $year = Nexista_Path::get($this->params['year'], 'flow');
     $month = Nexista_Path::get($this->params['month'], 'flow');
     $day = Nexista_Path::get($this->params['day'], 'flow');
     $name = $this->params['name'];
     $mydate = "{$year}-{$month}-{$day} 01:01:01";
     Nexista_Flow::add($name, $mydate);
     return true;
 }
Example #16
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $xpath = $this->params['var'];
     $node = Nexista_Flow::find($xpath);
     foreach ($node as $item) {
         //write new data to Flow
         $string = nl2br($item->nodeValue);
         $string = preg_replace('/(<pre)(.*)(<\\/pre>)/mes', "'\$1'.str_replace('<br />','','\$2').'\$3'", $string);
         $string = str_replace('\\"', '"', $string);
         $item->nodeValue = htmlspecialchars($string, ENT_QUOTES, "UTF-8", false);
     }
     return true;
 }
Example #17
0
 /**
  * Call this function to activate the processor
  *
  * @param   string    xpath to XML node, does not currently support nodesets
  * @param   string    node name to create and assign a value to
  * @return  boolean   success
  */
 public function process($name, $value)
 {
     $res = Nexista_Flow::find($name);
     //if var exists, set the new value
     if ($res->length === 1) {
         $res->item(0)->nodeValue = $value;
     } elseif ($res->length === 0) {
         //create new var/value
         Nexista_Flow::add($name, $value);
     } else {
         return false;
     }
     return true;
 }
Example #18
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;
     }
 }
Example #19
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     include 'HTML/Safe.php';
     $mytext = Nexista_Flow::getByPath($this->params['text']);
     $name = $this->params['name'];
     $parser =& new HTML_Safe();
     $new_text = $parser->parse($mytext);
     if (empty($name)) {
         $node = Nexista_Flow::find($this->params['text']);
         $node->item(0)->nodeValue = $new_text;
     } else {
         Nexista_Flow::add($name, $new_text);
     }
     return true;
 }
Example #20
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $tidy = new tidy();
     $xpath = $this->params['text'];
     $node = Nexista_Flow::find($xpath);
     $config = array('output-xhtml' => true, 'numeric-entities' => true, 'preserve-entities' => true);
     foreach ($node as $item) {
         $tidy->parseString($item->nodeValue, $config, 'utf8');
         $tidy->cleanRepair();
         $temp = str_replace('</body>', '', str_replace('<body>', '', $tidy->Body()));
         if (!strpos($temp, '&')) {
             $item->nodeValue = $temp;
         }
     }
     return true;
 }
Example #21
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $text = Nexista_Path::get($this->params['haystack']);
     $tokens = Nexista_Flow::getbypath($this->params['token_array_xpath']);
     /*
     echo "<pre>";
     print_r($tokens);
     echo "</pre>";
     echo "<br/>";
     */
     foreach ($tokens as $token) {
         $text = str_replace($token['key'], Nexista_Flow::getbypath($token['value']), $text);
     }
     Nexista_Flow::add('new_text', $text);
     return true;
 }
Example #22
0
 /**
  * Applies filter
  *
  * @return  boolean success
  * @access  private
  */
 function main()
 {
     $xpath = $this->params['source_datetime'];
     $node = Nexista_Flow::find($xpath);
     $sformat = Nexista_Path::get($this->params['source_format']);
     $tformat = Nexista_Path::get($this->params['target_format']);
     $tz = Nexista_Path::get($this->params['timezone_offset']);
     $tz = $tz * 3600;
     foreach ($node as $item) {
         if ($sformat == 'unix_epoch') {
             $item->nodeValue = gmdate($tformat, $item->nodeValue + $tz);
         } else {
             $unix_epoch_str = strtotime($item->nodeValue);
             $item->nodeValue = gmdate($tformat, $unix_epoch_str + $tz);
         }
     }
 }
Example #23
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $name = $this->params['name'];
     $count = $this->params['randomness'];
     if (!($count > 0)) {
         $count = 8;
     }
     if ($ph = @popen('xxd -p -l ' . $count . ' /dev/urandom', 'r')) {
         $rnd = fread($ph, $count);
         pclose($ph);
     }
     if (strlen($rnd) < $count) {
         $rnd = $rnd . mt_rand(100000, 2000000);
         $rnd = substr($rnd, 0, $count);
     }
     Nexista_Flow::add($name, $rnd);
     return true;
 }
Example #24
0
 /**
  * Applies filter
  *
  * @return  boolean success
  * @access  private
  */
 function main()
 {
     // Right now this filter only converts from 12 to 24 hour time formats.
     $hours = Nexista_Path::get($this->params['hours'], "flow");
     $minutes = Nexista_Path::get($this->params['minutes'], "flow");
     $am_pm = Nexista_Path::get($this->params['am_pm'], "flow");
     $when = $this->params['when'];
     if ($am_pm == "PM" && $hours != "12") {
         $hours = $hours + 12;
     }
     if ($am_pm == "AM" && $hours == "12") {
         $hours = "00";
     }
     $iso = "{$hours}:{$minutes}:00";
     $when = $when . "_iso_time";
     Nexista_Flow::add($when, $iso);
     return true;
 }
Example #25
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $ids_x = $this->params['ids'];
     $ids = Nexista_Flow::find($ids_x);
     $params = Nexista_Flow::getbypath($this->params['param_array_xpath']);
     foreach ($ids as $id) {
         $link = "";
         foreach ($params as $param) {
             //$link .= $param['name']."=";
             $myname = $param['name'];
             if ($myname == "key") {
                 $link .= $id->nodeValue . "/";
             } else {
                 $myval = Nexista_Flow::getbypath($param['value']);
                 $link .= $myval . "/";
             }
         }
         $id->nodeValue = $link;
     }
     return true;
 }
Example #26
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $var = Nexista_Flow::getByPath($this->params['var']);
     if (is_null($var) or is_array($var)) {
         return false;
     }
     $trans_array = array();
     for ($i = 127; $i < 255; $i++) {
         if ($this->params['translate'] == 'true') {
             $trans_array[chr($i)] = "&#" . $i . ";";
         } else {
             $trans_array[chr($i)] = "";
         }
     }
     //also deal with xsl stuff
     $sterile = strtr($var->textContent, $trans_array);
     //strip tags with namespaces
     $sterile = preg_replace('~<([^>\\"=\']*):(.*)>~mU', '', $sterile);
     //write new data to Flow
     $var->textContent = $sterile;
     return true;
 }
Example #27
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     // http://www.php.net/manual/en/function.crypt.php
     $pwd = Nexista_Flow::find($this->params['pwd']);
     $hash_type = $this->params['hash_type'];
     $count = 8;
     if ($pwd->length === 1) {
         $mypwd = $pwd->item(0)->nodeValue;
     }
     // If a cryptmd5 is selected, a hash is either provided or is generated.
     // The code used here to generate
     if ($hash_type == 'cryptmd5' || !empty($this->params['salt'])) {
         // Got salt?
         if ($this->params['salt'] == '') {
             $mysalt = '';
             if ($ph = @popen('xxd -p -l ' . $count . ' /dev/urandom', 'r')) {
                 $mysalt = fread($ph, $count);
                 pclose($ph);
             }
             if (strlen($mysalt) < $count) {
                 $mysalt = $mysalt . mt_rand(100000, 2000000);
                 $mysalt = substr($mysalt, 0, $count);
             }
             $mysalt = '$1$' . $mysalt . '$';
         } else {
             $salt = Nexista_Flow::find($this->params['salt']);
             $mysalt = $salt->item(0)->nodeValue;
         }
         $hash = crypt($mypwd, $mysalt);
         // Non-salted hash
         // http://www.php.net/manual/en/function.hash.php
     } elseif (in_array($hash_type, hash_algos())) {
         $hash = hash($hash_type, $mypwd);
     } else {
         return false;
     }
     Nexista_Flow::add('hash', $hash);
     return true;
 }
Example #28
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     // openssl genrsa -out key.pem
     // openssl rsa -in key.pem -noout -modulus
     // str_replace('Modulus=','',$modulus);
     // put modulus in config.xml defaults
     $mpk = Nexista_Path::get($this->params['private_key']);
     $pk = file_get_contents($mpk);
     $my_private_key = openssl_pkey_get_private($pk);
     $cipher_text = Nexista_Flow::find($this->params['ciphered_text']);
     if ($cipher_text->length === 1) {
         $my_cipher_text = $cipher_text->item(0)->nodeValue;
     }
     $my_cipher_text_bin = pack("H*", $my_cipher_text);
     //$my_cipher_text_bin = base64_decode($my_cipher_text);
     if (openssl_private_decrypt($my_cipher_text_bin, &$my_clear_text, $my_private_key)) {
         // success
         $cipher_text->item(0)->nodeValue = $my_clear_text;
     } else {
         return false;
     }
 }
Example #29
0
 /**
  * Call this function to activate the xml handler
  *
  *
  * @param       string  the name of the xml file to process
  * @param       string - path of parent. default to root
  * @return      boolean success
  */
 public function process($src, $parent = false)
 {
     //load xml file
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->load($src);
     $doc->xinclude();
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     //import new doc into flow recursively
     $new = $flow->flowDocument->importNode($doc->documentElement, 1);
     //append to parent if called for
     if ($parent) {
         $res = Nexista_Flow::find($parent);
         if ($res->length > 0) {
             $parent = $res->item(0);
             $parent->appendChild($new);
         } else {
             return false;
         }
     } else {
         $flow->root->appendChild($new);
     }
     return true;
 }
Example #30
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;
 }