Skip to content

Instantly share code, notes, and snippets.

@co3k
Created January 15, 2010 07:07
Show Gist options
  • Save co3k/277873 to your computer and use it in GitHub Desktop.
Save co3k/277873 to your computer and use it in GitHub Desktop.
This script creates JSON contents for OpenPNE 3 dashboard
<?php
function h($str)
{
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
$callback = $_GET['callback'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ad.pne.jp/dashboard/');
curl_setopt($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec($ch);
curl_close($ch);
$data = ob_get_contents();
ob_end_clean();
$data = str_replace('<!--innerBox"> -->', '', $data);
$data = str_replace('<!--', '', $data);
$data = str_replace('-->', '', $data);
$data = str_replace('<script language', '<!--', $data);
$data = str_replace('</script>', '-->', $data);
$data = str_replace('<noscript>', '<!--', $data);
$data = str_replace('</noscript>', '-->', $data);
$data = str_replace('<div style="float:left; margin: 0px 0px 0px 10px;">', '<div>', $data);
// extract "pneinfo"
$start_text = '<div class="box" id="pneinfo">';
$end_text = '<div class="box">';
$start_pos = strpos($data, $start_text);
$end_pos = strpos($data, $end_text, $start_pos);
$data = '<div>'.substr($data, $start_pos, $end_pos - strlen($end_text)).'</div>';
echo h($callback).'('.json_encode($data).')';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment