Ejemplo n.º 1
0
global $start_log;
global $ini_array;
global $ini_file;
global $unitname;
$GLOBALS['startlog'] = "/var/log/start.log";
$GLOBALS['ini_file'] = __DIR__ . "/sys_startup.ini";
/*if(!check_root())
	{
		echo "\nMust be run as root or from cron!!\n\n";
		log_it("Must be run as root or from cron!!");
		die; 
	}
*/
log_it("[Startup Ran]");
echo "FILE " . $GLOBALS['ini_file'] . "\n";
readini($GLOBALS['ini_file']);
//print_r($GLOBALS['ini_array']);
/* When this PI is using relays we need to init them using GPIO*/
initrelay();
/* Start temp monitor */
system("/home/pi/bin/templog/temp1.php -D 2>&1 &");
/* Start network monitor */
system("/root/network-monitorrpi.sh >/dev/null 2>&1 &");
$GLOBALS['unitname'] = preg_replace("/\r|\n/", "", shell_exec("/bin/hostname"));
//'*******************************************************************************
function check_root()
{
    if (posix_getuid() == 0) {
        //echo "This is root !";
        return True;
    } else {
Ejemplo n.º 2
0
function checksock()
{
    /* Accept incoming requests and handle them as child processes */
    $client = @socket_accept($GLOBALS['sock']);
    //echo "Client " .$client ."\n";
    if (!$client === false) {
        // Read the input from the client – 1024 bytes
        //$input = socket_read($client, 1024);
        $status = @socket_get_status($client);
        $input = @socket_read($client, 2048);
        // Strip all white spaces from input
        echo "RAW " . $input . "\n";
        if ($input == '') {
            break;
        }
        //$output = ereg_replace("[ \t\n\r]","",$input).chr(0);
        //$output = ereg_replace("[ \t\n\r]","",$input);
        $output = explode(" ", $input);
        switch (strtolower($output[0])) {
            case 'white':
                $response = "Turn on white\n\n";
                socket_write($client, $response);
                socket_close($client);
                break;
            case '-get':
                if (isset($output[1])) {
                    switch (strtolower($output[1])) {
                        case 'sd':
                            $response = "Strobe Duration " . $GLOBALS['strobedelay'] . "\n";
                            socket_write($client, $response, strlen($response));
                            socket_close($client);
                            break;
                    }
                } else {
                    $response = shwhelp();
                    socket_write($client, $response, strlen($response));
                    socket_close($client);
                }
                break;
            case '-yard':
            case '-y':
                if (isset($output[1])) {
                    yardlight($output[1]);
                } else {
                    $response = "Missing power number 0-10\n";
                    socket_write($client, $response);
                    socket_close($client);
                }
                break;
            case '-color':
            case '-c':
                echo "In Color Case\n";
                echo "OUTPUT 1 " . $output[1] . "\n";
                if (isset($output[1])) {
                    echo "COLOR SET\n";
                    $colorv = explode(",", $output[1]);
                    echo "SIZE COLORV " . sizeof($colorv);
                    if (sizeof($colorv) == 3) {
                        $GLOBALS['rl'] = $colorv[0];
                        $GLOBALS['gl'] = $colorv[1];
                        $GLOBALS['bl'] = $colorv[2];
                        changecolor($colorv[0], $colorv[1], $colorv[2]);
                        $response = "Color R" . $GLOBALS['rl'] . " G" . $GLOBALS['gl'] . " B" . $GLOBALS['bl'] . "\n";
                        socket_write($client, $response);
                        socket_close($client);
                    }
                }
                break;
            case '-setcolor':
                echo "In SetColor Case\n";
                if (isset($output[1])) {
                    $colorv = explode(",", $output[1]);
                    if (sizeof($colorv) == 3) {
                        $response = "Color Set to\n";
                        $response .= "R " . $colorv[0] . " G " . $colorv[1] . " B " . $colorv[2];
                        socket_write($client, $response);
                        socket_close($client);
                        readini($GLOBALS['inifile']);
                        $GLOBALS['rl'] = $colorv[0];
                        $GLOBALS['gl'] = $colorv[1];
                        $GLOBALS['bl'] = $colorv[2];
                        $GLOBALS['ini_array']['color']['r'] = $GLOBALS['rl'];
                        $GLOBALS['ini_array']['color']['g'] = $GLOBALS['gl'];
                        $GLOBALS['ini_array']['color']['b'] = $GLOBALS['bl'];
                        $result = write_ini_file($GLOBALS['ini_array'], $GLOBALS['inifile']);
                    }
                }
                break;
            case '-red':
                $GLOBALS['rl'] = 10;
                $GLOBALS['gl'] = 0;
                $GLOBALS['bl'] = 0;
                changecolor($GLOBALS['rl'], $GLOBALS['gl'], $GLOBALS['bl']);
                break;
            case 'test':
                $response = "Testing\n\n";
                socket_write($client, $response);
                socket_close($client);
                looptest();
                break;
            case "-s":
                socket_write($client, listscene());
                socket_close($client);
                break;
            case "-snd":
                socket_write($client, listsound());
                socket_close($client);
                break;
            case "-sl":
                if (isset($output[1])) {
                    socket_write($client, showscene($output[1]));
                } else {
                    socket_write($client, "Need Scene ");
                }
                socket_close($client);
                break;
            case "-run":
                if (isset($output[1])) {
                    socket_write($client, runscene($output[1]));
                    socket_close($client);
                }
                break;
            case '-p':
            case '-P':
                //try to fork or background process
                if (isset($output[1])) {
                    /*socket_write($client, $output[1]);
                      socket_close($client);
                      return;*/
                    $c = getcwd() . '/bp.php ' . $output[1] . ' >bp.txt 2>&1 & echo $!';
                    //socket_write($client, $c);
                    $GLOBALS['runpid'] = system($c);
                    $status = system('ps aux | grep -i ' . $GLOBALS['runpid']);
                    //echo $status;
                    socket_write($client, $GLOBALS['runpid']);
                } else {
                    socket_write($client, "Scene Number Required");
                }
                socket_close($client);
                break;
            case '-pk':
                if (isset($output[1])) {
                    $status = system('sudo kill ' . $output[1]);
                    socket_write($client, $status);
                    socket_close($client);
                }
                break;
            case '-ps':
                if (isset($GLOBALS['runpid'])) {
                    $status = system('ps aux | grep -i ' . $GLOBALS['runpid'] . ' | grep -v grep');
                    socket_write($client, "PID STATUS " . $GLOBALS['runpid'] . " " . $status . " end");
                } else {
                    socket_write($client, "PID NOT SET");
                }
                socket_close($client);
                break;
            case '-reset':
                //we should try a reset process to get all the relays back to of
                break;
            case 'kill':
                $response = "Killing\n\n";
                socket_write($client, $response);
                socket_close($client);
                socket_close($GLOBALS['sock']);
                exit;
                break;
            case "--help":
            case "-help":
            case "--h":
            case "-h":
                $response = shwhelp();
                socket_write($client, $response, strlen($response));
                socket_close($client);
                break;
            default:
                $response = "default\n\n";
                socket_write($client, $response);
                socket_close($client);
                break;
        }
    }
    // Display output back to client
    //socket_write($client, $response);
    // Close the client (child) socket
    //socket_close($client);
}
Ejemplo n.º 3
0
?>
</h3>
	<p><a href="#">System Requirments</a></p>
	<p><a href="#">Download</a></p>

	<br /><h2></h2><br />
	<p><img src="images/Windows-Shutdown-fast_1.gif" alt="Shutdown fast!" width="200" height="86" class="fltrt" /><h3>Windows Shutdown Fast!</h3></p>
    <p>Version : 1.0.0</p>
    <p>Size : 73 KB</p>
	<h3>Total Downloads : <?php 
echo readini("downloadcount.ini", "downloads", "shutdown_fast");
?>
</h3>
	<p><a href="#">System Requirments</a></p>
	<p><a href="#">Download</a></p>
<br />   
	<br /><h2></h2><br />
    <p><img src="images/iTech-ActiveX-Registerer_1.png" alt="Activex Registerer" width="200" height="86" class="fltrt" /><h3>ActiveX Registerer</h3></p>
    <p>Version : 1.0.0</p>
    <p>Size : 206 KB</p>
	<h3>Total Downloads : <?php 
echo readini("downloadcount.ini", "downloads", "activex_registerer");
?>
</h3>
    <p><a href="#">System Requirments</a></p>
	<p><a href="#">Download</a></p>
</div>
    <?php 
footernavigator();
?>
<!-- InstanceEnd --></html>