-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbsTools.php
executable file
·54 lines (51 loc) · 1.29 KB
/
dbsTools.php
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
<?php
$mysql = new mysqli("courseindex.db","yangzhou","19910728","test");
if (mysqli_connect_errno()) {
echo mysqli_connect_error();
exit();
}
function updateCourseDesc(){
$desc;
global $mysql;
if($result = $mysql->query("select * from course_desc")){
try{
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$desc =trim($row[descr]);
$id = $row[course_id];
$name =explode("</h1>",$desc);
//print $name[]
if(!strpos($name[0],"</a>")){
//echo $name[0]."<br>";
$name = explode("(",$name[0]);
$name=trim($name[0]);
$name=trim(strstr(trim(strstr(trim(strstr($name," "))," "))," "));
if($r = $mysql->query("update courses set name = \"$name\" where course_id = \"$id\"")){}
else{
echo $mysql->error."<br>";
}
echo($id."<br>");
}
else{
$name = explode("</a>",$name[0]);
$name = explode("(",$name[1]);
$name=trim($name[0]);
if($r = $mysql->query("update courses set name = \"$name\" where course_id = \"$id\"")){}
else{
echo $mysql->error."<br>";
}
echo($id."<br>");
}
}
}
catch(Exception $e){
echo $e->getTraceAsString();
}
}
else{
echo "<b>$query</b>";
echo $mysql->error."<br>";
}
}
//phpinfo();
updateCourseDesc();
?>