<?php
/* --------------------------------------------------------------
StyleEdit v2.0
Gambio GmbH
http://www.gambio.de
Copyright (c) 2010 Gambio GmbH
--------------------------------------------------------------
*/
/*
* class to handle the security sessions
*/
class GMSESecurity
{
function GMSESecurity()
{
return;
}
/*
* function to set the security token in db
* @param string $p_token
* @return boolean
*/
function set_sec_token($p_token)
{
$t_sec_token = $this->clean_sec_token($p_token);
if(!empty($t_sec_token))
{
if($this->valid_sec_token($t_sec_token) == false)
{
mysql_query("
INSERT
INTO
gm_css_style_security
SET
gm_css_style_security_token = '" . $t_sec_token . "',
gm_css_style_security_date = NOW()
");
}
}
return;
}
/*
* function to update the security token in db
* @param string $p_token
* @return boolean
*/
function update_sec_token($p_sec_id)
{
mysql_query("
UPDATE
gm_css_style_security
SET
gm_css_style_security_date = NOW()
WHERE
gm_css_style_security_id = '" . (int)$p_sec_id . "'
");
return;
}
/*
* function to clean security table in db
* @param $p_token
*/
function delete_sec_token($p_token = '')
{
if($p_token == '')
{
$t_query = mysql_query("
SELECT
gm_css_style_security_id AS id
FROM
gm_css_style_security
WHERE
UNIX_TIMESTAMP(gm_css_style_security_date) < (UNIX_TIMESTAMP()-30*60)
");
}
else
{
$t_sec_token= $this->clean_sec_token($p_token);
$t_query = mysql_query("
SELECT
gm_css_style_security_id AS id
FROM
gm_css_style_security
WHERE
gm_css_style_security_token = '" . $t_sec_token . "'
");
}
if(mysql_num_rows($t_query) > 0)
{
while($t_row = mysql_fetch_array($t_query, MYSQL_ASSOC))
{
$t_query_history = mysql_query("
SELECT
gm_css_style_history_id AS id
FROM
gm_css_style_history
WHERE
gm_css_style_security_id = '" . (int)$t_row['id'] . "'
");
if(mysql_num_rows($t_query_history) > 0)
{
while($t_row_history = mysql_fetch_array($t_query_history, MYSQL_ASSOC))
{
mysql_query("
DELETE
FROM
gm_css_style_history_content
WHERE
gm_css_style_history_id = '" . (int)$t_row_history['id'] . "'
");
}
mysql_query("
DELETE
FROM
gm_css_style_history
WHERE
gm_css_style_security_id = '" . (int)$t_row['id'] . "'
");
}
if($p_token == '')
{
mysql_query("
DELETE
FROM
gm_css_style_security
WHERE
gm_css_style_security_id = '" . (int)$t_row['id'] . "'
");
}
}
}
return;
}
/*
* function to valid the security token in db
* @param string $p_token
* @return boolean
*/
function valid_sec_token($p_token)
{
$t_sec_token = $this->clean_sec_token($p_token);
$t_query = mysql_query("
SELECT
gm_css_style_security_id AS id
FROM
gm_css_style_security
WHERE
gm_css_style_security_token = '" . $t_sec_token . "'
AND
UNIX_TIMESTAMP(gm_css_style_security_date) >= (UNIX_TIMESTAMP()-30*60)
");
if(mysql_num_rows($t_query) > 0)
{
$t_row = mysql_fetch_array($t_query, MYSQL_ASSOC);
$this->update_sec_token($t_row['id']);
return true;
}
else
{
return false;
}
}
/*
* function to clean the security token
* @param string $p_token
* @return string
*/
function clean_sec_token($p_token)
{
$t_token = mysql_real_escape_string($p_token);
$t_token = str_replace('|', '', $t_token);
$t_token = str_replace('/', '', $t_token);
$t_token = str_replace(',', '', $t_token);
$t_token = str_replace('.', '', $t_token);
$t_token = str_replace(' ', '', $t_token);
return $t_token;
}
/*
* function to get the security token id by the security token
* @param string $p_token
* @return string/boolean
*/
function get_token_id_by_token($p_token)
{
$t_sec_token = $this->clean_sec_token($p_token);
$t_query = mysql_query("
SELECT
gm_css_style_security_id AS id
FROM
gm_css_style_security
WHERE
gm_css_style_security_token = '" . $t_sec_token . "'
");
if(mysql_num_rows($t_query) > 0)
{
$t_token_id = mysql_fetch_array($t_query);
return $t_token_id['id'];
}
else
{
return false;
}
}
}
?>| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| GMBoxesMaster.php | 2013-11-12 21:10 | 7.91 KB | 76129f60960:kunden | -xw-x----- | |
| GMCSS.php | 2013-11-12 21:10 | 22.58 KB | 76129f60960:kunden | -xw-x----- | |
| GMCSSManager.php | 2013-11-12 21:10 | 29.85 KB | 76129f60960:kunden | -xw-x----- | |
| GMSEAjax.php | 2013-11-12 21:10 | 12.35 KB | 76129f60960:kunden | -xw-x----- | |
| GMSEError.php | 2013-11-12 21:10 | 1.97 KB | 76129f60960:kunden | -xw-x----- | |
| GMSEJSON.php | 2013-11-12 21:10 | 1.6 KB | 76129f60960:kunden | -xw-x----- | |
| GMSESecurity.php | 2013-11-12 21:10 | 4.79 KB | 76129f60960:kunden | -xw-x----- | |