Por ejemplo esta frase:
"que calor hace.....
porque es verano xD"
Pero me lo guarda de esta forma "que calor hace..... porque es verano xD".
*************
Ahora les pasare lo que se necesitó:
-_-_-_-_-_
index.php
process.php
config.php
db_con.php
like.php
like.sql
Bien empecemos:
index.php
Código PHP:
<script language=JavaScript>
<!--
function check_length(form1)
{
maxLen = 500; // numero de caracteres maximo permitidos
if (form1.textarea.value.length >= maxLen) {
// Mensaje de alerta si el límite máximo es alcanzado.
form1.textarea.value = form1.textarea.value.substring(0, maxLen);
}
else{ // La longitud máxima no alcanzó para actualizar el valor de mi contador de texto
form1.text_num.value = maxLen - form1.textarea.value.length;}
}
//-->
</script>
<?
if($_POST['like']){
if(empty($_POST['textarea'])){
die();
}
}
?>
<form id="form1" name="form1" method="post" action="process.php">
<textarea onKeyPress="check_length(this.form); onKeyDown=check_length(this.form);" name="textarea" id="textarea" cols="45" rows="5"></textarea>
<div class="char"> Limite: <input class="lim" size=1 value=500 name=text_num>
</div>
<input type="submit" name="like" id="button" value=" " />
</form>
<div class="hd_bg">
<h1><a href="#">Ultimas frases creadas</a></h1>
</div>
<div class="box_bg">
<div class="box_con">
<?
include('db_con.php');
mysql_connect("$host", "$username", "$password")or die("no se puede conectar a la BD");
mysql_select_db("$db_name")or die("No se puede seleccionar DB");
$top3 = "SELECT * FROM `like` ORDER BY `like`.`id` DESC LIMIT 0 , 9";
$new3 = mysql_query($top3) or die(mysql_error());
while($rows3 = mysql_fetch_array($new3)){
?>
<div style="clear:left;">
<a href="<? echo $site;?>like.php?like=<? echo $rows3['id']; ?>"><? echo stripslashes($rows3['like']);?></a>
</div>
<?
}
?>
process.php
Código PHP:
<?php
ob_start();
include('config.php');
include('db_con.php');
if($_POST['like']){
function hackerDefense(){
// begin hacker defense
foreach ($_POST as $secvalue) {
if ((eregi("<[^>]*script.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*object.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*iframe.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*applet.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*window.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*document.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*cookie.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*meta.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*style.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*alert.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*form.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*php.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*<?.*\"?[^>]*>", $secvalue)) ||
(eregi("<[^>]*img.*\"?[^>]*>", $secvalue))) {
header('location:'.$site.'index.php');
die ();
}
}
// end hacker defense
}
}
if($_POST['like']){
if(empty($_POST['textarea'])){
header('location:'.$site);
die();
}
hackerDefense();
$likes = $_POST['textarea'];
$like = mysql_escape_string($likes);
mysql_connect("$host", "$username", "$password")or die("no se puede conectar a la BD");
mysql_select_db("$db_name")or die("No se puede seleccionar DB");
$today = date("Ymdhis");
$rand = $today.mt_rand().mt_rand().mt_rand();
$count = '0';
$sql = "INSERT INTO `like` (`rand`, `like`, `count`, `created`) VALUES ('$rand', '$like', 0, '$today')";
if (!mysql_query($sql)){
die('Error: ' . mysql_error());
}
$resul = mysql_query("SELECT * FROM `like` WHERE rand = '$rand'") or die (mysql_error());
$r = mysql_fetch_array($resul);
header('location: '.$site.'like.php?like='.$r['id']);
}else{
header('location:'.$site);
}
ob_flush();
?>
like.php
Código PHP:
<? include('db_con.php'); ?>
<?
if($_GET['like']){
$nl = $_GET['like'];
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$re = mysql_query("SELECT * FROM `like` WHERE id = '$nl'") or die (mysql_error());
$s = mysql_fetch_array($re);
$id = $s['id'];
$rock = $s['like'];
$current_time = date("Ymdhis");
$update_view = $s['count'] + 1;
mysql_query("UPDATE `like` SET count = '$update_view', last_view='$current_time' WHERE id = '$id'") or die(mysql_error());
if($rock == ""){
header('location: index.php');
}
}
?>
<meta property="og:title" content="<? echo stripslashes($rock); ?>"/>
<div class="content">
<div class="ad">
<div class="ad_boxr">
</div>
<div class="ad_boxr"></div>
<div class="ad_boxr"></div>
</div>
<div class="like_box">
<div class="t">y</div>
<div class="c">
<p>
<? echo stripslashes($s['like']); ?>
</p>
</div>
</div>
<div class="b"></div>
</div>
<a href="index.php" class="but"><img src="images/create_button.png" alt="CREAR?" border="0" width="636" height="72" /></a>
<div class="bt_box">
</div>
<div class="hd_bg">
<h1><a href="#">Ultimas frases creadas</a></h1>
</div>
<div class="box_bg">
<div class="box_con">
<?
include('db_con.php');
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$top3 = "SELECT * FROM `like` ORDER BY `like`.`id` DESC LIMIT 0 , 9";
$new3 = mysql_query($top3) or die(mysql_error());
while($rows3 = mysql_fetch_array($new3)){
?>
<div style="clear:left;">
<a href="<?echo $site;?>like.php?like=<? echo $rows3['id']; ?>"><? echo stripslashes($rows3['like']);?></a>
</div>
<?
}
?>
</div>
</body>
</html>
ARCHIVOS DE COMUNICACIÓN A LA BASE DE DATOS:
config.php
Código PHP:
<?
$site = 'http://TuSitioWeb' // Escribir la ruta absoluta del directorio.
?>
Código PHP:
<?
$host="localhost"; // Host name
$username="Tu-Usuario-MYSQL"; // Mysql username
$password="Tu-Contrasenia-MYSQL"; // Mysql password
$db_name="Nombre-De-BD"; // Database name
$tbl_name="like"; // Table name
?>
Código:
y con esto ya esta listo (no tiene hoja de estilo xq lo hice asi nomas de mi web (copi y past) CREATE TABLE IF NOT EXISTS `like` ( `id` int(11) NOT NULL auto_increment, `rand` varchar(244) NOT NULL, `like` longtext NOT NULL, `count` int(11) NOT NULL, `created` varchar(255) NOT NULL, `last_view` varchar(255) NOT NULL, `youtube` mediumtext NOT NULL, `type` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Ahora lo que no me hace es el salto de linea; por mas que lo haga manualmente al salto (presionando ENTER) me lo guarda y me lo devuelve todo seguido Como podría yo acomodar eso??? muchísimas gracias foreros.
NOTA: el trabajo terminado esta en esta URL (mia): http://fraselandia.elrincondetuspps.com.ar/
Archivo ZIP de esta presentacion (sin hojas de estilos): http://fraselandia.elrincondetuspps..../frases_FB.zip
MUCHAS GRACIAS NUEVAMENTE!! y felices fiestas y prospero año nuevo para tod@s