[RC] HTTP Guest Cache

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
clove28
Registered User
Posts: 97
Joined: Mon Apr 21, 2014 11:00 am

Re: [RC] HTTP Guest Cache

Post by clove28 » Fri Jul 04, 2014 3:04 pm

Hi! I've been running around for this mod to work but I'm having a problem with the "function.php" code

Here's the part of the function.php where I need to put the code..

Code: Select all

	// Assign sid if session id is not specified
	if ($session_id === false)
	{
		$session_id = $_SID;
	}

	$amp_delim = ($is_amp) ? '&' : '&';
	$url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim;
After I put the mod codes, here's what it looks like..

Code: Select all

	$amp_delim = 	
	/* BEGIN mod_http_guest_cache */
	global $config;
	if ($_SID && !empty($config['mod_http_guest_cache']))
	{
		global $mod_http_guest_cache;
		if (!isset($mod_http_guest_cache))
		{
			global $phpbb_root_path, $phpEx;
			include_once "$phpbb_root_path/includes/mod_http_guest_cache.$phpEx";
		}
		$mod_http_guest_cache->remove_cache_param($url, $params, $amp_delim);
	}
	/* END mod_http_guest_cache */
	
($is_amp) ? '&' : '&';
	$url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim;
But I'm getting this error..
Parse error: syntax error, unexpected 'global' (T_GLOBAL) in /home1/rakista2/public_html/test2/includes/functions.php
Can someone help me with this? :oops:

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: [RC] HTTP Guest Cache

Post by Haravikk » Fri Jul 04, 2014 3:17 pm

It looks like you've inserted code into the middle of a line rather than after it, so you've left the $amp_delim = stranded from the ($is_amp) ? '&' : '&';. Also, the amp_delim and url_delim lines should come first.

So to fix your second code snippet it should look like this:

Code: Select all

    $amp_delim =  ($is_amp) ? '&' : '&';
   $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim;

    /* BEGIN mod_http_guest_cache */
   global $config;
   if ($_SID && !empty($config['mod_http_guest_cache']))
   {
      global $mod_http_guest_cache;
      if (!isset($mod_http_guest_cache))
      {
         global $phpbb_root_path, $phpEx;
         include_once "$phpbb_root_path/includes/mod_http_guest_cache.$phpEx";
      }
      $mod_http_guest_cache->remove_cache_param($url, $params, $amp_delim);
   }
   /* END mod_http_guest_cache */
Hope that helps!

clove28
Registered User
Posts: 97
Joined: Mon Apr 21, 2014 11:00 am

Re: [RC] HTTP Guest Cache

Post by clove28 » Fri Jul 04, 2014 3:36 pm

Hi Haravikk! Thanks for the reply..

After I edited it, now it shows another error..
Here's the original code..

Code: Select all

if ($cron_type)
		{
			$template->assign_var ('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $cron_type) . '" width="1" height="1" alt="cron" />');
		}
After putting the mod code, here's what it looks like..

Code: Select all

if ($cron_type)
		{
			$template->assign_var			
			/* BEGIN mod_http_guest_cache */
			if (!headers_sent())
			{
				global $mod_http_guest_cache;
				if (isset($mod_http_guest_cache) && $mod_http_guest_cache->is_cacheable())
				{
					$mod_http_guest_cache->unset_headers();
				}
			}
			/* END mod_http_guest_cache */('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $cron_type) . '" width="1" height="1" alt="cron" />');
		}
But I'm getting this error..
Parse error: syntax error, unexpected 'if' (T_IF) in /home1/rakista2/public_html/test2/includes/functions.php
What could be the problem? :oops:

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: [RC] HTTP Guest Cache

Post by Haravikk » Fri Jul 04, 2014 3:43 pm

Hmm, $template->assign_var looks like another incomplete line that's had an insertion in the middle, rather than after; are you applying the changes manually or are you using autoMOD?

Here's how that block of code should look after the addition:

Code: Select all

		if ($cron_type)
		{
			$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $cron_type) . '" width="1" height="1" alt="cron" />');
			/* BEGIN mod_http_guest_cache */
			if (!headers_sent())
			{
				global $mod_http_guest_cache;
				if (isset($mod_http_guest_cache) && $mod_http_guest_cache->is_cacheable())
				{
					$mod_http_guest_cache->unset_headers();
				}
			}
			/* END mod_http_guest_cache */
		}

clove28
Registered User
Posts: 97
Joined: Mon Apr 21, 2014 11:00 am

Re: [RC] HTTP Guest Cache

Post by clove28 » Fri Jul 04, 2014 3:50 pm

Hi Haravikk! Finally it worked! I've been studying this for almost 3 months and now it finally worked! Thank you! Thank you! :D :D

User avatar
Pthelovod
Registered User
Posts: 106
Joined: Mon Feb 22, 2010 1:32 am
Location: Россия
Name: Alexs Pthelovod
Contact:

Re: [RC] HTTP Guest Cache

Post by Pthelovod » Sat Sep 13, 2014 4:29 am

Haravikk, any news? :?:

Locked

Return to “[3.0.x] MODs in Development”