File: /var/www/content-sp/work-sp/oly_wiris_image.php
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
include 'config.php';
$mType = 'oly';
include 'str_replace_type.php';
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$root_link = $protocol . $_SERVER['HTTP_HOST'] . '/';
$offset = $_REQUEST['off'] != '' ? $_REQUEST['off'] : '1';
// $count = $conn->query("SELECT count(question_id) as c FROM csp_sp_question WHERE (question_statement LIKE '%showimage.php%' OR option_1 LIKE '%showimage.php%' OR option_2 LIKE '%showimage.php%' OR option_3 LIKE '%showimage.php%' OR option_4 LIKE '%showimage.php%' OR question_solution LIKE '%showimage.php%') and question_of LIKE '%csc-olympiad%'");
// $f = $count->fetch_assoc();
// echo $f['c'];
// die();
$query = $conn->query("SELECT question_id,question_statement,option_1,option_2,option_3,option_4,question_solution FROM csp_sp_question WHERE (question_statement LIKE '%showimage.php%' OR option_1 LIKE '%showimage.php%' OR option_2 LIKE '%showimage.php%' OR option_3 LIKE '%showimage.php%' OR option_4 LIKE '%showimage.php%' OR question_solution LIKE '%showimage.php%') and question_of LIKE '%csc-olympiad%' order by question_id asc limit $offset,500");
?>
<table border="1">
<tr>
<th>S.no</th>
<th>Question Id</th>
<th>Statement</th>
<th>Option 1</th>
<th>Option 2</th>
<th>Option 3</th>
<th>Option 4</th>
<th>Sol</th>
<!-- <th>Src</th>
<th>PathRead</th> -->
</tr>
<?php $i = 1 + $offset;
foreach ($query as $q) {
$question = str_replace('../', $root_link, $q['question_statement']);
$question = str_replace($spaceArray, $replaceSpaceArray, $question);
$question_solution = str_replace('../', $root_link, $q['question_solution']);
$question_solution = str_replace($spaceArray, $replaceSpaceArray, $question_solution);
$option1 = str_replace('../', $root_link, $q['option_1']);
$option1 = str_replace($spaceArray, $replaceSpaceArray, $option1);
$option2 = str_replace('../', $root_link, $q['option_2']);
$option2 = str_replace($spaceArray, $replaceSpaceArray, $option2);
if ($q['option_3']) {
$option3 = str_replace('../', $root_link, $q['option_3']);
$option3 = str_replace($spaceArray, $replaceSpaceArray, $option3);
} else {
$option3 = "";
}
if ($q['option_4']) {
$option4 = str_replace('../', $root_link, $q['option_4']);
$option4 = str_replace($spaceArray, $replaceSpaceArray, $option4);
} else {
$option4 = "";
}
// $doc = new DOMDocument();
// $doc->loadHTML($question);
// $xpath = new DOMXPath($doc);
// $imgSrc = $xpath->evaluate("string(//img/@src)");
?>
<tr>
<td><?php echo $i; ?></td>
<td>
<a href="nqb_question_edit?action=edit&quesId=<?php echo $q['question_id']; ?>&mType=oly" target="_blank" rel="noopener noreferrer">
<?php echo $q['question_id']; ?>
</a>
</td>
<td><?php echo $question; ?></td>
<td><?php echo $option1; ?></td>
<td><?php echo $option2; ?></td>
<td><?php echo $option3; ?></td>
<td><?php echo $option4; ?></td>
<td><?php echo $question_solution; ?></td>
<!-- <td><?php //echo $imgSrc;
?></td>
<td><?php //readfile($imgSrc);
?></td> -->
</tr>
<?php $i++;
} ?>
</table>
<style>
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
@media screen and (max-width: 600px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
/* general styling */
body {
font-family: "Open Sans", sans-serif;
line-height: 1.25;
}
</style>