Beispiel #1
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;
 }
Beispiel #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;
 }
Beispiel #3
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;
 }
Beispiel #4
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;
 }
Beispiel #5
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;
 }
Beispiel #6
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;
 }
Beispiel #7
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);
     }
 }
Beispiel #8
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;
     }
 }
Beispiel #9
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;
 }
Beispiel #10
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;
 }
Beispiel #11
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;
 }
Beispiel #12
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;
 }
Beispiel #13
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);
         }
     }
 }
Beispiel #14
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;
 }
Beispiel #15
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;
 }
Beispiel #16
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;
     }
 }
Beispiel #17
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;
 }
Beispiel #18
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;
 }
Beispiel #19
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;
     }
     $res = $var->item(0);
     $xmlString = $res->textContent;
     //load xml string
     $doc = new DOMDocument();
     $doc->loadXML($xmlString);
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     //import new doc into flow recursively
     $new = $flow->flowDocument->importNode($doc->documentElement, 1);
     $replace = $this->params['replace'];
     if ($replace == "true") {
         $res->nodeValue = "";
     }
     //append back to node as parsed xml now
     $res->appendChild($new);
     //echo $flow->outputXml($flow->root);
     //exit;
     return true;
 }
Beispiel #20
0
 /**
  * Returns the value of a flow variable(s) given an xpath query
  *
  * This is a wrapper for a joined find/get item query. 
  * If multiple items are found, it will only return the first one
  *
  * @param string $path       an xpath query
  * @param string $array_type type of array
  *
  * @return mixed value of first found variable, or an array if multiple matches,
  * or null if no matches
  */
 public static function getByPath($path, $array_type = null)
 {
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     $res = Nexista_Flow::find($path);
     if ($res->length > 1) {
         $array = array();
         foreach ($res as $r) {
             $array[] = $flow->get($r, $array_type);
         }
         return $array;
     }
     if ($res->length == 1) {
         $string = $flow->get($res->item(0), $array_type);
         if (is_null($string) or empty($string)) {
             return null;
         }
         return $string;
     } else {
         return null;
     }
 }