Ciao ragazzi, all'interno di una pagina html ho inserito un iframe centrato al centro e con larghezza impostata a 100%. Il contenuto di questo iframe è una pagina php, non capisco come mai è tutto centrato a sinistra, non ne vengo fuori, vi incollo il codice del file php:
codice:
<?php session_start();
//session_destroy();
/*
Author: Boon Xiong
Website: www.dingobats.com
Date: 11-20-2011
Ver: 1.2
*/
echo '
<html>
<title>XMLGuestbook</title>
<style type="text/css">
/*
@font-face {
font-family: "Your typeface";
src: url("type/filename.eot");
}
*/
body{
background-color: #fff;
font-family: Arial;
font-size: 14px;
}
.div{
border: 1px solid #bbb;
background-color: #fff;
padding: 5px;
margin-bottom: 6px;
width: 410px;
}
.paging{
padding: 5px;
}
.link{
color: #333;
}
.loginText{
border: 1px solid #770000;
padding: 5px;
background-color: #fff;
}
</style>
<script type="text/javascript">
function insertAtCaret (textObj, textFeildValue) {
if(document.all){
if (textObj.createTextRange && textObj.caretPos) {
var caretPos = textObj.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == \' \' ?textFeildValue + \' \' : textFeildValue;
}else{
textObj.value = textFeildValue;
}
}else{
if(textObj.setSelectionRange){
var rangeStart = textObj.selectionStart;
var rangeEnd = textObj.selectionEnd;
var tempStr1 = textObj.value.substring(0,rangeStart);
var tempStr2 = textObj.value.substring(rangeEnd);
textObj.value = tempStr1 + textFeildValue + tempStr2;
}else{
alert("This version of Mozilla based browser does not support setSelectionRange");
}
}
return false;
}
</script>
<a href="mailto:animearmoniche@gmail.com">Info</a> | <a href="index.php?sign">Lascia il tuo commento</a><p>
';
class GB{
var $file, $xmlFileData, $xmlData;
// the number of limited words you are willing to accept for their entry.
// remember that it's important to have a limit.
var $wordMAX = 500;
var $user = "user";
var $pass = "pass";
var $allowspam = true;
// the number of enteries you want to show up on a single page
var $numPages = 5;
function GB($data){
$this->file = $data;
$this->xmlFileData = file_get_contents($data);
$this->xmlData = new SimpleXMLElement($this->xmlFileData);
}
function main(){
$allow = $_SESSION['xmlGuestbook_ALLOW'];
// start of smileys
$patterns[0] = '/;\)/';
$patterns[1] = '/:\)/';
$replacements[0] = '<img src="images/wink.png">';
$replacements[1] = '<img src="images/smile.png">';
// end smileys
// ################################################################### //
// ################## DO NOT EDIT BELOW THIS LINE #################### //
// ################################################################### //
if($allow && isset($_POST['delete'])){
$this->delete();
echo "You have successfully delete the selected file(s)";
}
// Loging you out by setting your session to false;
if(isset($_GET['logout'])){ $_SESSION['xmlGuestbook_ALLOW'] = false; $allow = false;}
//checks when you tries to login
if(isset($_GET['admin'])){
if(isset($_POST['username'])){
if($_POST['username'] == $this->user && $_POST['password'] == $this->pass){
$_SESSION['xmlGuestbook_ALLOW'] = true;
$allow = $_SESSION['xmlGuestbook_ALLOW'];
}
}
//if you fail the admin Login, then the form shows again
if(!$allow){
echo '<div class="div" style="background-color: #990000; border: 0px solid #550000">ADMIN LOGIN</br>
<form name="login" method="post" action="#">
<input type="text" name="username" class="loginText"> : username<p>
<input type="text" name="password" class="loginText"> : password<p>
<input type="submit" value="login!" class="loginText"style="background-color: #880000;">
</form>
</div>
';
}
echo "<p>";
}else if(isset($_GET['sign'])){
if(isset($_POST['sign']) && !$_SESSION['xmlGuestbook_check_spam']){
$this->sign();
$_SESSION['xmlGuestbook_check_spam'] = (($this->allowspam) ? false:true);
}else if($_SESSION['xmlGuestbook_check_spam']){
echo "<h2 style=\"text-decoration: underline;\">Grazie per aver lasciato un tuo commento!</h2>";
}else{
echo '<div class="div">Scrivi qui sotto il tuo nome</br>
<form name="sign" method="post" action="#">
<input type="text" name="name" class="div" style="width: 400px;"> <p>
Scrivi qui sotto il tuo commento:<p>
<div style="float: center; padding-right: 11px;">
<textarea cols=50 rows=10 name="comments" class="div" style="width: 400px;"></textarea>
</div>
<div style="float: center;">';
for($i = 0 ; $i < count($patterns); $i++){
}
echo '</div>
<p style="clear: both">
<input type="submit" name="sign" value="INVIA!" class="div" style="background-color: #009966; width: 400px;">
</form><p style="font-size: 12px; color: white;">
NOTA: Puoi lasciare un solo messaggio al giorno. <br/>Il limite del testo è attualmente impostato a <u>'.$this->wordMAX.'</u> caratteri.
</p>
</div>
';
}
}
// shows a link to log you out IF you have logged in
echo (($allow) ? '<a href="?logout" class="link">» Log Out</a><p>':'');
echo "<p>";
// variables
$pages = $this->numPages;
$size = $this->getSize();
$p = $_GET['p'];
// end variables
if($p <=1) {
$p = 1;
}
$start = (($p -1) * $pages);
$inc = 0 ;
if($allow){
echo '<form name="delete" method="post" action="#">';
}
// Main Display of Enteries here
// $inc is a counter for alternating styling. Currently OFF
$inc = 0;
foreach($this->xmlData->message as $data) {
if($inc >= $start && $inc < ($start + $pages)){
$html .= '
<div class="div" '.(($inc % 2 == 0) ? '':'').'> '.(($allow) ? '<input type="checkbox" name="comments[]" value="'.$data->id.'">':'').'
<span style="color: black; font-weight: none">'.$data->Author.' <span style="font-size: 10px; color: #bbb">'.$data->date.'</span><br/>
'.stripslashes(preg_replace('/\n/', "</br>", preg_replace($patterns, $replacements, $data->comments))).'
</div>
';
}
$inc ++;
}
// PAGING
$paging = ($size /$pages);
for($x = 1 ; $x <= ceil($paging); $x++){
$page .='<span class="paging" ';
$link = '<a href="index.php?p='.$x.'" class="link">'.$x.'</a>';
$page .= (($p == $x) ? 'style="font-weight: bold; background-color: #fff; border: 0px solid #fff>'.$link.'':'>'.$link.'').'</span>';
}
// END PAGING
echo '';
echo $page;
echo '<p>';
echo $html;
echo (($allow) ? '<input type="submit" name="delete" value="Delete Selected Comments" class="div"></form></p>':'');
echo '<p>';
echo $page;
echo "<p style=\"clear: both\">Totale Messaggi: <b><i>".$size."</i></b>";
echo "<p>
";
// if the id matches file name
}
// All these methods are REQUIRED! Not not remove
function exist($id){
foreach($_POST['comments'] as $comments){
if($comments == $id){
return true;
}
}
return false;
}
private function getSize(){
$size = 0;
foreach($this->xmlData->message as $none){
$size++;
}
return $size;
}
private function sign(){
$Handle = fopen($this->file, 'w+');
$result = '<data>';
$result .= '
<message>
<Author>'.$_POST['name'].'</Author>
<id>'.$this->getSize().'</id>
<date>'.date("l F d, Y, h:i A").'</date>
<comments>'.substr($_POST['comments'], 0, $this->wordMAX).'</comments>
</message>
';
foreach($this->xmlData->message as $data) {
$result .= '
<message>
<Author>'.$data->Author.'</Author>
<id>'.$data->id.'</id>
<date>'.$data->date.'</date>
<comments>'.$data->comments.'</comments>
</message>
';
}
$result .='</data>';
// writes to the XML
fwrite($Handle, $result);
fclose($Handle);
/*
We have to reset the xml files again becuase we just wrote new enteries to the xml data.
*/
$this->xmlFileData = file_get_contents($this->file);
$this->xmlData = new SimpleXMLElement($this->xmlFileData);
}
private function delete(){
$Handle = fopen($this->file, 'w+');
$result = '<data>';
foreach($this->xmlData->message as $data) {
if(!$this->exist($data->id)){
$result .= '
<message>
<Author>'.$data->Author.'</Author>
<id>'.$data->id.'</id>
<date>'.$data->date.'</date>
<comments>'.$data->comments.'</comments>
</message>
';
}
}
$result .='</data>';
fwrite($Handle, $result);
fclose($Handle);
/*
WE have to reset the xml file becuase we just deleted enteries from the xml data
*/
$this->xmlFileData = file_get_contents($this->file);
$this->xmlData = new SimpleXMLElement($this->xmlFileData);
}
}
// MAIN EXECUTION HERE!
$dis = new GB("data.xml");
// main() will echo out the program so we don't need to echo out the method becuase main() does not return anything.
$dis->main();
?>