1
michaellee
Re: XoopsGallery Easly Hacked
  • 2008/1/28 8:06

  • michaellee

  • Just popping in

  • Posts: 2

  • Since: 2004/12/23


I encountered this problem too. I'm using a version 1.3.3.
I think to fix the issue, the extact() in init_basic (in my version, it is init.php) should be modified to include the option EXTR_SKIP. By this way, parameter from URL cannot overwrite program's internal variable (especially GALLERY_BASEDIR).

On my version, i need to modify init.php and check_init.php. You may search all PHP file to locate the "extract(" and then change it.

Quote:

From:

extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);

To:

extract($HTTP_GET_VARS,EXTR_SKIP);
extract($HTTP_POST_VARS,EXTR_SKIP);
extract($HTTP_COOKIE_VARS,EXTR_SKIP);


Hope this help



2
michaellee
newbb2 and cookie issue
  • 2005/3/29 9:52

  • michaellee

  • Just popping in

  • Posts: 2

  • Since: 2004/12/23


I'm using newbb2 (not final version). I think i hit the size limit on cookie. By looking at the cookie stored in my PC, it indicate an array of size 187 is serialized and stored in cookie topic_lastread. Afterward, new topic cannot be marked as read.

I have searched this forum and seem no solution available. Actually, i have scanned the code of newbb and found no reorganization on the cookie information. That means it will be full finally unless you clear the cookie periodically.

To fix this issue, i have modified the functions.php under include folder of newbb and created a new MySQL table ( called newbb_cookie_ext which contain uid and cookie_value) to store the information in the DB instead of cookie. Following is the modified code and would like to get comment for the core developer.

Since some information already stored in the cookie, i added code to merge cookie with database value. Also, i added some reorganization code to purge over 30 days not read topic if no. of topic stored in the database over 1500.
Quote:

function newbb_setcookie($name, $value = '')
{
global $forumCookie, $xoopsDB, $xoopsUser;

if ($name != 'topic_lastread') {
$value = (is_array($value))?serialize($value):$value;
setcookie($forumCookie['prefix'].$name, $value, $forumCookie['expire'], $forumCookie['path'], $forumCookie['domain'], $forumCookie['secure']);
}
else {
if (count($value) >= 1500 ) $value = compact_entries($value);
$value=serialize($value);
$sql = "UPDATE ".$xoopsDB->prefix("newbb_cookie_ext")." set cookie_value = '" .
($value) . "' where uid = " . $xoopsUser->getVar("uid") ;
if (!$xoopsDB->queryF($sql)) {
redirect_header('index.php',2,_MD_ERROROCCURED.'<br>'.$sql);
exit();
}
setcookie($forumCookie['prefix'].$name, "", time() - 3600, $forumCookie['path'], $forumCookie['domain'], $forumCookie['secure']);
}
}

function compact_entries($value) {
$curtime = time();
$period1 = 3600 * 24 * 30;
$period2 = 3600 * 24 * 10;
$ret1=array();
$ret2=array();
foreach ($value as $key=>$data) {
if ($curtime <= $data + $period2 ) {
$ret1[$key] = $data;
}
elseif ($curtime <= $data + $period1) {
$ret2[$key] = $data;
}
}
if ( count($ret1) + count($ret2) <= 1000 ) {
return $ret1 + $ret2;
}
else {
return $ret1;
}
}

function newbb_getcookie($name, $isArray = false)
{
global $forumCookie, $xoopsDB, $xoopsUser;
$value = !empty($_COOKIE[$forumCookie['prefix'].$name]) ? $_COOKIE[$forumCookie['prefix'].$name] : false;
// echo $name."=".$value;
if($isArray) $value = ($value)?unserialize($value):array();

if ($name == 'topic_lastread') {
$sql = "SELECT cookie_value from ".$xoopsDB->prefix("newbb_cookie_ext")." where uid = " .
$xoopsUser->getVar("uid");
if (!$result = $xoopsDB->query($sql) ) {
redirect_header('index.php',2,_MD_ERROROCCURED.'<br>'.$sql);
exit();
}
if (!$myrow = $xoopsDB->fetchArray($result) ) {
$value1 = array() ;
$sql = "INSERT INTO " .$xoopsDB->prefix("newbb_cookie_ext") . " values ( " .
$xoopsUser->getVar("uid") . ",'" . serialize(array()) ."')";
$xoopsDB->queryF($sql);
}
else {
$value1 = $myrow['cookie_value'];
// echo $name."=".$value1;
$value1 = unserialize($value1) ;
$value = merge_data ($value, $value1);
}
}
return $value;
}

function merge_data ($source, $dest)
{
if (count($source) > 0) {
foreach ($source as $key=>$data) {
if (isset($dest[$key])) {
if ($source[$key] > $dest[$key] ) {
$dest[$key] = $source[$key];
}
}
else {
$dest[$key] = $source[$key];
}
}
}
return $dest;
}




TopTop



Login

Who's Online

218 user(s) are online (194 user(s) are browsing Support Forums)


Members: 0


Guests: 218


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits