Jump to content

Arty Ziff

Members
  • Posts

    67
  • Joined

  • Last visited

Everything posted by Arty Ziff

  1. I'm using the following code to grab an RSS feed and parse it into an array: $doc = new DOMDocument(); $doc->load('http://MySite.com/feed/'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(1)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } My problem is that there is one tag I'd like to access, but don't quite know how... It is: <content:encoded> I've looked at 'content' => $node->getElementsByTagName('content:encoded')->item(1)->nodeValue and 'content' => $node->getElementsByTagName('content')->item(1)->nodeValue But neither work. Any ideas?
  2. I changed the link style of permalinks from the default: http://MySite.com/?p=123 To something I feel is more friendly: http://MySite.com/2011/10/01/sample-post/ And saved the new settings... Testing it out, I found that links now showed the new format, but when followed go to "Page Not Found". Now, I was thinking perhaps WordPress couldn't write the changes to .htaccess (I'm thinking mod_rewrite) and so the the new links where not being translated by Apache. So, I changed the file permission (just for testing) to 777 and tried again, resaving the new settings and navigating to the page. Still "Page Not Found". Any WordPress gurus out there know what I'm doing wrong? I'm sure it's obvious... Thanks, Arty Zifferini
  3. Recommendations for web developer tools / extensions for Chrome?
  4. This little discussion with / about user:ebmigue is interesting and all that, but has essentially HIJACKED my thread which is asking a question. Sure, I do use an "abstraction layer" of sorts in that I've written a class that handles the actual php DB commands - information about what I need to query is passed to the class, and results are passed back. But it's "homegrown" and limited, and I want more. I'm not interested in reinventing the wheel. I'm thinking of ADOdb, and I know there are competing libraries. I'm assuming people here have personal opinions about the completeness, design, and usability of ADOdb and similar libraries? User:ebmigue's project looks very interesting, and I will look at it because it looks interesting, but it's NOT what I'm looking for today...
  5. Currently, I'm using MySQL. and I don't see transitioning to something else as very likly. But if we did, it would be PostgreSQL. In any case... What is the current "group-think" on abstraction layers? For non-trivial applications? Any favorites?
  6. What is the difference / purposes between: <style> @import "/some/path/somefile.css"; </style> verses <link rel="stylesheet" href="/some/path/somefile.css" /> I'm working with a MooTools modal app that does not work without the @import and only the <link ... />. I find this odd.
  7. I need an OLDER version of OpenOffice, but I can't find any archives at OpenOffice.org. There are a number of websites like www.oldapps.com that "seem" to have the versions I want, but can these types of sites be trusted? Does anyone know if there is an OFFICIAL archive of older Windows executables?
  8. Suppose I have a multidimensional array... $AnArray[1][$j] I'd like to count how many $j So if $AnArray = array(0 => array('orange', 'banana', 'apple'), 1 => array('carrot', 'collard', 'pea','tuna')); The count I'm after would be 4...
  9. Several popular ways to manipulate images... GD, ImageMagick, netpbm... GD and ImageMagick are most popular. I've used netpbm in the past for thumbs because it had better quality results than GD... I mostly use GD because I'm lazy and "it's there". Thumbs, watermarks, captcha... All have php extensions... I think...
  10. Thanks, I didn't see the location in phpinfo, but I could be blind... "which" works. Yes, /usr/bin is where CentOS (and I suppose RHEL) puts it. I'm running code from cron outside the web root, thus I can't use lynx ...
  11. How do I find the location of the php executable? Running CentOS, and it's not at /usr/local/bin/php...
  12. Oooooo! I've never heard of REPLACE, but I like it!
  13. I'd like to add rows to a table, but only if a certain (varchar) col value does not already exist. I know I could make that col unique... Is there a way to form the INSERT query to insure uniqueness? I don't want to rely on MySQL returning an error...
  14. Yes, that's exactly what it does (of which there is only one occurrence in the HTML block being parsed...) The hierarchy is known, but it could change. But the tags (for the most part) have unique class names. Dcr0 - Works great. Thanks!
  15. I'm using php's DOM functions to strip some information out of a block of HTML: for ($i = 0; $i <= $tot_tblocks-1; $i++) { // Load the HTML blocks... $dom = new DOMDocument(); $dom->loadHTML($tblock[$i]); $xpath = new DOMXPath($dom); $tags = $xpath->query('//div[@class="desc"]/h2[@class="name"]'); // Get the part I want... foreach ($tags as $tag) { $tname[$i] = trim($tag->nodeValue); echo $tname[$i]."<br>"; } } Two questions: 1 - There is actually ever only one item ("name"), can I access it without the foreach loop? $tname[$i] = trim($tags->nodeValue); doesn't work. 2 - This code extracts content between tags of certain class names. But I would also like to extract the values of certain attributes of some of those tags, such as - perhaps - the value of the href in a <a> tag. The tag may not have unique class name, but I could still get an array from all the <a> tags in the source block? But I don't know how, and haven't been successful in deciphering the documentation... Any ideas?
  16. When I use DOM to extract content from HTML text files, I get "funny characters" When I look at the source, there is just white space. $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->loadHTML($tblock[$i]); $xpath = new DOMXPath($dom); $tags = $xpath->query('//div[@class="desc"]/h2[@class="name"]'); foreach ($tags as $tag) { $tname[$i] = trim($tag->nodeValue); echo $tname[$i]."<br>"; } How can I strip out those invisible special chars?
  17. Thanks, Mattal999, sure I thought about that, but out of the huge number of possible tags, it seems like there should be a better way that involved only listing the ones you DON'T want. As to regex, I suppose that's the ideal way barring a native function... THANKS!
  18. It seems like there should be a dedicated php function to strip a SPECIFIC tag, rather than the functionality of strip_tags. I'm using this: But this will not help me if for example I want to trip out scripts <script> ... </script>. Is there a better way?
  19. Anyone here remember Soylent Green? Where overpopulation brought about voluntary euthanasia, and then they dissolved the bodies in acid and extracted the nutrient to make into soy crackers for the masses? Good grief, Charlton Heston of all actors! Well, that's the way I'd like to go... http://en.wikipedia.org/wiki/Soylent_Green I was 10 when that movie came out, so I'm well on my way to be made into a soy cracker!
  20. Typically, what method do shopping cart systems use to store the cart information? Session vars? Cookies? Database? Just curious, not building one...
  21. Is there a way to restrict access to directories to scripts located on the same server? For example, I have some libraries. I don't want hackers to find them and perhaps use them, for example my pdf library.
  22. Greetings... Is there a way to set a cookie that is visible to more than one browser? For example, a visitor surfs in with Chrome and the page script sets a cookie, is there a way to set it for Chrome *and* FF *and* IE? I assume the answer is no...
  23. In many cases, variable have to be explicitly defined for whatever reason. However, often it is not required for a simple web page script. Yet, even in those cases, if a variable is NOT explicitly defined, the web server error log (example: my_domain.com-error_log) will rack up a lot of entries such as this: A busy site could result in large error logs... What is considered "best practice"? Should all variables always be explicitly defined with the var key word?
  24. How does one go about using one class inside another? For example, building a class that does some series of functions, and uses a db abstraction layer class in the process?
  25. Actually, I've discovered that the directory that contains the scripts that authenticate users is not dishing it up via SSL. Here's what I'm doing in httpd.conf... Directory that's working fine: <Directory "/home/my_site/public_html/secure"> AllowOverride All RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} secure RewriteRule ^(.*)$ https://www.my_site.com/secure/$1 [R,L] </Directory> Directory that's giving me non-SSL conectivity... <Directory "/home/my_site/public_html/classes"> AllowOverride All RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} secure RewriteRule ^(.*)$ https://www.my_site.com/classes/$1 [R,L] </Directory> But the directives are the same, why would one function how I want, but not the other?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.