Skip to content

Commit

Permalink
now dnswitch looks like it usable with php7
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Aug 11, 2018
1 parent 11fbbff commit 185b6db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.1 rev 6346
0.9.1 rev 6347
34 changes: 16 additions & 18 deletions docs/dshaper/dnswitch.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?php

///////////////////////////////////////
// //
// CONFIG SECTION //
// //
///////////////////////////////////////
// DN switcher files path
$dn_path = "/etc/stargazer/dn/";

//speed size
$speed_size = 'Kbit/s';
/* * **********************
* Config section
* *********************** */

//mysql settings
////MySQL database settings
$db_host = 'localhost';
$db_database = 'stg';
$db_login = 'mylogin';
$db_password = 'newpassword';

////////////// Main code section ///////////
// DN switcher files path
$dn_path = "/etc/stargazer/dn/";

//speed size
$speed_size = 'Kbit/s';

/* * **********************
* End of config section
* *********************** */

/**
* Advanced php5 scandir analog with some filters
Expand Down Expand Up @@ -69,11 +70,9 @@ function simple_queryall($query) {

if (!extension_loaded('mysql')) {
// init mysql link
$dblink = mysqli_connect($db_host, $db_login, $db_password);
//selecting stargazer database
mysqli_select_db($db_database, $dblink);
$dblink = mysqli_connect($db_host, $db_login, $db_password, $db_database);
//executing query
$queried = mysqli_query($query);
$queried = mysqli_query($dblink, $query);
//getting result as array
while ($row = mysqli_fetch_assoc($queried)) {
$result[] = $row;
Expand Down Expand Up @@ -134,7 +133,7 @@ function dshape_GetTimeRules() {
}

/**
* Switches speed directly
* Switches speed directly with dummynet
*
* @param int $speed
* @param int $mark
Expand All @@ -144,7 +143,6 @@ function dshape_GetTimeRules() {
*/
function dshape_SwitchSpeed($speed, $mark, $speed_size = 'Kbit/s') {
$shape_command = '/sbin/ipfw -q pipe ' . trim($mark) . ' config bw ' . $speed . '' . $speed_size . ' queue 32Kbytes' . "\n";
//print($shape_command);
shell_exec($shape_command);
}

Expand Down

0 comments on commit 185b6db

Please sign in to comment.