@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | $result = ""; |
334 | 334 | } elseif ($this->syndicateHtml) { |
335 | 335 | $result = "<![CDATA[".$this->rawFieldContent."]]>"; |
336 | - } else { |
|
336 | + }else { |
|
337 | 337 | if ($this->truncSize and is_int($this->truncSize)) { |
338 | - $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent),$this->truncSize); |
|
339 | - } else { |
|
338 | + $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize); |
|
339 | + }else { |
|
340 | 340 | $result = htmlspecialchars($this->rawFieldContent); |
341 | 341 | } |
342 | 342 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @param string filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
449 | 449 | * @param boolean displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. |
450 | 450 | */ |
451 | - function saveFeed($format="RSS0.91", $filename="", $displayContents=true) { |
|
451 | + function saveFeed($format = "RSS0.91", $filename = "", $displayContents = true) { |
|
452 | 452 | $this->_setFormat($format); |
453 | 453 | $this->_feed->saveFeed($filename, $displayContents); |
454 | 454 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
467 | 467 | * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
468 | 468 | */ |
469 | - function useCached($format="RSS0.91", $filename="", $timeout=3600) { |
|
469 | + function useCached($format = "RSS0.91", $filename = "", $timeout = 3600) { |
|
470 | 470 | $this->_setFormat($format); |
471 | 471 | $this->_feed->useCached($filename, $timeout); |
472 | 472 | } |
@@ -564,25 +564,25 @@ discard block |
||
564 | 564 | return $string; |
565 | 565 | } |
566 | 566 | |
567 | - $pos = strrpos($string,"."); |
|
567 | + $pos = strrpos($string, "."); |
|
568 | 568 | if ($pos>=$length-4) { |
569 | - $string = substr($string,0,$length-4); |
|
570 | - $pos = strrpos($string,"."); |
|
569 | + $string = substr($string, 0, $length-4); |
|
570 | + $pos = strrpos($string, "."); |
|
571 | 571 | } |
572 | 572 | if ($pos>=$length*0.4) { |
573 | - return substr($string,0,$pos+1)." ..."; |
|
573 | + return substr($string, 0, $pos+1)." ..."; |
|
574 | 574 | } |
575 | 575 | |
576 | - $pos = strrpos($string," "); |
|
576 | + $pos = strrpos($string, " "); |
|
577 | 577 | if ($pos>=$length-4) { |
578 | - $string = substr($string,0,$length-4); |
|
579 | - $pos = strrpos($string," "); |
|
578 | + $string = substr($string, 0, $length-4); |
|
579 | + $pos = strrpos($string, " "); |
|
580 | 580 | } |
581 | 581 | if ($pos>=$length*0.4) { |
582 | - return substr($string,0,$pos)." ..."; |
|
582 | + return substr($string, 0, $pos)." ..."; |
|
583 | 583 | } |
584 | 584 | |
585 | - return substr($string,0,$length-4)." ..."; |
|
585 | + return substr($string, 0, $length-4)." ..."; |
|
586 | 586 | |
587 | 587 | } |
588 | 588 | |
@@ -604,11 +604,11 @@ discard block |
||
604 | 604 | * @param indentString string a string that will be inserted before every generated line |
605 | 605 | * @return string the XML tags corresponding to $additionalElements |
606 | 606 | */ |
607 | - function _createAdditionalElements($elements, $indentString="") { |
|
607 | + function _createAdditionalElements($elements, $indentString = "") { |
|
608 | 608 | $ae = ""; |
609 | 609 | if (is_array($elements)) { |
610 | - foreach($elements AS $key => $value) { |
|
611 | - $ae.= $indentString."<$key>$value</$key>\n"; |
|
610 | + foreach ($elements AS $key => $value) { |
|
611 | + $ae .= $indentString."<$key>$value</$key>\n"; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | return $ae; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | */ |
649 | 649 | function _generateFilename() { |
650 | 650 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
651 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".xml"; |
|
651 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".xml"; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
@@ -686,12 +686,12 @@ discard block |
||
686 | 686 | * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
687 | 687 | * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
688 | 688 | */ |
689 | - function useCached($filename="", $timeout=3600) { |
|
689 | + function useCached($filename = "", $timeout = 3600) { |
|
690 | 690 | $this->_timeout = $timeout; |
691 | - if ($filename=="") { |
|
691 | + if ($filename == "") { |
|
692 | 692 | $filename = $this->_generateFilename(); |
693 | 693 | } |
694 | - if (file_exists($filename) AND (time()-filemtime($filename) < $timeout)) { |
|
694 | + if (file_exists($filename) AND (time()-filemtime($filename)<$timeout)) { |
|
695 | 695 | $this->_redirect($filename); |
696 | 696 | } |
697 | 697 | } |
@@ -705,18 +705,18 @@ discard block |
||
705 | 705 | * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
706 | 706 | * @param redirect boolean optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file. |
707 | 707 | */ |
708 | - function saveFeed($filename="", $displayContents=true) { |
|
709 | - if ($filename=="") { |
|
708 | + function saveFeed($filename = "", $displayContents = true) { |
|
709 | + if ($filename == "") { |
|
710 | 710 | $filename = $this->_generateFilename(); |
711 | 711 | } |
712 | 712 | $feedFile = fopen($filename, "w+"); |
713 | 713 | if ($feedFile) { |
714 | - fputs($feedFile,$this->createFeed()); |
|
714 | + fputs($feedFile, $this->createFeed()); |
|
715 | 715 | fclose($feedFile); |
716 | 716 | if ($displayContents) { |
717 | 717 | $this->_redirect($filename); |
718 | 718 | } |
719 | - } else { |
|
719 | + }else { |
|
720 | 720 | echo "<br /><b>Error creating feed file, please check write permissions.</b><br />"; |
721 | 721 | } |
722 | 722 | } |
@@ -736,29 +736,29 @@ discard block |
||
736 | 736 | * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps. |
737 | 737 | * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used. |
738 | 738 | */ |
739 | - function FeedDate($dateString="") { |
|
739 | + function FeedDate($dateString = "") { |
|
740 | 740 | $tzOffset = 0; |
741 | - if ($dateString=="") $dateString = date("r"); |
|
741 | + if ($dateString == "") $dateString = date("r"); |
|
742 | 742 | |
743 | 743 | //if (is_integer($dateString)) { |
744 | 744 | if (is_numeric($dateString)) { |
745 | 745 | $this->unix = $dateString; |
746 | 746 | return; |
747 | 747 | } |
748 | - if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",$dateString,$matches)) { |
|
749 | - $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); |
|
750 | - $this->unix = mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]); |
|
751 | - if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') { |
|
752 | - $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60; |
|
753 | - } else { |
|
754 | - if (strlen($matches[7])==1) { |
|
748 | + if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~", $dateString, $matches)) { |
|
749 | + $months = Array("Jan"=>1, "Feb"=>2, "Mar"=>3, "Apr"=>4, "May"=>5, "Jun"=>6, "Jul"=>7, "Aug"=>8, "Sep"=>9, "Oct"=>10, "Nov"=>11, "Dec"=>12); |
|
750 | + $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]); |
|
751 | + if (substr($matches[7], 0, 1) == '+' OR substr($matches[7], 0, 1) == '-') { |
|
752 | + $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60; |
|
753 | + }else { |
|
754 | + if (strlen($matches[7]) == 1) { |
|
755 | 755 | $oneHour = 3600; |
756 | 756 | $ord = ord($matches[7]); |
757 | - if ($ord < ord("M")) { |
|
758 | - $tzOffset = (ord("A") - $ord - 1) * $oneHour; |
|
759 | - } elseif ($ord >= ord("M") AND $matches[7]!="Z") { |
|
760 | - $tzOffset = ($ord - ord("M")) * $oneHour; |
|
761 | - } elseif ($matches[7]=="Z") { |
|
757 | + if ($ord<ord("M")) { |
|
758 | + $tzOffset = (ord("A")-$ord-1)*$oneHour; |
|
759 | + } elseif ($ord>=ord("M") AND $matches[7] != "Z") { |
|
760 | + $tzOffset = ($ord-ord("M"))*$oneHour; |
|
761 | + } elseif ($matches[7] == "Z") { |
|
762 | 762 | $tzOffset = 0; |
763 | 763 | } |
764 | 764 | } |
@@ -770,12 +770,12 @@ discard block |
||
770 | 770 | $this->unix += $tzOffset; |
771 | 771 | return; |
772 | 772 | } |
773 | - if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$dateString,$matches)) { |
|
774 | - $this->unix = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]); |
|
775 | - if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') { |
|
776 | - $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60; |
|
777 | - } else { |
|
778 | - if ($matches[7]=="Z") { |
|
773 | + if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) { |
|
774 | + $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
775 | + if (substr($matches[7], 0, 1) == '+' OR substr($matches[7], 0, 1) == '-') { |
|
776 | + $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60; |
|
777 | + }else { |
|
778 | + if ($matches[7] == "Z") { |
|
779 | 779 | $tzOffset = 0; |
780 | 780 | } |
781 | 781 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | function rfc822() { |
794 | 794 | //return gmdate("r",$this->unix); |
795 | 795 | $date = gmdate("D, d M Y H:i:s", $this->unix); |
796 | - if (TIME_ZONE!="") $date .= " ".str_replace(":","",TIME_ZONE); |
|
796 | + if (TIME_ZONE != "") $date .= " ".str_replace(":", "", TIME_ZONE); |
|
797 | 797 | return $date; |
798 | 798 | } |
799 | 799 | |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | * @return a date in ISO 8601 format |
804 | 804 | */ |
805 | 805 | function iso8601() { |
806 | - $date = gmdate("Y-m-d\TH:i:sO",$this->unix); |
|
807 | - $date = substr($date,0,22) . ':' . substr($date,-2); |
|
808 | - if (TIME_ZONE!="") $date = str_replace("+00:00",TIME_ZONE,$date); |
|
806 | + $date = gmdate("Y-m-d\TH:i:sO", $this->unix); |
|
807 | + $date = substr($date, 0, 22).':'.substr($date, -2); |
|
808 | + if (TIME_ZONE != "") $date = str_replace("+00:00", TIME_ZONE, $date); |
|
809 | 809 | return $date; |
810 | 810 | } |
811 | 811 | |
@@ -836,63 +836,63 @@ discard block |
||
836 | 836 | */ |
837 | 837 | function createFeed() { |
838 | 838 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
839 | - $feed.= $this->_createGeneratorComment(); |
|
840 | - if ($this->cssStyleSheet=="") { |
|
839 | + $feed .= $this->_createGeneratorComment(); |
|
840 | + if ($this->cssStyleSheet == "") { |
|
841 | 841 | $cssStyleSheet = "http://www.w3.org/2000/08/w3c-synd/style.css"; |
842 | 842 | } |
843 | - $feed.= $this->_createStylesheetReferences(); |
|
844 | - $feed.= "<rdf:RDF\n"; |
|
845 | - $feed.= " xmlns=\"http://purl.org/rss/1.0/\"\n"; |
|
846 | - $feed.= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
|
847 | - $feed.= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
|
848 | - $feed.= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
|
849 | - $feed.= " <channel rdf:about=\"".$this->syndicationURL."\">\n"; |
|
850 | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
851 | - $feed.= " <description>".htmlspecialchars($this->description)."</description>\n"; |
|
852 | - $feed.= " <link>".$this->link."</link>\n"; |
|
853 | - if ($this->image!=null) { |
|
854 | - $feed.= " <image rdf:resource=\"".$this->image->url."\" />\n"; |
|
843 | + $feed .= $this->_createStylesheetReferences(); |
|
844 | + $feed .= "<rdf:RDF\n"; |
|
845 | + $feed .= " xmlns=\"http://purl.org/rss/1.0/\"\n"; |
|
846 | + $feed .= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
|
847 | + $feed .= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
|
848 | + $feed .= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
|
849 | + $feed .= " <channel rdf:about=\"".$this->syndicationURL."\">\n"; |
|
850 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
851 | + $feed .= " <description>".htmlspecialchars($this->description)."</description>\n"; |
|
852 | + $feed .= " <link>".$this->link."</link>\n"; |
|
853 | + if ($this->image != null) { |
|
854 | + $feed .= " <image rdf:resource=\"".$this->image->url."\" />\n"; |
|
855 | 855 | } |
856 | 856 | $now = new FeedDate(); |
857 | - $feed.= " <dc:date>".htmlspecialchars($now->iso8601())."</dc:date>\n"; |
|
858 | - $feed.= " <items>\n"; |
|
859 | - $feed.= " <rdf:Seq>\n"; |
|
860 | - for ($i=0;$i<count($this->items);$i++) { |
|
861 | - $feed.= " <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
857 | + $feed .= " <dc:date>".htmlspecialchars($now->iso8601())."</dc:date>\n"; |
|
858 | + $feed .= " <items>\n"; |
|
859 | + $feed .= " <rdf:Seq>\n"; |
|
860 | + for ($i = 0; $i<count($this->items); $i++) { |
|
861 | + $feed .= " <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
862 | 862 | } |
863 | - $feed.= " </rdf:Seq>\n"; |
|
864 | - $feed.= " </items>\n"; |
|
865 | - $feed.= " </channel>\n"; |
|
866 | - if ($this->image!=null) { |
|
867 | - $feed.= " <image rdf:about=\"".$this->image->url."\">\n"; |
|
868 | - $feed.= " <title>".$this->image->title."</title>\n"; |
|
869 | - $feed.= " <link>".$this->image->link."</link>\n"; |
|
870 | - $feed.= " <url>".$this->image->url."</url>\n"; |
|
871 | - $feed.= " </image>\n"; |
|
863 | + $feed .= " </rdf:Seq>\n"; |
|
864 | + $feed .= " </items>\n"; |
|
865 | + $feed .= " </channel>\n"; |
|
866 | + if ($this->image != null) { |
|
867 | + $feed .= " <image rdf:about=\"".$this->image->url."\">\n"; |
|
868 | + $feed .= " <title>".$this->image->title."</title>\n"; |
|
869 | + $feed .= " <link>".$this->image->link."</link>\n"; |
|
870 | + $feed .= " <url>".$this->image->url."</url>\n"; |
|
871 | + $feed .= " </image>\n"; |
|
872 | 872 | } |
873 | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
|
873 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
|
874 | 874 | |
875 | - for ($i=0;$i<count($this->items);$i++) { |
|
876 | - $feed.= " <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
875 | + for ($i = 0; $i<count($this->items); $i++) { |
|
876 | + $feed .= " <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
877 | 877 | //$feed.= " <dc:type>Posting</dc:type>\n"; |
878 | - $feed.= " <dc:format>text/html</dc:format>\n"; |
|
879 | - if ($this->items[$i]->date!=null) { |
|
878 | + $feed .= " <dc:format>text/html</dc:format>\n"; |
|
879 | + if ($this->items[$i]->date != null) { |
|
880 | 880 | $itemDate = new FeedDate($this->items[$i]->date); |
881 | - $feed.= " <dc:date>".htmlspecialchars($itemDate->iso8601())."</dc:date>\n"; |
|
881 | + $feed .= " <dc:date>".htmlspecialchars($itemDate->iso8601())."</dc:date>\n"; |
|
882 | 882 | } |
883 | - if ($this->items[$i]->source!="") { |
|
884 | - $feed.= " <dc:source>".htmlspecialchars($this->items[$i]->source)."</dc:source>\n"; |
|
883 | + if ($this->items[$i]->source != "") { |
|
884 | + $feed .= " <dc:source>".htmlspecialchars($this->items[$i]->source)."</dc:source>\n"; |
|
885 | 885 | } |
886 | - if ($this->items[$i]->author!="") { |
|
887 | - $feed.= " <dc:creator>".htmlspecialchars($this->items[$i]->author)."</dc:creator>\n"; |
|
886 | + if ($this->items[$i]->author != "") { |
|
887 | + $feed .= " <dc:creator>".htmlspecialchars($this->items[$i]->author)."</dc:creator>\n"; |
|
888 | 888 | } |
889 | - $feed.= " <title>".htmlspecialchars(strip_tags(strtr($this->items[$i]->title,"\n\r"," ")))."</title>\n"; |
|
890 | - $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
891 | - $feed.= " <description>".htmlspecialchars($this->items[$i]->description)."</description>\n"; |
|
892 | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
893 | - $feed.= " </item>\n"; |
|
889 | + $feed .= " <title>".htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", " ")))."</title>\n"; |
|
890 | + $feed .= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
891 | + $feed .= " <description>".htmlspecialchars($this->items[$i]->description)."</description>\n"; |
|
892 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
893 | + $feed .= " </item>\n"; |
|
894 | 894 | } |
895 | - $feed.= "</rdf:RDF>\n"; |
|
895 | + $feed .= "</rdf:RDF>\n"; |
|
896 | 896 | return $feed; |
897 | 897 | } |
898 | 898 | } |
@@ -934,78 +934,78 @@ discard block |
||
934 | 934 | */ |
935 | 935 | function createFeed() { |
936 | 936 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
937 | - $feed.= $this->_createGeneratorComment(); |
|
938 | - $feed.= $this->_createStylesheetReferences(); |
|
939 | - $feed.= "<rss version=\"".$this->RSSVersion."\">\n"; |
|
940 | - $feed.= " <channel>\n"; |
|
941 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n"; |
|
937 | + $feed .= $this->_createGeneratorComment(); |
|
938 | + $feed .= $this->_createStylesheetReferences(); |
|
939 | + $feed .= "<rss version=\"".$this->RSSVersion."\">\n"; |
|
940 | + $feed .= " <channel>\n"; |
|
941 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n"; |
|
942 | 942 | $this->descriptionTruncSize = 500; |
943 | - $feed.= " <description>".$this->getDescription()."</description>\n"; |
|
944 | - $feed.= " <link>".$this->link."</link>\n"; |
|
943 | + $feed .= " <description>".$this->getDescription()."</description>\n"; |
|
944 | + $feed .= " <link>".$this->link."</link>\n"; |
|
945 | 945 | $now = new FeedDate(); |
946 | - $feed.= " <lastBuildDate>".htmlspecialchars($now->rfc822())."</lastBuildDate>\n"; |
|
947 | - $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
948 | - |
|
949 | - if ($this->image!=null) { |
|
950 | - $feed.= " <image>\n"; |
|
951 | - $feed.= " <url>".$this->image->url."</url>\n"; |
|
952 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->image->title),100)."</title>\n"; |
|
953 | - $feed.= " <link>".$this->image->link."</link>\n"; |
|
954 | - if ($this->image->width!="") { |
|
955 | - $feed.= " <width>".$this->image->width."</width>\n"; |
|
946 | + $feed .= " <lastBuildDate>".htmlspecialchars($now->rfc822())."</lastBuildDate>\n"; |
|
947 | + $feed .= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
948 | + |
|
949 | + if ($this->image != null) { |
|
950 | + $feed .= " <image>\n"; |
|
951 | + $feed .= " <url>".$this->image->url."</url>\n"; |
|
952 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)."</title>\n"; |
|
953 | + $feed .= " <link>".$this->image->link."</link>\n"; |
|
954 | + if ($this->image->width != "") { |
|
955 | + $feed .= " <width>".$this->image->width."</width>\n"; |
|
956 | 956 | } |
957 | - if ($this->image->height!="") { |
|
958 | - $feed.= " <height>".$this->image->height."</height>\n"; |
|
957 | + if ($this->image->height != "") { |
|
958 | + $feed .= " <height>".$this->image->height."</height>\n"; |
|
959 | 959 | } |
960 | - if ($this->image->description!="") { |
|
961 | - $feed.= " <description>".$this->image->getDescription()."</description>\n"; |
|
960 | + if ($this->image->description != "") { |
|
961 | + $feed .= " <description>".$this->image->getDescription()."</description>\n"; |
|
962 | 962 | } |
963 | - $feed.= " </image>\n"; |
|
963 | + $feed .= " </image>\n"; |
|
964 | 964 | } |
965 | - if ($this->language!="") { |
|
966 | - $feed.= " <language>".$this->language."</language>\n"; |
|
965 | + if ($this->language != "") { |
|
966 | + $feed .= " <language>".$this->language."</language>\n"; |
|
967 | 967 | } |
968 | - if ($this->copyright!="") { |
|
969 | - $feed.= " <copyright>".FeedCreator::iTrunc(htmlspecialchars($this->copyright),100)."</copyright>\n"; |
|
968 | + if ($this->copyright != "") { |
|
969 | + $feed .= " <copyright>".FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)."</copyright>\n"; |
|
970 | 970 | } |
971 | - if ($this->editor!="") { |
|
972 | - $feed.= " <managingEditor>".FeedCreator::iTrunc(htmlspecialchars($this->editor),100)."</managingEditor>\n"; |
|
971 | + if ($this->editor != "") { |
|
972 | + $feed .= " <managingEditor>".FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)."</managingEditor>\n"; |
|
973 | 973 | } |
974 | - if ($this->webmaster!="") { |
|
975 | - $feed.= " <webMaster>".FeedCreator::iTrunc(htmlspecialchars($this->webmaster),100)."</webMaster>\n"; |
|
974 | + if ($this->webmaster != "") { |
|
975 | + $feed .= " <webMaster>".FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)."</webMaster>\n"; |
|
976 | 976 | } |
977 | - if ($this->pubDate!="") { |
|
977 | + if ($this->pubDate != "") { |
|
978 | 978 | $pubDate = new FeedDate($this->pubDate); |
979 | - $feed.= " <pubDate>".htmlspecialchars($pubDate->rfc822())."</pubDate>\n"; |
|
979 | + $feed .= " <pubDate>".htmlspecialchars($pubDate->rfc822())."</pubDate>\n"; |
|
980 | 980 | } |
981 | - if ($this->category!="") { |
|
982 | - $feed.= " <category>".htmlspecialchars($this->category)."</category>\n"; |
|
981 | + if ($this->category != "") { |
|
982 | + $feed .= " <category>".htmlspecialchars($this->category)."</category>\n"; |
|
983 | 983 | } |
984 | - if ($this->docs!="") { |
|
985 | - $feed.= " <docs>".FeedCreator::iTrunc(htmlspecialchars($this->docs),500)."</docs>\n"; |
|
984 | + if ($this->docs != "") { |
|
985 | + $feed .= " <docs>".FeedCreator::iTrunc(htmlspecialchars($this->docs), 500)."</docs>\n"; |
|
986 | 986 | } |
987 | - if ($this->ttl!="") { |
|
988 | - $feed.= " <ttl>".htmlspecialchars($this->ttl)."</ttl>\n"; |
|
987 | + if ($this->ttl != "") { |
|
988 | + $feed .= " <ttl>".htmlspecialchars($this->ttl)."</ttl>\n"; |
|
989 | 989 | } |
990 | - if ($this->rating!="") { |
|
991 | - $feed.= " <rating>".FeedCreator::iTrunc(htmlspecialchars($this->rating),500)."</rating>\n"; |
|
990 | + if ($this->rating != "") { |
|
991 | + $feed .= " <rating>".FeedCreator::iTrunc(htmlspecialchars($this->rating), 500)."</rating>\n"; |
|
992 | 992 | } |
993 | - if ($this->skipHours!="") { |
|
994 | - $feed.= " <skipHours>".htmlspecialchars($this->skipHours)."</skipHours>\n"; |
|
993 | + if ($this->skipHours != "") { |
|
994 | + $feed .= " <skipHours>".htmlspecialchars($this->skipHours)."</skipHours>\n"; |
|
995 | 995 | } |
996 | - if ($this->skipDays!="") { |
|
997 | - $feed.= " <skipDays>".htmlspecialchars($this->skipDays)."</skipDays>\n"; |
|
996 | + if ($this->skipDays != "") { |
|
997 | + $feed .= " <skipDays>".htmlspecialchars($this->skipDays)."</skipDays>\n"; |
|
998 | 998 | } |
999 | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
|
999 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
|
1000 | 1000 | |
1001 | - for ($i=0;$i<count($this->items);$i++) { |
|
1002 | - $feed.= " <item>\n"; |
|
1003 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n"; |
|
1004 | - $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
1005 | - $feed.= " <description>".$this->items[$i]->getDescription()."</description>\n"; |
|
1001 | + for ($i = 0; $i<count($this->items); $i++) { |
|
1002 | + $feed .= " <item>\n"; |
|
1003 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)."</title>\n"; |
|
1004 | + $feed .= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
1005 | + $feed .= " <description>".$this->items[$i]->getDescription()."</description>\n"; |
|
1006 | 1006 | |
1007 | - if ($this->items[$i]->author!="") { |
|
1008 | - $feed.= " <author>".htmlspecialchars($this->items[$i]->author)."</author>\n"; |
|
1007 | + if ($this->items[$i]->author != "") { |
|
1008 | + $feed .= " <author>".htmlspecialchars($this->items[$i]->author)."</author>\n"; |
|
1009 | 1009 | } |
1010 | 1010 | /* |
1011 | 1011 | // on hold |
@@ -1013,24 +1013,24 @@ discard block |
||
1013 | 1013 | $feed.= " <source>".htmlspecialchars($this->items[$i]->source)."</source>\n"; |
1014 | 1014 | } |
1015 | 1015 | */ |
1016 | - if ($this->items[$i]->category!="") { |
|
1017 | - $feed.= " <category>".htmlspecialchars($this->items[$i]->category)."</category>\n"; |
|
1016 | + if ($this->items[$i]->category != "") { |
|
1017 | + $feed .= " <category>".htmlspecialchars($this->items[$i]->category)."</category>\n"; |
|
1018 | 1018 | } |
1019 | - if ($this->items[$i]->comments!="") { |
|
1020 | - $feed.= " <comments>".htmlspecialchars($this->items[$i]->comments)."</comments>\n"; |
|
1019 | + if ($this->items[$i]->comments != "") { |
|
1020 | + $feed .= " <comments>".htmlspecialchars($this->items[$i]->comments)."</comments>\n"; |
|
1021 | 1021 | } |
1022 | - if ($this->items[$i]->date!="") { |
|
1022 | + if ($this->items[$i]->date != "") { |
|
1023 | 1023 | $itemDate = new FeedDate($this->items[$i]->date); |
1024 | - $feed.= " <pubDate>".htmlspecialchars($itemDate->rfc822())."</pubDate>\n"; |
|
1024 | + $feed .= " <pubDate>".htmlspecialchars($itemDate->rfc822())."</pubDate>\n"; |
|
1025 | 1025 | } |
1026 | - if ($this->items[$i]->guid!="") { |
|
1027 | - $feed.= " <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n"; |
|
1026 | + if ($this->items[$i]->guid != "") { |
|
1027 | + $feed .= " <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n"; |
|
1028 | 1028 | } |
1029 | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
1030 | - $feed.= " </item>\n"; |
|
1029 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
1030 | + $feed .= " </item>\n"; |
|
1031 | 1031 | } |
1032 | - $feed.= " </channel>\n"; |
|
1033 | - $feed.= "</rss>\n"; |
|
1032 | + $feed .= " </channel>\n"; |
|
1033 | + $feed .= "</rss>\n"; |
|
1034 | 1034 | return $feed; |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1069,35 +1069,35 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | function createFeed() { |
1071 | 1071 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
1072 | - $feed.= $this->_createStylesheetReferences(); |
|
1073 | - $feed.= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
|
1074 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n"; |
|
1072 | + $feed .= $this->_createStylesheetReferences(); |
|
1073 | + $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
|
1074 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n"; |
|
1075 | 1075 | $this->truncSize = 500; |
1076 | - $feed.= " <subtitle>".$this->getDescription()."</subtitle>\n"; |
|
1077 | - $feed.= " <link>".$this->link."</link>\n"; |
|
1078 | - for ($i=0;$i<count($this->items);$i++) { |
|
1079 | - $feed.= " <entry>\n"; |
|
1080 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n"; |
|
1081 | - $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
1076 | + $feed .= " <subtitle>".$this->getDescription()."</subtitle>\n"; |
|
1077 | + $feed .= " <link>".$this->link."</link>\n"; |
|
1078 | + for ($i = 0; $i<count($this->items); $i++) { |
|
1079 | + $feed .= " <entry>\n"; |
|
1080 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)."</title>\n"; |
|
1081 | + $feed .= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
1082 | 1082 | $itemDate = new FeedDate($this->items[$i]->date); |
1083 | - $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
1084 | - $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
1085 | - $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
1086 | - $feed.= " <id>".htmlspecialchars($this->items[$i]->guid)."</id>\n"; |
|
1087 | - if ($this->items[$i]->author!="") { |
|
1088 | - $feed.= " <author>\n"; |
|
1089 | - $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
1090 | - if ($this->items[$i]->authorEmail!="") { |
|
1091 | - $feed.= " <email>".$this->items[$i]->authorEmail."</email>\n"; |
|
1083 | + $feed .= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
1084 | + $feed .= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
1085 | + $feed .= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
1086 | + $feed .= " <id>".htmlspecialchars($this->items[$i]->guid)."</id>\n"; |
|
1087 | + if ($this->items[$i]->author != "") { |
|
1088 | + $feed .= " <author>\n"; |
|
1089 | + $feed .= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
1090 | + if ($this->items[$i]->authorEmail != "") { |
|
1091 | + $feed .= " <email>".$this->items[$i]->authorEmail."</email>\n"; |
|
1092 | 1092 | } |
1093 | - $feed.=" </author>\n"; |
|
1093 | + $feed .= " </author>\n"; |
|
1094 | 1094 | } |
1095 | - $feed.= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
|
1096 | - $feed.= " <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()."</div>\n"; |
|
1097 | - $feed.= " </content>\n"; |
|
1098 | - $feed.= " </entry>\n"; |
|
1095 | + $feed .= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
|
1096 | + $feed .= " <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()."</div>\n"; |
|
1097 | + $feed .= " </content>\n"; |
|
1098 | + $feed .= " </entry>\n"; |
|
1099 | 1099 | } |
1100 | - $feed.= "</feed>\n"; |
|
1100 | + $feed .= "</feed>\n"; |
|
1101 | 1101 | return $feed; |
1102 | 1102 | } |
1103 | 1103 | } |
@@ -1128,53 +1128,53 @@ discard block |
||
1128 | 1128 | |
1129 | 1129 | function createFeed() { |
1130 | 1130 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
1131 | - $feed.= $this->_createGeneratorComment(); |
|
1132 | - $feed.= $this->_createStylesheetReferences(); |
|
1133 | - $feed.= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
|
1134 | - if ($this->language!="") { |
|
1135 | - $feed.= " xml:lang=\"".$this->language."\""; |
|
1131 | + $feed .= $this->_createGeneratorComment(); |
|
1132 | + $feed .= $this->_createStylesheetReferences(); |
|
1133 | + $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
|
1134 | + if ($this->language != "") { |
|
1135 | + $feed .= " xml:lang=\"".$this->language."\""; |
|
1136 | 1136 | } |
1137 | - $feed.= ">\n"; |
|
1138 | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
1139 | - $feed.= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; |
|
1140 | - $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
|
1141 | - $feed.= " <id>".htmlspecialchars($this->link)."</id>\n"; |
|
1137 | + $feed .= ">\n"; |
|
1138 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
1139 | + $feed .= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; |
|
1140 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
|
1141 | + $feed .= " <id>".htmlspecialchars($this->link)."</id>\n"; |
|
1142 | 1142 | $now = new FeedDate(); |
1143 | - $feed.= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; |
|
1144 | - if ($this->editor!="") { |
|
1145 | - $feed.= " <author>\n"; |
|
1146 | - $feed.= " <name>".$this->editor."</name>\n"; |
|
1147 | - if ($this->editorEmail!="") { |
|
1148 | - $feed.= " <email>".$this->editorEmail."</email>\n"; |
|
1143 | + $feed .= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; |
|
1144 | + if ($this->editor != "") { |
|
1145 | + $feed .= " <author>\n"; |
|
1146 | + $feed .= " <name>".$this->editor."</name>\n"; |
|
1147 | + if ($this->editorEmail != "") { |
|
1148 | + $feed .= " <email>".$this->editorEmail."</email>\n"; |
|
1149 | 1149 | } |
1150 | - $feed.= " </author>\n"; |
|
1150 | + $feed .= " </author>\n"; |
|
1151 | 1151 | } |
1152 | - $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
1153 | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
|
1154 | - for ($i=0;$i<count($this->items);$i++) { |
|
1155 | - $feed.= " <entry>\n"; |
|
1156 | - $feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
|
1157 | - $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
1158 | - if ($this->items[$i]->date=="") { |
|
1152 | + $feed .= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
1153 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
|
1154 | + for ($i = 0; $i<count($this->items); $i++) { |
|
1155 | + $feed .= " <entry>\n"; |
|
1156 | + $feed .= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
|
1157 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
1158 | + if ($this->items[$i]->date == "") { |
|
1159 | 1159 | $this->items[$i]->date = time(); |
1160 | 1160 | } |
1161 | 1161 | $itemDate = new FeedDate($this->items[$i]->date); |
1162 | - $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
1163 | - $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
1164 | - $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
1165 | - $feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
|
1166 | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
1167 | - if ($this->items[$i]->author!="") { |
|
1168 | - $feed.= " <author>\n"; |
|
1169 | - $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
1170 | - $feed.= " </author>\n"; |
|
1162 | + $feed .= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
1163 | + $feed .= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
1164 | + $feed .= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
1165 | + $feed .= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
|
1166 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
1167 | + if ($this->items[$i]->author != "") { |
|
1168 | + $feed .= " <author>\n"; |
|
1169 | + $feed .= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
1170 | + $feed .= " </author>\n"; |
|
1171 | 1171 | } |
1172 | - if ($this->items[$i]->description!="") { |
|
1173 | - $feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
|
1172 | + if ($this->items[$i]->description != "") { |
|
1173 | + $feed .= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
|
1174 | 1174 | } |
1175 | - $feed.= " </entry>\n"; |
|
1175 | + $feed .= " </entry>\n"; |
|
1176 | 1176 | } |
1177 | - $feed.= "</feed>\n"; |
|
1177 | + $feed .= "</feed>\n"; |
|
1178 | 1178 | return $feed; |
1179 | 1179 | } |
1180 | 1180 | } |
@@ -1195,25 +1195,25 @@ discard block |
||
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | function qp_enc($input = "", $line_max = 76) { |
1198 | - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
1198 | + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
1199 | 1199 | $lines = preg_split("/(?:\r\n|\r|\n)/", $input); |
1200 | 1200 | $eol = "\r\n"; |
1201 | 1201 | $escape = "="; |
1202 | 1202 | $output = ""; |
1203 | - while( list(, $line) = each($lines) ) { |
|
1203 | + while (list(, $line) = each($lines)) { |
|
1204 | 1204 | //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary |
1205 | 1205 | $linlen = strlen($line); |
1206 | 1206 | $newline = ""; |
1207 | - for($i = 0; $i < $linlen; $i++) { |
|
1207 | + for ($i = 0; $i<$linlen; $i++) { |
|
1208 | 1208 | $c = substr($line, $i, 1); |
1209 | 1209 | $dec = ord($c); |
1210 | - if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only |
|
1210 | + if (($dec == 32) && ($i == ($linlen-1))) { // convert space at eol only |
|
1211 | 1211 | $c = "=20"; |
1212 | - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required |
|
1212 | + } elseif (($dec == 61) || ($dec<32) || ($dec>126)) { // always encode "\t", which is *not* required |
|
1213 | 1213 | $h2 = floor($dec/16); $h1 = floor($dec%16); |
1214 | 1214 | $c = $escape.$hex["$h2"].$hex["$h1"]; |
1215 | 1215 | } |
1216 | - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted |
|
1216 | + if ((strlen($newline)+strlen($c))>=$line_max) { // CRLF is not counted |
|
1217 | 1217 | $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay |
1218 | 1218 | $newline = ""; |
1219 | 1219 | } |
@@ -1230,26 +1230,26 @@ discard block |
||
1230 | 1230 | * @return string the feed's complete text |
1231 | 1231 | */ |
1232 | 1232 | function createFeed() { |
1233 | - for ($i=0;$i<count($this->items);$i++) { |
|
1234 | - if ($this->items[$i]->author!="") { |
|
1233 | + for ($i = 0; $i<count($this->items); $i++) { |
|
1234 | + if ($this->items[$i]->author != "") { |
|
1235 | 1235 | $from = $this->items[$i]->author; |
1236 | - } else { |
|
1236 | + }else { |
|
1237 | 1237 | $from = $this->title; |
1238 | 1238 | } |
1239 | 1239 | $itemDate = new FeedDate($this->items[$i]->date); |
1240 | - $feed.= "From ".strtr(MBOXCreator::qp_enc($from)," ","_")." ".date("D M d H:i:s Y",$itemDate->unix())."\n"; |
|
1241 | - $feed.= "Content-Type: text/plain;\n"; |
|
1242 | - $feed.= " charset=\"".$this->encoding."\"\n"; |
|
1243 | - $feed.= "Content-Transfer-Encoding: quoted-printable\n"; |
|
1244 | - $feed.= "Content-Type: text/plain\n"; |
|
1245 | - $feed.= "From: \"".MBOXCreator::qp_enc($from)."\"\n"; |
|
1246 | - $feed.= "Date: ".$itemDate->rfc822()."\n"; |
|
1247 | - $feed.= "Subject: ".MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title,100))."\n"; |
|
1248 | - $feed.= "\n"; |
|
1240 | + $feed .= "From ".strtr(MBOXCreator::qp_enc($from), " ", "_")." ".date("D M d H:i:s Y", $itemDate->unix())."\n"; |
|
1241 | + $feed .= "Content-Type: text/plain;\n"; |
|
1242 | + $feed .= " charset=\"".$this->encoding."\"\n"; |
|
1243 | + $feed .= "Content-Transfer-Encoding: quoted-printable\n"; |
|
1244 | + $feed .= "Content-Type: text/plain\n"; |
|
1245 | + $feed .= "From: \"".MBOXCreator::qp_enc($from)."\"\n"; |
|
1246 | + $feed .= "Date: ".$itemDate->rfc822()."\n"; |
|
1247 | + $feed .= "Subject: ".MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100))."\n"; |
|
1248 | + $feed .= "\n"; |
|
1249 | 1249 | $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); |
1250 | - $feed.= preg_replace("~\nFrom ([^\n]*)(\n?)~","\n>From $1$2\n",$body); |
|
1251 | - $feed.= "\n"; |
|
1252 | - $feed.= "\n"; |
|
1250 | + $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body); |
|
1251 | + $feed .= "\n"; |
|
1252 | + $feed .= "\n"; |
|
1253 | 1253 | } |
1254 | 1254 | return $feed; |
1255 | 1255 | } |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | */ |
1263 | 1263 | function _generateFilename() { |
1264 | 1264 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
1265 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".mbox"; |
|
1265 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".mbox"; |
|
1266 | 1266 | } |
1267 | 1267 | } |
1268 | 1268 | |
@@ -1282,38 +1282,38 @@ discard block |
||
1282 | 1282 | |
1283 | 1283 | function createFeed() { |
1284 | 1284 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
1285 | - $feed.= $this->_createGeneratorComment(); |
|
1286 | - $feed.= $this->_createStylesheetReferences(); |
|
1287 | - $feed.= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
|
1288 | - $feed.= " <head>\n"; |
|
1289 | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
1290 | - if ($this->pubDate!="") { |
|
1285 | + $feed .= $this->_createGeneratorComment(); |
|
1286 | + $feed .= $this->_createStylesheetReferences(); |
|
1287 | + $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
|
1288 | + $feed .= " <head>\n"; |
|
1289 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
1290 | + if ($this->pubDate != "") { |
|
1291 | 1291 | $date = new FeedDate($this->pubDate); |
1292 | - $feed.= " <dateCreated>".$date->rfc822()."</dateCreated>\n"; |
|
1292 | + $feed .= " <dateCreated>".$date->rfc822()."</dateCreated>\n"; |
|
1293 | 1293 | } |
1294 | - if ($this->lastBuildDate!="") { |
|
1294 | + if ($this->lastBuildDate != "") { |
|
1295 | 1295 | $date = new FeedDate($this->lastBuildDate); |
1296 | - $feed.= " <dateModified>".$date->rfc822()."</dateModified>\n"; |
|
1296 | + $feed .= " <dateModified>".$date->rfc822()."</dateModified>\n"; |
|
1297 | 1297 | } |
1298 | - if ($this->editor!="") { |
|
1299 | - $feed.= " <ownerName>".$this->editor."</ownerName>\n"; |
|
1298 | + if ($this->editor != "") { |
|
1299 | + $feed .= " <ownerName>".$this->editor."</ownerName>\n"; |
|
1300 | 1300 | } |
1301 | - if ($this->editorEmail!="") { |
|
1302 | - $feed.= " <ownerEmail>".$this->editorEmail."</ownerEmail>\n"; |
|
1301 | + if ($this->editorEmail != "") { |
|
1302 | + $feed .= " <ownerEmail>".$this->editorEmail."</ownerEmail>\n"; |
|
1303 | 1303 | } |
1304 | - $feed.= " </head>\n"; |
|
1305 | - $feed.= " <body>\n"; |
|
1306 | - for ($i=0;$i<count($this->items);$i++) { |
|
1307 | - $feed.= " <outline type=\"rss\" "; |
|
1308 | - $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title,"\n\r"," "))); |
|
1309 | - $feed.= " title=\"".$title."\""; |
|
1310 | - $feed.= " text=\"".$title."\""; |
|
1304 | + $feed .= " </head>\n"; |
|
1305 | + $feed .= " <body>\n"; |
|
1306 | + for ($i = 0; $i<count($this->items); $i++) { |
|
1307 | + $feed .= " <outline type=\"rss\" "; |
|
1308 | + $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", " "))); |
|
1309 | + $feed .= " title=\"".$title."\""; |
|
1310 | + $feed .= " text=\"".$title."\""; |
|
1311 | 1311 | //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; |
1312 | - $feed.= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; |
|
1313 | - $feed.= "/>\n"; |
|
1312 | + $feed .= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; |
|
1313 | + $feed .= "/>\n"; |
|
1314 | 1314 | } |
1315 | - $feed.= " </body>\n"; |
|
1316 | - $feed.= "</opml>\n"; |
|
1315 | + $feed .= " </body>\n"; |
|
1316 | + $feed .= "</opml>\n"; |
|
1317 | 1317 | return $feed; |
1318 | 1318 | } |
1319 | 1319 | } |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | /** |
1344 | 1344 | * Contains HTML to be output at the end of the feed's html representation. |
1345 | 1345 | */ |
1346 | - var $footer ; |
|
1346 | + var $footer; |
|
1347 | 1347 | |
1348 | 1348 | /** |
1349 | 1349 | * Contains HTML to be output between entries. A separator is only used in |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | */ |
1363 | 1363 | var $openInNewWindow = true; |
1364 | 1364 | |
1365 | - var $imageAlign ="right"; |
|
1365 | + var $imageAlign = "right"; |
|
1366 | 1366 | |
1367 | 1367 | /** |
1368 | 1368 | * In case of very simple output you may want to get rid of the style tags, |
@@ -1371,7 +1371,7 @@ discard block |
||
1371 | 1371 | * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored |
1372 | 1372 | * in the function createFeed(). |
1373 | 1373 | */ |
1374 | - var $stylelessOutput =""; |
|
1374 | + var $stylelessOutput = ""; |
|
1375 | 1375 | |
1376 | 1376 | /** |
1377 | 1377 | * Writes the HTML. |
@@ -1379,12 +1379,12 @@ discard block |
||
1379 | 1379 | */ |
1380 | 1380 | function createFeed() { |
1381 | 1381 | // if there is styleless output, use the content of this variable and ignore the rest |
1382 | - if ($this->stylelessOutput!="") { |
|
1382 | + if ($this->stylelessOutput != "") { |
|
1383 | 1383 | return $this->stylelessOutput; |
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | //if no stylePrefix is set, generate it yourself depending on the script name |
1387 | - if ($this->stylePrefix=="") { |
|
1387 | + if ($this->stylePrefix == "") { |
|
1388 | 1388 | $this->stylePrefix = str_replace(".", "_", $this->_generateFilename())."_"; |
1389 | 1389 | } |
1390 | 1390 | |
@@ -1395,24 +1395,24 @@ discard block |
||
1395 | 1395 | |
1396 | 1396 | // use this array to put the lines in and implode later with "document.write" javascript |
1397 | 1397 | $feedArray = array(); |
1398 | - if ($this->image!=null) { |
|
1398 | + if ($this->image != null) { |
|
1399 | 1399 | $imageStr = "<a href='".$this->image->link."'".$targetInsert.">". |
1400 | 1400 | "<img src='".$this->image->url."' border='0' alt='". |
1401 | - FeedCreator::iTrunc(htmlspecialchars($this->image->title),100). |
|
1401 | + FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100). |
|
1402 | 1402 | "' align='".$this->imageAlign."' "; |
1403 | 1403 | if ($this->image->width) { |
1404 | - $imageStr .=" width='".$this->image->width. "' "; |
|
1404 | + $imageStr .= " width='".$this->image->width."' "; |
|
1405 | 1405 | } |
1406 | 1406 | if ($this->image->height) { |
1407 | - $imageStr .=" height='".$this->image->height."' "; |
|
1407 | + $imageStr .= " height='".$this->image->height."' "; |
|
1408 | 1408 | } |
1409 | - $imageStr .="/></a>"; |
|
1409 | + $imageStr .= "/></a>"; |
|
1410 | 1410 | $feedArray[] = $imageStr; |
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | if ($this->title) { |
1414 | 1414 | $feedArray[] = "<div class='".$this->stylePrefix."title'><a href='".$this->link."' ".$targetInsert." class='".$this->stylePrefix."title'>". |
1415 | - FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</a></div>"; |
|
1415 | + FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</a></div>"; |
|
1416 | 1416 | } |
1417 | 1417 | if ($this->getDescription()) { |
1418 | 1418 | $feedArray[] = "<div class='".$this->stylePrefix."description'>". |
@@ -1424,8 +1424,8 @@ discard block |
||
1424 | 1424 | $feedArray[] = "<div class='".$this->stylePrefix."header'>".$this->header."</div>"; |
1425 | 1425 | } |
1426 | 1426 | |
1427 | - for ($i=0;$i<count($this->items);$i++) { |
|
1428 | - if ($this->separator and $i > 0) { |
|
1427 | + for ($i = 0; $i<count($this->items); $i++) { |
|
1428 | + if ($this->separator and $i>0) { |
|
1429 | 1429 | $feedArray[] = "<div class='".$this->stylePrefix."separator'>".$this->separator."</div>"; |
1430 | 1430 | } |
1431 | 1431 | |
@@ -1433,12 +1433,12 @@ discard block |
||
1433 | 1433 | if ($this->items[$i]->link) { |
1434 | 1434 | $feedArray[] = |
1435 | 1435 | "<div class='".$this->stylePrefix."item_title'><a href='".$this->items[$i]->link."' class='".$this->stylePrefix. |
1436 | - "item_title'".$targetInsert.">".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100). |
|
1436 | + "item_title'".$targetInsert.">".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100). |
|
1437 | 1437 | "</a></div>"; |
1438 | - } else { |
|
1438 | + }else { |
|
1439 | 1439 | $feedArray[] = |
1440 | 1440 | "<div class='".$this->stylePrefix."item_title'>". |
1441 | - FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100). |
|
1441 | + FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100). |
|
1442 | 1442 | "</div>"; |
1443 | 1443 | } |
1444 | 1444 | } |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | $feedArray[] = "<div class='".$this->stylePrefix."footer'>".$this->footer."</div>"; |
1454 | 1454 | } |
1455 | 1455 | |
1456 | - $feed= "".join($feedArray, "\r\n"); |
|
1456 | + $feed = "".join($feedArray, "\r\n"); |
|
1457 | 1457 | return $feed; |
1458 | 1458 | } |
1459 | 1459 | |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | */ |
1467 | 1467 | function _generateFilename() { |
1468 | 1468 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
1469 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".html"; |
|
1469 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".html"; |
|
1470 | 1470 | } |
1471 | 1471 | } |
1472 | 1472 | |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | function createFeed() |
1488 | 1488 | { |
1489 | 1489 | $feed = parent::createFeed(); |
1490 | - $feedArray = explode("\n",$feed); |
|
1490 | + $feedArray = explode("\n", $feed); |
|
1491 | 1491 | |
1492 | 1492 | $jsFeed = ""; |
1493 | 1493 | foreach ($feedArray as $value) { |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | */ |
1506 | 1506 | function _generateFilename() { |
1507 | 1507 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
1508 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".js"; |
|
1508 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".js"; |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | // Project: Article Project // |
26 | 26 | // ------------------------------------------------------------------------ // |
27 | 27 | include "header.php"; |
28 | -$article_id = empty($_GET['article'])?0:intval($_GET['article']); |
|
29 | -if(empty($article_id)) return; |
|
30 | -if(planet_getcookie("art_".$article_id)>0) return; |
|
31 | -$article_handler =& xoops_getmodulehandler('article', $xoopsModule->getVar("dirname")); |
|
32 | -$article_obj =& $article_handler->get($article_id); |
|
28 | +$article_id = empty($_GET['article']) ? 0 : intval($_GET['article']); |
|
29 | +if (empty($article_id)) return; |
|
30 | +if (planet_getcookie("art_".$article_id)>0) return; |
|
31 | +$article_handler = & xoops_getmodulehandler('article', $xoopsModule->getVar("dirname")); |
|
32 | +$article_obj = & $article_handler->get($article_id); |
|
33 | 33 | $article_obj->setVar("art_views", $article_obj->getVar("art_views")+1, true); |
34 | 34 | $article_handler->insert($article_obj, true); |
35 | 35 | planet_setcookie("art_".$article_id, time()); |
@@ -31,37 +31,37 @@ discard block |
||
31 | 31 | * The notification detection scripts should be removed once absolute url is used in notification_select.php |
32 | 32 | * |
33 | 33 | */ |
34 | -if(preg_match("/(\/comment_[^\.]*\.php\?.*=.*)/i", $_SERVER["REQUEST_URI"], $matches)){ |
|
34 | +if (preg_match("/(\/comment_[^\.]*\.php\?.*=.*)/i", $_SERVER["REQUEST_URI"], $matches)) { |
|
35 | 35 | header("location: ".XOOPS_URL."/modules/".$GLOBALS["moddirname"].$matches[1]); |
36 | 36 | exit(); |
37 | 37 | } |
38 | -if(preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)){ |
|
38 | +if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) { |
|
39 | 39 | include XOOPS_ROOT_PATH.'/include/notification_update.php'; |
40 | 40 | exit(); |
41 | 41 | } |
42 | 42 | |
43 | -if($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)){ |
|
43 | +if ($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)) { |
|
44 | 44 | $args["article"] = @$args_num[0]; |
45 | 45 | $args["blog"] = @$args["blog"]; |
46 | 46 | } |
47 | 47 | |
48 | -$article_id = intval( empty($_GET["article"])?@$args["article"]:$_GET["article"] ); |
|
49 | -$blog_id = intval( empty($_GET["blog"])?@$args["blog"]:$_GET["blog"] ); |
|
48 | +$article_id = intval(empty($_GET["article"]) ? @$args["article"] : $_GET["article"]); |
|
49 | +$blog_id = intval(empty($_GET["blog"]) ? @$args["blog"] : $_GET["blog"]); |
|
50 | 50 | |
51 | -$article_handler =& xoops_getmodulehandler("article", $GLOBALS["moddirname"]); |
|
52 | -$blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
|
53 | -$article_obj =& $article_handler->get($article_id); |
|
54 | -$blog_obj =& $blog_handler->get($article_obj->getVar("blog_id")); |
|
51 | +$article_handler = & xoops_getmodulehandler("article", $GLOBALS["moddirname"]); |
|
52 | +$blog_handler = & xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
|
53 | +$article_obj = & $article_handler->get($article_id); |
|
54 | +$blog_obj = & $blog_handler->get($article_obj->getVar("blog_id")); |
|
55 | 55 | |
56 | 56 | // restore $_SERVER['REQUEST_URI'] |
57 | -if(!empty($REQUEST_URI_parsed)){ |
|
57 | +if (!empty($REQUEST_URI_parsed)) { |
|
58 | 58 | $_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php". |
59 | - (empty($article_id)?"":"?article=".$article_id); |
|
59 | + (empty($article_id) ? "" : "?article=".$article_id); |
|
60 | 60 | } |
61 | 61 | |
62 | -$xoopsOption["xoops_pagetitle"] = $xoopsModule->getVar("name"). " - " .$article_obj->getVar("art_title"); |
|
62 | +$xoopsOption["xoops_pagetitle"] = $xoopsModule->getVar("name")." - ".$article_obj->getVar("art_title"); |
|
63 | 63 | $xoopsOption["template_main"] = planet_getTemplate("article"); |
64 | -include_once( XOOPS_ROOT_PATH . "/header.php" ); |
|
64 | +include_once(XOOPS_ROOT_PATH."/header.php"); |
|
65 | 65 | include XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/vars.php"; |
66 | 66 | |
67 | 67 | $article_data = array( |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | "blog"=> array("id"=>$article_obj->getVar("blog_id"), "title"=>$blog_obj->getVar("blog_title")) |
79 | 79 | ); |
80 | 80 | |
81 | -if(!empty($xoopsModuleConfig["do_sibling"])){ |
|
82 | - $articles_sibling =& $article_handler->getSibling($article_obj, $blog_id); |
|
83 | - if(!empty($articles_sibling["previous"])) { |
|
81 | +if (!empty($xoopsModuleConfig["do_sibling"])) { |
|
82 | + $articles_sibling = & $article_handler->getSibling($article_obj, $blog_id); |
|
83 | + if (!empty($articles_sibling["previous"])) { |
|
84 | 84 | $articles_sibling["previous"]["url"] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php".URL_DELIMITER."".$articles_sibling["previous"]["id"]."/b".$blog_id; |
85 | 85 | $articles_sibling["previous"]["title"] = $articles_sibling["previous"]["title"]; |
86 | 86 | } |
87 | - if(!empty($articles_sibling["next"])){ |
|
87 | + if (!empty($articles_sibling["next"])) { |
|
88 | 88 | $articles_sibling["next"]["url"] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php".URL_DELIMITER."".$articles_sibling["next"]["id"]."/b".$blog_id; |
89 | 89 | $articles_sibling["next"]["title"] = $articles_sibling["next"]["title"]; |
90 | 90 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | $xoopsTpl -> assign("article", $article_data); |
96 | 96 | $xoopsTpl -> assign("sibling", $articles_sibling); |
97 | 97 | |
98 | -$xoopsTpl -> assign("user_level", !is_object($xoopsUser)?0:($xoopsUser->isAdmin()?2:1)); |
|
99 | -if(empty($xoopsModuleConfig["anonymous_rate"]) && !is_object($xoopsUser)){ |
|
100 | -}else{ |
|
98 | +$xoopsTpl -> assign("user_level", !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1)); |
|
99 | +if (empty($xoopsModuleConfig["anonymous_rate"]) && !is_object($xoopsUser)) { |
|
100 | +}else { |
|
101 | 101 | $xoopsTpl -> assign("canrate", 1); |
102 | 102 | } |
103 | 103 | |
104 | -if($transferbar = @include(XOOPS_ROOT_PATH."/Frameworks/transfer/bar.transfer.php")){ |
|
104 | +if ($transferbar = @include(XOOPS_ROOT_PATH."/Frameworks/transfer/bar.transfer.php")) { |
|
105 | 105 | $xoopsTpl->assign('transfer', $transferbar); |
106 | 106 | } |
107 | 107 |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | $xoopsOption["pagetype"] = "search"; |
29 | 29 | include "header.php"; |
30 | 30 | $xoopsModule->loadLanguage("main"); |
31 | -$config_handler =& xoops_gethandler("config"); |
|
32 | -$xoopsConfigSearch =& $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH); |
|
31 | +$config_handler = & xoops_gethandler("config"); |
|
32 | +$xoopsConfigSearch = & $config_handler->getConfigsByCat(XOOPS_CONF_SEARCH); |
|
33 | 33 | if (empty($xoopsConfigSearch["enable_search"])) { |
34 | 34 | redirect_header(XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php", 2, planet_constant("MD_NOACCESS")); |
35 | 35 | exit(); |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | $queries = array(); |
47 | 47 | $andor = isset($_POST["andor"]) ? $_POST["andor"] : (isset($_GET["andor"]) ? $_GET["andor"] : ""); |
48 | 48 | $start = isset($_GET["start"]) ? $_GET["start"] : 0; |
49 | -$category = intval( isset($_POST["category"]) ? $_POST["category"] : (isset($_GET["category"]) ? $_GET["category"] : null) ); |
|
50 | -$blog = intval( isset($_POST["blog"]) ? $_POST["blog"] : (isset($_GET["blog"]) ? $_GET["blog"] : null) ); |
|
51 | -$uid = intval( isset($_POST["uid"]) ? $_POST["uid"] : (isset($_GET["uid"]) ? $_GET["uid"] : null) ); |
|
49 | +$category = intval(isset($_POST["category"]) ? $_POST["category"] : (isset($_GET["category"]) ? $_GET["category"] : null)); |
|
50 | +$blog = intval(isset($_POST["blog"]) ? $_POST["blog"] : (isset($_GET["blog"]) ? $_GET["blog"] : null)); |
|
51 | +$uid = intval(isset($_POST["uid"]) ? $_POST["uid"] : (isset($_GET["uid"]) ? $_GET["uid"] : null)); |
|
52 | 52 | $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array()); |
53 | 53 | $sortby = isset($_POST["sortby"]) ? $_POST["sortby"] : (isset($_GET["sortby"]) ? $_GET["sortby"] : null); |
54 | 54 | $term = isset($_POST["term"]) ? $_POST["term"] : (isset($_GET["term"]) ? $_GET["term"] : ""); |
55 | 55 | |
56 | -$andor = (in_array(strtoupper($andor), array("OR", "AND", "EXACT")))?strtoupper($andor):"OR"; |
|
57 | -$sortby = (in_array(strtolower($sortby), array("a.art_id desc", "a.art_time desc", "a.art_title", "a.blog_id", "b.blog_id", "b.blog_feed", "b.blog_title", "b.blog_time"))) ? strtolower($sortby) : ""; |
|
56 | +$andor = (in_array(strtoupper($andor), array("OR", "AND", "EXACT"))) ? strtoupper($andor) : "OR"; |
|
57 | +$sortby = (in_array(strtolower($sortby), array("a.art_id desc", "a.art_time desc", "a.art_title", "a.blog_id", "b.blog_id", "b.blog_feed", "b.blog_title", "b.blog_time"))) ? strtolower($sortby) : ""; |
|
58 | 58 | |
59 | -if ( !( empty($_POST["submit"]) && empty($_GET["term"])) ) { |
|
59 | +if (!(empty($_POST["submit"]) && empty($_GET["term"]))) { |
|
60 | 60 | $next_search["category"] = $category; |
61 | 61 | $next_search["blog"] = $blog; |
62 | 62 | $next_search["uid"] = $uid; |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | $next_search["term"] = $term; |
66 | 66 | $query = trim($term); |
67 | 67 | |
68 | - if ( $andor != "EXACT" ) { |
|
68 | + if ($andor != "EXACT") { |
|
69 | 69 | $ignored_queries = array(); // holds kewords that are shorter than allowed minmum length |
70 | 70 | $temp_queries = preg_split("/[\s,]+/", $query); |
71 | 71 | foreach ($temp_queries as $q) { |
72 | 72 | $q = trim($q); |
73 | - if (strlen($q) >= $xoopsConfigSearch["keyword_min"]) { |
|
73 | + if (strlen($q)>=$xoopsConfigSearch["keyword_min"]) { |
|
74 | 74 | $queries[] = $myts->addSlashes($q); |
75 | - } else { |
|
75 | + }else { |
|
76 | 76 | $ignored_queries[] = $myts->addSlashes($q); |
77 | 77 | } |
78 | 78 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | redirect_header(XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/search.php", 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch["keyword_min"])); |
81 | 81 | exit(); |
82 | 82 | } |
83 | - } else { |
|
84 | - if (strlen($query) < $xoopsConfigSearch["keyword_min"]) { |
|
83 | + }else { |
|
84 | + if (strlen($query)<$xoopsConfigSearch["keyword_min"]) { |
|
85 | 85 | redirect_header(XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/search.php", 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch["keyword_min"])); |
86 | 86 | exit(); |
87 | 87 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | if (!empty($time)) { |
98 | 98 | $extra = ""; |
99 | - }else{ |
|
99 | + }else { |
|
100 | 100 | $extra = ""; |
101 | 101 | } |
102 | 102 | |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | { |
114 | 114 | $xoopsTpl->assign("results", $results); |
115 | 115 | |
116 | - if(count($next_search)>0){ |
|
116 | + if (count($next_search)>0) { |
|
117 | 117 | $items = array(); |
118 | - foreach($next_search as $para => $val){ |
|
119 | - if(!empty($val)) $items[] = "$para=$val"; |
|
118 | + foreach ($next_search as $para => $val) { |
|
119 | + if (!empty($val)) $items[] = "$para=$val"; |
|
120 | 120 | } |
121 | - if(count($items)>0) $paras = implode("&",$items); |
|
121 | + if (count($items)>0) $paras = implode("&", $items); |
|
122 | 122 | unset($next_search); |
123 | 123 | unset($items); |
124 | 124 | } |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | */ |
136 | 136 | if (count($results)) |
137 | 137 | { |
138 | - $next = $start + $limit; |
|
139 | - $queries = implode(",",$queries); |
|
138 | + $next = $start+$limit; |
|
139 | + $queries = implode(",", $queries); |
|
140 | 140 | $search_url_next = $search_url."&start=$next"; |
141 | 141 | $search_next = "<a href=\"".htmlspecialchars($search_url_next)."\">"._SR_NEXT."</a>"; |
142 | 142 | $xoopsTpl->assign("search_next", $search_next); |
143 | 143 | } |
144 | - if ( $start > 0 ) { |
|
145 | - $prev = $start - $limit; |
|
144 | + if ($start>0) { |
|
145 | + $prev = $start-$limit; |
|
146 | 146 | $search_url_prev = $search_url."&start=$prev"; |
147 | 147 | $search_prev = "<a href=\"".htmlspecialchars($search_url_prev)."\">"._SR_PREVIOUS."</a>"; |
148 | 148 | $xoopsTpl->assign("search_prev", $search_prev); |
@@ -157,54 +157,54 @@ discard block |
||
157 | 157 | /* type */ |
158 | 158 | $type_select = "<select name=\"andor\">"; |
159 | 159 | $type_select .= "<option value=\"OR\""; |
160 | - if("OR" == $andor) $type_select .= " selected=\"selected\""; |
|
160 | + if ("OR" == $andor) $type_select .= " selected=\"selected\""; |
|
161 | 161 | $type_select .= ">"._SR_ANY."</option>"; |
162 | 162 | $type_select .= "<option value=\"AND\""; |
163 | - if("AND" == $andor) $type_select .= " selected=\"selected\""; |
|
163 | + if ("AND" == $andor) $type_select .= " selected=\"selected\""; |
|
164 | 164 | $type_select .= ">"._SR_ALL."</option>"; |
165 | 165 | $type_select .= "<option value=\"EXACT\""; |
166 | - if("exact" == $andor) $type_select .= " selected=\"selected\""; |
|
166 | + if ("exact" == $andor) $type_select .= " selected=\"selected\""; |
|
167 | 167 | $type_select .= ">"._SR_EXACT."</option>"; |
168 | 168 | $type_select .= "</select>"; |
169 | 169 | |
170 | 170 | /* scope */ |
171 | 171 | $searchin_select = ""; |
172 | 172 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\""; |
173 | - if(in_array("title", $searchin)) $searchin_select .= " checked"; |
|
173 | + if (in_array("title", $searchin)) $searchin_select .= " checked"; |
|
174 | 174 | $searchin_select .= " />".planet_constant("MD_TITLE")." "; |
175 | 175 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\""; |
176 | - if(in_array("text", $searchin)) $searchin_select .= " checked"; |
|
176 | + if (in_array("text", $searchin)) $searchin_select .= " checked"; |
|
177 | 177 | $searchin_select .= " />".planet_constant("MD_BODY")." || "; |
178 | 178 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"blog\""; |
179 | - if(in_array("blog", $searchin)) $searchin_select .= " checked"; |
|
179 | + if (in_array("blog", $searchin)) $searchin_select .= " checked"; |
|
180 | 180 | $searchin_select .= " />".planet_constant("MD_BLOG")." "; |
181 | 181 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"feed\""; |
182 | - if(in_array("feed", $searchin)) $searchin_select .= " checked"; |
|
182 | + if (in_array("feed", $searchin)) $searchin_select .= " checked"; |
|
183 | 183 | $searchin_select .= " />".planet_constant("MD_FEED")." "; |
184 | 184 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"desc\""; |
185 | - if(in_array("desc", $searchin)) $searchin_select .= " checked"; |
|
185 | + if (in_array("desc", $searchin)) $searchin_select .= " checked"; |
|
186 | 186 | $searchin_select .= " />".planet_constant("MD_DESC")." "; |
187 | 187 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\""; |
188 | - if(empty($searchin)) $searchin_select .= " checked"; |
|
188 | + if (empty($searchin)) $searchin_select .= " checked"; |
|
189 | 189 | $searchin_select .= " />"._ALL." "; |
190 | 190 | |
191 | 191 | /* sortby */ |
192 | 192 | $sortby_select = "<select name=\"sortby\">"; |
193 | 193 | $sortby_select .= "<option value=\"\""; |
194 | - if(empty($sortby)) $sortby_select .= " selected=\"selected\""; |
|
194 | + if (empty($sortby)) $sortby_select .= " selected=\"selected\""; |
|
195 | 195 | $sortby_select .= ">"._NONE."</option>"; |
196 | 196 | $sortby_select .= "<option value=\"a.art_time\""; |
197 | - if("a.art_time" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
197 | + if ("a.art_time" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
198 | 198 | $sortby_select .= ">".planet_constant("MD_TIME")."</option>"; |
199 | 199 | $sortby_select .= "<option value=\"a.art_title\""; |
200 | - if("a.art_title" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
200 | + if ("a.art_title" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
201 | 201 | $sortby_select .= ">".planet_constant("MD_TITLE")."</option>"; |
202 | 202 | $sortby_select .= "<option value=\"\"> ---- </option>"; |
203 | 203 | $sortby_select .= "<option value=\"a.blog_title\""; |
204 | - if("a.blog_title" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
204 | + if ("a.blog_title" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
205 | 205 | $sortby_select .= ">".planet_constant("MD_BLOG")."</option>"; |
206 | 206 | $sortby_select .= "<option value=\"a.blog_time\""; |
207 | - if("b.blog_time" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
207 | + if ("b.blog_time" == $sortby) $sortby_select .= " selected=\"selected\""; |
|
208 | 208 | $sortby_select .= ">".planet_constant("MD_UPDATE")."</option>"; |
209 | 209 | $sortby_select .= "</select>"; |
210 | 210 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $xoopsTpl->assign("blog", $blog); |
220 | 220 | $xoopsTpl->assign("uid", $uid); |
221 | 221 | |
222 | -if ($xoopsConfigSearch["keyword_min"] > 0) { |
|
222 | +if ($xoopsConfigSearch["keyword_min"]>0) { |
|
223 | 223 | $xoopsTpl->assign("search_rule", sprintf(_SR_KEYIGNORE, $xoopsConfigSearch["keyword_min"])); |
224 | 224 | } |
225 | 225 |