Author Topic: MOD WIKIPEDIA  (Read 148027 times)

0 Members and 1 Guest are viewing this topic.

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: MOD WIKIPEDIA
« Reply #105 on: May 16, 2010, 02:13:44 PM »
habe ich glatt gemacht  :wink:
Wie immer "TOP"

Danke

Harald
Danke Harald




Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: MOD WIKIPEDIA
« Reply #106 on: May 18, 2010, 11:02:08 PM »
Wie unterschiedlich doch die Menschen sind ;)
OK, in meiner zweiten Galerie, ist mein Admin auch begeistert von diesem Mod, nur er möchte nur den Text haben, also ganz ohne Links.
Dazu habe ich den Code aus dem ersten Posting eingefügt, nur werden dort ja die roten Links auch angezeigt.
Wie bekomme ich diese auch noch raus, das alles ohne Link ist, und mein Admin zufrieden ist ;)

function get_wiki($image_wiki) {
  global 
$user_info$site_db$session_info$config;
   
ini_set('user_agent''(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6');
//    $image_wiki = preg_replace('/\\W/', '',$image_wiki);
    
$zeichen = array('#''?''§''$''%''&''/''('')''=''^''°''*''@');
    
$image_wiki str_replace($zeichen,"",$image_wiki);
    if(!
$image_wiki) return false;
    
//Gesamter Test aus der Wiki-API nehmen
    
$url "http://de.wikipedia.org/w/api.php?format=xml&action=parse&page=".$image_wiki;
    
$xml simplexml_load_file($url);
    
$text $xml->parse->text;
    if(!
$text) return false;
    
//Zusammenfassung suchen
    
$reg_exp '/<p>(.*?)<\/p>/s';
    
preg_match_all($reg_exp$text$match);
    
$summary $match[0][0];
    
$summary .= $match[0][1];
    
$summary .= $match[0][2];
    
$summary .= $match[0][3];
    
$summary .= $match[0][4];    
    
$summary .= $match[0][5];
    
$summary .= $match[0][6];
    
$summary utf8_decode($summary);
    
//wenn Artikel nicht vorhanden
    
if($summary == "<p><b>Artikel verschwunden?</b></p>") return false;
    
//Links auf interne Seite Ã¤ndern
     
$summary ereg_replace('href="/wiki/'''$summary);
    return 
$summary;
}


glaube dann haben wir hier alle Möglichkeiten durchgekaut  :D

LG Harald

PS,
um das auch noch aufzuführen, ihr könnt natürlich auch ausser dem Bild Namen, auch anderen Datenbankfeldern aufrufen laasen.
ändert dazu einfach in der detail.php das $image_wiki = $image_name; in eurem Wert.
Bei mir z.B. nach Hersteller = image_hersteller (selbst erstellte Tabelle)

$wiki "";
if (
$image_row['image_allow_wiki'] == 1){
    if (
$image_row['image_wiki']){
        
$image_wiki $image_row['image_wiki'];
        
$wiki get_wiki($image_wiki);
    }else {
    
$image_wiki $image_name;
    
$wiki get_wiki($image_wiki);
    }
}

Danke Harald




Rembrandt

  • Guest
Re: MOD WIKIPEDIA
« Reply #107 on: May 19, 2010, 05:47:50 AM »
$summary str_replace('href="/w/'''$summary);

mfg Andi

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: MOD WIKIPEDIA
« Reply #108 on: May 19, 2010, 04:20:51 PM »
leider nicht, dann gibt es wieder falsche normale Link, aber so klappt es

$summary str_replace('href="'''$summary);

dann wird kein Link mehr angezeigt

LG Harald
Danke Harald




Rembrandt

  • Guest
Re: MOD WIKIPEDIA
« Reply #109 on: May 19, 2010, 05:06:34 PM »
achso ich dachte du wolltes jetzt nur mehr die roten....

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: MOD WIKIPEDIA
« Reply #110 on: May 21, 2010, 06:48:36 PM »
in Step 9 bitte ändern, damit es auch in diesem Mod klappt
[MOD] Batch Copy/Move/Edit
http://www.4homepages.de/forum/index.php?topic=6759.msg147741;topicseen#msg147741


$additional_image_fields
['image_allow_wiki'] = array($lang['image_allow_wiki'], "text"0);
$additional_image_fields['image_wiki'] = array($lang['image_wiki'], "text"0);


LG
Danke Harald




rinaldos

  • Guest
Re: MOD WIKIPEDIA
« Reply #111 on: May 21, 2010, 07:50:15 PM »
Dann muss aber auch das Datenbankfeld geändert werden ....

:-)

Nachtrag. Ich nehme alles zurück.
Ich habe das bei mir so drinne, und auhc im ersten POSt nun angepasst

$additional_image_fields
['image_allow_wiki'] = array($lang['image_allow_wiki'], "radio"0);
$additional_image_fields['image_wiki'] = array($lang['image_wiki'], "text"0);


Gruss

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: MOD WIKIPEDIA
« Reply #112 on: June 04, 2010, 02:26:32 PM »
Hi all -
              when I tried to install this mod for categories.. I got the following error message in my server error log..
Code: [Select]
[Fri Jun 04 07:46:42 2010] [error] [client 207.46.xxx.xxxx] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: I/O warning : failed to load external entity &quot;http://de.wikipedia.org/w/api.php?format=xml&amp;action=parse&amp;page=Amanda%20Bynes&quot; in /home/xxxxxx/public_html/includes/functions.php on line 1959
[Fri Jun 04 07:46:42 2010] [error] [client 207.46.xxx.xxx] PHP Warning:  simplexml_load_file(http://de.wikipedia.org/w/api.php?format=xml&amp;action=parse&amp;page=Amanda%20Bynes) [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: failed to open stream: no suitable wrapper could be found in /home/xxxxxxx/public_html/includes/functions.php on line 1959
[Fri Jun 04 07:46:42 2010] [error] [client 207.46.xxx.xxx] PHP Warning:  simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: URL file-access is disabled in the server configuration in /home/xxxxxx/public_html/includes/functions.php on line 1959


Could anyone please let me know, how to fix this issue ?

Thanks,
batu544

rinaldos

  • Guest
Re: MOD WIKIPEDIA
« Reply #113 on: June 04, 2010, 02:37:01 PM »
Hi
replace
Code: [Select]
function get_wiki_cat($cat_name) {
  global $user_info, $site_db, $session_info, $config;

with
Code: [Select]
function get_wiki_cat($cat_name) {
  global $user_info, $site_db, $session_info, $config;
  ini_set('user_agent', '(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6');

I fixed post with addon for categories

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: MOD WIKIPEDIA
« Reply #114 on: June 04, 2010, 03:05:36 PM »
Hi rinaldos,
                I applied the above fix.. but no result.. still I am getting the same error message,.. :(


For your information. I only made the changes in 3 files..

1. functions.php
2. categories.php
3. categories.html


Thanks,
batu544


rinaldos

  • Guest
Re: MOD WIKIPEDIA
« Reply #115 on: June 04, 2010, 03:50:58 PM »
Thats correct, only 3 files. I have the same code in my HP which i postet for the categories :-)

Maybe, use the originally code, without Modification. And if there are no changes, please send me yout functions and your categories please ....

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: MOD WIKIPEDIA
« Reply #116 on: June 04, 2010, 04:54:39 PM »
Hi,
      I tried the same code in my local machine and it worked fine.. but in the server, it not working.. and I think this is because of  allow_url_fopen option is off .. this is just a guess and I think ini_set is not working with my host..

so, I tried some other way to bypass this thing and now its working.. 

but now the problem is all the internal links are not working ..

Is there anyway to remove those internal links .. ?? I don't want those internal links and if possible <p> </P> tags also in the output...


rinaldos,
                       here is my get_wiki_cat function..

Code: [Select]
function get_wiki_cat($cat_name) {
  global $user_info, $site_db, $session_info, $config;
  ini_set('user_agent', '(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6');
    $sign = array('#', '?', '§', '$', '%', '&', '/', '(', ')', '=', '^', '°', '*', '@', ' ');
    $cat_name = str_replace($sign,"_",$cat_name);
    if(!$cat_name) return false;
    //The whole test from the API take Wiki

if (!ini_get('allow_url_fopen') && !ini_get('allow_url_include'))
{
# Force allow_url_fopen=on and allow_url_include=off
stream_wrapper_unregister('http');
require('http_wrapper.php');
stream_wrapper_register('http', 'moo_stream_wrapper_http');
}
    $url = "http://en.wikipedia.org/w/api.php?format=xml&action=parse&page=".$cat_name;
    $xml = simplexml_load_file($url);
    $text = $xml->parse->text;
    if(!$text) return false;
    //Search summary
    $reg_exp = '/<p>(.*?)<\/p>/s';
    preg_match_all($reg_exp, $text, $match);
    $summary = $match[0][0];
    $summary .= $match[0][1];
    $summary .= $match[0][2];
    $summary = utf8_decode($summary);
    $summary .= "<a href = 'http://en.wikipedia.org/wiki/$cat_name'>Source: Wikipedia</a>";
    //If item is not available
    if($summary == "<p><b>Article content ??</b></p>") return false;
    //Links to internal pages
     $summary = ereg_replace('href="/wiki/', '', $summary);
    return $summary;
}


rinaldos

  • Guest
Re: MOD WIKIPEDIA
« Reply #117 on: June 04, 2010, 05:03:00 PM »
I think, the wrapper deactivate now all the links .... Sorry, i have at the moment no solution for your problem. Maybe some other guys....

Gruß
Ingo

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: MOD WIKIPEDIA
« Reply #118 on: June 04, 2010, 05:18:10 PM »
I think, the wrapper deactivate now all the links .... Sorry, i have at the moment no solution for your problem. Maybe some other guys....

Gruß
Ingo

:)  Will it help you, if I provide you the wrapper file ?

Is there any other way to remove the <p> and </p> tags from the generated output ?


Rembrandt

  • Guest
Re: MOD WIKIPEDIA
« Reply #119 on: June 04, 2010, 05:51:03 PM »
...

Is there any other way to remove the <p> and </p> tags from the generated output ?

Code: [Select]
function get_wiki_cat($cat_name) {
  global $user_info, $site_db, $session_info, $config;
  ini_set('user_agent', '(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6');
    $sign = array('#', '?', '§', '$', '%', '&', '/', '(', ')', '=', '^', '°', '*', '@', ' ');
    $cat_name = str_replace($sign,"_",$cat_name);
    if(!$cat_name) return false;
    //The whole test from the API take Wiki

if (!ini_get('allow_url_fopen') && !ini_get('allow_url_include'))
{
# Force allow_url_fopen=on and allow_url_include=off
stream_wrapper_unregister('http');
require('http_wrapper.php');
stream_wrapper_register('http', 'moo_stream_wrapper_http');
}
    $url = "http://en.wikipedia.org/w/api.php?format=xml&action=parse&page=".$cat_name;
    $xml = simplexml_load_file($url);
    $text = $xml->parse->text;
    if(!$text) return false;
    //Search summary
    $reg_exp = '/<p>(.*?)<\/p>/s';
    preg_match_all($reg_exp, $text, $match);
    $summary = $match[0][0];
    $summary .= $match[0][1];
    $summary .= $match[0][2];
    $summary = utf8_decode($summary);
    $summary .= "<a href = 'http://en.wikipedia.org/wiki/$cat_name'>Source: Wikipedia</a>";
    //If item is not available
    if($summary == "<p><b>Article content ??</b></p>") return false;
    //Links to internal pages

$remove= array('<p>','</p>');
$summary = str_replace($remove, "", $summary);

     $summary = ereg_replace('href="/wiki/', '', $summary);
    return $summary;
}


mfg Andi