Example #1
0
/**
 * Logs an sql error.
 *
 * @param string $message          
 * @return false
 */
function sql_error($message)
{
    sql_close();
    $message = trim($message) . "\n";
    $message .= debug_string_backtrace() . "\n";
    error_log('mysql_provider error: ' . $message);
    return false;
}
function query_to_value($query)
{
    $result = sql_query_dbg($query);
    if ($row = sql_fetch_row($result)) {
        sql_close($result);
        return $row[0];
    }
    return FALSE;
}
Example #3
0
function couponcode($upc)
{
    $man_id = substr($upc, 3, 5);
    $fam = substr($upc, 8, 3);
    $val = substr($upc, -2);
    $db = pDataConnect();
    $query = "select * from couponcodes where code = '" . $val . "'";
    $result = sql_query($query, $db);
    $num_rows = sql_num_rows($result);
    if ($num_rows == 0) {
        boxMsg("coupon type unknown<br>please enter coupon<br>manually");
    } else {
        $row = sql_fetch_array($result);
        $value = $row["Value"];
        $qty = $row["Qty"];
        if ($fam == "992") {
            $value = truncate2($value);
            $_SESSION["couponupc"] = $upc;
            $_SESSION["couponamt"] = $value;
            maindisplay("coupondeptsearch.php");
        } else {
            sql_close($db);
            $fam = substr($fam, 0, 2);
            $query = "select " . "max(unitPrice) as total, " . "max(department) as department, " . "sum(ItemQtty) as qty, " . "sum(case when trans_status = 'C' then -1 else quantity end) as couponqtty " . "from localtemptrans where substring(upc, 4, 5) = '" . $man_id . "' " . "group by substring(upc, 4, 5)";
            $db = tDataConnect();
            $result = sql_query($query, $db);
            $num_rows = sql_num_rows($result);
            if ($num_rows > 0) {
                $row = sql_fetch_array($result);
                if ($row["couponqtty"] < 1) {
                    boxMsg("Coupon already applied<BR>for this item");
                } else {
                    $dept = $row["department"];
                    $act_qty = $row["qty"];
                    if ($qty <= $act_qty) {
                        if ($value == 0) {
                            $value = -1 * $row["total"];
                        }
                        $value = truncate2($value);
                        addcoupon($upc, $dept, $value);
                        lastpage();
                    } else {
                        boxMsg("coupon requires " . $qty . "items<BR>there are only " . $act_qty . " item(s)<BR>in this transaction");
                    }
                }
            } else {
                boxMsg("product not found<BR>in transaction");
            }
            // sql_close($db);
        }
    }
}
Example #4
0
function load()
{
    $query_member = "select * from custdata where CardNo = '205203'";
    $query_product = "select * from products where upc = '0000000000090'";
    $query_localtemptrans = "select * from localtemptrans";
    $bdat = pDataConnect();
    $result = sql_query($query_product, $bdat);
    $result_2 = sql_query($query_member, $bdat);
    sql_close($bdat);
    $trans = tDataConnect();
    $result_3 = sql_query($query_localtemptrans, $trans);
    sql_close($trans);
}
Example #5
0
function nexttransno()
{
    $next_trans_no = 1;
    $db = pDataConnect();
    sql_query("update globalvalues set transno = transno + 1", $db);
    $result = sql_query("select transno from globalvalues", $db);
    $num_rows = sql_num_rows($result);
    if ($num_rows != 0) {
        $row = sql_fetch_array($result);
        $next_trans_no = $row["transno"];
    }
    sql_close($db);
}
Example #6
0
function getChgName()
{
    $query = "select LastName, FirstName from custdata where CardNo = '" . $_SESSION["memberID"] . "'";
    $connection = pDataConnect();
    $result = sql_query($query, $connection);
    $row = sql_fetch_array($result);
    $num_rows = sql_num_rows($result);
    if ($num_rows > 0) {
        if (strlen($_SESSION["memberID"]) != 4) {
            $_SESSION["ChgName"] = $row["LastName"];
        } elseif (strlen($_SESSION["memberID"]) == 4) {
            $LastInit = substr($row["LastName"], 0, 1) . ".";
            $_SESSION["ChgName"] = trim($row["FirstName"]) . " " . $LastInit;
        } else {
            $_SESSION["ChgName"] = $_SESSION["memMsg"];
        }
    }
    sql_close($connection);
}
Example #7
0
        setglobalvalue("LoggedIn", 1);
        loadglobalvalues();
        $_SESSION["training"] = 1;
        loginscreen();
    } else {
        $_SESSION["auth_fail"] = 1;
        header("Location:/login.php");
    }
} else {
    if (get_user_info(user_pass($password)) == $global_values["CashierNo"]) {
        loadglobalvalues();
        testremote();
        loginscreen();
    } else {
        if (user_pass_priv($password)) {
            loadglobalvalues();
            testremote();
            loginscreen();
        } else {
            $_SESSION["auth_fail"] = 1;
            header("Location:/login.php");
        }
        sql_close($db_a);
    }
}
getsubtotals();
$_SESSION["datetimestamp"] = strftime("%Y-%m-%m/%d/%y %T", time());
if ($_SESSION["LastID"] != 0 && $_SESSION["memberID"] != "0" and $_SESSION["memberID"]) {
    $_SESSION["unlock"] = 1;
    memberID($_SESSION["memberID"]);
}
Example #8
0
function datareload()
{
    $query_mem = "select * from custdata where CardNo='205203'";
    $query_prod = "select * from products where upc='0000000000090'";
    $query_temp = "select * from localtemptrans";
    $db_bdat = pDataConnect();
    sql_query($query_prod, $db_bdat);
    sql_query($query_mem, $db_bdat);
    sql_close($db_bdat);
    $db_trans = tDataConnect();
    sql_query($query_temp, $db_trans);
    sql_close($db_trans);
    $_SESSION["datetimestamp"] = strftime("%Y-%m-%m/%d/%y %T", time());
}
Example #9
0
function gettransno($CashierNo)
{
    $database = $_SESSION["tDatabase"];
    $register_no = $_SESSION["laneno"];
    $query = "SELECT max(trans_no) as maxtransno from localtranstoday where emp_no = '" . $CashierNo . "' and register_no = '" . $register_no . "' GROUP by register_no, emp_no";
    $connection = tDataConnect();
    $result = sql_query($query, $connection);
    $row = sql_fetch_array($result);
    if (!$row || !$row["maxtransno"]) {
        $trans_no = 1;
    } else {
        $trans_no = $row["maxtransno"] + 1;
    }
    sql_close($connection);
    return $trans_no;
}
Example #10
0
function _layout($template, $page_title = false, $v_custom = false)
{
    global $core, $user, $style, $starttime;
    // GZip
    if (_browser('gecko')) {
        ob_start('ob_gzhandler');
    }
    // Headers
    if (!headers_sent()) {
        header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($page_title !== false) {
        if (!is_array($page_title)) {
            $page_title = w($page_title);
        }
        foreach ($page_title as $k => $v) {
            $page_title[$k] = _lang($v);
        }
        $page_title = implode(' . ', $page_title);
    }
    //
    _lib_define();
    $filename = strpos($template, '#') !== false ? str_replace('#', '.', $template) : $template . '.htm';
    $style->set_filenames(array('body' => $filename));
    // SQL History
    if ($core->v('show_sql_history')) {
        foreach (_sql_history() as $i => $row) {
            if (!$i) {
                _style('sql_history');
            }
            _style('sql_history.row', array('QUERY' => str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;'), $row)));
        }
    }
    //
    $v_assign = array('SITE_TITLE' => $core->v('site_title'), 'PAGE_TITLE' => $page_title, 'G_ANALYTICS' => $core->v('google_analytics'), 'S_REDIRECT' => $user->v('session_page'), 'F_SQL' => _sql_queries());
    if ($v_custom !== false) {
        $v_assign += $v_custom;
    }
    $mtime = explode(' ', microtime());
    $v_assign['F_TIME'] = sprintf('%.2f', $mtime[0] + $mtime[1] - $starttime);
    v_style($v_assign);
    $style->pparse('body');
    sql_close();
    exit;
}
Example #11
0
                                        $sBuff .= '<tr><td><a href="#" onclick="dbexec(\'' . $dumptbl . '\');return false;">' . $tables . '</a></td></tr>';
                                    }
                                }
                            }
                            $sBuff .= '</table></div>';
                        }
                    }
                }
            }
            $sBuff .= '</td>
				<td id="dbRes" style="vertical-align:top;width:100%;"></td>
				</tr></tbody></table>';
            if (isset($p['sqlinit'])) {
                $sBuff .= mHide('jseval', 'dbhistory("s");');
            }
            sql_close($p['type'], $con);
        } else {
            $sBuff .= sDialog('Unable to connect to database');
        }
    } else {
        $sqllist = array();
        if (function_exists('mysql_connect') || function_exists('mysqli_connect')) {
            $sqllist['mysql'] = 'MySQL [using mysql_* or mysqli_*]';
        }
        if (function_exists('mssql_connect') || function_exists('sqlsrv_connect')) {
            $sqllist['mssql'] = 'MsSQL [using mssql_* or sqlsrv_*]';
        }
        if (function_exists('pg_connect')) {
            $sqllist['pgsql'] = 'PostgreSQL [using pg_*]';
        }
        if (function_exists('oci_connect]')) {
Example #12
0
	public function dl_file($name = '', $path = '', $data = '', $content_type = 'application/octet-stream', $disposition = 'attachment') {
		sql_close();

		$bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');

		$this->filename = ($name != '') ? $name : $this->filename;
		$this->filepath = ($path != '') ? $path : $this->filepath;

		$this->filename = rawurlencode(str_replace($bad_chars, '_', $this->filename));
		$this->filename = 'RockRepublik__' . preg_replace("/%(\w{2})/", '_', $this->filename);

		// Headers
		header('Content-Type: ' . $content_type . '; name="' . $this->filename . '"');
		header('Content-Disposition: ' . $disposition . '; filename="' . $this->filename . '"');
		header('Accept-Ranges: bytes');
		header('Pragma: no-cache');
		header('Expires: 0');
		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
		header('Content-transfer-encoding: binary');

		if ($data == '') {
			$this->filepath = '../' . $this->filepath;

			header('Content-length: ' . @filesize($this->filepath));
			@readfile($this->filepath);
		} else {
			print($data);
		}

		flush();
		exit;
	}
Example #13
0
function checksuspended()
{
    testremote();
    $db_a = tDataConnect();
    $m_conn = mDataConnect();
    $query_local = "select * from suspendedtoday";
    $query_remote = "select * from " . trim($_SESSION["mServer"]) . "." . trim($_SESSION["mDatabase"]) . ".dbo.suspendedtoday";
    $query = "select * from suspendedlist";
    if ($_SESSION["standalone"] == 1) {
        if ($_SESSION["remoteDBMS"] == "mssql") {
            $result = mssql_query($query_local, $db_a);
        } else {
            $result = mysql_query($query, $db_a);
        }
    } else {
        if ($_SESSION["remoteDBMS"] == "mssql") {
            $result = sql_query($query_remote, $db_a);
        } else {
            $result = mysql_query($query, $m_conn);
        }
    }
    $num_rows = sql_fetch_array($result);
    if ($num_rows == 0) {
        return 0;
    } else {
        return 1;
    }
    sql_close($db_a);
}
Example #14
0
     $_SESSION["chargetender"] = 0;
 }
 $_SESSION["discounttotal"] = $headerRow["discountTTL"];
 $_SESSION["memSpecial"] = $headerRow["memSpecial"];
 sql_close($connect);
 $queryID = "select * from custdata where CardNo = '" . $_SESSION["memberID"] . "'";
 $connID = pDataConnect();
 $result = sql_query($queryID, $connID);
 $row = sql_fetch_array($result);
 if ($row["Type"] == "PC") {
     $_SESSION["isMember"] = 1;
 } else {
     $_SESSION["isMember"] = 0;
 }
 $_SESSION["memMsg"] = blueLine($row);
 sql_close($connID);
 if ($_SESSION["isMember"] == 1) {
     $_SESSION["yousaved"] = number_format($_SESSION["transDiscount"] + $_SESSION["discounttotal"] + $_SESSION["memSpecial"] + $_SESSION["memCouponTTL"], 2);
     $_SESSION["couldhavesaved"] = 0;
     $_SESSION["specials"] = number_format($_SESSION["discounttotal"] + $_SESSION["memSpecial"], 2);
 } else {
     $dblyousaved = number_format($_SESSION["memSpecial"], 2);
     $_SESSION["yousaved"] = $_SESSION["discounttotal"];
     $_SESSION["couldhavesaved"] = number_format($_SESSION["memSpecial"], 2);
     $_SESSION["specials"] = $_SESSION["discounttotal"];
 }
 //    call to transLog, the body of the receipt comes from the view 'receipt'
 $query = "select * from rp_receipt where register_no = " . $laneno . " and emp_no = " . $cashierNo . " and trans_no = " . $transno . " order by trans_id";
 $db = tDataConnect();
 $result = sql_query($query, $db);
 $num_rows = sql_num_rows($result);
Example #15
0
    include_once "connect.php";
}
// apbw 5/3/05 BlueSkyFix
if (!function_exists("addcoupon")) {
    include_once "additem.php";
}
// apbw 5/3/05 BlueSkyFix
$dept = strtoupper(trim($_POST["dept"]));
$dept = str_replace(".", "", $dept);
if ($dept == "CL") {
    gohome();
} elseif (is_numeric(substr($dept, 2))) {
    // apbw 5/3/05 BlueSkyFix
    $dept = substr($dept, 2);
    // apbw 5/3/05 BlueSkyFix
    $upc = $_SESSION["couponupc"];
    $val = $_SESSION["couponamt"];
    $query = "select * from departments where dept_no = '" . $dept . "'";
    $db = pDataConnect();
    $result = sql_query($query, $db);
    $num_rows = sql_num_rows($result);
    if ($num_rows != 0) {
        addcoupon($upc, $dept, $val);
        gohome();
    } else {
        header("Location:coupondeptinvalid.php");
    }
    sql_close($db);
} else {
    header("Location:coupondeptinvalid.php");
}
Example #16
0
    public function home()
    {
        global $user;
        $v = $this->__(w('f e'));
        if (array_empty($v)) {
            _fatal();
        }
        $location = './style/' . $v['e'] . '/';
        $filename = _filename($v['f'], $v['e']);
        if (!@is_dir($location)) {
            _fatal();
        }
        if ($v['e'] == 'css' && $v['f'] != 'default') {
            $v['field'] = !is_numb($v['f']) ? 'alias' : 'id';
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_?? = ?
				LIMIT 1';
            if (!($tree = _fieldrow(sql_filter($sql, $v['field'], $v['f'])))) {
                _fatal();
            }
            $filetree = _rewrite($tree);
            $filename = _filename('_tree_' . $filetree, $v['e']);
        }
        // 304 Not modified response header
        if (@file_exists($location . $filename)) {
            $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT';
            $http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
            $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');
            header('Last-Modified: ' . $f_last_modified);
            if ($f_last_modified == $http_if_modified_since) {
                header('HTTP/1.0 304 Not Modified');
                header('Content-Length: 0');
                exit;
            }
        }
        switch ($v['e']) {
            case 'css':
                if ($v['f'] != 'default') {
                    $filetree = _rewrite($tree);
                    $filename = _filename('_tree_' . $filetree, $v['e']);
                    if (!@file_exists($location . $filename)) {
                        _fatal();
                    }
                }
                $browser = _browser();
                if (f($browser['browser'])) {
                    $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']);
                    foreach ($custom as $row) {
                        $handler = _filename('_tree_' . $row, 'css');
                        if (@file_exists($location . $handler)) {
                            _style('includes', array('CSS' => _style_handler('css/' . $handler)));
                        }
                    }
                }
                break;
            case 'js':
                if (!@file_exists($location . $filename)) {
                    _fatal();
                }
                _style_vreplace(false);
                break;
        }
        v_style(array('SPATH' => LIBD . 'visual'));
        sql_close();
        $ext = _style_handler($v['e'] . '/' . $filename);
        switch ($v['e']) {
            case 'css':
                $content_type = 'text/css; charset=utf-8';
                $ext = preg_replace('#(border-radius\\-?.*?)\\: ?(([0-9]+)px;)#is', _browser('firefox') || _browser('namoroka') ? '-moz-\\1: \\2' : '', $ext);
                $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext);
                $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext);
                $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext);
                break;
            case 'js':
                $content_type = 'application/x-javascript';
                require_once XFS . 'core/jsmin.php';
                $ext = JSMin::minify($ext);
                break;
        }
        ob_start('ob_gzhandler');
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 30) . ' GMT');
        header('Content-type: ' . $content_type);
        echo $ext;
        exit;
    }
Example #17
0
// include externe file from modules/include for functions, codes ...
if (file_exists("modules/include/footer_before.inc")) {
    include "modules/include/footer_before.inc";
}
foot();
// include externe file from modules/themes include for functions, codes ...
if (isset($user)) {
    if (file_exists("themes/{$cookie9}/include/footer_after.inc")) {
        include "themes/{$cookie9}/include/footer_after.inc";
    } else {
        if (file_exists("modules/include/footer_after.inc")) {
            include "modules/include/footer_after.inc";
        }
    }
} else {
    if (file_exists("themes/{$Default_Theme}/include/footer_after.inc")) {
        include "themes/{$Default_Theme}/include/footer_after.inc";
    } else {
        if (file_exists("modules/include/footer_after.inc")) {
            include "modules/include/footer_after.inc";
        }
    }
}
echo '
      </body>
   </html>';
include "sitemap.php";
global $mysql_p, $dblink;
if (!$mysql_p) {
    sql_close($dblink);
}
                                             $dump_tbl = "SELECT * FROM " . $tables . " LIMIT 0,100";
                                         } else {
                                             $dump_tbl = "";
                                         }
                                         $dump_tbl_link = $s_self . "db&connect=&sqlhost=" . $sqlhost . "&sqlport=" . $sqlport . "&sqluser="******"&sqlpass="******"&sqltype=" . $sqltype . "&sqlcode=" . urlencode($dump_tbl);
                                         $s_result .= "<tr><td onmouseup=\"return go('" . addslashes($dump_tbl_link) . "',event);\"><a target='_blank' href='" . $dump_tbl_link . "'>" . $tables . "</a></td></tr>";
                                     }
                                 }
                             }
                             $s_result .= "</table></div>";
                         }
                     }
                 }
             }
         }
         sql_close($sqltype, $con);
     } else {
         $s_result .= "<p class='notif'>Unable to connect to database</p>";
         $show_form = true;
     }
 }
 if ($show_form) {
     // sqltype : mysql, mssql, oracle, pgsql, sqlite, sqlite3, odbc, pdo
     $sqllist = array();
     if (function_exists("mysql_connect")) {
         $sqllist["mysql"] = "connect to MySQL <span style=\"font-size:12px;color:#999;\">- using mysql_*</span>";
     }
     if (function_exists("mssql_connect") || function_exists("sqlsrv_connect")) {
         $sqllist["mssql"] = "connect to MsSQL <span style=\"font-size:12px;color:#999;\">- using mssql_* or sqlsrv_*</span>";
     }
     if (function_exists("pg_connect")) {
Example #19
0
                                             $s_dump_tbl = "SELECT * FROM " . $s_tables . " LIMIT 0,100";
                                         } else {
                                             $s_dump_tbl = "";
                                         }
                                         $s_dump_tbl_link = $s_self . "x=db&connect=&sqlhost=" . pl($s_sql['host']) . "&sqlport=" . pl($s_sql['port']) . "&sqluser="******"&sqlpass="******"&sqltype=" . pl($s_sql['type']) . "&sqlcode=" . pl($s_dump_tbl);
                                         $s_result .= "<tr><td ondblclick=\"return go('" . adds($s_dump_tbl_link) . "',event);\"><a href='" . $s_dump_tbl_link . "'>" . $s_tables . "</a></td></tr>";
                                     }
                                 }
                             }
                             $s_result .= "</table></div>";
                         }
                     }
                 }
             }
         }
         sql_close($s_sql['type'], $s_con);
     } else {
         $s_result .= notif("Unable to connect to database");
         $s_show_form = true;
     }
 }
 if ($s_show_form) {
     // sqltype : mysql, mssql, oracle, pgsql, sqlite, sqlite3, odbc, pdo
     $s_sqllist = array();
     if (function_exists("mysql_connect")) {
         $s_sqllist["mysql"] = "Connect to MySQL <span class='desc' style='font-size:12px;'>- using class mysqli or mysql_*</span>";
     }
     if (function_exists("mssql_connect") || function_exists("sqlsrv_connect")) {
         $s_sqllist["mssql"] = "Connect to MsSQL <span class='desc' style='font-size:12px;'>- using sqlsrv_* or mssql_*</span>";
     }
     if (function_exists("pg_connect")) {
Example #20
0
function tenderReport()
{
    $db_a = mDataConnect();
    $blank = "             ";
    $eosQ = "select max(tdate) from dlog where register_no = " . $_SESSION["laneno"] . " and upc = 'ENDOFSHIFT'";
    $eosR = mysql_query($eosQ);
    $row = mysql_fetch_row($eosR);
    $EOS = $row[0];
    //	$EOS = '2007-08-01 12:00:00';
    $query_ckq = "select * from cktenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_ccq = "select * from cctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_dcq = "select * from dctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_miq = "select * from mitenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_fsq = "select * from fstenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_bp = "select * from buspasstotals where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $fieldNames = "  " . substr("Time" . $blank, 0, 10) . substr("Lane" . $blank, 0, 7) . substr("Trans #" . $blank, 0, 6) . substr("Emp #" . $blank, 0, 8) . substr("Change" . $blank, 0, 10) . substr("Amount" . $blank, 0, 10) . "\n";
    $ref = centerString(trim($_SESSION["CashierNo"]) . "-" . trim($_SESSION['laneno']) . " " . trim($_SESSION["cashier"]) . " " . build_time(time())) . "\n";
    // ----------------------------------------------------------------------------------------------------
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("T E N D E R  R E P O R T") . "\n";
    $receipt .= $ref;
    $receipt .= centerString("------------------------------------------------------");
    $receipt .= str_repeat("\n", 2);
    // --------------------------------
    // ccm-rle 10-12-2009 adding a total gross query that calculates the total gross sales
    // removed the sales tax from the gross total by removing IN (,'A') from trans_type
    $grossQ = "SELECT SUM(total) AS gross \r\n                from dlog\r\n                where tdate > '" . $EOS . "'\r\n                and register_no = " . $_SESSION['laneno'] . "\r\n                and trans_type IN('I','D')\r\n                and trans_subtype NOT IN('IC','MC')\n                and trans_status <> 'X'\r\n                and UPC <> 'DISCOUNT'\r\n                AND emp_no <> 9999";
    // ccm-rle delete this
    /*        $fp=fopen('cancel-log.txt','w');
    
            fwrite($fp,$grossQ);
            fclose($fp);
    */
    $grossR = mysql_query($grossQ);
    $row = mysql_fetch_row($grossR);
    $receipt .= "  " . substr("Gross Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    $receipt .= "\n";
    // --- ccm-rle adding total discounts for tracking purposes to tenderReport
    $disc_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n                FROM dlog\r\n                WHERE tdate > '" . $EOS . "'\r\n                AND register_no = " . $_SESSION['laneno'] . "               \r\n                AND upc = 'DISCOUNT'\n\t\tAND emp_no <> 9999";
    $results_tot = mysql_query($disc_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("Discount Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8) . "\n";
    // ccm-rle adding up all of the items that were taxable as sales - this number won't include items that were food stamp tendered... so I'm commenting it out.
    /*
            $taxablesalesQ = "SELECT SUM(total) AS gross 
                    from dlog
                    where tdate > '" .$EOS. "'
                    and register_no = " .$_SESSION['laneno']. "
                    and trans_type IN('I','D')
                    and trans_subtype <> 'IC'
                    and tax = 1
                    and trans_status <> 'X'
                    AND emp_no <> 9999";
    
            $taxablesalesR = mysql_query($taxablesalesQ);
            $row = mysql_fetch_row($taxablesalesR);
    
            $receipt .= "  ".substr("Taxable Sales Total: ".$blank.$blank,0,20);
            $receipt .= substr($blank.number_format(($row[0]),2),-8)."\n";
            $receipt .= "\n";
    */
    // ccm-rle added total tax to tender tape as well
    $tax_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n                FROM dlog\r\n                WHERE tdate > '" . $EOS . "'\r\n                AND register_no = " . $_SESSION['laneno'] . "               \n\t\tAND emp_no <> 9999\r\n                AND trans_type = 'A'";
    $results_tot = mysql_query($tax_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("Sales Tax Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    // ----------------------------------------------------------------------------------------------------
    // ccm-rle 10-8-2009 added trans_status <> 'X' to below so that transactions that are cancelled are not counted in the register. This may not be the best idea. This is actually already done by dlog automatically.
    $netQ = "SELECT SUM(total) AS net\r\n\t\tfrom dlog\r\n\t\twhere tdate > '" . $EOS . "'\r\n\t\tand register_no = " . $_SESSION['laneno'] . "\r\n\t\tand trans_type IN('I','D','A')\r\n\t\tand trans_subtype NOT IN('IC','MC')\n\t\tAND emp_no <> 9999";
    $netR = mysql_query($netQ);
    $row = mysql_fetch_row($netR);
    $receipt .= "  " . substr("NET Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    $receipt .= "\n";
    // ccm-rle 4-20-2010 Coupons that are tendered vs. scanned don't show up under net, but do under tender totals. So in order to balance the register we need the unscanned coupon total added up. This is a work around but should balance the reports.
    $coupontenderQ = "SELECT SUM(total) AS coupontender\n                from dlog\n                where tdate > '" . $EOS . "'\n                and register_no = " . $_SESSION['laneno'] . "\n                and trans_type IN('T')\n                and trans_subtype = 'MC'\n                AND emp_no <> 9999";
    $coupontenderR = mysql_query($coupontenderQ);
    $row = mysql_fetch_row($coupontenderR);
    $receipt .= "  " . substr("Unscanned Coupon Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    $receipt .= "\n";
    // ccm-rle this is where the various tendered items are added to the receipt such as debit card and WIC, in order to remove unused tenders the database needs to be modified to remove them and also is4c needs to have the commented out as potential tender sources. For the purposes of CCM we will be removed debit cards, EBT cash, WIC, prehkeys.php is where the tenders are recognized by is4c. ignoring this for now to code in needed aspects.
    $tendertotalsQ = "SELECT t.TenderName as tender_type,ROUND(-sum(d.total),2) as total,COUNT(*) as count\r\n\t\tFROM dlog d RIGHT JOIN is4c_op.tenders t\r\n\t\tON d.trans_subtype = t.TenderCode\r\n\t\tAND tdate > '" . $EOS . "'\r\n\t\tAND register_no = " . $_SESSION['laneno'] . " \r\n\t\tAND d.emp_no <> 9999\r\n                AND trans_status <> 'X'\r\n\t\tGROUP BY t.TenderName";
    $results_ttq = mysql_query($tendertotalsQ);
    while ($row = mysql_fetch_row($results_ttq)) {
        if (!isset($row[0])) {
            $receipt .= "NULL";
        } else {
            $receipt .= "  " . substr($row[0] . $blank . $blank, 0, 20);
        }
        if (!isset($row[1])) {
            $receipt .= "    0.00";
        } else {
            $receipt .= substr($blank . number_format($row[1], 2), -8);
        }
        if (!isset($row[2])) {
            $receipt .= "NULL";
        } else {
            if (!isset($row[1])) {
                $row[2] = 0;
            }
            $receipt .= substr($blank . $row[2], -4, 4);
        }
        $receipt .= "\n";
    }
    $receipt .= "\n";
    $cack_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n\t\tFROM dlog\r\n\t\tWHERE tdate > '" . $EOS . "'\r\n\t\tAND register_no = " . $_SESSION['laneno'] . "\r\n\t\tAND trans_subtype IN ('CA','CK')\n\t\tAND emp_no <> 9999";
    $results_tot = mysql_query($cack_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("CA & CK Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8) . "\n";
    $card_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n\t\tFROM dlog\r\n\t\tWHERE tdate > '" . $EOS . "'\r\n\t\tAND register_no = " . $_SESSION['laneno'] . "\n\t\tAND emp_no <> 9999\t\t\r\n\t\tAND trans_subtype IN ('DC','CC','FS','EC')";
    $results_tot = mysql_query($card_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("DC / CC / EBT Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8) . "\n";
    $hchrg_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n\t\tFROM dlog\r\n\t\tWHERE tdate > '" . $EOS . "'\r\n\t\tAND register_no = " . $_SESSION['laneno'] . "\r\n\t\tAND trans_subtype = 'MI'\n\t\tAND emp_no <> 9999\n\t\tAND card_no <> 9999";
    $results_tot = mysql_query($hchrg_tot);
    $row = mysql_fetch_row($results_tot);
    // ccm-rle commenting out the House and Storage Charge totals as they are not used by ccm
    /*
    	$receipt .= "  ".substr("House Charge Total: ".$blank.$blank,0,20);
    	$receipt .= substr($blank.number_format(($row[0] * -1),2),-8)."\n";
    	$schrg_tot = "SELECT ROUND(SUM(total),2) AS gross
    		FROM dlog
    		WHERE tdate > '" .$EOS. "'
    		AND register_no = ".$_SESSION['laneno']."
    		AND trans_subtype = 'MI'
    		AND card_no = 9999";
    	$results_tot = mysql_query($schrg_tot);
    	$row = mysql_fetch_row($results_tot);
    	$receipt .= "  ".substr("Store Charge Total: ".$blank.$blank,0,20);
    	$receipt .= substr($blank.number_format(($row[0] * -1),2),-8)."\n";
    */
    $receipt .= str_repeat("\n", 5);
    // apbw/tt 3/16/05 Franking II
    // ccm-rle adding a place here to count the number of cancelled transactions, no sales & hanging suspended
    // This adds the number of cancelled transactions for this tender report
    $cancelledtranQ = "SELECT COUNT(DISTINCT trans_no, emp_no) \r\n                from dtransactions \r\n                where datetime > '" . $EOS . "'\r\n                and register_no = " . $_SESSION['laneno'] . "\r\n                and trans_status = 'X'\r\n                AND emp_no <> 9999";
    /*        $fp=fopen('cancel-log.txt','w');
    	
    	fwrite($fp,$cancelledtranQ);
    	fclose($fp);
    */
    $cancelledtranR = mysql_query($cancelledtranQ);
    $row = mysql_fetch_row($cancelledtranR);
    $receipt .= "  " . substr("# of Cancelled Transactions: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    $receipt .= "\n";
    /*   ccm-rle This code was used to ensure there were no suspended transactions 	
    	$suspendedtranQ = "SELECT COUNT(DISTINCT trans_no)
    		from suspendedtoday
    		where datetime > '" .$EOS. "'
                    and register_no = " .$_SESSION['laneno']. "
    		and emp_no <> 9999";
    	$suspendedtranR = mysql_query($suspendedtranQ);
    	$row = mysql_fetch_row($suspendedtranR);
    	
            $receipt .= "  ".substr("# of Suspended Transactions: ".$blank.$blank,0,20);
            $receipt .= substr($blank.number_format(($row[0]),2),-8)."\n";
    	$receipt .= "\n";
    
    */
    $tranQ = "SELECT COUNT(DISTINCT trans_no, emp_no) \r\n                from dlog\r\n                where tdate > '" . $EOS . "'\r\n                and register_no = " . $_SESSION['laneno'] . "\r\n                and trans_status <> 'X'\r\n                AND emp_no <> 9999";
    $tranR = mysql_query($tranQ);
    $row = mysql_fetch_row($tranR);
    $receipt .= "  " . substr("Total Completed  Transactions: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    $receipt .= "\n";
    $receipt .= str_repeat("\n", 5);
    // apbw/tt 3/16/05 Franking II
    // ccm-rle Next need to write code to look up number of suspended transactions that are left hanging.
    // ----------------------------------------------------------------------------------------------------
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("C H E C K   T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_ckq = sql_query($query_ckq, $db_a);
    $num_rows_ckq = sql_num_rows($result_ckq);
    if ($num_rows_ckq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_ckq; $i++) {
            $row_ckq = sql_fetch_array($result_ckq);
            $timeStamp = timeStamp($row_ckq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_ckq["register_no"] . $blank, 0, 7) . substr($row_ckq["trans_no"] . $blank, 0, 6) . substr($row_ckq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_ckq["changeGiven"], 2), -10) . substr($blank . number_format($row_ckq["ckTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        //		$query_ckq = "select * from cktendertotal where register_no = ".$_SESSION["laneno"];
        //		$result_ckq = sql_query($query_ckq, $db_a);
        //		$row_ckq = sql_fetch_array($result_ckq);
        $query_ckq = "select SUM(ckTender) from cktenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_ckq = sql_query($query_ckq, $db_a);
        $row_ckq = sql_fetch_array($result_ckq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_ckq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    //ccm-rle commented out debit card tenders because for ccm they are combined with credit card tenders
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("D E B I T  C A R D  T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_dcq = sql_query($query_dcq, $db_a);
    $num_rows_dcq = sql_num_rows($result_dcq);
    if ($num_rows_dcq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_dcq; $i++) {
            $row_dcq = sql_fetch_array($result_dcq);
            $timeStamp = timeStamp($row_dcq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_dcq["register_no"] . $blank, 0, 7) . substr($row_dcq["trans_no"] . $blank, 0, 6) . substr($row_dcq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_dcq["changeGiven"], 2), -10) . substr($blank . number_format($row_dcq["dcTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        //		$query_dcq = "select * from dctendertotal where emp_no = ".$_SESSION["CashierNo"];
        //		$result_dcq = sql_query($query_dcq, $db_a);
        //		$row_dcq = sql_fetch_array($result_dcq);
        $query_dcq = "select SUM(dcTender) from dctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_dcq = sql_query($query_dcq, $db_a);
        $row_dcq = sql_fetch_array($result_dcq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_dcq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("C R E D I T   C A R D   T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_ccq = sql_query($query_ccq, $db_a);
    $num_rows_ccq = sql_num_rows($result_ccq);
    if ($num_rows_ccq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_ccq; $i++) {
            $row_ccq = sql_fetch_array($result_ccq);
            $timeStamp = timeStamp($row_ccq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_ccq["register_no"] . $blank, 0, 7) . substr($row_ccq["trans_no"] . $blank, 0, 6) . substr($row_ccq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_ccq["changeGiven"], 2), -10) . substr($blank . number_format($row_ccq["ccTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        //		$query_ccq = "select * from cctendertotal where register_no = ".$_SESSION["laneno"];
        //		$result_ccq = sql_query($query_ccq, $db_a);
        //		$row_ccq = sql_fetch_array($result_ccq);
        $query_ccq = "select SUM(ccTender) from cctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_ccq = sql_query($query_ccq, $db_a);
        $row_ccq = sql_fetch_array($result_ccq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_ccq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    //test
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("E B T  T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_fsq = sql_query($query_fsq, $db_a);
    $num_rows_fsq = sql_num_rows($result_fsq);
    if ($num_rows_fsq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_fsq; $i++) {
            $row_fsq = sql_fetch_array($result_fsq);
            $timeStamp = timeStamp($row_fsq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_fsq["register_no"] . $blank, 0, 7) . substr($row_fsq["trans_no"] . $blank, 0, 6) . substr($row_fsq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_fsq["changeGiven"], 2), -10) . substr($blank . number_format($row_fsq["FsTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        //		$query_fsq = "select * from fstendertotal where emp_no = ".$_SESSION["CashierNo"];
        //		$result_fsq = sql_query($query_fsq, $db_a);
        //		$row_fsq = sql_fetch_array($result_fsq);
        $query_fsq = "select SUM(fsTender) from fstenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_fsq = sql_query($query_fsq, $db_a);
        $row_fsq = sql_fetch_array($result_fsq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_fsq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    //ccm-rle commented out house store charges because ccm doesn't currently use them
    /*
    	$receipt .= centerString("H O U S E / S T O R E   C H A R G E   T E N D E R S")."\n";
    	$receipt .=	centerString("------------------------------------------------------");
    
    	$result_miq = sql_query($query_miq, $db_a);
    	$num_rows_miq = sql_num_rows($result_miq);
    
    	if ($num_rows_miq > 0) {
    		
    		$chgFieldNames = "  ".substr("Time".$blank, 0, 10)
    				.substr("Lane".$blank, 0, 7)
    				.substr("Trans #".$blank, 0, 6)
    				.substr("Emp #".$blank, 0, 8)
    				.substr("Member #".$blank, 0, 10)
    				.substr("Amount".$blank, 0, 10)."\n";
    		
    		$receipt .= $chgFieldNames;
    
    		for ($i = 0; $i < $num_rows_miq; $i++) {
    			$row_miq = sql_fetch_array($result_miq);
    			$timeStamp = timeStamp($row_miq["tdate"]);
    			$receipt .= "  ".substr($timeStamp.$blank, 0, 10)
    				.substr($row_miq["register_no"].$blank, 0, 7)
    				.substr($row_miq["trans_no"].$blank, 0, 6)
    				.substr($row_miq["emp_no"].$blank, 0, 6)
    				.substr($row_miq["card_no"].$blank, 0, 6)
    				.substr($blank.number_format($row_miq["MiTender"], 2), -10)."\n";
    
    		}
    
    		$receipt.= centerString("------------------------------------------------------");
    
    //		$query_miq = "select * from mitendertotal where register_no = ".$_SESSION["laneno"];
    //		$result_miq = sql_query($query_miq, $db_a);
    //		$row_miq = sql_fetch_array($result_miq);
    
    		$query_miq = "select SUM(miTender) from mitenders where tdate > '".$EOS."' and register_no = ".$_SESSION["laneno"];
    		$result_miq = sql_query($query_miq, $db_a);
    		$row_miq = sql_fetch_array($result_miq);
    
    		$receipt .= substr($blank.$blank.$blank.$blank."Total: ".number_format($row_miq[0],2), -56)."\n";
    	}
    	else {
    		$receipt .= "\n\n".centerString(" * * *   N O N E   * * * ")."\n\n"
    			.centerString("------------------------------------------------------");
    	}
    
    	$receipt .= str_repeat("\n", 3);	// apbw/tt 3/16/05 Franking II
    */
    //--------------------------------------------------------------------
    //ccm-rle commented out TRI MET passes because CCM doesn't use them
    /*
    		$receipt .= chr(27).chr(33).chr(5).centerString("T R I - M E T  P A S S E S   S O L D")."\n";
    	$receipt .=	centerString("------------------------------------------------------");
    
    	$result_bp = sql_query($query_bp, $db_a);
    	$num_rows_bp = sql_num_rows($result_bp);
    
    	if ($num_rows_bp > 0) {
    
    		$receipt .= $fieldNames;
    
    		for ($i = 0; $i < $num_rows_bp; $i++) {
    
    			$row_bp = sql_fetch_array($result_bp);
    			$timeStamp = timeStamp($row_bp["tdate"]);
    			$receipt .= "  ".substr($timeStamp.$blank, 0, 10)
    				.substr($row_bp["register_no"].$blank, 0, 7)
    				.substr($row_bp["trans_no"].$blank, 0, 6)
    				.substr($row_bp["emp_no"].$blank, 0, 6)
    				.substr($blank.($row_bp["upc"]), -10)
    				.substr($blank.number_format($row_bp["total"], 2), -10)."\n";
    		}
    
    		$receipt.= centerString("------------------------------------------------------");
    	}
    	else {
    		$receipt .= "\n\n".centerString(" * * *   N O N E   * * * ")."\n\n"
    			.centerString("------------------------------------------------------");
    	}
    */
    $receipt .= str_repeat("\n", 8);
    // apbw/tt 3/16/05 Franking II
    // ccm-rle - this creates a txt log on the IS4C computer of every tender report for logging purposes
    $tender_date = date('Y-m-d-H-i-s');
    $tender_log_file = "/pos/logs/tenderlog_" . $tender_date . "_" . $_SESSION["laneno"] . ".txt";
    $fp = fopen($tender_log_file, 'w');
    fwrite($fp, $receipt . chr(27) . chr(105));
    fclose($fp);
    writeLine($receipt . chr(27) . chr(105));
    // apbw/tt 3/16/05 Franking II
    sql_close($db_a);
    $_SESSION["msgrepeat"] = 1;
    $_SESSION["strRemembered"] = "ES";
    gohome();
}
Example #21
0
function voidupc($upc)
{
    $lastpageflag = 1;
    $deliflag = 0;
    if (strpos($upc, "*") && (strpos($upc, "**") || strpos($upc, "*") == 0 || strpos($upc, "*") == strlen($upc) - 1)) {
        $upc = "stop";
    } elseif (strpos($upc, "*")) {
        $voidupc = explode("*", $upc);
        if (!is_numeric($voidupc[0])) {
            $upc = "stop";
        } else {
            $quantity = $voidupc[0];
            $upc = $voidupc[1];
            $weight = 0;
        }
    } elseif (!is_numeric($upc) && !strpos($upc, "DP")) {
        $upc = "stop";
    } else {
        $quantity = 1;
        $weight = $_SESSION["weight"];
    }
    if (is_numeric($upc)) {
        $upc = substr("0000000000000" . $upc, -13);
        if (substr($upc, 0, 3) == "002" && substr($upc, -5) != "00000") {
            $scaleprice = substr($upc, 10, 4) / 100;
            $upc = substr($upc, 0, 8) . "0000";
            $deliflag = 1;
        } elseif (substr($upc, 0, 3) == "002" && substr($upc, -5) == "00000") {
            $scaleprice = $_SESSION["scaleprice"];
            $deliflag = 1;
        }
    }
    if ($upc == "stop") {
        inputUnknown();
    } else {
        $db = tDataConnect();
        if ($_SESSION["discounttype"] == 3) {
            $query = "select sum(quantity) as voidable, max(scale), as scale, max(volDiscType) as volDiscType " . "from localtemptrans where upc = '" . $upc . "' and discounttype = 3 and unitPrice = " . $_SESSION["caseprice"] . " group by upc";
        } elseif ($deliflag == 0) {
            $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and discounttype <> 3 group by upc, discounttype";
        } else {
            $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and unitPrice = " . $scaleprice . " and discounttype <> 3 group by upc";
        }
        if ($_SESSION["ddNotify"] == 1) {
            $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and discounttype <> 3 and discountable = " . $_SESSION["discountable"] . " group by upc, discounttype, discountable";
        }
        $result = sql_query($query, $db);
        $num_rows = sql_num_rows($result);
        if ($num_rows == 0) {
            boxMsg("Item not found");
        } else {
            $row = sql_fetch_array($result);
            if ($row["scale"] == 1 && $weight > 0) {
                $quantity = $weight - $_SESSION["tare"];
                $_SESSION["tare"] = 0;
            }
            $volDiscType = $row["volDiscType"];
            $voidable = nullwrap($row["voidable"]);
            $VolSpecial = 0;
            $volume = 0;
            $scale = nullwrap($row["scale"]);
            if ($voidable == 0 && $quantity == 1) {
                boxMsg("Items already voided");
            } elseif ($voidable == 0 && $quantity > 1) {
                boxMsg("Items already voided");
            } elseif ($scale == 1 && $quantity < 0) {
                boxMsg("tare weight cannot be greater than item weight");
            } elseif ($voidable < $quantity && $row["scale"] == 1) {
                $message = "Void request exceeds<br />weight of item rung in<p><b>You can void up to " . $row["voidable"] . " lb</b></p>";
                boxMsg($message);
            } elseif ($voidable < $quantity) {
                $message = "Void request exceeds<br />number of items rung in<p><b>You can void up to " . $row["voidable"] . "</b></p>";
                boxMsg($message);
            } else {
                unset($result);
                //--------------------------------Void Item----------------------------
                if ($_SESSION["discounttype"] == 3) {
                    $query_upc = "select * from localtemptrans where upc = '" . $upc . "' and discounttype = 3 and unitPrice = " . $_SESSION["caseprice"];
                } elseif ($deliflag == 0) {
                    $query_upc = "select * from localtemptrans where upc = '" . $upc . "' and discounttype <> 3";
                } else {
                    $query_upc = "select * from localtemptrans where upc = '" . $upc . "' and unitPrice = " . $scaleprice;
                }
                $_SESSION["discounttype"] = 9;
                $result = sql_query($query_upc, $db);
                $row = sql_fetch_array($result);
                $ItemQtty = $row["ItemQtty"];
                $foodstamp = nullwrap($row["foodstamp"]);
                $discounttype = nullwrap($row["discounttype"]);
                $mixMatch = nullwrap($row["mixMatch"]);
                if ($_SESSION["isMember"] != 1 && $row["discounttype"] == 2 || $_SESSION["isStaff"] == 0 && $row["discounttype"] == 4) {
                    $unitPrice = $row["regPrice"];
                } elseif (($_SESSION["isMember"] == 1 && $row["discounttype"] == 2 || $_SESSION["isStaff"] != 0 && $row["discounttype"] == 4) && $row["unitPrice"] == $row["regPrice"]) {
                    $db_p = pDataConnect();
                    $query_p = "select * from products where upc = '" . $upc . "'";
                    $result_p = sql_query($query_p, $db_p);
                    $row_p = sql_fetch_array($result_p);
                    $unitPrice = $row_p["special_price"];
                    sql_close($db_p);
                } else {
                    $unitPrice = $row["unitPrice"];
                }
                $discount = -1 * $row["discount"];
                $memDiscount = -1 * $row["memDiscount"];
                $discountable = $row["discountable"];
                $cost = 0;
                if ($_SESSION["ddNotify"] == 1) {
                    $discountable = $_SESSION["discountable"];
                }
                //----------------------mix match---------------------
                if ($volDiscType >= 1) {
                    $db_mm = tDataConnect();
                    $query_mm = "select sum(ItemQtty) as mmqtty from localtemptrans where mixMatch = " . $mixMatch;
                    $result_mm = sql_query($query_mm, $db_mm);
                    $row_mm = sql_fetch_array($result_mm);
                    $mmqtty = nullwrap($row_mm["mmqtty"]);
                    sql_close($db_mm);
                    $db_pq = pDataConnect();
                    $query_pq = "select * from products where upc = '" . $upc . "'";
                    $result_pq = sql_query($query_pq, $db_pq);
                    $row_pq = sql_fetch_array($result_pq);
                    if ($volDiscType == 1) {
                        $unitPrice = truncate2($row_pq["groupprice"] / $row_pq["quantity"]);
                    } elseif ($discounttype == 1) {
                        $unitPrice = $row_pq["special_price"];
                        $VolSpecial = nullwrap($row_pq["specialgroupprice"]);
                    } else {
                        $unitPrice = $row_pq["normal_price"];
                        $VolSpecial = nullwrap($row_pq["groupprice"]);
                    }
                    if ($row_pq["advertised"] == 0) {
                        $volume = nullwrap($row_pq["quantity"]);
                    } else {
                        $volume = nullwrap($row_pq["specialquantity"]);
                    }
                    sql_close($db_pq);
                    $volmulti = (int) ($quantity / $volume);
                    $vmremainder = $quantity % $volume;
                    if ($mixMatch == 0) {
                        $mm = (int) ($voidable / $volume);
                        $mmremainder = $voidable % $volume;
                    } else {
                        $mm = (int) ($mmqtty / $volume);
                        $mmremainder = $mmqtty % $volume;
                    }
                    if ($volmulti > 0) {
                        addItem($upc, $row["description"], $row["trans_type"], $row["trans_subtype"], "V", $row["department"], $cost, -1 * $volmulti, $VolSpecial, -1 * $volmulti * $VolSpecial, $VolSpecial, 0, $row["tax"], $foodstamp, $discount, $memDiscount, $discountable, $discounttype, -1 * $volmulti * $volume, $volDiscType, $volume, $VolSpecial, $mixMatch, -1 * $volume * $volmulti, 1, 0, '');
                        $quantity = $vmremainder;
                    }
                    if ($vmremainder > $mmremainder) {
                        $voladj = $row["VolSpecial"] - $unitPrice * ($volume - 1);
                        addItem($upc, $row["description"], $row["trans_type"], $row["trans_subtype"], "V", $row["department"], $cost, -1, $voladj, -1 * $voladj, $voladj, 0, $row["tax"], $foodstamp, $discount, $memDiscount, $discountable, $discounttype, -1, $volDiscType, $volume, $VolSpecial, $mixMatch, -1 * $volume, 1, 0, '');
                        $quantity = $quantity - 1;
                    }
                }
                $quantity = -1 * $quantity;
                $total = truncate2($quantity * $unitPrice);
                $CardNo = $_SESSION["memberID"];
                $discounttype = nullwrap($row["discounttype"]);
                if ($discounttype == 3) {
                    $quantity = -1 * $ItemQtty;
                }
                if ($_SESSION["tenderTotal"] < 0 && $foodstamp == 1 && -1 * $total > $_SESSION["fsEligible"]) {
                    boxMsg("Item already paid for");
                    $lastpageflag = 0;
                } elseif ($_SESSION["tenderTotal"] < 0 && -1 * $total > $_SESSION["runningTotal"] - $_SESSION["taxTotal"]) {
                    boxMsg("Item already paid for");
                    $lastpageflag = 0;
                } elseif ($quantity != 0) {
                    addItem($upc, $row["description"], $row["trans_type"], $row["trans_subtype"], "V", $row["department"], $cost, $quantity, $unitPrice, $total, $row["regPrice"], $scale, $row["tax"], $foodstamp, $discount, $memDiscount, $discountable, $discounttype, $quantity, $volDiscType, $volume, $VolSpecial, $mixMatch, 0, 1, 0, '');
                    if ($row["trans_type"] != "T") {
                        $_SESSION["ttlflag"] = 0;
                        $_SESSION["ttlrequested"] = 0;
                        $_SESSION["discounttype"] = 0;
                    }
                }
                if ($lastpageflag == 1) {
                    lastpage();
                } else {
                    $lastpageflag = 1;
                }
            }
        }
    }
}
Example #22
0
function tenderReport()
{
    $db_a = mDataConnect();
    $blank = "             ";
    $eosQ = "select max(tdate) from dlog where register_no = " . $_SESSION["laneno"] . " and upc = 'ENDOFSHIFT'";
    $eosR = mysql_query($eosQ);
    $num_rows = mysql_num_rows($eosR);
    if ($num_rows > 0) {
        $row = mysql_fetch_row($eosR);
        $EOS = $row[0];
    } else {
        $EOS = '2007-08-01 12:00:00';
        // probably could change...
    }
    $query_ckq = "select * from cktenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_ccq = "select * from cctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_dcq = "select * from dctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_miq = "select * from mitenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $query_bp = "select * from buspasstotals where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"] . " order by emp_no, tdate";
    $fieldNames = "  " . substr("Time" . $blank, 0, 10) . substr("Lane" . $blank, 0, 7) . substr("Trans #" . $blank, 0, 6) . substr("Emp #" . $blank, 0, 8) . substr("Change" . $blank, 0, 10) . substr("Amount" . $blank, 0, 10) . "\n";
    $ref = centerString(trim($_SESSION["CashierNo"]) . "-" . trim($_SESSION['laneno']) . " " . trim($_SESSION["cashier"]) . " " . build_time(time())) . "\n";
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("T E N D E R  R E P O R T") . "\n";
    $receipt .= $ref;
    $receipt .= centerString("------------------------------------------------------");
    $receipt .= str_repeat("\n", 2);
    $netQ = "SELECT SUM(total) AS net\r\n        from dlog\r\n        where tdate > '" . $EOS . "'\r\n        and register_no = " . $_SESSION['laneno'] . "\r\n        and trans_type IN('I','D')\r\n        and trans_subtype <> 'IC'\r\n        AND emp_no <> 9999";
    $netR = mysql_query($netQ);
    $row = mysql_fetch_row($netR);
    $receipt .= "  " . substr("NET Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0], 2), -8) . "\n";
    $receipt .= "\n";
    $tendertotalsQ = "SELECT t.TenderName as tender_type,ROUND(-sum(d.total),2) as total,COUNT(*) as count\r\n        FROM dlog d RIGHT JOIN is4c_op.tenders t\r\n        ON d.trans_subtype = t.TenderCode\r\n        AND tdate > '" . $EOS . "'\r\n        AND register_no = " . $_SESSION['laneno'] . " \r\n        AND d.emp_no <> 9999\r\n        GROUP BY t.TenderName";
    $results_ttq = mysql_query($tendertotalsQ);
    while ($row = mysql_fetch_row($results_ttq)) {
        if (!isset($row[0])) {
            $receipt .= "NULL";
        } else {
            $receipt .= "  " . substr($row[0] . $blank . $blank, 0, 20);
        }
        if (!isset($row[1])) {
            $receipt .= "    0.00";
        } else {
            $receipt .= substr($blank . number_format($row[1], 2), -8);
        }
        if (!isset($row[2])) {
            $receipt .= "NULL";
        } else {
            if (!isset($row[1])) {
                $row[2] = 0;
            }
            $receipt .= substr($blank . $row[2], -4, 4);
        }
        $receipt .= "\n";
    }
    $receipt .= "\n";
    $cack_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n        FROM dlog\r\n        WHERE tdate > '" . $EOS . "'\r\n        AND register_no = " . $_SESSION['laneno'] . "\r\n        AND trans_subtype IN ('CA','CK')";
    $results_tot = mysql_query($cack_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("CA & CK Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8) . "\n";
    $card_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n        FROM dlog\r\n        WHERE tdate > '" . $EOS . "'\r\n        AND register_no = " . $_SESSION['laneno'] . "\r\n        AND trans_subtype IN ('DC','CC','FS','EC')";
    $results_tot = mysql_query($card_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("DC / CC / EBT Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8) . "\n";
    $hchrg_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n        FROM dlog\r\n        WHERE tdate > '" . $EOS . "'\r\n        AND register_no = " . $_SESSION['laneno'] . "\r\n        AND trans_subtype = 'MI'\r\n        AND card_no <> 9999";
    $results_tot = mysql_query($hchrg_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("House Charge Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8) . "\n";
    $schrg_tot = "SELECT ROUND(SUM(total),2) AS gross\r\n        FROM dlog\r\n        WHERE tdate > '" . $EOS . "'\r\n        AND register_no = " . $_SESSION['laneno'] . "\r\n        AND trans_subtype = 'MI'\r\n        AND card_no = 9999";
    $results_tot = mysql_query($schrg_tot);
    $row = mysql_fetch_row($results_tot);
    $receipt .= "  " . substr("Store Charge Total: " . $blank . $blank, 0, 20);
    $receipt .= substr($blank . number_format($row[0] * -1, 2), -8);
    $receipt .= str_repeat("\n", 5);
    // apbw/tt 3/16/05 Franking II
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("C H E C K   T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_ckq = sql_query($query_ckq, $db_a);
    $num_rows_ckq = sql_num_rows($result_ckq);
    if ($num_rows_ckq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_ckq; $i++) {
            $row_ckq = sql_fetch_array($result_ckq);
            $timeStamp = timeStamp($row_ckq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_ckq["register_no"] . $blank, 0, 7) . substr($row_ckq["trans_no"] . $blank, 0, 6) . substr($row_ckq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_ckq["changeGiven"], 2), -10) . substr($blank . number_format($row_ckq["ckTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        $query_ckq = "select SUM(ckTender) from cktenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_ckq = sql_query($query_ckq, $db_a);
        $row_ckq = sql_fetch_array($result_ckq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_ckq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("D E B I T  C A R D  T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_dcq = sql_query($query_dcq, $db_a);
    $num_rows_dcq = sql_num_rows($result_dcq);
    if ($num_rows_dcq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_dcq; $i++) {
            $row_dcq = sql_fetch_array($result_dcq);
            $timeStamp = timeStamp($row_dcq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_dcq["register_no"] . $blank, 0, 7) . substr($row_dcq["trans_no"] . $blank, 0, 6) . substr($row_dcq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_dcq["changeGiven"], 2), -10) . substr($blank . number_format($row_dcq["dcTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        $query_dcq = "select SUM(dcTender) from dctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_dcq = sql_query($query_dcq, $db_a);
        $row_dcq = sql_fetch_array($result_dcq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_dcq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("C R E D I T   C A R D   T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_ccq = sql_query($query_ccq, $db_a);
    $num_rows_ccq = sql_num_rows($result_ccq);
    if ($num_rows_ccq > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_ccq; $i++) {
            $row_ccq = sql_fetch_array($result_ccq);
            $timeStamp = timeStamp($row_ccq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_ccq["register_no"] . $blank, 0, 7) . substr($row_ccq["trans_no"] . $blank, 0, 6) . substr($row_ccq["emp_no"] . $blank, 0, 6) . substr($blank . number_format($row_ccq["changeGiven"], 2), -10) . substr($blank . number_format($row_ccq["ccTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        $query_ccq = "select SUM(ccTender) from cctenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_ccq = sql_query($query_ccq, $db_a);
        $row_ccq = sql_fetch_array($result_ccq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_ccq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    $receipt .= centerString("H O U S E / S T O R E   C H A R G E   T E N D E R S") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_miq = sql_query($query_miq, $db_a);
    $num_rows_miq = sql_num_rows($result_miq);
    if ($num_rows_miq > 0) {
        $chgFieldNames = "  " . substr("Time" . $blank, 0, 10) . substr("Lane" . $blank, 0, 7) . substr("Trans #" . $blank, 0, 6) . substr("Emp #" . $blank, 0, 8) . substr("Member #" . $blank, 0, 10) . substr("Amount" . $blank, 0, 10) . "\n";
        $receipt .= $chgFieldNames;
        for ($i = 0; $i < $num_rows_miq; $i++) {
            $row_miq = sql_fetch_array($result_miq);
            $timeStamp = timeStamp($row_miq["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_miq["register_no"] . $blank, 0, 7) . substr($row_miq["trans_no"] . $blank, 0, 6) . substr($row_miq["emp_no"] . $blank, 0, 6) . substr($row_miq["card_no"] . $blank, 0, 6) . substr($blank . number_format($row_miq["MiTender"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
        $query_miq = "select SUM(miTender) from mitenders where tdate > '" . $EOS . "' and register_no = " . $_SESSION["laneno"];
        $result_miq = sql_query($query_miq, $db_a);
        $row_miq = sql_fetch_array($result_miq);
        $receipt .= substr($blank . $blank . $blank . $blank . "Total: " . number_format($row_miq[0], 2), -56) . "\n";
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 3);
    // apbw/tt 3/16/05 Franking II
    $receipt .= chr(27) . chr(33) . chr(5) . centerString("T R I - M E T  P A S S E S   S O L D") . "\n";
    $receipt .= centerString("------------------------------------------------------");
    $result_bp = sql_query($query_bp, $db_a);
    $num_rows_bp = sql_num_rows($result_bp);
    if ($num_rows_bp > 0) {
        $receipt .= $fieldNames;
        for ($i = 0; $i < $num_rows_bp; $i++) {
            $row_bp = sql_fetch_array($result_bp);
            $timeStamp = timeStamp($row_bp["tdate"]);
            $receipt .= "  " . substr($timeStamp . $blank, 0, 10) . substr($row_bp["register_no"] . $blank, 0, 7) . substr($row_bp["trans_no"] . $blank, 0, 6) . substr($row_bp["emp_no"] . $blank, 0, 6) . substr($blank . $row_bp["upc"], -10) . substr($blank . number_format($row_bp["total"], 2), -10) . "\n";
        }
        $receipt .= centerString("------------------------------------------------------");
    } else {
        $receipt .= "\n\n" . centerString(" * * *   N O N E   * * * ") . "\n\n" . centerString("------------------------------------------------------");
    }
    $receipt .= str_repeat("\n", 8);
    // apbw/tt 3/16/05 Franking II
    writeLine($receipt . chr(27) . chr(105));
    // apbw/tt 3/16/05 Franking II
    sql_close($db_a);
    $_SESSION["msgrepeat"] = 1;
    $_SESSION["strRemembered"] = "ES";
    gohome();
}
Example #23
0
    protected function _download_home()
    {
        global $user;
        $v = $this->__(array('f'));
        if (!f($v['f'])) {
            _fatal();
        }
        $sql = 'SELECT *
			FROM _downloads
			WHERE download_alias = ?';
        if (!($download = _fieldrow(sql_filter($sql, $v['f'])))) {
            _fatal();
        }
        $sql = 'UPDATE _downloads
			SET download_count = download_count + 1
			WHERE download_id = ?';
        _sql(sql_filter($sql, $download['download_id']));
        sql_close();
        $orig = array('#\\.#', '#\\&(\\w)(acute|tilde)\\;#');
        $repl = array('', '\\1');
        $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
        $filename = preg_replace($orig, $repl, $download['download_title']) . '.' . $download['download_extension'];
        $filename = preg_replace("/%(\\w{2})/", '_', rawurlencode(str_replace($bad_chars, '_', $filename)));
        $filepath = LIB . 'get/' . $download['download_id'] . '.' . $download['download_extension'];
        // Headers
        header('Content-Type: application/octet-stream; name="' . $filename . '"');
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Accept-Ranges: bytes');
        header('Pragma: no-cache');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-transfer-encoding: binary');
        header('Content-length: ' . @filesize($filepath));
        @readfile($filepath);
        exit;
    }
Example #24
0
function doInstall()
{
    global $mysql_usePrefix, $mysql_prefix, $weblog_ping;
    // 0. put all POST-vars into vars
    $mysql_host = postVar('mySQL_host');
    $mysql_user = postVar('mySQL_user');
    $mysql_password = postVar('mySQL_password');
    $mysql_database = postVar('mySQL_database');
    $mysql_create = postVar('mySQL_create');
    $mysql_usePrefix = postVar('mySQL_usePrefix');
    $mysql_prefix = postVar('mySQL_tablePrefix');
    $config_indexurl = postVar('IndexURL');
    $config_adminurl = postVar('AdminURL');
    $config_adminpath = postVar('AdminPath');
    $config_mediaurl = postVar('MediaURL');
    $config_skinsurl = postVar('SkinsURL');
    $config_pluginurl = postVar('PluginURL');
    $config_actionurl = postVar('ActionURL');
    $config_mediapath = postVar('MediaPath');
    $config_skinspath = postVar('SkinsPath');
    $user_name = postVar('User_name');
    $user_realname = postVar('User_realname');
    $user_password = postVar('User_password');
    $user_password2 = postVar('User_password2');
    $user_email = postVar('User_email');
    $blog_name = postVar('Blog_name');
    $blog_shortname = postVar('Blog_shortname');
    $charset = postVar('charset');
    $config_adminemail = $user_email;
    $config_sitename = $blog_name;
    $weblog_ping = postVar('Weblog_ping');
    $_POST = array();
    $config_indexurl = replaceDoubleBackslash($config_indexurl);
    $config_adminurl = replaceDoubleBackslash($config_adminurl);
    $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
    $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
    $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
    $config_actionurl = replaceDoubleBackslash($config_actionurl);
    $config_adminpath = replaceDoubleBackslash($config_adminpath);
    $config_skinspath = replaceDoubleBackslash($config_skinspath);
    $config_mediapath = replaceDoubleBackslash($config_mediapath);
    /**
     * Include and initialize multibyte functions as a replacement for mbstring extension
     *  if mbstring extension is not loaded.
     * Jan.28, 2011. Japanese Package Release Team
     */
    if (!function_exists('mb_convert_encoding')) {
        global $mbemu_internals;
        include_once $config_adminpath . 'libs/mb_emulator/mb-emulator.php';
    }
    if (function_exists('date_default_timezone_set')) {
        @date_default_timezone_set(function_exists('date_default_timezone_get') ? @date_default_timezone_get() : 'UTC');
    }
    if ($charset == 'ujis') {
        define('_CHARSET', 'EUC-JP');
        $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');
        $user_realname = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');
        $blog_name = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');
    } else {
        define('_CHARSET', 'UTF-8');
    }
    // 1. check all the data
    $errors = array();
    if (!$mysql_database) {
        array_push($errors, _ERROR2);
    }
    if ($mysql_usePrefix == 1 && strlen($mysql_prefix) == 0) {
        array_push($errors, _ERROR3);
    }
    if ($mysql_usePrefix == 1 && !preg_match('#^[a-zA-Z0-9_]+$#', $mysql_prefix)) {
        array_push($errors, _ERROR4);
    }
    // TODO: add action.php check
    if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl)) {
        array_push($errors, _ERROR5);
    }
    if (!endsWithSlash($config_adminpath)) {
        array_push($errors, _ERROR6);
    }
    if (!endsWithSlash($config_mediapath)) {
        array_push($errors, _ERROR7);
    }
    if (!endsWithSlash($config_skinspath)) {
        array_push($errors, _ERROR8);
    }
    if (!is_dir($config_adminpath)) {
        array_push($errors, _ERROR9);
    }
    if (!_isValidMailAddress($user_email)) {
        array_push($errors, _ERROR10);
    }
    if (!_isValidDisplayName($user_name)) {
        array_push($errors, _ERROR11);
    }
    if (!$user_password || !$user_password2) {
        array_push($errors, _ERROR12);
    }
    if ($user_password != $user_password2) {
        array_push($errors, _ERROR13);
    }
    if (!_isValidShortName($blog_shortname)) {
        array_push($errors, _ERROR14);
    }
    if (sizeof($errors) > 0) {
        showErrorMessages($errors);
    }
    // 2. try to log in to mySQL
    global $MYSQL_CONN;
    // this will need to be changed if we ever allow
    $MYSQL_CONN = @sql_connect_args($mysql_host, $mysql_user, $mysql_password);
    if ($MYSQL_CONN == false) {
        _doError(_ERROR15 . ': ' . sql_error());
    }
    // 3. try to create database (if needed)
    $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));
    $collation = $charset == 'utf8' ? 'utf8_general_ci' : 'ujis_japanese_ci';
    if ($mysql_create == 1) {
        $sql = 'CREATE DATABASE ' . $mysql_database;
        // <add for garble measure>
        if (version_compare($mySqlVer, '4.1.0', '>=')) {
            $sql .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
        }
        // </add for garble measure>*/
        sql_query($sql, $MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN));
    }
    // 4. try to select database
    sql_select_db($mysql_database, $MYSQL_CONN) or _doError(_ERROR17);
    /*
     * 4.5. set character set to this database in MySQL server
     * This processing is added by Nucleus CMS Japanese Package Release Team as of Mar.30, 2011
     */
    sql_set_charset_jp($charset);
    // 5. execute queries
    $filename = 'install.sql';
    $fd = fopen($filename, 'r');
    $queries = fread($fd, filesize($filename));
    fclose($fd);
    $queries = split("(;\n|;\r)", $queries);
    $aTableNames = array('nucleus_actionlog', 'nucleus_ban', 'nucleus_blog', 'nucleus_category', 'nucleus_comment', 'nucleus_config', 'nucleus_item', 'nucleus_karma', 'nucleus_member', 'nucleus_plugin', 'nucleus_skin', 'nucleus_template', 'nucleus_team', 'nucleus_activation', 'nucleus_tickets');
    // these are unneeded (one of the replacements above takes care of them)
    //			'nucleus_plugin_event',
    //			'nucleus_plugin_option',
    //			'nucleus_plugin_option_desc',
    //			'nucleus_skin_desc',
    //			'nucleus_template_desc',
    $aTableNamesPrefixed = array($mysql_prefix . 'nucleus_actionlog', $mysql_prefix . 'nucleus_ban', $mysql_prefix . 'nucleus_blog', $mysql_prefix . 'nucleus_category', $mysql_prefix . 'nucleus_comment', $mysql_prefix . 'nucleus_config', $mysql_prefix . 'nucleus_item', $mysql_prefix . 'nucleus_karma', $mysql_prefix . 'nucleus_member', $mysql_prefix . 'nucleus_plugin', $mysql_prefix . 'nucleus_skin', $mysql_prefix . 'nucleus_template', $mysql_prefix . 'nucleus_team', $mysql_prefix . 'nucleus_activation', $mysql_prefix . 'nucleus_tickets');
    // these are unneeded (one of the replacements above takes care of them)
    //			$mysql_prefix . 'nucleus_plugin_event',
    //			$mysql_prefix . 'nucleus_plugin_option',
    //			$mysql_prefix . 'nucleus_plugin_option_desc',
    //			$mysql_prefix . 'nucleus_skin_desc',
    //			$mysql_prefix . 'nucleus_template_desc',
    $count = count($queries);
    for ($idx = 0; $idx < $count; $idx++) {
        $query = trim($queries[$idx]);
        // echo "QUERY = " . htmlspecialchars($query) . "<p>";
        if ($query) {
            if ($mysql_usePrefix == 1) {
                $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
            }
            // <add for garble measure>
            if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0 && version_compare($mySqlVer, '4.1.0', '>=')) {
                $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
            }
            // </add for garble measure>*/
            sql_query($query, $MYSQL_CONN) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . sql_error($MYSQL_CONN));
        }
    }
    // 5a make first post
    if (strtoupper(_CHARSET) != 'UTF-8') {
        $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8');
        $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8');
        $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8');
    } else {
        $itm_title = _1ST_POST_TITLE;
        $itm_body = _1ST_POST;
        $itm_more = _1ST_POST2;
    }
    $newpost = "INSERT INTO " . tableName('nucleus_item') . " VALUES (" . "1, " . "'" . $itm_title . "'," . " '" . $itm_body . "'," . " '" . $itm_more . "'," . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";
    sql_query($newpost, $MYSQL_CONN) or _doError(_ERROR18 . ' (' . htmlspecialchars($newpost) . '): ' . sql_error($MYSQL_CONN));
    // 6. update global settings
    updateConfig('IndexURL', $config_indexurl);
    updateConfig('AdminURL', $config_adminurl);
    updateConfig('MediaURL', $config_mediaurl);
    updateConfig('SkinsURL', $config_skinsurl);
    updateConfig('PluginURL', $config_pluginurl);
    updateConfig('ActionURL', $config_actionurl);
    updateConfig('AdminEmail', $config_adminemail);
    updateConfig('SiteName', $config_sitename);
    if ($charset == 'ujis') {
        updateConfig('Language', 'japanese-euc');
    }
    // 7. update GOD member
    $query = 'UPDATE ' . tableName('nucleus_member') . " SET mname\t = '" . addslashes($user_name) . "'," . " mrealname\t = '" . addslashes($user_realname) . "'," . " mpassword\t = '" . md5(addslashes($user_password)) . "'," . " murl\t\t  = '" . addslashes($config_indexurl) . "'," . " memail\t\t= '" . addslashes($user_email) . "'," . " madmin\t\t= 1," . " mcanlogin\t = 1" . " WHERE" . " mnumber\t   = 1";
    sql_query($query, $MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN));
    // 8. update weblog settings
    $query = 'UPDATE ' . tableName('nucleus_blog') . " SET bname  = '" . addslashes($blog_name) . "'," . " bshortname = '" . addslashes($blog_shortname) . "'," . " burl\t   = '" . addslashes($config_indexurl) . "'" . " WHERE" . " bnumber\t= 1";
    sql_query($query, $MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN));
    // 8-2. update category settings
    if (strtoupper(_CHARSET) != 'UTF-8') {
        $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8');
        $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8');
    } else {
        $cat_name = _GENERALCAT_NAME;
        $cat_desc = _GENERALCAT_DESC;
    }
    $query = 'UPDATE ' . tableName('nucleus_category') . " SET cname  = '" . $cat_name . "'," . " cdesc\t  = '" . $cat_desc . "'" . " WHERE" . " catid\t  = 1";
    sql_query($query, $MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN));
    // 9. update item date
    $query = 'UPDATE ' . tableName('nucleus_item') . " SET   itime   = '" . date('Y-m-d H:i:s', time()) . "'" . " WHERE inumber = 1";
    sql_query($query, $MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN));
    global $aConfPlugsToInstall, $aConfSkinsToImport;
    $aSkinErrors = array();
    $aPlugErrors = array();
    if (count($aConfPlugsToInstall) > 0 || count($aConfSkinsToImport) > 0) {
        // 10. set global variables
        global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
        $MYSQL_HOST = $mysql_host;
        $MYSQL_USER = $mysql_user;
        $MYSQL_PASSWORD = $mysql_password;
        $MYSQL_DATABASE = $mysql_database;
        $MYSQL_PREFIX = $mysql_usePrefix == 1 ? $mysql_prefix : '';
        global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
        $DIR_NUCLEUS = $config_adminpath;
        $DIR_MEDIA = $config_mediapath;
        $DIR_SKINS = $config_skinspath;
        $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
        $DIR_LANG = $DIR_NUCLEUS . 'language/';
        $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
        // close database connection (needs to be closed if we want to include globalfunctions.php)
        sql_close($MYSQL_CONN);
        $manager = '';
        include_once $DIR_LIBS . 'globalfunctions.php';
        // 11. install custom skins
        $aSkinErrors = installCustomSkins($manager);
        $defskinQue = 'SELECT `sdnumber` as result FROM ' . sql_table('skin_desc') . ' WHERE `sdname` = "default"';
        $defSkinID = quickQuery($defskinQue);
        $updateQuery = 'UPDATE ' . sql_table('blog') . ' SET `bdefskin` = ' . intval($defSkinID) . ' WHERE `bnumber` = 1';
        sql_query($updateQuery);
        $updateQuery = 'UPDATE ' . sql_table('config') . ' SET `value` = ' . intval($defSkinID) . ' WHERE `name` = "BaseSkin"';
        sql_query($updateQuery);
        // 12. install NP_Ping, if decided
        if ($weblog_ping == 1) {
            global $aConfPlugsToInstall;
            array_push($aConfPlugsToInstall, "NP_Ping");
        }
        // 13. install custom plugins
        $aPlugErrors = installCustomPlugs($manager);
    }
    // 14. Write config file ourselves (if possible)
    $bConfigWritten = 0;
    if (@file_exists('../config.php') && is_writable('../config.php') && ($fp = @fopen('../config.php', 'w'))) {
        $config_data = '<' . '?php' . "\n\n";
        //$config_data .= "\n"; (extraneous, just added extra \n to previous line
        $config_data .= "   // mySQL connection information\n";
        $config_data .= "   \$MYSQL_HOST\t = '" . $mysql_host . "';\n";
        $config_data .= "   \$MYSQL_USER\t = '" . $mysql_user . "';\n";
        $config_data .= "   \$MYSQL_PASSWORD = '******';\n";
        $config_data .= "   \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
        $config_data .= "   \$MYSQL_PREFIX   = '" . ($mysql_usePrefix == 1 ? $mysql_prefix : '') . "';\n";
        $config_data .= "   // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
        $config_data .= "   // default is \$MYSQL_HANDLER = array('mysql','');\n";
        $config_data .= "   //\$MYSQL_HANDLER = array('mysql','mysql');\n";
        $config_data .= "   //\$MYSQL_HANDLER = array('pdo','mysql');\n";
        $config_data .= "   \$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n";
        $config_data .= "\n";
        $config_data .= "   // main nucleus directory\n";
        $config_data .= "   \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
        $config_data .= "\n";
        $config_data .= "   // path to media dir\n";
        $config_data .= "   \$DIR_MEDIA   = '" . $config_mediapath . "';\n";
        $config_data .= "\n";
        $config_data .= "   // extra skin files for imported skins\n";
        $config_data .= "   \$DIR_SKINS   = '" . $config_skinspath . "';\n";
        $config_data .= "\n";
        $config_data .= "   // these dirs are normally sub dirs of the nucleus dir, but \n";
        $config_data .= "   // you can redefine them if you wish\n";
        $config_data .= "   \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
        $config_data .= "   \$DIR_LANG\t= \$DIR_NUCLEUS . 'language/';\n";
        $config_data .= "   \$DIR_LIBS\t= \$DIR_NUCLEUS . 'libs/';\n";
        $config_data .= "\n";
        $config_data .= "   // include libs\n";
        $config_data .= "   include(\$DIR_LIBS . 'globalfunctions.php');\n";
        $config_data .= "?" . ">";
        $result = @fputs($fp, $config_data, strlen($config_data));
        fclose($fp);
        if ($result) {
            $bConfigWritten = 1;
        }
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><?php 
    echo _TITLE;
    ?>
</title>
	<style>@import url('../nucleus/styles/manual.css');</style>
</head>
<body>
	<div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php 
    echo _ALT_NUCLEUS_CMS_LOGO;
    ?>
" /></div> <!-- Nucleus logo -->

<?php 
    $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
    if (count($aAllErrors) > 0) {
        echo '<h1>' . _TITLE2 . '</h1>';
        echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
    }
    if (!$bConfigWritten) {
        ?>
		<h1><?php 
        echo _TITLE3;
        ?>
</h1>

		<?php 
        echo _TEXT10;
        ?>

		<pre><code>&lt;?php
	// mySQL connection information
	$MYSQL_HOST	 = '<b><?php 
        echo $mysql_host;
        ?>
</b>';
	$MYSQL_USER	 = '******';
	$MYSQL_PASSWORD = '******';
	$MYSQL_DATABASE = '<b><?php 
        echo $mysql_database;
        ?>
</b>';
	$MYSQL_PREFIX   = '<b><?php 
        echo $mysql_usePrefix == 1 ? $mysql_prefix : '';
        ?>
</b>';

	// new in 3.50. first element is db handler, the second is the db driver used by the handler
	// default is $MYSQL_HANDLER = array('mysql','');
	$MYSQL_HANDLER = array('<?php 
        echo $MYSQL_HANDLER[0];
        ?>
','<?php 
        echo $MYSQL_HANDLER[1];
        ?>
');

	// main nucleus directory
	$DIR_NUCLEUS = '<b><?php 
        echo $config_adminpath;
        ?>
</b>';

	// path to media dir
	$DIR_MEDIA   = '<b><?php 
        echo $config_mediapath;
        ?>
</b>';

	// extra skin files for imported skins
	$DIR_SKINS   = '<b><?php 
        echo $config_skinspath;
        ?>
</b>';

	// these dirs are normally sub dirs of the nucleus dir, but
	// you can redefine them if you wish
	$DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
	$DIR_LANG	= $DIR_NUCLEUS . 'language/';
	$DIR_LIBS	= $DIR_NUCLEUS . 'libs/';

	// include libs
	include($DIR_LIBS . 'globalfunctions.php');
?&gt;</code></pre>

	<?php 
        echo _TEXT11;
        ?>

	<div class="note">
	<?php 
        echo _TEXT12;
        ?>
	</div>

<?php 
    } else {
        ?>

	<h1><?php 
        echo _TITLE4;
        ?>
</h1>

	<?php 
        echo _TEXT13;
        ?>

<?php 
    }
    ?>

	<h1><?php 
    echo _TITLE5;
    ?>
</h1>
	
	<?php 
    echo _TEXT14;
    ?>

	<ul>
		<li><?php 
    echo _TEXT14_L1;
    ?>
</li>
		<li><?php 
    echo _TEXT14_L2;
    ?>
</li>
	</ul>

	<h1><?php 
    echo _HEADER10;
    ?>
</h1>

	<?php 
    echo _TEXT15;
    ?>

		<ul>
		<li><?php 
    echo _TEXT15_L1;
    ?>
</li>
		<li><?php 
    echo _TEXT15_L2;
    ?>
</li>
		<li><?php 
    echo _TEXT15_L3;
    ?>
</li>
		</ul>

	<?php 
    echo _TEXT16;
    ?>

	<h1><?php 
    echo _HEADER11;
    ?>
</h1>

	<p><?php 
    echo _TEXT16_H;
    ?>
		<ul>
			<li><a href="<?php 
    echo $config_adminurl;
    ?>
"><?php 
    echo _TEXT16_L1;
    ?>
</a></li>
			<li><a href="<?php 
    echo $config_indexurl;
    ?>
"><?php 
    echo _TEXT16_L2;
    ?>
</a></li>
		</ul>
	</p>

</body>
</html>

<?php 
}
Example #25
0
function couponTotal()
{
    $db = tDataConnect();
    $query = "select sum(total) as couponTotal from localtemptrans where upc = '0000000008005'";
    $result = sql_query($query, $db);
    $num_rows = sql_num_rows($result);
    if ($num_rows > 0) {
        $row = sql_fetch_array($result);
        $couponTotal = nullwrap($row["couponTotal"]);
    } else {
        $couponTotal = 0;
    }
    sql_close($db);
}
Example #26
0
function _layout($template, $page_title = false, $v_custom = false)
{
    global $core, $bio, $style, $starttime;
    // GZip
    if (_browser('gecko')) {
        ob_start('ob_gzhandler');
    }
    // Headers
    if (!headers_sent()) {
        header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($page_title !== false) {
        if (!is_array($page_title)) {
            $page_title = w($page_title);
        }
        foreach ($page_title as $k => $v) {
            $page_title[$k] = $bio->_lang($v);
        }
        $page_title = implode(' . ', $page_title);
    }
    $sql = 'SELECT module_alias, module_name
		FROM _modules
		WHERE module_header = 1
			AND module_active = 1
		ORDER BY module_order';
    $header_menu = sql_rowset($sql);
    foreach ($header_menu as $i => $row) {
        if (!$i) {
            _style('nav');
        }
        _style('nav.menu', array('ACTIVE' => false, 'HREF' => _link($row->module_alias), 'NAME' => $row->module_name));
    }
    //
    $filename = strpos($template, '#') !== false ? str_replace('#', '.', $template) : $template . '.htm';
    $style->set_filenames(array('body' => $filename));
    // SQL History
    if ($core->v('show_sql_history')) {
        foreach (sql_history() as $i => $row) {
            if (!$i) {
                _style('sql_history');
            }
            _style('sql_history.row', array('QUERY' => str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;'), $row)));
        }
    }
    //_pre($bio, true);
    //
    $v_assign = array('USER_ID' => $bio->v('bio_id'), 'USER_NAME' => $bio->v('bio_name'), 'SITE_TITLE' => $core->v('site_title'), 'PAGE_TITLE' => $page_title, 'G_ANALYTICS' => $core->v('google_analytics'), 'S_REDIRECT' => $bio->v('session_page'), 'F_SQL' => sql_queries());
    if ($v_custom !== false) {
        $v_assign += $v_custom;
    }
    $mtime = explode(' ', microtime());
    $v_assign['F_TIME'] = sprintf('%.2f', $mtime[0] + $mtime[1] - $starttime);
    v_style($v_assign);
    $style->pparse('body');
    sql_close();
    exit;
}
Example #27
0
        } elseif ($ligne['match_score_home'] < $ligne['match_score_visitor']) {
            $page['match'][$i]['visitor_gagnant'] = "1";
        }
        $page['match'][$i]['link_edit'] = "";
        $page['match'][$i]['link_delete'] = "";
        if ($right_user['edit_match']) {
            $page['match'][$i]['link_edit'] = convert_url("index.php?r=" . $lang['general']['idurl_match'] . "&v1=form_match&v2=" . $ligne['match_id']);
        }
        if ($right_user['delete_match']) {
            $page['match'][$i]['link_delete'] = convert_url("index.php?r=" . $lang['general']['idurl_match'] . "&v1=match_list&v2=delete&v3=" . $ligne['match_id']);
        }
        $i++;
    }
}
sql_free_result($res_match);
sql_close($sgbd);
# liste des teams
$page['link_select_team'] = convert_url("index.php?r=" . $lang['general']['idurl_team'] . "&v1=select_team_club");
$page['team'] = array();
if (!empty($page['value_team']) or $page['aff_club'] != "1") {
    include_once create_path("team/sql_team.php");
    include_once create_path("team/lg_team_" . LANG . ".php");
    include_once create_path("team/tpl_team.php");
    $var['order'] = "";
    $var['limit'] = "";
    $var['condition'] = " WHERE e.club_id='" . $page['value_club'] . "'";
    $var['value_team'] = $page['value_team'];
    $included = 1;
    include create_path("team/team_list.php");
    unset($included);
    $page['team'] = $page['team'];
Example #28
0
	function home() {
		global $user, $style;
		
		$v = $this->__(array('f', 'e'));
		if (empty($v['f']) || empty($v['e'])) {
			_fatal();
		}
		
		$filepath = './style/' . $v['e'] . '/';
		$filename = _filename($v['f'], $v['e']);
		$browser = array('firefox' => 'Gecko', 'ie' => 'IE', 'comp' => 'compatible');
		$sv = w();
		
		switch ($v['e']) {
			case 'css':
				$sv['CSSPATH'] = LIBD . 'style';
				
				foreach ($browser as $css_k => $css_v) {
					$css_match = (strstr($user->browser, $css_v) || $css_v === true) ? true : false;
					if ($css_match && @file_exists($filepath . '_tree_' . $css_k . '.css')) {
						$style->set_filenames(array('css' => 'css/_tree_' . $css_k . '.css'));
						$style->assign_var_from_handle('S_CSS', 'css');
						$style->assign_block_vars('includes', array('CSS' => $style->vars['S_CSS']));
					}
					
					$sv[strtoupper($css_k)] = $css_match;
				}
				$this->as_vars($sv);
				break;
			case 'js':
				if (!@file_exists($filepath . $filename)) {
					_fatal();
				}
				
				require_once(XFS . 'core/jsmin.php');
				
				foreach ($browser as $css_k => $css_v) {
					$css_match = (strstr($user->browser, $css_v) || $css_v === true) ? true : false;
					$sv[strtoupper($css_k)] = $css_match;
				}
				break;
		}
		
		if ($sv['COMP'] || $sv['FIREFOX']) {
			ob_start('ob_gzhandler');
		}
		
		// Headers
		header('Content-type: text/css; charset=utf-8');
		header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (60 * 60 * 24 * 30)) . ' GMT');
		
		// TODO: 304 Not modified response header
		
		/*$lastmodified = filemtime($filename);
		
		if ($lastmodified)
		{
			if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastmodified)
			{
				header("HTTP/1.0 304 Not Modified");
			}
			//exit;
		}
		else
		{
			header('Last-Modified: ' . gmdate('D, d, M Y H:i:s', $lastmodified) . ' GMT');
		}*/
		
		if ($v['e'] == 'js') {
			$style->replace_vars = false;
		}
		
		sql_close();
		$style->set_filenames(array('body' => $v['e'] . '/' . $filename));
		$style->assign_var_from_handle('EXT', 'body');
		
		switch ($v['e']) {
			case 'css':
				$code = str_replace(array("\r\n", "\n", "\t"), '', $style->vars['EXT']);
				break;
			case 'js':
				$code = JSMin::minify($style->vars['EXT']);
				break;
		}
		
		echo $code;
		exit;
	}
Example #29
0
</dateCreated>
	</head>
	<body>
<?php 
for ($n = 0; $n < count($feeds_list); $n++) {
    $feed = $feeds_list[$n];
    ?>
	<outline
		text="<?php 
    echo $feed['title'];
    ?>
"
		title="<?php 
    echo $feed['title'];
    ?>
"
		xmlUrl="<?php 
    echo $feed['feedUrl'];
    ?>
"
		type="<?php 
    echo $feed['type'];
    ?>
" />
<?php 
}
sql_close();
?>
	</body>
</opml>
Example #30
0
    public function home()
    {
        global $warning, $bio, $core, $warning;
        $v = $this->__(w('path ext'));
        if (array_empty($v)) {
            $warning->now();
        }
        $location = XFS . XHTM . _tbrowser() . '/' . $v->ext . '/';
        if (!@is_dir($location)) {
            $warning->now();
        }
        $filename = _filename($v->path, $v->ext);
        if ($v->ext == 'css' && $v->path != 'default') {
            $v->field = !is_numb($v->path) ? 'alias' : 'id';
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_?? = ?
				LIMIT 1';
            if (!($tree = sql_fieldrow(sql_filter($sql, $v->field, $v->path)))) {
                $warning->now();
            }
            $filetree = _rewrite($tree);
            $filename = _filename('_tree_' . $filetree, $v->ext);
        }
        //
        // 304 Not modified response header
        if (@file_exists($location . $filename)) {
            $f_last_modified = gmdate('D, d M Y H:i:s', filemtime($location . $filename)) . ' GMT';
            $http_if_none_match = v_server('HTTP_IF_NONE_MATCH');
            $http_if_modified_since = v_server('HTTP_IF_MODIFIED_SINCE');
            header('Last-Modified: ' . $f_last_modified);
            if ($f_last_modified == $http_if_modified_since) {
                header('HTTP/1.0 304 Not Modified');
                header('Content-Length: 0');
                exit;
            }
        }
        switch ($v->ext) {
            case 'css':
                if ($v->path != 'default') {
                    $filetree = _rewrite($tree);
                    $filename = _filename('_tree_' . $filetree, $v->ext);
                    if (!@file_exists($location . $filename)) {
                        $warning->now();
                    }
                }
                $browser = _browser();
                if (!empty($browser['browser'])) {
                    $custom = array($browser['browser'] . '-' . $browser['version'], $browser['browser']);
                    foreach ($custom as $row) {
                        $handler = _filename('_tree_' . $row, 'css');
                        if (@file_exists($location . $handler)) {
                            _style('includes', array('CSS' => _style_handler('css/' . $handler)));
                        }
                    }
                }
                _style_vreplace(false);
                break;
            case 'js':
                if (!@file_exists($location . $filename)) {
                    $warning->now();
                }
                _style_vreplace(false);
                break;
        }
        v_style(array('DOMAIN' => 'media'));
        sql_close();
        //
        // Headers
        $ext = _style_handler($v->ext . '/' . $filename);
        switch ($v->ext) {
            case 'css':
                $content_type = 'text/css; charset=utf-8';
                //$ext = preg_replace('#(border-radius\-?.*?)\: ?(([0-9]+)px;)#is', ((_browser('firefox')) ? '-moz-\1: \2' : ''), $ext);
                $ext = preg_replace('/(#([0-9A-Fa-f]{3})\\b)/i', '#\\2\\2', $ext);
                $ext = preg_replace('#\\/\\*(.*?)\\*\\/#is', '', $ext);
                $ext = str_replace(array("\r\n", "\n", "\t"), '', $ext);
                break;
            case 'js':
                $content_type = 'application/x-javascript';
                require_once XFS . XCOR . 'jsmin.php';
                $ext = JSMin::minify($ext);
                break;
        }
        ob_start('ob_gzhandler');
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT');
        // 30 days = 60 * 60 * 24 * 30
        header('Content-type: ' . $content_type);
        echo $ext;
        exit;
    }