Permalink
Browse files

I must be in love with some bugs...and enhancement !

  • Loading branch information...
1 parent ae29b6e commit e87a95d5ed7dc04882112c9e3c251b5745c11214 @molokoloco committed Mar 22, 2011
Showing with 24 additions and 24 deletions.
  1. +16 −15 wall/feed2json.php
  2. +4 −4 wall/index.php
  3. +4 −5 wall/wordpress2json.php
View
@@ -1,12 +1,14 @@
<?php
-//ini_set('display_errors','On');
+@ini_set('error_reporting', E_ALL & ~E_NOTICE);
+@ini_set('display_errors', 'on');
require_once(dirname(__FILE__).'/php/functions.php');
///////////// URLificator ///////////////////////////////////////////////////
-
-function getFinalUrl($url, $timeout=5) { // Get Real URL (Keep out FeedBurner redirecting...) // Inspired from comment here : http://php.net/manual/fr/ref.curl.php
+// Get Real URL (Keep out FeedBurner redirecting...)
+// Inspired from comments here : http://php.net/manual/fr/ref.curl.php
+function getFinalUrl($url, $timeout=5) {
if (!function_exists('curl_init') || empty($url)) return $url;
@@ -24,7 +26,7 @@ function getFinalUrl($url, $timeout=5) { // Get Real URL (Keep out FeedBurner re
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false ); // required for https urls
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- //curl_setopt($ch, CURLOPT_HEADER, true);
+ ### curl_setopt($ch, CURLOPT_HEADER, true);
$content = curl_exec($ch);
$response = curl_getinfo($ch);
@@ -53,7 +55,9 @@ function getFinalUrl($url, $timeout=5) { // Get Real URL (Keep out FeedBurner re
}
///////////// FEEDER ///////////////////////////////////////////////////
-
+// Convert distant RSS to processed JSON...
+// Based on the famous ./php/SimplePie
+// Images managed with ./php/PhpThumb
function getJsonFromFeed($feedUrl, $start=0, $offset=15, $size=800) {
global $WWW;
@@ -162,10 +166,11 @@ function getJsonFromFeed($feedUrl, $start=0, $offset=15, $size=800) {
else return '['.implode(',', $items).']';
}
+// Get infinite post items from inside my wordpress blog... >>> Check ./wordpress2json.php (copy)
function getJsonFromWordpress($page) {
if (!function_exists('curl_init')) return utf8_decode(file_get_contents('http://www.b2bweb.fr/wordpress2json/page/'.$page.'/'));
-
+
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/8.10 (intrepid) Firefox/3.0.11');
curl_setopt($ch, CURLOPT_URL, 'http://www.b2bweb.fr/wordpress2json/page/'.$page.'/');
@@ -183,18 +188,16 @@ function getJsonFromWordpress($page) {
$content = curl_exec($ch);
$response = curl_getinfo($ch);
curl_close($ch);
-
+
if ($response['http_code'] == 200 && !empty($content)) return utf8_decode($content);
return '[{"message":"Erreur URL interne"}]';
}
-
-
// LET'S GO AND FETCH FEED ! /////////////////////////////////////////////////////////////////////////////////////////////
-header('Content-Type: text/html; charset=utf-8');
-//header('Content-Type: application/json; charset=utf-8');
+### header('Content-Type: text/html; charset=utf-8'); // debug...
+header('Content-Type: application/json; charset=utf-8');
$feedUrl = getFeed();
$page = (isset($_GET['page']) && intval($_GET['page']) > 1 ? $_GET['page'] : 1);
@@ -204,9 +207,9 @@ function getJsonFromWordpress($page) {
$cacheBase = dirname(__FILE__).'/cache/';
$cache = $cacheBase.'json-'.$page.'-'.cleanName($feedUrl);
-// if (!is_dir($cacheBase)) mkdir($cache, 0777);
-### @unlink($cache);
+### if (!is_dir($cacheBase)) mkdir($cache, 0777); // Doyoudo
+### @unlink($cache); // debug...
$feedData = '';
if (!is_file($cache) || filemtime($cache) < (time() - (3600*6))) { // Re-cache every 6 hours
@ignore_user_abort(true);
@@ -220,5 +223,3 @@ function getJsonFromWordpress($page) {
else $feedData = @file_get_contents($cache);
echo utf8_encode($feedData);
-
-?>
View
@@ -13,7 +13,7 @@
<title>Wall [<?=(isset($feedUrl) ? htmlentities($feedUrl) : 'Work Wild Web @ b2bWeb.fr');?>]</title>
<meta http-equiv="WebDev" content="^Work In Progress^ By molokoloco 2010"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <!--<meta name="viewport" content="width=device-width; initial-scale=1.0;" /> // setted by jQMob -->
+ <!--<meta name="viewport" content="width=device-width; initial-scale=1.0;" />-->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="icon" type="image/x-icon" href="<?=$WWW;?>favicon.ico" />
@@ -28,7 +28,7 @@
<header>
<form action="#" method="get" name="formFeed" id="formFeed">
- <a href="<?=$WWW;?>google2reader.php" class="button blue" title="Choisir un flux RSS"><div class="icon gear"></div>Flux<span></span></a><input type="url" name="url" id="url" value="<?=htmlentities(urldecode($feedUrl));?>" title="Fluid interface @ BornToBeWeb, give me feed, give me food !" size="10"/>&nbsp;<a href="javascript:void(0);" onClick="$('form#formFeed').trigger('submit');" class="button blue" title="Choisir un flux RSS">Wallify&nbsp;!<span></span></a>
+ <a href="<?=$WWW;?>google2reader.php" class="button blue" title="Choisir un flux RSS"><div class="icon gear"></div>Flux<span></span></a><input type="url" name="url" id="url" value="<?=htmlentities(urldecode($feedUrl));?>" title="Fluid interface @ BornToBeWeb, give me feed, give me food !" size="10"/>&nbsp;<a href="javascript:void(0);" onclick="$('form#formFeed').trigger('submit');" class="button blue" title="Choisir un flux RSS">Wallify&nbsp;!<span></span></a>
</form>
</header>
@@ -44,9 +44,9 @@
</div>
<footer>
- <a href="javascript:void(0);" onClick="$('html, body').animate({scrollTop:0}, 1600);" class="button blue right" title="Remonter" id="up" style="display:none;"><div class="icon arrow"></div><span></span> Up</a> <a href="http://www.b2bweb.fr/" class="button blue right" title="http://www.b2bweb.fr"><div class="icon home"></div><span></span> Home</a>
+ <a href="javascript:void(0);" onclick="$('html, body').animate({scrollTop:0}, 1600);" class="button blue right" title="Remonter" id="up" style="display:none;"><div class="icon arrow"></div><span></span> Up</a> <a href="http://www.b2bweb.fr/" class="button blue right" title="http://www.b2bweb.fr"><div class="icon home"></div><span></span> Home</a>
<span id="scrollInfos"></span>
- <a href="javascript:(function(w){w.open('<?=$WWW;?>?url='+encodeURIComponent(w.location.href));})(window);" onClick="alert('Drag me to your bookmarks to Wallify site/feed with one clic...'); return false;" title="Drag me to your bookmarks to Wallify site with one clic..." class="button gray left"><div class="icon grid"></div>Wallmarklet<span></span></a>
+ <a href="javascript:(function(w){w.open('<?=$WWW;?>?url='+encodeURIComponent(w.location.href));})(window);" onclick="alert('Drag me to your bookmarks to Wallify site/feed with one clic...'); return false;" title="Drag me to your bookmarks to Wallify site with one clic..." class="button gray left"><div class="icon grid"></div>Wallmarklet<span></span></a>
</footer>
<script src="<?=$WWW;?>js/jquery-1.4.4.min.js"></script>
View
@@ -73,15 +73,14 @@ function getWorpressPost() {
wp_reset_query();
-
if ($paged > 0 && count($posts) < 2) return utf8_encode('[{"message":"no more"}]');
elseif (count($posts) < 2) return utf8_encode('[{"message":"We found no item in this feed... "}]');
- else return utf8_encode('[{"link":"http://www.b2bweb.fr", "title":"Work Wild Web @ b2bWeb.fr", "description":"Watching the Web... Coding, Politics and Geekness pleasure..."},'.implode(',', $posts).']');
+ else return utf8_encode('[{"link":"'.$WWW.'", "title":"Work Wild Web @ b2bWeb.fr", "description":"Watching the Web... Coding, Politics and Geekness pleasure..."},'.implode(',', $posts).']');
}
-header('Content-Type: text/html; charset=utf-8');
-//header('Content-Type: application/json; charset=utf-8');
-echo getWorpressPost(1);
+### header('Content-Type: text/html; charset=utf-8');
+header('Content-Type: application/json; charset=utf-8');
+echo getWorpressPost();
?>

0 comments on commit e87a95d

Please sign in to comment.