MastodonStartpage/web/admin/edinsth.php

99 lines
3 KiB
PHP
Raw Normal View History

2020-03-24 23:22:07 +01:00
<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/myconn.php');
$dbg='';
use function mysqli_real_escape_string as myesc;
// praticamente una macro
function hspech($str) {
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
$dbg.='<pre>'.print_r($_GET,1).'</pre>';
$modes=array('edit','add','remove');
if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^[0-9]+$/',$_GET['i'])===1 && array_key_exists('m',$_GET) && in_array($_GET['m'],$modes)) {
$id=$_GET['i']+0;
$fout='<form action="edinsth.php" method="post" id="f" onsubmit="ckf();">'.N;
switch ($_GET['w']) {
case 'LocalityID':
$res=mysqli_query($link,'SELECT * FROM Localities WHERE ID='.$id)
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($res)==1) {
$row=mysqli_fetch_assoc($res);
$stateid=$row['StateID'];
$locname=$row['Locality'];
$fout.='<div class="hiflab"><label for="StateID">State</label></div>'.N;
$fout.='<select id="StateID" name="StateID" class="hifinp">'.N;
$res=mysqli_query($link,'SELECT * FROM States ORDER BY State ASC')
or muoribene(mysqli_error($link),true);
$stateid=0;
while ($row=mysqli_fetch_assoc($res)) {
($row['ID']!=$stateid) ? $selected='' : $selected=' selected';
$fout.='<option value="'.$row['ID'].'"'.$selected.'>'.hspech($row['State']).'</option>'.N;
}
$fout.='</select>'.N;
$fout.='<div class="hiflab"><label for="Locality:'.$id.'">Locality (local name)</label></div>'.N;
$fout.='<input type="text" class="hifinp" name="Locality:'.$id.'" id="Locality:'.$id.'" maxlength="256" value="'.hspech($locname).'">'.N;
$fout.='<script language="JavaScript">'.N;
$fout.='<!--'.N;
$fout.='document.getElementById(\'Locality:'.$id.'\').focus();'.N;
$fout.='//-->'.N;
$fout.='</script>'.N;
} else {
$fout.='<p>There is no Locality with ID='.$id.'</p>'.N;
}
break;
case 'DispFinModes':
break;
case 'DispPolicies':
break;
case 'DispTags':
break;
default:
muoribene('Malformed input.',true);
break;
}
$fout.='</form>'.N;
} else {
muoribene('Malformed input.',true);
}
mysqli_close($link);
?>
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Little edits helper</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script language="JavaScript" src="js/confirma.js?v=<?php echo($cjrand); ?>"></script>
<script language="JavaScript" src="js/alerta.js?v=<?php echo($cjrand); ?>"></script>
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
<script language="JavaScript">
<!--
//-->
</script>
</head>
<body style="font-size:10pt;background-color:lightgrey;">
<div id="fullscreen">
<div id="middlerow">
<?php echo($fout); ?>
</div>
</div>
<?php echo($dbg); ?>
</body>
</html>