-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestingocr.php
72 lines (52 loc) · 2.2 KB
/
testingocr.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
<?php
$x=1;
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'mathtipun';
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
$files = scandir("images/",1);
foreach ($files as $gradelevel) {
if($gradelevel != "." AND $gradelevel != ".."){
$grade = scandir("images/$gradelevel",1);
foreach ($grade as $subject) {
if($subject != "." AND $subject != ".."){
$subs = scandir("images/$gradelevel/$subject",1);
foreach ($subs as $topic) {
if($topic != "." AND $topic != ".."){
$imagesearch = scandir("images/$gradelevel/$subject/$topic",1);
$pageno=1;
foreach ($imagesearch as $oneimage) {
if($oneimage != "." AND $oneimage != ".."){
echo $gradelevel."<br>";
echo $subject."<br>";
echo $topic."<br>";
echo $oneimage."<br>";
$gradeno = str_replace('GRADE', "", $gradelevel);
$source = "images/".$gradelevel."/".$subject."/".$topic."/".$oneimage;
$resultcheck = $conn->query("SELECT * FROM content WHERE image='".$oneimage."' AND grade='".$gradeno."' AND topic='".$topic."'");
If (mysqli_num_rows($resultcheck) == 0){
$conn->query("INSERT INTO content (grade, topic, image, content, wheretopic, dir, page)
VALUES ('".$gradeno."', '".$topic."', '".$oneimage."', '', 'images/".$gradelevel."/".$subject."/".$topic."/', 'images/".$gradelevel."/".$subject."', '".$pageno."')");
If($x == 1){
$sql = "SELECT * FROM content WHERE image='".$oneimage."' AND grade='".$gradeno."' AND topic='".$topic."'";
$retval = $conn->query($sql);
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {
echo "
<script>
window.open('updatecontent.php?getid=".$row['id']."&source=".$source."', '_blank');
</script>";
}
}
}
$pageno++;
$x++;
}
}
}
}
}
}
}
}
?>