Jump to content


mixing 2 scripts :s


2 replies to this topic

#1 Rizl4

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 22 January 2006 - 05:17 PM

Hi everyone,

atm i'm making a site for a clan of one of my friends.
So i have this download section wich uses collapsable menu's
so people can close a section :) and now i want to add a download
counter to it but i wouldn't know how to implement that, couse the
collapsing menu structure is using array's and i can't see where
to start and where this whole thing ends :)

anyway here is some usefull info
collapsable menu's code:
<?php session_start();

if($_GET['set'] > 0)
{
	
	if($_SESSION['whattoclose'] == NULL)
	{
	
		$_SESSION['whattoclose'] = $_GET['set'];
		
	} else {
	
		$_SESSION['whattoclose'] = $_SESSION['whattoclose'] . '|' . $_GET['set'];
	
	}

}

if($_GET['undo'] > 0)
{
	
	if(!empty($_SESSION['whattoclose'])){
	
		$_SESSION['whattoclose'] = str_replace("|".$_GET['undo'] , "" , $_SESSION['whattoclose']);
		$_SESSION['whattoclose'] = str_replace($_GET['undo'] , "" , $_SESSION['whattoclose']);

	}

}

function showTitle($id)
{

	$title = array(
		"Counter Strike 1.6",
		"Mohaa 1.11",
		"Other",
		""
		);
		
	$data = $_SESSION['whattoclose'];

	$not = explode( "|" , $data );
	if(!in_array( $id , $not ))
	{
		
		echo '<a href="'.$_SERVER['PHP_SELF'].'?set='.$id.'"><img src="images/close.jpg" border="0"></a> - ';
		echo $title[$id-1];
		echo("<br>----------------------------------------------------------------");
			
	} else {
		
		echo '<a href="'.$_SERVER['PHP_SELF'].'?undo='.$id.'"><img src="images/open.jpg" border="0"></a> - ';
		echo $title[$id-1];

	}		

}

function checkIt($id)
{

	$data = array(
		// Counter Strike Downloads
		'<div class="">
		&nbsp;|<a href="http://steampowered.com/download/SteamInstall.exe"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>Steam</b> - 3.2mb - by Valve<br>
		 <!-- interdownload section -->
		 <a href="#">Link2</a><br>
		 <!-- interdownload section -->
		 <a href="#">Link3</a>
		 </div>
		 '
		 ,
		 // Mohaa Downloads
		'
		<div class="">
		&nbsp;|<a href="http://www.urc-clan.com"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>Bladepack</b> - 24.2mb - by URC-CLAN<br>
		<!-- interdownload section -->
		&nbsp;|<a href="http://members.home.nl/johihek/Downloads/DMWClient-SE.exe"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>DWM Client SE</b> - 187kb - by DWMWORLD<br>
		<!-- interdownload section -->
		&nbsp;|<a href="downloads/opengl32.rar"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>openGL32.dll</b> - 231kb - by DWMWORLD
		 </div>
		'
		,
		// Other Downloads
		'
		<div class="">
		&nbsp;|<a href="http://www.snabbstart.com/_code/download.aspx?fileId=69"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>Ventrilo</b> 2.3.0 - 1.1mb - by Ventrilo.com<br>
		<!-- interdownload section -->
		&nbsp;|<a href="http://www.goteamspeak.com/index.php?page=downloads"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>Teamspeak</b> 2.0.32.60 - 5.59mb - by Teamspeak.com<br>
		<!-- interdownload section -->
		&nbsp;|<a href="downloads/mirc616.rar"><img src="images/download.jpg" border="0"></a>
		|&nbsp;<b>mIRC</b> 6.16 - 1.18mb - by mIRC<br>
		 </div>
		'
		);
	
	$str = $_SESSION['whattoclose'];

	$not = explode( "|" , $str );
	if(!in_array( $id , $not ))
	{
	
		echo '<div class="table">';
		echo $data[$id-1];
		echo '</div>';
	
	}

}

?>

if anyone has a suggestion your more then welcome ^_^
Greetzzz Rizla

#2 Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 22 January 2006 - 08:53 PM

You would make it so that when ever someone downloads a file such as. "downloadfile.php?id=1" You would update the table to add 1 where the id is defined as 1.

Then you can make the script hold the actual download link, and then use php's header() function to redirect the user to the correct url and at the same time, update the counter.

Edited by Chaos King, 22 January 2006 - 08:54 PM.


#3 Rizl4

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 23 January 2006 - 04:35 AM

And the array isn't going to give ma a problem? cause the downloads must be located in the header so it can collapse and expand...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users