Cześć, kupiłem skrypt, jednak posiada on błędy, a autor powiedział że nie udziela wsparcia gdyż skryptu już nie rozwija.
Potrzebuję pomocy, gdyż nie wiem jak to naprawić.
Moduł dodawania ogłoszeń z panelu admina działa dobrze, natomiast z poziomu użytkownika nie działa.
Gdy użytkownik dodaje ogłoszenie nie jest ono dodawane do bazy.
Działający kod z panelu admina:
<?php
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }
$errMessage = '';
if(isset($_GET['edit'])){
$id = $db->EscapeString($_GET['edit']);
$edit = $db->QueryFetchArray("SELECT * FROM `jobs` WHERE `id`='".$id."'");
if(isset($_POST['submit']) && !empty($_POST['title']) && !empty($_POST['description']) && !empty($_POST['requirement']) && is_numeric($_POST['type']) && is_numeric($_POST['reward'])){
$title = $db->EscapeString($_POST['title']);
$description = htmlentities(htmlspecialchars($_POST['description']));
$requirement = $db->EscapeString($_POST['requirement']);
$type = $db->EscapeString($_POST['type']);
$reward = $db->EscapeString($_POST['reward']);
$db->Query("UPDATE `jobs` SET `title`='".$title."', `description`='".$description."', `requirement`='".$requirement."', `type`='".$type."', `reward`='".$reward."' WHERE `id`='".$id."'");
$errMessage = '<div class="alert success"><span class="icon"></span><strong>Success!</strong> Job was successfully edited!</div>';
}
}elseif(isset($_GET['del']) && is_numeric($_GET['del'])){
$del = $db->EscapeString($_GET['del']);
$db->Query("DELETE FROM `jobs` WHERE `id`='".$del."'");
$db->Query("DELETE FROM `jobs_done` WHERE `job_id`='".$del."'");
}elseif(isset($_GET['pending']) && isset($_GET['approve']) && is_numeric($_GET['approve'])){
$job_id = $db->EscapeString($_GET['approve']);
$job = $db->QueryFetchArray("SELECT * FROM `jobs_done` WHERE `id`='".$job_id."' LIMIT 1");
if(!empty($job['uid'])){
if($job['type'] == 1){
$user = $db->QueryFetchArray("SELECT `premium` FROM `users` WHERE `id`='".$job['uid']."' LIMIT 1");
$premium = ($user['premium'] == 0 ? (time()+(86400*$job['reward'])) : ((86400*$job['reward'])+$user['premium']));
$db->Query("UPDATE `users` SET `premium`='".$premium."' WHERE `id`='".$job['uid']."'");
} elseif($job['type'] == 2) {
$db->Query("UPDATE `users` SET `account_balance`=`account_balance`+'".$job['reward']."' WHERE `id`='".$job['uid']."'");
} else {
$db->Query("UPDATE `users` SET `coins`=`coins`+'".$job['reward']."' WHERE `id`='".$job['uid']."'");
}
}
$db->Query("UPDATE `jobs_done` SET `status`='1' WHERE `id`='".$job_id."'");
$errMessage = '<div class="alert success"><span class="icon"></span><strong>SUCCESS:</strong> Job was successfully approved!</div>';
}elseif(isset($_GET['pending']) && isset($_GET['reject']) && is_numeric($_GET['reject'])){
$job_id = $db->EscapeString($_GET['reject']);
$db->Query("UPDATE `jobs_done` SET `status`='2' WHERE `id`='".$job_id."'");
$errMessage = '<div class="alert success"><span class="icon"></span><strong>SUCCESS:</strong> Job was successfully rejected!</div>';
}
if(isset($_POST['add'])){
$title = $db->EscapeString($_POST['title']);
$description = htmlentities(htmlspecialchars($_POST['description']));
$requirement = $db->EscapeString($_POST['requirement']);
$type = $db->EscapeString($_POST['type']);
$reward = $db->EscapeString($_POST['reward']);
if(!empty($title ) && !empty($description) && !empty($requirement) && is_numeric($type) && !empty($reward)){
$db->Query("INSERT INTO `jobs`(`title`,`description`,`requirement`,`reward`,`type`,`time`) VALUES ('".$title."', '".$description."', '".$requirement."', '".$reward."', '".$type."','".time()."')");
$errMessage = '<div class="alert success"><span class="icon"></span><strong>SUCCESS:</strong> Job was successfully added!</div>';
}else{
$errMessage = '<div class="alert error"><span class="icon"></span><strong>ERROR:</strong> You have to complete all fields!</div>';
}
}
if(isset($_GET['edit']) && !empty($edit['id'])){
?>
<section id="content" class="container_12 clearfix"><?=$errMessage?>
<div class="grid_12">
<form action="" method="post" class="box">
<div class="header">
<h2>Edit Job</h2>
</div>
<div class="content">
<div class="row">
<label><strong>Title</strong></label>
<div><input type="text" name="title" value="<?=(isset($_POST['title']) ? $_POST['title'] : $edit['title'])?>" required /></div>
</div>
<div class="row">
<label><strong>Description & Requirements</strong></label>
<div><textarea class="editor" name="description" id="description" required /><?=(isset($_POST['description']) ? $_POST['description'] : html_entity_decode(htmlspecialchars_decode($edit['description'])))?></textarea></div>
</div>
<div class="row">
<label><strong>Requirement</strong></label>
<div><input type="text" name="requirement" value="<?=(isset($_POST['requirement']) ? $_POST['requirement'] : $edit['requirement'])?>" required /></div>
</div>
<div class="row">
<label><strong>Reward Type</strong></label>
<div><select name="type"><option value="0">Coins</option><option value="1"<?=(!isset($_POST['type']) && $edit['type'] == 1 ? ' selected' : (isset($_POST['type']) && $_POST['type'] == 1 ? ' selected' : ''))?>>VIP Days</option><option value="2"<?=(!isset($_POST['type']) && $edit['type'] == 2 ? ' selected' : (isset($_POST['type']) && $_POST['type'] == 2 ? ' selected' : ''))?>>Money</option></select></div>
</div>
<div class="row">
<label><strong>Reward</strong></label>
<div><input type="text" name="reward" value="<?=(isset($_POST['reward']) ? $_POST['reward'] : $edit['reward'])?>" required /></div>
</div>
</div>
<div class="actions">
<div class="right">
<input type="submit" value="Edit Job" name="submit" />
</div>
</div>
</form>
</div>
</section>
<?php }elseif(isset($_GET['add'])){?>
<section id="content" class="container_12 clearfix"><?=$errMessage?>
<div class="grid_12">
<form action="" method="post" class="box">
<div class="header">
<h2>Add Job</h2>
</div>
<div class="content">
<div class="row">
<label><strong>Title</strong></label>
<div><input type="text" name="title" placeholder="Create youtube video / blog post / banner ads" required /></div>
</div>
<div class="row">
<label><strong>Description & Requirements</strong></label>
<div><textarea class="editor" name="description" id="description" required /></textarea></div>
</div>
<div class="row">
<label><strong>Requirement</strong></label>
<div><input type="text" name="requirement" placeholder="URL of the video / blog post / website ads" required /></div>
</div>
<div class="row">
<label><strong>Reward Type</strong></label>
<div><select name="type"><option value="0">Coins</option><option value="1">VIP Days</option><option value="2">Money</option></select></div>
</div>
<div class="row">
<label><strong>Reward</strong></label>
<div><input type="text" name="reward" placeholder="100" required /></div>
</div>
</div>
<div class="actions">
<div class="right">
<input type="submit" value="Add Job" name="add" />
</div>
</div>
</form>
</div>
</section>
<?php }elseif(isset($_GET['pending'])){?>
<section id="content" class="container_12 clearfix">
<h1 class="grid_12">Completed Jobs</h1>
<div class="grid_12">
<div class="box">
<table class="styled">
<thead>
<tr>
<th width="10">#</th>
<th>User</th>
<th>Job ID</th>
<th>Job Requirement</th>
<th>Reward</th>
<th>Status</th>
<th>Time</th>
<th width="90">Actions</th>
</tr>
</thead>
<tbody>
<?php
$page = (isset($_GET['p']) ? $_GET['p'] : 0);
$limit = 20;
$start = (is_numeric($page) && $page > 0 ? ($page-1)*$limit : 0);
$total_pages = $db->QueryGetNumRows("SELECT `id` FROM `jobs_done`");
include_once('../system/libs/apaginate.php');
$jobs = $db->QueryFetchArrayAll("SELECT a.*, b.login FROM jobs_done a LEFT JOIN users b ON b.id = a.uid ORDER BY a.time DESC LIMIT ".$start.",".$limit);
if(count($jobs) == 0) {
echo '<tr><td colspan="7" style="text-align: center">Nothing here yet!</td></tr>';
}
foreach($jobs as $job){
?>
<tr>
<td><?=$job['id']?></td>
<td><a href="index.php?x=users&edit=<?=$job['uid']?>"><?=$job['login']?></a></td>
<td><a href="index.php?x=jobs&edit=<?=$job['job_id']?>"><?=$job['job_id']?></a></td>
<td><?=$job['requirement']?></td>
<td><?=($job['type'] == 1 ? number_format($job['reward'], 0).' VIP days' : ($job['type'] == 2 ? get_currency_symbol($config['currency_code']).$job['reward'] : number_format($job['reward'], 0).' coins'))?></td>
<td class="center"><?=($job['status'] == 2 ? '<font color="red">Rejected</font>' : ($job['status'] == 1 ? '<font color="green">Complete</font>' : '<font color="blue">Pending</font>'))?></td>
<td><?=date('d M Y - H:i', $job['time'])?></td>
<td class="center">
<?php if($job['status'] == 0) { ?>
<a href="index.php?x=jobs&pending&approve=<?=$job['id']?>" class="button small grey tooltip" data-gravity=s title="Approve"><i class="icon-ok"></i></a>
<a href="index.php?x=jobs&pending&reject=<?=$job['id']?>" class="button small grey tooltip" data-gravity=s title="Reject"><i class="icon-remove"></i></a>
<?php
} else {
echo 'N/A';
}
?>
</td>
</tr>
<?php }?>
</tbody>
</table>
<?php if($total_pages > $limit){ ?>
<div class="dataTables_wrapper">
<div class="footer">
<div class="dataTables_paginate paging_full_numbers">
<a class="first paginate_button" href="<?=GetHref('p=1')?>">First</a>
<?=(($page <= 1 || $page == '') ? '<a class="previous paginate_button paginate_button_disabled">«</a>' : '<a class="previous paginate_button" href="'.GetHref('p='.($page-1)).'">«</a>')?>
<span><?=$pagination?></span>
<?=(($page >= $lastpage) ? '<a class="next paginate_button paginate_button_disabled">»</a>' : '<a class="next paginate_button" href="'.GetHref('p='.($page == 0 ? 2 : $page+1)).'">»</a>')?>
<a class="last paginate_button" href="<?=GetHref('p='.$lastpage)?>">Last</a>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</section>
<?php }else{?>
<section id="content" class="container_12 clearfix">
<h1 class="grid_12">Jobs</h1>
<div class="grid_12">
<div class="box">
<table class="styled">
<thead>
<tr>
<th width="10">ID</th>
<th>Title</th>
<th>Reward</th>
<th>Time</th>
<th width="90">Actions</th>
</tr>
</thead>
<tbody>
<?php
$jobs = $db->QueryFetchArrayAll("SELECT * FROM `jobs`");
if(count($jobs) == 0) {
echo '<tr><td colspan="5" style="text-align: center">Nothing here yet!</td></tr>';
}
foreach($jobs as $job){
?>
<tr>
<td><?=$job['id']?></td>
<td><?=$job['title']?></td>
<td><?=($job['type'] == 1 ? number_format($job['reward'], 0).' VIP days' : ($job['type'] == 2 ? get_currency_symbol($config['currency_code']).$job['reward'] : number_format($job['reward'], 0).' coins'))?></td>
<td><?=date('d M Y - H:i', $job['time'])?></td>
<td class="center">
<a href="index.php?x=jobs&edit=<?=$job['id']?>" class="button small grey tooltip" data-gravity=s title="Edit"><i class="icon-pencil"></i></a>
<a href="index.php?x=jobs&del=<?=$job['id']?>" class="button small grey tooltip" data-gravity=s title="Remove"><i class="icon-remove"></i></a>
</td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</section>
<?php }?>
Pliki pochodzące z panelu użytkownika:
https://drive.google.com/drive/folders/1Vrrl3gQmFpnLNfGH8gKNZ4vFXjRYvhWV?usp=sharing