Bonjour,
j'ai un plugin wordpress qui cherche des films sur allocine puis recupere les informations (acteurs, date de sortie, durée ....) et ajoute ces information comme des champs personnalisé dans wordpress.
mais depuis plusieurs semaine ce plugin ne marche plus, je crois que allocine ont changé des parametres, le probléme c'est pas moi qui l'a créee et j'arrive pas a le modifier.
voici un lient pour telecharger ce plugin si quelqu'un peut trouvé ou est le probléme.
http://www.2shared.com/file/2723mxoZ/pstream.html
et voici le fichier principale de plugin :
<?php
/*
*/
define ('PLUGIN_PATH',WP_PLUGIN_DIR.'/pstream/');
define ('PLUGIN_URL',WP_PLUGIN_URL.'/pstream/');
$plugin_admin_url = admin_url();
include(PLUGIN_PATH.'includes/functions.php');
if( !class_exists('pstream') )
{
class Pstream
{
function init_all()
{
global $wp_version, $pagenow , $current_user;
$exit_msg = "Soory but you have to update you wp verion";
if (version_compare($wp_version,"2.6","<"))
{
die($exit_msg);
}
/*
if the user is not admin remove all admin stuff from the wp admin area
*/
global $wpdb;
$table = $wpdb->prefix."report_deadl";
$structure = "CREATE TABLE $table (
id INT NOT NULL AUTO_INCREMENT,
meta_id INT NOT NULL,
meta_value VARCHAR(200) NOT NULL,
report_n INT(9) DEFAULT 0,
UNIQUE KEY id (id)
);";
$wpdb->query($structure);
if ($current_user->user_level != 10)
{
remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
add_filter( 'pre_transient_update_core', create_function( '$a', "return null;" ) );
}
add_action('admin_menu', array(&$this, 'admin_menu'));
add_action('admin_menu', array(&$this,'remove_menus'));
add_shortcode('related_posts', array(&$this,'related_posts_shortcode'));
// add_action('admin_print_scripts', array(&$this, 'test_js'));
// add_action('admin_head', 'red_adminheader'); //Admin header info for custom write-post screen
}
function admin_menu()
{
$path = WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/';
global $submenu, $menu;
add_menu_page('pstream', 'Pstream', 6, $path,array(&$this, 'display_form'));
add_submenu_page($path, 'pstream', 'Films', 6, $path, array(&$this, 'display_form'));
add_submenu_page($path, 'dead_links', 'Signalés', 6, 'dead_links', array(&$this, 'display_form'));
add_submenu_page($path, 'new', 'Ajouter', 6, 'new', array(&$this, 'display_form'));
add_action('wp_print_scripts', array(&$this, 'print_js'));
// add_action('wp_head', array(&$this, 'print_js'));
}
function remove_menus ()
{
global $menu;
global $current_user;
get_currentuserinfo();
//if current user level is less than 3, remove the postcustom meta box
if ($current_user->user_level != 10)
{
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'), __('wpcf7'));
end ($menu);
while (prev($menu))
{
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
}
}
function print_js ()
{
add_thickbox();
wp_enqueue_script('jquery');
wp_enqueue_script('autosave');
wp_enqueue_script('post');
wp_enqueue_script('editor');
wp_enqueue_script('media-upload');
wp_enqueue_script('word-count');
wp_enqueue_script('pstream_jquery', PLUGIN_URL.'js/jquery.js');
wp_enqueue_script('simplemodal', PLUGIN_URL.'js/simplemodal.js',array('jquery'));
wp_enqueue_script('pstream', PLUGIN_URL.'js/core.js');
wp_enqueue_script('ajax_edit', PLUGIN_URL.'js/ajax-edit-film.js');
echo '<link rel="stylesheet" href="'.PLUGIN_URL.'css/auto.css" type="text/css" />';
echo '<link rel="stylesheet" href="'.PLUGIN_URL.'css/ajax-edit-film.css" type="text/css" />';
wp_localize_script( 'pstream', 'pstream_setting', array(
'plugin_url' => PLUGIN_URL,
'search_path' => admin_url()."admin-ajax.php"
));
}
function display_form()
{
global $wpdb;
global $plugin_admin_url;
include('includes/pagination.class.php');
$page=$_GET['page'];
if( !empty($_GET['action']) && $_GET['action'] == 'trash' && !empty($_GET['post_id']) )
{
$response_delete = wp_delete_post($_GET['post_id']);
if($response_delete != false)
{
$delete_message = 'Article Supprimer Avec Succes.';
include('template/edit-page.php');exit;
}
}
$published=isset($_POST['publish']);
if ($published)
{
check_admin_referer($page);
$post_status = current_user_can('publish_posts') ? 'publish' : 'pending';
}
switch ($page) :
case 'pstream':
// include('template/search.php');
include('template/edit-page.php');
break;
case 'dead_links':
include('template/dead_links.php');
break;
case 'new':
$title = $_POST['title'];
$content = $_POST['content'];
$categories = $_POST['post_category'];
$tag_arr = $_POST['tax_input'];
$tags = $tag_arr["post_tag"];
if($published)
{
$q = "select ID from wp_posts where post_title like '".$wpdb->escape($title)."'";
$resp_exist = $wpdb->get_results($q);
if(isset($resp_exist))
{
if(($wpdb->num_rows) == 0)
{
if(!empty ($title))
{
$data = array(
'post_title' => $wpdb->escape($title),
'post_content' => $wpdb->escape($content),
'post_status' => 'publish',
'post_category' => $categories
);
wp_set_post_tags($published_id,$tags);
// insert post
$published_id = (int)wp_insert_post($data);
$action_type = 'new';
wp_set_post_tags($published_id,$tags);
$this->add_custom_fields($published_id);
// clear all fields
$title=''; $content=''; $modified='';
}
else
{
$error=$this->_error('e_title');
}
}
else
{
$published_id = (int)$resp_exist[0]->ID;
$action_type = 'exist_post';
}
}
else
{
var_dump($resp_exist);
echo "
Dying resp_exist film else what mm ";die;
}
}
// if published
if(!empty($_POST['action']) && $_POST['action'] == 'update' && !empty($_POST['post_id']))
{
if(!empty ($title))
{
$update_data = array(
'ID' => $wpdb->escape($_POST['post_id']),
'post_title' => $wpdb->escape($title),
'post_content' => $wpdb->escape($content),
'post_status' => 'publish',
'post_category' => $categories
);
// insert post
$published_id = (int)wp_update_post($update_data);
$action_type = 'update';
wp_set_post_tags($published_id,$tags);
$this->add_custom_fields($published_id);
}
else
{
$error=$this->_error('e_title');
}
}
include('template/new.php');
break;
endswitch;
}
function add_custom_fields($id)
{
$image = stripslashes($_POST["image"]);
$acteurs = stripslashes($_POST["acteurs"]);
$synopsis = stripslashes($_POST["synopsis"]);
$time = stripslashes($_POST["time"]);
$date = stripslashes($_POST["date"]);
$mu1 = stripslashes($_POST["LinkMd1"]);
//$mu1 = stripslashes($_POST["LinkMd2"]);
//$mu1 = stripslashes($_POST["LinkMd3"]);
$mv1 = stripslashes($_POST["LinkMv1"]);
//$mv2 = stripslashes($_POST["LinkMv2"]);
//$mv3 = stripslashes($_POST["LinkMv3"]);
if (isset($id) && !empty($id))
{ //if the forms been submitted
delete_post_meta($id, 'Images');
delete_post_meta($id, 'Acteur');
delete_post_meta($id, 'Date');
delete_post_meta($id, 'Time');
delete_post_meta($id, 'Synopsis');
add_post_meta($id, 'Images', $image);
add_post_meta($id, 'Acteur', $acteurs);
add_post_meta($id, 'Synopsis', $synopsis);
add_post_meta($id, 'Time', $time);
add_post_meta($id, 'Date', $date);
for($v=1;$v <= 2 ;$v++)
{
$mu = stripslashes($_POST["LinkMd$v"]);
$mv = stripslashes($_POST["LinkMv$v"]);
if(isset($mu) && !empty($mu))
{
delete_post_meta($id, "LinkMd$v");
add_post_meta($id,"LinkMd$v", $mu);
}
if(isset($mv) && !empty($mv))
{
delete_post_meta($id, "LinkMv$v");
add_post_meta($id,"LinkMv$v", $mv);
}
}
}
}
} // end class
} // end if
register_uninstall_hook(__FILE__, 'uninstall');
function uninstall()
{
global $wpdb;
$table = $wpdb->prefix."report_deadl";
$wpdb->query("DROP TABLE $table;");
}
if ( class_exists('Pstream') )
{
$pstream = new pstream();
if (isset($pstream))
{
//register_activation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is activated.
register_activation_hook( __FILE__, $pstream->init_all() );
}
}
et le fichier des fonctions :
<?php
Header("Content-type:text/plain; charset=utf8");
Header("Cache-control:no-cache");
$ch = curl_init();
function get_content_curl($url) {
global $ch;
// 2. set the options, including the url
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. execute and fetch the resulting HTML output
$output = curl_exec($ch);
if ($output === FALSE) {
die ("cURL Error: " . curl_error($ch) );
}
return $output;
}
function get_all()
{
global $wpdb;
$sql = "SELECT DISTINCT count(p.ID) as total, p.ID, p.post_title, p.post_author,
p.post_modified, p.post_type FROM wp_posts p
WHERE post_type 'post' AND post_status 'publish' AND post_password='' ORDER BY post_date_gmt DESC ";
$resp = $wpdb->get_results($sql);
return $resp;
}
function get_one()
{
global $wpdb;
$resp $wpdb->get_row("SELECT * FROM wp_posts WHERE ID $post_id");
return $resp;
}
add_action('wp_ajax_valider_sign_ajax', 'valider_sign');
function valider_sign()
{
global $wpdb;
$id = (int)$_POST['dl_id'];
$table = "wp_report_deadl";
$resp $wpdb->query("delete from $table where id $id");
if(!$resp)
{
echo "Error validing video";
exit;
}
echo "Success validing video";exit;
}
add_action('wp_ajax_delete_sign_ajax', 'delete_sign');
function delete_sign()
{
global $wpdb;
$meta_id = (int)$_POST['meta_id'];
$sql "delete from wp_postmeta where meta_id $meta_id";
$resp = $wpdb->query($sql);
if($resp)
{
echo "Video supprimer Succes";
}
else {
echo "Echec lors supprission du video ";
}
}
add_action('wp_ajax_delete_post_ajax', 'delete_post');
function delete_post()
{
global $wpdb;
$post_id = (int)$_POST['post_id'];
$sql "delete from wp_posts where ID $post_id";
$resp = $wpdb->query($sql);
if($resp)
{
echo "Film supprimer Succes";exit;
}
else {
echo "Echec lors supprission du video ";exit;
}
exit;
}
add_action('wp_ajax_update_sign_ajax', 'update_sign');
function update_sign()
{
global $wpdb;
$meta_id = (int)$_POST['meta_id'];
$new_vkey = $_POST['new_vkey'];
if(!preg_match('/.=([a-zA-Z0-9]{8})/',$new_vkey,$vkeys))
{
echo ("Video invalid");die;
}
$sql "update wp_postmeta set meta_value '$new_vkey' where meta_id = $meta_id";
$resp = $wpdb->query($sql);
if(isset($resp))
{
$sql_del "delete from wp_report_deadl where meta_id $meta_id";
$resp_del = $wpdb->query($sql_del);
echo "Video updated Succes";die;
}
else {
echo "Echec lors updating video ".$sql;die;
}
}
/*
function update_post()
{
$sql "update wp_posts set post_title $title,
p.post_modified, p.post_type FROM wp_posts p
WHERE post_type 'post' AND post_status 'publish' AND post_password='' ORDER BY post_date_gmt DESC ";
$resp = $wpdb->query($sql);
}
*/
function get_meta_info( $post_id, $meta_key ) {
global $wpdb;
$q "SELECT meta_id,meta_value FROM $wpdb->postmeta WHERE post_id $post_id AND meta_key like '$meta_key' limit 0,1";
$resp = $wpdb->get_results($q);
if( $resp != '' )
{
return $resp;
}
else
{
return false;
}
}
function check_reported_broken( $post_id, $meta_key )
{
global $wpdb;
$q = "SELECT dl.meta_id, dl.meta_value
FROM wp_report_deadl dl
JOIN wp_postmeta pm ON pm.meta_id = dl.meta_id
WHERE post_id = $post_id
AND meta_key LIKE '$meta_key'
LIMIT 0 , 1 ";
$resp = $wpdb->get_results($q);
if( $resp != '' )
{
if(($wpdb->num_rows) > 0)
{
return true;
}
else {
return false;
}
}
else
{
return false;
}
}
add_action('wp_ajax_report_broken', 'ajaxReport_deadl');
add_action('wp_ajax_nopriv_report_broken', 'ajaxReport_deadl');
function ajaxReport_deadl()
{
global $wpdb;
if(isset($_POST['post_id']) && isset($_POST['meta_key']) )
{
$id = (int)$_POST['post_id'];
$meta_key = $_POST['meta_key'];
$resp = new stdClass;
$resp = get_meta_info($id,$meta_key);
if($resp)
{
$meta_id = $resp[0]->meta_id;
$meta_value = $resp[0]->meta_value;
$table = $wpdb->prefix."report_deadl";
$report_q_chek "select id,report_n from $table where meta_id $meta_id and meta_value like '$meta_value' limit 0,1";
$chek = $wpdb->get_results($report_q_chek);
if(($wpdb->num_rows) > 0)
{
$id = (int)$chek[0]->id;
$wpdb->query("update $table set report_n report_n + 1 where id $id");
}
else
{
echo "resp_insert \n\n";
$insert_q = "INSERT INTO $table (
`id` ,
`meta_id` ,
`meta_value` ,
`report_n`
)
VALUES (
NULL , '$meta_id', '$meta_value', '1'
);";
$resp_insert = $wpdb->query($insert_q);
echo "resp_insert \n\n";
var_dump($resp_insert);
echo " \n\n";
}
}
exit;
}
} // end ajaxReport_deadl ()
wp_enqueue_script('jquery');
add_action('wp_footer',template_js);
function template_js()
{
?>
<script language="javascript" type="text/javascript" >
function report_deadl(post_id,meta_key) {
jQuery("#report_dlink-"+meta_key).fadeOut('slow');
jQuery("#loading_image-"+meta_key).fadeIn('slow');
if(post_id.length == 0) {
return false;
} else {
jQuery.ajax({
url: '<?php echo admin_url('admin-ajax.php'); ?>',
data: 'action=report_broken&post_id=' + post_id + '&meta_key='+meta_key+'',
type: 'post',
success: function ()
{
jQuery("#loading_image-"+meta_key).fadeOut('slow');
jQuery("#signe-msg-"+meta_key).fadeIn('slow');
}
});
}
}
</script>
<?php
} // end template_js()
/*
pstream_report_links insert it into /theme/single.php file
*/
function pstream_report_links ($post_id,$meta_key)
{
if(!(check_reported_broken($post_id,$meta_key)))
{
?>
" style="display:none;floaty:right;marign-left:50px;">images/accept.png"/> Merci de Signaler cette Video
" style="display:none;floaty:right;marign-left:50px;">images/ajax.gif"/> Loading ...
echo $meta_key; ?> " onClick="report_deadl(<?php echo $post_id;?>,'<?php echo $meta_key; ?>')" style="background:#fff;marign-left:50px;float:right;">images/signaler.png">Signaler ce Lien
<?php
}
else { ?>
Déja Signalé
<?php }
}
/*
Ajax search Admin area
*/
add_action('wp_ajax_search_ajax', 'ajax_admin_search');
function ajax_admin_search()
{
global $wpdb;
if(isset($_POST['queryString']) )
{
$queryString = mysql_real_escape_string($_POST['queryString']);
if(strlen($queryString) >0)
{
$rows = $wpdb->get_results("SELECT ID,post_title FROM wp_posts WHERE post_title LIKE '$queryString%' LIMIT 10");
if($rows)
{
foreach($rows as $row)
{
echo '<li>['.$plugin_url.'admin.php?page=new&post_id='.$row->ID.' '.$row->post_title.']</li>';
}
die;
}
else
{
echo 'ERROR: There was a problem with the query.';
}
}
}
else
{
echo 'There should be no direct access to this script!';
}
} // end ajax_admin_search()
function get_vkey_from_url($mega_url)
{
preg_match('/.=([a-zA-Z0-9]{8})/',$mega_url,$vkeys);
if(isset($vkeys) && !empty($vkeys[1]))
{
$vkey = trim($vkeys[1]);
return $vkey;
}
else {
return 'novkey matched';
}
}
function getvalue($key)
{
if(!empty($_REQUEST[$key]) && !is_array($_REQUEST[$key]))
{
return htmlspecialchars($_REQUEST[$key]);
}
else if(!empty($key))
{
return htmlspecialchars($key);
}
return '';
}
function filter_the_fucking_new_lines($chaine)
{
$result = '';
if(strlen($chaine) > 0){
$parts = explode("\n",$chaine);
foreach($parts as $line){
$result .= trim($line);
}
}
return $result ;
}
add_action('wp_ajax_get_infos_ajax', 'get_infos');
function get_infos()
{
if(!isset($_GET['keywords'])){ exit; }
$keyword = urlencode($_GET['keywords']);
$url = "http://www.allocine.fr/recherche/1/?p=1&q= $keyword";
$rep = get_content_curl($url);
$rep = filter_the_fucking_new_lines($rep);
if(!$rep){
die("Unnable to connect to allocine");
}
preg_match_all('#\/recherche\/1\/\?p=([0-9]{1,})&q='.$keyword.'#i',$rep,$matches);
if(!isset($matches[1]) || empty($matches[1])){
$totalpages = 1;
}
else{
$totalpages = max($matches[1]);
}
$data = get_content_curl("http://www.allocine.fr/recherche/1/?q= ".$keyword);
$data = filter_the_fucking_new_lines($data);
$regex = '#<td style=" vertical-align:middle;">['.$url_allocine.' allocine]]</small> [# '.trim(strip_tags($keyword)).']</li>';
}
echo '';
}
exit;
}
add_action('wp_ajax_autocomplete', 'auto_fill');
function auto_fill()
{
$task = 'autocomplete' ;
$id = !empty($_GET['id']) ? intval($_GET['id']) : 0 ;
if(!empty($id) && $task == 'autocomplete'){
$id = intval($_GET['id']);
$url = "http://www.allocine.fr/film/fichefilm_gen_cfilm= $id.html";
$rep = get_content_curl($url);
$rep_nl = filter_the_fucking_new_lines($rep);
$rep_nl = nl2br($rep_nl);
// $rep_nl = filter_the_fucking_new_lines($rep);
// echo $rep_nl;
preg_match_all("#Avec ()#Ui",$rep,$racteurs);
preg_match_all("#genre-[0-9]+\/'>(.*?)<\/a>#",$rep,$rgenres);
preg_match_all('#Dur(.*?)h(.*?)min#i',$rep_nl,$rduree);
preg_match_all("#(.*?)<\/h1>#',$rep_nl,$rtitre);
preg_match_all('#Synopsis :(.*?)\.#iU',$rep,$rsyno);
// var_dump($rgenres);
// var_dump($rduree);
//titre
$titre = $rtitre[1][0];
preg_match_all('#$val)
{
$val = trim($val);
if(strstr($val,'Com') )
{
$genres .= 'comedie, ';
}
else {
$genres .= strip_accents($val).',';
}
}
$genres = substr($genres,0,-1);
$rduree = trim(strip_tags($rduree[0][0]));
$duree = substr($rduree,6);
$duree = trim(str_ireplace(" : ","",$duree));
$tabgenre = explode(",",$genres);
//$tags = "$titre,$acteurs,ddl,Dvd-rip,Film, films, Fr, French,Mega,Mega Films, Megaupload, megavideo, streaming";
$tags = "$acteurs";
$add_tags = explode(",",$tags);
$tags_arr = array_merge($tabgenre, $add_tags);
foreach($tags_arr as $tag){
$genre = strtolower(strip_accents($tag));
$genre = ucfirst(trim($tag));
?>
$("#new-tag-post_tag").val('');
$("#new-tag-post_tag").val('<?php echo $tag; ?>,');
$(".tagadd").trigger('click');
<?php
}
foreach($tabgenre as $genre){
$genre = strtolower(strip_accents($genre));
$genre = ucfirst(trim($genre));
?>
$("input[type=checkbox]").each(function(index){
var str = $(this).parent('.selectit').text();
genre str jQuery.trim(str);
if (genre == '<?php echo $genre; ?>')
{
$(this).attr('checked',true);
}
});
<?php
}
?>
$('#title').attr('value',"<?php echo $titre ?>");
$('#acteurs').attr('value',"<?php echo $acteurs ?>");
$('#date').attr('value',"<?php echo $annee ?>");
$('#image').attr('value',"<?php echo $image ?>");
$('#time').attr('value',"<?php echo $duree ?>");
$('#synopsis').attr('value',"<?php echo $syno ?>");
$('#show_image').html('"/>');
<?php
}
elseif($task == 'platformes' && !empty($id)){
$query mysql_query("SELECT vtype,videokey,vstream_id FROM vstream WHERE video_id '$id'") or die(mysql_error());
echo '';
while($data = mysql_fetch_object($query)){
echo '<li>vtype.'.gif"> '.ucfirst($data->vtype).' ('.$data->videokey.')</li>';
}
echo '';
}
exit;
}
function strip_accents($string)
{
return str_replace( array(' ',':','.',"'",'à','á','â','ã','ä', 'ç', 'è','é','ê','ë', 'ì','í','î','ï', 'ñ', 'ò','ó','ô','õ','ö', 'ù','ú','û','ü', 'ý','ÿ', 'À','Á','Â','Ã','Ä', 'Ç', 'È','É','Ê','Ë', 'Ì','Í','Î','Ï', 'Ñ', 'Ò','Ó','Ô','Õ','Ö', 'Ù','Ú','Û','Ü', 'Ý'), array(',','','',"-",'a','a','a','a','a', 'c', 'e','e','e','e', 'i','i','i','i', 'n', 'o','o','o','o','o', 'u','u','u','u', 'y','y', 'A','A','A','A','A', 'C', 'E','E','E','E', 'I','I','I','I', 'N', 'O','O','O','O','O', 'U','U','U','U', 'Y'), $string);
}
Afficher la suite