Jump to content

rain13

Members
  • Posts

    346
  • Joined

  • Last visited

Posts posted by rain13

  1. Because it's general code that gets unread PM count. It's actually in main.html file into which text editor is read. I wrote html parser that allows you to replace placeholders with other file so I have main file that defines general look of page and then I load text editor into it from it's own file so I wont have to store same code in every file. Checking constantly would make that unread count change even when you do nothing.

  2. Hello.I use window.setInterval to constantly call function that updates info from server using XMLHttpRequest. The strange problem with that is that it causes textarea to miss some characters as you type. however if I replace code that gets new info from server with code that just returns 0, then it works nicely.What's more interesting is that only firefox seems to have this problem.Here you can try to type something (use firefox):

    <link removed to minimize traffic from searchengines>

  3.  

    Do you have an example of your problem online?

    bit.ly/162iqPPI put that link here as plain text because I don't want search engines to index it yet.when you log in with test//test and testuser//testuser or create new accounts) then under messages (top right) you can compose new message to given user. Lets say you send PM from testuser to test. In this case in test's window this messages link turns into bold and displays number of unread messages.On IE it would show you error message instead. Other than that it works.Here's copy of code above that requests that info.

    function loadXMLDoc(){	var xmlhttp;	if (window.XMLHttpRequest)	{// code for IE7+, Firefox, Chrome, Opera, Safari		xmlhttp=new XMLHttpRequest();	}	else	{// code for IE6, IE5		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");	}	xmlhttp.onreadystatechange=function()	{		if (xmlhttp.readyState==4 && xmlhttp.status==200)		{			ResponseText = xmlhttp.responseText.replace(//g,"");;		}	}	xmlhttp.open("GET","./lib/ucp.php?&a=RECV&mode=getcount",false);	xmlhttp.send();}
  4. I had some difficulties with that I used firebug to grab id of div and then searched whole project with netbeans, but it did not find that particular id..

     

     

    Edit:

    title was phpMyAdminlibrariesheader_scripts.inc.php line 60 (look for parent.document.title)

    navigation bar was phpMyAdminlibrariesheader.inc.php line 114 (look forhtmlspecialchars($server_info))

    mysql info was phpMyAdminmain.php on line 161

     

    just in case anyone interested

  5. Hello.

     

     

    I tried to POST

    '"

    On my localhost $_POST['test'] shows '" unescaped string exactly as it is

    On other host that had some old PHP and possibly different configuration as well $_POST['test'] shows '" which as you can see is escaped.Does anyone know what php setting specify wether to escape POST (and possibly GET too?) by default or not? Or what other characters get escaped?I did not call any functions by myself. It's escaped by host PHP itself.

     

     

    My software is coded to work with unescaped $_POST and escaping chars by PHP itself causes it display garbage string in posts since.Is there way to disable this auto escaping by server? Or is there way to detect if it's on? Because if I write function that would unescape whole POST array then on servers that doesn't escape POST data by default it would cause data loss.

  6. Hello.It may be funny to read, but I want to host my site on my university's account, but they have old mysql client there (4.0.x). I tried to use some free mysql hosts and PHP said meClient does not support authentication protocol requested by server; consider upgrading MySQL client.So I was wondering if anyone know any free mysql hosts that would either allow this old authentication protocol or that hosts older DB.

  7. The problem is that if I use IE then on php side $_COOKIE is just a empty array. If I use Firefox then $_COOKIE contains actual cookie data. So when I manually hit f5 in IE cookie gets sent to server but when that JS queries info then no cookie gets sent to server. So that cookie exists somewhere in IE but it only gets sent when I load page and NOT when javascript loads it.

  8. Hello.

     

    I am constantly checking unread private message count with JS using loadXMLDoc(). With firefox it successfully returns me number of unread PMs. But on IE it says "Welcome, guest Login or Register" instead of message count which means that since JS is not sending cookie, it gets logged in as guest. Could anyone be so nice ant tell me what I need to change in this code to make it send cookie in IE too in addition to other browsers?Edit: or shall I just pass cookie content as get parameter on IE?

    var ResponseText = '';function loadXMLDoc(){	var xmlhttp;	if (window.XMLHttpRequest)	{// code for IE7+, Firefox, Chrome, Opera, Safari		xmlhttp=new XMLHttpRequest();	}	else	{// code for IE6, IE5		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");	}	xmlhttp.onreadystatechange=function()	{		if (xmlhttp.readyState==4 && xmlhttp.status==200)		{			ResponseText = xmlhttp.responseText.replace(//g,"");;		}	}	xmlhttp.open("GET","./lib/ucp.php?&a=RECV&mode=getcount",false);	xmlhttp.send();}function GetChatCount(){	loadXMLDoc();	if(ResponseText == "0"){		document.getElementById("pm_link").innerHTML="<a href="./lib/ucp.php?a=RECV"><img src='./theme/default/images/pm.png' height='26' width='26'>Messages</a>";	}else{		document.getElementById("pm_link").innerHTML="<b><a href="./lib/ucp.php?a=RECV"><img src='./theme/default/images/pm.png' height='26' width='26'>Messages ("+ResponseText+" new)</a></b>";	}}window.setInterval(GetChatCount, 3000);
  9. Hello.

     

     

    Could anyone tell me how I coud use MAX(...) with insert into?

    DECLARE max_id INTEGER;SET max_id = (SELECT MAX( MsgID ) FROM privmsg);INSERT INTO `g`.`privmsg` (ID, MsgID, Data) VALUES (NULL, max_id , 'data');

    says#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE max_id INTEGER' at line 1 I have also tried

    INSERT INTO `g`.`privmsg` (ID, MsgID, Data) VALUES (NULL,SELECT 1 + coalesce((SELECT max(MsgID) FROM privmsg), 0) , 'data');

    which is based on this example: http://stackoverflow.com/questions/1587562/problem-with-mysql-insert-max1#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1 + coalesce((SELECT max(MsgID) FROM privmsg), 0) , 'data')' at line 1Of course I could write PHP gode that first gets MAX and then uses that value, but I think it would run faster if it were in single query.

  10. Thanks for hint. Meanwhile I managed to do it with UNION ALL. Is would LEFT JOIN be any better?Here's my solution incase anyone happens to find this post via search engine or I happen to loose it.

    SELECT warn.*, "" AS PostTitle FROM warn WHERE warn.UserID=37 AND (NOT EXISTS (SELECT 1 FROM post WHERE post.UserID=warn.UserID AND post.ID = warn.PostID))UNION ALLSELECT warn.*, post.PostTitle FROM warn,post WHERE warn.UserID=37 AND  post.UserID=warn.UserID AND post.ID = warn.PostID
  11. Hello

     

     

    I want to select warn.*, post.PostTitle. The problems is that some rows in warn does not have matching post. In that case I would like to select '' as PostTitle. So I tried a little if statement, but It gives error. Could anyone show me how to correctly write query that selects warn.*, post.PostTitle and that would select constant empty string as PostTitle if there is no post that matches given criteria?

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF (EXISTS(SELECT 1 FROM post WHERE post.UserID=37)) THEN SELECT warn.*, p' at line 1
    IF (EXISTS(SELECT 1 FROM post WHERE post.UserID=37)) THEN    SELECT warn.*, post.PostTitle FROM warn,post WHERE warn.UserID=37 AND  post.UserID=warn.UserIDELSE    SELECT warn.*, "" FROM warn WHERE warn.UserID=37END IF

    Here are some cases where post does not exist:1) Administrator or moderator have deleted post after issuing warning for it.2) warning was issued for something else than specific post.In these cases I would like to select '' as PostTitle.

  12. I was just trying to make generic highlighter that would work for any language. That's why i only have strings and keywords. Now that same code wold work with C/C++, PHP, JS, basic, lua and so on. all those languages have keywords such as for, while, do, if and so on. And string highlighting that supports line break and escaping would also work on languages that doesn't allow these.But anyway, thanks for taking time to read my posts and give hints about regex :)

  13. What makes you think that pattern is a workaround for a negative lookbehind?

    I got it from some site that explained it for JS. So that's best I could come up with... I am not the expert of regex.So instead I invented this:

    function Highlight(){		var keywords = "if|then|else|end|endif|function|string|short|unsigned|int|double|float|char|include|for|while|goto|const|void|return"	var codes = document.getElementsByClassName('code');	for (var i = 0; i < codes.length; ++i) {		var item = codes[i];		//alert(decodeHTMLEntities(item.innerHTML));		var decoded = decodeHTMLEntities(item.innerHTML);		//item.innerHTML =  decoded.replace(new RegExp('"([^"])*?(?!"$)"', ''), "<span class="string">$&</span>");		var tokens = decoded.split(/(?=["'])/g);		//alert(tokens.length);		var quote ="";		for (var j = 0; j < tokens.length; ++j) {			if(tokens[j].charAt(0)=='"' || tokens[j].charAt(0)=='''){				if(j > 0 && tokens[j-1].charAt(tokens[j-1].length-1) != "")				{					if(quote == ""){//not in quote yet						quote = tokens[j].charAt(0);						tokens[j] = "<span class="string">"+tokens[j];					}else{//in quote						if(tokens[j].charAt(0) == quote){//found quote == quote we are curently in?							quote = '';							tokens[j] = tokens[j].insert(1, "</span>");						}					}				}			}						if(quote==""){				unquoted_tokens = tokens[j].split(/(?=[*()[]{} ])/g);				for (var k = 0; k < unquoted_tokens.length; ++k) {					unquoted_tokens[k] = unquoted_tokens[k].replace(new RegExp(keywords, 'g'), "<span class="keyword">$&</span>");				}				tokens[j] = unquoted_tokens.join("");			}					}		item.innerHTML =  tokens.join("");	}}

    Just wondering what's your opinion of it. How is it's speed compared to regex?

     

     

    Here's the result.

    int compare (const void * a, const void * B){a = "I am string fortest if escaping "can 'break' it..";b = 'I am string fortest if escaping 'can "break" it..';return ( *(int*)a - *(int*)b );}

×
×
  • Create New...