Beispiel #1
0
 function getExpressionTree($expr)
 {
     global $g_sqlSingleRecFuncs;
     $parser = new SqlParser($expr);
     $king_expr = new Expression();
     $current_expr =& $king_expr;
     while (!is_empty_str($elem = $parser->parseNextElementRaw())) {
         // function or IN / NOT IN?
         if (in_array(strtoupper($elem), $g_sqlSingleRecFuncs) || strtoupper($elem) == "IN" || strtoupper($elem) == "NOT IN") {
             $current_expr->expr_str .= $elem . " ";
             $elem = $parser->parseNextElementRaw();
             if ($elem != "(") {
                 print_error_msg("( expected after " . $current_expr->expr_str);
                 return null;
             }
             $current_expr->expr_str .= $elem;
             while (!is_empty_str($elem = $parser->parseNextElementRaw()) && $elem != ")") {
                 $current_expr->expr_str .= $elem;
             }
             $current_expr->expr_str .= $elem . " ";
             continue;
         }
         if ($elem == "(") {
             $current_expr->expr_str .= " % ";
             unset($new_expr);
             $new_expr = new Expression("");
             $current_expr->addChild($new_expr);
             $new_expr->setParent($current_expr);
             unset($current_expr);
             $current_expr =& $new_expr;
         } else {
             if ($elem == ")") {
                 unset($tmp);
                 $tmp =& $current_expr->getParent();
                 unset($current_expr);
                 $current_expr =& $tmp;
             } else {
                 // no spaces on .'s
                 if ($elem == ".") {
                     remove_last_char($current_expr->expr_str);
                     $current_expr->expr_str .= $elem;
                 } else {
                     $current_expr->expr_str .= $elem . " ";
                 }
             }
         }
     }
     return $king_expr;
 }
function uz_image_library_input($label, $input_name, $input_value, $multi = false)
{
    if (is_array($input_value)) {
        $all_images = '';
        foreach ($input_value as $_image) {
            $all_images .= "{$_image},";
        }
        $input_value = remove_last_char($all_images);
    }
    ?>

		<div class="uz_input">

			<label> <?php 
    echo $label;
    ?>
 </label>

			<div class="image-library <?php 
    if ($multi) {
        echo 'multi';
    }
    ?>
 " data-actual="<?php 
    echo $input_value;
    ?>
" data-name="<?php 
    echo $input_name;
    ?>
">

				<div class="inner"> <i class="fa fa-spinner fa-spin"></i> </div>

				<div class="arrows">
					<a href="#" data-go="prev"> <i class="fa fa-angle-up fa-2x"></i> </a>
					<a href="#" data-go="next"> <i class="fa fa-angle-down fa-2x"></i> </a>
				</div>

			</div>

		</div>

	<?php 
}
Beispiel #3
0
 function parseResultSetFromFileForAppend($fd)
 {
     $start = getmicrotime();
     $rs = new ResultSet();
     // COLUMN NAMES
     // read with a maximum of 1000 bytes, until there is a newline included (or eof)
     $buf = "";
     while (is_false(strstr($buf, "\n"))) {
         $buf .= fgets($fd, 1000);
         if (feof($fd)) {
             print_error_msg("Invalid Table File!<br>");
             return null;
         }
     }
     // remove newline
     remove_last_char($buf);
     $rec = $this->parseRowFromLine($buf);
     $rs->setColumnNames($rec);
     // COLUMN TYPES
     // read with a maximum of 1000 bytes, until there is a newline included (or eof)
     $buf = "";
     while (is_false(strstr($buf, "\n"))) {
         $buf .= fgets($fd, 1000);
         if (feof($fd)) {
             print_error_msg("Invalid Table File!<br>");
             return null;
         }
     }
     // remove newline
     remove_last_char($buf);
     $rec = $this->parseRowFromLine($buf);
     $rs->setColumnTypes($rec);
     // COLUMN DEFAULT VALUES
     // read with a maximum of 1000 bytes, until there is a newline included (or eof)
     $buf = "";
     while (is_false(strstr($buf, "\n"))) {
         $buf .= fgets($fd, 1000);
         if (feof($fd)) {
             break;
             // there's no newline after the colum types => empty table
         }
     }
     // remove newline
     if (last_char($buf) == "\n") {
         remove_last_char($buf);
     }
     $rec = $this->parseRowFromLine($buf);
     $rs->setColumnDefaultValues($rec);
     // get file size
     fseek($fd, 0, SEEK_END);
     $size = ftell($fd);
     $lastRecSize = min($size, ASSUMED_RECORD_SIZE);
     $lastRecPos = false;
     while (is_false($lastRecPos)) {
         fseek($fd, -$lastRecSize, SEEK_END);
         $buf = fread($fd, $lastRecSize);
         $lastRecSize = $lastRecSize * 2;
         $lastRecSize = min($size, $lastRecSize);
         if ($lastRecSize < 1) {
             print_error_message("lastRecSize should not be 0! Contact developer please!");
         }
         $lastRecPos = $this->getLastRecordPosInString($buf);
         if (TXTDBAPI_VERBOSE_DEBUG) {
             echo "<hr>pass! <br>";
             echo "lastRecPos: " . $lastRecPos . "<br>";
             echo "buf: " . $buf . "<br>";
         }
     }
     $buf = trim(substr($buf, $lastRecPos));
     verbose_debug_print("buf after substr() and trim(): " . $buf . "<br>");
     $rs->reset();
     $row = $this->parseRowFromLine($buf);
     if (TXTDBAPI_VERBOSE_DEBUG) {
         echo "parseResultSetFromFileForAppend(): last Row:<br>";
         print_r($row);
         echo "<br>";
     }
     $rs->appendRow($row);
     $rs->setColumnAliases(create_array_fill(count($rs->colNames), ""));
     $rs->setColumnTables(create_array_fill(count($rs->colNames), ""));
     $rs->setColumnTableAliases(create_array_fill(count($rs->colNames), ""));
     $rs->setColumnFunctions(create_array_fill(count($rs->colNames), ""));
     $rs->colFuncsExecuted = create_array_fill(count($rs->colNames), false);
     debug_print("<i>III: parseResultSetFromFileForAppend: " . (getmicrotime() - $start) . " seconds elapsed</i><br>");
     return $rs;
 }
Beispiel #4
0
 function parseListTablesQuery()
 {
     $sqlObj = new SqlQuery();
     $sqlObj->type = "LIST TABLES";
     $colNames = array();
     $colTables = array();
     $colAliases = array();
     $fieldValues = array();
     $tables = array();
     $groupColumns = array();
     $orderColumns = array();
     $orderTypes = array();
     $where_expr = "";
     $distinct = 0;
     // parse Where statement (Raw, because the escape-chars are needend in the ExpressionParser)
     if (strtoupper($this->peekNextElement()) == "WHERE") {
         $this->skipNextElement();
         while (!is_empty_str($elem = $this->peekNextElementRaw())) {
             if (strtoupper($elem) == "ORDER" || $elem == ";" || strtoupper($elem) == "LIMIT") {
                 break;
             }
             $this->skipNextElement();
             // no " " on points
             if ($elem == ".") {
                 remove_last_char($where_expr);
                 $where_expr .= $elem;
             } else {
                 $where_expr .= $elem . " ";
             }
         }
     }
     // parse ORDER BY
     $orderColumnIndex = 0;
     if (strtoupper($this->peekNextElement()) == "ORDER") {
         $this->skipNextElement();
         if (strtoupper($this->parseNextElement()) != "BY") {
             print_error_msg("BY expected");
             return null;
         }
         while (!is_empty_str($elem = $this->peekNextElement())) {
             if ($elem == ";" || strtoupper($elem) == "LIMIT") {
                 break;
             }
             $this->skipNextElement();
             if ($elem == ",") {
                 $orderColumnIndex++;
             } else {
                 if (strtoupper($elem) == "ASC") {
                     $orderTypes[$orderColumnIndex] = ORDER_ASC;
                 } else {
                     if (strtoupper($elem) == "DESC") {
                         $orderTypes[$orderColumnIndex] = ORDER_DESC;
                     } else {
                         if (!isset($orderColumns[$orderColumnIndex])) {
                             $orderColumns[$orderColumnIndex] = $elem;
                         } else {
                             $orderColumns[$orderColumnIndex] .= $elem;
                         }
                         $orderTypes[$orderColumnIndex] = ORDER_ASC;
                     }
                 }
             }
         }
     }
     // parse LIMIT
     $limit = array();
     if (strtoupper($this->peekNextElement()) == "LIMIT") {
         $this->skipNextElement();
         while (!is_empty_str($elem = $this->peekNextElement())) {
             if ($elem == ";") {
                 break;
             }
             $this->skipNextElement();
             if ($elem != ",") {
                 $limit[] = $elem;
             }
         }
     }
     $sqlObj = new SqlQuery("LIST TABLES", $colNames, $tables, $colAliases, $colTables, $where_expr, $groupColumns, $orderColumns, $orderTypes, $limit);
     return $sqlObj;
 }
Beispiel #5
0
function remove_quotes(&$str)
{
    $str = substr($str, 1);
    remove_last_char($str);
}