Announcing the Crude Traffic Scheduler for Rivendell. Assumptions for now:
Your rivendell mysql server is on the same machine with a web server. Put the following 3 files in the rivtraf directory under your web root directory. On my ubuntu 14.04, this is /var/www/html/rivtraf and in the web server it is http://host/rivtraf The files are: index.html rivgentraf1.php rivgentraf2.php Files follow as inline text: index.html ====== starts at line below ======= <HTML> <HEAD> <TITLE>Crude Traffic Scheduler for Rivendell</TITLE> </HEAD> <BODY> <H1>Crude Traffic Scheduler for Rivendell</H1> <H2>Brought to you by drew Roberts<BR>In association with Bahamian Or Nuttin</P></H2> <A HREF="rivgentraf1.php">Traffic generator 1.</A> <P> <A HREF="rivgentraf2.php">Traffic generator 2.</A> <P> Traffic generator 1 schedules a fixed number of spots<BR> per hour (mytph) and you must be running more traffic<BR> carts per day then you have traffic events per hour<BR> for this scheduler to work correctly. <P> Traffic generator 2 schedules a fixed number of breaks<BR> per hour and a fixed number of spots per break and you<BR> must be running more traffic carts per day than you<BR> have traffic events per break for this scheduler to<BR> work correctly. <P> Either scheduler will randomly schedule carts in the<BR> TRAFFIC group. <P> <A HREF="http://www.bahamianornuttin.com">Bahamian Or Nuttin.</A><BR> <A HREF="http://zotzbro.blogspot.com">drew's blog.</A> </BODY> </HTML> ====== ends at line above ======= rivgentraf1.php ====== starts at line below ======= <?php // rivgentraf.php ?> <a href="index.html">Back To Start</a> <HR> <P> <?php // edit servername, username, password, and dbname to match */ // your local mysql needs for the rivendell database */ $servername = "localhost"; $username = "rduser"; $password = "letmein"; $dbname = "Rivendell"; // echo "Now on to main traffic generation.<P>"; // things should be open by now */ // Assumptions */ // first hour to schedule is 0 myhour */ // first break to schedule is 1 mybreak */ // 42 traffic per hour mytph */ // 24 hours per day hpd */ // traffic carts to schedule per day > mytph */ // if you need more traffic spots per hour */ // change mytph to suit your needs. */ $myhour = 0; $mybreak = 0; $mytph = 4; $hpd = 24; // hopefully you will not need to edit anything below this. */ // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } while($myhour < $hpd) { $sql = "SELECT NUMBER AS FOO, TITLE FROM CART WHERE GROUP_NAME='TRAFFIC' ORDER BY RAND() LIMIT $mytph"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row $myrow = 1; while($row = $result->fetch_assoc()) { $mytitle = substr($row["TITLE"],0,50); printf ("%02d:%02d:%02d %06d 30 %' -50s", $myhour,$mybreak,$myrow,$row["FOO"],$mytitle); echo "<BR>"; $myrow++; } } else { echo "0 results"; } // echo "<P>"; $myhour++; } $conn->close(); ?> ====== ends at line above ======= rivgentraf2.php ====== starts at line below ======= <?php // rivgentraf.php ?> <a href="index.html">Back To Start</a> <HR> <P> <?php // edit servername, username, password, and dbname to match */ // your local mysql needs for the rivendell database */ $servername = "localhost"; $username = "rduser"; $password = "letmein"; $dbname = "Rivendell"; // echo "Now on to main traffic generation.<P>"; // things should be open by now */ // Assumptions */ // first hour to schedule is 0 myhour */ // first break to schedule is 1 mybreak */ // 2 traffic per break mytpb */ // 2 breaks per hour mybph */ // 24 hours per day hpd */ // if you need more traffic spots per break or more breaks */ // per hour, change mytpb and mybph to suit your needs. */ $myhour = 0; $mybreak = 1; $mytpb = 2; $mybph = 2; $hpd = 24; // hopefully you will not need to edit anything below this. */ // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } while($myhour < $hpd) { while($mybreak <= $mybph) { $sql = "SELECT NUMBER AS FOO, TITLE FROM CART WHERE GROUP_NAME='TRAFFIC' ORDER BY RAND() LIMIT $mytpb"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row $myrow = 1; while($row = $result->fetch_assoc()) { // echo "id: " . $row["NUMBER"]. " - Name: " . <BR>";. " " . $row["ARTIST"]. "<br>"; $mytitle = substr($row["TITLE"],0,50); printf ("%02d:%02d:%02d %06d 30 %' -50s", $myhour,$mybreak,$myrow,$row["FOO"],$mytitle); echo "<BR>"; // echo "Mybreak = $mybreak - Myhour = $myhour - Myrow is $myrow"; $myrow++; } } else { echo "0 results"; } // echo "<P>"; // echo "Mybreak = $mybreak - Myhour = $myhour - row is $row"; // echo "<P>"; $mybreak++; } $mybreak = 1; // echo "<P>"; $myhour++; } $conn->close(); ?> ====== ends at line above ======= all the best, drew -- http://nakedghosts.blogspot.com/
_______________________________________________ Rivendell-dev mailing list [email protected] http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev
