-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.php
executable file
·117 lines (105 loc) · 3.02 KB
/
extension.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
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
<?php
require 'info.php';
extract($_GLOBALS);
function delete($problem_id){
$link = mysql_connect($hostname,$user,$pass);
if (!$link) {
die('error');
}
$db_selected = mysql_select_db($db_name, $link);
if(!$db_selected){
die('error');
}
$sql = sprintf("SELECT image_path FROM problems WHERE problem_id = %s",$problem_id);
$result = mysql_query($sql);
$image_path = mysql_result($result,0);
echo $image_path;
$first_path = sprintf("%s",$image_path);
$second_path = sprintf("escape/image_%s",$problem_id);
echo ($first_path);
echo (" ");
echo ($second_path);
$res = rename($first_path, $second_path);
if(!$res){
echo ("error");
}else{
echo ("OK");
}
$sql = sprintf("SELECT csv_path FROM problems WHERE problem_id = %s",$problem_id);
$result = mysql_query($sql);
$csv_path = mysql_result($result,0);
$first_path = sprintf("%s",$csv_path);
$second_path = sprintf("escape/scv_%s",$problem_id);
rename($first_path, $second_path);
$sql = sprintf("SELECT thumb_path from problems where problem_id = %s",$problem_id);
$result = mysql_query($sql);
$thumb_path = mysql_result($result,0);
$first_path = sprintf("%s",$thumb_path);
$second_path = sprintf("escape/thumb_%s",$problem_id);
rename($first_path, $second_path);
$sql = sprintf("SELECT score_id FROM score WHERE problem_id = %s",$problem_id);
$result = mysql_query($sql);
if(mysql_num_rows($result)==0){
echo ("なかった");
problem_delete($problem_id);
}else{
while($score_id = mysql_fetch_array($result, MYSQL_NUM)){
$sql = sprintf("DELETE from answers where score_id = %s",$score_id[0]);
mysql_query($sql);
}
echo ("あった");
problem_delete($problem_id);
}
}
function problem_delete($problem_id){
echo ("problem_delete");
$link = mysql_connect($hostname,$user,$pass);
if (!$link) {
die('error');
}
$db_selected = mysql_select_db($db_name, $link);
if(!$db_selected){
die('error');
}
$sql = sprintf("DELETE FROM problem_info WHERE problem_id = %s",$problem_id);
$res = mysql_query($sql);
if($res) {
echo ("ok");
}else{
echo ("NG");
}
$sql = sprintf("DELETE FROM score WHERE problem_id = %s",$problem_id);
mysql_query($sql);
$sql = sprintf("DELETE FROM problems WHERE problem_id = %s",$problem_id);
mysql_query($sql);
}
function ans_delete($ans_id){
$link = mysql_connect($hostname,$user,$pass);
if (!$link) {
die('error1');
}
$db_selected = mysql_select_db($db_name, $link);
if(!$db_selected){
echo "error2";
echo mysql_error($link);
die();
}
$sql = sprintf("DELETE FROM answers WHERE score_id = %s",$ans_id);
$res = mysql_query($sql);
if($res == true){
$sql = sprintf("DELETE FROM score WHERE score_id = %s",$ans_id);
$res = mysql_query($sql);
if($res == true){
echo("ok");
}
}else{
echo "error3";
echo mysql_error($link);
}
}
if (isset($_POST["problem_id"])){
delete($_POST["problem_id"]);
}else if(isset($_POST["score_id"])){
ans_delete($_POST["score_id"]);
}
?>