+ Reply to Thread
Results 1 to 4 of 4

Thread: Sig Of The Week

  1. #1
    o0slowpaul0o's Avatar
    o0slowpaul0o is offline x10 Sophmore o0slowpaul0o is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    127

    Sig Of The Week

    This was a Tutorial written to speed up the process of creating, judging, and managing a SOTW competition (specifically for GFX sites). My friend requested this so, he let me make it public.

    Quick Features:
    - Easily customized
    - Unlimited number of weeks
    - One-click judging
    - Automatic creation of new weeks

    Create a folder called sotw so you can put these files you create, in.

    Open up any text editor and place this code in and save it as config.php.

    Code:
    <?
    // This script was made by Josh Rendek @ http://gamersnetwork.us/ Do not remove any of the copyrights please.
    $server = 'localhost'; // Usually localhost
    $user = ''; // the username to access your database
    $pass = ''; // the password to access your database
    $db = ''; // the database the files will be stored on
    $dbLink = mysql_pconnect($server, $user, $pass) or die("Couldnt select user"); 
    $dbC = mysql_select_db($db, $dbLink) or die("Couldnt select database"); 
    $adminUser = 'demo';
    $adminPass = 'pass';
    $sotwPath = '/home/gamnet/www/scripts/gnSOTW/'; // make sure you leave the trailing slash
    $copyright = "<center><br><b>Created by:</b> <a href='http://x10hosting.com/'>o0slowpaul0o</a></center>";
    ?>
    Open up your text editor again and save this as installer.php

    Code:
    <?
    include('config.php');
    mysql_query("
     CREATE TABLE sotw_submits(
    id tinyint( 5 ) NOT NULL AUTO_INCREMENT ,
    user varchar( 255 ) NOT NULL default '',
    sig varchar( 255 ) NOT NULL default '',
    website varchar( 255 ) NOT NULL default '',
    wid tinyint( 5 ) NOT NULL default '0',
    winner enum( 'Y', 'N' ) NOT NULL default 'N',
    UNIQUE KEY id( id )
    ) TYPE = MYISAM
    ") or die("Error during install: <b>".mysql_error()."</b>");
    
    mysql_query("
    CREATE TABLE sotw_week (
      wid tinyint( 5 ) NOT NULL AUTO_INCREMENT ,
      UNIQUE KEY wid (wid)
    ) TYPE=MyISAM
            
    ") or die("Error during install: <b>".mysql_error()."</b>");
    
    echo "Sucesfully installed.";
    					echo "Week 1 created automatically.<br>";
    					mysql_query("INSERT INTO sotw_week VALUES ('null')") or die(mysql_error());
    					echo "New week table created.<br>";
    					$wid = 1;
    					mkdir($sotwPath.$wid, 0777);
    					echo "New week folder created.<br.";
    					
    ?>

    Open up your text editor again and save this as sotw_judge.php

    Code:
    <?
    include('config.php');
    // Admin check
      if (!isset($_SERVER['PHP_AUTH_USER'])) {
       header('WWW-Authenticate: Basic realm="gnSOTW v1.0"');
       header('HTTP/1.0 401 Unauthorized');
       echo 'You are not authorized to be here.';
       exit;
      } else {
      $check_user = $_SERVER['PHP_AUTH_USER'];
      $check_pass = $_SERVER['PHP_AUTH_PW'];
    	if($adminUser == $check_user && $adminPass == $check_pass){
    			
    
    
    
    
    
    					$sql = "SELECT * FROM sotw_week ORDER BY wid DESC LIMIT 1";
    					$q = mysql_query($sql);
    					while($row = mysql_fetch_array($q)){
    					$wid = $row['wid'];
    					}
    					
    					if($admin == 'judge' && $wid && $sig){
    					$sql = "UPDATE sotw_submits SET winner='Y' WHERE sig='$sig'";
    					mysql_query($sql) or die(mysql_error());
    					echo "SOTW Posted, new week created automatically.<br>";
    					mysql_query("INSERT INTO sotw_week VALUES ('null')") or die(mysql_error());
    					echo "New week table created.<br>";
    					$wid = $wid+1;
    					mkdir($sotwPath.$wid, 0777);
    					echo "New week folder created.<br.";
    					}
    					?>
    					
    					<center>Click on the sig to post it as the winner:<br><br>
    					<?
    					$i = 1;
    					if ($handle = opendir($sotwPath.$wid.'')) {
    					   while (false !== ($file = readdir($handle))) { 
    						   if ($file != "." && $file != "..") { 
    							echo "<font color='white'>".$i++.".</font> <a href='?admin=judge&week=".$wid."&sig=".$file."'><img src='".$wid."/".$file."' border=0 /> </a><br>"; 
    						   } 
    					   }
    					   closedir($handle); 
    					}
    					
    					}
    					}
    					
    					
    					echo $copyright;
    ?></center>
    Open up your text editor again and save this as sotw_view.php

    Code:
    <script language="JavaScript" src='pop.js' type="text/javascript"></script><center>
    <?
    include('config.php');
    $sql = "SELECT * FROM sotw_week ORDER BY wid DESC LIMIT 1";
    $q = mysql_query($sql);
    while($row = mysql_fetch_array($q)){
    $wid = $row['wid'];
    }
    $i = 1;
    if ($handle = opendir($wid.'/')) {
       while (false !== ($file = readdir($handle))) { 
           if ($file != "." && $file != "..") { 
    		echo "<font color='white'>".$i++.".</font> <a href='".$wid."/$file' target='new'><img src='".$wid."/".$file."' border=0 /> </a><br>"; 
           } 
       }
       closedir($handle); 
    }
    echo $copyright;
    ?></center>
    Open up your text edit or again and save this as sotw_submit.php

    Code:
    <center><table width="90%"  border="0" cellspacing="1" cellpadding="0">
      <tr>
        <td class='header2'>Submit Signature</td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF" class='smalltxt'>
    	<?
    	include('config.php');
    	if ("image/pjpeg" == $_FILES['userfile']['type'] || "image/jpeg" == $_FILES['userfile']['type'] || "image/gif" == $_FILES['userfile']['type'])
    	{
    	$sql = "SELECT * FROM sotw_week ORDER BY wid DESC LIMIT 1";
    	$q = mysql_query($sql);
    	while($row = mysql_fetch_array($q)){
    	$wid = $row['wid'];
    	}
    	
    	$sigs = $sotwPath.$wid."/";
    	$uploadfile = $sigs . $_FILES['userfile']['name'];
    	if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    	$img = $_FILES['userfile']['name'];
    	$name = $_FILES['userfile']['name'];
    	$debug = $_FILES;
    	
    	$sql = "INSERT INTO sotw_submits VALUES ('NULL', '$user', '$name', '$website', '$wid', 'N')";
    	mysql_query($sql) or die("Couldnt add sig to DB - ".mysql_error());
    	@chmod($sotwPath.$wid."/".$name, 0777);
    	
       print "File is valid, and was successfully added to this weeks contest (Week #".$wid.").";
    	}else{ echo "File couldnt be uploaded. <b>Debug:</B><br>";
    	print_r($_FILES);
    	 }
    	}
    ?>
    	<form action="" method="post" enctype="multipart/form-data" name="form1">
      <strong>User</strong>: <input type="text" name="user"><br>
      <strong>Sig</strong>:
      <input name="userfile" type="file">
      <br>
      <strong>Website</strong>:
      <input type="text" name="website">
      <br>
      <input type="submit" name="Submit" value="Submit Sig">
        </form></td>
      </tr>
    </table>
    <? echo $copyright; ?>
    Open up your text editor again and save this as sotw_winner.php

    Code:
    <?
    include('config.php');
    ?>
    <script src="pop.js" type="text/javascript"></script>
    <?
    $sql = "SELECT * FROM sotw_week ORDER BY wid DESC LIMIT 1";
    $q = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($q)){
    $lastweek = $row['wid'] - 1;
    }
    $sql = "SELECT * FROM sotw_submits WHERE wid='$lastweek' AND winner='Y'";
    $q = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($q)){
    echo "<a href='".$lastweek."/".$row['sig']."' target=new><img src='".$lastweek."/".$row['sig']."' width='65%' border=1 target='new' /></a>";
    }
    echo '
    <br>
        <a href="javascript:pop(\'sotw_submit.php\', 400, 100);">Submit Sig</a><br>
    	<a href="sotw_view.php?sotw=view">View This Weeks Entries</a>';
    	echo $copyright;
    ?>
    Last time now, open up a text editor and save this as pop.js

    Code:
    function pop(URL, w, h) {
    	  window.open(URL,'refrence','width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes'); 
    }
    Last thing now is to install. Open up config.php and edit your database needs. Upload it to your server and then run www.yourdomain.com/sotw/installer.php. Then your done!

    Demo: Would release a demo, but I can't give out my domain till it's finished. The first person to give a demo can get rid of the copyright.

    Please NOTE: Please do not remove the copyright for x10hosting. I had put it there to gain x10 more users than they usally do. Also, I might not be posting another tutorial for abit. Someone on this site requested a mod for IPB. So i gotta get work and see if I can do it.
    Last edited by o0slowpaul0o; 07-31-2005 at 05:00 AM.

  2. #2
    Akkarin's Avatar
    Akkarin is offline x10 Elder Akkarin is an unknown quantity at this point
    Join Date
    May 2005
    Location
    London, UK
    Posts
    827

    Re: Sig Of The Week

    Wow, this looks really useful I'll try it out when I can!

  3. #3
    o0slowpaul0o's Avatar
    o0slowpaul0o is offline x10 Sophmore o0slowpaul0o is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    127

    Re: Sig Of The Week

    Aha! I knew you would see this quick, I noticed you had a GFX site, so i wanted to help alittle by making a Tut. :D

  4. #4
    n4tec's Avatar
    n4tec is offline Lord Of The Keys n4tec is an unknown quantity at this point
    Join Date
    Feb 2005
    Location
    GeT NOTICED via n4tec
    Posts
    1,656

    Talking Re: Sig Of The Week

    thanx for the tutorial and thanx for all your tutorials.. when i lauch my other domain which is about graphics i will certainly use you tut...
    Last edited by n4tec; 07-31-2005 at 05:34 AM.
    .::: Regards, n4tec :::.


+ Reply to Thread

Similar Threads

  1. Forums have been down now for a week - problem?
    By BretFan1 in forum Free Hosting
    Replies: 6
    Last Post: 07-10-2006, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers