* moved account.create and news.archive to twig

* added new configurable date_timezone
This commit is contained in:
slawkens
2017-09-13 14:32:50 +02:00
parent 2c5b3f4da3
commit 3a6aab67d5
7 changed files with 351 additions and 318 deletions

View File

@@ -21,6 +21,7 @@ if($logged)
return;
}
$errors = array();
$step = isset($_POST['step']) ? $_POST['step'] : '';
if($step == 'save')
{
@@ -250,139 +251,6 @@ If you haven\'t registered on ' . $config['lua']['serverName'] . ' please ignore
}
}
?>
<script type="text/javascript">
eventId = 0;
lastSend = 0;
$('#createaccount').submit(function(){
return validate_form(this);
});
function checkAccount()
{
if(eventId != 0)
{
clearInterval(eventId);
eventId = 0;
}
if(document.getElementById("account_input").value == "")
{
document.getElementById("acc_check").innerHTML = '<b><font color="red">Please enter account<?php echo (USE_ACCOUNT_NAME ? ' name' : 'number'); ?>.</font></b>';
return;
}
// anti flood
date = new Date;
timeNow = parseInt(date.getTime());
if(lastSend != 0)
{
if(timeNow - lastSend < 1100)
{
eventId = setInterval('checkAccount()', 1100)
return;
}
}
account = document.getElementById("account_input").value;
$.get("tools/validate.php", { account: account, uid: Math.random() },
function(data){
document.getElementById("acc_check").innerHTML = data;
lastSend = timeNow;
});
}
function checkEmail()
{
if(eventId != 0)
{
clearInterval(eventId)
eventId = 0;
}
if(document.getElementById("email").value == "")
{
document.getElementById("email_check").innerHTML = '<b><font color="red">Please enter e-mail.</font></b>';
return;
}
//anti flood
date = new Date;
timeNow = parseInt(date.getTime());
if(lastSend != 0)
{
if(timeNow - lastSend < 1100)
{
eventId = setInterval('checkEmail()', 1100)
return;
}
}
email = document.getElementById("email").value;
$.get("tools/validate.php", { email: email, uid: Math.random() },
function(data){
document.getElementById("email_check").innerHTML = data;
lastSend = timeNow;
});
}
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null || value=="" || value==" ")
{
alert(alerttxt);
return false;
}
else
return true
}
}
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1 || dotpos-apos<2)
{
alert(alerttxt);
return false;
}
else
return true;
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(account_input,"Please enter name of new account!")==false)
{account_input.focus();return false;}
if (validate_required(email,"Please enter your e-mail!")==false)
{email.focus();return false;}
if (validate_email(email,"Invalid e-mail format!")==false)
{email.focus();return false;}
<?php if(!$config['account_mail_verify']): ?>
if (validate_required(passor,"Please enter password!")==false)
{passor.focus();return false;}
if (validate_required(passor2,"Please repeat password!")==false)
{passor2.focus();return false;}
if (passor2.value!=passor.value)
{alert('Repeated password is not equal to password!');return false;}
<?php endif; ?>
if(accept_rules.checked==false)
{alert('To create account you must accept server rules!');return false;}
}
}
</script>
<?php
$country_recognized = null;
if($config['account_country_recognize']) {
$info = json_decode(@file_get_contents('http://ispinfo.io/' . $_SERVER['REMOTE_ADDR'] . '/geo'), true);
@@ -393,177 +261,24 @@ function validate_form(thisform)
if(!empty($errors))
echo $twig->render('error_box.html.twig', array('errors' => $errors));
?>
To play on <?php echo $config['lua']['serverName']; ?> you need an account.
All you have to do to create your new account is to enter an account <?php echo (USE_ACCOUNT_NAME ? 'name' : 'number'); ?>, password<?php
if($config['recaptcha_enabled']) echo ', confirm reCAPTCHA';
if($config['account_country']) echo ', country';
?> and your email address.
Also you have to agree to the terms presented below. If you have done so, your account <?php echo (USE_ACCOUNT_NAME ? 'name' : 'number'); ?> will be shown on the following page and your account password will be sent to your email address along with further instructions. If you do not receive the email with your password, please check your spam filter.<br/><br/>
<form action="?subtopic=createaccount" method="post" >
<div class="TableContainer" >
<table class="Table1" cellpadding="0" cellspacing="0" >
<div class="CaptionContainer" >
<div class="CaptionInnerContainer" >
<span class="CaptionEdgeLeftTop" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-edge.gif);" /></span>
<span class="CaptionEdgeRightTop" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-edge.gif);" /></span>
<span class="CaptionBorderTop" style="background-image:url(<?php echo $template_path; ?>/images/content/table-headline-border.gif);" ></span>
<span class="CaptionVerticalLeft" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-vertical.gif);" /></span>
<div class="Text" >Create <?php echo $config['lua']['serverName']; ?> Account</div>
<span class="CaptionVerticalRight" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-vertical.gif);" /></span>
<span class="CaptionBorderBottom" style="background-image:url(<?php echo $template_path; ?>/images/content/table-headline-border.gif);" ></span>
<span class="CaptionEdgeLeftBottom" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-edge.gif);" /></span>
<span class="CaptionEdgeRightBottom" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-edge.gif);" /></span>
</div>
</div>
<tr>
<td>
<div class="InnerTableContainer" >
<table style="width:100%;" >
<tr>
<td class="LabelV" >
<span<?php echo (isset($errors['account'][0]) ? ' class="red"' : ''); ?>>Account <?php echo (USE_ACCOUNT_NAME ? 'Name' : 'Number'); ?>:</span>
</td>
<td>
<input type="text" name="account" id="account_input" onkeyup="checkAccount();" size="30" maxlength="<?php echo (USE_ACCOUNT_NAME ? '30' : '10'); ?>" value="<?php echo (isset($_POST['account']) ? $_POST['account'] : ''); ?>" />
<small id="acc_check"></small>
</td>
</tr>
<?php write_if_error('account'); ?>
<tr>
<td class="LabelV" >
<span<?php echo (isset($errors['email'][0]) ? ' class="red"' : ''); ?>>Email Address:</span>
</td>
<td style="width:100%;" >
<input type="text" name="email" id="email" onkeyup="checkEmail();" size="30" maxlength="50" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : ''); ?>" />
<small id="email_check"></small>
</td>
</tr>
<?php write_if_error('email'); ?>
<?php if($config['account_country']): ?>
<tr>
<td class="LabelV" >
<span<?php echo (isset($errors['country'][0]) ? ' class="red"' : ''); ?>>Country:</span>
</td>
<td>
<select name="country" id="account_country">
<?php
foreach(array('pl', 'se', 'br', 'us', 'gb', ) as $c)
echo '<option value="' . $c . '">' . $config['countries'][$c] . '</option>';
echo '<option value="">----------</option>';
foreach($config['countries'] as $code => $c)
echo '<option value="' . $code . '"' . (((isset($country) && $country == $code) || (!isset($country) && $country_recognized == $code)) ? ' selected' : '') . '>' . $c . '</option>';
?>
</select>
<img src="" id="account_country_img"/>
<script>
function updateFlag()
{
var img = $('#account_country_img');
var country = $('#account_country :selected').val();
if(country.length) {
img.attr('src', 'images/flags/' + country + '.gif');
img.show();
}
else {
img.hide();
}
}
if($config['account_country']) {
$countries = array();
foreach (array('pl', 'se', 'br', 'us', 'gb') as $c)
$countries[$c] = $config['countries'][$c];
$countries['--'] = '----------';
foreach ($config['countries'] as $code => $c)
$countries[$code] = $c;
}
$(function() {
updateFlag();
$('#account_country').change(function() {
updateFlag();
});
});
</script>
</td>
</tr>
<?php write_if_error('country'); ?>
<?php endif; ?>
<tr>
<td class="LabelV" >
<span<?php echo (isset($errors['password'][0]) ? ' class="red"' : ''); ?>>Password:</span>
</td>
<td>
<input type="password" name="password" value="" size="30" maxlength="50" />
</td>
</tr>
<?php write_if_error('password'); ?>
<tr>
<td class="LabelV" >
<span<?php echo (isset($errors['password'][0]) ? ' class="red"' : ''); ?>>Repeat password:</span>
</td>
<td>
<input type="password" name="password2" value="" size="30" maxlength="50" />
</td>
</tr>
<?php write_if_error('password');
if($config['recaptcha_enabled']):
?>
<tr>
<td class="LabelV" >
<span<?php echo (isset($errors['verification'][0]) ? ' class="red"' : ''); ?>>Verification:</span>
</td>
<td>
<div class="g-recaptcha" data-sitekey="<?php echo $config['recaptcha_site_key']; ?>" data-theme="<?php echo $config['recaptcha_theme']; ?>"></div>
</td>
</tr>
<?php write_if_error('verification'); ?>
<?php endif; ?>
<tr>
<td><br/></td>
</tr>
<tr>
<td colspan="2" ><b>Please select all of the following check boxes:</b></td>
</tr>
<tr>
<td colspan="2" >
<span><input type="checkbox" id="accept_rules" name="accept_rules" value="true"<?php echo (isset($_POST['accept_rules']) ? ' checked' : ''); ?>/> <label for="accept_rules">I agree to the <a href="?subtopic=rules" target="_blank"><?php echo $config['lua']['serverName']; ?> Rules</a>.</label></span>
</td>
</tr>
<?php if(isset($errors['accept_rules'][0])): ?>
<tr>
<td colspan="2">
<span class="FormFieldError"><?php echo $errors['accept_rules']; ?></span>
</td>
</tr>
<?php endif; ?>
</table>
</div>
</table></div></td></tr><br/>
<table width="100%">
<tr align="center">
<td>
<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td style="border:0px;" >
<input type="hidden" name="step" value="save" >
<div class="BigButton" style="background-image:url(<?php echo $template_path; ?>/images/buttons/sbutton.gif)" >
<div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" >
<div class="BigButtonOver" style="background-image:url(<?php echo $template_path; ?>/images/buttons/sbutton_over.gif);" ></div>
<input class="ButtonText" type="image" name="Submit" alt="Submit" src="<?php echo $template_path; ?>/images/buttons/_sbutton_submit.gif" >
</div>
</div>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
$(function() {
$('#account_input').focus();
});
</script>
<?php
function write_if_error($field)
{
global $errors;
if(isset($errors[$field][0]))
echo '<tr><td></td><td><span class="FormFieldError">' . $errors[$field] . '</span></td></tr>';
}
echo $twig->render('account.create.js.html.twig');
echo $twig->render('account.create.html.twig', array(
'account' => isset($_POST['account']) ? $_POST['account'] : '',
'email' => isset($_POST['email']) ? $_POST['email'] : '',
'countries' => isset($countries) ? $countries : null,
'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] : false,
'country_recognized' => $country_recognized,
'errors' => $errors
));
?>

View File

@@ -78,15 +78,11 @@ if(isset($_GET['archive']))
return;
}
?>
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
<td colspan="3" class="white"><b>News archives</b></td>
</tr>
<?php
$i = 0;
$news_DB = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'news').' WHERE type = 1 AND hidden != 1 ORDER BY date DESC');
$newses = array();
$news_DB = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'news').' WHERE `type` = 1 AND `hidden` != 1 ORDER BY `date` DESC');
foreach($news_DB as $news)
{
$link = internalLayoutLink('news');
@@ -94,13 +90,19 @@ if(isset($_GET['archive']))
$link .= '/archive/' . $news['id'];
else
$link .= 'archive&id=' . $news['id'];
echo '<tr BGCOLOR='. getStyle($i) .'><td width=4%><center><img src="'.$template_path.'/images/news/icon_' . $categories[$news['category']]['icon_id'] . '_small.gif"></center></td><td>'.date("j.n.Y", $news['date']).'</td><td><b><a href="' . $link.'">'.stripslashes($news['title']).'</a></b></td></tr>';
$i++;
$newses[] = array(
'link' => $link,
'icon_id' => $categories[$news['category']]['icon_id'],
'title' => stripslashes($news['title']),
'date' => $news['date']
);
}
echo '</table>';
echo $twig->render('news.archive.html.twig', array(
'newses' => $newses
));
return;
}