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)
{
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
Creating an invoice
Using fpdf I am trying to create an invoice to send to clients. The products are sold in pricing tie
Warehouse Management
Hi,
On our system, we have two storage locations ( A and B ) where A is the main factory
form class help (oop php5)
Hidy Ho Neighbors,
I'm forcing myself to learn oop/classes for php5. It seems like a good id
Multiple arrays inside data
Hi,
Simple question. I have a column called "array" in my database, and inserted in
How to load mysql (and other) extensions into PHP
How to load mysql (and other) extensions into PHP PHP Development forum discussing coding practices,
str_replace help
Hey there,
I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean
Multiple upload and Resize
I would like some help on my script I have the for my index.php
////
<html&
selectbox+database connection retrive problem
Code: [Select]
<tr>
<th align="left" scope="c
Filling gaps in dates
So i'm doing a query for sales data and my return array looks like this
('date' => '20
Material Issuing for receiving batch
Dear All experts in MM/ PP,
Material issuing from main stores to factory is currently usi