public static function getCSVMap()
 {
     if (!is_null(self::$_csvmap)) {
         return self::$_csvmap;
     }
     $fp = fopen(__DIR__ . '/map.csv', 'r');
     $columns = fgetcsv($fp);
     $csvmap = array();
     while ($row = fgetcsv($fp)) {
         $csvmap[] = $row;
     }
     return self::$_csvmap = $csvmap;
 }
 protected function _checkReportData($data)
 {
     if (!$data['news_title']) {
         throw new Exception("未輸入新聞標題");
     }
     if (!$data['news_link'] or !$this->validateURL($data['news_link'])) {
         throw new Exception("請輸入合法新聞網址");
     }
     if (!$data['report_title']) {
         throw new Exception("未輸入打臉簡介");
     }
     if (!$data['report_link'] or !$this->validateURL($data['report_link'])) {
         throw new Exception("請輸入合法打臉網址");
     }
     if ($data['report_link'] == $data['news_link']) {
         throw new Exception("打臉連結不能與新聞連結相同,打臉連結請提供有提出指正該新聞錯誤證據的消息來源");
     }
     if ($normaled_report_link = URLNormalizer::query($data['report_link']) and $normaled_news_link = URLNormalizer::query($data['news_link']) and $normaled_report_link->normalized_id == $normaled_news_link->normalized_id) {
         throw new Exception("打臉連結不能與新聞連結相同,打臉連結請提供有提出指正該新聞錯誤證據的消息來源");
     }
 }
Esempio n. 3
0
 /**
  * Use Glen Scotts UrlNormalizer to normalize the passed url.
  * 
  * @param  string $url 
  * @return string
  */
 public static function normalizeUrl($url)
 {
     if (!class_exists('URLNormalizer')) {
         require_once realpath(__DIR__ . '/../../classes') . '/URLNormalizer.php';
     }
     $un = new \URLNormalizer();
     $un->setUrl($url);
     return $un->normalize();
 }
Esempio n. 4
0
  normalized_url: 'https://www.facebook.com/394896373929368/posts/552832544802416',
  normalized_id: 'www.facebook.com/posts/552832544802416' }
*/
$url = 'https://www.facebook.com/permalink.php?story_fbid=691671064186291&id=100000302107473';
print_r(URLNormalizer::query($url));
/*
{ query_url: 'https://www.facebook.com/permalink.php?story_fbid=691671064186291&id=100000302107473',
  normalized_url: 'https://www.facebook.com/permalink.php?story_fbid=691671064186291&id=100000302107473',
  normalized_id: 'www.facebook.com/permalink/691671064186291/100000302107473' }
*/
$url = 'http://udn.com/NEWS/BREAKINGNEWS/BREAKINGNEWS1/民進黨立委杯葛-院會無議程-8395297.shtml';
print_r(URLNormalizer::query($url));
/*
{ query_url: 'http://udn.com/NEWS/BREAKINGNEWS/BREAKINGNEWS1/民進黨立委杯葛-院會無議程-8395297.shtml',
  normalized_url: 'http://udn.com/NEWS/BREAKINGNEWS/BREAKINGNEWS1/8395297.shtml',
  normalized_id: 'udn.com/news/8395297' }
*/
$url = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=Big5&NewsID=8108263&ch=fb_share&R=346';
print_r(URLNormalizer::query($url));
/*
{ query_url: 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=Big5&NewsID=8108263&ch=fb_share&R=346',
  normalized_url: 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=Big5&NewsID=8108263',
  normalized_id: 'udn.com/news/8108263' }
*/
$url = 'http://www.udn.com/2013/10/31/NEWS/NATIONAL/NATS1/8263682.shtml?ch=fb_share';
print_r(URLNormalizer::query($url));
/*
{ query_url: 'http://www.udn.com/2013/10/31/NEWS/NATIONAL/NATS1/8263682.shtml?ch=fb_share',
  normalized_url: 'http://www.udn.com/2013/10/31/NEWS/NATIONAL/NATS1/8263682.shtml',
  normalized_id: 'udn.com/news/8263682' }
*/