this is the code that handles grabbing the fav picks from the database...copied from init.inc.php:
// If the person is logged in get favs from DB those in the DB have precedence
if (USER_ID > 0){
$sql = "SELECT user_favpics FROM {$CONFIG['TABLE_FAVPICS']} WHERE user_id = ".USER_ID;
$results = cpg_db_query($sql);
$row = mysql_fetch_array($results);
if (!empty($row['user_favpics'])){
$FAVPICS = @unserialize(@base64_decode($row['user_favpics']));
}else{
$FAVPICS = array();
}
}
this is clearly the line of interest:
$FAVPICS = @unserialize(@base64_decode($row['user_favpics']));
so looked up what it is and it seems that the function for decoding this is built into php.
so here is an example from the php manual:
this is the url: http://uk2.php.net/base64_decode
efficiency might be an issue here...if evertime someone loads a page with cpmfetch on it has to run the decoder...not sure what the effects on the server would be.
Ahhh, thank you!
<?php
$str = 'YToxOntpOjA7aToyMzt9';
echo print_r(unserialize(base64_decode($str)));
?>
I did this to get a view of what is in there...
I got:
Array
(
[0] => 23
)
I'm have to check, but that seems to be the image pid. I have remote access to my test stuff, but it would be a pain to get in there now and add in some more. I will know more later. I only added one, so I am not sure how it works when you add more.
As for it bogging down the server, I don't *think* it would be an issue in most cases. The shear number of DB calls a forum, or gallery does to just render a page is massive compared to the typically one call CpmFetch does. Of course if you are google or something, every cycle and byte saved helps. I doubt it will be noticeable to a user or the system.
If we get something working, I can benchmark it fully.
I did a run of 100,000 iterations of unseralizing and decoding the base 64 and it took about 1.86 seconds. If you have 100,000 favorites... well, thats a different story. And we would only have to deserialize the ones we were going to display (for random anyway). Either way, its gonna be two sql calls perhaps...
Hmmm