PHP Symfony 2 passing class containing sockets between controllers - php

I am using PHP 5.5.9 and Symfony 2.2.7,
I need to pass an array of class that contains an array of PHP sockets between controllers.
The troubles I get is that I can't pass it through a session that puts a 0 instead of the socket, when I try to pass it through a service that was each time reset the class, then I try to put the array in static but that doesn't work too.
Did anyone have a clue, a track or something to help me?
Thanks for reading at least and have a good day.
Here is the class who ecapsul the sockets:
class Socket {
private $socket;
private $give;
private static $out;
function __construct($host, $port = -1){
$errno = 0;
$errmsg = "";
$this->give = false;
if ($port === -1) {
$this->socket = $host->getFd();
$this->give = true;
}
else {
$this->socket = fsockopen($host, $port, $errno, $errmsg);
echo "connection\n";
}
}
function __destruct() {
if (!$this->give && !$this->socket === false)
fclose($this->socket);
}
function getFd() {
return ($this->socket);
}
function writeSocket($buff, $size) {
if ($this->socket === false)
return (false);
echo "send: " . bin2hex($buff) . "\n";
return (fwrite($this->socket, $buff, $size));
}
function readSocket($size) {
if ($this->socket === false)
return (false);
$out = "";
$out = fgets($this->socket, $size + 1);
if (strlen($out) < $size) {
$tmp = fgets($this->socket, $size - strlen($out) + 1);
if (!($tmp === false))
$out .= $tmp;
}
echo "read: " . bin2hex($out) . "\n";
return ($out);
}
}
Here the class that implement the procol:
class EcoProtocol{
private $socket;
private $isLogged;
private $orga;
private $pass;
private $user;
private $KO;
/**
* Initiate the connexion to the server
* and read the first packet from the server
*/
public function __construct(){
$this->socket = new Socket("91.121.11.33", 4340);
}
public function logIn($new, $user, $pass) {
//using socket here
}
}
And here the class with the array:
class ConnexionsHandler {
private static $socket;
private $maxTime = 120;
function __construct(){
echo "construct";
if (!isset(ConnexionsHandler::$socket))
{
echo "is not set";
ConnexionsHandler::$socket = array();
}
print_r(ConnexionsHandler::$socket);
}
function __destruct(){
echo "destruct";
}
private function cleanConnexion(){
foreach (ConnexionsHandler::$socket as $key => $val) {
if (time() - $val[0] > $this->maxTime){
unset(ConnexionsHandler::$socket[$key]);
}
}
}
public function getConnexion($user){
$this->cleanConnexion();
if (array_key_exists($user, ConnexionsHandler::$socket)){
ConnexionsHandler::$socket[$user][0] = time();
return (ConnexionsHandler::$socket[$user][1]);
}
return (null);
}
public function createConnexion($new, $user, $pass){
$this->cleanConnexion();
$client = new EcoProtocol();
$ret = $client->logIn($new, $user, $pass);
ConnexionsHandler::$socket[$user][0] = time();
ConnexionsHandler::$socket[$user][1] = $client;
return ($ret);
}
}

Related

Memory leaks in socket server PHP

Class ServerSocket {
protected $IP_ADDRESS = IP_ADDRESS;
protected $PORT = PORT_NUMBER;
protected $userClass = 'WebSocketUser';
protected $mysock;
protected $users = array();
public static $sockets = array();
public $clients = array();
protected $countSockets = 0;
protected $socketsLimit = 1000;
FUNCTION __construct()
{
$this->mysock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($this->mysock, $this->IP_ADDRESS, $this->PORT);
socket_listen($this->mysock, 4096);
self::$sockets[] = $this->mysock;
}
/**
* Main function
*
*/
FUNCTION runServer()
{
$sock_id = 0;
$client_id = 0;
while ( true )
{
if ( empty(self::$sockets) )
{
self::$sockets[$sock_id] = $this->mysock;
$sock_id++;
}
$read = self::$sockets;
$write = $except = null;
foreach ( $read as $socket )
{
if ( $socket == $this->mysock )
{
//Accepting new clients
while ( ($client = socket_accept($socket) ) )
{
foreach ( $this->clients as $key=>$clientThread )
{
echo 'Thread is closed : '.$clientThread->getIsClosed() . "\n";
if($clientThread->getIsClosed() == 1 || $clientThread->isTerminated() || !$clientThread->isRunning())
{
unset($this->clients[$key]);
$clientThread->kill();
}
else
{
$responce = $clientThread->isThreadAlive();
if($clientThread->getIsClosed() == 1 || !$responce || $clientThread->isTerminated())
{
unset($this->clients[$key]);
$clientThread->kill();
}
echo 'RESPONCE is: ' . $responce . "\n";
}
}
echo 'Count of clients arr is: '. count($this->clients) . "\n";
$this->clients[$client_id] = new Client($client, $sock_id, $client_id);
$client_id++;
}
// Start The Threads
foreach ( $this->clients as $key=>$clientThread )
{
if( !$clientThread->isStarted())
{
$clientThread->start();
}
}
}
}
}
}
}
And my client class is:
class Client extends Thread {
public $stop = false;
public $Timeout = 4000; //millisecounds
public $CurrentTime = 0;
public $CurrentTimeout = 0;
public $isClosed; // 0 - false; 1 - true;
public $isWorking = 1; // 0 - false; 1 - true;
private $SocketPort = PORT_NUMBER;
private $SOCK_ID;
private $CLIENT_ID;
function setIsClosed($isClosed)
{
$this->isClosed = $isClosed;
}
function getIsClosed()
{
return $this->isClosed;
}
function isThreadAlive()
{
return true;
}
public FUNCTION __construct($socket, $sock_id, $client_id)
{
$this->socket = $socket;
$this->SOCK_ID = $sock_id;
$this->CLIENT_ID = $client_id;
$this->isClosed = 0;
$this->start();
}
protected function __distruct()
{
gc_collect_cycles();
}
FUNCTION disconnect($client)
{
$this->socketWriteWithChr10($client, 'Successfuly Disconnected from Server.');
$this->isClosed = 1;
$this->stop = true;
socket_shutdown($client, 2);
socket_close($client);
$this->__distruct();
}
public FUNCTION run()
{
$client = $this->socket;
$this->connect($client);
while ( true )
{
$command = socket_read($client, 2048) or $this->stop = true;
if ( $command === false || $command == '' )
{
$this->socketWriteWithChr10($client, 'Nothing to read! Successfuly Disconnected from Server.');
$this->stop = true;
$this->isClosed = 1;
socket_shutdown($client, 2);
socket_close($client);
break;
}
$this->getCommand($client, $command);
if($this->stop)
{
break;
}
}
}
public FUNCTION getCommand($client, $input)
{
switch (trim($input))
{
case 'FILE':
//Filename to save
file_put_contents('../SOCKET_FILES/' . $ID . '/' . $Dirs . $FILENAME, fileContent);break;
default :
$this->socketWriteWithChr10($client, 'unknown command');
break;
}
}
}
When i connect 1MB of is up and when i disconnect 1MB is reduce, but when i send files i get memory leaks. I can reduce memory when client is not connected, but if i send files the memory grow up and i have to restart my server.
The client program do this:
Connect
Send command file
Send parameters like ID,Dirs, ect.
The Server saves this file and send to client that file is written.
Client close the connection by command disconnect (server hit method disconnect).
The client program sends 6 files at once by while with 22 iterations.
In this steps memory grows and i can't reduce it. The strange fact is that i reduce my clients array.
What can it be? Im not good with linux. I only use htop.
I was googled and tried many examples, but the problem remains.
Thanks.
I found it. The problem is that 1 client try to send many files at once and the server can't close all files in time.

PHP Unexpected End of File [duplicate]

This question already has answers here:
PHP - unexpected end of file
(3 answers)
Closed 8 years ago.
I am getting an unexpected end of file error on the last line of this code, I have run it through www.phpcodechecker.com (Which I have found do be very reliable). What am I doing wrong? PHP version 5.5.9
<?php
/*
Hurricane Control Panel © 2014, a web control panel
by Hurricane Development of http://www.HurricaneDevelopment.com
is licenced under a Creative Commons
Attribution-NoDerivatives 4.0 International License
Permissions beyond the scope of this licence
may be available at http://creativecommons.org/licenses/by-nd/4.0/
*/
Defined("_HEXEC") or die ("This file may not be accessed directly");
class VARS {
public static $errors = false;
public static $extraJS = false;
public static $scriptJS = false;
public static $extraCSS = false;
}
abstract class GeneralUTIL {
/**
* Error functions
**/
public static function addErr($err) {
VARS::$errors[] = $err;
}
public static function logger($content,$level = LOGGER_INFO) {
if (!file_exists("logs")) {
mkdir("logs");
}
$scanned_directory = array_diff(scandir("logs",SCANDIR_SORT_DESCENDING), array('..', '.'));
$logs = false;
if (sizeof($scanned_directory) == 0) {
file_put_contents("logs/log.1", "", LOCK_EX);
chmod("logs/log.1",0600);
$logid = 1;
} else {
foreach ($scanned_directory as $key => $value) {
if (strpos($value,"log.") !== false) {
$logs[] = $value;
}
}
$logid = explode(".", $logs[0]);
$logid = $logid[1];
if (filesize("logs/log." . $logid) >= 200000) {
$logid = ((int) $logid) + 1;
file_put_contents("logs/log." . $logid, "", LOCK_EX);
chmod("logs/log." . $logid,0600);
}
}
date_default_timezone_set("America/New_York");
$d = getdate();
file_put_contents("logs/log." . $logid, "{$d['mon']}/{$d['mday']}/{$d['year']} {$d['hours']}:{$d['minutes']}:{$d['seconds']} $level $content \n", FILE_APPEND | LOCK_EX);
}
public static function sha512($password,$salt = null) {
if ($salt == null) {
$cost = 50000;
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
$salt = sprintf('$6$rounds=%d$', $cost) . $salt;
}
return crypt($password, $salt);
}
public static function matchSha512($password,$hash) {
if (crypt($password, $hash) === $hash) {
return true;
}
return false;
}
}
class PluginUTIL extends GeneralUTIL {
public static function addJS($jsPath) {
$debugArray = debug_backtrace();
$pluginAlias = UTIL::getBetween($debugArray[0]['file'],"/plugins/plugin_","/");
if ($pluginAlias == false) {
UTIL::addErr("The addJS Method was not called from a registered plugin");
return false;
}
$pluginLoader = new Plugins();
$pluginLoader->loadPlugins();
$plugins = $pluginLoader->getPluginsArray();
foreach ($plugins as $id => $pluginArray) {
if ($pluginArray['alias'] == $pluginAlias) {
VARS::$extraJS[] = PATH . "plugins/plugin_" . $pluginAlias . "/" . $jsPath;
return true;
}
}
}
public static function addScriptJS($script) {
VARS::$scriptJS = $script;
}
public static function addCSS($cssPath) {
$debugArray = debug_backtrace();
$pluginAlias = UTIL::getBetween($debugArray[0]['file'],"/plugins/plugin_","/");
if ($pluginAlias == false) {
UTIL::addErr("The addCSS Method was not called from a registered plugin");
return false;
}
$pluginLoader = new Plugins();
$pluginLoader->loadPlugins();
$plugins = $pluginLoader->getPluginsArray();
foreach ($plugins as $id => $pluginArray) {
if ($pluginArray['alias'] == $pluginAlias) {
VARS::$extraCSS[] = PATH . "plugins/plugin_" . $pluginAlias . "/" . $cssPath;
return true;
}
}
}
}
class UTIL extends GeneralUTIL {
public static function displayErrors($output) {
if (VARS::$errors != false && is_array(VARS::$errors)) {
$output = str_replace("<div id='errors' class='alert alert-danger'></div>","<div id='errors' class='alert alert-danger'><h1>Uh Oh. Some errors occured!</h1>" . implode("<br>",VARS::$errors) . "</div>",$output);
} else {
$output = str_replace("<div id='errors' class='alert alert-danger'></div>","",$output);
}
return $output;
}
/**
* Custom JS /CSS functions
**/
public static function addCustomJSFromPath($path) {
VARS::$extraJS[] = PATH . $path;
}
public static function includeCustomJS() {
if (VARS::$extraJS != false && is_array(VARS::$extraJS)) {
foreach (VARS::$extraJS as $key => $path): ?>
<script src="<?php echo $path; ?>"></script>
<?php endforeach;
}
if (VARS::$scriptJS != false): ?>
<script type="text/javascript">
<?php echo VARS::$scriptJS; ?>
</script>
<? endif;
}
public static function includeCustomCSS($output) {
if (VARS::$extraCSS != false && is_array(VARS::$extraCSS)) {
$css = "";
foreach (VARS::$extraCSS as $key => $path):
$css .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"$path\">\n";
endforeach;
$output = str_replace("CUSTOMCSSAREAHERE",$css,$output);
} else {
$output = str_replace("CUSTOMCSSAREAHERE","",$output);
}
return $output;
}
/**
* Get Between two strings function
**/
public static function getBetween($content,$start,$end) {
if (preg_match('/' . str_replace("/","\\/", $start) . '(.*?)' . str_replace("/","\\/", $end) . '/',$content, $res) === false) {
return false;
}
return $res[1];
}
/**
* Redirect page function
**/
public static function redirect($location, $code = '302') {
switch($code) {
case '301';
header("HTTP/1.1 301 Moved Permanently");
break;
case '303';
header("HTTP/1.1 303 See Other");
break;
case '404';
header('HTTP/1.1 404 Not Found');
break;
}
//remove any & in the url to prevent any problems
$location = str_replace('&', '&', $location);
header("Location: $location");
//kill the script from running and output a link for browsers which enable turning off header redirects *cough Opera cough* :P
exit('If you were not redirected automatically please click here');
}
}
?>
Change this
<? endif;
to this
<?php endif;
inside UTIL::includeCustomJS

How to return true/false from a function in php

How can I use the return true/false for another function?
<?php
class Bet {
private $Client;
private $Secret;
private $Server;
public function __construct() {
$this->Client = md5(uniqid(rand(), true));
$this->Secret = md5(uniqid(rand(), true));
$this->Server = md5(uniqid(rand(), true));
}
public function Bet($Type, $Chance) {
if($Type == 'auto') {
$hash = hash('sha512', $this->Client . $this->Secret . $this->Server);
$Result = round(hexdec(substr($hash, 0, 8)) / 42949672.95, 2);
if($Result < $Chance) {
return true;
} else {
return false;
}
}
}
}
?>
Heres what I been trying:
if(isset($_POST['chance'], $_POST['bet'])) {
print_r($Bet->Bet('auto', $_POST['chance']));
if($Bet == true)
{
return "1";
} else {
return "2";
}
}
But I can't see to get inside the if state.
try this
if($Bet)
{
return "1";
} else {
return "2";
}
}
You have to instantiate your class:
$bet = new Bet($type, $chance);
but a constructor cannot return a value like you are doing.
try something like this:
public function betTest() { return what you want; }
[...]
if ($bet->betTest()) { return 1; } else { return 2; }
or use a static method:
public static function betTest() { /.../ }
if (Bet::betTest()) { ... }
Based on your code:
<?php
class Bet {
private $Client;
private $Secret;
private $Server;
private $result;
public function __construct($Type, $Chance) {
$this->Client = md5(uniqid(rand(), true));
$this->Secret = md5(uniqid(rand(), true));
$this->Server = md5(uniqid(rand(), true));
if($Type == 'auto') {
$hash = hash('sha512', $this->Client . $this->Secret . $this->Server);
$Result = round(hexdec(substr($hash, 0, 8)) / 42949672.95, 2);
if($Result < $Chance) {
$this->result = true;
} else {
$this->result = false;
}
}
}
/**
* #return boolean
*/
public function isReturnLessThanChance() { return $this->result; }
}
$bet = new Bet("", "");
if ($bet->isResultLessThanChance()) {
return 1;
else
return 2;
you can try this also.
if($Bet === true) { return "1"; } else { return "2"; }
=== check data type as well as value. then (true !== 1).

How to close a socket connection in script?

Im using SocketServer.class.php to do connection from a GPS tracking unit to my server. A quick example of whats happening.
Unit connects to my server, connection is established and data/buffer is sent to server and the unit disconnects and this tells the socket to close. But on some versions of the units the unit does not close the connection and the socket stays open which then holds up the process of the other units connecting and sending their information. How or what php code can I use to close a connection/socket from a unit after a curtain time or do a socket timeout after a while?
Because this creates two problems for me. I can either have the one or the other.
1) Close the connection after the first batch of information is sent/received. But the information that the unit sometimes sends through is in 3 buffer sends (hope i said that correctly) so now i keep the connection/socket open and wait for the unit to say "I'm done, close the socket". That works fine. But then the problem arises when the unit doesn't say "I'm done" and the socket stays open but all information is received.
Here is the code I have:
<?php
class SocketServer
{
protected $config;
protected $master_socket;
public $max_clients = 99999;
public $max_read = 32768;
public $clients;
public $complete_string = "";
public function __construct($bind_ip,$port)
{
set_time_limit(0);
$this->hooks = array();
$this->config["ip"] = $bind_ip;
$this->config["port"] = $port;
$this->master_socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($this->master_socket,$this->config["ip"],$this->config["port"]) or die("Port ".$this->config["port"]." is still open\r\n");
socket_getsockname($this->master_socket,$bind_ip,$port);
socket_listen($this->master_socket);
SocketServer::debug("Listenting for connections on {$bind_ip}:{$port}");
}
public function loop_once()
{
// Setup Clients Listen Socket For Reading
$read[0] = $this->master_socket;
for($i = 1; $i <= $this->max_clients; $i++)
{
if(isset($this->clients[$i]))
{
$read[$i + 1] = $this->clients[$i]->socket;
}
}
// Set up a blocking call to socket_select
if(socket_select($read,$write = NULL, $except = NULL, $tv_sec = 8) < 1)
{
return true;
}
// Handle new Connections
if(in_array($this->master_socket, $read))
{
for($i = 1; $i <= $this->max_clients; $i++)
{
if(empty($this->clients[$i]))
{
$temp_sock = $this->master_socket;
$this->clients[$i] = new SocketServerClient($this->master_socket,$i);
SocketServer::debug("Client {$i} from {$this->clients[$i]->ip} connected # ".date("d-M-Y H:i:s"), time());
break;
}
elseif($i == ($this->max_clients-1))
{
SocketServer::debug("Too many clients... :( ");
}
}
}
// Handle Input
for($i = 0; $i < $this->max_clients; $i++) // for each client
{
if(isset($this->clients[$i]))
{
if(in_array($this->clients[$i]->socket, $read))
{
$input = socket_read($this->clients[$i]->socket, $this->max_read);
if($input == null)
{
$this->disconnect($i);
}
else
{
$this->clients[$i]->complete_string .= $input;
}
}
}
}
return true;
}
public function disconnect($client_index,$message = "")
{
$i = $client_index;
SocketServer::debug("Lets interpret the string\r\n");
SocketServer::interpret();
SocketServer::debug("Client {$i} from {$this->clients[$i]->ip} disconnected");
SocketServer::debug("------------------------------------------------------------------------------------------------------------------------------------------");
$this->clients[$i]->destroy();
unset($this->clients[$i]);
}
public function interpret()
{
//Lets get the info to start
for($i = 0; $i < $this->max_clients; $i++) // for each client
{
if(isset($this->clients[$i]))
{
$complete_string = $this->clients[$i]->complete_string;
SocketServer::debug($complete_string);
//Do something with the string here
//Clear the Complete String Variable for next use
$this->clients[$i]->complete_string = "";
}
}
}
public function infinite_loop()
{
$test = true;
do
{
$test = $this->loop_once();
}
while($test);
}
public static function debug($text)
{
echo("{$text}\r\n");
}
function &__get($name)
{
return $this->{$name};
}
}
class SocketServerClient
{
protected $socket;
protected $ip;
protected $hostname;
protected $server_clients_index;
public function __construct(&$socket,$i)
{
$this->server_clients_index = $i;
$this->socket = socket_accept($socket) or die("Failed to Accept");
socket_getpeername($this->socket,$ip);
$this->ip = $ip;
}
public function lookup_hostname()
{
$this->hostname = gethostbyaddr($this->ip);
return $this->hostname;
}
public function destroy()
{
socket_close($this->socket);
}
function &__get($name)
{
return $this->{$name};
}
function __isset($name)
{
return isset($this->{$name});
}
}

php class _Construct empty

<?
session_start();
/*
echo $_SESSION['SQLIP'];
echo "<br>";
echo $_SESSION['SQLDB'];
echo "<br>";
echo $_SESSION['SQLUSER'];
echo "<br>";
echo $_SESSION['SQLPASS'];
echo "<br>";
*/
class DB_MSSQL {
private $Host;
private $Database;
private $User;
private $Password;
public $Link_ID = 0;
public $Query_ID = 0;
public $Record = array();
public $Row = 0;
public $Errno = 0;
public $Error = "";
public $Halt_On_Error = "yes";
public $Auto_Free = 1;
public $PConnect = 0;
public function _construct(){
$this->Host = $_SESSION['SQLIP'];
$this->Database = $_SESSION['SQLDB'];
$this->User = $_SESSION['SQLUSER'];
$this->Password = $_SESSION['SQLPASS'];
}
function DB_MSSQL($query = "") {
if($query) {
$this->query($query);
}
}
function connect() {
if ( 0 == $this->Link_ID ) {
if(!$this->PConnect) {
$this->Link_ID = mssql_connect($this->Host, $this->User, $this->Password);
} else {
$this->Link_ID = mssql_pconnect($this->Host, $this->User, $this->Password);
}
if (!$this->Link_ID)
$this->connect_failed("connect ($this->Host, $this->User, \$Password) failed");
else
if (!mssql_select_db($this->Database, $this->Link_ID)) {
$this->connect_failed("cannot use database ".$this->Database);
}
}
}
function connect_failed($message) {
$this->Halt_On_Error = "yes";
$this->halt($message);
}
function free_result(){
mssql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
function query($Query_String)
{
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new DB_Sql_Subclass;'
*/
return 0;
if (!$this->Link_ID)
$this->connect();
// printf("<br>Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = mssql_query($Query_String, $this->Link_ID);
$this->Row = 0;
if (!$this->Query_ID) {
$this->Errno = 1;
$this->Error = "General Error (The MSSQL interface cannot return detailed error messages).";
$this->halt("Invalid SQL: ");
}
return $this->Query_ID;
}
function next_record() {
if ($this->Record = mssql_fetch_row($this->Query_ID)) {
// add to Record[<key>]
$count = mssql_num_fields($this->Query_ID);
for ($i=0; $i<$count; $i++){
$fieldinfo = mssql_fetch_field($this->Query_ID,$i);
$this->Record[strtolower($fieldinfo->name)] = $this->Record[$i];
}
$this->Row += 1;
$stat = 1;
} else {
if ($this->Auto_Free) {
$this->free_result();
}
$stat = 0;
}
return $stat;
}
function seek($pos) {
mssql_data_seek($this->Query_ID,$pos);
$this->Row = $pos;
}
function metadata($table) {
$count = 0;
$id = 0;
$res = array();
$this->connect();
$id = mssql_query("select * from $table", $this->Link_ID);
if (!$id) {
$this->Errno = 1;
$this->Error = "General Error (The MSSQL interface cannot return detailed error messages).";
$this->halt("Metadata query failed.");
}
$count = mssql_num_fields($id);
for ($i=0; $i<$count; $i++) {
$info = mssql_fetch_field($id, $i);
$res[$i]["table"] = $table;
$res[$i]["name"] = $info->name;
$res[$i]["len"] = $info->max_length;
$res[$i]["flags"] = $info->numeric;
}
$this->free_result();
return $res;
}
function affected_rows() {
// Not a supported function in PHP3/4. Chris Johnson, 16May2001.
// return mssql_affected_rows($this->Query_ID);
$rsRows = mssql_query("Select ##rowcount as rows", $this->Link_ID);
if ($rsRows) {
return mssql_result($rsRows, 0, "rows");
}
}
function num_rows() {
return mssql_num_rows($this->Query_ID);
}
function num_fields() {
return mssql_num_fields($this->Query_ID);
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Field_Name) {
return $this->Record[strtolower($Field_Name)];
}
function p($Field_Name) {
print $this->f($Field_Name);
}
function halt($msg) {
if ("no" == $this->Halt_On_Error)
return;
$this->haltmsg($msg);
if ("report" != $this->Halt_On_Error)
die("Session halted.");
}
function haltmsg($msg) {
printf("<p>Server have a critical error!<br><br><br>We are very sorry for any inconvenience!<br><br>\n", $msg);
printf("<b>MSSQL Error</b>: %s (%s)</p>\n",
$this->Errno,
$this->Error);
}
}
$_php_major_version = substr(phpversion(), 0, 1);
if((4 > $_php_major_version) or !class_exists("DB_Sql"))
{
class DB_Sql extends DB_MSSQL
{
function DB_Sql($query = "")
{
$this->DB_MSSQL($query);
}
}
}
unset($_php_major_version);
?>
I have a question, why on DB_MSSQL my $Host,$Datebase,$User,$Password are empty?
If i test $_SESSIONS Between DB_MSSQL are OK.
Class don't have errors but this variables are empty... and i don't know why..
Can anybody help me?
Thank you verry much!
You have missed one underscore, you should have write :
public function __construct()
It should work like this.

Categories