Jump to content

Mr_CHISOL

Members
  • Content Count

    404
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Mr_CHISOL

  • Rank
    Member
  • Birthday 02/01/1986

Previous Fields

  • Languages
    CSS, XHTML, PHP, XML

Contact Methods

  • MSN
    mr_chisol@msn.com
  • Website URL
    http://www.kacthus.net
  • ICQ
    0

Profile Information

  • Location
    Sweden
  • Interests
    Computers<br />Programming (C/C++, PHP, Perl)<br />Music<br />Photographing<br />Choir
  1. First, the else-statement and continue is unnecessary (unless you trying to be extremely "clear") as it's nothing after the if anyway.Second, I can't (don't need and don't want to) use DOM to create the select-element, as I need it as an string to be inserted in the content of the dialog. The dialog takes it content as a string with (X)HTML and not DOM, there's three (good?) reasons for that: 1. It's easier to use a string 2. as most of the dialogs content is generated by PHP (and then sent to the browser using XML etc) It would be a pain to use DOM 3. I don't need to, it works great without it :?)Then, the main problem was that I had forgotten something (something that you apparently missed too): get the value from the reg-element. The loops goes thru the cars, but then to be able to show the registrationnumbers I needed to get it from the reg-element for each car (and not directly from the car node/element). On the other hand it still hadn't worked correctly if you didn't point out the problem with node types...So thanks for your help! :?)Here's the code I'm using now. function showRegList( node, persNo ){ var select = '<select name="regNos" id="regNos" style="width: 9em">'; regsNode = new Array(); for (var i=0; i < node.length; i++ ) { if (node[i].nodeType == 1) { select += '<option value="' + i + '">' + node[i].getElementsByTagName( 'reg' )[0].firstChild.nodeValue + '</option>'; regsNode.push( node[i] ); } } select += '</select>'; dialogWContent( 'Kunden med pers.-/org.nummer ' + persNo + ' har flera fordon registrerade i sytemet.' + 'Vänligen välj ett fordon/registreringsnummer i listan nedan, ' + 'för vilken bokningen ska gälla.' '<div style="text-align:center">' + select + '</div>', /** The select box **/ 'Välj registreringsnummer!', function ( ok ) { if (ok) { regPos = document.getElementById( 'regNos' ).value; showCarInfo( regsNode[regPos], true ); } }, 2, 'okcancel' );} and the calling script: if (XmlDoc.documentElement.childNodes.length == 1) { str += showCarInfo( XmlDoc.getElementsByTagName("car")[0] ); } else { str += '<!--CAR_INFO-->'; showRegList( XmlDoc.documentElement.childNodes ); } Oh, one quick question (doesn't matter really as this works): Why can't I use XmlDoc.getElementsByTagName("car") to call showRegList() with??
  2. Yes, the content-type is right.The "catching" code: function getCustCarInfo( id ){ var URL = _DOMAIN_ + _PATH_; //URL = URL + "khtml_test.php"; URL = URL + "?task=getCustCars&cid=" + id + "&ajax=1"; var first = true; if (kAjaxDebug == true) URL = URL + "kdebug=1"; kdebug( 'getCustCarInfo(): URL = ' + URL ); XmlHttp.onreadystatechange = null; XmlHttp.open( "GET", URL, false ); XmlHttp.send( null ); var XmlDoc = XmlHttp.responseXML; if (!XmlDoc) { kdebug( 'getCustCarInfo(): Not xml... <pre>' + XmlHttp.responseText + '</pre>' ); XmlDoc = (new DOMParser()).parseFromString(XmlHttp.responseText, "text/xml"); } var str = '<h4 class="nside">Fordon</h4><table border="0" class="blank">' /*+ '<tr><td>'*/; try { status = XmlDoc.getElementsByTagName("status")[0].childNodes[0].nodeValue; str += '<tr><td><span class="italic">Hittade inget fordon för kunden</span></td></tr></table>'; dialog( 'Hittade inget fordon för kunden!' + 'Vänligen fyll i fordonets registreringsnummer istället eller' + ' lägg till fordonet i systemet innan du skapar en ny bokning.', 'warning', 'Ange personnummer!', null, null, 2 ); return str; } catch (e) {} if (XmlDoc.documentElement.childNodes.length == 1) { str += showCarInfo( XmlDoc.getElementsByTagName("car")[0] ); } else { str += '<!--CAR_INFO-->'; showRegList( XmlDoc.documentElement.childNodes, XmlDoc.documentElement.childNodes.length ); } str += '</table>'; return str;} the php: } else if ($task == 'getCustCars') { $extraXMLInfo = ''; $GLOBALS['stopoutput'] = true; header( 'content-type: text/xml' ); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; echo "<cars>\n"; $w = array(); if (isset($_GET['isPersNo'])) { if (($_SESSION['level'] < 6) && ($_SESSION['groupName'] != 'admin')) $w[] = array( 'cid', intval( $_SESSION['cid'] ) ); $w[] = array( 'persNo', $_GET['cid'] ); $kh->getDB()->select( 'customers', 'id', $w ); $w = array(); if ($info = $kh->getDB()->getInfo()) { $w[] = array( 'owner', intval( $info->id ) ); } } else $w[] = array( 'owner', intval( $_GET['cid'] ) ); $kh->getDB()->select( 'cars', '', $w ); $cars = $kh->getDB()->getData( true ); if (!empty( $cars )) { foreach ($cars as $car) { echo " <car>\n"; echo " <id>" . $car->id . "</id>\n"; echo " <reg>" . $car->reg . "</reg>\n"; echo " <make><![CDATA[" . $car->maker . "]]></make>\n"; echo " <model>" . $car->model . "</model>\n"; echo " <year>" . $car->year . "</year>\n"; echo " <color><![CDATA[" . $car->color . "]]></color>\n"; echo " <ownerid>" . $car->owner . "</ownerid>\n"; echo " <trans><![CDATA[" . $car->trans . "]]></trans>\n"; echo " <fuel><![CDATA[" . $car->fuel . "]]></fuel>\n"; echo " <extra><![CDATA[" . $car->extra . "]]></extra>\n"; echo " </car>\n"; } } else echo " <status>-404</status>\n"; echo "</cars>\n\n"; exit();
  3. The commenting is strange I know, but i use it when I have multiple parts of code that I want to test seperately, works like this (bold is commented)/**/str += '<option value="' + i + '">' + node.nodeValue + '</option>';/*/str += '<option value="' + i + '">' + node.childNodes[0].nodeValue + '</option>';/**/or (note the space in the first "block comment")/** /str += '<option value="' + i + '">' + node.nodeValue + '</option>';/*/str += '<option value="' + i + '">' + node.childNodes[0].nodeValue + '</option>';/**/Which let me alternate between two lines (in this case) with just adding/removing a space (I have no keyboard shortcut for comment). Its a bit uglu I know, but it works great during developing.The function I admitted isn't complete. It actaully look like this (I removed it in my first post as it down't matter): function showRegList( node, length ){ var str = '<select name="regNos" id="regNos">'; for (i=0; i < length; i++ ) { /**/str += '<option value="' + i + '">' + node[i].nodeValue + '</option>';/*/ str += '<option value="' + i + '">' + node[i].childNodes[0].nodeValue + '</option>';/**/ } regsNode = node; str += '</select>'; dialogWContent( 'Kunden med pers.-/org.nummer ' + persNo + ' har flera fordon registrerade i sytemet.' + 'Vänligen välj ett fordon/registreringsnummer i listan nedan, ' + 'för vilken bokningen ska gälla.<br />' + str, 'Välj registreringsnummer!', function ( ok ) { if (ok) { regPos = document.getElementById( 'regNos' ).value; showCarInfo( regsNode[regPos], true ); } }, 2, 'okcancel' );} FYI: The text is in Swedish.dialogWContent() (as dialog()) is my own functions that simply shows a custom dialog using div (I can have 3 on top of each other, each is modal using a semi-ransparent bg that covers everything) (dialog() shows a diaalog with icon or prompt, like "Are you sure?" etc, and dialogWContent() shows a dialog more like a "normal dialog in a app")The function doesn't return cause it's not needed. The function shows a second dialog when the user enters the socialsecurity number of a customer that has more than one car in the first dialog.. (It's all powered with PHP-generated XML and AJAX)None of this inflects on the XML and I still can't get the values from the XML...
  4. I have a problem with XML-DOM and Javascript (!).My PHP-file generates a xml-file like this: <?xml version="1.0" encoding="UTF-8"?><cars> <car> <id>1</id> <reg>ABC123</reg> <make><![CDATA[Volvo]]></make> <model>V70</model> <year>-07</year> <color><![CDATA[rod]]></color> <ownerid>1</ownerid> <trans><![CDATA[Automat]]></trans> <fuel><![CDATA[bensin]]></fuel> <extra><![CDATA[]]></extra> </car> <car> <id>2</id> <reg>CDE345</reg> <make><![CDATA[Mini]]></make> <model>Cooper S</model> <year>-05</year> <color><![CDATA[rod]]></color> <ownerid>1</ownerid> <trans><![CDATA[Automat]]></trans> <fuel><![CDATA[Flexi-fuel]]></fuel> <extra><![CDATA[]]></extra> </car></cars> Than I have this code: if (XmlDoc.documentElement.childNodes.length == 1) { str += showCarInfo( XmlDoc.getElementsByTagName("car")[0] ); } else { str += '<!--CAR_INFO-->'; showRegList( XmlDoc.documentElement.childNodes, XmlDoc.documentElement.childNodes.length ); } and then that code call this function (the else-statement): function showRegList( node, length ){ var str = '<select name="regNos" id="regNos">'; for (i=0; i < length; i++ ) { /**/str += '<option value="' + i + '">' + node[i].nodeValue + '</option>';/*/ str += '<option value="' + i + '">' + node[i].childNodes[0].nodeValue + '</option>';/**/ } regsNode = node; str += '</select>';...] It's a bit "ruff" as it's in development, but neither of the statements in the loop seem to work, what am I doing wrong and what should I do to make it work??All it displays (if not an error) is just empty or null.Thanks for any help :?)
  5. Hi!Here's what troubles my mind atm: I'm working on a webapp. for a client (for booking "sessions" in "Autoshops![?]/mechanichs"), which they then will sell as a service to "autoshops". I'm buidling it in PHP and have written my own framework and db-wrapper. Right now (while developing) I'm using MySQL (as that is what I have installed). But I don't know what db-server/engine I should tell my clients to use when setting up their server.As it's a "comercial services" I guess they would need MySQL enterprise (or can they actually use MySQL Community Edition???) which is about $300/year (which may be a bit steep for them), if they would use MySQL.One option is then the free PostgreSQL.Which one should I recommed? If this only was a question about the cost, PostgreSQL would be the obvious choice, but there's other variables:The posts is going to be small (no large/long texts etc) but they will be many as theyre will be many (hopefully) companies that use this service and each company then have their one info as: customers, cars, sessions and billing info etc. When it comes to the sessions they are split into 15 minutes "parts" (so it would be about 32 [8 * 4] posts per day/company, or 6400 posts in a month if there's 10 companies) so they would be the biggest part in the db.What db-engine/server is best in that aspect (size)?Which one would you recommend: PostgreSQL, MySQL or something else?Is there something I need to think about when converting my wrapper from mysql to PostgreSQL (if so) (except mysql_real_escape_string)???Thanks and GBY..
  6. Mr_CHISOL

    Blocking Opera

    First (as the other said): you can't secure a site by blocking out a certain browser...and opera is one of the better browsers avaliable...Second: there's many differentways the user can change in the source of your sites (well atleast the [generaterd] HTML) as saving the source etc. and there's nothing you can do about it..I would say that, if you are so concerned about that users change the HTML on your site (the changes wont transfer back to the server) you a poorely designed security on your site and you need to go over it and make the right changes (or rewrite it completely) :?) (I agree.., even if I'm blocking older versions of IE in my current project, but that's for compatible reasons and as IE5 etc can be security holes, I don't think it's a good idea for companies to use them...)
  7. Your missing two echo's in your code...it should be: if ($alt) echo "<tr bgcolor=\"#F2F2F2\">";else echo "<tr bgcolor=\"#FFFFFF\">"; not if ($alt)<tr bgcolor=\"#F2F2F2\">";else<tr bgcolor=\"#FFFFFF\">";
  8. Mr_CHISOL

    Regular Expressions

    The thing is that that reg.exp (/[A-Z0-9 _-]{3,12}/i) matches a substring/section of the string and not nessassary the whole string. (/abc/ matches "abc", "aabc", "123abc456" etc.). To make it to only match the whole string you need to add ^ (matches the beginning of the string) and $ (matches the end of the string) (just as you have in the first reg.exp. The regexp would the look like this:/^[A-Z0-9 _-]{3,12}$/iOr in the code: <?php// The "i" after the pattern delimiter indicates a case-insensitive searchif (preg_match("/^([0-9]{1}|[0-9]{2})-[a-z]{3}, [0-9]{2}:[0-9]{2} GMT$/i", "01-Jun, 13:30 GMT")) { if(preg_match("/^[A-Z0-9 _-]{3,12}$/i", "abcdefghijklm")) { echo "A match was found."; }} else { echo "A match was not found.";}?> Good Luck and Don't Panic! ;?)
  9. May I ask why don't you want to use a form??You are still able to submit the form without using a submitbutton (using JavaScript) or visible fields...
  10. That's not completely true. Apparentely you never heard of AJAX!?AJAX Can be used to send (as GET or POST) and recive data without reloading the pageTake a look what you can find using google: http://www.google.se/search?q=AJAX+POST&am...lient=firefox-a
  11. Mr_CHISOL

    Referrer URL

    One other way to do it is to use sessions...
  12. Use isset(): if (isset($_GET['s'])) {...} else if (isset($_GET['letter'])) {...} else {...}
  13. Mr_CHISOL

    PHP Password Check

    You forgot the line...But you have many ("obvious") problems with your code, for example missplaced semi-colons (; ).Here's how it should look: <?php$password = $_POST['password'];$cpassword = 'pass1';if ($password == $cpassword) { print "Correct Password";} else { print "Wrong Password";} Ex: If you have a semi-colon after the if-statement if (...); that means you end the "entite if-statement", so the else-statement is then "unvalid", as it's no "open" if-statement...You also don't need semi-colons after blocks ({ ... };). Semi-colons doesn't stand for end-of-line, it stands for end-of-statement. Consider this: // Calls to some random functionsfoo(); bar(); myFunc(); print('Hello!!'); if ($myVar) print('true'); Even if it's all on one line, it's still valid (it wouldn't be if we removed any semi-colon), but as it's hard to read and can be confusing it's better to write it like this: // Calls to some random functionsfoo();bar();myFunc();print('Hello!!');if ($myVar) print('true'); I would also recommend that you change the field-type to password..EDIT: Sorry, missed the other post..
  14. Mr_CHISOL

    Performance Issue

    Yes, that's why they are faster.. {EDIT: Apparently it isn't a great idea to go away and eat while posting in a forum }You could use SimpleXML or DOM, but (at least with SimpleXML) you get a "ugly output" (no newlines etc), (saw that you could get nicer output with DOM via ::formatOutput).One thing that I would miss with both your method (specially your method...) and DOM is to (easally) add tags within other tags. I'm working on my own framework (basically the same idea as you have, but a little more advanced/more features), among other things, it keeps track of the opened tags (and closes all open tags, in order, before "flush"), it also intends the html-code. (You can download it here: http://kachtus.net/~ch/files/khtml.zip, note that it's not documented and still treated as "beta", it's still "very under development").
  15. ""OFF TOPIC""First: Even if it's not your site, I'll guess that's you that's writing the page (or helping someone do it..), nomather what you should do it in the "correct" or best way (not always the simplest). If you do things right and in a good way (also behave nicely etc..), you get a good reputation (can give you more clients or a job..), if you do things in the "wrong" or in a "bad way", you get a bad reputation (= hard to get customers etc..).Remember that! Always try to do things right etc..Second: (this builds somewhat on the first..) Most IE users aren't stupid (perhaps "ignorant"/"uninformed", but not stupid). Most IE users us IE because IE comes installed by default, and they don't that they can, or how to, install other browsers. Some users use IE because they are forced (by the IT-department on their comapny [there's alot things you can say about IT-departments...]). There's also users who use IE by choice (who are wellinformed etc..), there's things that you can say about them that's perhaps isn't the nicest things you can say about someone, but I'm not gonna say anything of that..So, you shouldn't call IE users stupid, because most of them isn't, they just don't know that there's something better (or can't use it..). I've talked with people that thinks that IE (and the blue E) is the only way to internet (or even that that is internet...), but they aren't stupid, they just haven't the knowledge...Then you could remove the word "users" so it'd say "IE is stupid.", 'cause IE is stupid (the "stupideness" of the IE development team can be discussed... ), It doesn't follow standard etc (the latest, IE 7, is the best of the versions, but not good enough yet. Will it ever be??). IE has given me alot of headakes..I can't get what the IE developers are thinking, there's a standard and I can't why it should be so hard to follow standards (other browsers do it...).
×
×
  • Create New...