Beispiel #1
0
Datei: lib.php Projekt: 0-php/AI
function understanding($input, $db)
{
    $output = '';
    $action = '';
    //Initial check (mainly for size)
    $input_params = text_parameters($input);
    //If input is correct, eval hardcoded commands
    $hard = hardcoded($input, $db);
    if ($hard != FALSE) {
        $type = 'Hardcoded';
        $output .= addslashes($hard['output']);
        if ($hard['out_type'] == 'append') {
            $method = 'append';
        } else {
            $method = 'html';
        }
        $action = "\$('#" . $hard['element'] . "')." . $method . "('" . $output . "')";
    } else {
        $output .= 'Input: <b>' . $input . '</b><br>';
        //In case we're done work already and cached it
        $meaning = check_cache_for_input($input);
        //Sanitize from common errors of transmitting data in computer systems
        $meaning = sanitize($meaning);
        //Make sure nothing in input will threaten system in any way. Output is code, ready to execute
        $input_secured = secure_data($meaning);
        //Determining data type, content type
        $input_types = typification($meaning);
        //Create simplified version in case of too complex input can slow down understanding
        $input_simplified = simplify($meaning, $input_types);
        $types = get_main_types($input_types);
        if ($types === FALSE) {
            //Can't be
            die("Unknown type of input. Something really wrong");
        }
        $results = array();
        foreach ($types as $type) {
            //echo $type;
            $results[] = output_mapping($input, $type);
        }
        $best_result = best_result($results);
        $output .= 'Input type: ' . $best_result['type'] . '<br><br>Output:<br><br>';
        $output .= "<b>" . $best_result['output'] . "</b><br><br>";
        $action = "\$('#output').append('" . $output . "');";
    }
    return array('output' => $output, 'action' => $action);
}
Beispiel #2
0
// console output
echo "<pre>";
print_r($vod);
echo "</pre>";
// store simplified record
$vod = JSON_encode($vod);
file_put_contents('cache/vod.json', $vod);
/* trends */
// fetch and store raw trends data
$trends = fetch('trends');
file_put_contents('cache/trends-raw.json', $trends);
// simplify product records
$records = JSON_decode($trends)->items;
$items = array();
foreach ($records as &$item) {
    $items[] = simplify($item);
}
// store complete simplified trends records
file_put_contents('cache/trends.json', JSON_encode($items));
// tranche simplified trends records
$slice = array_slice($items, 0, 8);
// console output
echo "<pre>";
print_r($slice);
echo "</pre>";
// store simplifed trend record tranche
$slice = JSON_encode($slice);
file_put_contents('cache/trends-top.json', $slice);
/* payload data */
$payload = "{\n" . '"categories": ' . $categories . ",\n" . '"vod": ' . $vod . ",\n" . '"trends": ' . $slice . "\n" . '}';
echo "<hr>";
         $result = infix($firststep['left']) . " = " . infix($firststep['right']);
         echo json_encode(array('result' => $result, 'finalAnswer' => false));
         return "";
     }
     $eq['left'] = analyze($firststep['left'], 'left');
     $eq['right'] = analyze($firststep['right'], 'right');
     $eq['left'] = array_pop($eq['left']);
     $eq['right'] = array_pop($eq['right']);
     // var_dump($eq);
     // var_dump($firststep);
     if ($eq != $firststep) {
         $result = $eq['left'] . "=" . $eq['right'];
         echo json_encode(array('result' => $result, 'finalAnswer' => false));
         return "";
     }
     $result = simplify($eq['left'], $eq['right']);
     if ($result != $eq['right']) {
         $answer = "x = " . $result;
         $data = array('result' => $answer, 'finalAnswer' => true);
         echo json_encode($data);
     }
 } else {
     $ctr = 0;
     $equationSteps = 0;
     $givenSteps = 0;
     $lowestTerm = false;
     $equations = array($given, $expr);
     foreach ($equations as $expr) {
         $distribute = array();
         $leftToRight = array();
         $rightToLeft = array();
Beispiel #4
0
 if (preg_match_all("/[X]\\^(10)|(20)/", $argv[1], $check2)) {
     echo "The polynomial degree is stricly greater than 2, I can't solve.\n";
     exit;
 }
 $first = explode("=", $argv[1]);
 $first[0] = simplify($first[0], 0);
 echo "degree 0 left side of the equation simplification:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first[0] = simplify($first[0], 1);
 echo "degree 1 left side of the equation simplification:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first[0] = simplify($first[0], 2);
 echo "degree 2 left side of the equation simplification:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first[1] = simplify($first[1], 0);
 echo "degree 0 right side of the equation simplification:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first[1] = simplify($first[1], 1);
 echo "degree 1 right side of the equation simplification:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first[1] = simplify($first[1], 2);
 echo "degree 2 right side of the equation simplification:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first = transfert($first[0], $first[1], 0);
 if (!isset($first[1])) {
     $first[1] = "0";
 }
 echo "degree 0 transfert:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first = transfert($first[0], $first[1], 1);
 if (!isset($first[1])) {
     $first[1] = "0";
 }
 echo "degree 1 transfert:\n                                                                 " . $first[0] . " = " . $first[1] . "\n";
 $first = transfert($first[0], $first[1], 2);
 if (!isset($first[1]) || !empty($first[1])) {
     $first[1] = "0";
 }
Beispiel #5
0
function comments($id, $root = '')
{
    global $_PERSIST, $isauth, $isadmin, $falsecookie, $forgotten;
    $posted = false;
    if ($id[1] == '/') {
        $comments =& $_PERSIST[$id[0]]['subdirs'][substr($id, 2)];
    } else {
        $comments =& $_PERSIST[$id];
    }
    echo '<h3 style="margin-top:100px" id="comments">Commentary</h3>';
    if ($_POST['msg']) {
        if (!($_POST['name'] = trim($_POST['name'])) || strlen($_POST['name']) > 64) {
            echo '<p style="color:red">Error: Name is invalid.</p>';
        }
        if (!$isauth && simplify($_REQUEST['captcha']) != 'machinegun' && simplify($_REQUEST['captcha']) != 'mg') {
            echo '<p style="color:red">Error: Wrong answer.</p>';
        } else {
            if ($isadmin) {
                $comments[] = array('name' => stripslashes($_POST['name']), 'msg' => stripslashes($_POST['msg']), 'time' => time(), 'admin' => true);
            } else {
                $comments[] = array('name' => stripslashes($_POST['name']), 'msg' => stripslashes($_POST['msg']), 'time' => time());
            }
            if (persist_update()) {
                $posted = true;
            } else {
                echo '<p style="color:red">Error: Internal server error. Please try again later.</p>';
            }
        }
    } else {
        if ($_POST['remember'] && !$isauth && simplify($_REQUEST['captcha']) != 'machinegun' && simplify($_REQUEST['captcha']) != 'mg') {
            echo '<p class="msg" style="color:red">Error: Wrong answer.</p>';
        }
    }
    if ($comments) {
        foreach ($comments as $i => $comment) {
            if (count($comments) > 10 && $i == 0) {
                echo '<div id="morecomments">';
            }
            if (count($comments) > 10 && $i == count($comments) - 10) {
                ?>
</div>
<script type="text/javascript">
<!--
document.getElementById('morecomments').style.display = 'none';
document.write('<p class="backforward" id="morecommentslink" style="text-align: left;"><a href="#comments" onclick="return morecomments();">Earlier comments</a></p>');
function morecomments()
{
	document.getElementById('morecomments').style.display = 'block';
	document.getElementById('morecommentslink').style.display = 'none';
	return false;
}
-->
</script>
<?php 
            }
            echo '<p><em><strong>' . htmlspecialchars($comment['name']) . '</strong>' . ($comment['admin'] ? ' <span style="color:#556688;font-size:10pt;">[Admin]</span>' : '') . ' wrote ' . onreldate($comment['time']) . ':</em></p><blockquote><p>' . ($comment['htmlcomment'] ? $comment['msg'] : nl2br(htmlspecialchars($comment['msg']))) . '</p></blockquote>';
        }
    } else {
        echo '<p><em>No comments yet.</em></p>';
    }
    echo '<h4>Add a comment</h4>';
    if ($posted) {
        echo '<p class="msg">Success!</p>';
    }
    echo '<form action="' . $root . (tourl($id) == 'index' ? './' : tourl($id)) . '#comments" method="post" onsubmit="if (!document.getElementById(\'captcha\').value) {alert(\'Please answer the question. (Hint: The answer is machinegun)\');return false;}"><p id="testparagraph">Name:<br /><input type="text" class="textbox" name="name" value="' . ($_POST['name'] ? $_POST['name'] : $_COOKIE['name']) . '" size="20" /> <input type="checkbox" name="remember" id="remember" value="remember"' . ($_COOKIE['name'] ? ' checked="checked" />' : ' />') . '<label for="remember">Remember name</label><br />Message:<br /><textarea class="textbox" id="msg" name="msg" rows="8" cols="40">' . ($posted ? '' : $_REQUEST['msg']) . '</textarea><br />' . ($isauth && $_COOKIE['name'] && !$falsecookie || $isadmin ? '' : 'To prove you are not a spammer, you must correctly answer this question:<br />The first weapon you get in the single-player campaign is?<br /><input class="textbox" type="text" name="captcha" id="captcha" value="' . ($isauth ? 'machinegun' : $_REQUEST['captcha']) . '" /><br />(<em>Hint: The answer is machinegun</em>)<br />') . '<br /><input type="submit" value="Submit" /></p></form>';
    ?>
<script>
<!--
document.getElementById('msg').style.width = ''+(document.getElementById('testparagraph').offsetWidth-10>650?650:document.getElementById('testparagraph').offsetWidth-10)+'px';
if (document.getElementById('testparagraph').offsetWidth-10>650) document.getElementById('msg').style.height = '200px';
-->
</script>
<?php 
    if ($forgotten) {
        echo '<p class="msg">Your name has been forgotten.</p>';
    }
    if ($_COOKIE['name']) {
        echo '<form action="' . $root . (tourl($id) == 'index' ? './' : tourl($id)) . '#comments" method="post"><input type="submit" class="small" name="forget" value="Forget name" /></form>';
    }
}
Beispiel #6
0
<?php

$prices = simplify(load_tone_data('devices')->get(), 'cost', 'type');
$forms_steps = simplify(load_tone_data('forms')->get(), 'post_id', 'step');
$first_step_post = get_post($forms_steps->FIRST);
$second_step_post = get_post($forms_steps->SECOND);
?>
<script src="<?php 
bloginfo('stylesheet_directory');
?>
/js/consistency_checker.js"></script>
<script>
	var $j = jQuery.noConflict();
	$j(function(){
		var prices = <?php 
echo json_encode($prices);
?>
;

		function calcCosts(phones_qty) {
			var costs = {
				"phone_system": prices.PBX*1 + phones_qty*prices.PHONE,
				"installation": prices.INSTALLATION*1
			};
			costs.total = costs.phone_system + costs.installation;
			
			return costs;
		}
		
		function setCosts(costs) {
			$j('#phone-system-cost').html(costs.phone_system);
function iterate_simplify($points, $max)
{
    if (count($points) <= $max) {
        return $points;
    }
    //echo 'Reducing points (max='.$max.') from '.count($points);
    $min = round($max * 0.9);
    $tolerance = 1.0E-5;
    $tol1 = 0;
    $tol2 = 0;
    $steps = 0;
    while ($steps++ < 10) {
        $p = simplify($points, $tolerance);
        $cnt = count($p);
        if ($cnt > $max) {
            $tol1 = $tolerance;
            $tolerance = $tol2 < $tolerance ? $tolerance * 2 : ($tolerance + $tol2) / 2;
        } elseif ($cnt < $min) {
            $tol2 = $tolerance;
            $tolerance = ($tol1 + $tolerance) / 2;
        } else {
            break;
        }
    }
    //echo ' to '.count($p).' ('.$steps.' iterations)<br>';
    return $p;
}
Beispiel #8
0
    for ($i = 0; $i < $len; $i++) {
        if ($markers[$i]) {
            array_push($newPoints, $points[$i]);
        }
    }
    return $newPoints;
}
$tolerance = array_key_exists(2, $_SERVER['argv']) ? floatval($_SERVER['argv'][2]) : 0.001;
$json = json_decode(file_get_contents($_SERVER['argv'][1]));
foreach ($json->features as $feature_id => $feature) {
    $geometry = $feature->geometry;
    if ($geometry->type == 'MultiPolygon') {
        foreach ($geometry->coordinates as $coordinate_id => $polygons) {
            foreach ($polygons as $polygon_id => $points) {
                $tmp_points = array();
                foreach ($points as $point) {
                    $tmp_points[] = array('x' => $point[0], 'y' => $point[1]);
                }
                $simplify_points = @simplify($tmp_points, $tolerance, true);
                $simplify_polygon = array();
                foreach ($simplify_points as $point) {
                    $simplify_polygon[] = array($point['x'], $point['y']);
                }
                $json->features[$feature_id]->geometry->coordinates[$coordinate_id][$polygon_id] = $simplify_polygon;
            }
        }
    } else {
        throw new Exception('test');
    }
}
echo json_encode($json, JSON_UNESCAPED_UNICODE);
Beispiel #9
0
function build_title()
{
    global $site_name, $page_display_name, $page_type, $s, $m, $x, $p;
    // will probably need support for child pages!
    if ($page_type == 'dynamic' && $m == 'permalink') {
        $post_title = safe_field('title', 'pixie_dynamic_posts', "post_slug = '{$x}'");
        if ($post_title) {
            echo "{$site_name} - {$page_display_name} - {$post_title}";
        } else {
            echo "{$site_name}";
            /* escaping other language characters can cause an error. */
        }
    } else {
        if ($m == 'tag') {
            if ($p) {
                echo "{$site_name} - {$page_display_name} - Tag - " . simplify(squash_slug($x)) . " - Page {$p}";
            } else {
                echo "{$site_name} - {$page_display_name} - Tag - " . simplify(squash_slug($x));
            }
        } else {
            if ($m == 'page') {
                echo "{$site_name} - {$page_display_name} - " . simplify($m) . " " . simplify($x);
            } else {
                if ($m) {
                    echo "{$site_name} - {$page_display_name} - " . simplify($m);
                } else {
                    echo "{$site_name} - {$page_display_name}";
                }
            }
        }
    }
}
Beispiel #10
0
function db_dropdown($table, $current, $name, $condition)
{
    global $edit, $go;
    $table = adjust_prefix($table);
    $rs = safe_query("select * from {$table} where {$condition}");
    $num = mysql_num_rows($rs);
    $i = 0;
    echo "\t\t\t\t\t\t\t\t<select class=\"form_select\" name=\"{$name}\" id=\"{$name}\">\n";
    if (!$current && isset($go) && $go == 'new') {
        echo "\t\t\t\t\t\t\t\t\t<option selected=\"selected\" value=\"NULL\">-</option>\n";
    } else {
        if ($current === NULL && isset($edit) && $edit) {
            echo "\t\t\t\t\t\t\t\t\t<option selected=\"selected\" value=\"NULL\">-</option>\n";
        } else {
            if (isset($edit) && $edit) {
                echo "\t\t\t\t\t\t\t\t\t<option value=\"NULL\">-</option>\n";
            }
        }
    }
    while ($i < $num) {
        $F = mysql_fetch_array($rs);
        for ($j = 0; $j < mysql_num_fields($rs); $j++) {
            if (last_word(mysql_field_name($rs, $j)) == 'id') {
                $id = simplify($F[$j]);
            } else {
                $fieldname = $F[1];
            }
        }
        if ($current == $id) {
            print "\t\t\t\t\t\t\t\t\t<option selected=\"selected\" value=\"{$id}\">{$fieldname}</option>\n";
        } else {
            print "\t\t\t\t\t\t\t\t\t<option value=\"{$id}\">{$fieldname}</option>\n";
        }
        $i++;
    }
    echo "\t\t\t\t\t\t\t\t</select>";
}
Beispiel #11
0
 function ShowBody()
 {
     global $edit, $s, $m, $x, $page, $page_display_name, $lang, $type;
     // check $edit against $x - they need to represent the same page, if not redirect.
     $checkid = safe_field('page_id', 'pixie_core', "page_name='{$x}'");
     if (isset($edit) && $edit && $m == 'static') {
         if ($edit != $checkid) {
             echo "<div class=\"helper\"><h3>" . $lang['help'] . "</h3><p>" . $lang['unknown_edit_url'] . "</p></div>";
             $cancel = TRUE;
         }
     }
     if (isset($cancel)) {
     } else {
         $cancel_not_set = 1;
     }
     if ($cancel_not_set == 1) {
         $Nams = explode('|', substr($this->Nam, 0, strlen($this->Nam) - 1));
         $Type = explode('|', substr($this->Typ, 0, strlen($this->Typ) - 1));
         $Leng = explode('|', substr($this->Len, 0, strlen($this->Len) - 1));
         $Flag = explode('|', substr($this->Flg, 0, strlen($this->Flg) - 1));
         $Fild = explode('|', substr($this->Res, 0, strlen($this->Res) - 1));
         if (!$page) {
             $page = 1;
         }
         if (isset($s) && $s == 'settings') {
             if (strpos($this->tablename, 'module')) {
                 $formtitle = $lang['advanced'] . " " . $lang['page_settings'];
             } else {
                 if (strpos($this->tablename, 'dynamic')) {
                     $formtitle = $lang['advanced'] . " " . $lang['page_settings'];
                 } else {
                     $formtitle = $lang['page_settings'];
                 }
             }
         } else {
             if (isset($edit) && $edit) {
                 if ($m == 'static') {
                     $formtitle = $lang['edit'] . " {$page_display_name} " . $lang['settings_page'];
                 } else {
                     $formtitle = $lang['edit'] . " {$page_display_name} " . str_replace('.', "", $lang['entry']) . " (#{$edit})";
                 }
             } else {
                 $formtitle = $lang['new_entry'] . " {$page_display_name} " . str_replace('.', "", $lang['entry']);
             }
         }
         if (isset($s) && $s == 'settings') {
             $post = "?s={$s}&amp;x={$x}";
         } else {
             if ($m == 'static' && isset($edit)) {
                 $post = "?s={$s}&amp;m={$m}&amp;x={$x}&amp;edit={$edit}&amp;page={$page}";
             } else {
                 $post = "?s={$s}&amp;m={$m}&amp;x={$x}&amp;page={$page}";
             }
         }
         echo "<form accept-charset=\"UTF-8\" action=\"{$post}\" method=\"post\" id=\"form_addedit\" class=\"form\">\n";
         echo "\t\t\t\t\t\t<fieldset>\n\t\t\t\t\t\t<legend>{$formtitle}</legend>\n";
         echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"table_name\" value=\"{$this->tablename}\" maxlength=\"80\" />\n";
         for ($j = 0; $j < count($Nams); $j++) {
             // clears out the form as some of the fields populate
             if (!isset($edit) or !$edit) {
                 $Fild[$j] = "";
             }
             // if comments are disabled then hide the field
             if ($Nams[$j] == 'comments' && !public_page_exists('comments')) {
                 echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"no\" maxlength=\"" . $Leng[$j] . "\" />\n";
                 $j++;
             }
             if (!in_array($Nams[$j], $this->exclude)) {
                 //fields populated and output depending on type etc.
                 //$searchfor = "_".first_word($Nams[$j]);
                 if ($Leng[$j] < 40) {
                     $ln = $Leng[$j];
                 } else {
                     if ($Leng[$j] <= 400) {
                         $ln = 50;
                     }
                 }
                 $nullf = explode(" ", $Flag[$j]);
                 if ($nullf[0] == 'not_null') {
                     // label required fields
                     if (isset($lang['form_' . $Nams[$j]])) {
                         if ($Nams[$j] != 'page_name' or $type == 'static' or !isset($edit) or !$edit) {
                             /* Prevents the editing of page_name which does not work in modules and dynamic pages */
                             $displayname = $lang['form_' . $Nams[$j]] . " <span class=\"form_required\">" . $lang['form_required'] . "</span>";
                         } else {
                             $displayname = " <span style=\"display:none\" class=\"form_required\">" . $lang['form_required'] . "</span>";
                         }
                     } else {
                         $displayname = simplify($Nams[$j]) . " <span class=\"form_required\">" . $lang['form_required'] . "</span>";
                     }
                 } else {
                     if (isset($lang['form_' . $Nams[$j]]) && $lang['form_' . $Nams[$j]]) {
                         $displayname = $lang['form_' . $Nams[$j]] . " <span class=\"form_optional\">" . $lang['form_optional'] . "</span>";
                     } else {
                         $displayname = simplify($Nams[$j]) . " <span class=\"form_optional\">" . $lang['form_optional'] . "</span>";
                     }
                 }
                 // check language file for any form help
                 if (isset($lang['form_help_' . $Nams[$j]]) && $lang['form_help_' . $Nams[$j]]) {
                     if ($Nams[$j] != 'page_name' or $type == 'static' or !isset($edit) or !$edit) {
                         /* Prevents the editing of page_name which does not work in modules and dynamic pages */
                         $form_help = "<span class=\"form_help\">" . $lang['form_help_' . $Nams[$j]] . "</span>";
                     } else {
                         $form_help = "<span style=\"display:none\" class=\"form_help\">" . $lang['form_help_' . $Nams[$j]] . "</span>";
                     }
                 } else {
                     $form_help = "";
                 }
                 if ($GLOBALS['rich_text_editor'] == 1) {
                     $containsphp = strlen(stristr(utf8_decode($Fild[$j]), '<?php')) > 0;
                     if ($containsphp) {
                         $form_help .= " <span class=\"alert\">" . $lang['form_php_warning'] . '</span>';
                     }
                 }
                 echo "\t\t\t\t\t\t\t<div class=\"form_row\">\n\t\t\t\t\t\t\t\t<div class=\"form_label\">\n\t\t\t\t\t<label for=\"{$Nams[$j]}\">" . $displayname . "</label>{$form_help}</div>\n";
                 //$Type[$j] $Leng[$j] $Flag[$j] for field info
                 //echo "$Nams[$j] - $Type[$j] - $Leng[$j] - $Flag[$j]"; // see form field properties
                 if ($Type[$j] == 'timestamp' && !isset($edit) && !$edit) {
                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n";
                     if (isset($date)) {
                         date_dropdown($date);
                     } else {
                         $date = NULL;
                         date_dropdown($date);
                     }
                     echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                 } else {
                     if ($Type[$j] == 'timestamp' && isset($edit) && $edit) {
                         echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n";
                         date_dropdown($Fild[$j]);
                         echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                         //} else if ($Type[$j] == "blob") {
                         //	echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea\">\n\t\t\t\t\t\t\t\t<textarea name=\"$Nams[$j]\" class=\"form_item_textarea_no_ckeditor\">$Fild[$j]</textarea>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                     } else {
                         if ($Type[$j] == 'longtext' or $Leng[$j] > 800 or $Type[$j] == 'blob') {
                             if ($GLOBALS['rich_text_editor'] == 1) {
                                 if (!$containsphp) {
                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea_ckeditor\">\n\t\t\t\t\t\t\t\t\t\t<textarea name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" cols=\"50\" class=\"ck-textarea\" rows=\"10\">" . htmlentities($Fild[$j], ENT_QUOTES, 'UTF-8') . "</textarea>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n";
                                     // id=\"$Nams[$j]\"
                                 } else {
                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea\">\n\t\t\t\t\t\t\t\t<textarea name=\"{$Nams[$j]}\" class=\"form_item_textarea_no_ckeditor\">" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "</textarea>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                     // id=\"$Nams[$j]\"
                                 }
                             } else {
                                 echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea\">\n\t\t\t\t\t\t\t\t<textarea name=\"{$Nams[$j]}\" class=\"form_item_textarea_no_ckeditor\">" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "</textarea>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                 // id=\"$Nams[$j]\"
                             }
                         } else {
                             if ($Type[$j] == "set'yes','no'" or $Flag[$j] == 'not_null set') {
                                 if ($Fild[$j] == 'no') {
                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_radio\">\n\t\t\t\t\t\t\t\tYes<input type=\"radio\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" class=\"form_radio\" value=\"yes\" />\n\t   \t\t\t\t\t\t     \tNo<input checked=\"checked\" type=\"radio\" name=\"{$Nams[$j]}\" class=\"form_radio\" value=\"{$Fild[$j]}\" />\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t</div>\n";
                                 } else {
                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_radio\">\n\t\t\t\t\t\t\t\tYes<input checked=\"checked\" type=\"radio\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" class=\"form_radio\" value=\"yes\" />\n\t   \t\t\t\t\t\t     \tNo<input type=\"radio\" name=\"{$Nams[$j]}\" class=\"form_radio\" value=\"no\"/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                 }
                             } else {
                                 if (first_word($Nams[$j]) == 'image') {
                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop image_preview\">\n";
                                     db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Image' order by file_id desc");
                                     echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                 } else {
                                     if (first_word($Nams[$j]) == 'document') {
                                         echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n";
                                         db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Other' order by file_id desc");
                                         echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                     } else {
                                         if (first_word($Nams[$j]) == 'video') {
                                             echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n";
                                             db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Video' order by file_id desc");
                                             echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                         } else {
                                             if (first_word($Nams[$j]) == 'audio') {
                                                 echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n";
                                                 db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Audio' order by file_id desc");
                                                 echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                             } else {
                                                 if (first_word($Nams[$j]) == 'file') {
                                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n";
                                                     db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_id >= '0' order by file_id desc");
                                                     echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                                 } else {
                                                     if ($Nams[$j] == 'tags') {
                                                         $tableid = 0;
                                                         $condition = $tableid . " >= '0'";
                                                         form_tag($this->tablename, $condition);
                                                         echo "\t\t\t\t\t\t\t\t<div class=\"form_item\">\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" size=\"";
                                                         if (isset($ln)) {
                                                             echo $ln;
                                                         } else {
                                                             $ln = 25;
                                                             echo $ln;
                                                         }
                                                         echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                                     } else {
                                                         if ($Nams[$j] == 'page_blocks') {
                                                             form_blocks();
                                                             echo "\t\t\t\t\t\t\t\t<div class=\"form_item\">\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" size=\"";
                                                             if (isset($ln)) {
                                                                 echo $ln;
                                                             } else {
                                                                 $ln = 25;
                                                                 echo $ln;
                                                             }
                                                             echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                                         } else {
                                                             if ($Nams[$j] == 'privs') {
                                                                 if ($Fild[$j] == 2) {
                                                                     $adminclass = "selected=\"selected\"";
                                                                     $everyoneclass = NULL;
                                                                 } else {
                                                                     $everyoneclass = "selected=\"selected\"";
                                                                     $adminclass = NULL;
                                                                 }
                                                                 echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n\t\t\t\t\t\t\t\t\t<select class=\"form_select\" name=\"{$Nams[$j]}\" name=\"{$Nams[$j]}\">\n\t\t\t\t\t\t\t\t\t\t<option value=\"2\" {$adminclass}>Administrators only</option>\n\t\t\t\t\t\t\t\t\t\t<option value=\"1\" {$everyoneclass}>Administrators &amp; Clients</option>\n\t\t\t\t\t\t\t\t\t</select>\n\t   \t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n";
                                                             } else {
                                                                 if ($Nams[$j] != 'page_name' or $type == 'static' or !isset($edit) or !$edit) {
                                                                     /* Prevents the editing of page_name which does not work in modules and dynamic pages */
                                                                     echo "\t\t\t\t\t\t\t\t<div class=\"form_item\">\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "\" size=\"";
                                                                     if (isset($ln)) {
                                                                         echo $ln;
                                                                     } else {
                                                                         $ln = 25;
                                                                         echo $ln;
                                                                     }
                                                                     echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>";
                                                                 } else {
                                                                     echo "\t\t\t\t\t\t\t\t<div style=\"display:none\" class=\"form_item\">\n\t\t\t\t\t\t\t\t<input style=\"display:none\" type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "\" size=\"";
                                                                     if (isset($ln)) {
                                                                         echo $ln;
                                                                     } else {
                                                                         $ln = 25;
                                                                         echo $ln;
                                                                     }
                                                                     echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>";
                                                                 }
                                                                 echo "\n\t\t\t\t\t\t\t</div>\n";
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 //other field types still to come: File uploads...?
                 //hidden fields populated
             } else {
                 if ($Nams[$j] == 'page_id' && isset($s) && $s == 'publish' && $m == 'dynamic') {
                     $page_id = get_page_id($x);
                     echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"{$page_id}\" maxlength=\"" . $Leng[$j] . "\" />\n";
                 } else {
                     if (last_word($Nams[$j]) == 'id') {
                         echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" maxlength=\"" . $Leng[$j] . "\" />\n";
                     } else {
                         if ($Nams[$j] == 'author') {
                             if (isset($edit) && $edit) {
                                 $output = $Fild[$j];
                             } else {
                                 if (!isset($GLOBALS['pixie_user'])) {
                                     $GLOBALS['pixie_user'] = NULL;
                                 }
                                 $output = $GLOBALS['pixie_user'];
                             }
                             echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"" . $output . "\" maxlength=\"" . $Leng[$j] . "\" />\n";
                         } else {
                             if ($Type[$j] == "timestamp") {
                                 echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"" . returnSQLtimestamp(time()) . "\" maxlength=\"" . $Leng[$j] . "\" />\n";
                             } else {
                                 if ($Nams[$j] == 'page_type') {
                                     if ($type) {
                                         $output = $type;
                                     } else {
                                         if (isset($edit)) {
                                             $output = safe_field('page_type', 'pixie_core', "page_id='{$edit}'");
                                         }
                                     }
                                     echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"" . $output . "\" maxlength=\"" . $Leng[$j] . "\" />\n";
                                 } else {
                                     if ($Nams[$j] == 'publish' && !$edit) {
                                         echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"yes\" maxlength=\"0\" />\n";
                                     } else {
                                         if ($Nams[$j] == 'page_content') {
                                             // do nothing
                                         } else {
                                             if ($Nams[$j] == 'admin') {
                                                 // do nothing
                                             } else {
                                                 echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" maxlength=\"" . $Leng[$j] . "\" />\n";
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (isset($edit) && $edit) {
             echo "\t\t\t\t\t\t\t<div class=\"form_row_button\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" name=\"submit_edit\" class=\"form_submit\" value=\"" . $lang['form_button_update'] . "\" />\n\t\t\t\t\t\t\t</div>\n";
         } else {
             if (isset($go) && $go == 'new') {
                 // do a save draft and save button button?? - when everything can be saved as a draft and is autosaved using AJAX
             } else {
                 echo "\t\t\t\t\t\t\t<div class=\"form_row_button\" id=\"form_button\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" name=\"submit_new\" class=\"form_submit\" value=\"" . $lang['form_button_save'] . "\" />\n\t\t\t\t\t\t\t</div>\n";
             }
         }
         if ($m != 'static') {
             echo "\t\t\t\t\t\t\t<div class=\"form_row_button\">\n\t\t\t\t\t\t\t\t<span class=\"form_button_cancel\"><a href=\"?s={$s}&amp;m={$m}&amp;x={$x}\" title=\"" . $lang['form_button_cancel'] . "\">" . $lang['form_button_cancel'] . "</a></span>\n\t\t\t\t\t\t\t</div>\n";
         }
         echo "\t\t\t\t\t\t\t<div class=\"safclear\"></div>\n\t\t\t\t\t\t</fieldset>\n";
         echo "\t\t\t\t\t</form>";
     }
 }