-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimportcat.php
More file actions
136 lines (119 loc) · 3.43 KB
/
importcat.php
File metadata and controls
136 lines (119 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
// Load WordPress
require_once './wp-load.php';
require_once './wp-admin/includes/taxonomy.php';
ini_set('memory_limit', '2048M');
// Set the timezone so times are calculated correctly
date_default_timezone_set('Europe/Paris');
function traitement_youtube($content){
$re = '/(\<div.+youtube\.com\/watch\?v=(\w+).+\<\/div\>)/';
//$replacement = "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/$2\" frameborder=\"0\" allowfullscreen></iframe>";
$replacement = "http://www.youtube.com/watch?v=$2";
$content = preg_replace($re, $replacement, $content);
//preg_match_all($re, $content, $matches, PREG_SET_ORDER, 0);
return $content;
}
function insert_news($news_id,$old_newsid) {
$host = "localhost";
$dbname = "wp";
$login_db = "root";
$pwd_db = "";
$bdd = new PDO('mysql:host='.$host.';dbname='.$dbname.';charset=utf8', $login_db , $pwd_db);
$reponse = $bdd->query('insert into wp_transpo_news values(\''.$news_id.'\','.$old_newsid.');');
$donnees = $reponse->fetch();
}
function update_news($news_id,$old_newsid) {
$host = "localhost";
$dbname = "wp";
$login_db = "root";
$pwd_db = "";
$bdd = new PDO('mysql:host='.$host.';dbname='.$dbname.';charset=utf8', $login_db , $pwd_db);
$reponse = $bdd->query('update wp_posts set ID = '.$old_newsid.' where ID = '.$news_id.';');
$donnees = $reponse->fetch();
return $old_newsid;
}
function get_user($oldid) {
$host = "localhost";
$dbname = "wp";
$login_db = "root";
$pwd_db = "";
$bdd = new PDO('mysql:host='.$host.';dbname='.$dbname.';charset=utf8', $login_db , $pwd_db);
$reponse = $bdd->query('select * from wp_transpo_authors where author_id=\''.$oldid.'\';');
$donnees = $reponse->fetch();
return $donnees['id'];
}
function get_game($id) {
$host = "localhost";
$dbname = "nofrag_old";
$login_db = "root";
$pwd_db = "";
$bdd = new PDO('mysql:host='.$host.';dbname='.$dbname.';charset=utf8', $login_db , $pwd_db);
$reponse = $bdd->query('select * from games where id=\''.$id.'\';');
$donnees = $reponse->fetch();
return $donnees['name'];
}
$host = "localhost";
$dbname = "nofrag_old";
$login_db = "root";
$pwd_db = "";
$bdd = new PDO('mysql:host='.$host.';dbname='.$dbname.';charset=utf8', $login_db , $pwd_db);
$reponse = $bdd->query('select * from news order by news_id desc;');
$i = 0;
while ($donnees = $reponse->fetch()){
echo $donnees['type_id'];
switch ($donnees['type_id']){
//annonce
case '9':
wp_set_post_terms($id, 147, 'category');
break ;
//chroniques
case '23':
wp_set_post_terms($id, 132, 'category');
break;
// bullshit
case '36' :
wp_set_post_terms($id, 144, 'category');
break ;
// business
case '20' :
wp_set_post_terms($id, 141, 'category');
break;
// dossiers
case '22' :
wp_set_post_terms($id, 133, 'category');
break;
// mod
case '15' :
wp_set_post_terms($id, 146, 'category');
break;
// vrac
case '18' :
wp_set_post_terms($id, 142, 'category');
break ;
// patch
case '7' :
wp_set_post_terms($id, 143, 'category');
break ;
// preview
case '2' :
wp_set_post_terms($id, 131, 'category');
break ;
// bons plans
case '35' :
wp_set_post_terms($id, 134, 'category');
break;
//Tests
case '12' :
wp_set_post_terms($id, 129, 'category');
break;
//vidéos
case '6':
wp_set_post_terms($id, 145, 'category');
break;
default :
// news par défaut
//wp_set_post_terms($id, 130, 'category');
}
}
echo "ok ".$i;
?>