| Server IP : 192.169.170.185 / Your IP : 216.73.216.97 Web Server : Apache System : Linux p3plmcpnl495852.prod.phx3.secureserver.net 4.18.0-553.52.1.lve.el8.x86_64 #1 SMP Wed May 21 15:31:29 UTC 2025 x86_64 User : akhilnew ( 1712764) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/akhilnew/public_html/datacomjournal.com/admin/ |
Upload File : |
<?php
isset($package) OR die('No direct access allowed.');
if($opt1 && ($opt1 === 'add' OR $opt1 === 'edit')):
if($opt1 === 'edit' && $opt2):
$stmt = $mysqli->prepare("SELECT $firstcol, category, content, alignment, status, catsortnumber, sortnumber FROM $table WHERE $firstcol = ? LIMIT 1") or die($mysqli->error);
$stmt->bind_param('i', $opt2);
$stmt->execute();
$stmt->store_result();
$count_rows = $stmt->num_rows();
$stmt->bind_result($id, $category, $content, $alignment, $status, $catsortnumber, $sortnumber);
$stmt->fetch();
$stmt->close();
if($count_rows !== 1):
die('Invalid data selection.');
endif;
else:
$id = '';$category = '';$content = '';$alignment = 'T';$status = 'enabled';$catsortnumber = '';$sortnumber = '';
endif;
$talignment = $alignment === 'T' ? 'checked' : '';
$lalignment = $alignment === 'L' ? 'checked' : '';
$ralignment = $alignment === 'R' ? 'checked' : '';
$status = $status === 'enabled' ? 'checked' : '';
function categories(){
global $mysqli, $table;$html = '';
$stmt = $mysqli->prepare("SELECT category FROM $table GROUP BY category ORDER BY category ASC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows() > 0):
$stmt->bind_result($category);
while($stmt->fetch()):
$html .= $category ? '<option value="'.html_entity_decode($category).'">'.html_entity_decode($category).'</option>' : '';
endwhile;
endif;
$stmt->close();
return $html;
}
$categories = categories();
echo <<<EOJ
<input type="hidden" name="dataid" value="{$id}" readonly />
<div class="head">
<button type="button" class="waves-effect btn-flat" onclick="history.back()"><i class="material-icons">keyboard_return</i></button>
<button type="submit" class="waves-effect btn-flat blue accent-4 white-text">Submit</button>
<input type="text" name="uploadedfileurl" placeholder="Uploaded file URL" class="grey lighten-2 right url" onfocus="this.select()" readonly />
</div>
<div class="body">
<div class="row">
<div class="col s12 m12 l12">
<label for="category">category</label>
<div class="flex">
<input type="text" name="category" value="{$category}" id="category" list="categorylist" />
<datalist id="categorylist">{$categories}</datalist>
<label for="applytoall" class="chklab left"><input type="checkbox" name="applytoall" value="Y" id="applytoall" />apply to all</label>
</div>
</div>
</div>
<div class="row">
<div class="col s12 m12 l12 md">
<label for="content">content</label><br clear="all">
<textarea rows="25" cols="25" name="content" class="htmleditor">{$content}</textarea>
</div>
</div>
<div class="row">
<div class="col s12 m6 l6">
<label for="catsortnumber">category sort number</label>
<input type="text" name="catsortnumber" value="{$catsortnumber}" maxlength="2" pattern="[0-9]+" id="catsortnumber" class="int" onpaste="return false" />
</div>
<div class="col s12 m6 l6">
<label for="sortnumber">sort number</label>
<input type="text" name="sortnumber" value="{$sortnumber}" maxlength="3" pattern="[0-9]+" id="sortnumber" class="int" onpaste="return false" />
</div>
</div>
<div class="row">
<div class="col s12 m6 l6">
<label class="chklab left" style="padding:0 10px">alignment</label>
<label for="T" class="chklab left"><input type="radio" name="alignment" value="T" id="T" {$talignment} />top</label>
<label for="R" class="chklab left"><input type="radio" name="alignment" value="R" id="R" {$ralignment} />right</label>
<label for="L" class="chklab left"><input type="radio" name="alignment" value="L" id="L" {$lalignment} />left</label>
</div>
<div class="col s12 m6 l6">
<label for="status" class="chklab left"><input type="checkbox" name="status" value="enabled" id="status" {$status} />status</label>
</div>
</div>
</div>
<div class="fixed-action-btn">
<button type="button" class="btn-floating blue accent-4" onclick="$('.upf').show(0);"><i class="material-icons">file_upload</i></button>
</div>
EOJ;
else:
$stmt = $mysqli->prepare("SELECT * FROM $table") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
$total_rows = $stmt->num_rows();
$stmt->close();
echo <<<EOJ
<div class="head">
<button type="button" class="waves-effect btn-flat green white-text" onclick="_curl('add')">Add new</button>
<button type="submit" class="waves-effect btn-flat h" onclick="_sopt('enabled')">Enable</button>
<button type="submit" class="waves-effect btn-flat h" onclick="_sopt('disabled')">Disable</button>
<button type="submit" class="waves-effect btn-flat red h" onclick="_sopt('delete', 'Do you really want to delete?')"><i class="material-icons white-text">delete</i></button>
<div class="pagination right"><b class="left">Total Rows : {$total_rows}</b></div>
</div>
<table class="table">
<thead>
<tr>
<th class="xs center-align" nowrap><input type="checkbox" name="checkall" value="" class="checkall" /></th>
<th class="xs center-align" nowrap>s. no.</th>
<th>category</th>
<th>content</th>
<th class="sm center-align" nowrap>alignment</th>
<th class="sm center-align" nowrap>status</th>
<th class="sm center-align" nowrap>c. sort num.</th>
<th class="sm center-align" nowrap>sort num.</th>
<th class="lg right-align" nowrap>creation</th>
<th class="sm center-align" nowrap>action</th>
</tr>
</thead>
<tbody>
EOJ;
$stmt = $mysqli->prepare("SELECT $firstcol, category, content, alignment, status, catsortnumber, sortnumber, creation FROM $table ORDER BY catsortnumber ASC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows() > 0):
$stmt->bind_result($id, $category, $content, $alignment, $status, $catsortnumber, $sortnumber, $creation);
while($stmt->fetch()):
$snum = $snum + 1;
$content= html_entity_decode($content);
$color = $status === 'enabled' ? 'green-text' : 'red-text';
$option = $status === 'enabled' ? 'disabled' : 'enabled';
echo <<<EOJ
<tr>
<td class="center-align" nowrap><input type="checkbox" name="dataid[]" value="{$id}" class="checkbox" /></td>
<td class="center-align" nowrap>{$snum}</td>
<td>{$category}</td>
<td>{$content}</td>
<td class="center-align" nowrap>{$alignment}</td>
<td class="center-align" nowrap><button type="submit" class="{$color}" onclick="_sopt('{$option}', '', this)">{$status}</button></td>
<td class="center-align" nowrap>{$catsortnumber}</td>
<td class="center-align" nowrap>{$sortnumber}</td>
<td class="right-align" nowrap>{$fn->nice_date($creation)}</td>
<td class="center-align" nowrap><button type="button" class="blue-text text-accent-4" onclick="_curl('edit/{$id}')">edit</button></td>
</tr>
EOJ;
endwhile;
else:
echo '<tr><td colspan="10" class="center-align">MySQL returned an empty result set (i.e. zero rows).</td></tr>';
endif;
$stmt->close();
echo '</tbody>';
echo '</table>';
endif;
?>