| 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/electrojournal.com/admin/ |
Upload File : |
<?php
if($opt1 && ($opt1 === 'add' OR $opt1 === 'edit')):
if($opt1 === 'edit' && $opt2):
$stmt = $mysqli->prepare("SELECT $firstcol, category, text, link, rel, target, 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, $text, $link, $rel, $target, $catsortnumber, $sortnumber);
$stmt->fetch();
$stmt->close();
if($count_rows !== 1):
die('Invalid data selection.');
endif;
else:
$id = '';$category = '';$text = '';$link = '';$rel = 'dofollow';$target = '_blank';$catsortnumber = '';$sortnumber = '';
endif;
$dofollow = $rel === 'dofollow' ? 'selected' : '';
$nofollow = $rel === 'nofollow' ? 'selected' : '';
$blank = $target === '_blank' ? 'selected' : '';
$self = $target === '_self' ? 'selected' : '';
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 .= '<option value="'.$category.'">'.$category.'</option>';
endwhile;
endif;
$stmt->close();
return $html;
}
$categories = categories();
echo <<<EOJ
<input type="hidden" name="dataid" value="{$id}" readonly />
<div class="head white">
<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>
</div>
<div class="body white">
<div class="row">
<div class="col s12 m12 l12">
<label for="category">category<b class="red-text right">*</b></label>
<input type="text" name="category" value="{$category}" id="category" list="categorylist" />
<datalist id="categorylist">{$categories}</datalist>
</div>
</div>
<div class="row">
<div class="col s12 m12 l6">
<label for="text">text<b class="red-text right">*</b></label>
<input type="text" name="text" value="{$text}" id="text" />
</div>
<div class="col s12 m12 l6">
<label for="link">link<b class="red-text right">*</b></label>
<input type="text" name="link" value="{$link}" id="link" />
</div>
</div>
<div class="row">
<div class="col s12 m12 l6">
<label for="rel">rel<b class="red-text right">*</b></label>
<select name="rel" id="rel" class="browser-default">
<option value="dofollow" {$dofollow}>dofollow</option>
<option value="nofollow" {$nofollow}>nofollow</option>
</select>
</div>
<div class="col s12 m12 l6">
<label for="target">target<b class="red-text right">*</b></label>
<select name="target" id="target" class="browser-default">
<option value="_blank" {$blank}>_blank</option>
<option value="_self" {$self}>_self</option>
</select>
</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}" id="catsortnumber" />
</div>
<div class="col s12 m6 l6">
<label for="sortnumber">sort number</label>
<input type="text" name="sortnumber" value="{$sortnumber}" id="sortnumber" />
</div>
</div>
</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 white">
<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"><input type="checkbox" name="checkall" id="checkall" value="" /></th>
<th class="xs center-align">s. no.</th>
<th>category</th>
<th>link</th>
<th>rel</th>
<th>target</th>
<th class="center-align" style="width:100px">c. sort number</th>
<th class="center-align" style="width:100px">sort number</th>
<th class="sm center-align">status</th>
<th class="lg center-align">creation</th>
<th class="sm center-align">action</th>
</tr>
</thead>
<tbody>
EOJ;
$stmt = $mysqli->prepare("SELECT $firstcol, category, text, link, rel, target, catsortnumber, sortnumber, status, creation FROM $table ORDER BY id DESC") or die($mysqli->error);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows() > 0):
$stmt->bind_result($id, $category, $text, $link, $rel, $target, $catsortnumber, $sortnumber, $status, $creation);
while($stmt->fetch()):
$snum = $snum + 1;
$statuscolor = $status === 'enabled' ? 'green-text' : 'red-text';
$option = $status === 'enabled' ? 'disabled' : 'enabled';
echo <<<EOJ
<tr>
<td class="center-align"><input type="checkbox" name="dataid[]" value="{$id}" class="checkbox" /></td>
<td class="center-align">{$snum}</td>
<td>{$category}</td>
<td><a href="{$link}" target="_blank">{$text}</a></td>
<td>{$rel}</td>
<td>{$target}</td>
<td class="center-align">{$catsortnumber}</td>
<td class="center-align">{$sortnumber}</td>
<td class="center-align"><button type="submit" class="{$statuscolor}" onclick="_sopt('{$option}', '', this)">{$status}</button></td>
<td class="right-align">{$fn->nice_date($creation)}</td>
<td class="center-align"><button type="button" class="blue-text text-accent-3" onclick="cURL('edit/{$id}')">edit</button></td>
</tr>
EOJ;
endwhile;
else:
echo '<tr><td colspan="11" class="center-align">MySQL returned an empty result set (i.e. zero rows).</td></tr>';
endif;
$stmt->close();
echo '</tbody>';
echo '</table>';
endif;
?>