// Connection a la base mysql
$base = mysql_connect (‘gregowarck_db.mysql.db’, ‘gregowarck_db’, ‘kvAKfTPJf4Ka’);
mysql_select_db (‘gregowarck_db.mysql.db’, $base) ;
// Si post on met a jour la table puis envoie sur cible
if ($_POST[‘message’] != NULL)
{
$message = $_POST[‘message’];
//echo ‘Message: ‘.$message.”\n”;
$from = $_POST[‘from’];
$ip = $_SERVER[‘REMOTE_ADDR’];
// ajout du message ds la table wpfabriqueurs_led_matrix_msg
// lancement de la requete d insertion
$sql = ‘INSERT INTO wpfabriqueurs_led_matrix_msg VALUES(“”,”‘.$message.'”, “‘.$from.'”, NOW(),”‘.$ip.'”)’;
mysql_query ($sql) or exit(mysql_error());
// Envoie sur cible
$url = ‘http://82.67.233.171’;
$myvars = ‘L1=’.$message.’&L2=’.$from;
$myvars = str_replace(” “, “+”, $myvars);
$url_get=$url.”?”.$myvars;
//echo $url_get.”\n”;
$ch = curl_init($url_get);
//echo ‘ch :’.$ch.”\n”;
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
//echo ‘rep :’.$response.”\n”;
curl_close($ch);
}
// on chope l ensemble des précédents messages
$sql = ‘SELECT * FROM wpfabriqueurs_led_matrix_msg ORDER BY num DESC’;
mysql_set_charset(‘utf8’);
$res = mysql_query($sql) or exit(mysql_error());
// Affiche message en cours
$row = mysql_fetch_row($res);
echo ‘Message en cours : ‘.$row[1].’‘.”\n”;
echo ‘From: ‘.$row[2].’‘.”\n”.”\n”.”\n”;
?>
// Affiche messages precedents
echo ‘Messages precedents:‘.”\n”;
echo ‘
‘; // affiche champs for ($i = 1; $i < mysql_num_fields($res)-2; $i++) { echo ”;
}//boucle ligne
$f=1;
while ($row = mysql_fetch_row($res))
{
echo ‘
‘; // if ($f == 1) // { // $bal = ”;
// $f = 0;
// }
// else
// {
$bal = ”;
$balend = ”;
// }
//boucle colonne
for ($j = 1; $j < count($row)-2; $j++)
{
echo $bal;
echo ($row[$j] == NULL) ? ‘NULL‘ : $row[$j];
echo $balend;
}
echo ”;
}
echo ‘
‘; echo mysql_field_name($res, $i); echo ‘ |
‘; // $balend = ‘ |
---|
‘;
// on ferme la connexion à la base
mysql_close();
?>