Ir para conteúdo
Fórum Script Brasil
  • 0

[Erro] WsSys - Erro Fatal


Guest Conpb

Pergunta

WsSys - Erro Fatal

MySQL - Query inválida

Query: DELETE FROM `_sessions` WHERE `expire` < '1199477046';

Erro retornado: 1146 - Table 'main._sessions' doesn't exist

Estou com esse erro, já tentei de tudo, até criar uma coluna com isso na tabela e não deu certo.

alguém sabe o que é isso, e como claro, consertar.

Fico grato desde já se alguém responder.

obrigado!

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0
Guest Visitante
<?php

class Library {

var $ip = null;

var $s = null;

var $cfg = array();

var $hash = "";

var $hash_at_link = "";

var $is_new_visitor = false;

var $sdata = array();

var $udata = array();

var $pdata = array(

'template' => "default",

'content-type' => "text/html; charset=iso-8859-1"

);

var $webcrawlers = array( 'ia_archiver', 'ask jeeves', 'gigabot', 'google', 'grub', 'msnbot', 'scooter', 'wget', 'slurp' );

// Função de criação do sistema

function Library ( &$WsSys ) {

$this->s = &$WsSys; $s = &$this->s;

$addrs = array();

foreach( array_reverse( explode( ",", $s->req_s['HTTP_X_FORWARDED_FOR']) ) as $x_f )

{

$x_f = trim( $x_f );

if ( preg_match( "/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $x_f ) ) { $addrs[] = $x_f; }

}

$addrs[] = $s->req_s['REMOTE_ADDR'];

$addrs[] = $s->req_s['HTTP_PROXY_USER'];

foreach ( $addrs as $k => $v )

{

if ( isset( $v ) )

{

$this->ip = $v;

break;

}

}

}

function error ( $msg = "" )

{

$s = &$this->s;

header( "Content-Type: ". $this->pdata['content-type'] );

echo "<b>[Erro]</b> ". $msg;

$this->_exit();

}

function replace ( $string = "", $data = array() )

{

$s = &$this->s;

foreach ( $data as $k => $v ) { $string = str_replace( "%". $k ."%", $v, $string ); }

return $string;

}

function advanced_replace( $string, $replace = array(), $place = "" )

{

$s = &$this->s;

if ( !is_array( $replace ) || count( $replace ) == 0 ) { return $string; }

foreach ( $replace as $k => $v )

{

if ( is_array( $v ) )

{

$string = $this->advanced_replace( $string, $v, $place . $k .":" );

}

else { $string = str_replace( "%". $place . $k ."%", $v, $string ); }

}

return $string;

}

function session_create ( $cookie_name, $hash = "" )

{

$s = &$this->s;

if ( preg_match( "/(". implode( "|", $this->webcrawlers ) .")/i", $s->req_s['HTTP_USER_AGENT'] ) )

{

$hash = "0f4f0cf0c233cc3a0e11ad5c636b2c79";

$this->is_new_visitor = false;

return $hash;

}

if ( $hash == "51f6a0d04bf28977c1ea7d7fc554eaee" ) { return $hash; }

if ( !$hash ) { $hash = md5( time() * rand() ); }

$check = sha1( $this->ip ." | ". $s->req_s['HTTP_USER_AGENT'] );

$s->sql_query( "INSERT INTO `_sessions` ( `hash`, `expire`, `check`, `data` ) VALUES ( '". $hash ."', '". ( time() + 1200 ) ."', '". $check ."', '' ); " );

setcookie( $cookie_name, $hash, time() + 1200 );

$this->is_new_visitor = true;

return $hash;

}

function session_init ( $cookie_name, $get_name )

{

$s = &$this->s;

$hash = ""; $hash_at_link = 1;

$s->sql_query( "DELETE FROM `_sessions` WHERE `expire` < '". time() ."'; " );

if ( preg_match( "/(". implode( "|", $this->webcrawlers ) .")/i", $s->req_s['HTTP_USER_AGENT'] ) )

{

$hash_at_link = 0;

$this->hash = "0f4f0cf0c233cc3a0e11ad5c636b2c79";

return;

}

if ( $s->req_g[ $get_name ] == "51f6a0d04bf28977c1ea7d7fc554eaee" )

{

$hash_at_link = 1;

$this->hash = $s->req_g[ $get_name ];

return;

}

if ( $s->req_c[ $cookie_name ] ) { $hash = $s->req_c[ $cookie_name ]; $hash_at_link = 0; }

else if ( $s->req_g[ $get_name ] ) { $hash = $s->req_g[ $get_name ]; $hash_at_link = 1; }

if ( !preg_match( "/^[0-9a-f]{32}$/", $hash ) ) { $this->hash = $this->session_create( $cookie_name ); }

else

{

$data = $s->sql_query_results( "SELECT `check`, `data` FROM `_sessions` WHERE `hash` = '". $hash ."'; " ); $data = $data[0];

if ( $data['check'] == sha1( $this->ip ." | ". $s->req_s['HTTP_USER_AGENT'] ) )

{

setcookie( $cookie_name, $hash, time() + 1200 );

$this->hash = $hash;

$this->sdata = $s->vars_import( $data['data'] );

$s->sql_query( "UPDATE `_sessions` SET `expire` = '". ( time() + 1200 ) ."' WHERE `hash` = '". $hash ."'; " );

}

else

{

$this->hash = $this->session_create( $cookie_name );

}

}

$this->hash_at_link = $hash_at_link;

}

function session_save ( )

{

if ( $this->hash == "0f4f0cf0c233cc3a0e11ad5c636b2c79" || $this->hash == "51f6a0d04bf28977c1ea7d7fc554eaee" ) { return; }

$s = &$this->s;

$s->sql_query( "UPDATE `_sessions` SET `data` = '". $s->escape( $s->vars_export( $this->sdata ), "'" ) ."' WHERE `hash` = '". $this->hash ."'; " );

$s->sql_query( "OPTIMIZE TABLE `_sessions`; " );

}

function _init ( )

{

$s = &$this->s;

$s->sql_connect();

$this->confs_read();

$this->session_init( "ws_session", "s" );

$this->user_load();

}

function _load ( )

{

global $_base; $s = &$this->s;

if ( !$s->req_g['env'] ) { $s->req_g['env'] = "guest"; }

if ( !$s->req_g['do'] ) { $s->req_g['do'] = "main"; }

if ( strpos( $s->req_g['do'], "." ) !== false ) { list( $s->req_g['do'], $s->req_g['act'] ) = explode( ".", $s->req_g['do'], 2 ); }

$s->req_g = $this->http_get_safe( $s->req_g );

if ( $s->req_g['env'] == "admin" && $this->udata['mail'] && $this->udata['level'] != "A" ) { $this->redir( "__self|env=guest&do=error&error=admin_only" ); }

else if ( $s->req_g['env'] != "guest" && !$this->udata['mail'] ) { $this->redir( "__self|env=guest&do=login&red=. urlencode( $s->req_s['REQUEST_URI] ) ); }

$required_module = $_base ."/inc/". $s->req_g['env'] ."/". $s->req_g['do'] .".php";

if ( !file_exists( $required_module ) ) { header( "HTTP/1.0 404 Not Found" ); $this->error( "O ambiente <u>". $s->req_g['env'] ."</u> ou a ação <u>". $s->req_g['do'] ."</u> não existem no sistema." ); }

else

{

ob_start();

require_once $required_module;

$this->_loaded = ob_get_contents();

ob_end_clean();

}

}

function _print ( )

{

global $_base; $s = &$this->s;

header( "Content-type: ". $this->pdata['content-type'] );

$this->pdata['replace'] = array();

if ( $this->pdata['template'] )

{

$required_template = $_base ."/inc/tpl.". $this->pdata['template'] .".php";

if ( !file_exists( $required_template ) ) { $this->error( "O modelo solicitado pela ação não existe no sistema." ); }

else

{

ob_start();

require_once $required_template;

$final = ob_get_contents();

ob_end_clean();

}

$replace = array( "inc:content" => $this->_loaded );

}

else { $final = $this->_loaded; }

$replace = array_merge( $replace, $this->pdata['replace'] );

$final = $s->replace_vars( $final, $replace );

$final = str_replace( "__host", "http://". $s->req_s['HTTP_HOST'], $final );

if ( $this->hash_at_link )

{

$final = str_replace( "__self|", $s->req_s['SCRIPT_NAME'] ."?s=. $this->hash ."&", $final );

$final = str_replace( "__self", $s->req_s['SCRIPT_NAME] ."?s=". $this->hash, $final );

}

else

{

$final = str_replace( "__self|", $s->req_s['SCRIPT_NAME'] ."?", $final );

$final = str_replace( "__self", $s->req_s['SCRIPT_NAME'], $final );

}

echo $final;

}

function _end ( )

{

$s = &$this->s;

$this->session_save();

$s->sql_close();

$this->confs_save();

}

function _exit ( )

{

$s = &$this->s;

$this->_end(); exit;

}

function redir ( $url, $msg = "" )

{

$s = &$this->s;

if ( $this->hash_at_link )

{

$url = str_replace( "__self|", $s->req_s['SCRIPT_NAME'] ."?s=. $this->hash ."&", $url );

$url = str_replace( "__self", $s->req_s['SCRIPT_NAME] ."?s=". $this->hash, $url );

}

else

{

$url = str_replace( "__self|", $s->req_s['SCRIPT_NAME'] ."?", $url );

$url = str_replace( "__self", $s->req_s['SCRIPT_NAME'], $url );

}

if ( $msg ) { $this->sdata['msg'] = $msg; }

header( "Location: ". $url );

echo "<html><head><title>Redirecionamento</title><meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" /><meta http-equiv=\"refresh\" content=\"0; URL=. $s->quote_safe( $url ) ."\"></head><body>Redirecionando para ". $url ."<br /><br /><a href=\"". $url ."\">Clique aqui se nada acontecer.</a></body></html>";

$this->_exit();

}

function http_get_safe( $array = array() )

{

$s = &$this->s;

foreach ( $array as $k => $v )

{

$v = str_replace( "../", "", $v );

$v = str_replace( "..\\", "", $v );

$v = str_replace( "/..", "", $v );

$v = str_replace( "\\..", "", $v );

$array[ $k ] = $v;

}

return $array;

}

function confs_read ( )

{

global $_base; $s = &$this->s;

$this->cfg = $s->db_vars_open( $_base ."/db/configs.php", 1 );

$this->cfg_checksum = sha1( print_r( $this->cfg, 1 ) );

}

function confs_save ( )

{

global $_base; $s = &$this->s;

if ( sha1( print_r( $this->cfg, 1 ) ) != $this->cfg_checksum ) { $s->db_vars_save( $_base ."/db/configs.php", $this->cfg ); }

}

function user_load()

{

$s = &$this->s; $auto_login = 0;

if ( !$this->sdata['auth] )

{

if ( $s->req_c['auto_auth'] )

{

$auto_login = 1;

$this->sdata['auth'] = $s->req_c['auto_auth'];

setcookie( "auto_auth", $this->sdata['auth'], time() + 31536000 );

}

else { return; }

}

list( $mail, $pwd ) = explode( "|", $this->sdata['auth'], 2 );

$data = $s->sql_query_results( "SELECT * FROM `users` WHERE `mail` = '". $mail ."' AND `pwd` = '". $pwd ."'; " );

if ( $data[0] )

{

if ( $auto_login )

{

if ( $data[0]['level'] == "A" ) { $this->is_new_visitor = 0; }

}

$this->udata = $data[0];

$this->logon_tasks();

}

else { unset( $this->sdata['auth'] ); }

}

function get_user_data ( $id )

{

$s = &$this->s;

$user_data = $s->sql_query_results( "SELECT * FROM `users` WHERE `id` = '". $s->escape( $id, "'" ) ."'" );

return $user_data[0];

}

function form_check ( $fields, $check )

{

$s = &$this->s;

$error = "";

if ( !is_array( $fields ) ) { $fields = array( $fields ); }

switch ( $check )

{

case "not_null":

foreach ( $fields as $v )

{

if ( !isset( $s->req_p[ $v ] ) || $s->req_p[ $v ] === "" ) { $error = "form_null_found"; break; }

}

break;

case "is_mail":

foreach ( $fields as $v )

{

if ( !preg_match( "/[^@]+@[^\.]+\..+/U", $s->req_p[ $v ] ) ) { $error = "form_invalid_mail"; break; }

}

break;

case "is_equal":

$check = null;

foreach ( $fields as $v )

{

if ( !$check ) { $check = $s->req_p[ $v ]; }

else { if ( $check != $s->req_p[ $v ] ) { $error = "form_pwd_mismatch"; break; } }

}

break;

}

if ( $error ) { $this->redir( "__self|env=guest&do=error&error=. $error ); }

}

function http_retrieve ( $url, $only_headers = 0, $ref = "" )

{

$s = &$this->s;

$url = parse_url( $url );

if ( !$url['port] ) { $url['port'] = 80; }

if ( $url['query'] ) { $url['path'] .= "?". $url['query']; }

$sk = @fsockopen( $url['host'], $url['port'], $sk_err_n, $sk_err, 30 );

if ( !$sk ) { return false; }

fwrite( $sk, "GET ". $url['path'] ." HTTP/1.0" ."\r\n".

"Host: ". $url['host'] ."" ."\r\n".

"User-Agent: ". $s->req_s['HTTP_USER_AGENT'] ."\r\n".

( ( $ref ) ? "Referer: ". $ref ."\r\n" : "" ) .

"\r\n" );

$sk_hsent = 0; $sk_h = array();

while ( !feof( $sk ) )

{

$x = fgets( $sk, 2048 );

if ( !$sk_hsent && trim( $x ) == "" ) { $sk_hsent = 1; break; }

else { $sk_h[] .= trim( $x ); }

}

$res = array();

$res['http_response'] = $sk_h[0]; unset( $sk_h[0] );

$res['headers'] = array();

foreach ( $sk_h as $k => $v )

{

list( $name, $content ) = explode( ":", $v, 2 );

$res['headers'][ strtolower( $name ) ] = trim( $content );

}

if ( !$only_headers )

{

$res['content'] = "";

while ( !feof( $sk ) )

{

$res['content'] .= fgets( $sk, 2048 );

}

}

fclose( $sk );

return $res;

}

function logon_tasks ( )

{

$s = &$this->s;

$s->sql_query( "UPDATE `subscriptions` SET `paid` = 'N', `expire` = '0' WHERE `paid` = 'Y' AND `expire` <= '". $s->escape( time(), "'" ) ."'" );

}

}

?>

Acho que o erro ta ai ^^

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652,1k
×
×
  • Criar Novo...