Πως βαζω στο κεντρο ενα εγγραφο php?

Σε αυτή την περιοχή μπορείτε να βρείτε ή να αναζητήσετε πληροφορίες σχετικές με την PHP

Συντονιστές: WebDev Moderators, Super-Moderators, PHP Moderators

Απάντηση

Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 11:37

I don't catch you :P


Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 11:48

Βάλε όλα τα περιεχόμενα μέσα σε ένα div με κλάση container και δώσε του αυτό το css.

.container { width:600px; margin:0px auto; }

Ελπίζω να κατάλαβα καλά.


Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 11:56

Δεν είναι θέμα php. Είναι html και css.

Το αρχείο που έχεις έχει inline css μέσα. Ανοιξε το και βάλε αυτά που σου είπα.

Άβαταρ μέλους
fiskilis
Honorary Member
Δημοσιεύσεις: 14093
Εγγραφή: 16 Νοέμ 2003 22:44
Τοποθεσία: Athens
Επικοινωνία:

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από fiskilis » 12 Νοέμ 2010 11:58

αυτο ειναι το css
πως πρεπει να παει ?
<style type="text/css">
<!--
body {
font-family:Geneva, Arial, Helvetica, sans-serif;
font-size:0.9em;
}
a, a:hover, a:visited {
color:#d20000;
}
form {
padding:15px;
margin:0;
border:1px solid #dddddd;
width:50%;
}
form label {
font-weight:bold;
padding-right:10px;
}
form input {
border:1px solid #dddddd;
border-right:2px solid #cccccc;
border-bottom:2px solid #cccccc;
padding:4px;
}
form input.button {
background-color:#D20000;
font-weight:bold;
font-size:0.8em;
color:#ffffff;
border:1px solid #FF0505;
border-right-color:#9E0000;
border-bottom-color:#9E0000;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
//-->
</style>

Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 12:01

Κώδικας: Επιλογή όλων

<style type="text/css"> 
<!-- 
body &#123; 
font-family&#58;Geneva, Arial, Helvetica, sans-serif; 
font-size&#58;0.9em; 
&#125; 
a, a&#58;hover, a&#58;visited &#123; 
color&#58;#d20000; 
&#125; 
form &#123; 
padding&#58;15px; 
margin&#58;0; 
border&#58;1px solid #dddddd; 
width&#58;50%; 
&#125; 
form label &#123; 
font-weight&#58;bold; 
padding-right&#58;10px; 
&#125; 
form input &#123; 
border&#58;1px solid #dddddd; 
border-right&#58;2px solid #cccccc; 
border-bottom&#58;2px solid #cccccc; 
padding&#58;4px; 
&#125; 
form input.button &#123; 
background-color&#58;#D20000; 
font-weight&#58;bold; 
font-size&#58;0.8em; 
color&#58;#ffffff; 
border&#58;1px solid #FF0505; 
border-right-color&#58;#9E0000; 
border-bottom-color&#58;#9E0000; 
font-family&#58;Verdana, Arial, Helvetica, sans-serif; 

/*To width to kaneis oso thes*/
.container &#123; width&#58;600px; margin&#58;0px auto; &#125; 

&#125; 
//--> 
</style>
Μετά το <body> γράφεις <div class="container"> και πριν το </body> γράφεις </div>


Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 12:12

Δώσε όλον τον κώδικα να το δώ!

Άβαταρ μέλους
fiskilis
Honorary Member
Δημοσιεύσεις: 14093
Εγγραφή: 16 Νοέμ 2003 22:44
Τοποθεσία: Athens
Επικοινωνία:

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από fiskilis » 12 Νοέμ 2010 12:14

Κώδικας: Επιλογή όλων

<?php
ob_start&#40;&#41;;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http&#58;//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Short your long URL </title>
<style type="text/css">
<!--	
	body &#123;
		font-family&#58;Geneva, Arial, Helvetica, sans-serif;
		font-size&#58;0.9em;
	&#125;

	a, a&#58;hover, a&#58;visited &#123;
		color&#58;#d20000;
	&#125;
	form &#123;
		padding&#58;15px;
		margin&#58;0;
		border&#58;1px solid #dddddd;
		width&#58;50%;
	&#125;
	form label &#123;
		font-weight&#58;bold;
		padding-right&#58;10px;
	&#125;
	form input &#123;
		border&#58;1px solid #dddddd;
		border-right&#58;2px solid #cccccc;
		border-bottom&#58;2px solid #cccccc;
		padding&#58;4px;
	&#125;
	form input.button &#123;
		background-color&#58;#D20000;
		font-weight&#58;bold;
		font-size&#58;0.8em;
		color&#58;#ffffff;
		border&#58;1px solid #FF0505;
		border-right-color&#58;#9E0000;
		border-bottom-color&#58;#9E0000;
		font-family&#58;Verdana, Arial, Helvetica, sans-serif;
	&#125;
//-->
</style>
</head>
<body>
<?php
/*
*
*	script by HREF.name Webmaster - www.spyka.net
*	version 1.2
*	copyright &#40;c&#41; 2010 href.name Web Group
*	license http&#58;//creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0
*	support&#58; http&#58;//www.href.name
*
*/

/*
location of file to store URLS
*/
$file = 'urls.txt';

/* 
use mod_rewrite&#58; 0 - no or 1 - yes
*/
$use_rewrite = 1;

/*
language/style/output variables
*/

$l_url			= 'URL';
$l_nourl		= '<strong>No URL supplied</strong>';
$l_yoururl		= '<strong>Your short url&#58;</strong>';
$l_invalidurl	= '<strong>Invalid URL supplied.</strong>';
$l_createurl	= 'Make shorter!';

//////////////////// NO NEED TO EDIT BELOW ////////////////////

if&#40;!is_writable&#40;$file&#41; || !is_readable&#40;$file&#41;&#41;
&#123;
	die&#40;'Cannot write or read from file. Please CHMOD the url file &#40;urls.txt&#41; by default to 777 and make sure it is uploaded.'&#41;;
&#125;

$action = trim&#40;$_GET&#91;'id'&#93;&#41;;
$action = &#40;empty&#40;$action&#41; || $action == ''&#41; ? 'create' &#58; 'redirect';

$valid = "^&#40;https?|ftp&#41;\&#58;\/\/&#40;&#91;a-z0-9+!*&#40;&#41;,;?&=\$_.-&#93;+&#40;\&#58;&#91;a-z0-9+!*&#40;&#41;,;?&=\$_.-&#93;+&#41;?@&#41;?&#91;a-z0-9+\$_-&#93;+&#40;\.&#91;a-z0-9+\$_-&#93;+&#41;*&#40;\&#58;&#91;0-9&#93;&#123;2,5&#125;&#41;?&#40;\/&#40;&#91;a-z0-9+\$_-&#93;\.?&#41;+&#41;*\/?&#40;\?&#91;a-z+&\$_.-&#93;&#91;a-z0-9;&#58;@/&%=+\$_.-&#93;*&#41;?&#40;#&#91;a-z_.-&#93;&#91;a-z0-9+\$_.-&#93;*&#41;?\$";

$output = '';

if&#40;$action == 'create'&#41;
&#123;
	if&#40;isset&#40;$_POST&#91;'create'&#93;&#41;&#41;
	&#123;
		$url = trim&#40;$_POST&#91;'url'&#93;&#41;;
		
		if&#40;$url == ''&#41;
		&#123;
			$output = $l_nourl;
		&#125;
		else
		&#123;
			if&#40;eregi&#40;$valid, $url&#41;&#41;
			&#123;
				$fp = fopen&#40;$file, 'a'&#41;;
				fwrite&#40;$fp, "&#123;$url&#125;\r\n"&#41;;
				fclose&#40;$fp&#41;;
				
				$id			= count&#40;file&#40;$file&#41;&#41;;
				$dir		= dirname&#40;$_SERVER&#91;'PHP_SELF'&#93;&#41;;
				$filename	= explode&#40;'/', $_SERVER&#91;'PHP_SELF'&#93;&#41;;
				$filename   = $filename&#91;&#40;count&#40;$filename&#41; - 1&#41;&#93;;
				
				$shorturl = &#40;$use_rewrite == 1&#41; ? "http&#58;//&#123;$_SERVER&#91;'HTTP_HOST'&#93;&#125;&#123;$dir&#125;/&#123;$id&#125;" &#58; "http&#58;//&#123;$_SERVER&#91;'HTTP_HOST'&#93;&#125;&#123;$dir&#125;/&#123;$filename&#125;?id=&#123;$id&#125;";
				
				$output = "&#123;$l_yoururl&#125; <a href='&#123;$shorturl&#125;'>&#123;$shorturl&#125;</a>";
			&#125;
			else
			&#123;
				$output = $l_invalidurl;
			&#125;
		&#125;
	&#125;
&#125;

if&#40;$action == 'redirect'&#41;
&#123;
	$urls = file&#40;$file&#41;;
	$id   = trim&#40;$_GET&#91;'id'&#93;&#41; - 1;
	if&#40;isset&#40;$urls&#91;$id&#93;&#41;&#41;
	&#123;
		header&#40;"Location&#58; &#123;$urls&#91;$id&#93;&#125;"&#41;;
		exit;
	&#125;
	else
	&#123;
		die&#40;'Script error'&#41;;
	&#125;
&#125;

//////////////////// FEEL FREE TO EDIT BELOW ////////////////////
?>


<!-- start html output -->
<form action="<?=$_SERVER&#91;'PHP_SELF'&#93;?>" method="post">
<p class="response"><?=$output?></p>
<p>
	<label for="s-url">URL&#58;</label>
	<input id="s-url" type="text" name="url" />
</p>
<p>
	<input type="submit" class="button" name="create" value="<?=$l_createurl?>" />
</p>
</form>
<p>hosted by <a href="http&#58;//tophosting.pro">Top-Hosting</a></p>
<!-- Histats.com  START  &#40;standard&#41;--> 
<script type="text/javascript">document.write&#40;unescape&#40;"%3Cscript src=%27http&#58;//s10.histats.com/js15.js%27 type=%27text/javascript%27%3E%3C/script%3E"&#41;&#41;;</script> 
<a href="http&#58;//www.histats.com" target="_blank" title="site stats" ><script  type="text/javascript" > 
try &#123;Histats.start&#40;1,1301575,4,0,0,0,"00000000"&#41;;
Histats.track_hits&#40;&#41;;&#125; catch&#40;err&#41;&#123;&#125;;
</script></a> 
<noscript><a href="http&#58;//www.histats.com" target="_blank"><img  src="http&#58;//sstatic1.histats.com/0.gif?1301575&101" alt="site stats" border="0"></a></noscript> 
<!-- Histats.com  END  --> 
<!-- Begin @ ads.freestuff.gr Δωρεάν Διαφήμιση Code --> 
<IFRAME SRC="http&#58;//ads.freestuff.gr/a/view.pl?iframe;member=oiogr" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO WIDTH=468 HEIGHT=60><SCRIPT LANGUAGE="JavaScript" SRC="http&#58;//ads.freestuff.gr/a/view.pl?jscript;member=oiogr"></SCRIPT><NOSCRIPT><A HREF="http&#58;//ads.freestuff.gr/a/view.pl?member=oiogr;banner=NonSSI;page=01" TARGET="_blank"><IMG SRC="http&#58;//ads.freestuff.gr/a/view.pl?member=oiogr;page=01" WIDTH=468 HEIGHT=60 ALT="@ ads.freestuff.gr Δωρεάν Διαφήμιση" BORDER=0></A></NOSCRIPT></IFRAME><BR><A HREF="http&#58;//ads.freestuff.gr/a/i/oiogr/" TARGET="_blank"><IMG SRC="http&#58;//ads.freestuff.gr/b.gif" WIDTH=468 HEIGHT=16 ALT="@ ads.freestuff.gr Δωρεάν Διαφήμιση" ISMAP BORDER=0></A>
<!-- End @ ads.freestuff.gr Δωρεάν Διαφήμιση Code -->
<!-- end html output -->
</body>
</html>
<?php
ob_end_flush&#40;&#41;;
?>

Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 12:17

Κώδικας: Επιλογή όλων

<?php 
ob_start&#40;&#41;; 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http&#58;//www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Short your long URL </title> 
<style type="text/css"> 
<!--    
   body &#123; 
      font-family&#58;Geneva, Arial, Helvetica, sans-serif; 
      font-size&#58;0.9em; 
   &#125; 

   a, a&#58;hover, a&#58;visited &#123; 
      color&#58;#d20000; 
   &#125; 
   form &#123; 
      padding&#58;15px; 
      margin&#58;0; 
      border&#58;1px solid #dddddd; 
      width&#58;50%; 
   &#125; 
   form label &#123; 
      font-weight&#58;bold; 
      padding-right&#58;10px; 
   &#125; 
   form input &#123; 
      border&#58;1px solid #dddddd; 
      border-right&#58;2px solid #cccccc; 
      border-bottom&#58;2px solid #cccccc; 
      padding&#58;4px; 
   &#125; 
   form input.button &#123; 
      background-color&#58;#D20000; 
      font-weight&#58;bold; 
      font-size&#58;0.8em; 
      color&#58;#ffffff; 
      border&#58;1px solid #FF0505; 
      border-right-color&#58;#9E0000; 
      border-bottom-color&#58;#9E0000; 
      font-family&#58;Verdana, Arial, Helvetica, sans-serif; 
   &#125; 

.container &#123; width&#58;600px; margin&#58;0px auto; &#125;
//--> 
</style> 
</head> 
<body> 
<div class="container">
<?php 
/* 
* 
*   script by HREF.name Webmaster - www.spyka.net 
*   version 1.2 
*   copyright &#40;c&#41; 2010 href.name Web Group 
*   license http&#58;//creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 
*   support&#58; http&#58;//www.href.name 
* 
*/ 

/* 
location of file to store URLS 
*/ 
$file = 'urls.txt'; 

/* 
use mod_rewrite&#58; 0 - no or 1 - yes 
*/ 
$use_rewrite = 1; 

/* 
language/style/output variables 
*/ 

$l_url         = 'URL'; 
$l_nourl      = '<strong>No URL supplied</strong>'; 
$l_yoururl      = '<strong>Your short url&#58;</strong>'; 
$l_invalidurl   = '<strong>Invalid URL supplied.</strong>'; 
$l_createurl   = 'Make shorter!'; 

//////////////////// NO NEED TO EDIT BELOW //////////////////// 

if&#40;!is_writable&#40;$file&#41; || !is_readable&#40;$file&#41;&#41; 
&#123; 
   die&#40;'Cannot write or read from file. Please CHMOD the url file &#40;urls.txt&#41; by default to 777 and make sure it is uploaded.'&#41;; 
&#125; 

$action = trim&#40;$_GET&#91;'id'&#93;&#41;; 
$action = &#40;empty&#40;$action&#41; || $action == ''&#41; ? 'create' &#58; 'redirect'; 

$valid = "^&#40;https?|ftp&#41;\&#58;\/\/&#40;&#91;a-z0-9+!*&#40;&#41;,;?&=\$_.-&#93;+&#40;\&#58;&#91;a-z0-9+!*&#40;&#41;,;?&=\$_.-&#93;+&#41;?@&#41;?&#91;a-z0-9+\$_-&#93;+&#40;\.&#91;a-z0-9+\$_-&#93;+&#41;*&#40;\&#58;&#91;0-9&#93;&#123;2,5&#125;&#41;?&#40;\/&#40;&#91;a-z0-9+\$_-&#93;\.?&#41;+&#41;*\/?&#40;\?&#91;a-z+&\$_.-&#93;&#91;a-z0-9;&#58;@/&%=+\$_.-&#93;*&#41;?&#40;#&#91;a-z_.-&#93;&#91;a-z0-9+\$_.-&#93;*&#41;?\$"; 

$output = ''; 

if&#40;$action == 'create'&#41; 
&#123; 
   if&#40;isset&#40;$_POST&#91;'create'&#93;&#41;&#41; 
   &#123; 
      $url = trim&#40;$_POST&#91;'url'&#93;&#41;; 
       
      if&#40;$url == ''&#41; 
      &#123; 
         $output = $l_nourl; 
      &#125; 
      else 
      &#123; 
         if&#40;eregi&#40;$valid, $url&#41;&#41; 
         &#123; 
            $fp = fopen&#40;$file, 'a'&#41;; 
            fwrite&#40;$fp, "&#123;$url&#125;\r\n"&#41;; 
            fclose&#40;$fp&#41;; 
             
            $id         = count&#40;file&#40;$file&#41;&#41;; 
            $dir      = dirname&#40;$_SERVER&#91;'PHP_SELF'&#93;&#41;; 
            $filename   = explode&#40;'/', $_SERVER&#91;'PHP_SELF'&#93;&#41;; 
            $filename   = $filename&#91;&#40;count&#40;$filename&#41; - 1&#41;&#93;; 
             
            $shorturl = &#40;$use_rewrite == 1&#41; ? "http&#58;//&#123;$_SERVER&#91;'HTTP_HOST'&#93;&#125;&#123;$dir&#125;/&#123;$id&#125;" &#58; "http&#58;//&#123;$_SERVER&#91;'HTTP_HOST'&#93;&#125;&#123;$dir&#125;/&#123;$filename&#125;?id=&#123;$id&#125;"; 
             
            $output = "&#123;$l_yoururl&#125; <a href='&#123;$shorturl&#125;'>&#123;$shorturl&#125;</a>"; 
         &#125; 
         else 
         &#123; 
            $output = $l_invalidurl; 
         &#125; 
      &#125; 
   &#125; 
&#125; 

if&#40;$action == 'redirect'&#41; 
&#123; 
   $urls = file&#40;$file&#41;; 
   $id   = trim&#40;$_GET&#91;'id'&#93;&#41; - 1; 
   if&#40;isset&#40;$urls&#91;$id&#93;&#41;&#41; 
   &#123; 
      header&#40;"Location&#58; &#123;$urls&#91;$id&#93;&#125;"&#41;; 
      exit; 
   &#125; 
   else 
   &#123; 
      die&#40;'Script error'&#41;; 
   &#125; 
&#125; 

//////////////////// FEEL FREE TO EDIT BELOW //////////////////// 
?> 


<!-- start html output --> 
<form action="<?=$_SERVER&#91;'PHP_SELF'&#93;?>" method="post"> 
<p class="response"><?=$output?></p> 
<p> 
   <label for="s-url">URL&#58;</label> 
   <input id="s-url" type="text" name="url" /> 
</p> 
<p> 
   <input type="submit" class="button" name="create" value="<?=$l_createurl?>" /> 
</p> 
</form> 
<p>hosted by <a href="http&#58;//tophosting.pro">Top-Hosting</a></p> 
<!-- Histats.com  START  &#40;standard&#41;--> 
<script type="text/javascript">document.write&#40;unescape&#40;"%3Cscript src=%27http&#58;//s10.histats.com/js15.js%27 type=%27text/javascript%27%3E%3C/script%3E"&#41;&#41;;</script> 
<a href="http&#58;//www.histats.com" target="_blank" title="site stats" ><script  type="text/javascript" > 
try &#123;Histats.start&#40;1,1301575,4,0,0,0,"00000000"&#41;; 
Histats.track_hits&#40;&#41;;&#125; catch&#40;err&#41;&#123;&#125;; 
</script></a> 
<noscript><a href="http&#58;//www.histats.com" target="_blank"><img  src="http&#58;//sstatic1.histats.com/0.gif?1301575&101" alt="site stats" border="0"></a></noscript> 
<!-- Histats.com  END  --> 
<!-- Begin @ ads.freestuff.gr Δωρεάν Διαφήμιση Code --> 
<IFRAME SRC="http&#58;//ads.freestuff.gr/a/view.pl?iframe;member=oiogr" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO WIDTH=468 HEIGHT=60><SCRIPT LANGUAGE="JavaScript" SRC="http&#58;//ads.freestuff.gr/a/view.pl?jscript;member=oiogr"></SCRIPT><NOSCRIPT><A HREF="http&#58;//ads.freestuff.gr/a/view.pl?member=oiogr;banner=NonSSI;page=01" TARGET="_blank"><IMG SRC="http&#58;//ads.freestuff.gr/a/view.pl?member=oiogr;page=01" WIDTH=468 HEIGHT=60 ALT="@ ads.freestuff.gr Δωρεάν Διαφήμιση" BORDER=0></A></NOSCRIPT></IFRAME><BR><A HREF="http&#58;//ads.freestuff.gr/a/i/oiogr/" TARGET="_blank"><IMG SRC="http&#58;//ads.freestuff.gr/b.gif" WIDTH=468 HEIGHT=16 ALT="@ ads.freestuff.gr Δωρεάν Διαφήμιση" ISMAP BORDER=0></A> 
<!-- End @ ads.freestuff.gr Δωρεάν Διαφήμιση Code --> 
<!-- end html output --> 
</div>
</body> 
</html> 
<?php 
ob_end_flush&#40;&#41;; 
?>
Δεν μπορώ να το τεστάρω τώρα, αλλά λογικά θα παίζει.


Άβαταρ μέλους
Khronos
Δημοσιεύσεις: 754
Εγγραφή: 11 Δεκ 2006 14:43
Τοποθεσία: Ηράκλειο

Πως βαζω στο κεντρο ενα εγγραφο php?

Δημοσίευση από Khronos » 12 Νοέμ 2010 12:24

Κώδικας: Επιλογή όλων

<?php 
ob_start&#40;&#41;; 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http&#58;//www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Short your long URL </title> 
<style type="text/css"> 
<!--    
   body &#123; 
      font-family&#58;Geneva, Arial, Helvetica, sans-serif; 
      font-size&#58;0.9em; 
   &#125; 

   a, a&#58;hover, a&#58;visited &#123; 
      color&#58;#d20000; 
   &#125; 
   form &#123; 
      padding&#58;15px; 
      margin&#58;0; 
      border&#58;1px solid #dddddd; 
      width&#58;50%; 
   &#125; 
   form label &#123; 
      font-weight&#58;bold; 
      padding-right&#58;10px; 
   &#125; 
   form input &#123; 
      border&#58;1px solid #dddddd; 
      border-right&#58;2px solid #cccccc; 
      border-bottom&#58;2px solid #cccccc; 
      padding&#58;4px; 
   &#125; 
   form input.button &#123; 
      background-color&#58;#D20000; 
      font-weight&#58;bold; 
      font-size&#58;0.8em; 
      color&#58;#ffffff; 
      border&#58;1px solid #FF0505; 
      border-right-color&#58;#9E0000; 
      border-bottom-color&#58;#9E0000; 
      font-family&#58;Verdana, Arial, Helvetica, sans-serif; 
   &#125; 

//--> 
</style> 
</head> 
<body> 
<div style="width&#58;500px; margin&#58;0px auto;"> 
<?php 
/* 
* 
*   script by HREF.name Webmaster - www.spyka.net 
*   version 1.2 
*   copyright &#40;c&#41; 2010 href.name Web Group 
*   license http&#58;//creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 
*   support&#58; http&#58;//www.href.name 
* 
*/ 

/* 
location of file to store URLS 
*/ 
$file = 'urls.txt'; 

/* 
use mod_rewrite&#58; 0 - no or 1 - yes 
*/ 
$use_rewrite = 1; 

/* 
language/style/output variables 
*/ 

$l_url         = 'URL'; 
$l_nourl      = '<strong>No URL supplied</strong>'; 
$l_yoururl      = '<strong>Your short url&#58;</strong>'; 
$l_invalidurl   = '<strong>Invalid URL supplied.</strong>'; 
$l_createurl   = 'Make shorter!'; 

//////////////////// NO NEED TO EDIT BELOW //////////////////// 

if&#40;!is_writable&#40;$file&#41; || !is_readable&#40;$file&#41;&#41; 
&#123; 
   die&#40;'Cannot write or read from file. Please CHMOD the url file &#40;urls.txt&#41; by default to 777 and make sure it is uploaded.'&#41;; 
&#125; 

$action = trim&#40;$_GET&#91;'id'&#93;&#41;; 
$action = &#40;empty&#40;$action&#41; || $action == ''&#41; ? 'create' &#58; 'redirect'; 

$valid = "^&#40;https?|ftp&#41;\&#58;\/\/&#40;&#91;a-z0-9+!*&#40;&#41;,;?&=\$_.-&#93;+&#40;\&#58;&#91;a-z0-9+!*&#40;&#41;,;?&=\$_.-&#93;+&#41;?@&#41;?&#91;a-z0-9+\$_-&#93;+&#40;\.&#91;a-z0-9+\$_-&#93;+&#41;*&#40;\&#58;&#91;0-9&#93;&#123;2,5&#125;&#41;?&#40;\/&#40;&#91;a-z0-9+\$_-&#93;\.?&#41;+&#41;*\/?&#40;\?&#91;a-z+&\$_.-&#93;&#91;a-z0-9;&#58;@/&%=+\$_.-&#93;*&#41;?&#40;#&#91;a-z_.-&#93;&#91;a-z0-9+\$_.-&#93;*&#41;?\$"; 

$output = ''; 

if&#40;$action == 'create'&#41; 
&#123; 
   if&#40;isset&#40;$_POST&#91;'create'&#93;&#41;&#41; 
   &#123; 
      $url = trim&#40;$_POST&#91;'url'&#93;&#41;; 
        
      if&#40;$url == ''&#41; 
      &#123; 
         $output = $l_nourl; 
      &#125; 
      else 
      &#123; 
         if&#40;eregi&#40;$valid, $url&#41;&#41; 
         &#123; 
            $fp = fopen&#40;$file, 'a'&#41;; 
            fwrite&#40;$fp, "&#123;$url&#125;\r\n"&#41;; 
            fclose&#40;$fp&#41;; 
              
            $id         = count&#40;file&#40;$file&#41;&#41;; 
            $dir      = dirname&#40;$_SERVER&#91;'PHP_SELF'&#93;&#41;; 
            $filename   = explode&#40;'/', $_SERVER&#91;'PHP_SELF'&#93;&#41;; 
            $filename   = $filename&#91;&#40;count&#40;$filename&#41; - 1&#41;&#93;; 
              
            $shorturl = &#40;$use_rewrite == 1&#41; ? "http&#58;//&#123;$_SERVER&#91;'HTTP_HOST'&#93;&#125;&#123;$dir&#125;/&#123;$id&#125;" &#58; "http&#58;//&#123;$_SERVER&#91;'HTTP_HOST'&#93;&#125;&#123;$dir&#125;/&#123;$filename&#125;?id=&#123;$id&#125;"; 
              
            $output = "&#123;$l_yoururl&#125; <a href='&#123;$shorturl&#125;'>&#123;$shorturl&#125;</a>"; 
         &#125; 
         else 
         &#123; 
            $output = $l_invalidurl; 
         &#125; 
      &#125; 
   &#125; 
&#125; 

if&#40;$action == 'redirect'&#41; 
&#123; 
   $urls = file&#40;$file&#41;; 
   $id   = trim&#40;$_GET&#91;'id'&#93;&#41; - 1; 
   if&#40;isset&#40;$urls&#91;$id&#93;&#41;&#41; 
   &#123; 
      header&#40;"Location&#58; &#123;$urls&#91;$id&#93;&#125;"&#41;; 
      exit; 
   &#125; 
   else 
   &#123; 
      die&#40;'Script error'&#41;; 
   &#125; 
&#125; 

//////////////////// FEEL FREE TO EDIT BELOW //////////////////// 
?> 


<!-- start html output --> 
<form action="<?=$_SERVER&#91;'PHP_SELF'&#93;?>" method="post"> 
<p class="response"><?=$output?></p> 
<p> 
   <label for="s-url">URL&#58;</label> 
   <input id="s-url" type="text" name="url" /> 
</p> 
<p> 
   <input type="submit" class="button" name="create" value="<?=$l_createurl?>" /> 
</p> 
</form> 
<p>hosted by <a href="http&#58;//tophosting.pro">Top-Hosting</a></p> 
<!-- Histats.com  START  &#40;standard&#41;--> 
<script type="text/javascript">document.write&#40;unescape&#40;"%3Cscript src=%27http&#58;//s10.histats.com/js15.js%27 type=%27text/javascript%27%3E%3C/script%3E"&#41;&#41;;</script> 
<a href="http&#58;//www.histats.com" target="_blank" title="site stats" ><script  type="text/javascript" > 
try &#123;Histats.start&#40;1,1301575,4,0,0,0,"00000000"&#41;; 
Histats.track_hits&#40;&#41;;&#125; catch&#40;err&#41;&#123;&#125;; 
</script></a> 
<noscript><a href="http&#58;//www.histats.com" target="_blank"><img  src="http&#58;//sstatic1.histats.com/0.gif?1301575&101" alt="site stats" border="0"></a></noscript> 
<!-- Histats.com  END  --> 
<!-- Begin @ ads.freestuff.gr Δωρεάν Διαφήμιση Code --> 
<IFRAME SRC="http&#58;//ads.freestuff.gr/a/view.pl?iframe;member=oiogr" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=NO WIDTH=468 HEIGHT=60><SCRIPT LANGUAGE="JavaScript" SRC="http&#58;//ads.freestuff.gr/a/view.pl?jscript;member=oiogr"></SCRIPT><NOSCRIPT><A HREF="http&#58;//ads.freestuff.gr/a/view.pl?member=oiogr;banner=NonSSI;page=01" TARGET="_blank"><IMG SRC="http&#58;//ads.freestuff.gr/a/view.pl?member=oiogr;page=01" WIDTH=468 HEIGHT=60 ALT="@ ads.freestuff.gr Δωρεάν Διαφήμιση" BORDER=0></A></NOSCRIPT></IFRAME><BR><A HREF="http&#58;//ads.freestuff.gr/a/i/oiogr/" TARGET="_blank"><IMG SRC="http&#58;//ads.freestuff.gr/b.gif" WIDTH=468 HEIGHT=16 ALT="@ ads.freestuff.gr Δωρεάν Διαφήμιση" ISMAP BORDER=0></A> 
<!-- End @ ads.freestuff.gr Δωρεάν Διαφήμιση Code --> 
<!-- end html output --> 
</div> 
</body> 
</html> 
<?php 
ob_end_flush&#40;&#41;; 
?> 
Ετσι?


Απάντηση

Επιστροφή στο “PHP Προγραμματισμός”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 1 επισκέπτης