Esempio n. 1
0
function nuBuildTable($J)
{
    $h = '';
    $h .= "<table>";
    $h .= "<tr>";
    $h .= "<th class='id'>ID</th>";
    for ($i = 0; $i < count($J->objects); $i++) {
        $w = $J->objects[$i]->width . 'px';
        $v = $J->objects[$i]->title;
        $h .= "<th class='s{$i}'>{$v}</th>";
    }
    $h .= "</tr>";
    $T = nuRunQuery("SELECT * FROM {$J->records}");
    while ($R = db_fetch_row($T)) {
        $h .= "<tr>";
        $h .= "<td class='id'>" . $R[0] . "</td>";
        for ($i = 0; $i < count($J->objects); $i++) {
            $w = $J->objects[$i]->width . 'px';
            $v = $R[$i + 1];
            $h .= "<td class='s{$i}'>{$v}</td>";
        }
        $h .= "</td>";
        $h .= "</tr>";
    }
    $h .= "</table>";
    return $h;
}
Esempio n. 2
0
 private function nuGetFieldValue($O)
 {
     $type = '';
     $value = '';
     if (strtoupper(substr($O->fieldName, 0, 4)) == 'SUM(') {
         $type = 's';
         $field = substr($O->fieldName, 4, -1);
     }
     if (strtoupper(substr($O->fieldName, 0, 8)) == 'AVERAGE(') {
         $type = 'p';
         $fields = explode(',', substr($O->fieldName, 8, -1));
     }
     if ($type == '') {
         //-- normal value
         //Add the 'is_array' check by SG 8th May 2015
         if (is_array($this->ROW)) {
             if (array_key_exists($O->fieldName, $this->ROW)) {
                 $v = $this->nuGetFormatting($O);
                 $value = mb_convert_encoding($v['V'], "WINDOWS-1252", "UTF-8");
             }
         }
     } else {
         //-- summed value
         $groups = array();
         $where = '';
         if ($type == 'p') {
             $count = 'SUM(nu_sum_' . trim($fields[0]) . ') AS the_sum_a, SUM(nu_sum_' . trim($fields[1]) . ') AS the_sum_b';
         } else {
             $count = 'SUM(nu_sum_' . trim($field) . ') AS the_sum_a';
         }
         for ($i = 3; $i <= $this->group; $i++) {
             $groups[] = $this->LAY->groups[$i]->sortField . " = '" . str_replace("'", "\\'", $this->ROW[$this->LAY->groups[$i]->sortField]) . "'";
             $where = ' WHERE ';
         }
         $sql = "SELECT {$count} FROM {$this->TABLE_ID}" . "_nu_summary {$where} " . implode(' AND ', $groups);
         $t = nuRunQuery($sql);
         $r = db_fetch_row($t);
         if ($r[1] == 0 and $type == 'p') {
             $value = 0;
         } else {
             if ($type == 'p') {
                 //                    $value  = ($r[0] / $r[1]) * 100;
                 $value = $r[0] / $r[1];
             } else {
                 $value = $r[0];
             }
         }
     }
     if ($O->format != '') {
         //-- format value
         $format = nuTextFormats();
         $datatype = $format[$O->format]->type;
         if ($datatype == 'date') {
             if ($value != '0000-00-00' && $value != '') {
                 $value = date($format[$O->format]->phpdate, strtotime($value));
             } else {
                 $value = '';
             }
         }
         if ($datatype == 'number') {
             $value = number_format($value, $format[$O->format]->format, $format[$O->format]->decimal, $format[$O->format]->separator);
         }
     }
     return $value;
 }
<?php

/*
** File:           runCronProcedure_nu2.php
** Author:         nuSoftware
** Created:        2007/04/26
** Last modified:  2009/07/15
**
** Copyright 2004, 2005, 2006, 2007, 2008, 2009 nuSoftware
**
** This file is part of the nuBuilder source package and is licensed under the
** GPLv3. For support on developing in nuBuilder, please visit the nuBuilder
** wiki and forums. For details on contributing a patch for nuBuilder, please
** visit the `Project Contributions' forum.
**
**   Website:  http://www.nubuilder.com
**   Wiki:     http://wiki.nubuilder.com
**   Forums:   http://forums.nubuilder.com
*/
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
$dir = $argv[1];
$report = $argv[2];
include "../{$dir}/database.php";
include 'common.php';
$T = nuRunQuery("SELECT * FROM zzsys_activity WHERE sat_all_code = '{$report}'");
$A = db_fetch_object($T);
eval($A->sat_procedure_code);
Esempio n. 4
0
 private function buildHTMLForSubform($CRLF, $TAB, $fieldName, $fieldTitle, $blankRows, $objectID)
 {
     if (!$this->displayThisObject) {
         return '';
     } else {
         $this->parentForm->subformNames[] = $this->objectProperty['sob_all_name'];
         $this->parentForm->subformTabs[] = $this->parentForm->formTabNames[$this->objectProperty['sob_all_tab_title']];
     }
     $format = textFormatsArray();
     if ($this->objectProperty['sob_all_on_change'] != '') {
         $OnChange = 'onchange="' . $this->objectProperty["sob_all_on_change"] . '" ';
     }
     $this->CRLF = $CRLF;
     $this->TAB = $TAB;
     $hGap = 3;
     //gap between fields
     $vHeight = 23;
     //row height
     $vTitleHeight = $this->objectProperty['sob_subform_title_height'] * 16;
     //row height
     $vTop = 10;
     //row height
     $sfDimensions = array();
     $fldDimensions = array();
     $t = nuRunQuery("SELECT * FROM zzsys_object WHERE sob_zzsys_form_id = '" . $this->objectProperty['zzsys_object_id'] . "' ORDER BY sob_all_column_number, sob_all_order_number");
     while ($r = db_fetch_array($t)) {
         $objectLength = $r['sob_' . $r['sob_all_type'] . '_length'];
         // eg. text objects are 'sob_text_length'
         if ($r['sob_all_type'] == 'lookup') {
             $objectLength = $r['sob_lookup_code_length'];
             // code length
             if ($r['sob_lookup_no_description'] != '1') {
                 $objectLength = $objectLength + 0.5 + $r['sob_lookup_description_length'];
                 // description length
             }
         }
         if ($r['sob_all_type'] == 'text') {
             if ($format[$r['sob_text_format']]->type == 'date') {
                 $objectLength = $objectLength + 1.5;
                 // date button length
             }
         }
         $fldDimensions[$r['sob_all_name']]->type = $r['sob_all_type'];
         $fldDimensions[$r['sob_all_name']]->columnAlign = 'left';
         if ($r['sob_all_type'] == 'text') {
             $fldDimensions[$r['sob_all_name']]->columnAlign = $r['sob_text_align'];
         }
         if ($r['sob_all_type'] == 'display') {
             $fldDimensions[$r['sob_all_name']]->columnAlign = $r['sob_display_align'];
         }
         $fldDimensions[$r['sob_all_name']]->columnTitle = $r['sob_all_title'];
         $fldDimensions[$r['sob_all_name']]->column = $r['sob_all_column_number'];
         $fldDimensions[$r['sob_all_name']]->leftCoordinate = round($sfDimensions[$r['sob_all_column_number']]->columnWidth);
         $fldDimensions[$r['sob_all_name']]->columnWidth = $objectLength * 16 + $hGap;
         $sfDimensions[$r['sob_all_column_number']]->columnWidth = round($sfDimensions[$r['sob_all_column_number']]->columnWidth) + $fldDimensions[$r['sob_all_name']]->columnWidth;
         $colHeight = round($sfDimensions[$r['sob_all_column_number']]->columnHeight);
         if ($colHeight == 0) {
             $sfDimensions[$r['sob_all_column_number']]->columnHeight = $vHeight;
             $colHeight = $sfDimensions[$r['sob_all_column_number']]->columnHeight;
         }
         if ($r['sob_all_type'] == 'textarea' and $colHeight < $r['sob_textarea_height'] * 16) {
             $sfDimensions[$r['sob_all_column_number']]->columnHeight = $r['sob_textarea_height'] * 16;
         }
     }
     $longest = '';
     foreach ($sfDimensions as $key => $value) {
         // get longest row
         if ($value->columnWidth > $longest) {
             $longest = $value->columnWidth;
         }
         $rowHeight = $rowHeight + $value->columnHeight;
     }
     $prntCheckBox = $this->objectProperty['sob_subform_delete_box'] == '1' and $this->objectProperty['sob_subform_read_only'] != '1';
     if ($prntCheckBox) {
         //add room for the delete tick box
         $longest = $longest + $vHeight;
     } else {
         $longest = $longest + 20;
     }
     //add scroll bar
     $sfWidth = $longest + 20;
     $sfLeft = $this->objectProperty['sob_subform_left'];
     //add height of subform title + column title(s) to overall height
     $sfHeight = $this->objectProperty['sob_subform_height'] * 16 - $this->objectProperty['sob_subform_title_height'] * 16 - 100;
     $sfTop = $this->objectProperty['sob_subform_top'];
     if ($this->objectProperty['sob_subform_width'] == 0) {
         $scsfWidth = $sfWidth + 10;
     } else {
         $scsfWidth = $this->objectProperty['sob_subform_width'];
     }
     $scsfHeight = $sfHeight - 20;
     $scsfHeight = $sfHeight - 16;
     //changed from -10 to -16
     $s = "<div name='sf_title{$fieldName}' id='sf_title{$fieldName}' class='selected' style='text-align:left;position:absolute;height:20;top:{$sfTop};left:{$sfLeft};width:{$sfWidth};'>{$fieldTitle}</div>{$CRLF}";
     $sfTop = $sfTop + 20;
     $s = $s . "{$TAB}<div name='{$fieldName}' id='{$fieldName}' class='selected' style='position:absolute;overflow:auto;width:{$scsfWidth};height:{$scsfHeight};top:{$sfTop};left:{$sfLeft};'>{$CRLF}";
     $s = $s . "{$TAB}   <div name='title{$fieldName}' id='title{$fieldName}' style='position:absolute;top:0;left:0;background:#6D7B8D'>{$CRLF}";
     // build subform column titles
     $columnTop = 0;
     $columnNumber = '';
     foreach ($fldDimensions as $key => $value) {
         if ($columnNumber != $value->column) {
             if ($columnNumber == '') {
                 $columnNumber = $value->column;
             }
         }
         if ($columnTop == 0) {
             // only print headings for the first row (sob_subform_column_order)
             if ($columnNumber == $value->column) {
                 $width = $value->columnWidth;
                 $dbc = '';
                 if ($this->parentForm->zzsys_user_id == 'globeadmin' and $this->form->sys_setup != '1') {
                     $dbc = " ondblclick=\"openBrowse('object', '{$objectID}', '', '" . $this->parentForm->session . "', '')\"";
                 }
                 $s = $s . "{$TAB}      <div {$dbc} class='unselected' style='vertical-align:top;font-size:x-small;font-family:tahoma;font-weight:bold;top:0;left:{$value->leftCoordinate};width:{$width};height:{$vTitleHeight};overflow:hidden;position:absolute;text-align:" . align($value->columnAlign) . ";'>{$CRLF}";
                 $s = $s . "{$TAB}         {$value->columnTitle}{$CRLF}";
                 $s = $s . "{$TAB}      </div>{$CRLF}";
                 $nextLeft = $value->leftCoordinate + $value->columnWidth;
             }
         }
     }
     $sfHeight = $sfHeight - $columnTop - $vHeight;
     //  adjusting for scrollng div
     $this->objectName = $this->objectProperty['sob_all_name'];
     //  set subform name
     //add room for the delete tick box
     if ($this->objectProperty['sob_subform_read_only'] != '1') {
         $s = $s . "{$TAB}      <div class='unselected' style='top:0;left:{$nextLeft};width:50;height:{$vTitleHeight};overflow:hidden;position:absolute;align:left;'>{$CRLF}";
         //align:left removed
         if ($prntCheckBox) {
             $s = $s . "{$TAB}         <font style='vertical-align:top;font-size:xx-small;font-family:tahoma;font-weight:bold;'>&nbsp;Delete&nbsp;</font>{$CRLF}";
         }
         $s = $s . "{$TAB}      </div>{$CRLF}";
     }
     //end of subform column titles
     //start scrolling div
     $sfHeight = $sfHeight - $vTitleHeight;
     // adjust a bit to see all of scroll bar
     $columnTop = $columnTop + $vTitleHeight;
     //added by nick 10-06-09 $grey needs to be defined before it can be used
     //vvvvv
     $grey = iif($grey == $this->objectProperty['sob_subform_odd_background_color'], $this->objectProperty['sob_subform_even_background_color'], $this->objectProperty['sob_subform_odd_background_color']);
     //^^^^^
     $subformClass = str_replace('.', '', $this->objectProperty['sob_all_class']);
     $s = $s . "{$TAB}         <div name='scroller{$fieldName}' class='{$subformClass}' id='scroller{$fieldName}' style='border-style:solid;border-width:2;border-color:white;position:absolute;overflow:scroll;width:{$sfWidth};height:{$sfHeight};top:{$columnTop};left:0;background:{$grey};'>{$CRLF}";
     //put subform objects in an array
     $subformObjects = array();
     $t = nuRunQuery("SELECT * FROM zzsys_object WHERE sob_zzsys_form_id = '" . $this->objectProperty['zzsys_object_id'] . "' ORDER BY sob_all_column_number, sob_all_order_number");
     while ($r = db_fetch_object($t)) {
         $subformObjects[] = $r;
     }
     //get SQL for subform
     //		$subformSQL               = replaceVariablesInString($this->TT,$this->objectProperty['sob_subform_sql'], $this->recordID);
     //get SQL for subform //-- added by sc 4-feb-2009
     if (is_array($this->parentForm->recordValues)) {
         $hVariables = arrayToHashArray($this->parentForm->recordValues);
         //--session values (access level and user etc. )
     }
     $subformSQL = replaceVariablesInString($this->TT, $this->objectProperty['sob_subform_sql'], $this->recordID);
     if (is_array($this->parentForm->recordValues)) {
         $subformSQL = replaceHashVariablesWithValues($hVariables, $subformSQL);
     }
     //---------
     $subformTable = nuRunQuery($subformSQL);
     $columnTop = $vHeight * -1 + 5;
     $nextTop = 0;
     $columnNumber = '';
     //loop through subform records
     if ($this->parentForm->cloning == '1') {
         $primaryKey = '';
     } else {
         $primaryKey = $this->objectProperty['sob_subform_primary_key'];
     }
     while ($subformRecord = mysql_fetch_array($subformTable)) {
         $this->recordID = $subformRecord[$this->objectProperty['sob_subform_primary_key']];
         $this->nextRowNumber();
         //loop through each object for this subform record
         $newRow = true;
         $grey = iif($grey == $this->objectProperty['sob_subform_odd_background_color'], $this->objectProperty['sob_subform_even_background_color'], $this->objectProperty['sob_subform_odd_background_color']);
         $dq = '"';
         $s = $s . "{$TAB}               <div id='rowdiv_{$this->subformPrefix}' onfocus='SFrowColor(this, {$dq}{$fieldName}{$dq})' style='background:{$grey};height:{$rowHeight}'>{$CRLF}";
         $checkBoxDone = false;
         for ($i = 0; $i < count($subformObjects); $i++) {
             $subformFieldDiv = $fldDimensions[$subformObjects[$i]->sob_all_name];
             if ($columnNumber != $subformFieldDiv->column or $i == 0) {
                 $columnNumber = $subformFieldDiv->column;
                 $columnTop = $nextTop;
                 $nextTop = $columnTop + $sfDimensions[$columnNumber]->columnHeight;
             }
             //add room for the delete tick box
             if ($prntCheckBox and !$checkBoxDone) {
                 $checkBoxDone = true;
                 $s = $s . "{$TAB}               <div style='position:absolute;top:{$columnTop};left:{$nextLeft}'>{$CRLF}";
                 $s = $s . "{$TAB}                  <input name='row{$this->subformPrefix}' id='row{$this->subformPrefix}' type='checkbox' {$OnChange} tabindex='-1'/>{$CRLF}";
                 $s = $s . "{$TAB}               </div>{$CRLF}";
             }
             $s = $s . "{$TAB}               <div name='row{$this->subformPrefix}' id='row{$this->subformPrefix}' style='background:lightgray;position:absolute;top:{$columnTop};left:{$subformFieldDiv->leftCoordinate}'>{$CRLF}";
             $fieldWidth = $subformFieldDiv->columnWidth - $hGap;
             if ($newRow) {
                 $s = $s . "{$TAB}                  <input name='{$this->subformPrefix}{$primaryKey}' id='{$this->subformPrefix}{$primaryKey}' value='{$this->recordID}' type='hidden'/>{$CRLF}";
                 $newRow = false;
             }
             $s = $s . "{$TAB}                  " . $this->buildObject($subformObjects[$i], $subformRecord) . "{$CRLF}";
             $s = $s . "{$TAB}               </div>{$CRLF}";
         }
         $rowNumber = $rowNumber + 1;
         $newRow = true;
         $s = $s . "{$TAB}               </div>{$CRLF}";
     }
     $sfRowTotal = $rowNumber + $blankRows;
     $columnNumber = '';
     //loop through blank subform records
     for ($blankRecord = 0; $blankRecord < $blankRows; $blankRecord++) {
         $this->recordID = '-1';
         $this->nextRowNumber();
         //loop through each object for this subform record
         $grey = iif($grey == $this->objectProperty['sob_subform_odd_background_color'], $this->objectProperty['sob_subform_even_background_color'], $this->objectProperty['sob_subform_odd_background_color']);
         //			$grey                 = iif($grey=='#E0E0E0 ','#F0F0F0','#E0E0E0 ');
         $s = $s . "{$TAB}               <div style='background:{$grey};height:{$rowHeight}'>{$CRLF}";
         $checkBoxDone = false;
         for ($i = 0; $i < count($subformObjects); $i++) {
             $subformFieldDiv = $fldDimensions[$subformObjects[$i]->sob_all_name];
             if ($columnNumber != $subformFieldDiv->column) {
                 $columnNumber = $subformFieldDiv->column;
                 $columnTop = $nextTop;
                 $nextTop = $columnTop + $sfDimensions[$columnNumber]->columnHeight;
             }
             //add room for the delete tick box
             if ($prntCheckBox and !$checkBoxDone) {
                 $checkBoxDone = true;
                 $s = $s . "{$TAB}               <div style='position:absolute;top:{$columnTop};left:{$nextLeft}'>{$CRLF}";
                 $s = $s . "{$TAB}                  <input name='row{$this->subformPrefix}' id='row{$this->subformPrefix}' type='checkbox' {$OnChange} tabindex='-1' checked='checked'/>{$CRLF}";
                 $s = $s . "{$TAB}               </div>{$CRLF}";
             }
             $s = $s . "{$TAB}               <div name='{$this->subformPrefix}' id='{$this->subformPrefix}' style='position:absolute;top:{$columnTop};left:{$subformFieldDiv->leftCoordinate}'>{$CRLF}";
             $fieldWidth = $subformFieldDiv->columnWidth - $hGap;
             $s = $s . "{$TAB}                  " . $this->buildObject($subformObjects[$i], $subformRecord) . "{$CRLF}";
             $s = $s . "{$TAB}               </div>{$CRLF}";
         }
         $rowNumber = $rowNumber + 1;
         $columnNumber = '';
         $s = $s . "{$TAB}               </div>{$CRLF}";
     }
     $s = $s . "{$TAB}         </div>{$CRLF}";
     $s = $s . "{$TAB}      </div>{$CRLF}";
     $s = $s . "{$TAB}   </div>{$CRLF}";
     $s = $s . "{$TAB}   <div style='position:absolute;overflow:hidden;width:0;height:0;top:0;left:10;background:blue;'>{$CRLF}";
     $sfColumns = count($fldDimensions);
     $s = $s . "{$TAB}      <input name='subformid{$fieldName}' id='subformid{$fieldName}' value='" . $this->objectProperty['zzsys_object_id'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='rows{$fieldName}' id='rows{$fieldName}' value='{$sfRowTotal}' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='columns{$fieldName}' id='columns{$fieldName}' value='{$sfColumns}' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='table{$fieldName}' id='table{$fieldName}' value='" . $this->objectProperty['sob_subform_table'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='foreignkey{$fieldName}' id='foreignkey{$fieldName}' value='" . $this->objectProperty['sob_subform_foreign_key'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='primarykey{$fieldName}' id='primarykey{$fieldName}' value='" . $this->objectProperty['sob_subform_primary_key'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='readonly{$fieldName}' id='readonly{$fieldName}' value='" . $this->objectProperty['sob_subform_read_only'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='deletebox{$fieldName}' id='deletebox{$fieldName}' value='" . $this->objectProperty['sob_subform_delete_box'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='rowColor_{$fieldName}' id='rowColor_{$fieldName}' value='" . $this->objectProperty['sob_subform_selected_row_color'] . "' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='lastRow_{$fieldName}' id='lastRow_{$fieldName}' value='' type='hidden' />{$CRLF}";
     $s = $s . "{$TAB}      <input name='lastColor_{$fieldName}' id='lastColor_{$fieldName}' value='' type='hidden' />{$CRLF}";
     $cNo = 0;
     foreach ($fldDimensions as $key => $value) {
         $s = $s . "{$TAB}      <input name='{$fieldName}{$cNo}' id='{$fieldName}{$cNo}' value='{$key}' type='hidden' />{$CRLF}";
         $cNo = $cNo + 1;
     }
     $s = $s . "{$TAB}</div>{$CRLF}";
     return $s;
 }
Esempio n. 5
0
<?php

require_once 'nucommon.php';
if (isset($_GET['p'])) {
    $values = array($_GET['p']);
    $sql = "SELECT zzzsys_php_id, slp_php FROM zzzsys_php WHERE slp_code = ? AND slp_nonsecure = '1' ";
    $rs = nuRunQuery($sql, $values);
    $num = db_num_rows($rs);
    if ($num == 1) {
        $r = db_fetch_object($rs);
        $r->slp_php = nuGetSafePHP('slp_php', $r->zzzsys_php_id, $r->slp_php);
        $e = nuReplaceHashes($r->slp_php, $_GET);
        eval($e);
    } else {
        echo "Request is not allowed";
    }
} else {
    echo "Request format is invalid";
}
function hasDeleteBox($pParentID)
{
    $t = nuRunQuery("SELECT * FROM zzsys_object WHERE zzsys_object_id = '{$pParentID}'");
    $r = db_fetch_object($t);
    return $r->sob_subform_delete_box == '1';
}
function mysqlbackup($host, $dbname, $uid, $pwd, $output, $structure_only)
{
    //this function creates a text file (or output to a HTTP connection), that when parsed through MYSQL's telnet client, will re-create the entire database
    //Parameters:
    //    $host: usually "localhost" but depends on where the MySQL database engine is mounted
    //    $dbname : The MySQL database name
    //    $uid : the database's username (not your account's), leave blank if none is required
    //    $pwd : the database's password
    //    $output : this is the complete filespec for the output text file, or if you want the result SQL to be sent back to the browser, leave blank.
    //    $structure_only : set this to true if you want just the schema of the database (not the actual data) to be output.
    // **************
    // IMPORTANT: If you use this function, for personal or commercial use, AND you feel an overwhelming sense of gratitude that someone actually took the time and wrote it,
    // immediately go to your paypal account and send me $10 with a small comment of how and how much it helped! Set the payment recipient to woodystanford@yahoo.com .
    // **************
    if (strval($output) != "") {
        $fptr = fopen($output, "w");
    } else {
        $fptr = false;
    }
    //connect to MySQL database
    $con = mysql_connect($host, $uid, $pwd);
    $db = mysql_select_db($dbname, $con);
    //open back-up file ( or no file for browser output)
    //set up database
    out($fptr, "create database {$dbname};\n\n");
    //enumerate tables
    $res = mysql_list_tables($dbname);
    $nt = mysql_num_rows($res);
    for ($a = 0; $a < $nt; $a++) {
        $row = mysql_fetch_row($res);
        $tablename = $row[0];
        //start building the table creation query
        $sql = "create table {$tablename}\n(\n";
        $res2 = nuRunQuery("SELECT * FROM {$tablename} ");
        $nf = mysql_num_fields($res2);
        $nr = mysql_num_rows($res2);
        $fl = "";
        //parse the field info first
        for ($b = 0; $b < $nf; $b++) {
            $fn = mysql_field_name($res2, $b);
            $ft = mysql_fieldtype($res2, $b);
            $fs = mysql_field_len($res2, $b);
            $ff = mysql_field_flags($res2, $b);
            $sql .= "    {$fn} ";
            $is_numeric = false;
            switch (strtolower($ft)) {
                case "int":
                    $sql .= "int";
                    $is_numeric = true;
                    break;
                case "blob":
                    $sql .= "text";
                    $is_numeric = false;
                    break;
                case "real":
                    $sql .= "real";
                    $is_numeric = true;
                    break;
                case "string":
                    $sql .= "char({$fs})";
                    $is_numeric = false;
                    break;
                case "unknown":
                    switch (intval($fs)) {
                        case 4:
                            //little weakness here...there is no way (thru the PHP/MySQL interface) to tell the difference between a tinyint and a year field type
                            $sql .= "tinyint";
                            $is_numeric = true;
                            break;
                        default:
                            //we could get a little more optimzation here! (i.e. check for medium ints, etc.)
                            $sql .= "int";
                            $is_numeric = true;
                            break;
                    }
                    break;
                case "timestamp":
                    $sql .= "timestamp";
                    $is_numeric = true;
                    break;
                case "date":
                    $sql .= "date";
                    $is_numeric = false;
                    break;
                case "datetime":
                    $sql .= "datetime";
                    $is_numeric = false;
                    break;
                case "time":
                    $sql .= "time";
                    $is_numeric = false;
                    break;
                default:
                    //future support for field types that are not recognized (hopefully this will work without need for future modification)
                    $sql .= $ft;
                    $is_numeric = true;
                    //I'm assuming new field types will follow SQL numeric syntax..this is where this support will breakdown
                    break;
            }
            //VERY, VERY IMPORTANT!!! Don't forget to append the flags onto the end of the field creator
            if (strpos($ff, "unsigned") != false) {
                //timestamps are a little screwy so we test for them
                if ($ft != "timestamp") {
                    $sql .= " unsigned";
                }
            }
            if (strpos($ff, "zerofill") != false) {
                //timestamps are a little screwy so we test for them
                if ($ft != "timestamp") {
                    $sql .= " zerofill";
                }
            }
            if (strpos($ff, "auto_increment") != false) {
                $sql .= " auto_increment";
            }
            if (strpos($ff, "not_null") != false) {
                $sql .= " not null";
            }
            if (strpos($ff, "primary_key") != false) {
                $sql .= " primary key";
            }
            //End of field flags
            if ($b < $nf - 1) {
                $sql .= ",\n";
                $fl .= $fn . ", ";
            } else {
                $sql .= "\n);\n\n";
                $fl .= $fn;
            }
            //we need some of the info generated in this loop later in the algorythm...save what we need to arrays
            $fna[$b] = $fn;
            $ina[$b] = $is_numeric;
        }
        out($fptr, $sql);
        if ($structure_only != true) {
            //parse out the table's data and generate the SQL INSERT statements in order to replicate the data itself...
            for ($c = 0; $c < $nr; $c++) {
                $sql = "insert into {$tablename} ({$fl}) values (";
                $row = mysql_fetch_row($res2);
                for ($d = 0; $d < $nf; $d++) {
                    $data = strval($row[$d]);
                    if ($ina[$d] == true) {
                        $sql .= intval($data);
                    } else {
                        $sql .= "\"" . mysql_escape_string($data) . "\"";
                    }
                    if ($d < $nf - 1) {
                        $sql .= ", ";
                    }
                }
                $sql .= ");\n";
                out($fptr, $sql);
            }
            out($fptr, "\n\n");
        }
        mysql_free_result($res2);
    }
    if ($fptr != false) {
        fclose($fptr);
    }
    return 0;
}
Esempio n. 8
0
<?php

/*
** File:           image.php
** Author:         nuSoftware
** Created:        2007/04/26
** Last modified:  2009/07/15
**
** Copyright 2004, 2005, 2006, 2007, 2008, 2009 nuSoftware
**
** This file is part of the nuBuilder source package and is licensed under the
** GPLv3. For support on developing in nuBuilder, please visit the nuBuilder
** wiki and forums. For details on contributing a patch for nuBuilder, please
** visit the `Project Contributions' forum.
**
**   Website:  http://www.nubuilder.com
**   Wiki:     http://wiki.nubuilder.com
**   Forums:   http://forums.nubuilder.com
*/
$dir = $_GET['dir'];
$imageID = $_GET['iid'];
include "../{$dir}/database.php";
include 'common.php';
$s = "SELECT * FROM zzsys_image WHERE zzsys_image_id = '{$imageID}'";
$t = nuRunQuery($s);
$r = db_fetch_object($t);
Header("Content-type: image/png");
print $r->sim_blob;
    $SQL->setWhere(" {$SQL->where} AND ({$object->sob_lookup_id_field} = '{$rID}')");
}
$SQL->removeAllFields();
$SQL->addField($object->sob_lookup_id_field);
$fieldNames[] = $object->sob_all_name;
$SQL->addField($object->sob_lookup_code_field);
$fieldNames[] = 'code' . $object->sob_all_name;
$SQL->addField($object->sob_lookup_description_field);
$fieldNames[] = 'description' . $object->sob_all_name;
$t = nuRunQuery("SELECT * FROM zzsys_lookup WHERE slo_zzsys_object_id = '{$object->zzsys_object_id}'");
while ($r = db_fetch_object($t)) {
    $SQL->addField($r->zzsys_slo_table_field_name);
    $fieldNames[] = $r->zzsys_slo_page_field_name;
}
$t = nuRunQuery($SQL->SQL);
$fieldArray = tableFieldNamesToArray($t);
$T = nuRunQuery($SQL->SQL);
$R = db_fetch_row($T);
for ($i = 0; $i < count($fieldArray); $i++) {
    tofile("UPDATE zzsys_small_form_value SET sfv_value = '" . $R[$i] . "'  WHERE sfv_form_record = '{$f}{$fr}{$ses}' AND sfv_name = '" . $fieldNames[$i] . "'");
    nuRunQuery("UPDATE zzsys_small_form_value SET sfv_value = '" . $R[$i] . "'  WHERE sfv_form_record = '{$f}{$fr}{$ses}' AND sfv_name = '" . $fieldNames[$i] . "'");
}
$url = "formsmall.php?x=11&f={$f}&fr={$fr}&r={$rID}&dir={$dir}&ses={$ses}";
print "<html>\n<body onload=\"document.forms.lookup.submit()\">\n";
print "<form name='lookup' method='POST' action='{$url}'>\n</form>\n";
print "</body>\n</html>\n";
return;
?>


Esempio n. 10
0
function db_columns($n)
{
    $a = array();
    $d = $_SESSION['DBName'];
    $s = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{$d}' AND TABLE_NAME = '{$n}' ORDER BY ORDINAL_POSITION";
    $t = nuRunQuery($s);
    while ($r = db_fetch_object($t)) {
        $a[] = $r->COLUMN_NAME;
    }
    return $a;
}
Esempio n. 11
0
function nuDownloadFile($i, $s = '')
{
    //-- $s can be used to get type, name and blob from another table
    if ($s == '') {
        $s = "SELECT sfi_type AS file_type, sfi_name AS file_name, sfi_blob AS file_blob FROM zzzsys_file WHERE zzzsys_file_id = '{$i}'";
    }
    $t = nuRunQuery($s);
    $r = db_fetch_object($t);
    header('Content-Type: ' . $r->file_type . ';');
    header('Content-Disposition: attachement;filename="' . $r->file_name . '";');
    $f = fopen('php://output', 'w');
    fwrite($f, $r->file_blob);
    fclose($f);
}
 public function buildControls($sectionNumber, $canGrow, $record)
 {
     $s = '';
     $setup = nuSetup();
     $dq = '"';
     $sortedControls = $this->sortSectionControlsByTopPositionOrder($sectionNumber, $this->report->Controls);
     for ($j = 0; $j < count($sortedControls); $j++) {
         $pSection = $sortedControls[$j]["Section"];
         $pName = $sortedControls[$j]["Name"];
         $pControlSource = $sortedControls[$j]["Source"];
         $i = $this->getDisplayControlIndex($pSection, $pName, $pControlSource);
         if ($this->report->Controls[$i]->Section == $sectionNumber) {
             $Name = $this->report->Controls[$i]->Name;
             $Source = $this->report->Controls[$i]->ControlSource;
             $ControlType = $this->report->Controls[$i]->ControlType;
             $Top = $this->toScale($this->report->Controls[$i]->Top);
             $Width = $this->toScale($this->report->Controls[$i]->Width);
             $Height = $this->toScale($this->report->Controls[$i]->Height);
             $Left = $this->toScale($this->report->Controls[$i]->Left);
             $Section = $this->report->Controls[$i]->Section;
             $Fontname = $this->report->Controls[$i]->FontName;
             $Fontsize = $this->report->Controls[$i]->FontSize;
             $Format = $this->report->Controls[$i]->Format;
             $Decimal = $this->report->Controls[$i]->DecimalPlaces;
             $IsHyperlink = $this->report->Controls[$i]->IsHyperlink;
             $ReportTag = $this->report->Controls[$i]->Tag;
             $Report = $this->report->Controls[$i]->Report;
             $Parameters = $this->report->Controls[$i]->Parameters;
             $LikeClause = $this->report->Controls[$i]->SmartTags;
             $LikeClause = str_replace("\"", "", $LikeClause);
             //image
             if ($this->sectionGrow == 1 && $sectionNumber != 0) {
                 $Top = $Top + $this->sectionGrowStack;
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'page break') {
                 $this->justDidPageBreak = true;
                 $this->hasExplicitPageBreak = true;
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'graph') {
                 $thetag = $this->report->Controls[$i]->ControlSource;
                 $thename = $this->report->Controls[$i]->Graph;
                 $thedir = $_GET['dir'];
                 for ($a = 0; $a < count($this->fields); $a++) {
                     //-----replace any strings, with hashes around them, in the querystring that match
                     //-----fieldnames in the table
                     //-----with values from the table
                     //-----e.g. id=#ID# could become id=007
                     $thetag = str_replace('#' . $this->fields[$a] . '#', $record[$this->fields[$a]], $thetag);
                 }
                 $addSession = '&ses=' . $_GET['ses'];
                 $s = $s . "   <div  style='position:absolute;left:{$Left};top:{$Top};height:{$Height}'>\n";
                 $s = $s . "      <img src='graph_report.php?dir={$thedir}{$addSession}&activityID={$this->reportID}&graph_name={$thename}&{$thetag}'>\n";
                 $s = $s . "   </div>\n";
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'image') {
                 $thetag = $this->report->Controls[$i]->ControlSource;
                 $imageCode = $this->report->Controls[$i]->Graph;
                 //-- the code (sim_code in zzsys_image)
                 $thedir = $_GET['dir'];
                 for ($a = 0; $a < count($this->fields); $a++) {
                     //-----replace any strings, with hashes around them, in the querystring that match
                     //-----fieldnames in the table
                     //-----with values from the table
                     //-----e.g. id=#ID# could become id=007
                     $thetag = str_replace('#' . $this->fields[$a] . '#', $record[$this->fields[$a]], $thetag);
                 }
                 $imageT = nuRunQuery("SELECT zzsys_image_id FROM zzsys_image WHERE sim_code = '{$imageCode}'");
                 $imageR = db_fetch_row($imageT);
                 $s = $s . "   <div  style='position:absolute;left:{$Left};top:{$Top};height:{$Height}'>\n";
                 $s = $s . "      <img src='formimage.php?dir={$thedir}&iid={$imageR['0']}&{$thetag}'>\n";
                 $s = $s . "   </div>\n";
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'label') {
                 if ($Source == '=Date()' || $Source == '=Now()') {
                     if ($Format == '' || $Format == '20' || $Format == 'Long Date') {
                         $formattedValue = date('d-M-Y H:i');
                     } else {
                         $formattedValue = date($this->accessDateFormatToPHPDateFormat($Format));
                     }
                     //$Caption = $formattedValue;
                     $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$formattedValue}</div>\n";
                 } else {
                     if ($Source == '="Page " & [Page] & " of " & [Pages]') {
                         $formattedValue = "Page #thePageNumber# of #totalNumberOfPages#";
                         $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$formattedValue}</div>\n";
                         //echo $s."<br>";
                     } else {
                         $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>" . $this->report->Controls[$i]->Caption . "</div>\n";
                     }
                 }
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'text area') {
                 //--Field
                 $displayValue = $record[$this->report->Controls[$i]->ControlSource];
                 //Sum
                 $theSource = $this->report->Controls[$i]->ControlSource;
                 $builtInFunction = false;
                 //============numbering pages (using a label)=======================================
                 //---- Page #thePageNumber# of #totalNumberOfPages#      eg. Page 6 of 12
                 //==================================================================================
                 if ($theSource == '="Page " & [Page] & " of " & [Pages]' || $theSource == 'Page #thePageNumber# of #totalNumberOfPages#') {
                     $displayValue = "Page #thePageNumber# of #totalNumberOfPages#";
                 }
                 if (strtoupper($theSource) == '=NOW()' || strtoupper($theSource) == '=DATE()') {
                     if ($Format == '' || $Format == '20' || $Format == 'Long Date') {
                         $displayValue = date('d-M-Y H:i');
                     } else {
                         $displayValue = date($this->accessDateFormatToPHPDateFormat($Format));
                     }
                 }
                 if (strtoupper(substr($theSource, 0, 4)) == 'SUM(') {
                     //--sum for header or footer sections
                     $sumField = substr($theSource, 4, -1);
                     $selectFields = 'SUM(' . trim($sumField) . '_Sum) as answer ';
                     $groupSQL = $this->getGroupBySql($this->sectionLevel($sectionNumber), $selectFields, $record);
                     $t1 = nuRunQuery($groupSQL);
                     $r1 = mysql_fetch_row($t1);
                     $displayValue = $r1[0];
                 }
                 if (strtoupper(substr($theSource, 0, 6)) == '=SUM([') {
                     //--if the sum function
                     $sumField = substr($theSource, 6, -2);
                     $selectFields = 'SUM(' . trim($sumField) . '_Sum) as answer ';
                     $groupSQL = $this->getGroupBySql($this->sectionLevel($sectionNumber), $selectFields, $record);
                     $t1 = nuRunQuery($groupSQL);
                     $r1 = mysql_fetch_row($t1);
                     $displayValue = $r1[0];
                 }
                 if (strtoupper(substr($theSource, 0, 8)) == 'PERCENT(') {
                     //--percent of 2 sums
                     $sumField = substr($theSource, 8, -1);
                     $sumFields = array();
                     $sumFields = explode(',', $sumField);
                     $selectFields = 'SUM(' . trim($sumFields[0]) . '_Sum) as answer1, SUM(' . trim($sumFields[1]) . '_Sum) as answer2 ';
                     $groupSQL = $this->getGroupBySql($this->sectionLevel($sectionNumber), $selectFields, $record);
                     $t1 = nuRunQuery($groupSQL);
                     $r1 = mysql_fetch_row($t1);
                     if ($r1[1] == 0) {
                         $displayValue = 0;
                         //--because nothing can be divided by zero
                     } else {
                         $displayValue = $r1[0] / $r1[1] * 100;
                     }
                 }
                 $displayValue = formatTextValue($displayValue, $Format);
                 if ($this->report->Controls[$i]->CanGrow == 'True' and $canGrow) {
                     $oldValue = $displayValue;
                     $break_variants = array("<br>", "<BR>", "<br />", "<BR />", "<br/>", "<BR/>");
                     $displayValue = str_replace($break_variants, "\n", $displayValue);
                     if ($this->report->nuBuilder == '1') {
                         $textWidth = str_replace('px', '', $this->report->Controls[$i]->Width) / ($this->report->Controls[$i]->FontSize / 2);
                         $displayValue = wordwrap($displayValue, $textWidth, "<br />");
                     } else {
                         $displayValue = wordwrap($displayValue, iif($ReportTag == '', 10, $ReportTag), "<br />");
                     }
                     $displayValue = nl2br($displayValue);
                     $lines = substr_count($displayValue, "<br />") + 1;
                     $linesArray = explode("<br />", $displayValue);
                     if ($lines <= 5) {
                         $Height = $Fontsize * 1.2;
                     } else {
                         if ($lines > 5 && $lines <= 15) {
                             $Height = $Fontsize * 1.3;
                         } else {
                             if ($lines > 15 && $lines <= 25) {
                                 $Height = $Fontsize * 1.4;
                             } else {
                                 if ($lines > 25) {
                                     $Height = $Fontsize * 1.5;
                                 }
                             }
                         }
                     }
                     $defaultHeight = $Height;
                     $Height = $Height * $lines;
                     $this->growByHeight = $this->growByHeight + $Height;
                     if ($this->growBy < $Height - $defaultHeight) {
                         $this->growBy = $Height - $defaultHeight;
                         if ($sectionNumber != 0) {
                             $sectionHeight = $this->toScale($this->report->Sections[$sectionNumber]->Height);
                             $growByHeight = $this->growBy;
                             $growString = "";
                             $pos = count($linesArray) - 1;
                             if ($this->growAddHeight == 0) {
                                 $this->growAddHeight = $this->thisPageLength;
                             }
                             if ($this->growAddHeight + $growByHeight > $this->useablePageLength) {
                                 for ($k = count($linesArray) - 1; $k >= 0; $k--) {
                                     $Height = $defaultHeight * $k;
                                     $this->growBy = $Height - $defaultHeight;
                                     $growByHeight = $this->growBy + $sectionHeight;
                                     if ($this->growAddHeight + $growByHeight < $this->useablePageLength) {
                                         $pos = $k;
                                         $this->attachGroupHeaderFieldGrowByText($this->report->Controls[$i]);
                                         $this->growBySectionNumber = $Section;
                                         break;
                                     }
                                 }
                                 for ($k = 0; $k < $pos; $k++) {
                                     $growString = $growString . $linesArray[$k] . "<br />";
                                 }
                                 $index = 0;
                                 for ($k = $pos; $k < count($linesArray); $k++) {
                                     $this->nextPageGrowText[$index] = $linesArray[$k];
                                     $index++;
                                 }
                                 $displayValue = $growString;
                             } else {
                                 $this->growAddHeight = $this->growAddHeight + $growByHeight;
                             }
                             $this->growByHeight = $Height;
                             $this->sectionGrowStack = $growByHeight;
                             $this->sectionGrow = 1;
                         }
                     }
                     if ($sectionNumber != 0) {
                         $this->growByTotal = $this->growByTotal + $Height;
                     }
                     $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$this->growByHeight}'>{$displayValue}</div>\n";
                 } else {
                     //------create drilldown-------------------
                     if ($Report != '') {
                         $reportlink = $Report;
                         $sessionlink = $_GET['ses'];
                         $formsessionlink = $_GET['form_ses'];
                         $dirlink = $_GET['dir'];
                         $displayValue = "<a class='{$Name}' href='runreport.php?x=1&dir={$dir}&ses={$sessionlink}&form_ses={$formsessionlink}&r={$Report}'>{$displayValue}</a>";
                     }
                     //-----------------------------------------
                     $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$displayValue}</div>\n";
                 }
             }
         }
     }
     return $s;
 }
Esempio n. 13
0
<?php

require_once 'nucommon.php';
$s = "SELECT * FROM zzzsys_file WHERE sfi_code = ? ";
$t = nuRunQuery($s, array($_GET['i']));
$r = db_fetch_object($t);
$f = "'Content-type: {$r->sfi_type}'";
Header($f);
print $r->sfi_blob;
} else {
    $filename = $_FILES['uploadedfile']['tmp_name'];
    $handle = fopen($filename, "rb");
    $contents = fread($handle, filesize($filename));
    $contents = addslashes($contents);
    fclose($handle);
    $newRecord = false;
    if ($iid == '-1' or $iid == '') {
        $iid = uniqid('1');
        $newRecord = true;
    }
    if ($newRecord) {
        nuRunQuery("INSERT INTO zzsys_image (zzsys_image_id, sim_blob) VALUES ('{$iid}','{$contents}')");
        tofile('new');
    } else {
        nuRunQuery("UPDATE zzsys_image SET sim_blob = '{$contents}' WHERE zzsys_image_id = '{$iid}'");
        tofile('old');
    }
    print "<script>\n\n";
    print "function closedown(){\n";
    //--- set zzsys_image_id on opener page
    print "   window.opener.document.getElementById('recordID').value = '{$iid}';\n\n";
    print "   if(window.opener.nuAfterUpload){\n";
    print "      window.opener.nuAfterUpload('recordID');\n";
    print "   };\n\n";
    print "   self.close();\n\n";
    print "}\n";
    print "</script>\n";
    print "<body onload=' closedown()'>\n";
}
print "</body>";
print "theWeight[2] = 'lighter'\n";
print "\nvar theControl = new Array()\n";
print "theControl[0] = 'Field'\n";
print "theControl[1] = 'Label'\n";
print "theControl[2] = 'Graph'\n";
print "theControl[3] = 'PageBreak'\n";
print "\nvar theGraph = new Array()\n";
$tg = nuRunQuery("SELECT sag_graph_name FROM zzsys_activity_graph WHERE sag_zzsys_activity_id = '{$reportID}'");
$tcount = 1;
print "theGraph[0] = ''\n";
while ($rg = db_fetch_row($tg)) {
    print "theGraph[{$tcount}] = 'graph-{$rg['0']}'\n";
    $tcount = $tcount + 1;
}
//added by nick 15-01-09
$tg = nuRunQuery("SELECT sim_code FROM zzsys_image ");
while ($rg = db_fetch_row($tg)) {
    print "theGraph[{$tcount}] = 'image-{$rg['0']}'\n";
    $tcount = $tcount + 1;
}
print "\n</script>\n";
function sectionNumber($pSection, $pLayout, $pVisible)
{
    $arrayNumberOfSection = -1;
    for ($i = 0; $i < count($pLayout->Sections); $i++) {
        if ($pLayout->Sections[$i]->SectionNumber == $pSection) {
            $arrayNumberOfSection = $i;
        }
    }
    if ($arrayNumberOfSection == -1) {
        //--not created by Access Report
Esempio n. 16
0
<?php

require_once 'nucommon.php';
$jsonID = $_GET['i'];
$t = nuRunQuery("SELECT deb_message AS json FROM zzzsys_debug WHERE zzzsys_debug_id = ? ", array($jsonID));
$r = db_fetch_object($t);
$JSON = json_decode($r->json);
$DATA = $JSON->slp_php;
$ID = $JSON->zzzsys_php_id;
$DATA = nuGetSafePHP('slp_php', $ID, $DATA);
$TABLE_ID = nuTT();
$hashData = nuBuildHashData($JSON, $TABLE_ID);
$php = nuReplaceHashes($DATA, $hashData);
eval($php);
//-- run php code
nuRunQuery("DELETE FROM zzzsys_debug WHERE zzzsys_debug_id = ? ", array($jsonID));
 public function buildControls($sectionNumber, $canGrow, $record)
 {
     //tofile("Build Controls");
     $s = '';
     $setup = nuSetup();
     $dq = '"';
     //tofile("Count Controls ".count($this->report->Controls));
     for ($i = 0; $i < count($this->report->Controls); $i++) {
         if ($this->report->Controls[$i]->Section == $sectionNumber) {
             //tofile("Get Control");
             $Name = $this->report->Controls[$i]->Name;
             $Source = $this->report->Controls[$i]->ControlSource;
             $Controltype = $this->report->Controls[$i]->ControlType;
             //tofile("Control Type: ".$this->report->Controls[$i]->ControlType);
             $Top = $this->toScale($this->report->Controls[$i]->Top);
             $Width = $this->toScale($this->report->Controls[$i]->Width);
             $Height = $this->toScale($this->report->Controls[$i]->Height);
             $Left = $this->toScale($this->report->Controls[$i]->Left);
             $Section = $this->report->Controls[$i]->Section;
             $Fontname = $this->report->Controls[$i]->FontName;
             $Fontsize = $this->report->Controls[$i]->FontSize;
             if (intval($Fontsize) >= 12) {
                 $Fontsize = $Fontsize - 4;
             } else {
                 if (intval($Fontsize) == 11) {
                     $Fontsize = $Fontsize - 3;
                 } else {
                     if (intval($Fontsize) <= 10) {
                         $Fontsize = $Fontsize - 2;
                     }
                 }
             }
             $Fontweight = $this->report->Controls[$i]->FontWeight;
             $Fontname = iif($Fontname == null, 'Arial', $Fontname);
             $Fontname = iif($Fontname != 'Arial', 'Arial', $Fontname);
             $Fontweight = iif($Fontweight == 'bold', 'B', '');
             $Caption = $this->report->Controls[$i]->Caption;
             $ln = iif($Caption == '', 2, 0);
             $TextAlign = $this->report->Controls[$i]->TextAlign;
             $TextAlign = $this->GetTextAlign($TextAlign);
             $ForeColor = $this->report->Controls[$i]->ForeColor;
             $BackColor = $this->report->Controls[$i]->BackColor;
             $BackStyle = $this->report->Controls[$i]->BackStyle;
             $BorderWidth = $this->report->Controls[$i]->BorderWidth;
             $BorderColor = $this->report->Controls[$i]->BorderColor;
             $Format = $this->report->Controls[$i]->Format;
             $Decimal = $this->report->Controls[$i]->DecimalPlaces;
             $IsHyperlink = $this->report->Controls[$i]->IsHyperlink;
             $ReportTag = $this->report->Controls[$i]->Tag;
             $LikeClause = $this->report->Controls[$i]->SmartTags;
             $LikeClause = str_replace("\"", "", $LikeClause);
             //$ForeColor					= $this->html2rgb('#'.$ForeColor);
             //$BackColor 					= $this->html2rgb('#'.$BackColor);
             //$BorderColor 				= $this->html2rgb('#'.$BorderColor);
             /*if ($BackColor == '' || $BackColor == strtolower('#FFFFFF') || $BackColor == strtolower('FFFFFF')) {
             			$BackStyle = 0;
             		} else {
             			$BackStyle = 1;
             		}*/
             $ForeColor = iif(substr($ForeColor, 0, 1) == '#', $ForeColor, '#' . $ForeColor);
             $BackColor = iif(substr($BackColor, 0, 1) == '#', $BackColor, '#' . $BackColor);
             $BorderColor = iif(substr($BorderColor, 0, 1) == '#', $BorderColor, '#' . $BorderColor);
             $ForeColor = $this->html2rgb($ForeColor);
             $BackColor = $this->html2rgb($BackColor);
             $BorderColor = $this->html2rgb($BorderColor);
             $this->SetTextColor($ForeColor[0], $ForeColor[1], $ForeColor[2]);
             $this->SetFillColor($BackColor[0], $BackColor[1], $BackColor[2]);
             $this->SetDrawColor($BorderColor[0], $BorderColor[1], $BorderColor[2]);
             if ($BorderWidth > 0) {
                 $this->SetLineWidth($BorderWidth / 100);
                 $BorderWidth = 1;
             }
             //$BorderWidth = 1;
             //$Top = (($this->stackheight + $Top)/100) + 0.3;
             $Left = $Left / 100 + 0.2;
             //$Width = ($Width / 100) + 0.002;
             $Width = $Width / 100;
             $Height = $Height / 100;
             $Top = ($this->stackheight + $Top * 1.0) / 100 + 0.25;
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'page break') {
                 $this->justDidPageBreak = true;
                 $this->hasExplicitPageBreak = true;
                 continue;
             }
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'image') {
                 $thetag = $this->report->Controls[$i]->ControlSource;
                 $imageCode = $this->report->Controls[$i]->Graph;
                 //-- the code (sim_code in zzsys_image)
                 $thedir = $_GET['dir'];
                 for ($a = 0; $a < count($this->fields); $a++) {
                     //-----replace any strings, with hashes around them, in the querystring that match
                     //-----fieldnames in the table
                     //-----with values from the table
                     //-----e.g. id=#ID# could become id=007
                     $thetag = str_replace('#' . $this->fields[$a] . '#', $record[$this->fields[$a]], $thetag);
                 }
                 $thetag = str_replace(" ", "%20", $thetag);
                 // Escapes any spaces in the parameters/arguments
                 //tofile("Graph Tag: ".$thetag);
                 $imageT = nuRunQuery("SELECT zzsys_image_id FROM zzsys_image WHERE sim_code = '{$imageCode}'");
                 $imageR = db_fetch_row($imageT);
                 $s = $s . "   <div  style='position:absolute;left:{$Left};top:{$Top};height:{$Height}'>\n";
                 $s = $s . "      <img src='formimage.php?dir={$thedir}&iid={$imageR['0']}&{$thetag}'>\n";
                 $s = $s . "   </div>\n";
                 //tofile("http://dev.nubuilder.com/productionnu2/formimage.php?dir=$thedir&iid=$imageR[0]&$thetag");
                 $logo = fopen("http://dev.nubuilder.com/productionnu2/formimage.php?dir=" . $thedir . "&iid=" . $imageR[0] . "&" . $thetag, "r");
                 file_put_contents('temp' . $this->imagecount . '.png', $logo);
                 if (filesize('temp' . $this->imagecount . '.png') > 0) {
                     $im = imagecreatefrompng('temp' . $this->imagecount . '.png');
                     imageinterlace($im, 0);
                     imagepng($im, 'temp' . $this->imagecount . '.png');
                     $imageDimensions = getimagesize('temp' . $this->imagecount . '.png');
                     $imageWidth = $imageDimensions[0] * 0.01;
                     $imageHeight = $imageDimensions[1] * 0.01;
                     $this->Image('temp' . $this->imagecount . '.png', $Left, $Top, $imageWidth, $imageHeight);
                 }
                 unlink('temp' . $this->imagecount . '.png');
                 $this->imagecount++;
                 $this->Rect($Left, $Top, $imageWidth, $imageHeight, 'D');
                 continue;
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'graph' || $this->report->Controls[$i]->ControlType == 'Graph') {
                 if ($this->controlType($this->report->Controls[$i]->ControlType) == 'graph') {
                     $thetag = $this->report->Controls[$i]->ControlSource;
                     $thename = $this->report->Controls[$i]->Graph;
                     tofile("lowercase graph: " . $thetag);
                 } else {
                     if ($this->report->Controls[$i]->ControlType == 'Graph') {
                         $thetag = $this->report->Controls[$i]->ControlSource;
                         $thename = $this->report->Controls[$i]->Graph;
                         tofile("uppercase graph: " . $thetag);
                     }
                 }
                 $thedir = $_GET['dir'];
                 for ($a = 0; $a < count($this->fields); $a++) {
                     //-----replace any strings, with hashes around them, in the querystring that match
                     //-----fieldnames in the table
                     //-----with values from the table
                     //-----e.g. id=#ID# could become id=007
                     $thetag = str_replace('#' . $this->fields[$a] . '#', $record[$this->fields[$a]], $thetag);
                 }
                 $addSession = '&ses=' . $_GET['ses'];
                 $thetag = str_replace(" ", "%20", $thetag);
                 // Escapes any spaces in the parameters/arguments
                 //tofile("Graph Tag: ".$thetag);
                 $logo = fopen("http://www.nubuilder.com/productionnu2/graph_report.php?dir={$thedir}{$addSession}&activityID={$this->reportID}&graph_name={$thename}&{$thetag}", "r");
                 file_put_contents('temp' . $this->imagecount . '.png', $logo);
                 $imageDimensions = getimagesize('temp' . $this->imagecount . '.png');
                 $imageWidth = $imageDimensions[0] * 0.01;
                 $imageHeight = $imageDimensions[1] * 0.01;
                 $this->Image('temp' . $this->imagecount . '.png', $Left, $Top, $imageWidth, $imageHeight);
                 unlink('temp' . $this->imagecount . '.png');
                 $this->imagecount++;
                 $this->Rect($Left, $Top, $imageWidth, $imageHeight, 'D');
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'label' || $this->report->Controls[$i]->ControlType == 'Label') {
                 if (substr($this->report->Controls[$i]->ControlSource, 0, 4) == '<img') {
                     //tofile("Test Caption ".$this->GetImageLink($ReportClass->Controls[$i]->Caption));
                     //tofile("Show Header fields ".$Name." ".$Source." ".$Caption." ".$Fontname." P".$PageNumber." ".$Top);
                     $this->SetXY($Left, $Top);
                     $output = $this->parse($this->report->Controls[$i]->ControlSource);
                     $image_properties = $this->GetImageSourceAndDimensions($output);
                     if (substr($image_properties['source'], -4, 4) == '.jpg' || substr($image_properties['source'], -4, 4) == '.png') {
                         $this->Image($image_properties['source'], $Left, $Top, $image_properties['width'], $image_properties['height']);
                     }
                     continue;
                 }
                 if ($this->report->Controls[$i]->Tag != $this->report->Controls[$i]->ControlType) {
                     //tofile("Check Tag ".$this->report->Controls[$i]->Tag);
                     //$s                  = $s . "      <div class='$Name' style='position:absolute;top:$Top;height:$Height'><img src='$setup->seStartingDirectory/reports/".$this->report->Controls[$i]->Tag.".jpg'></div>\n";
                     $this->SetXY($Left, $Top);
                     //$this->Image($setup->seStartingDirectory."/reports/".$ReportClass->Controls[$i]->Tag.".jpg",$Left,$Top,$Width,$Height);
                     if ($ReportClass->Controls[$i]->Caption != '') {
                         $this->SetFont($Fontname, $Fontweight, $Fontsize);
                         $this->SetXY($Left, $Top);
                         $this->Cell($Width, $Height, $Caption, $BorderWidth, $ln, $TextAlign);
                         //tofile("Caption: ".$Caption);
                     }
                     continue;
                 }
                 if ($Source == '="Page " & [Page] & " of " & [Pages]' || $Source == 'Page #thePageNumber# of #totalNumberOfPages#') {
                     $Caption = "Page " . $this->pageNumber . " of " . $GLOBALS['TotalPages'];
                     $this->SetFont($Fontname, $Fontweight, $Fontsize);
                     $this->SetXY($Left, $Top);
                     $this->Cell($Width, $Height, $Caption, $BorderWidth, $ln, $TextAlign, $BackStyle);
                     $s = $s . "   <div class='{$Name}'>Page #thePageNumber# of #totalNumberOfPages#</div>\n";
                     continue;
                 } else {
                     if ($Source == '=Date()' || $Source == '=Now()') {
                         if ($Format == '' || $Format == '20' || $Format == 'Long Date') {
                             $formattedValue = date('d-M-Y H:i');
                         } else {
                             $formattedValue = date($this->accessDateFormatToPHPDateFormat($Format));
                         }
                         $Caption = $formattedValue;
                         $this->SetFont($Fontname, $Fontweight, $Fontsize);
                         $this->SetXY($Left, $Top);
                         $this->Cell($Width, $Height, $Caption, $BorderWidth, $ln, $TextAlign, $BackStyle);
                         $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$formattedValue}</div>\n";
                         continue;
                     }
                 }
                 $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>" . $this->report->Controls[$i]->Caption . "</div>\n";
                 if (strlen($Caption) == 1 && $BorderWidth >= 1) {
                     $this->SetDrawColor($BorderColor[0], $BorderColor[1], $BorderColor[2]);
                     $this->SetFillColor($BorderColor[0], $BorderColor[1], $BorderColor[2]);
                     $BackStyle = 1;
                 }
                 $this->SetFont($Fontname, $Fontweight, $Fontsize);
                 //tofile("Label: ".$this->report->Controls[$i]->ControlSource);
                 $output = $this->parse($this->report->Controls[$i]->Caption);
                 if ($output[0]['innerhtml'] == null) {
                     //tofile("Label used: ".$this->report->Controls[$i]->Caption);
                     $break_variants = array("<br />", "<BR />", "<br/>", "<BR/>");
                     $string = str_replace($break_variants, "<br>", $this->report->Controls[$i]->Caption);
                     $lines = explode("<br>", $string);
                     if (sizeof($lines) > 1) {
                         $string = "";
                         for ($j = 0; $j < sizeof($lines); $j++) {
                             $lines[$j] = trim($lines[$j]);
                             $string = $string . $lines[$j] . "\n";
                         }
                     }
                     if (sizeof($lines) > 1) {
                         //tofile("more than 1 line");
                         $Height = $this->CalculateLineHeight($Fontsize);
                         $this->SplitLines($Width, $Height, $string, $BorderWidth, $ln, $TextAlign, $BackColor, $BackStyle, $Left, $Top, 0, $i);
                     } else {
                         //tofile("1 line only");
                         $this->SetXY($Left, $Top);
                         $this->Cell($Width, $Height, $this->report->Controls[$i]->Caption, $BorderWidth, $ln, $TextAlign, $BackStyle);
                     }
                 } else {
                     $this->SetXY($Left, $Top);
                     $this->SetHTMLAttributes($Width, $Height, $output, $BorderWidth, $ln, $TextAlign, $BackColor, $BackStyle, $Left, $Top);
                 }
                 //$this->Cell($Width,$Height,$r[$ReportClass->Controls[$i]->ControlSource],$BorderWidth,$ln,$TextAlign,$BackColor);
                 //$this->SetFont($Fontname,$Fontweight,$Fontsize);
                 //$this->SetXY($Left, $Top);
                 //$this->Cell($Width,$Height,$Caption,$BorderWidth,$ln,$TextAlign,$BackStyle);
             }
             //========================================================================================
             if ($this->controlType($this->report->Controls[$i]->ControlType) == 'text area' || $this->report->Controls[$i]->ControlType == 'Field') {
                 $formattedValue = $record[$this->report->Controls[$i]->ControlSource];
                 $formattedValue = str_replace("&nbsp;", " ", $formattedValue);
                 $formattedValue = str_replace("&nbsp", " ", $formattedValue);
                 if ($this->report->Controls[$i]->Tag != '') {
                     $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'><img src='{$setup->seStartingDirectory}/reports/" . $this->report->Controls[$i]->Tag . ".jpg'></div>\n";
                 }
                 //Sum
                 $theSource = $this->report->Controls[$i]->ControlSource;
                 //tofile("Source: ".strtoupper(substr($theSource, 0, 8)));
                 if (substr($theSource, 0, 6) == '=Sum([' or strtoupper(substr($theSource, 0, 10)) == '=PERCENT([' or substr($theSource, 0, 4) == 'sum(' or strtoupper(substr($theSource, 0, 8)) == 'PERCENT(') {
                     $sumIt = substr($theSource, 0, 6) == '=Sum([' || substr($theSource, 0, 4) == 'sum(';
                     //tofile(substr($theSource, 0, 10)." flag ".$sumIt);
                     if ($sumIt) {
                         //--if the sum function
                         $SumOn = str_replace('=Sum([', '', $theSource);
                         $SumOn = str_replace('])', '', $SumOn);
                         $SumOn = str_replace('sum(', '', $SumOn);
                         $SumOn = str_replace(')', '', $SumOn);
                         $selectFields = 'sum(' . $SumOn . '_Sum) as answer ';
                     } else {
                         //--if the Percent function
                         $SumOn = substr($theSource, 8);
                         //tofile("Sum On: ".$SumOn);
                         $SumOn = str_replace(']', '', $SumOn);
                         //-- remove right square brackets
                         $SumOn = str_replace('[', '', $SumOn);
                         //-- remove left square brackets
                         $SumOn = str_replace(')', '', $SumOn);
                         //-- remove only right bracket
                         $SumOn = str_replace(' ', '', $SumOn);
                         //-- remove any spaces
                         $theFields = explode(',', $SumOn);
                         //-- split left and right field
                         $selectFields = 'sum(' . $theFields[0] . '_Sum) as divideIt, sum(' . $theFields[1] . '_Sum) as BYY ';
                         //tofile("Select Fields: ".$selectFields);
                     }
                     $SectionLevel = $this->sectionLevel($sectionNumber);
                     for ($ii = 0; $ii <= $SectionLevel; $ii++) {
                         if ($ii == 0) {
                             if ($this->report->Groups[$ii]->Field != '') {
                                 $whereClause = $this->report->Groups[$ii]->Field . " = {$dq}" . $record[$this->report->Groups[$ii]->Field] . "{$dq}";
                             }
                         } else {
                             if ($this->report->Groups[$ii]->Field != '') {
                                 $whereClause = $whereClause . ' AND ' . $this->report->Groups[$ii]->Field . " = {$dq}" . $record[$this->report->Groups[$ii]->Field] . "{$dq}";
                             }
                         }
                     }
                     $SumOn = trim($SumOn);
                     if (strlen($SectionLevel) == 0) {
                         $whereClause = "SELECT {$selectFields} FROM {$this->sumTT}";
                     } else {
                         $whereClause = "SELECT {$selectFields} FROM {$this->sumTT} WHERE {$whereClause}";
                     }
                     $t1 = nuRunQuery($whereClause);
                     $r1 = mysql_fetch_row($t1);
                     $formattedValue = $r1[0];
                     //tofile("Sum Value: ".$formattedValue);
                     if (!$sumIt) {
                         //---using the 'PERCENT' function
                         if ($r1[1] == 0) {
                             $formattedValue = 0;
                             //--because nothing can be divided by zero
                         } else {
                             $formattedValue = $r1[0] / $r1[1] * 100;
                         }
                     }
                     if ($Format == 'Fixed') {
                         if ($r1[0] != '') {
                             $formattedValue = number_format($r1[0], $Decimal);
                         }
                     }
                     //format of the result of the sum
                     if ($Format == 'Currency') {
                         if ($r1[0] != '') {
                             $formattedValue = "\$" . number_format($r1[0], 2);
                             $formattedValue = str_replace('$-', '-$', $formattedValue);
                         }
                     }
                     $formattedValue = formatTextValue($formattedValue, $Format);
                     $Caption = $formattedValue;
                     $this->SetFont($Fontname, $Fontweight, $Fontsize);
                     $this->SetXY($Left, $Top);
                     $this->Cell($Width, $Height, $this->SetStringByWidth($Caption, $Width - 0.1), $BorderWidth, $ln, $TextAlign, $BackStyle);
                     $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$formattedValue}</div>\n";
                 } else {
                     //page display
                     if ($Source == '="Page " & [Page] & " of " & [Pages]' || $Source == 'Page #thePageNumber# of #totalNumberOfPages#') {
                         $Caption = "Page " . $this->pageNumber . " of " . $GLOBALS['TotalPages'];
                         $this->SetFont($Fontname, $Fontweight, $Fontsize);
                         $this->SetXY($Left, $Top);
                         $this->Cell($Width, $Height, $Caption, $BorderWidth, $ln, $TextAlign, $BackStyle);
                         $s = $s . "   <div class='{$Name}'>Page #thePageNumber# of #totalNumberOfPages#</div>\n";
                     } else {
                         //date display
                         if ($Source == '=Date()' or $Source == '=Now()') {
                             if ($Format == '' || $Format == '20' || $Format == 'Long Date') {
                                 $formattedValue = date('d-M-Y H:i');
                             } else {
                                 $formattedValue = date($this->accessDateFormatToPHPDateFormat($Format));
                             }
                             //$formattedValue     = date($this->accessDateFormatToPHPDateFormat($Format));
                             $Caption = $formattedValue;
                             $this->SetFont($Fontname, $Fontweight, $Fontsize);
                             $this->SetXY($Left, $Top);
                             $this->Cell($Width, $Height, $Caption, $BorderWidth, $ln, $TextAlign, $BackStyle);
                             $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$formattedValue}</div>\n";
                         } else {
                             //format number
                             if ($Format == 'Fixed') {
                                 if ($record[$this->report->Controls[$i]->ControlSource] != '') {
                                     $formattedValue = number_format($record[$this->report->Controls[$i]->ControlSource], $Decimal);
                                 }
                             }
                             //currency number
                             if ($Format == 'Currency') {
                                 $formattedValue = "\$" . number_format($record[$this->report->Controls[$i]->ControlSource], 2);
                                 $formattedValue = str_replace('$-', '-$', $formattedValue);
                             }
                             //date format (no todate() and now())
                             if (substr($Format, 0, 2) == 'dd' or substr($Format, 0, 2) == 'mm' or substr($Format, 0, 2) == 'yy' or substr($Format, 0, 2) == 'hh' or substr($Format, 0, 2) == 'nn' or substr($Format, 0, 2) == 'ss') {
                                 //for sql format case yyyy-mm-dd
                                 if (substr($formattedValue, 4, 1) == '-' and substr($formattedValue, 7, 1) == '-') {
                                     $timestamp = mktime(0, 0, 0, substr($formattedValue, 5, 2), substr($formattedValue, 8, 2), substr($formattedValue, 0, 4));
                                     $formattedValue = date($this->accessDateFormatToPHPDateFormat($Format), $timestamp);
                                 }
                             }
                             $formattedValue = formatTextValue($formattedValue, $Format);
                             //tofile($formattedValue);
                             if ($this->report->Controls[$i]->CanGrow == 'True' and $canGrow) {
                                 //$oldValue               = $formattedValue;
                                 $lines = $this->SplitAndWordWrapText($formattedValue, $Width);
                                 if (sizeof($lines) > 1) {
                                     $string = "";
                                     for ($j = 0; $j < sizeof($lines); $j++) {
                                         $lines[$j] = trim($lines[$j]);
                                         $string = $string . $lines[$j] . "<br>";
                                     }
                                 }
                                 $this->SetFont($Fontname, $Fontweight, $Fontsize);
                                 if (sizeof($lines) > 1) {
                                     //tofile("more than 1 line");
                                     $Height = $this->CalculateLineHeight($Fontsize);
                                     $this->SplitLines($Width, $Height, $string, $BorderWidth, $ln, $TextAlign, $BackColor, $BackStyle, $Left, $Top, sizeof($lines), $i);
                                 } else {
                                     //tofile("1 line only");
                                     $this->SetXY($Left, $Top);
                                     $this->Cell($Width, $Height, $lines[0], $BorderWidth, $ln, $TextAlign, $BackStyle);
                                 }
                                 /*$formattedValue         = wordwrap($formattedValue, iif(is_numeric($ReportTag) == false,10,$ReportTag), "<br />"); 
                                 									$formattedValue         = nl2br($formattedValue);
                                 
                                 									$lines                  = substr_count($formattedValue, "<br />")+1;
                                 									$defaultHeight          = $Height;
                                 									//$Height                 = $Height * iif($lines == 0, 1, $lines);
                                 									if($this->growBy < $Height - $defaultHeight){
                                 										$this->growBy       = $Height - $defaultHeight;
                                 									}
                                     								$this->SetFont($Fontname,$Fontweight,$Fontsize);
                                     								$this->SetXY($Left, $Top);
                                 
                                     								$this->Cell($Width,$Height,$this->SetStringByWidth($formattedValue,$Width-0.1),$BorderWidth,$ln,$TextAlign,$BackStyle);*/
                             } else {
                                 $Caption = $formattedValue;
                                 $output = $this->parse($Caption);
                                 //tofile("Test Caption: ".$Caption);
                                 $this->SetFont($Fontname, $Fontweight, $Fontsize);
                                 $this->SetXY($Left, $Top);
                                 if ($BackColor == '' || $BackColor == strtolower('#FFFFFF') || $BackColor == strtolower('FFFFFF')) {
                                     $BackStyle = 0;
                                 } else {
                                     $BackStyle = 1;
                                 }
                                 if ($output[0]['innerhtml'] == null) {
                                     //tofile($this->GetStringWidth($Caption)." ".$Width." ".$Caption);
                                     $this->Cell($Width, $Height, $this->SetStringByWidth($Caption, $Width - 0.1), $BorderWidth, $ln, $TextAlign, $BackStyle);
                                 } else {
                                     $this->SetHTMLAttributes($Width, $Height, $output, $BorderWidth, $ln, $TextAlign, $BackColor, $BackStyle, $Left, $Top);
                                 }
                                 //tofile($BorderColor[0]." ".$BorderColor[1]." ".$BorderColor[2]);
                                 //tofile("Border Width: ".$BorderWidth);
                                 $s = $s . "      <div class='{$Name}' style='position:absolute;top:{$Top};height:{$Height}'>{$formattedValue}</div>\n";
                             }
                         }
                     }
                 }
             }
         }
     }
     return $s;
 }
 public function addIndexes($groupByList)
 {
     $t = nuRunQuery("SELECT * FRoM {$this->sumTT}");
     nuRunQuery("ALTER TABLE `{$this->sumTT}` ADD PRIMARY KEY ( {$groupByList} ) ");
     $a = explode(',', $groupByList);
     for ($i = 0; $i < count($a); $i++) {
         nuRunQuery("ALTER TABLE {$this->sumTT} ADD INDEX (`" . $a[$i] . "`)");
     }
 }
Esempio n. 19
0
print "   return '{$id}';\n";
print "}\n";
print "\n";
print "function goBack(){\n";
print "   window.open(document.referrer,'_self');";
print "}\n";
print "\n";
print "</script>\n";
if ($stoplogin) {
    tofile('IN STOPLOGIN');
    // 2009/07/15 - Nick changed failed login attempt to use document.referrer to go back to the login page
    print "<body onload='goBack();'>\n";
} else {
    $userID = iif($r->ID == '', 'globeadmin', $r->ID);
    // 2009/06/02 - Michael - added IP logging.
    nuRunQuery("INSERT INTO zzsys_user_log (zzsys_user_log_id, sul_zzsys_user_id, sul_ip, sul_start) VALUES ('{$id}', '{$userID}', '{$_SERVER['REMOTE_ADDR']}', '{$now}')");
    //		nuRunQuery("INSERT INTO zzsys_user_log (zzsys_user_log_id, sul_zzsys_user_id, sul_start) VALUES ('$id', '$userID', '$now')");
    tofile("small : {$small}");
    if ($small == '1') {
        tofile('IN SMALL = 1');
        print "<body onload='document.index.submit();'>\n";
        print "<form name='index' method='post' action='formsmall.php?x=1&r=-1&dir={$dir}&ses={$id}&f=index'></form>\n";
    } else {
        tofile('IN SMALL <> 1');
        print "<body onload='closeAndOpenForm();'>\n";
    }
}
print "</body></html>\n";
tofile('cookie .. ' . $_COOKIE['security_check']);
function security_check()
{
Esempio n. 20
0
$emailSetup = $GLOBALS['nuSetup'];
if ($emailSetup->set_smtp_host == "" || $emailSetup->set_smtp_from_address == "" || $emailSetup->set_smtp_from_name == "" || $emailSetup->set_smtp_port == "" || $emailSetup->set_smtp_use_ssl == "") {
    header("Location: nuemailnoconfig.php");
}
if ($_REQUEST['a'] == "") {
    $form_action = "nuemailsend.php";
} else {
    //must be a valid PHP Code
    $form_action = "nucall.php?p=" . $_REQUEST['a'];
}
$input_style = "style=\"width:250px;\"";
$from = $emailSetup->set_smtp_from_address;
$sus_login_name = $_REQUEST['uname'];
if ($sus_login_name != "globeadmin") {
    $sqlUser = "******";
    $rsUser = nuRunQuery($sqlUser);
    if (db_num_rows($rsUser) > 0) {
        $objUser = db_fetch_object($rsUser);
        $replyto = $objUser->sus_email;
        $replytoname = $objUser->sus_name;
        if ($replyto == "" || $replyto == null) {
            header("Location: nuemailnoconfig.php?m=1");
        }
    } else {
        header("Location: nuemailnoconfig.php?m=1");
    }
} else {
    $replyto = $emailSetup->set_smtp_from_address;
    $replytoname = "globeadmin";
}
?>
Esempio n. 21
0
 private function buildHTMLForInarray($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX)
 {
     if ($this->displayThisObject) {
         $inputType = 'text';
     } else {
         $inputType = 'hidden';
         $fieldTitle = '';
     }
     if ($this->parentType == 'form') {
         //--not a subform
         $titleTableDetail = "{$TAB}  <td class='selected' bgcolor='{$this->bgcolor}' style='text-align:right'>{$fieldTitle}</td>{$CRLF}";
         $tr1 = "{$TAB}<tr class='selected'>{$CRLF}";
         $tr2 = "{$TAB}</tr>{$CRLF}";
         $td1 = "{$TAB}  <td class='selected' style='text-align:left'>{$CRLF}{$TAB}    ";
         $td2 = "{$TAB}  </td>{$CRLF}";
     }
     if ($PREFIX != '') {
         $untick = "untick('{$PREFIX}');";
     }
     $style = $this->addStyle('width', $this->objectProperty['sob_inarray_length'] * 16);
     $style = $style . $this->addStyle('text-align', $this->objectProperty['sob_inarray_align']);
     $s = $titleTableDetail . $td1;
     $s = $s . "<input ";
     $s = $s . $this->addProperty('type', $inputType);
     $s = $s . $this->addProperty('name', $fieldName);
     $s = $s . $this->addProperty('id', $fieldName);
     $s = $s . $this->addProperty('value', $fieldValue);
     $s = $s . $this->addProperty('accesskey', $this->objectProperty['sob_all_access_key']);
     if ($inputType == 'text') {
         if ($this->objectProperty['sob_all_class'] == '') {
             $s = $s . $this->addProperty('class', 'objects');
         } else {
             $s = $s . $this->addProperty('class', $this->objectProperty['sob_all_class']);
         }
         $s = $s . $this->addProperty('style', $style);
         $s = $s . $this->addProperty('onchange', $untick . "uDB(this);" . $fieldName . '_array(this);' . $this->objectProperty['sob_all_onchange']);
         $s = $s . $this->addProperty('onblur', $this->objectProperty['sob_all_on_blur']);
         $s = $s . $this->addProperty('onfocus', $this->objectProperty['sob_all_on_focus']);
         $s = $s . $this->addProperty('onkeypress', $this->objectProperty['sob_all_on_keypress']);
         $s = $s . $this->addProperty('ondblclick', $this->objectProperty['sob_all_on_doubleclick']);
     }
     if ($this->objectProperty['sob_text_read_only'] == '1') {
         $s = $s . " readonly='readonly' ";
     }
     $s = $s . "/>{$CRLF}";
     $s = $s . $td2;
     //---replace any hashes with variables
     $sql = replaceVariablesInString($this->TT, $this->objectProperty['sob_inarray_sql'], $this->recordID);
     //---run sql and use the first row and colomn as the value for this field
     $t = nuRunQuery($sql);
     $fun = "function {$fieldName}" . "_array(pThis){ {$CRLF}";
     $fun = $fun . "   var ar    = new Array();{$CRLF}";
     $fun = $fun . "   var found = new Boolean(false);{$CRLF}";
     $counter = 0;
     while ($r = db_fetch_row($t)) {
         if ($counter == 0) {
             $first = $r[0];
         }
         $last = $r[0];
         $fun = $fun . "   ar[{$counter}] = \"{$r['0']}\";{$CRLF}";
         $counter = $counter + 1;
     }
     $dq = '"';
     $fun = $fun . "   {$CRLF}";
     $fun = $fun . "   for (i=0 ; i < ar.length ; i++){ {$CRLF}";
     $fun = $fun . "      if(ar[i] == pThis.value){ {$CRLF}";
     $fun = $fun . "         found=true;{$CRLF}";
     $fun = $fun . "      }{$CRLF}";
     $fun = $fun . "   }{$CRLF}";
     $fun = $fun . "   if(found==false){ {$CRLF}";
     $fun = $fun . "      alert('Must be between {$dq}{$first}{$dq} and {$dq}{$last}{$dq}'){$CRLF}";
     $fun = $fun . "      pThis.value = '';{$CRLF}";
     $fun = $fun . "   }{$CRLF}";
     $fun = $fun . "}{$CRLF}";
     $this->parentForm->appendJSfunction($fun);
     return $tr1 . $s . $tr2;
 }
print "<head>\n";
print "<meta http-equiv='Content-Type' content='text/html'/>\n";
print "<title></title>\n";
print "<!-- Form Functions -->\n";
print "<script type='text/javascript'>\n";
print "/* <![CDATA[ */\n";
print "function reload(pthis){//  reload form.php\n";
if ($_POST['del_ok'] == '1') {
    print "   parent.window.close();\n";
    print "   parent.opener.document.focus();\n";
    print "   parent.opener.document.forms[0].submit();\n";
    $theform = formFields($sysformID);
    nuRunQuery("DELETE FROM {$theform->sfo_table} WHERE {$theform->sfo_primary_key} = '{$recordID}'");
    $t = nuRunQuery("SELECT * FROM zzsys_object WHERE sob_zzsys_form_id = '{$sysformID}' and sob_all_type = 'subform'");
    while ($r = db_fetch_object($t)) {
        nuRunQuery("DELETE FROM {$r->sob_subform_table} WHERE {$r->sob_subform_foreign_key} = '{$recordID}'");
    }
    //----------create an array of hash variables that can be used in any "hashString"
    $arrayOfHashVariables1 = postVariablesToHashArray();
    //--values of this record
    $arrayOfHashVariables1['#id#'] = $theRecordID;
    //--this record's id
    $arrayOfHashVariables = recordToHashArray('zzsys_session', 'zzsys_session_id', $ses);
    //--session values (access level and user etc. )
    $arrayOfHashVariables = joinHashArrays($arrayOfHashVariables, $arrayOfHashVariables1);
    //--join the arrays together
    $nuHashVariables = $arrayOfHashVariables;
    //--added by sc 23-07-2009
    //----------allow for custom code----------------------------------------------
    eval(replaceHashVariablesWithValues($arrayOfHashVariables, $theform->sfo_custom_code_run_after_delete));
} else {
Esempio n. 23
0
function getLedgerCode($ledgerID)
{
    $RS = nuRunQuery("SELECT led_code FROM ledger WHERE ledger_id = '{$ledgerID}'");
    $ledgerObj = mysql_fetch_object($RS);
    return $ledgerObj->led_code;
}
$s = "SELECT * FROM zzsys_activity_graph WHERE sag_zzsys_activity_id = '{$activityID}' AND sag_graph_name = '{$graph_name}'";
$tA = nuRunQuery($s);
$graphObject = db_fetch_object($tA);
$s = "SELECT * FROM zzsys_graph WHERE zzsys_graph_id = '{$graphObject->sag_graph_zzsys_graph_id}'";
$tB = nuRunQuery($s);
$graphType = db_fetch_object($tB);
//----------create an array of hash variables that can be used in any "hashString"
$arrayOfHashVariables = recordToHashArray('zzsys_session', 'zzsys_session_id', $ses);
//--session values (access level and user etc. )
$arrayOfHashVariables['#id#'] = $theRecordID;
//--this record's id
$arrayOfHashVariables['#clone#'] = $clone;
//--if it is a clone
$arrayOfHashVariables['#graphTable#'] = $graphTable;
//--temp table name
foreach ($_GET as $key => $value) {
    $arrayOfHashVariables["#{$key}#"] = $value;
}
//-- create a temp table called $graphTable
eval(replaceHashVariablesWithValues($arrayOfHashVariables, $graphObject->sag_graph_code));
//--replace hash variables then run code
//-- turn $graphTable into this type of graph
eval(replaceHashVariablesWithValues($arrayOfHashVariables, $graphType->sgr_graph_code));
//--replace hash variables then run code
//-----------custom code end---------------------------------------------------
//-- create a temp table called $graphTable
//	eval($graphObject->sag_graph_code);
//-- turn $graphTable into this type of graph
//	eval($graphType->sgr_graph_code);
nuRunQuery("DROP TABLE {$graphTable}");
function isDuplicate($session, $form, $recordID, $field, $value)
{
    $s = "SELECT count(*) FROM {$form->sfo_table} ";
    $s = $s . "WHERE {$field} = '{$value}' ";
    $s = $s . "AND {$form->sfo_primary_key} != '{$recordID}'";
    $t = nuRunQuery($s);
    $r = db_fetch_row($t);
    if ($r[0] != 0) {
        return true;
    }
    $id = uniqid('1');
    $theDate = date('Y-m-d H:i:s');
    $s = "INSERT INTO zzsys_duplicate (zzsys_duplicate_id, sdu_session_id, sdu_table_name, sdu_field_name, sdu_value, sdu_date)";
    $s = $s . "VALUES ('{$id}', '{$session}', '{$form->sfo_table}', '{$field}', '{$value}', '{$theDate}')";
    nuRunQuery($s, false);
    $s = "SELECT count(*) FROM zzsys_duplicate ";
    $s = $s . "WHERE sdu_session_id = '{$session}' ";
    $s = $s . "AND sdu_table_name = '{$form->sfo_table}' ";
    $s = $s . "AND sdu_field_name = '{$field}' ";
    $s = $s . "AND sdu_value = '{$value}' ";
    $t = nuRunQuery($s);
    $r = db_fetch_row($t);
    if ($r[0] != 0) {
        return false;
    }
}
Esempio n. 26
0
} else {
    $dq = '"';
}
$t = nuRunQuery("SELECT * FROM {$dataTable}");
$Field = array();
$Field = tableFieldNamesToArray($t);
if ($A->sat_export_header != '0') {
    for ($i = 0; $i < count($Field); $i++) {
        if ($i > 0) {
            print chr($ascii);
        }
        print $Field[$i];
    }
    print "\r\n";
}
$t = nuRunQuery("SELECT * FROM {$dataTable}");
while ($r = db_fetch_array($t)) {
    for ($f = 0; $f < count($Field); $f++) {
        if ($f > 0) {
            print chr($ascii);
        }
        //       $theFieldValue                       = str_replace(chr(13).chr(10), "<br/>", $r[$Field[$f]]);
        //       $theFieldValue                       = str_replace(chr(13), "<br/>", $theFieldValue);
        //       $theFieldValue                       = str_replace(chr(10), "<br/>", $theFieldValue);
        $theFieldValue = str_replace('"', '', $r[$Field[$f]]);
        print $dq . $theFieldValue . $dq;
    }
    print "\r\n";
}
nuRunQuery("DROP TABLE {$dataTable}");
Esempio n. 27
0
<?php

/*
** File:           formhelp.php
** Author:         nuSoftware
** Created:        2007/04/26
** Last modified:  2009/07/15
**
** Copyright 2004, 2005, 2006, 2007, 2008, 2009 nuSoftware
**
** This file is part of the nuBuilder source package and is licensed under the
** GPLv3. For support on developing in nuBuilder, please visit the nuBuilder
** wiki and forums. For details on contributing a patch for nuBuilder, please
** visit the `Project Contributions' forum.
**
**   Website:  http://www.nubuilder.com
**   Wiki:     http://wiki.nubuilder.com
**   Forums:   http://forums.nubuilder.com
*/
include '../' . $_GET['dir'] . '/database.php';
include 'common.php';
$f = $_GET['f'];
tofile("SELECT * FROM zzsys_form WHERE zzsys_form_id = '{$f}'");
$t = nuRunQuery("SELECT * FROM zzsys_form WHERE zzsys_form_id = '{$f}'");
$r = db_fetch_object($t);
print "<html><head><title>Help for {$r->sfo_title} Screen</title></head>";
print "<body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000>";
print $r->sfo_help;
print "</body></html>";
Esempio n. 28
0
<?php

require_once 'nucommon.php';
$response = array();
$response['DATA'] = '';
$response['SUCCESS'] = false;
$response['ERRORS'] = array();
$GLOBALS['ERRORS'] = array();
$hashData = nuHashData();
$code = $_GET['c'];
$sql = "SELECT * FROM  zzzsys_php WHERE slp_code = ?";
$t = nuRunQuery($sql, array($code));
$r = db_fetch_object($t);
if (nuPHPAccess($r->zzzsys_php_id)) {
    $r->slp_php = nuGetSafePHP('slp_php', $r->zzzsys_php_id, $r->slp_php);
    $e = nuReplaceHashes($r->slp_php, $hashData);
    eval($e);
    $response['DATA'] = $nuParameters;
    if ($nuError != '') {
        $response['ERRORS'][] = $nuError;
    }
} else {
    $response['ERRORS'][] = "Access denied to PHP - ({$r->slp_code})";
}
print json_encode($response);
Esempio n. 29
0
**
** Copyright 2004, 2005, 2006, 2007, 2008, 2009 nuSoftware
**
** This file is part of the nuBuilder source package and is licensed under the
** GPLv3. For support on developing in nuBuilder, please visit the nuBuilder
** wiki and forums. For details on contributing a patch for nuBuilder, please
** visit the `Project Contributions' forum.
**
**   Website:  http://www.nubuilder.com
**   Wiki:     http://wiki.nubuilder.com
**   Forums:   http://forums.nubuilder.com
*/
session_start();
$dir = $_GET['dir'];
include "../{$dir}/database.php";
include 'common.php';
$T = nuRunQuery("SELECT sat_report_display_code FROM zzsys_activity WHERE sat_all_code = '" . $_GET['r'] . "'");
$A = db_fetch_object($T);
eval($A->sat_report_display_code);
$report = new Reporting();
$ver = $report->Version;
if ($ver == '3') {
    include 'run_report_html_v3.php';
} else {
    if ($ver == '2') {
        include 'run_report_html_v2.php';
    } else {
        include 'run_report_html_v1.php';
    }
}
run_html_report();
 public function buildObject($C)
 {
     $lineFormat = formatForPDFandHTML($C->text_string[0]);
     //-- get any formatting stuff from the beginning of the string eg. #BOLD#
     $can_grow = $C->can_grow == '1';
     $temp_name = $this->temp_filename . $this->imagecount;
     $this->imagecount = $this->imagecount + 1;
     $draw = 'DF';
     $BC = $C->border_color;
     if (lresize($C->border_width) == 0 or $BC == 'transparent' or strtolower($BC) == 'white' or strtolower($BC) == '#ffffff' or strtolower($BC) == 'ffffff') {
         $draw = str_replace('D', '', $draw);
     }
     $BC = $C->background_color;
     if ($BC == 'transparent' or strtolower($BC) == 'white' or strtolower($BC) == '#ffffff' or strtolower($BC) == 'ffffff') {
         $draw = str_replace('F', '', $draw);
     }
     if (count($lineFormat['bgcolor']) == 0) {
         //-- no specific bg color for this object
         $color = rgbcolor($C->background_color, $this->html);
     } else {
         $color = $lineFormat['bgcolor'];
         if (strpos($draw, 'F') === false) {
             $draw = $draw . 'F';
         }
     }
     $this->SetFillColor($color['r'], $color['g'], $color['b']);
     $color = rgbcolor($C->border_color, $this->html);
     $this->SetDrawColor($color['r'], $color['g'], $color['b']);
     if (count($lineFormat['color']) == 0) {
         //-- no specific color for this object
         $color = rgbcolor($C->color, $this->html);
     } else {
         $color = $lineFormat['color'];
     }
     $this->SetTextColor($color['r'], $color['g'], $color['b']);
     $field_width = hresize($C->width);
     $this->SetLineWidth(lresize($C->border_width));
     if ($C->type != 'Graph') {
         if ($draw != '') {
             $this->Rect(hresize($C->left), vresize($C->top) + $this->section_top + 2, $field_width, hresize($C->height) + hresize($C->extra_growth), $draw);
         }
     }
     if (strpos($lineFormat['style'], 'B') === false) {
         //-- no specific boldness for this object
         if ($C->font_weight == 'bold') {
             $weight = 'B';
         } else {
             $weight = '';
         }
     } else {
         $weight = 'B';
     }
     $this->SetFont($C->font_name, $weight, fresize($C->font_size));
     $offset_top = hresize($C->original_height) * 0.2;
     if ($C->type == 'Graph') {
         if ($C->format == 'image') {
             $PT = nuRunQuery("SELECT zzsys_image_id FROM zzsys_image WHERE sim_code = '{$C->graph}'");
             $PR = db_fetch_object($PT);
             $logo = fopen(getPHPurl() . "formimage.php?dir=" . $_GET['dir'] . "&iid={$PR->zzsys_image_id}", "r");
         } else {
             $chop_at = strrpos($C->text_string[0], " width='");
             //-- chops off the "width='523' height='246' />" bit of the image
             $url = substr($C->text_string[0], 10, $chop_at - 11);
             $url = str_replace(" ", "%20", $url);
             $logo = fopen(getPHPurl() . $url, "r");
         }
         file_put_contents($temp_name . '.png', $logo);
         if (filesize($temp_name . '.png') > 0) {
             $im = imagecreatefrompng($temp_name . '.png');
             imageinterlace($im, 0);
             imagepng($im, $temp_name . '.png');
             $this->Image($temp_name . '.png', hresize($C->left), vresize($C->top) + $this->section_top + 2, $field_width, hresize($C->height) + hresize($C->extra_growth));
             unlink($temp_name . '.png');
         }
     } else {
         $string_array = array();
         if ($can_grow) {
             //-- already an array
             $string_array = $C->text_string;
         } else {
             //-- create an array
             $swap_br = array(chr(13), '<br/>', '<Br />', '<Br/>', '<BR />', '<BR/>');
             $the_string = str_replace($swap_br, '<br />', $C->text_string[0]);
             $string_array = explode("<br />", $the_string);
         }
         for ($ts = 0; $ts < count($string_array); $ts++) {
             $data = '';
             if ($ts == 0) {
                 $data = $lineFormat['string'];
                 //-- string with formatting removed
             } else {
                 $data = $string_array[$ts];
             }
             $data = str_replace('#totalNumberOfPages#', $this->total_pages, $data);
             $data = str_replace('#thePageNumber#', $this->page_no, $data);
             $data = str_replace('&nbsp;', ' ', $data);
             $data = str_replace('&nbsp', ' ', $data);
             if (strtoupper($data) == '=NOW()' or strtoupper($data) == 'NOW()') {
                 $data = $this->timestamp;
             }
             $text_width = $this->GetStringWidth($data);
             $resized_length = fwresize($text_width);
             $offset_left = 0;
             if ($C->text_align == 'right') {
                 $offset_left = vresize($C->width - $resized_length);
             }
             if ($C->text_align == 'center') {
                 $offset_left = vresize(($C->width - $resized_length) / 2);
             }
             if (!$can_grow and count($string_array) > 1) {
                 //-- dont realign top
                 $text_top = vresize($C->top) + fresize($C->font_size) / 2 * (1 * (1 + $ts)) + $this->section_top + 2;
             } else {
                 $text_top = vresize($C->top) + hresize($C->original_height) * (1 * (1 + $ts)) + $this->section_top + 2;
             }
             $left = vresize($C->left);
             $this->Text(hresize($C->left) + $offset_left, $text_top - $offset_top, $data);
         }
     }
     if ($cHeight != 0) {
     }
 }