<?php
function sjl_alzwar() {
global $htmlorphp,$sjl_loop,$LANGAUGE;

if ($htmlorphp=="1"){
$y = "add_sjl.html";
}else{
$y = "guestbook.php?action=add_sjl_alzwar";
}

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $sjl_loop;
$startpoint = ($page * $perpage) - $perpage;

$printcats = "<div id='guestbook'><h1><a href='$y'>".$LANGAUGE[124]."</a></h1>";

$sql = @mysql_query("SELECT * FROM sjl_alzwar where active=1 order by id desc limit $startpoint,$perpage");
$nu = mysql_num_rows($sql);
if($nu == 0){
$printcats .= "";
}else{
$printcats .= "<br />";
$ff=0;
while ($Row = @mysql_fetch_array($sql))
{
++$ff;
$text = text(3,$Row['threads']);
$text = Replace($text);
$text = str_replace("[LIST]","<ul>",$text);
$text = str_replace("[/LIST]","</ul>",$text);
$text = str_replace("[LIST1]","<ol>",$text);
$text = str_replace("[/LIST1]","</ol>",$text);
$text = str_replace("[*]","<li>",$text);

$name = text(3,$Row[name]);
$country = text(3,$Row[country]);
$email = text(3,$Row[email]);

$sqq = mysql_query ("SELECT * FROM contries where id='".$Row['countryid']."'");
$con = mysql_fetch_array($sqq);
$con['name_ar'] = text(3,$con['name_ar']);

if($con['name_ar']==""){
$rrrw = $LANGAUGE[246];
}else{
$rrrw = $con['name_ar'];
}

$d = date("j/n/Y",$Row['date']);

if($nu == $ff){
$br = "";
}else{
$br = "<br />";
}

$printcats .= "<div class='ginfo'><a href='mailto:$email'>$name</a> - $rrrw - $d</div>";
$printcats .= "<div class='gcomments'><div class='gpadding'>".$text."</div></div>".$br;
}

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `sjl_alzwar` where active=1")) / $perpage);

if($pagesnum > 1){
$printcats .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='sjlpages-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='guestbook.php?action=home&page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$printcats .= "$z";

}
$printcats .= "</div>";
}

$printcats .= "</div>";
}
return $printcats;
}

function sjl_alzwar_add() {
global $htmlorphp,$folder,$_SESSION,$LANGAUGE;
$text1 = rand(0,9);
$text2 = rand(0,9);
$text3 = "<label for='xzx5'>".$LANGAUGE[176]." ".$text1." + ".$text2."</label>";
$text4 = $text1 + $text2;

$_SESSION["captchacode"] = $text4;

$string = mt_rand();
$string = substr(sha1($string), 0, 6);
$string = str_replace(array('0', 'O', 'o', '9', 'g', 'G'), rand(1, 8), $string);
$datex = time();
$codemembers = $datex.$string;
$codemembers = MD5($codemembers);
$codemembers = substr($codemembers, 0, 15);

$form = '<script type="text/javascript">
// function to verify registration data
function regCheck(submitform) {
var correct = true;
var emailPat =/^(.+)@(.+)$/;
var matchArray = submitform.sender.value.match(emailPat);

var count = 0;

if (submitform.name.value == "") {
        correct = false;
        alert("'.$LANGAUGE[196].'");
        submitform.name.focus();

} else if (matchArray == null) {
        correct = false;
        alert("'.$LANGAUGE[172].'");
        submitform.sender.focus();

} else if (submitform.message.value == "") {
        correct = false;
        alert("'.$LANGAUGE[174].'");
        submitform.message.focus();


} else if (submitform.code.value == "") {
        correct = false;
        alert("'.$LANGAUGE[177].'");
        submitform.code.focus();
}

if (correct) {
        submitform.submit();
}

}
</script>';

if ($htmlorphp=="1"){
$y = "add_sjlok.html";
}else{
$y = "guestbook.php?action=add_sjlalzwar_indatabase";
}

$form .= '<div class="box">
<form name="signup" method="post" action="'.$y.'">
<input type="hidden" name="codenumber" value="'.$codemembers.'" />

<label for="ttt2">'.$LANGAUGE[247].'</label><br />
<input id="ttt2" size="60" name="name" onfocus="this.select()" type="text" /><br /><br />
<label for="ttt1">'.$LANGAUGE[248].'</label><br />
<input id="ttt1" dir="ltr" size="60" name="sender" onfocus="this.select()" type="text" /><br /><br />
<label for="ttt4">'.$LANGAUGE[249].'</label><br />
<select id="ttt4" size="1" name="countryid">';
$sql = mysql_query ("SELECT * FROM  contries order by orders ASC");
while($cat=mysql_fetch_array($sql))
{
$cat['name_ar'] = stripslashes($cat['name_ar']);
$cat['name_ar'] = htmlspecialchars($cat['name_ar']);
$form .= '<option value="'.$cat['id'].'">'.$cat['name_ar'].'</option>';
}
$form .= '</select><br /><br />

<script type="text/javascript">edToolbar(\'mytxtarea\'); </script>
<textarea id="mytxtarea" name="message" rows="15" cols="60"></textarea>

<br /><br />

'.$text3.' <input id="xzx5" name="code" size="10" onfocus="this.select()" /><br /><br />
<input type="button" value=" '.$LANGAUGE[201].' " name="Send" id="Send" onclick="regCheck(signup)" />
</form>
</div>';
return $form;
}
?>