ANNEXES
a. Le Script PHP pour l'envoi du SMS
<?php
######################################################## # Login
information for the SMS Gateway
########################################################
$ozeki_user = "admin";
$ozeki_password = "bonjours"; $ozeki_url ="/api?";
######################################################## #
Functions used to send the SMS message
########################################################
function httpRequest($url){
$pattern = "/http...([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
preg_match($pattern,$url,$args);
$in = "";
$fp = fsockopen("$args[1]", $args[2], $errno, $errstr, 30);
if (!$fp) {
return("$errstr ($errno)");
} else {
$out = "GET /$args[3] HTTP/1.1\r\n";
$out .= "Host: $args[1]:$args[2]\r\n";
$out .= "User-agent: Ozeki PHP client\r\n";
$out .= "Accept: */*\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out); while (!feof($fp)) { $in.=fgets($fp, 128);
}
}
fclose($fp);
return($in);
}
function ozekiSend($phone, $msg, $debug=false){ global
$ozeki_user,$ozeki_password,$ozeki_url;
$url = 'username='.$ozeki_user;
$url.= '&password='.$ozeki_password; $url.=
'&action=sendmessage';
$url.= '&messagetype=SMS:TEXT'; $url.=
'&recipient='.urlencode($phone); $url.=
'&messagedata='.urlencode($msg);
$urltouse = $ozeki_url.$url;
if ($debug) { echo "Request:
<br>$urltouse<br><br>"; }
//Open the URL to send the message $response =
httpRequest($urltouse); if ($debug) {
echo "Response: <br><pre>".
I S T A 2 0 1 4 - 2 0 1 5 Page | - 108 -
str_replace(array("<",">"),array("<",">"),$response).
"</pre><br>"; }
return($response);
}
######################################################## # GET
data from sendsms.html
########################################################
$phonenum = $_POST['recipient']; $message = $_POST['message'];
$debug = true;
ozekiSend($phonenum,$message,$debug); ?>
b. Script html d'envoi
<html>
<body>
<h1>My SMS form</h1>
<form method=post
action='sendsms.php'>
<table border=0>
<tr>
<td>Recipient</td>
<td><input type='text'
name='recipient'></td>
</tr>
<tr>
<td>Message</td>
<td><textarea rows=4 cols=40
name='message'></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=submit
value=Send></td>
</tr>
</table>
</form>
</body>
</html>
c. Script pour le moteur de recherche des
resultats
<?php
if(isset($_POST['submit'])){
$anscol=mysql_real_escape_string(htmlspecialchars($_POST['anscol']));
$codclasse=mysql_real_escape_string(htmlspecialchars($_POST['codclasse']));
$matrie=mysql_real_escape_string(htmlspecialchars($_POST['matrie']));
if(empty($anscol) or empty($codclasse) or empty($matrie)){
echo "<div id='error'>Veuillez remplir tous les champs
s.v.p!</div>";
}else{
$req=mysql_query("SELECT COUNT(T1.matrie)
FROM v_cotes_cours_classe as T1,etudiant_en_ordre as T2
WHERE anscol='$anscol' AND T2.matrie='$matrie' AND
codclasse='$codclasse'
and Statut='PAYE'");
$result=mysql_result($req,0);
if($result==0){
I S T A 2 0 1 4 - 2 0 1 5 Page | - 109 -
echo "<div id='error'>Vous n'etes pas en ordre avec la
section!</div>";
}else{
$sql=mysql_query("SELECT matrie
FROM v_cotes_cours_classe
WHERE anscol='$anscol' AND matrie='$matrie' AND
codclasse='$codclasse'");
$donnees=mysql_fetch_array($sql); $matrie=$donnees['matrie'];
header("location:tout/gescotes/index.php?page=bulletin&matrie=$matrie&codclasse
=$codclasse");
}
}
}
?>
<form id="form" method="post" action="">
<fieldset>
<table>
<tr>
<td><label>Année
Académique</label></td>
<td>:
<select name="anscol">
<option selected></option>
<option>2013-2014</option>
<option>2014-2015</option>
</select>
</td>
</tr>
<tr>
<td><label>Classe</label></td>
<td>:
<select name="codclasse">
<option selected></option>
<?php
$req=mysql_query("SELECT*FROM classe order by codclasse ASC");
while($data=mysql_fetch_array($req)){
?>
}
<option><?php echo $data['codclasse'];
?></option> <?php
?>
</select>
</td>
</tr>
<tr>
<td><label>N°
Matricule</label></td>
<td>: <input type="text" name="matrie"
class="mat"></td>
</tr>
<tr>
<td colspan="2"><input type="submit"
name="submit" value="Search" id="submit"></td>
<!--a href="#" name="submit" id="submit"
onClick="document.getElementById('form_2').submit()"><span><span>Search</span></spa
n></a-->
</tr>
</table>
</fieldset>
</form>
I S T A 2 0 1 4 - 2 0 1 5 Page | - 110 -
|