Jump to content

iwato

Members
  • Posts

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. iwato

    Missing XML Formatting

    Fortunately, I have discovered a way to view my XML feed documents. I use Google's Chrome browser. I do have another question about security and the activation of my feed. BACKGROUND: For the moment I am able to generate an RSS2 feed automatically by downloading information from my website's database and processing it using the methods and properties of a PHP library called FeedWriter. The PHP document that processes my RSS2 feed resides locally and is only available to the internet when I am online. My goal is to make it available on my website's host server. CURRENT PROCEDURE 1) Upload the information required to produce a new item to a MySQL database located on my site's host server. 2) Download the information sent to the database onto my local machine and create the XML/RSS2 feed document. 3) Upload the newly produced XML/RSS2 feed document to my website. MY GOAL: What I would like to do is simply upload the information to my MySQL database and generate the new feed automatically. CONSIDERATION 1) All that is necessary to produce a new feed is to add a new entry to my database and make a call to the PHP file that creates the RSS2 feed. Once the call is made the new RSS2 feed appears in the same document window in which the PHP code that produces it resides. New header information is generated and replaces the old. 2) Were I to place the PHP document that creates the feed on my website would I be producing a security risk?
  2. iwato

    Missing XML Formatting

    At minimum I have finally found an RSS Feed writer that is well assembled - FeedWriter by Anis Uddin Ahmad and Michael Bremmer. I can recommend very highly.
  3. iwato

    Missing XML Formatting

    I have now experimented with my third RSS library, and the same problem persists. Fortunately, I believe to have discovered the true source of the problem -- Safari and my RSS Bot feed reader. They are swallowing my code. Each time I execute a piece of software that is suppose to produce an XML/RSS document either Safari or my RSS Bot software intervenes and asks me whether I want to add it to my list of feeds. Whether I answer yes or know, when I go to open the page that results in the XML document, there is nothing there. At best, I can read the source PHP code that creates the page using PHP's show_source( ) function. Even when I perform a search on my machine for the whereabouts of the XML/RSS files that my RSS Bot software has consumed nothing appears. is there not someway for me to fool my RSS feed readers into ignoring my newly created feeds? I have been trying to automate my RSS feed creation for nearly three weeks and have learned quite a bit, but when I cannot see the result of my effort, it is very frustrating. Help! Roddy
  4. QUESTION: How does one read the expression Feed::ATOM in the brief block of code below? class ATOM extends Feed { /** * {@inheritdoc} */ public function __construct() { parent::__construct(Feed::ATOM); } }
  5. QUESTION: How does one read the expression Feed::ATOM in the brief block of code below? class ATOM extends Feed { /** * {@inheritdoc} */ public function __construct() { parent::__construct(Feed::ATOM); } }
  6. Ingolme: Very cool. My first practical use of the $_GET superglobal. I did not know that it was so easy to employ.
  7. RECENT DISCOVERY: I recently discovered a handy PHP function called show_source( ) and would now like to apply it in a particular sort of way. GOAL: I would like to open a new tab in my current window that shows the source code of a page that I have opened in the window. DILEMMA: Since PHP operates before a page is opened I am a lot confused about how to make this happen. This is what I have accomplished so far. $( document ).ready(function() { console.log( "ready!" ); $('.show_src a').on('click', function(event) { event.preventDefault(); var address = $(this).attr('href'); window.open(address); ... }); }); <li class='show_src'>The <a href='./composer/php_rss_generator/RSSGenerator/ItemInterface.php' title='' target='_blank'>Interface</a></li> <li class='show_src'>The <a href='./composer/php_rss_generator/RSSGenerator/Item.php' title='' target='_blank'>Class</a></li> I have tried a variety of ways to replace the three dots above including .ajax( ) and window.write( ) but nothing seems to work. Any ideas? Roddy
  8. iwato

    Missing XML Formatting

    No, it is not because of capitalization. I changed all class names to names beginning with caps. It made no difference. The error message was the same.
  9. iwato

    Missing XML Formatting

    OK. I eliminated the var keyword and am now seeing the following parsing error when I go to load the class file. Parse error: parse error, expecting `"function (T_FUNCTION)"' in /Users/kiusau/vendor/phpclasses/rssgen2_0/rss_generator.inc.php on line 20 Is it because the class name is not capitalized?
  10. iwato

    Missing XML Formatting

    This is the PHP package that I am using. And, I beginning to feel very sorry that I chose it. Simply, it appeared better documented than the others that I had viewed. <?php /* RSS Feed Generator for PHP 4 or higher version Version 1.0.3 Written by Vagharshak Tozalakyan <vagh@armdex.com> License: GNU Public License Classes in package: class rssGenerator_rss class rssGenerator_channel class rssGenerator_image class rssGenerator_textInput class rssGenerator_item For additional information please reffer the documentation */ class rssGenerator_rss { var $rss_version = '2.0'; var $encoding = ''; var $stylesheet = ''; function cData($str) { return '<![CDATA[ ' . $str . ' ]]>'; } function createFeed($channel) { $selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https://'); $selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $rss = '<?xml version="1.0"'; if (!empty($this->encoding)) { $rss .= ' encoding="' . $this->encoding . '"'; } $rss .= '?>' . "\n"; if (!empty($this->stylesheet)) { $rss .= $this->stylesheet . "\n"; } $rss .= '<!-- Generated on ' . date('r') . ' -->' . "\n"; $rss .= '<rss version="' . $this->rss_version . '" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n"; $rss .= ' <channel>' . "\n"; $rss .= ' <atom:link href="' . ($channel->atomLinkHref ? $channel->atomLinkHref : $selfUrl) . '" rel="self" type="application/rss+xml" />' . "\n"; $rss .= ' <title>' . $channel->title . '</title>' . "\n"; $rss .= ' <link>' . $channel->link . '</link>' . "\n"; $rss .= ' <description>' . $channel->description . '</description>' . "\n"; if (!empty($channel->language)) { $rss .= ' <language>' . $channel->language . '</language>' . "\n"; } if (!empty($channel->copyright)) { $rss .= ' <copyright>' . $channel->copyright . '</copyright>' . "\n"; } if (!empty($channel->managingEditor)) { $rss .= ' <managingEditor>' . $channel->managingEditor . '</managingEditor>' . "\n"; } if (!empty($channel->webMaster)) { $rss .= ' <webMaster>' . $channel->webMaster . '</webMaster>' . "\n"; } if (!empty($channel->pubDate)) { $rss .= ' <pubDate>' . $channel->pubDate . '</pubDate>' . "\n"; } if (!empty($channel->lastBuildDate)) { $rss .= ' <lastBuildDate>' . $channel->lastBuildDate . '</lastBuildDate>' . "\n"; } foreach ($channel->categories as $category) { $rss .= ' <category'; if (!empty($category['domain'])) { $rss .= ' domain="' . $category['domain'] . '"'; } $rss .= '>' . $category['name'] . '</category>' . "\n"; } if (!empty($channel->generator)) { $rss .= ' <generator>' . $channel->generator . '</generator>' . "\n"; } if (!empty($channel->docs)) { $rss .= ' <docs>' . $channel->docs . '</docs>' . "\n"; } if (!empty($channel->ttl)) { $rss .= ' <ttl>' . $channel->ttl . '</ttl>' . "\n"; } if (sizeof($channel->skipHours)) { $rss .= ' <skipHours>' . "\n"; foreach ($channel->skipHours as $hour) { $rss .= ' <hour>' . $hour . '</hour>' . "\n"; } $rss .= ' </skipHours>' . "\n"; } if (sizeof($channel->skipDays)) { $rss .= ' <skipDays>' . "\n"; foreach ($channel->skipDays as $day) { $rss .= ' <day>' . $day . '</day>' . "\n"; } $rss .= ' </skipDays>' . "\n"; } if (!empty($channel->image)) { $image = $channel->image; $rss .= ' <image>' . "\n"; $rss .= ' <url>' . $image->url . '</url>' . "\n"; $rss .= ' <title>' . $image->title . '</title>' . "\n"; $rss .= ' <link>' . $image->link . '</link>' . "\n"; if ($image->width) { $rss .= ' <width>' . $image->width . '</width>' . "\n"; } if ($image->height) { $rss .= ' <height>' . $image->height . '</height>' . "\n"; } if (!empty($image->description)) { $rss .= ' <description>' . $image->description . '</description>' . "\n"; } $rss .= ' </image>' . "\n"; } if (!empty($channel->textInput)) { $textInput = $channel->textInput; $rss .= ' <textInput>' . "\n"; $rss .= ' <title>' . $textInput->title . '</title>' . "\n"; $rss .= ' <description>' . $textInput->description . '</description>' . "\n"; $rss .= ' <name>' . $textInput->name . '</name>' . "\n"; $rss .= ' <link>' . $textInput->link . '</link>' . "\n"; $rss .= ' </textInput>' . "\n"; } if (!empty($channel->cloud_domain) || !empty($channel->cloud_path) || !empty($channel->cloud_registerProcedure) || !empty($channel->cloud_protocol)) { $rss .= ' <cloud domain="' . $channel->cloud_domain . '" '; $rss .= 'port="' . $channel->cloud_port . '" path="' . $channel->cloud_path . '" '; $rss .= 'registerProcedure="' . $channel->cloud_registerProcedure . '" '; $rss .= 'protocol="' . $channel->cloud_protocol . '" />' . "\n"; } if (!empty($channel->extraXML)) { $rss .= $channel->extraXML . "\n"; } foreach ($channel->items as $item) { $rss .= ' <item>' . "\n"; if (!empty($item->title)) { $rss .= ' <title>' . $item->title . '</title>' . "\n"; } if (!empty($item->description)) { $rss .= ' <description>' . $item->description . '</description>' . "\n"; } if (!empty($item->link)) { $rss .= ' <link>' . $item->link . '</link>' . "\n"; } if (!empty($item->pubDate)) { $rss .= ' <pubDate>' . $item->pubDate . '</pubDate>' . "\n"; } if (!empty($item->author)) { $rss .= ' <author>' . $item->author . '</author>' . "\n"; } if (!empty($item->comments)) { $rss .= ' <comments>' . $item->comments . '</comments>' . "\n"; } if (!empty($item->guid)) { $rss .= ' <guid isPermaLink="'; $rss .= ($item->guid_isPermaLink ? 'true' : 'false') . '">'; $rss .= $item->guid . '</guid>' . "\n"; } /* if (!empty($item->source_url)) { $rss .= ' <source url="' . $item->source_url . '">'; $rss .= $item->source . '</source>' . "\n"; } */ if (!empty($item->source)) { $rss .= ' <source url="' . $item->source_url . '">'; $rss .= $item->source . '</source>' . "\n"; } if (!empty($item->enclosure_url) || !empty($item->enclosure_type)) { $rss .= ' <enclosure url="' . $item->enclosure_url . '" '; $rss .= 'length="' . $item->enclosure_length . '" '; $rss .= 'type="' . $item->enclosure_type . '" />' . "\n"; } foreach ($item->categories as $category) { $rss .= ' <category'; if (!empty($category['domain'])) { $rss .= ' domain="' . $category['domain'] . '"'; } $rss .= '>' . $category['name'] . '</category>' . "\n"; } $rss .= ' </channel>' . "\r"; return $rss .= '</rss>'; } } } class rssGenerator_channel { var $atomLinkHref = ''; var $title = ''; var $link = ''; var $description = ''; var $language = ''; var $copyright = ''; var $managingEditor = ''; var $webMaster = ''; var $pubDate = ''; var $lastBuildDate = ''; var $categories = array(); var $generator = ''; var $docs = ''; var $ttl = ''; var $image = ''; var $textInput = ''; var $skipHours = array(); var $skipDays = array(); var $cloud_domain = ''; var $cloud_port = '80'; var $cloud_path = ''; var $cloud_registerProcedure = ''; var $cloud_protocol = ''; var $items = array(); var $extraXML = ''; } class rssGenerator_image { var $url = ''; var $title = ''; var $link = ''; var $width = '88'; var $height = '31'; var $description = ''; } class rssGenerator_textInput { var $title = ''; var $description = ''; var $name = ''; var $link = ''; } class rssGenerator_item { var $title = ''; var $description = ''; var $link = ''; var $author = ''; var $pubDate = ''; var $comments = ''; var $guid = ''; var $guid_isPermaLink = true; var $source = ''; var $source_url = ''; var $enclosure_url = ''; var $enclosure_length = '0'; var $enclosure_type = ''; var $categories = array(); } ?> Of course, all is not lost, because I have learned a great deal about other matters in the process. Simply I have now wasted two days trying to figure out why the createFeed( ) function is not doing its job. As of yet, I still have not received a reply from the author.
  11. iwato

    Missing XML Formatting

    I am told that it is undefined.
  12. iwato

    Missing XML Formatting

    Unfortunately, there is nothing to print. Catchable fatal error: Object of class rssGenerator_rss could not be converted to string in /Users/kiusau/Sites/reflexive/php_practice/libraries/rssgen2.0/gc_implemenation/rss2gen.php on line 1400
  13. iwato

    Missing XML Formatting

    And, where is the URL that those lines build?
  14. iwato

    Missing XML Formatting

    OK. i have discovered that the include statement is failing. Still, I do not understand the statement $selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https://'); $selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  15. iwato

    Missing XML Formatting

    OK. This is the code. I am exhausted. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $host = "..."; $user = "..."; $pwd = "..."; $mysqli_obj = new mysqli($host, $user, $pwd); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $mysqli_obj->set_charset("utf8"); $db = "thege0_grammarcaptive"; $mysqli_obj->select_db($db); $tbl_name = 'rss2_podcast_channel'; $sql_1 = "SELECT * FROM ". $tbl_name . " ORDER BY channel_pubdate DESC LIMIT 1"; $chan_arr = array(); $result_obj = $mysqli_obj->query($sql_1); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $chan_arr[$key] = $value; } } $tbl_name = 'rss2_podcast_item'; $sql_1 = "SELECT * FROM ". $tbl_name . " ORDER BY item_pubdate DESC LIMIT 5"; $item_arr = array(); $result_obj = $mysqli_obj->query($sql_1); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $item_arr[$key] = $value; } $items[] = $item_arr; } $tbl_name = 'rss2_podcast_itunes'; $sql_1 = "SELECT * FROM ". $tbl_name . " ORDER BY publish_date_itunes DESC LIMIT 5"; $itunes_arr = array(); $result_obj = $mysqli_obj->query($sql_1); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $itunes_arr[$key] = $value; } $itunes[] = $itunes_arr; } include('/Users/kiusau/Sites/reflexive/php_practice/libraries/rssgen2.0/rss_generator.inc.php'); $rss_feed = new rssGenerator_rss(); $atomLinkHref = '../../../../grammarcaptive.com/feed/gc_podcasts.xml'; $chan_categories = array(0 => array('domain' => '', 'name' => $chan_arr['channel_category1']),1 => array('domain' => '', 'name' => $chan_arr['channel_category2']),2 => array('domain' => '', 'name' => $chan_arr['channel_category3'])); $i = 0; $length = count($items); while ($i < $length) { foreach ($items[$i] as $key => $value) { if ($key == 'item_category1') { $item_categories[$i][$key] = array('domain'=>'','name'=>$value); } if ($key == 'item_category2') { $item_categories[$i][$key] = array('domain'=>'','name'=>$value); } if ($key == 'item_category3') { $item_categories[$i][$key] = array('domain'=>'','name'=>$value); } } $i++; } $i = 0; $length = count($itunes); while ($i < $length) { foreach ($itunes[$i] as $key => $value) { if ($key == 'itunes_category1') { $itunes_categories[$i][$key] = array('domain'=>'','name'=>$value); } if ($key == 'itunes_category2') { $itunes_categories[$i][$key] = array('domain'=>'','name'=>$value); } if ($key == 'itunes_category3') { $itunes_categories[$i][$key] = array('domain'=>'','name'=>$value); } } $i++; } $i = 0; $length = count($items); while ($i < $length) { $rss_item = new rssGenerator_item(); foreach ($items[$i] as $key => $value) { $rss_item->title = $items[$i]['item_title']; $rss_item->description = $items[$i]['item_description']; $rss_item->link = $items[$i]['item_link']; $rss_item->pubDate = $items[$i]['item_pubdate']; $rss_item->author = $items[$i]['item_author']; $rss_item->comments = $items[$i]['item_comments']; $rss_item->guid = $items[$i]['item_guid']; $rss_item->guid_isPermaLink = 'false'; $rss_item->source = 'Grammar Captive'; $rss_item->source_url = $items[$i]['item_source']; $rss_item->enclosure_url = $items[$i]['item_enclurl']; $rss_item->enclosure_length = $items[$i]['item_encllength']; $rss_item->enclosure_type = $items[$i]['item_encltype']; $rss_item->categories = $item_categories[$i]; } $rss_items[] = $rss_item; $i++; } $rss_image = new rssGenerator_image(); $rss_image->title = $chan_arr['channel_img_title']; $rss_image->url = $chan_arr['channel_img_url']; $rss_image->link = $chan_arr['channel_img_link']; $rss_image->width = $chan_arr['channel_img_width']; $rss_image->height = $chan_arr['channel_img_height']; $rss_image->description = $chan_arr['channel_img_description']; $rss_channel = new rssGenerator_channel(); $rss_channel->atomLinkHref = $atomLinkHref; $rss_channel->title = $chan_arr['channel_title']; $rss_channel->link = $chan_arr['channel_link']; $rss_channel->description = $rss_feed->cData($chan_arr['channel_description']); $rss_channel->language = $chan_arr['channel_language']; $rss_channel->copyright = $chan_arr['channel_copyright']; $rss_channel->webMaster = $chan_arr['channel_link']; $rss_channel->pubDate = $chan_arr['channel_pubdate']; $rss_channel->lastBuildDate = $chan_arr['channel_lastbuilddate']; $rss_channel->categories = $chan_categories; $rss_channel->image = $rss_image; $rss_channel->items = $rss_items; $rss_feed->encoding = 'UTF-8'; $rss_feed->version = '2.0'; $rss_feed->createFeed($rss_channel); // header('Location: gc_podcasts.xml'); $result_obj->free(); $mysqli_obj->close(); ?> Now, mind you. This identical code works in an HTML file with all kinds of HTML mark-up, but when set aside unto its own without the mark-up it fails resulting in the PHP white sheet.
  16. BACKGROUND: I have recently created the content of an automatically generated podcast using a PHP Class that I found on a webpage found https://www.phpclasses.org/package/2957-PHP-Generate-RSS-2-0-feeds.html. Unfortunately, when I attempt to display the generated feed all that is displayed are the values of the input variables, or alternatively nothing (see (below)depending on the method of display. In short, the desired formatting -- the reason that I downloaded the PHP Class -- is missing. The page that creates the above result is a text file with a .php extension and a header( ) function. $rss_feed->encoding = 'UTF-8'; $rss_feed->version = '2.0'; $rss_feed->createFeed($rss_channel); header('Content-Type: text/xml; $rss_channel = the object that combines the formatting with the values of the input variables and their respective objects. The Class is relatively straight-forward and easily customized, but for two lines that I do not understand and could well be preventing the display of the XML code, if not properly configured. Interestingly, whether they are commented out or left in tact, they have no affect on what is displayed. $selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https://'); $selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; When I run the .php file the following message appears at the top of the completed page. Still nothing below the message appears. Also, I do not know the source of this message. it does not appear to come from the .php document. Now, I have not constructed a style-sheet for the Feed page, but I hardly see how this could stop the feed from appearingl Please advise.
  17. This problem has been resolved. After a night's rest I discovered that I was accidentally querying the same table twice. A condition likely caused by an improper copy and paste. LESSON: When everything appears correct, do not doubt its correctness. Look elsewhere for the error.
  18. Please ignore the missing back-tick before the obs column. it was a typo incurred while editing code taken from the results of a SHOW CREATE TABLE statement.
  19. Thank you. I will add these links to my notes. Roddy
  20. This is what I thought too, but it does not appear to run.
  21. QUESTION ONE: How does one suppress duplicate row entries? QUESTION TWO: In the following case what is causing them to occur? BACKGROUND: I created several tables only to discover that they were not as I wanted them. AFter truncateng each, I dropped what I believed to be poorly structured columns, rearranged some, and added still others. When I tested the result, everything worked great except for one problem -- a single table entry reuslted in duplicate rows. THE TABLE STRUCTURE CREATE TABLE 'table_name' (obs` int(5) NOT NULL AUTO_INCREMENT . . . PRIMARY KEY (`obs`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 A SAMPLE SQL STATEMENT INSERT INTO rss2_podcast_itunes (podcast_no_itunes, itunes_category1, itunes_category2, itunes_category3, itunes_complete, itunes_new_feed_url, itunes_name, itunes_email, itunes_duration, itunes_order, itunes_author, itunes_block, itunes_image, itunes_explicit, itunes_summary) VALUES ('54', 'education', 'language', 'English', '', '', 'Roddy A. Stegemann', 'kiusau@me.com', '00:01:01', '', 'Roddy A. Stegemann', '', 'http://www.grammarcaptive.com/_images/captive.png', '', 'Test') Please note the following: No value is entered for the obs field/column. The auto increment advances one for each row entered. Below each successfully loaded row entry appears another row identical in every way but one -- the appearance of an incremental advance in the value of the obs field. Please advise. Roddy
  22. iwato

    Issues comments

    JSG - Up until now I have understood that a Javascript script can be entered via an <input> or <textarea> control form, or for that matter any other data that is passed from a form to the same or another processing page when the <submit> control is triggered. What you seem to be suggesting is something else. Am I in error? If not, could you provide an example. I would like to see what i am up against. Roddy
  23. I have never heard of a static class -- only static properties and methods of a class. Do you mean by non-static class a class without static properties or methods? If I have understood correctly, the purpose of the pseudo $this variable is to distinguish between variables within a specific scope or class from regular variables -- these latter being variable that can be used anywhere except within a class or specified scope. In effect, one can speak of three different kinds of variables: 1) regular variables -- variables defined and used outside of specific scopes and classes. 2) $this -> variables -- variables defined within a specific scope or class and accessed from within the scope or class using the $this-> notation of from without using a class object and the -> operator. 3) global variables -- variables defined within a specific scope (not class) that can be accessed from without the scope as regular variables and presumably within the scope as same. Is this assessment correct? Have you anything to add?
×
×
  • Create New...