Optimize Code
Posted on
16th Feb 2014 07:03 pm by
admin
Just started getting into the use of cookies. The following code will redirect users to a set URL should they view a preset number of pages. I'm a little concerned with the speed in which this executes though. Is there a better way, or this fine?
Code: [Select]public function onPrepareContent(&$article, &$params, $limitstart)
Did you know?Explore Trending and Topic pages for more stories like this.
{
global $mainframe;
$content = $article -> text;
$current = JURI::current();
$duration = $this->params->get('duration');
$destination = $this->params->get('destination');
$max_count = $this->params->get('maxcount');
$site_id = 'aseihthaslhetlasiehtlasndlksahdlv';
$value = 1;
if(!(isset($_COOKIE["$site_id"])))
{
setcookie("$site_id", $value, time() + 60 * 60 * 24 * $duration);
}
if(isset($_COOKIE["$site_id"]))
{
$increment = TRUE;
if($_COOKIE["$site_id"] > $max_count)
{
$value = 1;
setcookie("$site_id", $value, time() + 60 * 60 * 24 * $duration);
$increment = FALSE;
header("Location: $destination");
}
if($increment)
{
$value = $_COOKIE["$site_id"];
$value++;
setcookie("$site_id", $value, time() + 60 * 60 * 24 * $duration);
/*$content = $_COOKIE["$site_id"];*/
}
}
$article -> text = $content;
}
No comments posted yet
Your Answer:
Login to answer
138
43
Other forums
Slow data retrieval which requires improvement..please help
I am working on a Help Desk Ticketing system and have a page called MY TICKETS which shows all ticke
Parse multirow HTML table
Hello all,
I have a site I am working on. Its a sports site and I am trying to add stats to a DB
How to separate records and ORDER BY
Let say i have 100 records and displayed in one page, then i want to get the records from 50-100 and
Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba
Dynamic Array using glob?
Is there an easier way to do this?
I am trying to get create a dyamic array based on files wi
[newb] Image hosting help.
Hey there, I'm new to php, I know some basics and i can code PWN, I'm only 14 but I'm interested in
cPanel API
Hi Guys,
Need a little guidance. I'm trying to get my script to communicate with cPanel (or W
Need help Updating SQL Server Express DB from c# :(
Please can anyone help with:-
1 How to sructure the strSelect statement.
2 How to instruct
Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of
Problem writing URL into database
How would I write this into the database?
<?php echo "http://".$_SERVER['SER