1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I make this script run in sequential order?

Discussion in 'CPA' started by rydg187, Sep 28, 2009.

  1. rydg187

    rydg187 Registered Member

    Joined:
    Jun 26, 2009
    Messages:
    87
    Likes Received:
    4
    How can I make this script run in sequential order?


    PHP:
     <?php
    $referer 
    $_SERVER['HTTP_REFERER'];
    $redirectTo "";

    $random rand(016); // change 16 to the number of links below
    switch($random) {
        case 
    0:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    1:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    2:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    3:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    4:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    5:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    6:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    7:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    8:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    9:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    10:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    11:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    12:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    13:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    14:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    15:
            
    $redirectTo "http://afflink.com";
            break;
        case 
    16:
            
    $redirectTo "http://afflink.com";
            break;
        default:
            
    $redirectTo "http://www.google.com";
            break;
    }

    if (
    $referer == "" && (isset($redirectTo) && $redirectTo != "")) {
        echo 
    "<meta http-equiv=\"refresh\" content=\"0;url=$redirectTo\">";
    }
    ?>

     
  2. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    Lol, my script...


    Yeah, agreed to above poster.

    If it was me, I'd do it over a MySQL database, purely because it's more secure and because it's actually more easier.

    If you need anymore help, I'll post the code that is needed.
     
  3. rydg187

    rydg187 Registered Member

    Joined:
    Jun 26, 2009
    Messages:
    87
    Likes Received:
    4


    Yes it is your script. Thank you for this script. Can you please post the code that is needed to make this script run in sequential order? I am not really sure what to do, I have a little bit of experience working with MySQL.
     
  4. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    Alright, here it is. I haven't fully tested it because, well.... I couldn't be bothered because it meant that I'd have to DMR to that page and ... all that XD, but it should work. I went as far as "you have a referrer so I won't do anything".


    redirect.php
    PHP:
    <?php
    require 'inc.php'// won't work without it

    $referer $_SERVER['HTTP_REFERER'];
    $redirectTo "";
    $numLinks 16// the highest case number; default: 16

    $curHits getHits(); // gets the number of hits
    switch($curHits) {
        case 
    0:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    1:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    2:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    3:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    4:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    5:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    6:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    7:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    8:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    9:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    10:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    11:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    12:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    13:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    14:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    15:
            
    $redirectTo "http://www.afflink.com";
            break;
        case 
    16:
            
    $redirectTo "http://www.afflink.com";
            break;
        default:
            
    $redirectTo "http://www.google.com";
            break;
    }

    $curHits++; // add one to number of hits
    if ($curHits $numLinks$curHits 0// if the new variable is higher than the number of links, then reset to 0
    setHits($curHits); // set the database to the new variable

    if ($referer == "" && (isset($redirectTo) && $redirectTo != "")) {
        echo 
    "<meta http-equiv=\"refresh\" content=\"0;url=$redirectTo\">";

    ?>
    ----------------------------------------------------------------

    inc.php
    PHP:
    <?php
    /*
     * Includes File, containing various useful functions.
     * by iPwnJ00, for rydg187 of BHW.
     */

    require("config.php"); // might come in handy

    /**
     *
     * Returns results of a database query.
     *
     */
    function querydb($query) {
        global 
    $DATABASE$DOWNLOAD;

        
    $mysql mysql_connect($DATABASE['host'], $DATABASE['username'], $DATABASE['password']);
        
    mysql_select_db($DATABASE['dbname'], $mysql);
        
    $result mysql_query($query$mysql);

        return 
    $result;
    }

    /**
     *
     * Returns the current number of hits.
     *
     */
    function getHits() {
        
    $result querydb("SELECT hits FROM cpacounter");
        while (
    $row mysql_fetch_assoc($result)) {
            
    $hits[] = $row['hits'];
        }

        return 
    $hits[0];
    }

    /**
     *
     * Sets the number of hits.
     *
     */
    function setHits($hits) {
        
    querydb("UPDATE cpacounter SET hits = $hits"); // drop error
    }
    ?>
    --------------------------------------------------------------

    config.php
    PHP:
    <?php
    /**
     *  DATABASE RELATED VARIABLES
     */

    $DATABASE['host'] = 'localhost';     // The server which the database is on.
    $DATABASE['dbname'] = "seqcpa";     // The database name.
    $DATABASE['username'] = "seqcpa";     // The database user.
    $DATABASE['password'] = "0bv10uslyn0tmyp@$$w0rd";     // The database password.

    ?>

    You will also need to run these SQL queries on your web host. Use phpMyAdmin or ask your web host for assistance:

    Code:
    -- phpMyAdmin SQL Dump
    -- version 2.11.9.5
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Sep 28, 2009 at 10:03 AM
    -- Server version: 5.0.81
    -- PHP Version: 5.2.6
    
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    
    --
    -- Database: `seqcpa`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `cpacounter`
    --
    
    CREATE TABLE IF NOT EXISTS `cpacounter` (
      `hits` int(11) NOT NULL default '0'
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    --
    -- Dumping data for table `cpacounter`
    --
    
    INSERT INTO `cpacounter` (`hits`) VALUES
    (0);
    
     
    • Thanks Thanks x 1