php-via-command-linewindows
Gesponsorde koppelingen
PHP script bestanden
het batch bestand:
MySQL tabel
Code (php)
1
2
3
4
5
6
2
3
4
5
6
CREATE TABLE IF NOT EXISTS `tasks` (
`ID` int(10) NOT NULL auto_increment,
`ACTION` varchar(50) NOT NULL,
`EXTRA` varchar(1000) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1485 ;
`ID` int(10) NOT NULL auto_increment,
`ACTION` varchar(50) NOT NULL,
`EXTRA` varchar(1000) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1485 ;
De php code(Commandline):
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
echo "<--Commandline_PHP script-->\n\n";
//de code telt niks op om een oneindige loop te krijgen
//ik wist geen andere manier
$i = 1;
while ($i <= 10) {
mysql_connect("localhost", "{mysql user}", "{mysql pass}",{mysql poort});
mysql_select_db("{cmd_php database}");
$res = mysql_query('SELECT * FROM `tasks` LIMIT 0, 30 ');
while ($arr = mysql_fetch_array($res,MYSQL_BOTH)) {
$ACTION = $arr['ACTION'];
if (!stristr($ACTION,'echo')) echo "<--Taak gevonden(ID: ".$arr['ID']." && ACTION: ".$ACTION.")-->\n";
//verwijder taak uit database
mysql_query('DELETE FROM `tasks` WHERE `tasks`.`ID` = '.$arr['ID'].' LIMIT 1');
if (stristr($ACTION,'quit')) exit;
elseif (stristr($ACTION,'exec')) system($arr['EXTRA']);
elseif (stristr($ACTION,'echo') && !empty($arr['EXTRA']) && $arr['EXTRA'] != "\n") echo $arr['EXTRA']."\n";
else echo " * <--Ombekend commando(".$ACTION.")-->\n";
}
mysql_free_result($res);
//1 seconde pause om alles weer wat rust te geven
sleep(1);
}
?>
echo "<--Commandline_PHP script-->\n\n";
//de code telt niks op om een oneindige loop te krijgen
//ik wist geen andere manier
$i = 1;
while ($i <= 10) {
mysql_connect("localhost", "{mysql user}", "{mysql pass}",{mysql poort});
mysql_select_db("{cmd_php database}");
$res = mysql_query('SELECT * FROM `tasks` LIMIT 0, 30 ');
while ($arr = mysql_fetch_array($res,MYSQL_BOTH)) {
$ACTION = $arr['ACTION'];
if (!stristr($ACTION,'echo')) echo "<--Taak gevonden(ID: ".$arr['ID']." && ACTION: ".$ACTION.")-->\n";
//verwijder taak uit database
mysql_query('DELETE FROM `tasks` WHERE `tasks`.`ID` = '.$arr['ID'].' LIMIT 1');
if (stristr($ACTION,'quit')) exit;
elseif (stristr($ACTION,'exec')) system($arr['EXTRA']);
elseif (stristr($ACTION,'echo') && !empty($arr['EXTRA']) && $arr['EXTRA'] != "\n") echo $arr['EXTRA']."\n";
else echo " * <--Ombekend commando(".$ACTION.")-->\n";
}
mysql_free_result($res);
//1 seconde pause om alles weer wat rust te geven
sleep(1);
}
?>
De PHP code(Website) om iets te echoen op de commandline
Code (php)
1
2
3
4
5
2
3
4
5
<?php
$cmd = 'text om te echoen';
mysql_connect("localhost", "{mysql user}", "{mysql pass}",{mysql poort});
mysql_query('INSERT INTO `cmd_php`.`tasks` (`ID`, `ACTION`, `EXTRA`) VALUES (NULL, \'echo\', \''.$cmd.'\');');
?>
$cmd = 'text om te echoen';
mysql_connect("localhost", "{mysql user}", "{mysql pass}",{mysql poort});
mysql_query('INSERT INTO `cmd_php`.`tasks` (`ID`, `ACTION`, `EXTRA`) VALUES (NULL, \'echo\', \''.$cmd.'\');');
?>