Overview

Packages

  • controller
  • models
  • None

Classes

  • Ajax
  • Article
  • Cache
  • Employee
  • Firefly
  • gmreader
  • gmsite
  • Home
  • Link
  • Merchant
  • Model_article
  • Model_cache
  • Model_employee
  • Model_firefly
  • Model_gmreader
  • Model_gmsite
  • Model_link
  • Model_merchant
  • Model_reference
  • Model_user
  • Reference
  • Setting
  • User

Functions

  • check_permission
  • data_status
  • data_status_select
  • dump_html_tree
  • employee_select
  • file_get_html
  • generate_page
  • gerenate_pager_from_table
  • get_desc_asc
  • get_url_support
  • is_admin
  • is_loggedin
  • link_extractor
  • merchant_status
  • reference_reverter
  • role_select
  • siteinfo
  • str_get_html
  • yes_no
  • yesno_select
  • Overview
  • Package
  • Class
  1: <?php 
  2: 
  3: function reference_reverter(){
  4:     $all_nodes = $this->db->from('xenon_data')->where('data_id in (select distinct data_id from xenon_reference_data)')->get();
  5:     foreach($all_nodes->result() as $article){
  6:         $dom = new DOMDocument();
  7:         $dom->loadHTML(html_entity_decode(mb_convert_encoding($article->data_body,"HTML-ENTITIES","UTF-8")));
  8:         $a_tags = $dom->getElementsByTagName('a');
  9:         foreach ($a_tags as $a_tag) {
 10:             $txt = iconv("UTF-8", "ISO-8859-1",str_replace('&#38;','&amp;',str_replace('’', "'", $a_tag->nodeValue)));
 11:             if($a_tag->getAttribute('class') == 'reference'){
 12:                 $refe_id = $this->db->select('refe_id')->from('xenon_reference_data')->where('data_id',$article->data_id)->where('row_num',substr($txt, 1))->get()->row()->refe_id;
 13:                 $refe_hr = $this->db->select('refe_link')->from('xenon_reference')->where('refe_id',$refe_id)->get()->row()->refe_link;
 14:                 $link = $dom->createElement('a',"references");
 15:                 $link->setAttribute('href', $refe_hr);
 16:                 $link->setAttribute('class','blueref');
 17:                 $a_tag->parentNode->replaceChild($link, $a_tag);
 18:             }
 19:         }
 20:         $data_final['data_body'] = substr($dom->saveHTML(),119,-15);
 21:         $this->db->where('data_id',$article->data_id);
 22:         $this->db->update('xenon_data',$data_final);
 23:     }
 24: }
 25: 
 26: function link_extractor(){
 27:                 $all_nodes = $this->db->from('xenon_data')->limit(1500)->get();
 28:             
 29:             foreach($all_nodes->result() as $article){
 30:                 echo $article->data_id.'::<a target="_blank" href="http://admin.greenmedicineworks.com/article/edit/'.urlencode(base64_encode($article->data_id)).'">'.urlencode(base64_encode($article->data_id)).'</a><br />';
 31:                 
 32:                 $dom = new DOMDocument();
 33:                 $dom->loadHTML(html_entity_decode(mb_convert_encoding($article->data_body,"HTML-ENTITIES","UTF-8")));
 34:                 $a_tags = $dom->getElementsByTagName('a');
 35:                 foreach ($a_tags as $a_tag) {
 36:                     $txt = /*iconv("UTF-8", "ISO-8859-1",*/str_replace('&#38;','&amp;',str_replace('’', "'", $a_tag->nodeValue))/*)*/;
 37:                     $txt = htmlentities($txt);
 38:                     echo $txt.'<br />';
 39:                     $data['link_text'] = $txt;
 40:                     $data['link_class'] = $a_tag->getAttribute('class');
 41:                     $data['link_href'] =  $a_tag->getAttribute('href');
 42:                     $data_get = $this->db->from('xenon_link')->where('link_text',$txt)->where('link_href',$a_tag->getAttribute('href'))->get();
 43:                     if($data_get->num_rows() == 0){
 44:                         $this->db->insert('xenon_link',$data);
 45:                         $id_main = $this->db->insert_id();
 46:                         $id_enc = urlencode(base64_encode($id_main));
 47:                         if($this->db->from('xenon_data_links')->where('link_id',$id_main)->where('data_id',$article->data_id)->get()->num_rows() == 0){
 48:                             $data_link['link_id'] = $id_main;
 49:                             $data_link['data_id'] = $article->data_id;
 50:                             $this->db->insert('xenon_data_links',$data_link);
 51:                         }
 52:                         $link = $dom->createElement('a',$txt);
 53:                         $link->setAttribute('href', $id_enc);
 54:                         $a_tag->parentNode->replaceChild($link, $a_tag);
 55:                         //echo '<a href="'.$div->getAttribute('href').'" class="'.$div->getAttribute('class').'">'.$div->nodeValue.'</a><br />';
 56:                     }else{
 57:                         $id_main = $data_get->row()->link_id;
 58:                         $id_enc = urlencode(base64_encode($id_main));
 59:                         if($this->db->from('xenon_data_links')->where('link_id',$id_main)->where('data_id',$article->data_id)->get()->num_rows() == 0){
 60:                             $data_link['link_id'] = $id_main;
 61:                             $data_link['data_id'] = $article->data_id;
 62:                             $this->db->insert('xenon_data_links',$data_link);
 63:                         }
 64:                         $link = $dom->createElement('a',$txt);
 65:                         $link->setAttribute('href', $id_enc);
 66:                         $a_tag->parentNode->replaceChild($link, $a_tag);
 67:                     }
 68:                 }
 69:                 $data_final['data_body_temp'] = substr($dom->saveHTML(),119,-15);
 70:                 $this->db->where('data_id',$article->data_id);
 71:                 $this->db->update('xenon_data',$data_final);
 72:             }
 73: }
 74: 
 75: 
 76: /**
 77:  * All of the Defines for the classes below.
 78:  * @author S.C. Chen <me578022@gmail.com>
 79:  */
 80: 
 81: // helper functions
 82: // -----------------------------------------------------------------------------
 83: // get html dom from file
 84: // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
 85: function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
 86: {
 87:     // We DO force the tags to be terminated.
 88:     $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
 89:     // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
 90:     $contents = file_get_contents($url, $use_include_path, $context, $offset);
 91:     // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
 92:     //$contents = retrieve_url_contents($url);
 93:     if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
 94:     {
 95:         return false;
 96:     }
 97:     // The second parameter can force the selectors to all be lowercase.
 98:     $dom->load($contents, $lowercase, $stripRN);
 99:     return $dom;
100: }
101: 
102: // get html dom from string
103: function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
104: {
105:     $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
106:     if (empty($str) || strlen($str) > MAX_FILE_SIZE)
107:     {
108:         $dom->clear();
109:         return false;
110:     }
111:     $dom->load($str, $lowercase, $stripRN);
112:     return $dom;
113: }
114: 
115: // dump html dom tree
116: function dump_html_tree($node, $show_attr=true, $deep=0)
117: {
118:     $node->dump($node);
119: }
120: 
121: 
122: 
API documentation generated by ApiGen