Jump to content

Yuval200

Members
  • Posts

    79
  • Joined

  • Last visited

Everything posted by Yuval200

  1. I really liked http://www.colourlovers.com.. I also really liked the programming of the site.
  2. Oh, sorry, thanks again :)I'm doing fine now XML wise, I only have a small OOP issue. I have read about the __destruct function. As I understood, the function works when the parser finish parsing the code and there is no more HTML to be wrote. Code-wise it works great. class xml { public $file, $error, $xmlfile = array(); function __construct($xmlFile) { $this->error = "<b>Class " . __CLASS__ . ":</b>"; if (!is_array($xmlFile)) die($this->error." \$xmlFile must be entered as an array."); $this->file = array(); foreach($xmlFile as $number => $xml) { $xml = "data/{$xml}"; $this->xmlfile[] = $xml; if (!file_exists($xml)) die($this->error." file {$xml} (<em>number {$number}</em>) doesn't exist."); $this->file[] = new SimpleXMLElement($xml, null, true); //Loads the xml files, one at a time. } return $this->file; } function updateXML(&$xmlPath, $xmlValue, $attributeName = false) { if (!$attributeName) return $xmlPath[0] = $xmlValue; return $xmlPath[$attributeName] = $xmlValue; } function __destruct() { foreach($this->xmlfile as $number => $xml) { if(!$this->file[$number]->asXML($xml)) die($this->error." Could not update file {$xml} (number {$number})."); $this->file[$number]->asXML($xml); die("INDEED"); } }} (just refer to the __destruct function, it's the only thing changed). The interesting part is that when I change the function name to something like __fhfdsdsbfdsa and then call it using $classxml->__dfkmdmbldflbndfalbd() it works great. Why? Should I not use __destruct for this case?Thanks
  3. So I need to save all I did when I finish working with the XML document? How do I do this?
  4. Heh, that was a stupid mistake.. THANKS ALOT :)Now, I have a weird error.. This is the function: function updateXML(&$xmlPath, $xmlValue, $attributeName = false) { if (!$attributeName) return $xmlPath[0] = $xmlValue; return $xmlPath[$attributeName] = $xmlValue; } And the code: $classxml->updateXML($xml[0]->post[0]->poster, "66", "id");$classxml->updateXML($xml[0]->post[0]->content, "d");echo $xml[0]->post[0]->poster['id'] . "\n" . $xml[0]->post[0]->content; With the code above it changes the content, but the thing I noticed is when I delete the first line, the value of "id" returns to 1337, and when removing the second line, content value returns to be "Post Content". Why?
  5. Thanks ALOT man ! I added [0] after $xmlPath and it works great now .Now I have a problem with attributes, I updated my XML document: <?xml version="1.0" encoding="utf-8"?><posts> <post> <poster id="1337">Yuval</poster> <content>Post content</content> </post></posts> I am trying to echo the following line: echo $xml[0]->post[0]->content['id']; Doesn't work, I have tried var_dump: var_dump($xml[0]->post[0]->content['id']);var_dump((string) $xml[0]->post[0]->content['id']); First line returns null, and the second line returns a string with the length of 0. I have tried to chage content['id'] to content[0]['id'] But it still doesn't work.. Can you please help me?Thanks
  6. updateXML: function updateXML(&$xmlPath, $xmlValue, $attributeName = false) { if (!$attributeName) { echo "XMLPath:\n"; var_dump($xmlPath); echo "\nXMLValue:\n"; var_dump($xmlValue); echo "\nAttrName:\n"; var_dump($attributeName); echo "!\n"; return $xmlPath = $xmlValue; } elseif (trim($attributeName)) { //$this } } It returns the following:
  7. Yuval200

    xml and php

    After reading the XML tutorial, I recommend you use the SimpleXMLElement class
  8. Thanks , but it still doesn't work.. the function looks like this now: function updateXML(&$xmlPath, $xmlValue, $attributeName = false) { if (!$attributeName) return $xmlPath = $xmlValue; elseif (trim($attributeName)) { //$this } }
  9. Sorry, I solved that issue some time ago, now I have a new one with functions; To change the value of a tag, I need to do the following: class xml { public $file; protected $error; function __construct($xmlFile) { $this->error = "<b>Class " . __CLASS__ . ":</b>"; if (!is_array($xmlFile)) die($this->error." \$xmlFile must be entered as an array."); $this->file = array(); foreach($xmlFile as $number => $xml) { $xml = "data/{$xml}"; if (!file_exists($xml)) die($this->error." file {$xml} (<em>number {$number}</em>) doesn't exist."); $this->file[] = new SimpleXMLElement($xml, null, true); //Loads the xml files, one at a time. } } function updateXML($xmlPath, $xmlValue, $attributeName = false) { if (!$attributeName) return $xmlPath = $xmlValue; elseif (!trim($isElement) && trim($attributeName)) { //$this } }}$classxml = new xml(array('posts.xml'));$xml = $classxml->file; Now, I am using the following function: $classxml->updateXML($xml[0]->post[0]->content, "d"); But it doesn't work, Why ?Thanks in advance :}
  10. Lol, you haven't hurt anything .Now, if someone could just answer my question
  11. Yeah, I remember using this way some time ago, forgot about it.. Haha, I'm not that of a beginner, Printing an array in a foreach loop isn't to difficult for me .--Another issue, how do I update existing tags? I have tried the following: echo $xml[0]->post[0]->content;$xml[0]->post[0]->content = "NOT Post content"; But it doesn't seem to work..Thanks
  12. Hello guys .Well, I have the following issue; I am using the following XML document: <?xml version="1.0" encoding="utf-8"?><posts> <post> <poster>Yuval</poster> <content>Post content</content> </post></posts> Now, I use the SimpleXMLElement class, and it really all works fine, I just don't understand something.When I use the following code: echo $xml[0]->children()->children(); It works two, and it writes "Yuval". My question: how can I access the second element (content)? I have tried several ways but nothing seems to work.Thanks
  13. PLEASE, can anyone give me an example with the whole thing? PLEASE
  14. Thanks, thing is.. $regex_output will be something like this:$regex_output = preg_replace("blabla", "blabla", $_POST['bla']) AND THAT IS WHAT I AM ASKING!How can I tell PHP that I want to explode the sub-string INSIDE the box. Please, can anyone help me.
  15. Thanks.. I know regex stuff, but again, can I please have an example on how to perform this?
  16. Can I please have an example about it? I know how to do it with the whole string, but not with a specified part of it, as I said..
  17. Hello again guys :)I have a question, lets say I have a code box, like the in IPB, how do I put numbers for each line, like:[code]1. <?php2. echo "Hello world";3. ?> I know I can use the explode, and then, the all-magical foreach. Thing is, I am looking for a solution to apply only to a PART of a string (like, the lines will apply to code boxes only, and not to the whole post). I've writen this post here because I think that the line numbering is some-what PHP related.Yuval
  18. Yuval200

    WHY ME

    Well, I wrote in my code (before any outpost was made): function replace($buffer) { $buffer = str_replace('&', '&', $buffer); return $buffer; } ob_start(replace); and in the end of my code: ob_end_flush(); Now, two things:o The crappy function didn't replaced all those (&) in my text.o When replacing the & with it's entity, the urls are fine, but the a tags underline is scretched all over the line/td.Is it possible to fix this?Thanks
  19. Yuval200

    WHY ME

    http://www.php.net/manual/en/function.ob-start.phpDo you think example 1 will do the job?
  20. Yuval200

    WHY ME

    Doing the search&replace thing via a program is problematic, because I'll have to redo it everytime the link is added, and since the posts are dynamic, it isn't that good.Aspnetguy, I know about the str_replace and the preg_replace functions, but how can I apply those to the whole document?
  21. Yuval200

    WHY ME

    Is there a way to change those & without doing it by hand (who knows how much of those I will need to replace)? I'm not talking about JS regex, because that will dinamicly change the page, but the source will stay the same.. Is there a good solution?
  22. Yuval200

    WHY ME

    :)I have a PHP system thingy, and I'm building the CP of it, now, this is the page HTML outpost: <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css.css" /> <script type="text/javascript" src="scripts.js"></script> <script type="text/javascript" src="cpscripts.js"></script> <style type="text/css"> #container_content {overflow: auto} </style> <!--[if IE]><style type="text/css">textarea {scrollbar-3dlight-color: white; scrollbar-arrow-color: black; scrollbar-darkshadow-color: white; scrollbar-face-color: white; scrollbar-highlight-color: white; scrollbar-shadow-color: white; scrollbar-track-color: white}</style><![endif]--> <link rel="shortcut icon" href="favicon.png" /> <title>YuvPost! מערכת תגובות</title> </head> <body onkeyup="keylogoff(event)"> <div id="container"> <div id="container_nav">בחר פעולה: <ul> <li id="container_nav_home"><a href="main.php?page=admincp&action=main" class="plain">הדף הראשי של הפאנל</a>.</li> <li><a href="main.php?page=admincp&action=cpmassage" class="plain">כתוב הודעת מנהל</a>.</li> <li><a href="main.php?page=admincp&action=posts" class="plain">נהל הודעות</a>.</li> </ul> <a href="java script:void(0)" class="plain" id="logoff" onclick="confirmsg(1, 'main.php?page=admincp&action=logoff')">התנתק מפאנל הניהול</a>. </div> <div id="container_content"> <p>נהל את הודעות המערכת. ביכולתך לבחור בין שתי פעולות - מחיקה, ועריכה. כל ההודעות הקיימות מסודרות עפ"י המספר המזהה שלהן (post_id).</p> <p>במידה והודעות מסויימות נצמאות בדף ההודעות (outpost.php) אך לא כאן. רענן את הדף על ידי לחיצה על Ctrl + R או על ידי לחיצה על הקישור <a href="java script:void(0)" onclick="location.reload()" class="script">הזה</a>.</p> <table id="aposts_table"> <tr id="apost_data"> <th>מספר</th> <th>שם</th> <th>IP</th> <th>תאריך</th> <th>תוכן</th> <th>פעולות</th> </tr> <tr valign="top" class="post"> <td class="post_id">#1</td> <td class="post_by">יובל200</td> <td class="post_ip"><span class="showtitle" title="כתובת IP לא זמינה">null</span></td> <td class="post_date"><span class="showtitle" title="תאריך מלא: 15/11/2006 17:42">15/11/2006</span></td> <td class="post_content">ריקון מקולל.תאריך ה�... <a href="java script: void(0)" onclick="open_popup('main.php?page=showpost&postid=1', 600, 250)" class="script" title="קרא את כל ההודעה">></a></td> <td class="post_action"> <img src="post_edit.png" alt="ערוך" title="ערוך הודעה" onmouseover="this.style.cursor = 'pointer'" /> <img src="post_delete.png" alt="מחק" title="מחק הודעה" onclick="confirmsg(2, 'main.php?page=admincp&action=delete&postnum=1')" onmouseover="this.style.cursor = 'pointer'" /> </td> </tr> <tr valign="top" class="post"> <td class="post_id">#2</td> <td class="post_by">יובל200</td> <td class="post_ip"><span class="showtitle" title="כתובת IP לא זמינה">null</span></td> <td class="post_date"><span class="showtitle" title="תאריך מלא: 15/11/2006 17:43">15/11/2006</span></td> <td class="post_content">נסיון נוסף.<?php die(); ?&... <a href="java script: void(0)" onclick="open_popup('main.php?page=showpost&postid=2', 600, 250)" class="script" title="קרא את כל ההודעה">></a></td> <td class="post_action"> <img src="post_edit.png" alt="ערוך" title="ערוך הודעה" onmouseover="this.style.cursor = 'pointer'" /> <img src="post_delete.png" alt="מחק" title="מחק הודעה" onclick="confirmsg(2, 'main.php?page=admincp&action=delete&postnum=2')" onmouseover="this.style.cursor = 'pointer'" /> </td> </tr> <tr valign="top" class="post"> <td class="post_id">#3</td> <td class="post_by">יובל200</td> <td class="post_ip"><span class="showtitle" title="כתובת IP לא זמינה">null</span></td> <td class="post_date"><span class="showtitle" title="תאריך מלא: 15/11/2006 18:10">15/11/2006</span></td> <td class="post_content">בובה, עכשיו יש גם אייקונים!... <a href="java script: void(0)" onclick="open_popup('main.php?page=showpost&postid=3', 600, 250)" class="script" title="קרא את כל ההודעה">></a></td> <td class="post_action"> <img src="post_edit.png" alt="ערוך" title="ערוך הודעה" onmouseover="this.style.cursor = 'pointer'" /> <img src="post_delete.png" alt="מחק" title="מחק הודעה" onclick="confirmsg(2, 'main.php?page=admincp&action=delete&postnum=3')" onmouseover="this.style.cursor = 'pointer'" /> </td> </tr> <tr valign="top" class="post"> <td class="post_id">#4</td> <td class="post_by">יובל200</td> <td class="post_ip"><span class="showtitle" title="כתובת IP לא זמינה">null</span></td> <td class="post_date"><span class="showtitle" title="תאריך מלא: 15/11/2006 18:18">15/11/2006</span></td> <td class="post_content">English Test! Ahoy thar! HARHRHR.TEST... <a href="java script: void(0)" onclick="open_popup('main.php?page=showpost&postid=4', 600, 250)" class="script" title="קרא את כל ההודעה">></a></td> <td class="post_action"> <img src="post_edit.png" alt="ערוך" title="ערוך הודעה" onmouseover="this.style.cursor = 'pointer'" /> <img src="post_delete.png" alt="מחק" title="מחק הודעה" onclick="confirmsg(2, 'main.php?page=admincp&action=delete&postnum=4')" onmouseover="this.style.cursor = 'pointer'" /> </td> </tr> <tr valign="top" class="post"> <td class="post_id">#5</td> <td class="post_by">יובל200</td> <td class="post_ip"><span class="showtitle" title="כתובת IP מלאה: 127.0.0.1">127.0</span></td> <td class="post_date"><span class="showtitle" title="תאריך מלא: 30/11/2006 20:12">30/11/2006</span></td> <td class="post_content">נסיון לבדיקת הגרשיים. ... <a href="java script: void(0)" onclick="open_popup('main.php?page=showpost&postid=5', 600, 250)" class="script" title="קרא את כל ההודעה">></a></td> <td class="post_action"> <img src="post_edit.png" alt="ערוך" title="ערוך הודעה" onmouseover="this.style.cursor = 'pointer'" /> <img src="post_delete.png" alt="מחק" title="מחק הודעה" onclick="confirmsg(2, 'main.php?page=admincp&action=delete&postnum=5')" onmouseover="this.style.cursor = 'pointer'" /> </td> </tr> <tr> <td colspan="6"> <strong>אם מידע מסויים לא נמצא בהודעה, הוא יראה כריק או כ- "null".</strong> <div id="orderby"> סדר הודעות עפ"י <select> <option>מספר הודעה.</option> <option>שם הכותב</option> <option>כתובת IP.</option> <option>תאריך</option> <option>תוכן ההודעה</option> </select> בסדר <select> <option <!--onclick="orderdata('asc')"-->>יורד.</option> <option <!--onclick="orderdata('desc')"-->>עולה.</option> </select> </div> </td> </tr> </table> </div> </div> <p id="links"> לך:<br /> <a href="main.php?page=outpost" class="postlink">צפה בהודעות קיימות</a>.<br /> <a href="main.php?page=form" class="postlink">פרסם הודעה</a>.<br /> <a href="main.php?page=cplogin" class="postlink">התחבר לפאנל ניהול</a>. </p> <noscript>Javascript חייבת להיות מאופשרת להפעלת כל אופציות המערכת.<br /></noscript> <div id="copyrights"> <p>YuvPost! גרסא 1.0. כל הזכויות שמורות <a class="normal" href="mailto:yuval_ritt@hotmail.co.il">ליובל200</a><sup style="font-size: x-small">©</sup>, "favicon" ואייקונים שונים ע"י <a class="normal" href="http://www.famfamfam.com" target="_blank">מארק ג'יימס</a>.</p> <p><!--[if IE]>נצפה באופן הטוב ביותר עם <a class="normal" href="http://www.mozilla.com/firefox/" target="_blank">Mozilla Firefox</a>.<br /><![endif]--><span class="help"><a href="http://validator.w3.org/check/referer" target="_blank" class="normal">XHTML</a> ו- <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank" class="normal">CSS</a></span> תקני.</p> </div> <script type="text/javascript" src="jsstyling.js"></script> </body></html> (Ignore the hebrew..)Now, I really don't get it. The validator gives me errors like "cannot generate system identifier for general entity 'action'," "general entity 'action' not defined and no default entity," "reference not terminated by REFC delimiter."I've noticed that most of the errors are in URLs.. For now, there are like 22 validation errors for XHTML 1.0 Traditional..Can you please help me..?Thanks
  23. Thanks again aspneguy, but it didn't worked :<I guess I'll have to move the function to the head section untill I'll find a solution.
  24. Hello AGAIN guys :)Anyway, I was surfing the HTML DOM tutorial, and found some cool things with the event object like this and this, I fought that if it was possible to alert the key that was pressed, I can also assign an action to it if it is clicked. I made a simple function in the head section, and then made the function to work by adding the <body> tag a "onkeyup" attribute that contains the function.. Now, that works fine, but I didn't wanted that, so I made something else in the body section. <script type="text/javascript"><!-- function keylogoff(event) { if (event.keyCode == 65) alert('hello'); } document.body.onkeyup = keylogoff(event);//--></script> As you guessed, it didn't worked..I made it simple as I can so I can debug it, but nothing. In FF WTF, the Javascript Inspector wrote: Now, it might think that "event" is a varible, but it isn't. I wrote "event" in the phar-something (those "()") because the "Tryit" example did it too.Can you help me?Thanks
  25. Sorry if this question is noobish/out of place, but can you please tell me what is a JS tool kit?
×
×
  • Create New...