Foros del Web » Programando para Internet » Javascript » Frameworks JS »

ayuda con chat

Estas en el tema de ayuda con chat en el foro de Frameworks JS en Foros del Web. hola bueno deseo colaboracion si alguien me puede ayudar se algo de programacion no todo pero bueno el caso es que conseguido unos archivos de ...
  #1 (permalink)  
Antiguo 17/08/2010, 11:28
 
Fecha de Ingreso: agosto-2010
Ubicación: bogota
Mensajes: 6
Antigüedad: 13 años, 8 meses
Puntos: 0
ayuda con chat

hola bueno deseo colaboracion si alguien me puede ayudar se algo de programacion no todo pero bueno el caso es que conseguido unos archivos de un chat el cual es este http://www.iccradio.net/chat/ pero quiero hacerlo para mi pagina propia tengo estos codigos ajaxupload.php,principal.php y ajaxupload.js los cuales pongo a sus disposicion. la funcionalidad de este chat es que permite subir las imagenes de los chateadores y poner su nombre y mensajes pero no e podido lograr que funcione ya que me hace falta un archivo llamado verchat.php el cual es mencionado en el archivo principal.php y pues desearia saber que codigo introducir para crear ese archivo por mi parte llamado verchat.php y ademas dentro del codigo del archivo principal.php hay una linea de codigo que no entiendo la cual es esta ajax.open("GET","verchat.php?"+'nocacheww='+aleato rio,true); esta linea aparece en la funcion cargarcontenido y luego aparece otra linea en la funcion cargar contenido2 la cual es esta
ajax.open("GET", "verchat.php?t1="+t3+';'+t2+': '+t1+'&nocacheww='+aleatorio,true);
ojala me pudieran explicar esto y ayudar para poder crear este chat funcionando muchas gracias gracias

[

este codigo llamado principal.php donde se introduce codigo javascript en donde no entiendo esta linea de codigo
ajax.open("GET", "verchat.php?"+'nocacheww='+aleatorio,true); la cual se repite en las funciones cargar contenido y cargarcontenido2 y bueno el archivo verchat.php no lo pude conseguir alguien me podria explicar que hace esa linea de codigo y en especial donde dice nocacheww= y si alguien sabe que debe contener el codigo verchat.php
  #2 (permalink)  
Antiguo 17/08/2010, 11:31
 
Fecha de Ingreso: agosto-2010
Ubicación: bogota
Mensajes: 6
Antigüedad: 13 años, 8 meses
Puntos: 0
Respuesta: ayuda con chat

principal.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript">

function nuevoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

function cargarContenido(){
var contenedor;
var aleatorio=Math.random();
contenedor = document.getElementById('minichat');
ajax=nuevoAjax();
ajax.open("GET", "verchat.php?"+'nocacheww='+aleatorio,true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText

}
}
ajax.send(null)
contenedor.scrollTop = contenedor.scrollHeight + contenedor.offsetHeight;
}

function cargarContenido2(){
var t1, t2, t3,contenedor;
var aleatorio=Math.random();
contenedor = document.getElementById('minichat');
t1 = document.getElementById('texto1').value;
t2 = document.getElementById('texto12').value;
t3 = document.getElementById('dir_foto').value;
document.getElementById('texto1').value='';
ajax=nuevoAjax();
ajax.open("GET", "verchat.php?t1="+t3+';'+t2+': '+t1+'&nocacheww='+aleatorio,true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
contenedor.scrollTop = contenedor.scrollHeight + contenedor.offsetHeight;
}
}
ajax.send(null)
}



</script>
<script type="text/javascript" src="scripts/ajaxupload.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ddd</title>
<style type="text/css">
<!--
#minichat {
position:absolute;
left:14px;
top:61px;
width:606px;
height:289px;
z-index:1;
overflow: scroll;
}
#Layer1 {
position:absolute;
left:15px;
top:390px;
width:505px;
height:46px;
z-index:2;
}
#upload_area {
position:absolute;
left:533px;
top:365px;
width:77px;
height:58px;
z-index:3;

}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(forma.jpg);
background-repeat: no-repeat;
background-color: #000000;
}
#Layer2 {
position:absolute;
left:275px;
top:334px;
width:124px;
height:73px;
z-index:4;
}
#Layer3 {
position:absolute;
left:14px;
top:333px;
width:315px;
height:58px;
z-index:5;
}
-->
</style>
</head>

<body onload="setInterval('cargarContenido()',1000)">




<div name="minichat" id="minichat"></div>
<div id="Layer1">



<strong>mensaje</strong><br />
<input name="texto1" type="text" id="texto1" onkeyup = "if(event.keyCode == 13) cargarContenido2()" size="75" />
<br />
</p>
</div>
<div id="upload_area" >
<input name="dir_foto" type="hidden" id="dir_foto" />
</div>
<div id="Layer2">


<!------------julio---------------->

<form action="scripts/ajaxupload.php" method="post" name="sleeker" id="sleeker" enctype="multipart/form-data">
<input type="hidden" name="maxSize" value="9999999999" />
<input type="hidden" name="maxW" value="50" />
<input type="hidden" name="fullPath" value="uploads/" />
<input type="hidden" name="relPath" value="../uploads/" />
<input type="hidden" name="colorR" value="255" />
<input type="hidden" name="colorG" value="255" />
<input type="hidden" name="colorB" value="255" />
<input type="hidden" name="maxH" value="50" />
<input type="hidden" name="filename" value="filename" />
<p>Foto<br />
<input type="file" name="filename" onChange="ajaxUpload(this.form,'scripts/ajaxupload.php?filename=name&amp;maxSize=999999999 9&amp;maxW=200&amp;fullPath=uploads/&amp;relPath=../uploads/&amp;colorR=255&amp;colorG=255&amp;colorB=255&amp; maxH=300','upload_area','Wait...&lt;br /&gt;&lt;img src=\'images/loader_light_blue.gif\' width=\'128\' height=\'15\' border=\'0\' /&gt;','&lt;img src=\'images/error.gif\' width=\'16\' height=\'16\' border=\'0\' /&gt; Error in Upload, check settings and path info in source code.'); return false;" /></p>
</form>

<!------------julio---------------->
</div>
<div id="Layer3">
<p> <strong>tu nombre</strong><br />
<input type="text" name="texto12" id="texto12" />
</p></div>
<p>
<label></label>
<label></label>
</p>
</body>
</html>
  #3 (permalink)  
Antiguo 17/08/2010, 11:32
 
Fecha de Ingreso: agosto-2010
Ubicación: bogota
Mensajes: 6
Antigüedad: 13 años, 8 meses
Puntos: 0
Respuesta: ayuda con chat

COLOR="red"]este es ajaxupload.php el que carga las imagenes de los chateadores[/COLOR]




<?php
function uploadImage($fileName, $maxSize, $maxW, $fullPath, $relPath, $colorR, $colorG, $colorB, $maxH = null){
$folder = $relPath;
$maxlimit = $maxSize;
$allowed_ext = "jpg,jpeg,gif,png,bmp";
$match = "";
$filesize = $_FILES[$fileName]['size'];
if($filesize > 0){
$filename = strtolower($_FILES[$fileName]['name']);
$filename = preg_replace('/\s/', '_', $filename);
if($filesize < 1){
$errorList[] = "File size is empty.";
}
if($filesize > $maxlimit){
$errorList[] = "File size is too big.";
}
if(count($errorList)<1){
$file_ext = preg_split("/\./",$filename);
$allowed_ext = preg_split("/\,/",$allowed_ext);
foreach($allowed_ext as $ext){
if($ext==end($file_ext)){
$match = "1"; // File is allowed
$NUM = time();
$front_name = substr($file_ext[0], 0, 15);
$newfilename = $front_name."_".$NUM.".".end($file_ext);
$filetype = end($file_ext);
$save = $folder.$newfilename;
if(!file_exists($save)){
list($width_orig, $height_orig) = getimagesize($_FILES[$fileName]['tmp_name']);
if($maxH == null){
if($width_orig < $maxW){
$fwidth = $width_orig;
}else{
$fwidth = $maxW;
}
$ratio_orig = $width_orig/$height_orig;
$fheight = $fwidth/$ratio_orig;

$blank_height = $fheight;
$top_offset = 0;

}else{
if($width_orig <= $maxW && $height_orig <= $maxH){
$fheight = $height_orig;
$fwidth = $width_orig;
}else{
if($width_orig > $maxW){
$ratio = ($width_orig / $maxW);
$fwidth = $maxW;
$fheight = ($height_orig / $ratio);
if($fheight > $maxH){
$ratio = ($fheight / $maxH);
$fheight = $maxH;
$fwidth = ($fwidth / $ratio);
}
}
if($height_orig > $maxH){
$ratio = ($height_orig / $maxH);
$fheight = $maxH;
$fwidth = ($width_orig / $ratio);
if($fwidth > $maxW){
$ratio = ($fwidth / $maxW);
$fwidth = $maxW;
$fheight = ($fheight / $ratio);
}
}
}
if($fheight == 0 || $fwidth == 0 || $height_orig == 0 || $width_orig == 0){
die("FATAL ERROR REPORT ERROR CODE [add-pic-line-67-orig] to <a href='http://draconiamradio.webhop.net'>AT WEB RESULTS</a>");
}
if($fheight < 45){
$blank_height = 45;
$top_offset = round(($blank_height - $fheight)/2);
}else{
$blank_height = $fheight;
}
}
$image_p = imagecreatetruecolor($fwidth, $blank_height);
$white = imagecolorallocate($image_p, $colorR, $colorG, $colorB);
imagefill($image_p, 0, 0, $white);
switch($filetype){
case "gif":
$image = @imagecreatefromgif($_FILES[$fileName]['tmp_name']);
break;
case "jpg":
$image = @imagecreatefromjpeg($_FILES[$fileName]['tmp_name']);
break;
case "jpeg":
$image = @imagecreatefromjpeg($_FILES[$fileName]['tmp_name']);
break;
case "png":
$image = @imagecreatefrompng($_FILES[$fileName]['tmp_name']);
break;
}
@imagecopyresampled($image_p, $image, 0, $top_offset, 0, 0, $fwidth, $fheight, $width_orig, $height_orig);
switch($filetype){
case "gif":
if(!@imagegif($image_p, $save)){
$errorList[]= "PERMISSION DENIED [GIF]";
}
break;
case "jpg":
if(!@imagejpeg($image_p, $save, 100)){
$errorList[]= "PERMISSION DENIED [JPG]";
}
break;
case "jpeg":
if(!@imagejpeg($image_p, $save, 100)){
$errorList[]= "PERMISSION DENIED [JPEG]";
}
break;
case "png":
if(!@imagepng($image_p, $save, 0)){
$errorList[]= "PERMISSION DENIED [PNG]";
}
break;
}
@imagedestroy($filename);
}else{
$errorList[]= "CANNOT MAKE IMAGE IT ALREADY EXISTS";
}
}
}
}
}else{
$errorList[]= "NO FILE SELECTED";
}
if(!$match){
$errorList[]= "File type isn't allowed: $filename";
}
if(sizeof($errorList) == 0){
return $fullPath.$newfilename;
}else{
$eMessage = array();
for ($x=0; $x<sizeof($errorList); $x++){
$eMessage[] = $errorList[$x];
}
return $eMessage;
}
}

$filename = strip_tags($_REQUEST['filename']);
$maxSize = strip_tags($_REQUEST['maxSize']);
$maxW = strip_tags($_REQUEST['maxW']);
$fullPath = strip_tags($_REQUEST['fullPath']);
$relPath = strip_tags($_REQUEST['relPath']);
$colorR = strip_tags($_REQUEST['colorR']);
$colorG = strip_tags($_REQUEST['colorG']);
$colorB = strip_tags($_REQUEST['colorB']);
$maxH = strip_tags($_REQUEST['maxH']);
$filesize_image = $_FILES[$filename]['size'];
if($filesize_image > 0){
$upload_image = uploadImage($filename, $maxSize, $maxW, $fullPath, $relPath, $colorR, $colorG, $colorB, $maxH);
if(is_array($upload_image)){
foreach($upload_image as $key => $value) {
if($value == "-ERROR-") {
unset($upload_image[$key]);
}
}
$document = array_values($upload_image);
for ($x=0; $x<sizeof($document); $x++){
$errorList[] = $document[$x];
}
$imgUploaded = false;
}else{
$imgUploaded = true;
}
}else{
$imgUploaded = false;
$errorList[] = "File Size Empty";
}
?>
<?php
if($imgUploaded){
echo '<img src="/up2/images/success.gif" width="16" height="16" border="0" style="marin-bottom: -4px;" /><img src="'.$upload_image.'" border="0" />';
}else{
echo '<img src="/up2/images/error.gif" width="16" height="16px" border="0" style="marin-bottom: -3px;" /> Error(s) Found: ';
foreach($errorList as $value){
echo $value.', ';
}
}
?>
  #4 (permalink)  
Antiguo 17/08/2010, 11:32
 
Fecha de Ingreso: agosto-2010
Ubicación: bogota
Mensajes: 6
Antigüedad: 13 años, 8 meses
Puntos: 0
Respuesta: ayuda con chat

este es el codigo
ajaxupload.js





function $m(theVar){

return document.getElementById(theVar)

}

function remove(theVar){

var theParent = theVar.parentNode;

theParent.removeChild(theVar);

}

function addEvent(obj, evType, fn){

if(obj.addEventListener)

obj.addEventListener(evType, fn, true)

if(obj.attachEvent)

obj.attachEvent("on"+evType, fn)

}

function removeEvent(obj, type, fn){

if(obj.detachEvent){

obj.detachEvent('on'+type, fn);

}else{

obj.removeEventListener(type, fn, false);

}

}

function isWebKit(){

return RegExp(" AppleWebKit/").test(navigator.userAgent);

}

function ajaxUpload(form,url_action,id_element,html_show_lo ading,html_error_http){

var detectWebKit = isWebKit();

form = typeof(form)=="string"?$m(form):form;

var erro="";

if(form==null || typeof(form)=="undefined"){

erro += "The form of 1st parameter does not exists.\n";

}else if(form.nodeName.toLowerCase()!="form"){

erro += "The form of 1st parameter its not a form.\n";

}

if($m(id_element)==null){

erro += "The element of 3rd parameter does not exists.\n";

}

if(erro.length>0){

alert("Error in call ajaxUpload:\n" + erro);

return;

}

var iframe = document.createElement("iframe");

iframe.setAttribute("id","ajax-temp");

iframe.setAttribute("name","ajax-temp");

iframe.setAttribute("width","0");

iframe.setAttribute("height","0");

iframe.setAttribute("border","0");

iframe.setAttribute("style","width: 0; height: 0; border: none;");

form.parentNode.appendChild(iframe);

window.frames['ajax-temp'].name="ajax-temp";

var doUpload = function(){

removeEvent($m('ajax-temp'),"load", doUpload);

var cross = "javascript: ";

cross += "window.parent.$m('"+id_element+"').innerHTML = document.body.innerHTML; void(0);";

$m(id_element).innerHTML = html_error_http;

$m('ajax-temp').src = cross;

if(detectWebKit){

remove($m('ajax-temp'));

}else{

setTimeout(function(){ remove($m('ajax-temp'))}, 250);

}

}

addEvent($m('ajax-temp'),"load", doUpload);

form.setAttribute("target","ajax-temp");

form.setAttribute("action",url_action);

form.setAttribute("method","post");

form.setAttribute("enctype","multipart/form-data");

form.setAttribute("encoding","multipart/form-data");

if(html_show_loading.length > 0){

$m(id_element).innerHTML = html_show_loading;

}

form.submit();

}

Etiquetas: ajax, chat
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:22.