Example #1
0
function _e($str)
{
    if (!isUTF8($str)) {
        return utf8_encode($str);
    }
    return $str;
}
Example #2
0
 function GetTasks($parentTaskId)
 {
     global $page;
     $xmlData = "";
     $i = 0;
     while (isset($page->element[$i])) {
         $page_element = $page->element[$i];
         switch ($page_element->get_elementtype()) {
             case HAW_TABLE:
                 $table = $page->element[$i];
                 for ($a = 0; $a < $table->number_of_rows; $a++) {
                     $xmlData .= "<row>";
                     $row = $table->row[$a];
                     for ($b = 0; $b < $row->number_of_columns; $b++) {
                         $column = $row->column[$b];
                         if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                             $text = '<col>' . $column->get_text() . '</col>';
                             $xmlData .= !isUTF8($text) ? $text : utf8_encode($text);
                         }
                         if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                             $text = '<col>' . $column->get_label() . '</col>';
                             $xmlData .= !isUTF8($text) ? $text : utf8_encode($text);
                         }
                     }
                     $xmlData .= "</row>";
                 }
                 break;
         }
         $i++;
     }
     return array("somearray" => array(6 => 5, 13 => 9, "a" => 42));
     //return $xmlData;
 }
Example #3
0
function strip_quotes($text)
{
    if (!isUTF8($text)) {
        $text = utf8_encode($text);
    }
    return str_replace('"', "", $text);
}
Example #4
0
 function create_page()
 {
     $i = 0;
     $content = '';
     while (isset($this->element[$i])) {
         $page_element = $this->element[$i];
         switch ($page_element->get_elementtype()) {
             case HAW_PLAINTEXT:
                 $text = $this->element[$i];
                 $content .= !isUTF8(stripslashes($text->text)) ? utf8_encode(stripslashes($text->text)) : stripslashes($text->text);
                 break;
             case HAW_LINK:
                 $link = $this->element[$i];
                 break;
             case HAW_TABLE:
                 $table = $this->element[$i];
                 echo utf8_encode("var camila_table = new Array();\n");
                 for ($a = 0; $a < $table->number_of_rows; $a++) {
                     $row = $table->row[$a];
                     echo utf8_encode("var camila_row");
                     echo !isUTF8($a) ? utf8_encode($a) : $a;
                     echo utf8_encode(" = new Array();\n");
                     for ($b = 0; $b < $row->number_of_columns; $b++) {
                         $column = $row->column[$b];
                         if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                             echo utf8_encode("camila_row");
                             echo !isUTF8($a) ? utf8_encode($a) : $a;
                             echo utf8_encode("[");
                             echo !isUTF8($b) ? utf8_encode($b) : $b;
                             echo utf8_encode("] = '");
                             echo !isUTF8(addslashes($column->text)) ? utf8_encode(addslashes($column->text)) : addslashes($column->text);
                             echo utf8_encode("';\n");
                         }
                         if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                             echo utf8_encode("camila_row");
                             echo !isUTF8($a) ? utf8_encode($a) : $a;
                             echo utf8_encode("[");
                             echo !isUTF8($b) ? utf8_encode($b) : $b;
                             echo utf8_encode("] = '");
                             echo !isUTF8(addslashes($column->label)) ? utf8_encode(addslashes($column->label)) : addslashes($column->label);
                             echo utf8_encode("';\n");
                         }
                     }
                     echo utf8_encode("camila_table[");
                     echo !isUTF8($a) ? utf8_encode($a) : $a;
                     echo utf8_encode("] = camila_row");
                     echo !isUTF8($a) ? utf8_encode($a) : $a;
                     echo utf8_encode(";\n");
                 }
                 break;
         }
         $i++;
         !isUTF8(stripslashes($text->text)) ? utf8_encode(stripslashes($text->text)) : stripslashes($text->text);
     }
     echo utf8_encode("var camila_content='");
     echo $content;
     echo utf8_encode("';\n");
 }
Example #5
0
function makeUTF8($str, $encoding = "")
{
    if ($str !== "") {
        if (empty($encoding) && isUTF8($str)) {
            $encoding = "UTF-8";
        }
        if (empty($encoding)) {
            $encoding = mb_detect_encoding($str, 'UTF-8, ISO-8859-1');
        }
        if (empty($encoding)) {
            $encoding = "ISO-8859-1";
        }
        //  if charset can't be detected, default to ISO-8859-1
        return $encoding == "UTF-8" ? $str : @mb_convert_encoding($str, "UTF-8", $encoding);
    }
}
Example #6
0
 function create_page()
 {
     global $_CAMILA;
     if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download') {
         header("Content-type: application/csv");
         header("Content-Disposition: filename=\"" . $this->camila_export_safe_filename() . ".csv\"");
     } else {
         $_CAMILA['ob_filename'] = $this->camila_export_safe_filename() . '.' . $this->camila_export_get_ext();
         if (!$this->camila_export_file_exists || $_REQUEST['camila_export_overwrite'] == 'y') {
             $_CAMILA['ob_file'] = fopen($this->camila_export_get_dir() . $this->camila_export_filename(), 'w');
         }
         ob_start('camila_ob_file_callback');
     }
     $i = 0;
     while (isset($this->element[$i])) {
         $page_element = $this->element[$i];
         switch ($page_element->get_elementtype()) {
             case HAW_TABLE:
                 $table = $this->element[$i];
                 for ($a = 0; $a < $table->number_of_rows; $a++) {
                     $row = $table->row[$a];
                     for ($b = 0; $b < $row->number_of_columns; $b++) {
                         $column = $row->column[$b];
                         if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                             $text = "\"" . str_replace('"', '""', $column->get_text()) . "\"";
                             echo isUTF8($text) ? $text : utf8_encode($text);
                         }
                         if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                             $text = "\"" . str_replace('"', '""', $column->get_label()) . "\"";
                             echo isUTF8($text) ? $text : utf8_encode($text);
                         }
                         if ($b < $row->number_of_columns - 1) {
                             echo utf8_encode(",");
                         } else {
                             echo utf8_encode("\n");
                         }
                     }
                 }
                 break;
         }
         $i++;
     }
     if ($_REQUEST['camila_export_action'] != '' && $_REQUEST['camila_export_action'] != 'download') {
         ob_end_flush();
     }
 }
 function get_site_meta_tags($url)
 {
     $site_title = array();
     $fp = @file_get_contents($url);
     if ($fp) {
         $res = preg_match("/<title>(.*)<\\/title>/siU", $fp, $title_matches);
         if ($res) {
             $site_title = preg_replace('/\\s+/', ' ', $title_matches[1]);
             $site_title = trim($site_title);
         }
         $site_meta_tags = get_meta_tags($url);
         $site_meta_tags['title'] = $site_title;
         foreach ($site_meta_tags as $key => $value) {
             if (!isUTF8($value)) {
                 $site_meta_tags[$key] = utf8_encode($value);
             }
         }
     }
     return $site_meta_tags;
 }
Example #8
0
                            } else {
                                //data is lost ... unknown encryption
                            }
                        }
                        fputs($dbgDuo, "\nCategory treatment done.");
                    }
                }
                if ($next >= $_POST['total']) {
                    $finish = "suggestion";
                }
            } else {
                fputs($dbgDuo, "\nStarting suggestion.\n\n");
                // decrypt passwords in suggestion table
                $resData = mysqli_query($dbTmp, "SELECT id, pw, pw_iv\n                    FROM " . $_SESSION['tbl_prefix'] . "suggestion") or die(mysqli_error($dbTmp));
                while ($record = mysqli_fetch_array($resData)) {
                    $tmpData = substr(decrypt($record['pw']), strlen($record['pw_iv']));
                    if (isUTF8($tmpData) && !empty($tmpData)) {
                        $encrypt = cryption($tmpData, SALT, "", "encrypt");
                        // store Password
                        mysqli_query($dbTmp, "UPDATE " . $_SESSION['tbl_prefix'] . "suggestion\n                            SET pw = '" . $encrypt['string'] . "', pw_iv = '" . $encrypt['iv'] . "'\n                            WHERE id =" . $record['id']) or die(mysqli_error($dbTmp));
                    } else {
                        //data is lost ... unknown encryption
                    }
                }
                $finish = true;
            }
            fputs($dbgDuo, "\n\nAll finished.\n");
            echo '[{"finish":"' . $finish . '" , "next":"' . $next . '" ' . ', "progress":"' . round($next * 100 / $_POST['total'], 0) . '"}]';
            break;
    }
}
 // Prepare encryption options
 $iv = substr(md5("<X" . SALT, true), 0, 8);
 $key = substr(md5("-üØ" . SALT, true) . md5("-üÙ" . SALT, true), 0, 24);
 $opts = array('iv' => $iv, 'key' => $key);
 // treat 10 files
 $filesList = explode(';', $_POST['list']);
 foreach ($filesList as $file) {
     if ($cpt < 5) {
         // skip file is Coherancey not respected
         $fp = fopen($_SESSION['settings']['path_to_upload_folder'] . '/' . $file, "rb");
         $line = fgets($fp);
         $skipFile = false;
         // check if isUTF8. If yes, then check if process = encryption, and vice-versa
         if (!isUTF8($line) && $_POST['option'] == "decrypt") {
             $skipFile = true;
         } elseif (isUTF8($line) && $_POST['option'] == "encrypt") {
             $skipFile = true;
         }
         fclose($fp);
         if ($skipFile == true) {
             // make a copy of file
             if (!copy($_SESSION['settings']['path_to_upload_folder'] . '/' . $file, $_SESSION['settings']['path_to_upload_folder'] . '/' . $file . ".copy")) {
                 $error = "Copy not possible";
                 exit;
             }
             // Open the file
             unlink($_SESSION['settings']['path_to_upload_folder'] . '/' . $file);
             $fp = fopen($_SESSION['settings']['path_to_upload_folder'] . '/' . $file . ".copy", "rb");
             $out = fopen($_SESSION['settings']['path_to_upload_folder'] . '/' . $file, 'wb');
             if ($_POST['option'] == "decrypt") {
                 stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts);
$rationale = '';
$status = array();
// Get the values from the REQUEST parameters
foreach ($_REQUEST as $name => $value) {
    if ($name == 'email') {
        $email = $value;
        // XXX do stripslashes() here and below?
    } elseif ($name == 'rationale') {
        $rationale = $value;
    } elseif ($value == 'TBW' || $value == 'WIP' || $value == 'SCS' || $value == 'none') {
        // Ignore any other values, including empty values.
        $status[addslashes($name)] = $value;
    }
}
// Ensure that email and rationale were provided
if ($email == '' || !Email::isValidEmail($email) || $rationale == '' || !isUTF8($rationale) || mb_strlen($rationale) > 125) {
    getMissingInfo($email, $rationale, $status);
} else {
    if ($_SERVER['PATH_INFO'] == '/confirm') {
        updateDB($email, $rationale, $status);
        outputConfirmed();
    } else {
        $body = getMailConfirmRequest($email, $rationale, $status);
        $sig = "HTML5 Status Updates\nhttp://www.whatwg.org/html5";
        $mail = new Email();
        $mail->setSubject("HTML5 Status Update");
        $mail->addRecipient('To', '*****@*****.**', 'Lachlan Hunt');
        $mail->setFrom("*****@*****.**", "WHATWG");
        $mail->setSignature($sig);
        $mail->setText($body);
        $mail->send();
Example #11
0
/**
 * Converts accented characters into their plain alphabetic counterparts
 *
 * @access	public
 * @param	string		Raw text
 * @return	string		Cleaned text
 */
function convertAccents($string)
{
    if (!preg_match('/[\\x80-\\xff]/', $string)) {
        return $string;
    }
    if (isUTF8($string)) {
        $_chr = array(chr(195) . chr(128) => 'A', chr(195) . chr(129) => 'A', chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A', chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A', chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E', chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E', chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I', chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I', chr(195) . chr(143) => 'I', chr(195) . chr(145) => 'N', chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O', chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O', chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U', chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U', chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y', chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a', chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a', chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a', chr(195) . chr(165) => 'a', chr(195) . chr(167) => 'c', chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e', chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e', chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i', chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i', chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o', chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o', chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o', chr(195) . chr(182) => 'o', chr(195) . chr(185) => 'u', chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u', chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y', chr(195) . chr(191) => 'y', chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a', chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a', chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a', chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c', chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c', chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c', chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c', chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd', chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd', chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e', chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e', chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e', chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e', chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e', chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g', chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g', chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g', chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g', chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h', chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h', chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i', chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i', chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i', chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i', chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i', chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij', chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j', chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k', chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L', chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L', chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L', chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L', chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L', chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N', chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N', chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N', chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N', chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N', chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o', chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o', chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o', chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe', chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r', chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r', chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r', chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's', chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's', chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's', chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's', chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't', chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't', chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't', chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u', chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u', chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u', chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u', chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u', chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u', chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w', chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y', chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z', chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z', chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z', chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's', chr(226) . chr(130) . chr(172) => 'E', chr(194) . chr(163) => '');
        $string = strtr($string, $_chr);
    } else {
        $_chr = array();
        $_dblChars = array();
        /* We assume ISO-8859-1 if not UTF-8 */
        $_chr['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158) . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194) . chr(195) . chr(199) . chr(200) . chr(201) . chr(202) . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210) . chr(211) . chr(212) . chr(213) . chr(217) . chr(218) . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235) . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243) . chr(244) . chr(245) . chr(249) . chr(250) . chr(251) . chr(252) . chr(253) . chr(255) . chr(191) . chr(182) . chr(179) . chr(166) . chr(230) . chr(198) . chr(175) . chr(172) . chr(188) . chr(163) . chr(161) . chr(177);
        $_chr['out'] = "EfSZszYcYuAAAACEEEEIIIINOOOOUUUUYaaaaceeeeiiiinoooouuuuyyzslScCZZzLAa";
        $string = strtr($string, $_chr['in'], $_chr['out']);
        $_dblChars['in'] = array(chr(140), chr(156), chr(196), chr(197), chr(198), chr(208), chr(214), chr(216), chr(222), chr(223), chr(228), chr(229), chr(230), chr(240), chr(246), chr(248), chr(254));
        $_dblChars['out'] = array('Oe', 'oe', 'Ae', 'Aa', 'Ae', 'DH', 'Oe', 'Oe', 'TH', 'ss', 'ae', 'aa', 'ae', 'dh', 'oe', 'oe', 'th');
        $string = str_replace($_dblChars['in'], $_dblChars['out'], $string);
    }
    return $string;
}
Example #12
0
function expression_results_and_interface($OBJ_EXPR, $idx, $entire_match, $idt, $bool_buffer_output_merge)
{
    global $db;
    global $mode_xml, $mode_edit, $mode_cxml, $mode_short, $mode_output;
    global $this_server_url, $q, $qn;
    global $standalone_code;
    global $STATIC;
    global $adjacent_dictionary;
    global $APP;
    global $mode_jidonly;
    global $settings;
    global $u;
    global $demo_domain;
    global $system_adjacent_dictionary_keys;
    $retval = array();
    $retval['buffer'] = "";
    // idx = tree # in the forest of trees
    // xml mode
    if ($mode_xml) {
        for ($in = 1; $in < $idt + 1; $in++) {
            echo "\t";
        }
        echo "<result>\n";
        for ($in = 1; $in < $idt + 2; $in++) {
            echo "\t";
        }
        echo "<hfs>\n";
    }
    // edit mode
    if ($mode_edit) {
        echo "<ul style='margin-left:0px;background-color:" . rcolor() . "'>";
        //echo "<font size=-1>";
    }
    // CUSTOM HEADER FIELDS/PRINTOUT
    $chead = "";
    $chead_after_replace = "";
    if (isset($OBJ_EXPR->obj_match_customs['0.header'])) {
        $chead = $OBJ_EXPR->obj_match_customs['0.header']->obj_txt->body;
        $chead_after_replace = replace_hf_parameters($chead, $q->obj_hf_parameters);
    }
    if ($mode_cxml && !$mode_jidonly) {
        if (!$bool_buffer_output_merge) {
            echo $chead_after_replace;
        }
    }
    $retval['buffer'] = $retval['buffer'] . $chead_after_replace;
    //if ($mode_cxml && !$mode_jidonly) echo $chead_after_replace;
    if ($mode_edit) {
        echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>";
        echo getTranslation("Custom Header", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . "0";
        echo "): ";
        echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
        echo "<input type='hidden' name='idx_key' value='0.header'/>";
        echo "<textarea name='str_txt' rows='1' cols='50' style='width:500px;'>";
        echo str_replace("<", "&lt;", $chead);
        echo "</textarea>";
        echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
        echo "</form>\n";
    }
    if ($chead != $chead_after_replace && $mode_edit) {
        echo "\tAfter Replacement: " . htmlspecialchars($chead_after_replace) . "\n";
    }
    if ($mode_edit) {
        echo "<ul style='margin-left:5px;'>";
    }
    $mi = 0;
    //print_r($entire_match);
    if (is_array($entire_match)) {
        foreach ($entire_match as $match_field) {
            // for each (each "(.*?)" field in the regex)
            $mi = $mi + 1;
            $this_value = $match_field;
            $filtering_expression = "";
            $rid = 0;
            // CUSTOM HEADER FIELDS/PRINTOUT
            $custom_head = $OBJ_EXPR->obj_match_customs;
            $chead = "";
            $chead_after_replace = "";
            if ($custom_head) {
                if (isset($custom_head[$mi . '.header'])) {
                    $chead = $custom_head[$mi . '.header']->obj_txt->body;
                    $chead_after_replace = replace_hf_parameters($chead, $q->obj_hf_parameters);
                }
            }
            if ($mode_cxml && !$mode_jidonly) {
                if (!$bool_buffer_output_merge) {
                    echo $chead_after_replace;
                }
            }
            $retval['buffer'] = $retval['buffer'] . $chead_after_replace;
            // CUSTOM HEADER GUI EDIT FIELD
            $this_box_color = "";
            if ($mode_edit) {
                echo "<br/>";
                echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Header", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . $mi . "): ";
                echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
                echo "<input type='hidden' name='idx_key' value='" . $mi . ".header'/>";
                echo "<textarea rows='1' name='str_txt' style='width:500px;'/>";
                echo str_replace("<", "&lt;", $chead);
                echo "</textarea>";
                echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                echo "</form>\n";
                if ($chead != $chead_after_replace) {
                    echo "\tAfter Replacement: " . htmlspecialchars($chead_after_replace) . "\n";
                }
                echo "<br/>";
                echo "<b><span style='margin-left:15px;'>" . getTranslation("FILTER RESULT VALUE", $settings) . " (" . getTranslation("Length", $settings) . ": " . strlen($this_value) . "):</span></b>\n";
                echo "<ul style='margin-left:15px;'>";
                $rows_textarea = 1;
                if (strlen($this_value) > 30) {
                    //$rows_textarea=2;
                }
                echo "<textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='{$rows_textarea}' cols='60'>";
                echo str_replace("<", "&lt;", $this_value);
                //echo print_r($this_value);
                //echo trim(htmlspecialchars($this_value));
                echo "</textarea>";
                $this_box_color = rcolor();
                echo "<div style='vertical-align:top;background-color:" . rcolor() . ";margin-left:0px;'>";
            }
            $match_entries = $OBJ_EXPR->obj_match_entries;
            $bool_has_filter = false;
            $bool_has_operation = false;
            $bool_has_buffer = false;
            $bool_has_action = false;
            $bool_has_output = false;
            $bool_has_output_type_print = false;
            $bool_buffer_children = false;
            if (is_array($match_entries)) {
                //print_r($match_entries);
                if ($mode_edit) {
                    echo "<ul style='margin-left:5px;'>";
                }
                foreach ($match_entries as $match_entry) {
                    if ($match_entry->id_entry_type == 'processing') {
                        $bool_has_filter = true;
                    }
                    if ($match_entry->id_entry_type == 'operation') {
                        $bool_has_operation = true;
                    }
                    // OUTPUT
                    if ($match_entry->id_entry_type == 'output') {
                        if (strpos($match_entry->idx_id, "-1") === False) {
                            $bool_has_output = true;
                            if ($match_entry->id_entry_subtype == 'print-value') {
                                $bool_has_output_type_print = true;
                            }
                        }
                    }
                    // END IF OUTPUT
                    // ACTION
                    if ($match_entry->id_entry_type == 'action') {
                        $bool_has_action = true;
                        if ($match_entry->id_entry_subtype == 'buffer') {
                            $bool_has_buffer = true;
                        }
                    }
                    // END IF ACTION
                }
                // FOREACH
                if ($bool_has_buffer || $bool_buffer_output_merge) {
                    $bool_buffer_children = true;
                }
                usort($match_entries, "meordersort");
                if ($mode_edit) {
                }
                // END IF (NOTEFILTER)
                foreach ($match_entries as $match_entry) {
                    foreach ($match_entry->obj_me_settings as $MESK => $MESV) {
                        //if ( !isset($match_entry->obj_me_settings[$MESK]->value) )
                        //{
                        //    $match_entry->obj_me_settings[$MESK]->value = "";
                        //}
                        $match_entry->obj_me_settings[$MESK]->value = replace_dictionary($match_entry->obj_me_settings[$MESK]->value, $adjacent_dictionary);
                    }
                    $match_entry_apply_to_subgroup_array = explode("#", $match_entry->idx_id);
                    $match_entry_apply_to_subgroup = $match_entry_apply_to_subgroup_array[0];
                    if ($match_entry_apply_to_subgroup != $mi) {
                        continue;
                    }
                    // PROCESSING
                    if ($match_entry->id_entry_type == 'processing') {
                        if ($mode_edit) {
                            $this_box_color = rcolor();
                            echo getTranslation("PROCESSING", $settings);
                            echo ": ";
                            echo "<ul style='background-color:{$this_box_color};'>";
                            if (isset($match_entry->obj_expression)) {
                                echo "<a name='" . $match_entry->obj_expression->id . "_-1.notesection'>";
                                echo "<div style='background-color:" . rcolor() . ";padding-left:35px;'>";
                                echo getTranslation("Describe everything in the outer area covered by", $settings);
                                echo "<span style='background-color:{$this_box_color};width:100px;display:inline;'>";
                                echo getTranslation("this color", $settings);
                                echo "</span>";
                                echo getTranslation("- what does it take as input, and what does it give as output?", $settings);
                                echo "<br/>";
                                echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>";
                                echo "<input type='hidden' name='id_expr' value='" . $match_entry->obj_expression->id . "'/>";
                                echo "<input type='hidden' name='idx_key' value='-1.notesection'/>";
                                echo "<textarea rows='1' name='str_txt' style='background-color:" . rcolor() . ";width:75%;'/>";
                                $custom_entry = $match_entry->obj_expression->obj_match_customs;
                                if (isset($custom_entry["-1.notesection"])) {
                                    echo htmlspecialchars($custom_entry["-1.notesection"]->obj_txt->body);
                                }
                                echo "</textarea>";
                                echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                                echo "<a style='font-size:10px;padding-left:40px;' href='#filtering_toc'>";
                                echo "Go to table of contents";
                                echo "</a>";
                                echo "</form>\n";
                                echo "</div>";
                                echo "</a>";
                            }
                            // END IF (NOTESECTION)
                            echo "<form action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post' style='display:inline;'>";
                            echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>";
                            echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>";
                            echo "<input type='hidden' name='id_entry_type' value='output'/>";
                            echo "PROCESSING TYPE: <select name='id_entry_subtype'>";
                            echo "<option value=''></option>";
                            foreach ($STATIC['processing_types'] as $processing_key => $processing_value) {
                                $seltxt = "";
                                if ($processing_key == $match_entry->id_entry_subtype) {
                                    $seltxt = " selected";
                                }
                                echo "<option value='" . $processing_key . "'{$seltxt}>" . getTranslation($processing_value, $settings) . "</option>";
                            }
                            echo "</select>";
                            echo "<br/>";
                            echo "&nbsp;&nbsp;";
                            echo getTranslation("use", $settings);
                            echo " ";
                            echo "<textarea rows='1' name='str_expression' style='width:600px;background-color:" . rcolor() . ";display:inline;'>";
                            if (isset($match_entry->obj_me_settings['str_expression'])) {
                                echo $match_entry->obj_me_settings['str_expression']->obj_value->body;
                            }
                            echo "</textarea>";
                            echo "<ul style='padding-left:80px;'>";
                            echo "<div style='background-color:" . rcolor() . ";'>";
                            $fail_match_checked = false;
                            if (isset($match_entry->obj_me_settings['str_bool_fail_n_matches'])) {
                                if ($match_entry->obj_me_settings['str_bool_fail_n_matches']->value == "true") {
                                    $fail_match_checked = true;
                                }
                            }
                            $checked_html = "";
                            if ($fail_match_checked) {
                                $checked_html = " checked='checked'";
                            }
                            echo "<input type='checkbox' name='str_bool_fail_n_matches' value='true'{$checked_html}/>";
                            echo " ";
                            echo getTranslation("If # of Matches/Occurrences", $settings);
                            echo " ";
                            $selected = "";
                            echo "<select name='str_fail_match_operator' style='background-color:" . rcolor() . ";display:inline;'>";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "eq") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='eq'{$selected}>";
                            echo "=";
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "not") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='not'{$selected}>";
                            echo getTranslation("Not", $settings);
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gt") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='gt'{$selected}>";
                            echo "&gt;";
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lt") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='lt'{$selected}>";
                            echo "&lt;";
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lte") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='lte'{$selected}>";
                            echo "&lt;=";
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gte") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='gte'{$selected}>";
                            echo "&gt;=";
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "mod") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='mod'{$selected}>";
                            echo getTranslation("Mod by N = 0", $settings);
                            echo "</option>";
                            $selected = "";
                            if (isset($match_entry->obj_me_settings['str_fail_match_operator'])) {
                                if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "modnot0") {
                                    $selected = " selected='selected'";
                                }
                            }
                            echo "<option value='modnot0'{$selected}>";
                            echo getTranslation("Mod by N not 0", $settings);
                            echo "</option>";
                            echo "</select>";
                            echo " ";
                            echo "<input type='text' name='str_fail_n_matches' value='";
                            if (isset($match_entry->obj_me_settings['str_fail_n_matches'])) {
                                echo $match_entry->obj_me_settings['str_fail_n_matches']->obj_value->body;
                            } else {
                                echo "0";
                            }
                            echo "' style='background-color:" . rcolor() . ";display:inline;width:50px;'/>";
                            echo " ";
                            echo getTranslation("cause function to fail with status", $settings);
                            echo " ";
                            echo "<input type='text' name='str_fail_status' value='";
                            if (isset($match_entry->obj_me_settings['str_fail_status'])) {
                                echo $match_entry->obj_me_settings['str_fail_status']->obj_value->body;
                            } else {
                                echo "failed";
                            }
                            echo "' style='background-color:" . rcolor() . ";display:inline;'/>";
                            echo "</div>";
                            echo "<div style='background-color:" . rcolor() . ";'>";
                            $max_matches_checked = false;
                            if (isset($match_entry->obj_me_settings['str_bool_max_matches'])) {
                                if ($match_entry->obj_me_settings['str_bool_max_matches']->value == "true") {
                                    $max_matches_checked = true;
                                }
                            }
                            $checked_html = "";
                            if ($max_matches_checked) {
                                $checked_html = " checked='checked'";
                            }
                            echo "<input type='checkbox' name='str_bool_max_matches' value='true'{$checked_html}/>";
                            echo "Max # of Matches: ";
                            echo "<input type='text' name='str_max_match_count' value='";
                            if (isset($match_entry->obj_me_settings['str_max_match_count'])) {
                                echo $match_entry->obj_me_settings['str_max_match_count']->obj_value->body;
                            } else {
                                echo "0";
                            }
                            echo "' style='background-color:" . rcolor() . ";display:inline;'/>";
                            echo "</div>";
                            echo "</ul>";
                            echo "<br/>";
                            echo "<ul>";
                            echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                            echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>";
                            echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>";
                            echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>";
                            echo "</ul>";
                            echo "</form>";
                            echo "\n<ul>";
                            echo getTranslation("using", $settings);
                            echo " ";
                            if ($match_entry->id_entry_subtype == 'filter-regex') {
                                echo getTranslation("pattern", $settings);
                            }
                            if ($match_entry->id_entry_subtype == 'filter-split-string') {
                                echo getTranslation("split delimiter", $settings);
                            }
                            if ($match_entry->id_entry_subtype == 'filter-xpath') {
                                echo getTranslation("XPath", $settings);
                            }
                            if ($match_entry->id_entry_subtype == 'filter-split-regex') {
                                echo getTranslation("split regex", $settings);
                            }
                            echo ": <b>";
                            if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') {
                                echo "#";
                            }
                            if (isset($match_entry->obj_me_settings['str_expression'])) {
                                echo htmlspecialchars($match_entry->obj_me_settings['str_expression']->obj_value->body);
                            }
                            if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') {
                                echo "#ism";
                                echo "<br/>";
                                echo "<ul >";
                                echo getTranslation("filter-regex tip", $settings);
                                echo "</ul>";
                            }
                            echo "</b></ul>\n";
                        }
                        // end if (edit interface)
                        $filtering_expression = "";
                        if (isset($match_entry->obj_me_settings['str_expression'])) {
                            $filtering_expression = $match_entry->obj_me_settings['str_expression']->obj_value->body;
                        }
                        $orig_filtering_expression = $filtering_expression;
                        $filtering_expression = replace_hf_parameters($filtering_expression, $q->obj_hf_parameters);
                        if ($mode_edit) {
                            if ($filtering_expression != $orig_filtering_expression) {
                                if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') {
                                    echo "#";
                                }
                                echo htmlspecialchars($filtering_expression);
                                if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-split-regex') {
                                    echo "#ism";
                                }
                            }
                            if ($match_entry->id_entry_subtype == 'filter-regex') {
                                echo "<br/>";
                            }
                        }
                        // XML MODE OUTPUT
                        if ($mode_xml) {
                            for ($in = 1; $in < $idt + 3; $in++) {
                                echo "\t";
                            }
                            echo "<hf>\n";
                            for ($in = 1; $in < $idt + 4; $in++) {
                                echo "\t";
                            }
                            echo "<expression>" . htmlspecialchars($filtering_expression) . "</expression>\n";
                        }
                        // end if
                        // PROCESSING SUBTYPE: FILTER REGEX
                        if ($match_entry->id_entry_subtype == 'filter-regex') {
                            // if regex
                            if (strlen($filtering_expression) > 0) {
                                preg_match_all("#" . $filtering_expression . "#ism", $this_value, $submatches, PREG_SET_ORDER);
                            } else {
                            }
                            if (strlen($filtering_expression) == 0) {
                                $submatches = array();
                            } else {
                                if ($filtering_expression == "(.*)") {
                                    $submatches = array(array($this_value));
                                } else {
                                    for ($i = 0; $i < count($submatches); $i++) {
                                        unset($submatches[$i][0]);
                                    }
                                }
                            }
                        }
                        // end if (is regex filtering)
                        // PROCESSING SUBTYPE: SPLIT STRING
                        if ($match_entry->id_entry_subtype == 'filter-split-string') {
                            $submatch_retval = array();
                            if (strlen($filtering_expression) > 0) {
                                // if split
                                $submatches = explode($filtering_expression, $this_value);
                                foreach ($submatches as $sm) {
                                    $submatch_retval[] = array($sm);
                                }
                                $submatches = $submatch_retval;
                            }
                        }
                        // PROCESSING SUBTYPE: STRING FORMATTER
                        if ($match_entry->id_entry_subtype == 'filter-string-formatter') {
                            // if split
                            //echo "SUBMATCHES:";
                            $submatches = sscanf($this_value, $filtering_expression);
                            $submatch_retval = array();
                            foreach ($submatches as $sm) {
                                $submatch_retval[] = array($sm);
                            }
                            $submatches = $submatch_retval;
                            //print_r($submatches);
                        }
                        // PROCESSING SUBTYPE: REGEX SPLIT
                        if ($match_entry->id_entry_subtype == 'filter-split-regex') {
                            // if split
                            if (strlen($filtering_expression) > 0) {
                                $submatches = preg_split("#" . $filtering_expression . "#ism", $this_value);
                                $submatch_retval = array();
                                foreach ($submatches as $sm) {
                                    $submatch_retval[] = array($sm);
                                }
                                $submatches = $submatch_retval;
                            } else {
                                $submatches = array();
                            }
                            // echo "<pre>";
                            // print_r($submatches);
                        }
                        // PROCESSING SUBTYPE: XPATH
                        if ($match_entry->id_entry_subtype == 'filter-xpath') {
                            try {
                                // if xpath
                                if (strlen($filtering_expression) > 0) {
                                    $xp_xml = new SimpleXMLElement($this_value);
                                    $submatches = $xp_xml->xpath($filtering_expression);
                                    for ($iii = 0; $iii < count($submatches); $iii++) {
                                        $submatches[$iii] = array(if_attribute_xpath_parse(innerxml($submatches[$iii]), $filtering_expression));
                                    }
                                }
                            } catch (Exception $e) {
                            }
                        }
                        // XML MODE OUTPUT
                        if ($mode_xml) {
                            for ($in = 1; $in < $idt + 4; $in++) {
                                echo "\t";
                            }
                            echo "<results>\n";
                        }
                        // end if
                        if ($mode_edit) {
                            echo "<ul style='margin-left:5px;'>";
                            echo "<ul style='margin-left:5px;'>";
                        }
                        $match_counter = 0;
                        // IF A NON-BLANK FILTERING EXPRESSION...
                        if (strlen($filtering_expression) > 0) {
                            $chead = "";
                            $chead_after_replace = "";
                            //echo "<pre>";
                            //print_r($match_entry->obj_expression);
                            if (isset($match_entry->obj_expression->obj_match_customs)) {
                                $custom_head = $match_entry->obj_expression->obj_match_customs;
                                if (isset($custom_head['-1.header'])) {
                                    $chead = $custom_head['-1.header']->obj_txt->body;
                                    $chead_after_replace = replace_hf_parameters($chead, $q->obj_hf_parameters);
                                }
                            }
                            if ($mode_cxml && !$mode_jidonly) {
                                if (!$bool_buffer_output_merge) {
                                    echo $chead_after_replace;
                                }
                            }
                            $retval['buffer'] = $retval['buffer'] . $chead_after_replace;
                            // CUSTOM FOOTER GUI EDIT FIELD
                            if ($mode_edit) {
                                echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Header", $settings) . "(" . substr($match_entry->obj_expression->id, 0, min(strlen($match_entry->obj_expression->id), 5)) . ",-1): ";
                                echo "<input type='hidden' name='id_expr' value='" . $match_entry->obj_me_settings['str_expression']->obj_value->id . "'/>";
                                echo "<input type='hidden' name='idx_key' value='-1.header'/>";
                                echo "<textarea rows='1' name='str_txt' style='width:500px;'/>";
                                echo str_replace("<", "&lt;", $chead);
                                echo "</textarea>";
                                echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                                echo "</form>\n";
                            }
                            if ($chead != $chead_after_replace) {
                                echo "\tAfter Replacement: " . htmlspecialchars($chead_after_replace) . "\n";
                            }
                            if (isset($match_entry->obj_me_settings['str_bool_max_matches']) && isset($match_entry->obj_me_settings['str_max_match_count'])) {
                                if ($match_entry->obj_me_settings['str_bool_max_matches']->value != "false") {
                                    if (strlen($match_entry->obj_me_settings['str_max_match_count']->value) > 0) {
                                        if (count($submatches) > intval($match_entry->obj_me_settings['str_max_match_count']->value) && intval($match_entry->obj_me_settings['str_max_match_count']->value) > 0) {
                                            $submatches = array_slice($submatches, 0, intval($match_entry->obj_me_settings['str_max_match_count']->value));
                                        }
                                    }
                                }
                            }
                            $function_fail = false;
                            // FAIL CONDITION CHECK
                            if (true) {
                                if (isset($match_entry->obj_me_settings['str_bool_fail_n_matches']) && isset($match_entry->obj_me_settings['str_fail_match_operator']) && isset($match_entry->obj_me_settings['str_fail_n_matches']) && isset($match_entry->obj_me_settings['str_fail_status'])) {
                                    if ($match_entry->obj_me_settings['str_bool_fail_n_matches']->value != "false") {
                                        if (strlen($match_entry->obj_me_settings['str_fail_match_operator']->value) > 0 && strlen($match_entry->obj_me_settings['str_fail_n_matches']->value) > 0 && strlen($match_entry->obj_me_settings['str_fail_status']->value) > 0) {
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "eq") {
                                                if (count($submatches) == intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "not") {
                                                if (count($submatches) != intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lt") {
                                                if (count($submatches) < intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gt") {
                                                if (count($submatches) > intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "gte") {
                                                if (count($submatches) >= intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "lte") {
                                                if (count($submatches) <= intval($match_entry->obj_me_settings['str_fail_n_matches']->value)) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "mod") {
                                                if (count($submatches) % intval($match_entry->obj_me_settings['str_fail_n_matches']->value) == 0) {
                                                    $function_fail = true;
                                                }
                                            }
                                            if ($match_entry->obj_me_settings['str_fail_match_operator']->value == "modnot0") {
                                                if (count($submatches) % intval($match_entry->obj_me_settings['str_fail_n_matches']->value) != 0) {
                                                    $function_fail = true;
                                                }
                                            }
                                        }
                                        // end if (fail fields not blank)
                                    }
                                }
                            }
                            if ($function_fail) {
                                if (($mode_xml || $mode_cxml) && $mode_output) {
                                    $new_job_flag = new job_flag();
                                    $props = array();
                                    $props['id_job'] = $_GET['JID'];
                                    $props['flag'] = "failed";
                                    $props['status'] = $match_entry->obj_me_settings['str_fail_status']->value;
                                    //."-count:".count($submatches);
                                    $new_job_flag->create($props);
                                    sleep(2);
                                    return;
                                }
                                if ($mode_edit) {
                                    echo "<ul>";
                                    echo getTranslation("If this function were run, it would fail because there are", $settings) . " " . count($submatches) . " " . getTranslation("matches.", $settings);
                                    echo "</ul>";
                                }
                            }
                            if ($match_entry->id_entry_subtype == 'filter-regex' || $match_entry->id_entry_subtype == 'filter-xpath') {
                                foreach ($submatches as $sm) {
                                    $match_counter = $match_counter + 1;
                                    $bo = expression_results_and_interface($match_entry->obj_expression, $match_counter, $sm, $idt + 4, $bool_buffer_children);
                                    if ($bool_buffer_children) {
                                        $retval['buffer'] = $retval['buffer'] . $bo['buffer'];
                                    }
                                    if ($match_counter == 20 && $mode_short) {
                                        if ($mode_edit) {
                                            echo "<span style='background-color:red;color:white'>Only a few values have been printed out on this edit page (limit 100)</span><br/>\n";
                                        }
                                        break;
                                    }
                                }
                                // foreach (submatch)
                            } else {
                                if ($match_entry->id_entry_subtype == 'filter-split-string' || $match_entry->id_entry_subtype == 'filter-split-regex' || $match_entry->id_entry_subtype == 'filter-string-formatter') {
                                    foreach ($submatches as $sm) {
                                        $bo = expression_results_and_interface($match_entry->obj_expression, 1, $sm, $idt + 4, $bool_buffer_children);
                                        if ($bool_buffer_children) {
                                            $retval['buffer'] = $retval['buffer'] . $bo['buffer'];
                                        }
                                    }
                                    // end for
                                }
                            }
                            // end if (split)
                            // CUSTOM FOOTER GUI EDIT FIELD
                            $cfoot = "";
                            $cfoot_after_replace = "";
                            if (isset($match_entry->obj_expression->obj_match_customs)) {
                                $custom_foot = $match_entry->obj_expression->obj_match_customs;
                                if (isset($custom_foot['-1.footer'])) {
                                    $cfoot = $custom_foot['-1.footer']->obj_txt->body;
                                    $cfoot_after_replace = replace_hf_parameters($cfoot, $q->obj_hf_parameters);
                                }
                            }
                            if ($mode_cxml && !$mode_jidonly) {
                                if (!$bool_buffer_output_merge) {
                                    echo $cfoot_after_replace;
                                }
                            }
                            $retval['buffer'] = $retval['buffer'] . $cfoot_after_replace;
                            if ($mode_edit) {
                                echo "<br/>";
                                echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Footer", $settings) . "(" . substr($match_entry->obj_expression->id, 0, min(strlen($match_entry->obj_expression->id), 5)) . ",-1): ";
                                echo "<input type='hidden' name='id_expr' value='" . $match_entry->obj_me_settings['str_expression']->obj_value->id . "'/>";
                                echo "<input type='hidden' name='idx_key' value='-1.footer'/>";
                                echo "<textarea rows='1' name='str_txt' style='width:500px;'/>";
                                echo str_replace("<", "&lt;", $cfoot);
                                echo "</textarea>";
                                echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                                echo "</form>\n";
                            }
                            if ($cfoot != $cfoot_after_replace) {
                                echo "\tAfter Replacement: " . htmlspecialchars($cfoot_after_replace) . "\n";
                            }
                        }
                        // end if (not blank processing expression)
                        if ($mode_edit) {
                            echo "</ul>";
                            echo "</ul>";
                        }
                        // A EXPRESSION WHICH HAS FAILED (NO MATCHES)
                        // PRINT OUT VAL
                        if ($mode_cxml) {
                            if ($match_counter == 0) {
                                //echo htmlspecialchars($this_value);
                            }
                        }
                        // XML MODE OUTPUT
                        if ($mode_xml) {
                            // A EXPRESSION WHICH HAS FAILED (NO MATCHES)
                            // PRINT OUT VAL
                            /*if ($match_counter==0) // there were no more submatches! print out val
                            		{
                            			for($in=1;$in<$idt+2+3;$in++) echo "\t";
                            			echo "<value>";
                            			echo "<offset>".$this_idx."</offset><string>".mb_convert_encoding(htmlspecialchars($this_value),"UTF-8")."</string>";
                            			echo "</value>\n";
                            		}*/
                            for ($in = 1; $in < $idt + 4; $in++) {
                                echo "\t";
                            }
                            echo "</results>\n";
                            for ($in = 1; $in < $idt + 3; $in++) {
                                echo "\t";
                            }
                            echo "</hf>\n";
                        }
                        // end if (xml)
                        if ($mode_edit) {
                            //echo "</ul>";
                        }
                        if ($mode_edit) {
                            echo "</ul>";
                        }
                    } else {
                        if ($match_entry->id_entry_type == 'operation') {
                            $pp = '';
                            $ap = '';
                            if ($match_entry->id_entry_subtype == 'prepend-and-append' || $match_entry->id_entry_subtype == 'prepend-and-append-file') {
                                if (isset($match_entry->obj_me_settings['prepend'])) {
                                    $pp = $match_entry->obj_me_settings['prepend']->obj_value->body;
                                }
                                if (isset($match_entry->obj_me_settings['prepend'])) {
                                    $ap = $match_entry->obj_me_settings['append']->obj_value->body;
                                }
                            }
                            // end if (prepend & append)
                            $find = "";
                            $replace_with = "";
                            if ($match_entry->id_entry_subtype == 'replace' || $match_entry->id_entry_subtype == 'replace-using-regex') {
                                if (isset($match_entry->obj_me_settings['find'])) {
                                    $find = $match_entry->obj_me_settings['find']->obj_value->body;
                                }
                                if (isset($match_entry->obj_me_settings['replace_with'])) {
                                    $replace_with = $match_entry->obj_me_settings['replace_with']->obj_value->body;
                                }
                            }
                            // end if (replace)
                            if ($mode_edit) {
                                echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post'>";
                                echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>";
                                echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>";
                                echo "<input type='hidden' name='id_entry_type' value='" . $match_entry->id_entry_type . "'/>";
                                echo getTranslation("OPERATION", $settings);
                                echo ": <select name='id_entry_subtype'>";
                                echo "<option value=''></option>";
                                foreach ($STATIC['operation_types'] as $operation_type_key => $operation_type_value) {
                                    $seltxt = "";
                                    if ($operation_type_key == $match_entry->id_entry_subtype) {
                                        $seltxt = " selected";
                                    }
                                    echo "<option value='" . $operation_type_key . "'" . $seltxt . ">" . getTranslation($operation_type_value, $settings) . "</option>";
                                }
                                echo "</select>";
                                echo ":<br/>";
                                echo "<ul>";
                                if ($match_entry->id_entry_subtype == 'prepend-and-append' || $match_entry->id_entry_subtype == 'prepend-and-append-file') {
                                    echo getTranslation("Prepend", $settings);
                                    echo ": <textarea rows='1' name='prepend' style='background-color:" . rcolor() . ";width:200px;display:inline;'>" . htmlspecialchars($pp) . "</textarea>;";
                                    echo getTranslation("Append", $settings);
                                    echo ": <textarea rows='1' name='append' style='background-color:" . rcolor() . ";width:200px;display:inline;'>" . htmlspecialchars($ap) . "</textarea>;";
                                }
                                // end if (prepend)
                                if ($match_entry->id_entry_subtype == 'replace' || $match_entry->id_entry_subtype == 'replace-using-regex') {
                                    echo getTranslation("Replace", $settings);
                                    echo ": <textarea style='background-color:" . rcolor() . ";display:inline;' rows='1' name='find'>" . htmlspecialchars($find) . "</textarea>; ";
                                    echo getTranslation("With", $settings);
                                    echo ": <textarea style='background-color:" . rcolor() . ";display:inline;' rows='1' name='replace_with'>" . htmlspecialchars($replace_with) . "</textarea>;";
                                }
                                // end if (replace)
                                echo "<br/>";
                                echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                                echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>";
                                echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>";
                                echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>";
                                echo "</form>";
                                echo "</ul>";
                                echo "";
                            }
                            // end if (edit mode);
                            if ($match_entry->id_entry_subtype == 'read-non-html') {
                                $inside_counter = 0;
                                $finalval = "";
                                for ($i = 0; $i < strlen($this_value); $i++) {
                                    $this_letter = substr($this_value, $i, 1);
                                    if ($this_letter == "<") {
                                        $inside_counter = $inside_counter + 1;
                                        continue;
                                    }
                                    if ($this_letter == ">") {
                                        $inside_counter = $inside_counter - 1;
                                        continue;
                                    }
                                    if ($inside_counter == 0) {
                                        $finalval = $finalval . $this_letter;
                                    }
                                }
                                // end for
                                $this_value = $finalval;
                                // non-html
                            } else {
                                if ($match_entry->id_entry_subtype == 'urlencode') {
                                    $this_value = urlencode($this_value);
                                } else {
                                    if ($match_entry->id_entry_subtype == 'double-urlencode') {
                                        $this_value = urlencode($this_value);
                                        $this_value = urlencode($this_value);
                                    } else {
                                        if ($match_entry->id_entry_subtype == 'treat-as-integer') {
                                            $this_value = intval($this_value);
                                        } else {
                                            if ($match_entry->id_entry_subtype == 'treat-as-float') {
                                                $this_value = floatval($this_value);
                                            } else {
                                                if ($match_entry->id_entry_subtype == 'urldecode') {
                                                    $this_value = urldecode($this_value);
                                                    $this_value = str_replace("&amp;", "&", $this_value);
                                                } else {
                                                    if ($match_entry->id_entry_subtype == 'double-urldecode') {
                                                        $this_value = urldecode($this_value);
                                                        $this_value = str_replace("&amp;", "&", $this_value);
                                                        $this_value = urldecode($this_value);
                                                        $this_value = str_replace("&amp;", "&", $this_value);
                                                    } else {
                                                        if ($match_entry->id_entry_subtype == 'prepend-and-append') {
                                                            $pp_new = replace_hf_parameters($pp, $q->obj_hf_parameters);
                                                            $pp_new = replace_dictionary($pp, $adjacent_dictionary);
                                                            $ap_new = replace_hf_parameters($ap, $q->obj_hf_parameters);
                                                            $ap_new = replace_dictionary($ap, $adjacent_dictionary);
                                                            if ($pp != $pp_new) {
                                                                if ($mode_edit) {
                                                                    echo "<br/><ul style='vertical-align:top;'>VALUE BEFORE SUBSTITUTION: <textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='1' cols='100'>" . trim(htmlspecialchars($pp)) . "</textarea></ul>";
                                                                }
                                                            }
                                                            if ($ap != $ap_new) {
                                                                if ($mode_edit) {
                                                                    echo "<br/><ul style='vertical-align:top;'>VALUE BEFORE SUBSTITUTION: <textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='1' cols='100'>" . trim(htmlspecialchars($ap)) . "</textarea></ul>";
                                                                }
                                                            }
                                                            $ap = $ap_new;
                                                            $pp = $pp_new;
                                                            $this_value = $pp . $this_value . $ap;
                                                            // prepend & append
                                                        } else {
                                                            if ($match_entry->id_entry_subtype == 'replace') {
                                                                // replace
                                                                $this_value = str_replace($find, $replace_with, $this_value);
                                                            } else {
                                                                if ($match_entry->id_entry_subtype == 'erase') {
                                                                    $this_value = "";
                                                                    // erase
                                                                } else {
                                                                    if ($match_entry->id_entry_subtype == 'prepend-and-append-file') {
                                                                        // prepend & append file contents
                                                                        $ppf = file_get_contents($pp);
                                                                        $apf = file_get_contents($ap);
                                                                        $this_value = $ppf . $this_value . $apf;
                                                                        // prepend & append
                                                                    } else {
                                                                        if ($match_entry->id_entry_subtype == 'replace-using-regex') {
                                                                            // replace using regular expression
                                                                            $this_value = preg_replace('#' . $find . '#', $replace_with, $this_value);
                                                                        } else {
                                                                            if ($match_entry->id_entry_subtype == 'html-entities') {
                                                                                // htmlentities
                                                                                $this_value = htmlentities($this_value, ENT_QUOTES);
                                                                            } else {
                                                                                if ($match_entry->id_entry_subtype == 'trim') {
                                                                                    // trim
                                                                                    $this_value = trim($this_value);
                                                                                } else {
                                                                                    if ($match_entry->id_entry_subtype == 'keywdreppass') {
                                                                                        //keyword prelacement pass
                                                                                        $value_after_replacement = replace_hf_parameters($this_value, $q->obj_hf_parameters);
                                                                                        $value_after_replacement2 = replace_dictionary($value_after_replacement, $adjacent_dictionary);
                                                                                        $this_value = $value_after_replacement2;
                                                                                    } else {
                                                                                        if ($match_entry->id_entry_subtype == 'base64-decode') {
                                                                                            //base64_decode
                                                                                            $this_value = base64_decode($this_value);
                                                                                        } else {
                                                                                            if ($match_entry->id_entry_subtype == 'base64-encode') {
                                                                                                //base64_encode
                                                                                                $this_value = base64_encode($this_value);
                                                                                            } else {
                                                                                                if ($match_entry->id_entry_subtype == 'html-entity-decode') {
                                                                                                    $this_value = html_entity_decode($this_value, ENT_QUOTES);
                                                                                                } else {
                                                                                                    if ($match_entry->id_entry_subtype == 'htmlspecialchars') {
                                                                                                        // htmlspecialchars
                                                                                                        $this_value = htmlspecialchars($this_value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_XML1, 'UTF-8');
                                                                                                    } else {
                                                                                                        if ($match_entry->id_entry_subtype == 'htmlspecialchars-decode') {
                                                                                                            // htmlspecialchars_decode
                                                                                                            $this_value = htmlspecialchars_decode($this_value, ENT_QUOTES | ENT_XML1, 'UTF-8');
                                                                                                        } else {
                                                                                                            if ($match_entry->id_entry_subtype == 'strtoupper') {
                                                                                                                // strtoupper
                                                                                                                $this_value = strtoupper($this_value);
                                                                                                            } else {
                                                                                                                if ($match_entry->id_entry_subtype == 'strtolower') {
                                                                                                                    // strtolower
                                                                                                                    $this_value = strtolower($this_value);
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if ($mode_edit) {
                                echo "<br/><ul style='vertical-align:top;'>";
                                echo getTranslation("VALUE AFTER OPERATION", $settings);
                                echo ": <textarea style=\"margin-left:0px;font-family:'Courier New';\" rows='1' cols='100'>" . trim(htmlspecialchars($this_value)) . "</textarea></ul><br/><br/>";
                            }
                        } else {
                            if ($match_entry->id_entry_type == 'action') {
                                // todo need to add xml/cxml mode codes
                                if ($mode_edit) {
                                    echo "<form action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post' style='display:inline;'>";
                                    echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>";
                                    echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>";
                                    echo "<input type='hidden' name='id_entry_type' value='output'/>";
                                    echo getTranslation("ACTION", $settings);
                                    echo ": <select name='id_entry_subtype'>";
                                    echo "<option value=''></option>";
                                    foreach ($STATIC['action_types'] as $action_key => $action_value) {
                                        $seltxt = "";
                                        if ($action_key == $match_entry->id_entry_subtype) {
                                            $seltxt = " selected";
                                        }
                                        if ($action_key != "php-code" || $_SERVER['HTTP_HOST'] != $demo_domain) {
                                            echo "<option value='" . $action_key . "'{$seltxt}>" . getTranslation($action_value, $settings) . "</option>";
                                        }
                                    }
                                    echo "</select>";
                                }
                                if ($match_entry->id_entry_subtype == 'his-hf') {
                                    $his_url = "";
                                    if (isset($match_entry->obj_me_settings['str_his'])) {
                                        $his_url = $match_entry->obj_me_settings['str_his']->obj_value->body;
                                    }
                                    $his_url_after_hfp_replacement = replace_hf_parameters($his_url, $q->obj_hf_parameters);
                                    $his_url_after_dict_replace = replace_dictionary($his_url_after_hfp_replacement, $adjacent_dictionary);
                                    if ($mode_edit) {
                                        echo ": ";
                                        echo "<br/>";
                                        echo "<ul>";
                                        echo "HIS ";
                                        echo getTranslation("URL", $settings);
                                        echo ":<br/><textarea rows='1' name='str_his' style='width:500px;'>";
                                        echo htmlspecialchars($his_url);
                                        echo "</textarea>";
                                        echo "<br/>";
                                        if ($his_url != $his_url_after_dict_replace) {
                                            echo "<b>";
                                            echo getTranslation("After Function Parameter/Adjacent Dictionary Value Replacement", $settings);
                                            echo ":</b>";
                                            echo "<ul>";
                                            echo "<textarea style='background-color:#ddd;width:500px;' readonly='readonly'>";
                                            echo htmlspecialchars($his_url_after_dict_replace);
                                            echo "</textarea>";
                                            echo "</ul>";
                                        }
                                        echo getTranslation("Shortcut to Settings page", $settings);
                                        echo ": ";
                                        echo "<ul>";
                                        echo "<a href='?q={$qn}&v=settings' target='_new'>";
                                        echo getTranslation("Click Here", $settings);
                                        echo " ";
                                        echo "<img src='images/settings.png' border='0' width='20'/></a>";
                                        echo "</ul>";
                                        echo getTranslation("Example", $settings);
                                        echo "<ul>";
                                        echo "{$this_server_url}/<font color='red'>?</font>s=weather<font color='red'>&</font>uid=YOUR-UID<font color='red'>&</font>secret=YOUR-SECRET<font color='red'>&</font>cxml<font color='red'>&</font>remote<font color='red'>&</font>location=Atlanta%2C+GA";
                                        echo "</ul>";
                                        echo getTranslation("Example", $settings);
                                        echo "<ul>";
                                        echo "{$this_server_url}/<font color='red'>?</font>q=4f6cc17061477b0348630219f32985420855235a<font color='red'>&</font>uid=YOUR-UID<font color='red'>&</font>secret=YOUR-SECRET<font color='red'>&</font>cxml<font color='red'>&</font>remote<font color='red'>&</font>location=Atlanta%2C+GA";
                                        echo "</ul>";
                                        echo "<br/>";
                                        echo "<br/>";
                                        echo getTranslation("Suggested Local HIS Functions based on current parameters and dictionary values", $settings);
                                        echo ":";
                                        echo "<ul>";
                                        $suggested_hfs = array();
                                        foreach ($adjacent_dictionary as $adk => $adv) {
                                            if (is_standard_ad($adk)) {
                                                continue;
                                            }
                                            $hfp_hf = new hfp_hf();
                                            $hfp_hfs = $hfp_hf->get_from_hashrange($u->id_user . "@" . $adk);
                                            foreach ($hfp_hfs as $each_hfp_hf) {
                                                if ($each_hfp_hf['id_hf'] != "undefined") {
                                                    $suggested_id_hf_ary = explode("@", $each_hfp_hf['id_hf']);
                                                    $suggested_id_hf = $suggested_id_hf_ary[0];
                                                    if ($suggested_id_hf == $qn) {
                                                        continue;
                                                    }
                                                    $suggested_hf = new hf_id_user();
                                                    $suggested_hf->get_from_hashrange($u->id_user, $suggested_id_hf);
                                                    if ($suggested_hf->id != "undefined") {
                                                        $suggested_hfs[] = array('hf' => $suggested_hf, 'param' => $each_hfp_hf);
                                                        //echo $suggested_hf->name;
                                                        //echo "<br/>";
                                                    }
                                                }
                                            }
                                        }
                                        foreach ($q->obj_hf_parameters as $hf_param) {
                                            if (isset($hf_param->obj_overridden) && $hf_param->obj_overridden) {
                                                continue;
                                            }
                                            if (isset($hf_param->obj_inherited) && $hf_param->obj_inherited) {
                                                //continue;
                                            }
                                            $hfp_hf = new hfp_hf();
                                            $hfp_hfs = $hfp_hf->get_from_hashrange($u->id_user . "@" . $hf_param->keyword);
                                            foreach ($hfp_hfs as $each_hfp_hf) {
                                                if ($each_hfp_hf['id_hf'] != "undefined") {
                                                    $suggested_id_hf_ary = explode("@", $each_hfp_hf['id_hf']);
                                                    $suggested_id_hf = $suggested_id_hf_ary[0];
                                                    if ($suggested_id_hf == $qn) {
                                                        continue;
                                                    }
                                                    $suggested_hf = new hf_id_user();
                                                    $suggested_hf->get_from_hashrange($u->id_user, $suggested_id_hf);
                                                    if ($suggested_hf->id != "undefined") {
                                                        $suggested_hfs[] = array('hf' => $suggested_hf, 'param' => $each_hfp_hf);
                                                        //$suggested_hfs[]=$suggested_hf;
                                                        //echo $suggested_hf->name;
                                                        //echo "<br/>";
                                                    }
                                                }
                                            }
                                        }
                                        $printed_suggestions = array();
                                        foreach ($suggested_hfs as $suggested_hf) {
                                            $suggested_hf_function = $suggested_hf['hf'];
                                            $suggested_hf_param = $suggested_hf['param'];
                                            //if (in_array($suggested_hf->id,$printed_suggestions)) continue;
                                            echo "<a href='?q=" . $suggested_hf_function->id . "&v=overview' target='_new'>";
                                            echo $suggested_hf_function->name;
                                            echo "</a>";
                                            echo " ";
                                            echo getTranslation("uses", $settings);
                                            echo " ";
                                            echo "<font color='red'>";
                                            $full_hfp_split = explode("@", $suggested_hf_param['parameter_name']);
                                            $full_hfp = $full_hfp_split[1];
                                            echo htmlspecialchars($full_hfp);
                                            echo "</font>";
                                            echo " ";
                                            echo getTranslation("as an input", $settings);
                                            echo " ";
                                            echo "<input onClick='this.form.str_his.value=\"[THIS_HIS_WEB_INTERFACE_HOME]/?q=" . urlencode($suggested_hf_function->id) . "&cxml&remote&uid=ENTER-YOUR-UID&secret=ENTER-YOUR-SECRET\";' type='button' value='";
                                            echo getTranslation("Use", $settings);
                                            echo "'/>";
                                            echo " ";
                                            echo "<input onClick='this.form.str_his.value=\"[THIS_HIS_WEB_INTERFACE_HOME]/?s=" . urlencode($suggested_hf_function->name) . "&cxml&remote&uid=ENTER-YOUR-UID&secret=ENTER-YOUR-SECRET\";' type='button' value='";
                                            echo getTranslation("Use by Name", $settings);
                                            echo "'/>";
                                            echo "<br/>";
                                            $printed_suggestions[] = $suggested_hf_function->id;
                                        }
                                        echo "</ul>";
                                        echo "<br/>";
                                        echo "<br/>";
                                        echo "</ul>";
                                    }
                                    // end if (mode edit)
                                    if ($his_url != $his_url_after_dict_replace) {
                                        $his_url = $his_url_after_dict_replace;
                                    }
                                    if ($mode_xml || $mode_cxml || $mode_jidonly) {
                                        if (strlen($his_url) > 0) {
                                            // set his action flag (not nec., the server can detect when placeholders exist for its job id)
                                            // choose placeholder hash to insert into output file for now
                                            // generate special postback url that will fulfill placeholder in the future, and replace the hash value
                                            //     in this file's temporary output
                                            // submit job to gather output
                                            // set this job's status equal to "paused" when done, instead of "completed"
                                            //    doable without changing code here
                                            // jobs getting executed & updating the placeholder hashes with real his hf output
                                            // database table mah_placeholders
                                            //     id
                                            //     id_job         (this job)
                                            //     str_placeholder (generated hash)
                                            //     id_child_job    (job submitted to gather results to replace this job's temporary hash value printed
                                            // postback url's activities will include something to fulfill the placeholder (not necessary)
                                            //     and also run a check to see if all placeholders for this job have been completed, and, if so,
                                            //     run all value replacements and overwrite an updated copy of this job's temporary output
                                            //     file to the file storage location
                                            $placeholder_hash = sha1($this_value . microtime() . rand(1, 20));
                                            if (!$mode_jidonly) {
                                                echo $placeholder_hash;
                                            }
                                            $GLOBALS['HIS_URLS_TO_VISIT' . $GLOBALS['VISITOR']][$placeholder_hash] = $his_url . "&jidonly&uid=" . urlencode($_GET['uid']) . "&secret=" . urlencode($_GET['secret']);
                                            // $should add &remote also?
                                            $this_value = "";
                                        }
                                        // end if (hisurl not blank)
                                    }
                                    // end if (xml or cxml)
                                }
                                // end if (his + postback)
                                if ($match_entry->id_entry_subtype == 'cur-as-key' || $match_entry->id_entry_subtype == 'cur-as-val' || $match_entry->id_entry_subtype == 'key-and-val' || $match_entry->id_entry_subtype == 'clear-adj') {
                                    // use current value as adjacent dictionary key2/value3
                                    $readonly_key = "";
                                    $readonly_value = "";
                                    if ($match_entry->id_entry_subtype == 'cur-as-key') {
                                        $readonly_key = " readonly='readonly' style='background-color:#ddd;'";
                                    } else {
                                        if ($match_entry->id_entry_subtype == 'cur-as-val') {
                                            $readonly_value = " readonly='readonly' style='background-color:#ddd;'";
                                        }
                                    }
                                    $dict_key = "";
                                    $dict_value = "";
                                    if ($match_entry->id_entry_subtype == 'cur-as-key' || $match_entry->id_entry_subtype == 'key-and-val') {
                                        if (isset($match_entry->obj_me_settings['str_value'])) {
                                            if ($match_entry->obj_me_settings['str_value']) {
                                                $dict_value = $match_entry->obj_me_settings['str_value']->obj_value->body;
                                            }
                                        }
                                    }
                                    if ($match_entry->id_entry_subtype == 'cur-as-val' || $match_entry->id_entry_subtype == 'key-and-val') {
                                        if (isset($match_entry->obj_me_settings['str_key'])) {
                                            if ($match_entry->obj_me_settings['str_key']) {
                                                $dict_key = $match_entry->obj_me_settings['str_key']->obj_value->body;
                                            }
                                        }
                                    }
                                    if ($match_entry->id_entry_subtype == 'cur-as-key') {
                                        // use current value as adjacent dictionary key
                                        $dict_key = $this_value;
                                    } else {
                                        if ($match_entry->id_entry_subtype == 'cur-as-val') {
                                            // use current value as adjacent dictionary value
                                            $dict_value = $this_value;
                                        }
                                    }
                                    if ($match_entry->id_entry_subtype != 'clear-adj') {
                                        if (strlen($dict_key) == 0 && $match_entry->id_entry_subtype != 'clear-adj') {
                                            $dict_key = "[test_key]";
                                        }
                                        if ($mode_edit && $match_entry->id_entry_subtype != 'clear-adj') {
                                            echo ":<br/>";
                                            echo "<ul>";
                                            $field_name = "name='str_key'";
                                            if ($match_entry->id_entry_subtype == 'cur-as-key') {
                                                $field_name = "";
                                            }
                                            echo "<textarea {$field_name}{$readonly_key}>";
                                        }
                                        $dict_key_after_hfp_replacement = replace_hf_parameters($dict_key, $q->obj_hf_parameters);
                                        if ($mode_edit) {
                                            echo htmlspecialchars($dict_key);
                                            echo "</textarea>";
                                            $field_name = "name='str_value'";
                                            if ($match_entry->id_entry_subtype == 'cur-as-val') {
                                                $field_name = "";
                                            }
                                            echo " <font style='font-size:70px;'>=</font> <textarea {$field_name}{$readonly_value}>";
                                        }
                                        $dict_value_after_hfp_replacement = replace_hf_parameters($dict_value, $q->obj_hf_parameters);
                                        if ($mode_edit) {
                                            echo htmlspecialchars($dict_value);
                                            echo "</textarea><br/>";
                                        }
                                        if ($mode_edit && $match_entry->id_entry_subtype != 'clear-adj') {
                                            echo "</ul>";
                                        }
                                        // show a post-hfparameter'd version
                                        if (count($q->obj_hf_parameters) > 0 && ($dict_value != $dict_value_after_hfp_replacement || $dict_key != $dict_key_after_hfp_replacement)) {
                                            if ($mode_edit) {
                                                echo "<b>After Function Parameter Value Replacement:</b>";
                                                echo "<ul>";
                                                echo "<textarea style='background-color:#ddd;' readonly='readonly'>";
                                                echo $dict_key_after_hfp_replacement;
                                            }
                                            $dict_key = $dict_key_after_hfp_replacement;
                                            if ($mode_edit) {
                                                echo "</textarea>";
                                                echo " <font style='font-size:70px;'>=</font> ";
                                                echo "<textarea style='background-color:#ddd;' readonly='readonly'>";
                                                echo $dict_value_after_hfp_replacement;
                                            }
                                            $dict_value = $dict_value_after_hfp_replacement;
                                            if ($mode_edit) {
                                                echo "</textarea><br/>";
                                                echo "</ul>";
                                            }
                                        }
                                        // do a AVK replace ALSO & show
                                        $adjacent_dictionary_without_this_entry = $adjacent_dictionary;
                                        if (isset($adjacent_dictionary_without_this_entry[$dict_key])) {
                                            unset($adjacent_dictionary_without_this_entry[$dict_key]);
                                        }
                                        $dict_key_after_dict_replace = replace_dictionary($dict_key, $adjacent_dictionary_without_this_entry);
                                        $dict_value_after_dict_replace = replace_dictionary($dict_value, $adjacent_dictionary_without_this_entry);
                                        if (count($adjacent_dictionary) > 0 && ($dict_key != $dict_key_after_dict_replace || $dict_value != $dict_value_after_dict_replace)) {
                                            if ($mode_edit) {
                                                echo "<b>After Adjacent Dictionary Value Replacement:</b>";
                                                echo "<ul>";
                                                echo "<textarea style='background-color:#ddd;' readonly='readonly'>";
                                                echo $dict_key_after_dict_replace;
                                            }
                                            $dict_key = $dict_key_after_dict_replace;
                                            if ($mode_edit) {
                                                echo "</textarea>";
                                                echo " <font style='font-size:70px;'>=</font> ";
                                                echo "<textarea style='background-color:#ddd;' readonly='readonly'>";
                                                echo $dict_value_after_dict_replace;
                                            }
                                            $dict_value = $dict_value_after_dict_replace;
                                            if ($mode_edit) {
                                                echo "</textarea><br/>";
                                                echo "</ul>";
                                            }
                                        }
                                        if (strlen($dict_key) > 0) {
                                            if (isset($adjacent_dictionary[$dict_key])) {
                                                unset($adjacent_dictionary[$dict_key]);
                                            }
                                            $adjacent_dictionary[$dict_key] = $dict_value;
                                        }
                                    }
                                    // END IF (NOT CLEAR ADJACENT DICTIONARY MATCHENTRY SUBTYPE)
                                    if ($match_entry->id_entry_subtype == 'clear-adj') {
                                        foreach ($adjacent_dictionary as $ak => $av) {
                                            if (!in_array($ak, $system_adjacent_dictionary_keys)) {
                                                unset($adjacent_dictionary[$ak]);
                                            }
                                        }
                                        if ($mode_edit) {
                                            echo "<br/>";
                                            echo "<br/>";
                                            echo "<ul>";
                                            echo getTranslation("Adjacent dictionary has been cleared.", $settings);
                                            echo "<br/>";
                                            echo "<br/>";
                                        }
                                    }
                                    // END IF (CLEAR ADJACENT DICTIONARY)
                                    // show dictionary summary
                                    if (count($adjacent_dictionary) > 0 || $match_entry->id_entry_subtype == 'clear-adj') {
                                        if ($mode_edit) {
                                            echo "<ul>";
                                            echo "<b>";
                                            echo getTranslation("Current Parameter Values", $settings);
                                            echo ": ";
                                            echo "</b>";
                                            echo "<ul>";
                                            echo "<table border='1'>";
                                            foreach ($q->obj_hf_parameters as $hf_param) {
                                                if (isset($hf_param->obj_overridden) && $hf_param->obj_overridden) {
                                                    continue;
                                                }
                                                echo "<tr>";
                                                echo "<td>";
                                                echo htmlspecialchars($hf_param->keyword);
                                                echo "</td>";
                                                echo "<td style='font-size:10px'>";
                                                echo htmlspecialchars($hf_param->printable_value);
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                            echo "</table>";
                                            echo "<br/>";
                                            echo "</ul>";
                                            echo getTranslation("Current Adjacent Dictionary Contents", $settings);
                                            echo ": ";
                                            echo "<ul>";
                                            echo "<table border='1'>";
                                            foreach ($adjacent_dictionary as $adk => $adv) {
                                                if (is_standard_ad($adk)) {
                                                    continue;
                                                }
                                                echo "<tr>";
                                                echo "<td>";
                                                echo htmlspecialchars($adk);
                                                echo "</td>";
                                                echo "<td style='font-size:10px'>";
                                                echo htmlspecialchars($adv);
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                            if (count($adjacent_dictionary) == 0) {
                                                echo "<tr>";
                                                echo "<td>";
                                                echo getTranslation("Adjacent dictionary is empty.", $settings);
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                            echo "</table>";
                                            echo "</ul>";
                                            echo "<br/>";
                                            echo "</ul>";
                                        }
                                    }
                                    // END IF (SHOW ADJ DICT SUMMARY TABLE)
                                    if ($match_entry->id_entry_subtype == 'clear-adj') {
                                        if ($mode_edit) {
                                            echo "</ul>";
                                            echo "<br/>";
                                        }
                                    }
                                    if ($mode_edit) {
                                        //echo "</ul>";
                                    }
                                }
                                // end if (use current value as adjacent dictionary key)
                                if ($match_entry->id_entry_subtype == 'buffer') {
                                    // buffer action - collect previous childrens' value/filtering results and set filtered value to this
                                    //$this_value=$retval['buffer'];
                                    if ($bool_has_buffer) {
                                        $bool_has_buffer = false;
                                        $bool_buffer_children = true;
                                    }
                                    if ($bool_buffer_output_merge) {
                                    } else {
                                        $bool_has_filter = false;
                                    }
                                    if ($mode_edit) {
                                        echo "<ul><br/>";
                                        echo getTranslation("This Buffering action will prevent printing of preceeding sub-processings' data outputs unless a \"Print Value\" OUTPUT entry is made below.", $settings);
                                        echo "<br/>";
                                        echo "<br/>";
                                        echo getTranslation("Buffered Content added to Adjacent Dictionary Key [BUFFER]", $settings);
                                        echo ":<br/><textarea cols='100'>";
                                        if (isset($retval['buffer'])) {
                                            echo str_replace("<", "&lt;", $retval['buffer']);
                                            //echo htmlspecialchars($this_value);
                                        }
                                        echo "</textarea>";
                                        echo "<br/>";
                                    }
                                    if ($mode_cxml && !$mode_jidonly) {
                                        //echo $retval['buffer'];
                                    }
                                    // do a AVK replace ALSO & show
                                    $adjacent_dictionary["[BUFFER]"] = $retval['buffer'];
                                    // show dictionary summary
                                    if (count($adjacent_dictionary) > 0) {
                                        if ($mode_edit) {
                                            echo "<b>";
                                            echo getTranslation("Current Parameter Values", $settings);
                                            echo ": ";
                                            echo "</b>";
                                            echo "<ul>";
                                            echo "<table border='1'>";
                                            foreach ($q->obj_hf_parameters as $hf_param) {
                                                if (isset($hf_param->obj_overridden) && $hf_param->obj_overridden) {
                                                    continue;
                                                }
                                                echo "<tr>";
                                                echo "<td>";
                                                echo htmlspecialchars($hf_param->keyword);
                                                echo "</td>";
                                                echo "<td style='font-size:10px'>";
                                                echo htmlspecialchars($hf_param->printable_value);
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                            echo "</table>";
                                            echo "<br/>";
                                            echo "</ul>";
                                            echo getTranslation("Current Adjacent Dictionary Contents", $settings);
                                            echo ": ";
                                            echo "<ul>";
                                            echo "<table border='1'>";
                                            foreach ($adjacent_dictionary as $adk => $adv) {
                                                if (is_standard_ad($adk)) {
                                                    continue;
                                                }
                                                echo "<tr>";
                                                echo "<td>";
                                                echo htmlspecialchars($adk);
                                                echo "</td>";
                                                echo "<td style='font-size:10px'>";
                                                echo htmlspecialchars($adv);
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                            echo "</table>";
                                            echo "</ul>";
                                            echo "<br/>";
                                            echo "</ul>";
                                        }
                                    }
                                }
                                // end if (buffer action)
                                if ($match_entry->id_entry_subtype == 'php-code' && strpos($settings['uri']['@attributes']['value'], $demo_domain) === FALSE) {
                                    // EXECUTE PHP CODE HERE - $STR contains current value
                                    $the_code = "";
                                    if (isset($match_entry->obj_me_settings['php_code'])) {
                                        $the_code = $match_entry->obj_me_settings['php_code']->obj_value->body;
                                    }
                                    $the_code_replace = replace_hf_parameters($the_code, $q->obj_hf_parameters);
                                    $the_code_replace = replace_dictionary($the_code_replace, $adjacent_dictionary);
                                    $the_code_original = $the_code;
                                    $the_code = $the_code_replace;
                                    $this_value_before_code = $this_value;
                                    $STR = $this_value;
                                    if ($mode_edit) {
                                        echo "<ul>";
                                        // use current value as adjacent dictionary key
                                        echo "<br/>";
                                        echo getTranslation("Run PHP Code (Variable \$STR gets or sets current value)", $settings);
                                        echo ":<br/><textarea cols='50' name='php_code'>";
                                        echo str_replace("<", "&lt;", $the_code_original);
                                        echo "</textarea>";
                                        if ($the_code_original != $the_code_replace) {
                                            echo "<br/>";
                                            echo "<b>After Function Parameter/Adjacent Dictionary Value Replacement:</b>";
                                            echo "<ul>";
                                            echo "<textarea style='background-color:#ddd;' readonly='readonly'>";
                                            echo htmlspecialchars($the_code);
                                            echo "</textarea>";
                                            echo "</ul>";
                                        }
                                        echo "<br/>";
                                        echo "<br/>";
                                        echo "</ul>";
                                    }
                                    // end if (edit mode)
                                    if (strlen($the_code) > 0) {
                                        eval($the_code);
                                    }
                                    $this_value = $STR;
                                    if ($mode_edit) {
                                        if ($this_value_before_code != $this_value) {
                                            echo "<br/>";
                                            echo "<b>Value of \$STR After PHP Code:</b>";
                                            echo "<ul>";
                                            echo "<textarea style='background-color:#ddd;' readonly='readonly'>";
                                            echo htmlspecialchars($this_value);
                                            echo "</textarea>";
                                            echo "</ul>";
                                        }
                                    }
                                }
                                // end if (use current value as adjacent dictionary key)
                                // MOVE MATCH ENTRY UP OR DOWN, UPDATE OR DELETE
                                if ($mode_edit) {
                                    echo "<ul>";
                                    echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                                    echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>";
                                    echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>";
                                    echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>";
                                    echo "</form>";
                                    //echo "<input type='submit' value='Update'/><input type='submit' name='btnUp' value='Move Up'/><input type='submit' name='btnDown' value='Move Down'/></form>";
                                    //echo "<form style='display:inline;' action='?q=$qn&action=delete-match-action' method='post'>";
                                    //echo "<input type='hidden' name='id_match_entry' value='".$match_entry['id']."'/>";
                                    //echo "<input type='submit' value='Delete'/>";
                                    //echo "</form>";
                                    echo "</ul>";
                                }
                                // end if (edit mode)
                            } else {
                                if ($match_entry->id_entry_type == 'output') {
                                    // todo need to add xml/cxml mode codes
                                    if (strpos($match_entry->idx_id, "-1") === False) {
                                        $bool_has_output = true;
                                    }
                                    $raw_response = "";
                                    /// SERVICES DEFINITION
                                    $services_file = dirname(__FILE__) . "/services.xml";
                                    $service_doc = xmlToArray(simplexml_load_file($services_file));
                                    $SERVICES = array();
                                    foreach ($service_doc as $services) {
                                        foreach ($services as $service) {
                                            $SERVICES[] = new Service($service);
                                        }
                                    }
                                    // GENERALLY USED MATCH ENTRY SETTING - ITS OKAY IF IT IS NOT USED
                                    $do_this_output_in_edit_mode = false;
                                    if (isset($match_entry->obj_me_settings['run_in_edit_mode'])) {
                                        if ($match_entry->obj_me_settings['run_in_edit_mode']->value == "true") {
                                            $do_this_output_in_edit_mode = true;
                                        }
                                    }
                                    $plugin_base_filename = "plugins/matchentry." . $match_entry->id_entry_type . "." . $match_entry->id_entry_subtype . "";
                                    $plugin_init_filename = $plugin_base_filename . "." . "init" . ".php";
                                    $plugin_exec_filename = $plugin_base_filename . "." . "exec" . ".php";
                                    $plugin_dispose_filename = $plugin_base_filename . "." . "dispose" . ".php";
                                    $plugin_edit_filename = $plugin_base_filename . "." . "edit" . ".php";
                                    if (file_exists($plugin_init_filename)) {
                                        try {
                                            include $plugin_init_filename;
                                        } catch (Exception $e) {
                                            if ($mode_edit) {
                                                echo "<br/>";
                                            }
                                            echo getTranslation("PLUGIN ERROR DURING INITIALIZATION", $settings);
                                            echo ": ";
                                            if ($mode_edit) {
                                                echo "<br/>";
                                                echo "<textarea rows='3' style='background-color:" . rcolor() . "' style='width:500px;'/>";
                                            }
                                            echo str_replace("<", "&lt;", $e);
                                            if ($mode_edit) {
                                                echo "</textarea>";
                                                echo "<br/>";
                                            }
                                        }
                                    }
                                    // IF NOT EDIT MODE, OR IS EDIT MODE & RUN-IN-EDIT-MODE SETTING IS TURNED ON
                                    if (!$mode_edit || $mode_edit && $do_this_output_in_edit_mode) {
                                        if (file_exists($plugin_exec_filename)) {
                                            try {
                                                include $plugin_exec_filename;
                                            } catch (Exception $e) {
                                                if ($mode_edit) {
                                                    echo "<br/>";
                                                }
                                                echo getTranslation("PLUGIN ERROR DURING EXECUTION", $settings);
                                                echo ": ";
                                                if ($mode_edit) {
                                                    echo "<br/>";
                                                    echo "<textarea rows='3' style='background-color:" . rcolor() . "' style='width:500px;'/>";
                                                }
                                                echo str_replace("<", "&lt;", $e);
                                                if ($mode_edit) {
                                                    echo "</textarea>";
                                                    echo "<br/>";
                                                }
                                            }
                                        }
                                    }
                                    // IF NOT MODE EDIT OR EDIT MODE + RUN IN EDIT MODE
                                    if (file_exists($plugin_dispose_filename)) {
                                        try {
                                            include $plugin_dispose_filename;
                                        } catch (Exception $e) {
                                            if ($mode_edit) {
                                                echo "<br/>";
                                            }
                                            echo getTranslation("PLUGIN ERROR DURING DISPOSAL", $settings);
                                            echo ": ";
                                            if ($mode_edit) {
                                                echo "<br/>";
                                                echo "<textarea rows='3' style='background-color:" . rcolor() . "' style='width:500px;'/>";
                                            }
                                            echo str_replace("<", "&lt;", $e);
                                            if ($mode_edit) {
                                                echo "</textarea>";
                                                echo "<br/>";
                                            }
                                        }
                                    }
                                    // SHOW EDIT GUI
                                    if ($mode_edit) {
                                        echo "<form action='?q={$qn}&v=filtering-expression&action=update-match-entry' method='post' style='display:inline;'>";
                                        echo "<input type='hidden' name='id_expr' value='" . $match_entry->id_expr . "'/>";
                                        echo "<input type='hidden' name='idx_id' value='" . $match_entry->idx_id . "'/>";
                                        echo "<input type='hidden' name='id_entry_type' value='output'/>";
                                        echo getTranslation("OUTPUT", $settings);
                                        echo ": <select name='id_entry_subtype'>";
                                        echo "<option value=''></option>";
                                        foreach ($STATIC['output_types'] as $output_key => $output_value) {
                                            $seltxt = "";
                                            $extratxt = "";
                                            if ($output_key == $match_entry->id_entry_subtype) {
                                                $seltxt = " selected";
                                            }
                                            if ($output_key != "print-value") {
                                                $extratxt = getTranslation("Post data externally, do not print", $settings);
                                                $extratxt = $extratxt . ": ";
                                            }
                                            echo "<option value='" . $output_key . "'{$seltxt}>" . $extratxt . getTranslation($output_value, $settings) . "</option>";
                                        }
                                        echo "</select>";
                                        echo ": ";
                                        echo "<br/>";
                                        echo "<ul>";
                                        if ($match_entry->id_entry_subtype == 'print-value') {
                                            // PRINT VALUE
                                            echo "<br/>";
                                            echo "Value will be printed out to the web page/console/output file.";
                                            echo "<br/>";
                                        }
                                        // END IF (PRINT VALUE)
                                        if (file_exists($plugin_edit_filename)) {
                                            include $plugin_edit_filename;
                                        }
                                        // Database hf
                                        if ($match_entry->id_entry_subtype == 'database-hf') {
                                            // Database Function
                                            echo "Database Type ";
                                            echo "<select name='str_dbtype'>";
                                            echo "<option value=''></option>";
                                            foreach ($APP['services'] as $service) {
                                                if ($service->enabled && $service->type == "database") {
                                                    $seltxt = "";
                                                    if (isset($match_entry->obj_me_settings['str_dbtype'])) {
                                                        if ($match_entry->obj_me_settings['str_dbtype']->obj_value->body == $service->name) {
                                                            $seltxt = " selected='selected'";
                                                        }
                                                    }
                                                    echo "<option value='" . $service->name . "'{$seltxt}>" . $service->name . "</option>";
                                                }
                                            }
                                            echo "</select>";
                                            echo "<br/>";
                                            echo "";
                                            echo "Database Server: ";
                                            echo "<textarea rows='1' name='str_server'>";
                                            if (isset($match_entry->obj_me_settings['str_server'])) {
                                                echo $match_entry->obj_me_settings['str_server']->obj_value->body;
                                            }
                                            echo "</textarea>";
                                            echo "<br/>";
                                            echo "<ul>";
                                            echo "username: <textarea rows='1' name='str_user'>";
                                            if (isset($match_entry->obj_me_settings['str_user'])) {
                                                echo $match_entry->obj_me_settings['str_user']->obj_value->body;
                                            }
                                            echo "</textarea>";
                                            echo "<br/>";
                                            echo "password: <textarea rows='1' name='str_pass'>";
                                            if (isset($match_entry->obj_me_settings['str_pass'])) {
                                                echo $match_entry->obj_me_settings['str_pass']->obj_value->body;
                                            }
                                            echo "</textarea>";
                                            echo "<br/>";
                                            echo "database name: <textarea rows='1' name='str_dbname'>";
                                            if (isset($match_entry->obj_me_settings['str_dbname'])) {
                                                echo $match_entry->obj_me_settings['str_dbname']->obj_value->body;
                                            }
                                            echo "</textarea>";
                                            echo "<br/>";
                                            echo "</ul>";
                                            echo "Database Statement:<ul><textarea readonly='readonly'  style='background-color:#ddd;width:600px;'>";
                                            echo htmlspecialchars($this_value);
                                            echo "</textarea></ul>";
                                        }
                                        // end if (database hf)
                                        // Send E-Mail
                                        // TODO
                                        echo "<br/>";
                                        echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                                        echo "<input type='submit' name='btnUp' value='" . getTranslation("Move Up", $settings) . "'/>";
                                        echo "<input type='submit' name='btnDown' value='" . getTranslation("Move Down", $settings) . "'/>";
                                        echo "<input type='submit' name='btnDelete' value='" . getTranslation("Delete", $settings) . "'/>";
                                        echo "</form>";
                                        echo "</ul>";
                                        echo "<br/>";
                                    }
                                    // end if (edit mode);
                                }
                            }
                        }
                    }
                    // end if (match entry type == output)
                }
                // END FOREACH (MATCH ENTRY)
                if ($mode_edit) {
                    echo "</ul>";
                }
            }
            // END IF (ANY MATCH ENTRIES ON THIS MATCH)
            // NO MATCH PROCESSING FILTERS ON THIS AT ALL; PRINT OUT THE VALUE YOU HAVE
            if (!$bool_has_filter && !$bool_has_output) {
                if ($mode_cxml && !$mode_jidonly) {
                    if (!$bool_buffer_output_merge) {
                        if (!isUTF8($this_value)) {
                            // TODO: WHAT IF THIS WAS BINARY RESULT CONTENT?
                            echo mb_convert_encoding($this_value, "UTF-8");
                        } else {
                            echo $this_value;
                        }
                    }
                }
                // mode cxml
                $retval['buffer'] = $retval['buffer'] . $this_value;
                if ($mode_xml && !$mode_jidonly) {
                    for ($in = 1; $in < $idt + 2; $in++) {
                        echo "\t";
                    }
                    echo "<value>";
                    //echo "<offset>".$this_idx."</offset>";
                    echo "<string>";
                    if (!isUTF8($this_value)) {
                        echo mb_convert_encoding(htmlspecialchars($this_value), "UTF-8");
                    } else {
                        echo htmlspecialchars($this_value);
                    }
                    echo "</string>";
                    echo "</value>\n";
                }
                // mode xml
            }
            // end if ( no filters found - behavior )
            // ADD OUTPUT, ADD PROCESSING, ADD OPERATION, ADD ACTION GUI ELEMENTS
            if ($mode_edit) {
                //echo "</div>";
                //echo "<ul>";
                echo "\n";
                echo "</div>";
                echo getTranslation("ADD", $settings) . " " . getTranslation("OUTPUT", $settings) . ": " . getTranslation("Output this value", $settings) . ": ";
                echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>";
                echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
                echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>";
                echo "<input type='hidden' name='id_entry_type' value='output'/>";
                echo "<select name='id_entry_subtype'>";
                echo "<option value=''></option>";
                foreach ($STATIC['output_types'] as $output_key => $output_value) {
                    echo "<option value='" . $output_key . "'>" . getTranslation($output_value, $settings) . "</option>";
                }
                echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>";
                echo "</form>";
                echo "<br/>";
                echo getTranslation("ADD", $settings) . " " . getTranslation("PROCESSING", $settings) . ": " . getTranslation("The text above", $settings) . ":<!--({$mi}," . $OBJ_EXPR->id . ",{$qn})-->";
                echo " ";
                echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>";
                echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
                echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>";
                echo "<input type='hidden' name='id_entry_type' value='processing'/>";
                echo "<select name='id_entry_subtype'>";
                echo "<option value=''></option>";
                foreach ($STATIC['processing_types'] as $processing_key => $processing_value) {
                    echo "<option value='" . $processing_key . "'>" . getTranslation($processing_value, $settings) . "</option>";
                }
                echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>";
                echo "</form>";
                echo "<br/>";
                echo getTranslation("ADD", $settings) . " " . getTranslation("OPERATION", $settings) . ": " . getTranslation("In-place modify", $settings) . ": ";
                echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>";
                echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
                echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>";
                echo "<input type='hidden' name='id_entry_type' value='operation'/>";
                echo "<select name='id_entry_subtype'>";
                echo "<option value=''></option>";
                foreach ($STATIC['operation_types'] as $operation_key => $operation_value) {
                    echo "<option value='" . $operation_key . "'>" . getTranslation($operation_value, $settings) . "</option>";
                }
                echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>";
                echo "</form>";
                echo "<br/>";
                echo getTranslation("ADD", $settings) . " " . getTranslation("ACTION", $settings) . ":";
                echo " ";
                echo "<form action='?q={$qn}&v=filtering-expression&action=add-match-entry' method='post' style='display:inline;'>";
                echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
                echo "<input type='hidden' name='idx_id' value='" . $mi . "'/>";
                echo "<input type='hidden' name='id_entry_type' value='action'/>";
                echo "<select name='id_entry_subtype'>";
                echo "<option value=''></option>";
                foreach ($STATIC['action_types'] as $action_key => $action_value) {
                    if ($action_key != "php-code" || $_SERVER['HTTP_HOST'] != $demo_domain) {
                        echo "<option value='" . $action_key . "'>" . getTranslation($action_value, $settings) . "</option>";
                    }
                }
                echo "</select><input value='" . getTranslation("Submit", $settings) . "' type='submit'/>";
                echo "</form>";
                echo "</b></font>\n";
                echo "</ul><br/>";
                //echo "<div style='margin-left:0px;background-color:".rcolor()."'>";
            }
            // end if (edit mode)
            $custom_foot = $OBJ_EXPR->obj_match_customs;
            $cfoot = "";
            $cfoot_after_replace = "";
            if ($custom_foot) {
                if (isset($custom_foot[$mi . '.footer'])) {
                    $cfoot = $custom_foot[$mi . '.footer']->obj_txt->body;
                    $cfoot_after_replace = replace_hf_parameters($cfoot, $q->obj_hf_parameters);
                }
            }
            if ($mode_cxml && !$mode_jidonly) {
                if (!$bool_buffer_output_merge) {
                    echo $cfoot_after_replace;
                }
            }
            $retval['buffer'] = $retval['buffer'] . $cfoot_after_replace;
            if ($mode_edit) {
                echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Footer", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . $mi . "): ";
                echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
                echo "<input type='hidden' name='idx_key' value='" . $mi . ".footer'/>";
                echo "<textarea rows='1' name='str_txt' style='width:500px;'/>";
                echo str_replace("<", "&lt;", $cfoot);
                echo "</textarea>";
                echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
                echo "</form>\n";
            }
            if ($cfoot != $cfoot_after_replace) {
                echo "\tAfter Replacement: " . htmlspecialchars($cfoot_after_replace) . "\n";
            }
        }
        // end foreach (each match field (i.e. "(.*?)" ) in the regex)
    } else {
        // NO MATCH PROCESSING FILTERS ON THIS AT ALL; PRINT OUT THE VALUE YOU HAVE
        if ($mode_cxml && !$mode_jidonly) {
            if (!$bool_buffer_output_merge) {
                if (!isUTF8($this_value)) {
                    // TODO: WHAT IF THIS WAS BINARY RESULT CONTENT?
                    echo mb_convert_encoding($this_value, "UTF-8");
                } else {
                    echo $this_value;
                }
            }
        }
        // mode cxml
        $retval['buffer'] = $retval['buffer'] . $this_value;
        if ($mode_xml && !$mode_jidonly) {
            for ($in = 1; $in < $idt + 2; $in++) {
                echo "\t";
            }
            echo "<value>";
            //echo "<offset>".$this_idx."</offset>";
            echo "<string>";
            if (!isUTF8($this_value)) {
                echo mb_convert_encoding(htmlspecialchars($this_value), "UTF-8");
            } else {
                echo htmlspecialchars($this_value);
            }
            echo "</string>";
            echo "</value>\n";
        }
        // mode xml
    }
    if ($mode_edit) {
        echo "</ul>";
    }
    // CUSTOM FOOTER FIELDS/PRINTOUT
    $cfoot = "";
    $cfoot_after_replace = "";
    if (isset($OBJ_EXPR->obj_match_customs['0.footer'])) {
        if (isset($OBJ_EXPR->obj_match_customs['0.footer'])) {
            $cfoot = $custom_foot['0.footer']->obj_txt->body;
            $cfoot_after_replace = replace_hf_parameters($cfoot, $q->obj_hf_parameters);
        }
    }
    if ($mode_cxml && !$mode_jidonly) {
        if (!$bool_buffer_output_merge) {
            echo $cfoot_after_replace;
        }
    }
    $retval['buffer'] = $retval['buffer'] . $cfoot_after_replace;
    //if ($mode_cxml && !$mode_jidonly) echo $cfoot_after_replace;
    if ($mode_edit) {
        echo "<form style='display:inline;' action='?q={$qn}&v=filtering-expression&action=update-custom-text' method='post'>" . getTranslation("Custom Footer", $settings) . " (" . substr($OBJ_EXPR->id, 0, min(5, strlen($OBJ_EXPR->id))) . "," . "0" . "): ";
        echo "<input type='hidden' name='id_expr' value='" . $OBJ_EXPR->id . "'/>";
        echo "<input type='hidden' name='idx_key' value='0.footer'/>";
        echo "<textarea rows='1' name='str_txt' style='width:500px;'/>";
        echo str_replace("<", "&lt;", $cfoot);
        echo "</textarea>";
        echo "<input type='submit' value='" . getTranslation("Update", $settings) . "'/>";
        echo "</form>\n";
    }
    if ($cfoot != $cfoot_after_replace && $mode_edit) {
        echo "\tAfter Replacement: " . htmlspecialchars($cfoot_after_replace) . "\n";
    }
    if ($mode_xml) {
        for ($in = 1; $in < $idt + 2; $in++) {
            echo "\t";
        }
        echo "</hfs>\n";
    }
    if ($mode_edit) {
        echo "\n\n";
        echo "</font></ul>";
    }
    if ($mode_xml) {
        for ($in = 1; $in < $idt + 1; $in++) {
            echo "\t";
        }
        echo "</result>\n";
    }
    //echo "<hr/>";
    return $retval;
}
Example #13
0
 function create_page()
 {
     $tqx_pieces = explode(";", $_REQUEST['tqx']);
     foreach ($tqx_pieces as $p) {
         $arr = explode(":", $p);
         $this->_gva_tqx[$arr[0]] = $arr[1];
     }
     if ($this->_gva_tqx['reqId'] != '') {
         $this->_gva_reqId = $this->_gva_tqx['reqId'];
     }
     if ($this->_gva_tqx['out'] != '') {
         $this->_gva_out = $this->_gva_tqx['out'];
     }
     if ($this->_gva_tqx['responseHandler'] != '') {
         $this->_gva_responseHandler = $this->_gva_tqx['responseHandler'];
     }
     $i = 0;
     while (isset($this->element[$i])) {
         $page_element = $this->element[$i];
         switch ($page_element->get_elementtype()) {
             case HAW_TABLE:
                 $table = $this->element[$i];
                 switch ($this->_gva_out) {
                     case 'csv':
                         //header("Content-type: application/csv");
                         //header("Content-Disposition: filename=\"" . trim($this->title) . ".csv\"");
                         for ($a = 0; $a < $table->number_of_rows; $a++) {
                             $row = $table->row[$a];
                             for ($b = 0; $b < $row->number_of_columns; $b++) {
                                 $column = $row->column[$b];
                                 if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                                     $text = "\"" . str_replace('"', '""', $column->get_text()) . "\"";
                                     echo isUTF8($text) ? $text : utf8_encode($text);
                                 }
                                 if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                                     $text = "\"" . str_replace('"', '""', $column->get_label()) . "\"";
                                     echo isUTF8($text) ? $text : utf8_encode($text);
                                 }
                                 if ($b < $row->number_of_columns - 1) {
                                     echo utf8_encode(",");
                                 } else {
                                     echo utf8_encode("\n");
                                 }
                             }
                         }
                         break;
                     case 'json':
                         echo $this->_gva_responseHandler . "(";
                         $cols = array();
                         $a = 0;
                         $row = $table->row[$a];
                         for ($b = 0; $b < $row->number_of_columns; $b++) {
                             $column = $row->column[$b];
                             if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                                 $text = $column->get_text();
                                 $text = isUTF8($text) ? $text : utf8_encode($text);
                             }
                             if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                                 $text = $column->get_label();
                                 $text = isUTF8($text) ? $text : utf8_encode($text);
                             }
                             switch ($column->metatype) {
                                 case 'I':
                                 case 'N':
                                     $cols[] = array('id' => $b, 'label' => $text, 'type' => 'number');
                                     break;
                                 default:
                                     $cols[] = array('id' => $b, 'label' => $text, 'type' => 'string');
                             }
                         }
                         $rows = array();
                         for ($a = 1; $a < $table->number_of_rows; $a++) {
                             $row = $table->row[$a];
                             $r = array();
                             for ($b = 0; $b < $row->number_of_columns; $b++) {
                                 $column = $row->column[$b];
                                 if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                                     $text = $column->get_text();
                                     $text = isUTF8($text) ? $text : utf8_encode($text);
                                 }
                                 if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                                     $text = $column->get_label();
                                     $text = isUTF8($text) ? $text : utf8_encode($text);
                                 }
                                 switch ($column->metatype) {
                                     case 'I':
                                         $r[] = array('v' => (int) $text);
                                         break;
                                     default:
                                         $r[] = array('v' => $text);
                                 }
                             }
                             $rows[] = array('c' => $r);
                         }
                         $this->_gva_table = array('cols' => $cols, 'rows' => $rows);
                         $jarr = array('version' => $this->_gva_version, 'status' => $this->_gva_status, 'table' => $this->_gva_table, 'sig' => md5(serialize($this->_gva_table)));
                         if ($this->_gva_reqId != '') {
                             $jarr['reqId'] = $this->_gva_reqId;
                         }
                         $json = new Services_JSON();
                         echo $json->encode($jarr);
                         echo ");";
                         break;
                 }
                 break;
         }
         $i++;
     }
 }
Example #14
0
 function validate()
 {
     if (!$this->updatable || strpos(strtolower($this->validation), 'ignore') !== false) {
         return true;
     }
     parent::validate();
     $found = false;
     reset($this->options);
     while ($tok = each($this->options)) {
         $curr = isUTF8($tok[1][0]) ? $tok[1][0] : utf8_encode($tok[1][0]);
         if ($curr == $this->value) {
             $found = true;
         }
     }
     if (!$found) {
         $this->form->validator->setError($this->field, 901);
     }
 }
Example #15
0
/**
* US-ASCII transliterations of Unicode text
* Ported Sean M. Burke's Text::Unidecode Perl module (He did all the hard work!)
* Warning: you should only pass this well formed UTF-8!
* Be aware it works by making a copy of the input string which it appends transliterated
* characters to - it uses a PHP output buffer to do this - it means, memory use will increase,
* requiring up to the same amount again as the input string
* @see http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm
* @param string UTF-8 string to convert
* @param string (default = ?) Character use if character unknown
* @return string US-ASCII string
* @package utf8_to_ascii
*/
function utf8_to_ascii($str, $unknown = '?')
{
    # The database for transliteration stored here
    static $UTF8_TO_ASCII = array();
    # Variable lookups faster than accessing constants
    $UTF8_TO_ASCII_DB = UTF8_TO_ASCII_DB;
    if (!isUTF8($str)) {
        $str = utf8_encode($str);
    }
    if (strlen($str) == 0) {
        return '';
    }
    $len = strlen($str);
    $i = 0;
    # Use an output buffer to copy the transliterated string
    # This is done for performance vs. string concatenation - on my system, drops
    # the average request time for the example from ~0.46ms to 0.41ms
    # See http://phplens.com/lens/php-book/optimizing-debugging-php.php
    # Section  "High Return Code Optimizations"
    ob_start();
    while ($i < $len) {
        $ord = NULL;
        $increment = 1;
        $ord0 = ord($str[$i]);
        # Much nested if /else - PHP fn calls expensive, no block scope...
        # 1 byte - ASCII
        if ($ord0 >= 0 && $ord0 <= 127) {
            $ord = $ord0;
            $increment = 1;
        } else {
            # 2 bytes
            $ord1 = ord($str[$i + 1]);
            if ($ord0 >= 192 && $ord0 <= 223) {
                $ord = ($ord0 - 192) * 64 + ($ord1 - 128);
                $increment = 2;
            } else {
                # 3 bytes
                $ord2 = ord($str[$i + 2]);
                if ($ord0 >= 224 && $ord0 <= 239) {
                    $ord = ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128);
                    $increment = 3;
                } else {
                    # 4 bytes
                    $ord3 = ord($str[$i + 3]);
                    if ($ord0 >= 240 && $ord0 <= 247) {
                        $ord = ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2 - 128) * 64 + ($ord3 - 128);
                        $increment = 4;
                    } else {
                        ob_end_clean();
                        trigger_error("utf8_to_ascii: looks like badly formed UTF-8 at byte {$i}");
                        return FALSE;
                    }
                }
            }
        }
        $bank = $ord >> 8;
        # If we haven't used anything from this bank before, need to load it...
        if (!array_key_exists($bank, $UTF8_TO_ASCII)) {
            $bankfile = UTF8_TO_ASCII_DB . '/' . sprintf("x%02x", $bank) . '.php';
            if (file_exists($bankfile)) {
                # Load the appropriate database
                if (!(include $bankfile)) {
                    ob_end_clean();
                    trigger_error("utf8_to_ascii: unable to load {$bankfile}");
                }
            } else {
                # Some banks are deliberately empty
                $UTF8_TO_ASCII[$bank] = array();
            }
        }
        $newchar = $ord & 255;
        if (array_key_exists($newchar, $UTF8_TO_ASCII[$bank])) {
            echo $UTF8_TO_ASCII[$bank][$newchar];
        } else {
            echo $unknown;
        }
        $i += $increment;
    }
    $str = ob_get_contents();
    ob_end_clean();
    return $str;
}
Example #16
0
         $html .= '&nbsp;<font size="2px">[' . strip_tags(stripslashes(substr(cleanString($tempo[0]), 0, 30))) . ']</font>';
     }
 }
 $html .= '</a>';
 // increment array for icons shortcuts (don't do if option is not enabled)
 if (isset($_SESSION['settings']['copy_to_clipboard_small_icons']) && $_SESSION['settings']['copy_to_clipboard_small_icons'] == 1) {
     if ($need_sk == true && isset($_SESSION['my_sk'])) {
         $pw = decrypt($record['pw'], mysqli_escape_string($link, stripslashes($_SESSION['my_sk'])));
     } else {
         $pw = substr(decrypt($record['pw']), strlen(@$record['rand_key']));
     }
 } else {
     $pw = "";
 }
 // test charset => may cause a json error if is not utf8
 if (!isUTF8($pw)) {
     $pw = "";
     $html .= '&nbsp;<img src="includes/images/exclamation_small_red.png" title="' . $LANG['pw_encryption_error'] . '" />';
 }
 $html .= '<span style="float:right;margin:2px 10px 0px 0px;">';
 // display quick icon shortcuts ?
 if (isset($_SESSION['settings']['copy_to_clipboard_small_icons']) && $_SESSION['settings']['copy_to_clipboard_small_icons'] == 1) {
     $itemLogin = '******' . $record['id'] . '" />';
     $itemPw = '<img src="includes/images/mini_lock_disable.png" id="icon_pw_' . $record['id'] . '" class="copy_clipboard tip" />';
     if ($displayItem == true) {
         if (!empty($record['login'])) {
             $itemLogin = '******' . $record['id'] . '" class="copy_clipboard item_clipboard tip" title="' . $LANG['item_menu_copy_login'] . '" />';
         }
         if (!empty($pw)) {
             $itemPw = '<img src="includes/images/mini_lock_enable.png" id="iconpw_' . $record['id'] . '" class="copy_clipboard item_clipboard tip" title="' . $LANG['item_menu_copy_pw'] . '" />';
         }
Example #17
0
             $pw = decryptOld($data['pw'], $oldPersonalSaltkey);
             // decrypt using protocol #1
         } else {
             // used protocol is #2
             // get key for this pw
             $dataItem = DB::queryfirstrow("SELECT rand_key\n                        FROM " . prefix_table("keys") . "\n                        WHERE `sql_table` = %s AND id = %i", "items", $data['id']);
             if (!empty($dataItem['rand_key'])) {
                 // remove key from pw
                 $pw = substr($pw, strlen($dataTemp['rand_key']));
             }
         }
     }
     // encrypt it
     if (!empty($pw) && isUTF8($pw)) {
         $encrypt = cryption($pw, $personal_sk, "", "encrypt");
         if (isUTF8($pw)) {
             // store Password
             DB::update(prefix_table('items'), array('pw' => $encrypt['string'], 'pw_iv' => $encrypt['iv']), "id = %i", $data['id']);
         }
     }
 } else {
     // COMPLETE RE-ENCRYPTION
     $personal_sk = $_SESSION['my_sk'];
     // get data about pw
     $data = DB::queryfirstrow("SELECT id, pw, pw_iv\n                FROM " . prefix_table("items") . "\n                WHERE id = %i", $_POST['currentId']);
     if (empty($data['pw_iv'])) {
         // check if pw encrypted with protocol #2
         $pw = decrypt($data['pw'], $_SESSION['my_sk']);
         if (empty($pw)) {
             // used protocol is #1
             $pw = decryptOld($data['pw'], $_SESSION['my_sk']);
Example #18
0
 function create_page()
 {
     global $_CAMILA;
     if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download' || $_REQUEST['camila_export_action'] == 'sendmail') {
         $fname = tempnam(CAMILA_TMP_DIR, 'export.xls');
     } else {
         if (!$this->camila_export_file_exists || $_REQUEST['camila_export_overwrite'] == 'y') {
             $fname = $this->camila_export_get_dir() . $this->camila_export_filename();
         } else {
             $fname = tempnam(CAMILA_TMP_DIR, 'export.xls');
         }
     }
     $workbook =& new Spreadsheet_Excel_Writer_Workbook($fname);
     $workbook->setTempDir(CAMILA_TMP_DIR);
     $workbook->setVersion(8);
     $dWorksheet =& $workbook->addworksheet($_CAMILA['page_short_title'] . ' - ' . camila_get_translation('camila.worktable.worksheet.data'));
     $i = 0;
     $m = camila_get_translation('camila.dateformat.monthpos');
     $d = camila_get_translation('camila.dateformat.daypos');
     $y = camila_get_translation('camila.dateformat.yearpos');
     $date_format =& $workbook->addFormat();
     $fmt = str_replace(array('d', 'm', 'y'), array('dd', 'mm', 'yyyy'), strtolower($_CAMILA['date_format']));
     $date_format->setNumFormat($fmt);
     $dataFound = false;
     while (isset($this->element[$i])) {
         $page_element = $this->element[$i];
         switch ($page_element->get_elementtype()) {
             case HAW_TABLE:
                 $table = $this->element[$i];
                 $row = $table->row[0];
                 for ($b = 0; $b < $row->number_of_columns; $b++) {
                     $column = $row->column[$b];
                     if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                         $text = $column->get_text();
                     }
                     if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                         $text = $column->get_label();
                     }
                     $dWorksheet->writeString($a, $b, isUTF8($text) ? utf8_decode($text) : $text);
                 }
                 if (!$_CAMILA['page']->camila_worktable || $_CAMILA['page']->camila_worktable && ($_REQUEST['camila_worktable_export'] == 'all' || $_REQUEST['camila_worktable_export'] == 'dataonly')) {
                     for ($a = 1; $a < $table->number_of_rows; $a++) {
                         $row = $table->row[$a];
                         $dataFound = true;
                         for ($b = 0; $b < $row->number_of_columns; $b++) {
                             $column = $row->column[$b];
                             if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                                 $text = $column->get_label();
                                 $url = $column->get_url();
                                 $dWorksheet->writeUrl($a, $b, $url, $text);
                             } else {
                                 if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                                     $text = $column->get_text();
                                 }
                                 switch ($column->metatype) {
                                     case 'I':
                                     case 'N':
                                         if ($text != '') {
                                             $dWorksheet->writeNumber($a, $b, intval($text));
                                         }
                                         break;
                                     case 'D':
                                         if ($text != '') {
                                             $dWorksheet->writeNumber($a, $b, $this->xl_date_list(intval(substr($text, $y, 4)), intval(substr($text, $m, 2)), intval(substr($text, $d, 2))), $date_format);
                                         }
                                         break;
                                     default:
                                         $dWorksheet->writeString($a, $b, isUTF8($text) ? utf8_decode($text) : $text);
                                 }
                             }
                         }
                     }
                 }
                 break;
         }
         $i++;
     }
     if ($_CAMILA['page']->camila_worktable && ($_REQUEST['camila_worktable_export'] == 'all' || $_REQUEST['camila_worktable_export'] == 'confonly')) {
         $worksheet =& $workbook->addworksheet($_CAMILA['page_short_title'] . ' - ' . camila_get_translation('camila.worktable.worksheet.conf'));
         $aLeft =& $workbook->addformat();
         $aLeft->setAlign('left');
         $opt = array();
         $opt[] = camila_get_translation('camila.worktable.field.sequence');
         $opt[] = camila_get_translation('camila.worktable.field.name.abbrev');
         $opt[] = camila_get_translation('camila.worktable.field.type');
         $opt[] = camila_get_translation('camila.worktable.field.listofvalues');
         $opt[] = camila_get_translation('camila.worktable.field.maxlength');
         $opt[] = camila_get_translation('camila.worktable.field.required');
         $opt[] = camila_get_translation('camila.worktable.field.defaultval');
         $opt[] = camila_get_translation('camila.worktable.field.readonly');
         $opt[] = camila_get_translation('camila.worktable.field.visible');
         $opt[] = camila_get_translation('camila.worktable.field.force');
         $opt[] = camila_get_translation('camila.worktable.field.unique');
         $opt[] = camila_get_translation('camila.worktable.field.options');
         $opt[] = camila_get_translation('camila.worktable.field.autosuggestwtname');
         $opt[] = camila_get_translation('camila.worktable.field.autosuggestwtcolname');
         $opt[] = '';
         $opt[] = camila_get_translation('camila.worktable.configuration');
         $opt[] = camila_get_translation('camila.worktable.name');
         $opt[] = camila_get_translation('camila.worktable.desc');
         $opt[] = camila_get_translation('camila.worktable.order.by');
         $opt[] = camila_get_translation('camila.worktable.order.dir');
         $opt[] = camila_get_translation('camila.worktable.canupdate');
         $opt[] = camila_get_translation('camila.worktable.caninsert');
         $opt[] = camila_get_translation('camila.worktable.candelete');
         $opt[] = camila_get_translation('camila.worktable.category');
         foreach ($opt as $key => $value) {
             $text = $opt[$key];
             $worksheet->writeString(intval($key) + 1, $o, isUTF8($text) ? utf8_decode($text) : $text);
         }
         $worksheet->setColumn(0, 0, 30);
         $id = substr($_SERVER['PHP_SELF'], 12, -4);
         $result = $_CAMILA['db']->Execute('select * from ' . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ') order by sequence');
         if ($result === false) {
             camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg());
         }
         $yesNoArr = camila_get_translation_array('camila.worktable.options.noyes');
         $fieldTypeArr = camila_get_translation_array('camila.worktable.options.fieldtype');
         $forceArr = camila_get_translation_array('camila.worktable.options.force');
         $orderDirArr = camila_get_translation_array('camila.worktable.options.order.dir');
         $colArray = array();
         $count = 1;
         while (!$result->EOF) {
             $colArray[$result->fields['col_name']] = $result->fields['name'];
             $text = $result->fields['name'];
             $worksheet->writeString(0, $count, isUTF8($text) ? utf8_decode($text) : $text);
             if ($_REQUEST['camila_worktable_export'] == 'all' && !$dataFound) {
                 $dWorksheet->writeString(0, $count - 1, isUTF8($text) ? utf8_decode($text) : $text);
             }
             $text = $result->fields['sequence'];
             $worksheet->writeNumber(1, $count, isUTF8($text) ? utf8_decode($text) : $text, $aLeft);
             $text = $result->fields['name_abbrev'];
             $worksheet->writeString(2, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $fieldTypeArr[$result->fields['type']];
             $worksheet->writeString(3, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $result->fields['listbox_options'];
             $worksheet->writeString(4, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $result->fields['maxlength'];
             $worksheet->writeNumber(5, $count, isUTF8($text) ? utf8_decode($text) : $text, $aLeft);
             $text = $yesNoArr[$result->fields['required']];
             $worksheet->writeString(6, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $result->fields['default_value'];
             $worksheet->writeString(7, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $text = $yesNoArr[$result->fields['readonly']];
             $worksheet->writeString(8, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $text = $yesNoArr[$result->fields['visible']];
             $worksheet->writeString(9, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $forceArr[$result->fields['force_case']];
             $worksheet->writeString(10, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $yesNoArr[$result->fields['must_be_unique']];
             $worksheet->writeString(11, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $result->fields['field_options'];
             $worksheet->writeString(12, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $result->fields['autosuggest_wt_name'];
             $worksheet->writeString(13, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $text = $result->fields['autosuggest_wt_colname'];
             $worksheet->writeString(14, $count, isUTF8($text) ? utf8_decode($text) : $text);
             $count++;
             $result->MoveNext();
         }
         $worksheet->setColumn(1, $count - 1, 15);
         $result = $_CAMILA['db']->Execute('select * from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id));
         if ($result === false) {
             camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg());
         }
         $text = $result->fields['short_title'];
         $worksheet->writeString(17, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $result->fields['full_title'];
         $worksheet->writeString(18, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $colArray[$result->fields['order_field']];
         $worksheet->writeString(19, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $orderDirArr[$result->fields['order_dir']];
         $worksheet->writeString(20, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $yesNoArr[$result->fields['canupdate']];
         $worksheet->writeString(21, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $yesNoArr[$result->fields['caninsert']];
         $worksheet->writeString(22, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $yesNoArr[$result->fields['candelete']];
         $worksheet->writeString(23, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = $result->fields['category'];
         $worksheet->writeString(24, 1, isUTF8($text) ? utf8_decode($text) : $text);
         $text = camila_get_translation('camila.worktable.bookmarks');
         $worksheet->writeString(16, 2, isUTF8($text) ? utf8_decode($text) : $text);
         $query = 'select base_url,url,title from ' . CAMILA_APPLICATION_PREFIX . 'camila_bookmarks where base_url=' . $_CAMILA['db']->qstr('cf_worktable' . $id . '.php') . ' order by sequence';
         $result = $_CAMILA['db']->Execute($query);
         if ($result === false) {
             camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg());
         }
         $i = 0;
         while (!$result->EOF) {
             $i++;
             $text = $result->fields['title'];
             $worksheet->writeString(16 + $i, 2, isUTF8($text) ? utf8_decode($text) : $text);
             $url = parse_url($result->fields['url'], PHP_URL_QUERY);
             $qArr = $this->parse_query_string($url);
             $text = $qArr['filter'];
             $worksheet->writeString(16 + $i, 3, isUTF8($text) ? utf8_decode($text) : $text);
             $result->MoveNext();
         }
     }
     if ($_CAMILA['page']->camila_worktable && !$dataFound && $_REQUEST['camila_worktable_export'] == 'dataonly') {
         $id = substr($_SERVER['PHP_SELF'], 12, -4);
         $result = $_CAMILA['db']->Execute('select * from ' . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ') order by sequence');
         if ($result === false) {
             camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg());
         }
         $count = 1;
         while (!$result->EOF) {
             $text = $result->fields['name'];
             $dWorksheet->writeString(0, $count - 1, isUTF8($text) ? utf8_decode($text) : $text);
             $count++;
             $result->MoveNext();
         }
     }
     $workbook->close();
     if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download') {
         header("Content-Type: application/x-msexcel; name=\"" . $this->camila_export_safe_filename() . '.' . $this->camila_export_get_ext() . "\"");
         header("Content-Disposition: attachment; filename=\"" . $this->camila_export_safe_filename() . '.' . $this->camila_export_get_ext() . "\"");
     }
     $fh = fopen($fname, "rb");
     if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download') {
         fpassthru($fh);
         unlink($fname);
     }
     if ($_REQUEST['camila_export_action'] == 'sendmail') {
         global $_CAMILA;
         require_once CAMILA_LIB_DIR . 'phpmailer/class.phpmailer.php';
         $mail = new PHPMailer();
         if (CAMILA_MAIL_IS_SMTP) {
             $mail->IsSMTP();
         }
         $mail->Host = CAMILA_MAIL_HOST;
         $mail->SMTPAuth = CAMILA_MAIL_SMTP_AUTH;
         $mail->From = CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_FROM;
         $mail->FromName = CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_FROM_NAME;
         $mail->AddAttachment($fname, 'file.xls');
         $mail->AddAddress(CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_TO);
         //$mail->AddCC(CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_CC, CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_CC);
         $mail->IsHTML(false);
         $mail->Subject = CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_SUBJECT;
         $text = camila_get_translation('camila.worktable.confirm') . " - " . camila_get_translation('camila.login.username') . ': ' . $_CAMILA['user_name'];
         $mail->Body = $text;
         $mail->AltBody = $text;
         $mail->Send();
         unlink($fname);
     }
 }
Example #19
0
	define("SERVERNAME", $config["SERVERNAME"]);
	define("PATH_DATA" , $config["PATH_DATA"]);
	define("DOCUMENT_ROOT", $config["DOCUMENT_ROOT"]);
	define("APP_PATH", $config["DOCUMENT_ROOT"] . $config["PATH_DATA"]);

	define('LOG_DIR', $logDir);
	define('LOG_FILE',"log" . date('Ymd') . "_search.txt");

	// verifica se exitem acentos codificados em ISO nos parâmetros de entrada (q, filter e filterLabel)
	if (!isUTF8($_REQUEST["q"])){
		$_REQUEST["q"] = utf8_encode($_REQUEST["q"]);
	}
	if (!isUTF8($_REQUEST["filter"])){
		$_REQUEST["filter"] = utf8_encode($_REQUEST["filter"]);
	}
	if (!isUTF8($_REQUEST["filterLabel"])){
		$_REQUEST["filterLabel"] = utf8_encode($_REQUEST["filterLabel"]);
	}

	// seta variavel colectionData com a configuracao da colecao atual
	if ($_REQUEST['col'] != ''){
		for ($c = 0; $c < count($config->search_collection_list->collection); $c++){
			$colName = $config->search_collection_list->collection[$c]->name;
			$colSite = $config->search_collection_list->collection[$c]->site;
			if (!isset($colSite) || $colSite == ''){
				$colSite = $defaultSite;
			}
			if ($_REQUEST['col'] == $colName ){
				if ( isset($_REQUEST['site']) ) {
					if ($_REQUEST['site'] == $colSite ){
						$colectionData = $config->search_collection_list->collection[$c];
Example #20
0
/**
 * ClipBucket Form Validator
 * this function controls the whole logic of how to operate input
 * validate it, generate proper error
 */
function validate_cb_form($input, $array)
{
    //Check the Collpase Category Checkboxes
    if ($input['cat']['title'] == 'Video Category') {
        global $db;
        $query = "SELECT * FROM " . tbl("config") . " WHERE configid=234";
        $row = db_select($query);
        $row[0]['value'] . $input['cat']['title'];
        if ($row[0]['value'] == '0') {
            unset($input['cat']);
        }
    }
    if (is_array($input)) {
        foreach ($input as $field) {
            $field['name'] = formObj::rmBrackets($field['name']);
            //pr($field);
            $title = $field['title'];
            $val = $array[$field['name']];
            $req = $field['required'];
            $invalid_err = $field['invalid_err'];
            $function_error_msg = $field['function_error_msg'];
            if (is_string($val)) {
                if (!isUTF8($val)) {
                    $val = utf8_decode($val);
                }
                $length = strlen($val);
            }
            $min_len = $field['min_length'];
            $min_len = $min_len ? $min_len : 0;
            $max_len = $field['max_length'];
            $rel_val = $array[$field['relative_to']];
            if (empty($invalid_err)) {
                $invalid_err = sprintf("Invalid '%s'", $title);
            }
            if (is_array($array[$field['name']])) {
                $invalid_err = '';
            }
            //Checking if its required or not
            if ($req == 'yes') {
                if (empty($val) && !is_array($array[$field['name']])) {
                    e($invalid_err);
                    $block = true;
                } else {
                    $block = false;
                }
            }
            $funct_err = is_valid_value($field['validate_function'], $val);
            if ($block != true) {
                //Checking Syntax
                if (!$funct_err) {
                    if (!empty($function_error_msg)) {
                        e($function_error_msg);
                    } elseif (!empty($invalid_err)) {
                        e($invalid_err);
                    }
                }
                if (!is_valid_syntax($field['syntax_type'], $val)) {
                    if (!empty($invalid_err)) {
                        e($invalid_err);
                    }
                }
                if (isset($max_len)) {
                    if ($length > $max_len || $length < $min_len) {
                        e(sprintf(lang('please_enter_val_bw_min_max'), $title, $min_len, $field['max_length']));
                    }
                }
                if (function_exists($field['db_value_check_func'])) {
                    $db_val_result = $field['db_value_check_func']($val);
                    if ($db_val_result != $field['db_value_exists']) {
                        if (!empty($field['db_value_err'])) {
                            e($field['db_value_err']);
                        } elseif (!empty($invalid_err)) {
                            e($invalid_err);
                        }
                    }
                }
                if ($field['relative_type'] != '') {
                    switch ($field['relative_type']) {
                        case 'exact':
                            if ($rel_val != $val) {
                                if (!empty($field['relative_err'])) {
                                    e($field['relative_err']);
                                } elseif (!empty($invalid_err)) {
                                    e($invalid_err);
                                }
                            }
                            break;
                    }
                }
            }
        }
    }
}
Example #21
0
File: index.php Project: hisapi/his
 //echo $PLACEHOLDER_HASH."\n";
 // in jidonly mode, only the newly submitted job id is printed out
 // http mode does not work, do local mode
 $NEW_CHILD_JID = "";
 $idx = 0;
 $failed_to_create_child_jobs = false;
 while (strlen($NEW_CHILD_JID) < 40 || strlen($NEW_CHILD_JID) > 90) {
     if ($idx > 0) {
         sleep(5);
     }
     if ($idx > 50) {
         $failed_to_create_child_jobs = true;
         break;
     }
     $NEW_CHILD_JID = @file_get_contents($HIS_URL . "&JID=" . urlencode($this_jid));
     if (isUTF8($NEW_CHILD_JID)) {
         $NEW_CHILD_JID = iconv("UTF-8", "ISO-8859-1//IGNORE", $NEW_CHILD_JID);
     }
     $idx = $idx + 1;
 }
 // END WHILE
 if ($failed_to_create_child_jobs) {
     $new_job_flag = new job_flag();
     $props = array();
     $props['id_job'] = $this_jid;
     $props['flag'] = "failed";
     $props['status'] = "failed-to-create-child-jobs";
     //."-count:".count($submatches);
     exit;
 }
 if (strlen($NEW_CHILD_JID) > 0 && strlen($this_jid) > 0) {
Example #22
0
     if (count($tempo) == 1) {
         $html .= '&nbsp;<font size="2px">[' . strip_tags(stripslashes(substr(cleanString($record['description']), 0, 30))) . ']</font>';
     } else {
         $html .= '&nbsp;<font size="2px">[' . strip_tags(stripslashes(substr(cleanString($tempo[0]), 0, 30))) . ']</font>';
     }
 }
 $html .= '</a>';
 // increment array for icons shortcuts (don't do if option is not enabled)
 if (isset($_SESSION['settings']['copy_to_clipboard_small_icons']) && $_SESSION['settings']['copy_to_clipboard_small_icons'] == 1) {
     if ($need_sk == true && isset($_SESSION['my_sk'])) {
         $pw = cryption($record['pw'], $_SESSION['my_sk'], $record['pw_iv'], "decrypt");
     } else {
         $pw = cryption($record['pw'], SALT, $record['pw_iv'], "decrypt");
     }
     // test charset => may cause a json error if is not utf8
     if (!isUTF8($pw) || empty($pw)) {
         $pw = "";
         $html .= '&nbsp;<i class="fa fa-warning fa-sm mi-red tip" title="' . $LANG['pw_encryption_error'] . '"></i>';
     }
 } else {
     $pw = "";
 }
 $html .= '<span style="float:right;margin:2px 10px 0px 0px;">';
 // mini icon for collab
 if (isset($_SESSION['settings']['anyone_can_modify']) && $_SESSION['settings']['anyone_can_modify'] == 1) {
     if ($record['anyone_can_modify'] == 1) {
         $html .= '<i class="fa fa-pencil fa-sm mi-grey-1 tip" title="' . $LANG['item_menu_collab_enable'] . '"></i>&nbsp;&nbsp;';
     }
 }
 // display quick icon shortcuts ?
 if (isset($_SESSION['settings']['copy_to_clipboard_small_icons']) && $_SESSION['settings']['copy_to_clipboard_small_icons'] == 1) {
Example #23
0
 function pdf_html_from_link($link)
 {
     for ($ii = 1; $ii < $link->br; $ii++) {
         $suffix .= "\n";
     }
     $html = isUTF8($link->label) ? utf8_decode($link->label) . $suffix : $link->label . $suffix;
     return $html;
 }
Example #24
0
 function create_page()
 {
     global $_CAMILA;
     require_once CAMILA_LIB_DIR . 'xml-2-pdf/Xml2Pdf.php';
     require_once CAMILA_LIB_DIR . 'minitemplator/MiniTemplator.class.php';
     $xmlfile = CAMILA_TMPL_DIR . '/' . $_CAMILA['lang'] . '/' . $_REQUEST['camila_xml2pdf'];
     $xml = '';
     $t = new MiniTemplator();
     $t->readTemplateFromFile($xmlfile);
     if ($_REQUEST['camila_xml2pdf_checklist_options_0'] != 'y') {
         $format = camila_get_locale_date_adodb_format();
         $text = date($format);
         $t->setVariable(camila_get_translation('camila.export.template.date'), isUTF8($text) ? utf8_decode($text) : $text, true);
         $text = date($format . ' H:i');
         $t->setVariable(camila_get_translation('camila.export.template.timestamp'), isUTF8($text) ? utf8_decode($text) : $text, true);
     }
     $i = 0;
     while (isset($this->element[$i])) {
         $page_element = $this->element[$i];
         switch ($page_element->get_elementtype()) {
             case HAW_FORM:
                 $i = 0;
                 while (isset($page_element->element[$i])) {
                     $form_element = $page_element->element[$i];
                     $form_fieldname = substr($form_element->name, strlen($_CAMILA['datagrid_form']->name) + 1);
                     $form_label = $_CAMILA['datagrid_form']->fields[$form_fieldname]->title;
                     switch ($form_element->get_elementtype()) {
                         //case HAW_IMAGE:
                         //case HAW_RADIO:
                         //case HAW_RULE:
                         case HAW_HIDDEN:
                         case HAW_INPUT:
                         case HAW_TEXTAREA:
                             $text = html_entity_decode($form_element->value);
                             for ($ii = 0; $ii < $form_element->br - 1; $ii++) {
                                 $text .= "\n";
                             }
                             $t->setVariable($form_element->label, isUTF8($text) ? utf8_decode($text) : $text, true);
                             $t->setVariable($form_label, isUTF8($text) ? utf8_decode($text) : $text, true);
                             break;
                         case HAW_SELECT:
                             foreach ($form_element->options as $key => $value) {
                                 if ($value['value'] == $form_element->value) {
                                     $text = $value['label'];
                                 }
                             }
                             $text = html_entity_decode($text);
                             $t->setVariable($form_element->label, isUTF8($text) ? utf8_decode($text) : $text, true);
                             $t->setVariable($form_label, isUTF8($text) ? utf8_decode($text) : $text, true);
                             break;
                         case HAW_CHECKBOX:
                             if (!$form_element->is_checked()) {
                                 break;
                             }
                             //$text = html_entity_decode($form_element->label);
                             $nl = 1;
                             if ($form_element->br > 0) {
                                 $nl = $form_element->br;
                             }
                             for ($ii = 0; $ii < $nl; $ii++) {
                                 $text .= "\n";
                             }
                             $t->setVariable($form_element->name, isUTF8($text) ? utf8_decode($text) : $text, true);
                             $t->setVariable($form_label, isUTF8($text) ? utf8_decode($text) : $text, true);
                             break;
                         case HAW_PLAINTEXT:
                             break;
                     }
                     $i++;
                 }
                 $t->addBlock('form');
                 break;
             case HAW_PLAINTEXT:
                 if ($this->element[$i]->text == camila_get_translation('camila.nodatafound') && $_CAMILA['datagrid_nodata'] == 1) {
                     $rowsperpage = 0;
                     if ($t->blockExists('row1')) {
                         $rowsperpage = 1;
                         while ($t->blockExists('row' . ($rowsperpage + 1))) {
                             $rowsperpage++;
                         }
                         if ($rowsperpage > 0) {
                             for ($ii = 0; $ii < $rowsperpage; $ii++) {
                                 $t->addBlock('row' . ($ii + 1));
                             }
                             $t->addBlock('table');
                         }
                     }
                 }
                 break;
             case HAW_LINK:
                 $link = $this->element[$i];
                 for ($ii = 0; $ii < $link->br; $ii++) {
                     $suffix .= "\n";
                 }
                 //$this->pdf_text(isUTF8($link->label) ? utf8_decode($link->label).$suffix : $link->label.$suffix);
                 break;
             case HAW_TABLE:
                 $table = $this->element[$i];
                 $cols = array();
                 $rowsperpage = 0;
                 $rownum = 1;
                 $pagnum = 1;
                 $multitable = false;
                 if ($t->blockExists('row1')) {
                     $multitable = true;
                     $rowsperpage = 1;
                     while ($t->blockExists('row' . ($rowsperpage + 1))) {
                         $rowsperpage++;
                     }
                 }
                 if ($_REQUEST['camila_xml2pdf_checklist_options_0'] != 'y') {
                     $row = $table->row[0];
                     for ($b = 0; $b < $row->number_of_columns; $b++) {
                         $column = $row->column[$b];
                         $cols[$b] = strtolower($column->text);
                     }
                     $t->setVariable(camila_get_translation('camila.xml2pdf.table.totalrows'), intval($table->number_of_rows) - 1);
                     for ($a = 1; $a < $table->number_of_rows; $a++) {
                         $row = $table->row[$a];
                         for ($b = 0; $b < $row->number_of_columns; $b++) {
                             $column = $row->column[$b];
                             if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                                 $text = $column->get_text();
                             }
                             if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                                 $text = $column->get_label();
                             }
                             $t->setVariable($cols[$b], isUTF8($text) ? utf8_decode($text) : $text, true);
                             $t->setVariable(camila_get_translation('camila.xml2pdf.table.row.num'), $a);
                         }
                         if (!$multitable) {
                             $t->addBlock('row');
                         } else {
                             $t->addBlock('row' . $rownum);
                         }
                         $rownum++;
                         if ($rownum > $rowsperpage) {
                             $rownum = 1;
                             $pagnum++;
                             $t->addBlock('table');
                         }
                     }
                     if (!$multitable || $rownum > 1 && $rownum <= $rowsperpage || $multitable && $pagnum == 1) {
                         $t->addBlock('table');
                     }
                 } else {
                     if ($rowsperpage > 0) {
                         for ($ii = 0; $ii < $rowsperpage; $ii++) {
                             $t->addBlock('row' . ($ii + 1));
                         }
                         $t->addBlock('table');
                     }
                 }
                 $a = 1;
                 $row = $table->row[$a];
                 for ($b = 0; $b < $row->number_of_columns; $b++) {
                     $column = $row->column[$b];
                     if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) {
                         $text = $column->get_text();
                     }
                     if (is_object($column) && $column->get_elementtype() == HAW_LINK) {
                         $text = $column->get_label();
                     }
                     $t->setVariable($cols[$b], isUTF8($text) ? utf8_decode($text) : $text, true);
                     $t->setVariable(camila_get_translation('camila.xml2pdf.table.row.num'), $a);
                 }
                 break;
         }
         $i++;
     }
     $t->generateOutputToString($xml);
     $obj = new Xml2Pdf($xml);
     $pdf = $obj->render();
     $pdf->Output($this->title . '.pdf', 'D');
 }
<?php

if ($match_entry->id_entry_subtype == 'print-value') {
    if ($mode_cxml && !$mode_jidonly) {
        if (!$bool_buffer_output_merge) {
            if (!isUTF8($this_value)) {
                // TODO: WHAT IF THIS WAS BINARY RESULT CONTENT?
                echo mb_convert_encoding($this_value, "UTF-8");
            } else {
                echo $this_value;
            }
        }
    }
    // mode cxml
}
// IF PRINT VALUE OUTPUT SUBTYPE
Example #26
0
function camila_error_text($msg)
{
    global $_CAMILA;
    if (is_object($_CAMILA['page'])) {
        //if (camila_isUTF8($msg))
        //    $msg=utf8_decode($msg);
        if (!isUTF8($msg)) {
            $msg = utf8_encode($msg);
        }
        $text = new CHAW_text($msg, HAW_TEXTFORMAT_BOLD);
        $text->set_color('red');
        $text->set_br(2);
        $msg = str_replace("\n", '\\n', $msg);
        $_CAMILA['page']->add_text($text);
        $_CAMILA['page']->camila_add_js("<script type=\"text/javascript\">\n");
        $_CAMILA['page']->camila_add_js("  camila_addDOMLoadEvent ( function()\n");
        $_CAMILA['page']->camila_add_js("  {alert ('" . str_replace("'", "\\'", $msg) . "') })");
        $_CAMILA['page']->camila_add_js("</script>\n");
    } else {
        echo $msg;
    }
}
Example #27
0
 function rtf_formatting_from_link($link)
 {
     $suffix = '';
     for ($ii = 0; $ii < $link->br; $ii++) {
         $suffix .= "\\par ";
     }
     $code = isUTF8($link->label) ? utf8_decode($link->label) . $suffix : $link->label . $suffix;
     return $code;
 }
Example #28
0
 function strtolower_utf8($string)
 {
     if (isUTF8($string)) {
         $string = utf8_encode($string);
     }
     return mb_strtolower($string, 'UTF-8');
 }
 function is_configuration_sheet($data, $sheetnum)
 {
     $confCell = utf8_encode($data->val(17, 1, $sheetnum));
     $text = camila_get_translation('camila.worktable.configuration');
     if (!isUTF8($text)) {
         $text = utf8_encode($text);
     }
     return $confCell == $text;
 }
Example #30
0
function ztag_lib_readHTTP($strURL)
{
    $objCURL = curl_init();
    curl_setopt($objCURL, CURLOPT_URL, $strURL);
    curl_setopt($objCURL, CURLOPT_RETURNTRANSFER, 1);
    // curl_setopt($objCURL, CURLOPT_HEADER, 1);
    // curl_setopt($objCURL, CURLINFO_HEADER_OUT, 1);
    curl_setopt($objCURL, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)");
    // curl_setopt($objCURL, CURLOPT_COOKIE, "FGTServer=34B68E04678B6417793617BE38F54F47B3BBFF47; __utma=60534895.122979554.1255118786.1266121550.1266123845.13; __utmz=60534895.1266020117.10.3.utmcsr=stf.gov.br|utmccn=(referral)|utmcmd=referral|utmcct=/portal_stj/; ASPSESSIONIDSQBRSDCQ=BLCIHAPCFDAHJLEACAFCNBNJ; __utmc=60534895; ASPSESSIONIDSSARQACQ=DDCNCAPCNJNBJHDPPFPJCCEK; ASPSESSIONIDSQAQTCDQ=NFDCHLIDEIMEAAJNPFIJFHDB; ASPSESSIONIDSSCRTCBQ=PJIFCLIDNJLIHCOJGLHHLBJE; ASPSESSIONIDSQBSRBCQ=HLJGGFLDINBPGOECFNLGPMJA; __utmb=60534895.4.10.1266123845" );
    $strResult = curl_exec($objCURL);
    if (!$strResult) {
        $strResult = "<br /><b>Curl error</b>: " . curl_error($objCURL);
    }
    // $arrURL = curl_getinfo($objCURL);
    // echo "<br />http_code=".$arrURL["http_code"];
    // echo "<br />content_type=".v["content_type"];
    if (isUTF8($strResult)) {
        $strResult = utf8_decode($strResult);
    }
    return $strResult;
}