Unlink default_avatar.png ne törlődjön

Unlink default_avatar.png ne törlődjön
2020-07-15T23:14:41+02:00
2020-07-16T09:26:49+02:00
2022-10-15T21:16:34+02:00
exxon
Helló mindenki, lenne egy kis problémám.
Szóval hogyan tudom megoldani hogy unlink lefusson de ha a kép deafult_avatar.png akkor az ne törlődjön.
szerveren próbáltam a ch módot de akkor is törlődik..

<?php session_start(); define('IS_ADMIN','true'); require('../core/config/config.php'); require('../core/config/config-theme.php'); require('../core/system.php'); if(!isLogged() || $user['is_admin'] == 0) { header('Location: ../index.php'); exit; } $page['name'] = 'Admin - Admin menu'; $menu['delkep'] = 'active'; if(isset($_GET['delete']) && isset($_GET['delid'])) { $delid = $_GET['delid']; $path = $_GET['path']; unlink('../uploads/'.$path); $db->query("UPDATE `users` SET `profile_picture` = 'default_avatar.png' WHERE `users`.`id` = '".$delid."'"); header('Location: delkep.php?success'); exit; } $photos = "SELECT * FROM users ORDER BY id DESC"; // Pagination $per_page = 9; $count = $db->query($photos)->num_rows; $last_page = ceil($count/$per_page); if(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; } if($p < 1) { $p = 1; } elseif($p > $last_page) { $p = $last_page; } $limit = 'LIMIT ' .($p - 1) * $per_page .',' .$per_page; $photos.= " $limit"; $photos = $db->query($photos); require('../inc/admin/top.php'); ?> <section id="page-content"> <!-- Start body content --> <div class="body-content animated fadeIn"> <div class="row"> <div class="col-lg-12"> <br> <?php if(isset($_GET['success'])) { echo '<div class="alert alert-success"> <i class="fa fa-check-circle fa-fw"></i> Photo deleted successfully </div>'; } ?> <?php if($photos->num_rows >= 1) { ?> <table class="table table-responsive table-inverse"> <thead> <tr> <th style="text-align:center;"> ID </th> <th style="text-align:center;"> Photo </th> <th style="text-align:center;"> Uploaded By </th> <th style="text-align:center;"> Imported from Instagram </th> <th style="text-align:center;"> Date </th> <th style="text-align:center;"> Actions </th> </tr> </thead> <tbody> <?php while($photo = $photos->fetch_array()) { $uploader = getProfilePicture($domain,$photo); ?> <tr> <td style="vertical-align:middle;width:100px;text-align:center;"> <?php echo $photo['id']; ?> </td> <td style="vertical-align:middle;width:100px;text-align:center;"> <a href="<?php echo $uploader ?>" target="_blank"> <img src="<?php echo $uploader ?>" style="height:100px;width:100px" data-toggle="tooltip" data-placement="bottom" data-title="Click to view in full size" placeholder="" data-original-title="" title=""> </a> <td style="vertical-align:middle;text-align:center;"> <?php echo $photo['full_name']; ?> </td> <td style="vertical-align:middle;text-align:center;"> </td> <td style="vertical-align:middle;text-align:center;"> </td> <td style="vertical-align:middle;text-align:center;"> <a href="<?php echo $uploader?>" target="_blank" class="btn btn-theme"> <i class="fa fa-eye" style="color:#fff;"></i> </a> <a href="?delete=true&amp;delid=<?php echo $photo['id']; ?>&amp;path=<?php echo $photo['profile_picture'] ?>" class="btn btn-theme"> <i class="fa fa-trash" style="color:#fff;"></i> </a> </td> </tr> <? } ?> </tbody> </table> <ul class="pagination pagination-lg"> <?php if(($last_page >= $p) && $last_page > 1) { for($i=1; $i<=$last_page; $i++) { if($i == $p) { echo '<li class="active"> <a href="delkep.php?p='.$i.'"> '.$i.' </a> </li>'; } else { echo '<li> <a href="delkep.php?p='.$i.'"> '.$i.' </a> </li>'; } } } ?> </ul> <? } ?> </div> </div> </div> <!--/ End body content --> </section> <script src="<?php echo $domain?>/vendor/modernizr/modernizr.js"></script> <script src="<?php echo $domain?>/vendor/jquery/dist/jquery.js"></script> <script src="<?php echo $domain?>/vendor/bootstrap/dist/js/bootstrap.js"></script> <script src="<?php echo $domain?>/vendor/jQuery-Storage-API/jquery.storageapi.js"></script> <script src="<?php echo $domain?>/vendor/animo.js/animo.js"></script> <script src="<?php echo $domain?>/vendor/sweetalert/dist/sweetalert.min.js"></script> <script src="<?php echo $domain?>/app/js/app.js"></script> </body> </html>
Mutasd a teljes hozzászólást!
if(isset($_GET['delete']) && isset($_GET['delid'])) { $delid = $_GET['delid']; $path = $_GET['path']; if ($path == 'default_avatar.png') { $db->query("UPDATE `users` SET `profile_picture` = 'default_avatar.png' WHERE `users`.`id` = '".$delid."'"); } else { unlink('../uploads/'.$path); $db->query("UPDATE `users` SET `profile_picture` = 'default_avatar.png' WHERE `users`.`id` = '".$delid."'"); }
Mutasd a teljes hozzászólást!

Tetszett amit olvastál? Szeretnél a jövőben is értesülni a hasonló érdekességekről?
abcd