Fix delete old photo

This commit is contained in:
iBNu Maksum 2024-10-31 14:46:51 +07:00
parent 93583afb65
commit 1f1430fd21
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
10 changed files with 63 additions and 43 deletions

View File

@ -96,7 +96,7 @@ switch ($action) {
}
if (empty($msg)) {
if (!empty($_FILES['photo']['name'])) {
if (!empty($_FILES['photo']['name']) && file_exists($_FILES['photo']['tmp_name'])) {
if (function_exists('imagecreatetruecolor')) {
$hash = md5_file($_FILES['photo']['tmp_name']);
$subfolder = substr($hash, 0, 2);
@ -129,11 +129,11 @@ switch ($action) {
}
}
if (file_exists($imgPath)) {
if ($user['photo'] != '') {
if (file_exists($UPLOAD_PATH . $d['photo'])) {
unlink($UPLOAD_PATH . $d['photo']);
if (file_exists($UPLOAD_PATH . $d['photo'] . '.thumb.jpg')) {
unlink($UPLOAD_PATH . $d['photo'] . '.thumb.jpg');
if ($user['photo'] != '' && strpos($user['photo'], 'default') === false) {
if (file_exists($UPLOAD_PATH . $user['photo'])) {
unlink($UPLOAD_PATH . $user['photo']);
if (file_exists($UPLOAD_PATH . $user['photo'] . '.thumb.jpg')) {
unlink($UPLOAD_PATH . $user['photo'] . '.thumb.jpg');
}
}
}

View File

@ -347,8 +347,8 @@ switch ($action) {
->find_many();
if ($d) {
if(isset($routes['3']) && $routes['3'] == 'deletePhoto'){
if($d['photo'] != '' && $d['photo'] != '/user.default.jpg'){
if(file_exists($UPLOAD_PATH.$d['photo'])){
if($d['photo'] != '' && strpos($d['photo'], 'default') === false){
if(file_exists($UPLOAD_PATH.$d['photo']) && strpos($d['photo'], 'default') === false){
unlink($UPLOAD_PATH.$d['photo']);
if(file_exists($UPLOAD_PATH.$d['photo'].'.thumb.jpg')){
unlink($UPLOAD_PATH.$d['photo'].'.thumb.jpg');
@ -628,7 +628,7 @@ switch ($action) {
}
if ($msg == '') {
if (!empty($_FILES['photo']['name'])) {
if (!empty($_FILES['photo']['name']) && file_exists($_FILES['photo']['tmp_name'])) {
if (function_exists('imagecreatetruecolor')) {
$hash = md5_file($_FILES['photo']['tmp_name']);
$subfolder = substr($hash, 0, 2);
@ -661,11 +661,11 @@ switch ($action) {
}
}
if(file_exists($imgPath)){
if($c['photo'] != ''){
if(file_exists($UPLOAD_PATH.$d['photo'])){
unlink($UPLOAD_PATH.$d['photo']);
if(file_exists($UPLOAD_PATH.$d['photo'].'.thumb.jpg')){
unlink($UPLOAD_PATH.$d['photo'].'.thumb.jpg');
if($c['photo'] != '' && strpos($c['photo'], 'default') === false){
if(file_exists($UPLOAD_PATH.$c['photo'])){
unlink($UPLOAD_PATH.$c['photo']);
if(file_exists($UPLOAD_PATH.$c['photo'].'.thumb.jpg')){
unlink($UPLOAD_PATH.$c['photo'].'.thumb.jpg');
}
}
}

View File

@ -475,8 +475,8 @@ switch ($action) {
}
if ($d) {
if(isset($routes['3']) && $routes['3'] == 'deletePhoto'){
if($d['photo'] != '' && $d['photo'] != '/admin.default.png'){
if(file_exists($UPLOAD_PATH.$d['photo'])){
if($d['photo'] != '' && strpos($d['photo'], 'default') === false){
if(file_exists($UPLOAD_PATH.$d['photo']) && strpos($d['photo'], 'default') === false){
unlink($UPLOAD_PATH.$d['photo']);
if(file_exists($UPLOAD_PATH.$d['photo'].'.thumb.jpg')){
unlink($UPLOAD_PATH.$d['photo'].'.thumb.jpg');
@ -653,7 +653,7 @@ switch ($action) {
}
run_hook('edit_admin'); #HOOK
if ($msg == '') {
if (!empty($_FILES['photo']['name'])) {
if (!empty($_FILES['photo']['name']) && file_exists($_FILES['photo']['tmp_name'])) {
if (function_exists('imagecreatetruecolor')) {
$hash = md5_file($_FILES['photo']['tmp_name']);
$subfolder = substr($hash, 0, 2);
@ -686,7 +686,7 @@ switch ($action) {
}
}
if(file_exists($imgPath)){
if($d['photo'] != ''){
if($d['photo'] != '' && strpos($d['photo'], 'default') === false){
if(file_exists($UPLOAD_PATH.$d['photo'])){
unlink($UPLOAD_PATH.$d['photo']);
if(file_exists($UPLOAD_PATH.$d['photo'].'.thumb.jpg')){

View File

@ -810,5 +810,20 @@
"Package_Details": "Rincian Paket",
"Summary": "Ringkasan",
"Allow_Balance_custom_amount": "Izinkan Saldo jumlah khusus",
"Allow_Customer_buy_balance_with_any_amount": "Izinkan Pelanggan membeli saldo dengan jumlah berapa pun"
"Allow_Customer_buy_balance_with_any_amount": "Izinkan Pelanggan membeli saldo dengan jumlah berapa pun",
"Or": "Atau",
"Filter": "Menyaring",
"Show_chart": "Tampilkan grafik",
"Start_Date": "Tanggal Mulai",
"Start_time": "Waktu mulai",
"End_Date": "Tanggal Akhir",
"End_Time": "Akhir Zaman",
"Internet_Plans": "Paket Internet",
"Methods": "Metode",
"Hap_Lite": "Hap Lite",
"balance": "keseimbangan",
"radius": "radius",
"Max_30_days": "Maksimal 30 hari",
"Information": "Informasi",
"Export_and_Print_will_show_all_data_without_pagination": "Ekspor dan Cetak akan menampilkan semua data tanpa pagination"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -180,12 +180,12 @@ class FaceDetector
*
* @throws NoFaceException
*/
public function cropFaceToJpeg($outFileName = null, $resize = false, $width = 200)
public function cropFaceToJpeg($outFileName = null, $width = 200)
{
if (empty($this->face)) {
throw new NoFaceException('No face detected');
}
if (!$resize) {
// if (!$resize) {
$x = ($a = $this->face['x'] - $this->face['w'] / 2) > 0 ? $a : 0;
$y = ($b = $this->face['y'] - $this->face['w'] / 2) > 0 ? $b : 0;
$im_width = imagesx($this->canvas);
@ -193,24 +193,24 @@ class FaceDetector
$w = ($w = $this->face['w'] * 2) > $im_width ? $im_width : $w;
$h = ($h = $w) > $im_height ? $im_height : $h;
$canvas = imagecreatetruecolor($w, $h);
$canvas = imagecreatetruecolor($width, $width);
imagecopy($canvas, $this->canvas, 0, 0, $x, $y, $w, $h);
// $canvas = imagecreatetruecolor($this->face['w'], $this->face['w']);
// imagecopy($canvas, $this->canvas, 0, 0, $this->face['x'], $this->face['y'], $this->face['w'], $this->face['w']);
} else {
$x = ($a = $this->face['x'] - $width / 2) > 0 ? $a : 0;
$y = ($b = $this->face['y'] - $width / 2) > 0 ? $b : 0;
$im_width = imagesx($this->canvas);
$im_height = imagesy($this->canvas);
$w = ($w = $width * 2) > $im_width ? $im_width : $w;
$h = ($h = $w) > $im_height ? $im_height : $h;
// } else {
// $x = ($a = $this->face['x'] - $width / 2) > 0 ? $a : 0;
// $y = ($b = $this->face['y'] - $width / 2) > 0 ? $b : 0;
// $im_width = imagesx($this->canvas);
// $im_height = imagesy($this->canvas);
// $w = ($w = $width * 2) > $im_width ? $im_width : $w;
// $h = ($h = $w) > $im_height ? $im_height : $h;
$canvas = imagecreatetruecolor($w, $h);
imagecopy($canvas, $this->canvas, 0, 0, $x, $y, $w, $h);
// $canvas = imagecreatetruecolor($w, $h);
// imagecopy($canvas, $this->canvas, 0, 0, $width, $width, $w, $h);
// $canvas = imagecreatetruecolor($width, $width);
// imagecopyresized($canvas, $this->canvas, 0, 0, $this->face['x'], $this->face['y'], $width, $width, $this->face['w'], $this->face['w']);
}
// // $canvas = imagecreatetruecolor($width, $width);
// // imagecopyresized($canvas, $this->canvas, 0, 0, $this->face['x'], $this->face['y'], $width, $width, $this->face['w'], $this->face['w']);
// }
if ($outFileName === null) {
header('Content-type: image/jpeg');

View File

@ -21,7 +21,7 @@
<div class="col-md-6 col-xs-8">
<input type="file" class="form-control" name="photo" accept="image/*">
</div>
<div class="form-group col-md-3 col-xs-4">
<div class="form-group col-md-3 col-xs-4" title="Not always Working">
<label class=""><input type="checkbox" checked name="faceDetect" value="yes"> Facedetect</label>
</div>
</div>

View File

@ -19,7 +19,7 @@
<div class="col-md-6 col-xs-8">
<input type="file" class="form-control" name="photo" accept="image/*">
</div>
<div class="form-group col-md-3 col-xs-4">
<div class="form-group col-md-3 col-xs-4" title="Not always Working">
<label class=""><input type="checkbox" checked name="faceDetect" value="yes"> Facedetect</label>
</div>
</div>

View File

@ -19,7 +19,7 @@
<div class="col-md-6 col-xs-8">
<input type="file" class="form-control" name="photo" accept="image/*">
</div>
<div class="form-group col-md-3 col-xs-4">
<div class="form-group col-md-3 col-xs-4" title="Not always Working">
<label class=""><input type="checkbox" checked name="faceDetect" value="yes"> Facedetect</label>
</div>
</div>

View File

@ -26,7 +26,7 @@
</div>
<div class="panel-body">
<form id="site-search" method="post" action="{$_url}customers">
<input type="hidden" name="csrf_token" value="{$csrf_token}">
<input type="hidden" name="csrf_token" value="{$csrf_token}">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
<div class="col-lg-4">
<div class="input-group">
@ -96,6 +96,7 @@
<thead>
<tr>
<th>{Lang::T('Username')}</th>
<th>Photo</th>
<th>{Lang::T('Account Type')}</th>
<th>{Lang::T('Full Name')}</th>
<th>{Lang::T('Balance')}</th>
@ -113,6 +114,11 @@
<tr {if $ds['status'] != 'Active'}class="danger" {/if}>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor:pointer;">{$ds['username']}</td>
<td>
<a href="{$UPLOAD_PATH}{$ds['photo']}" target="photo">
<img src="{$UPLOAD_PATH}{$ds['photo']}.thumb.jpg" width="32" alt="">
</a>
</td>
<td>{$ds['account_type']}</td>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor: pointer;">{$ds['fullname']}</td>
@ -120,8 +126,7 @@
<td align="center">
{if $ds['phonenumber']}
<a href="tel:{$ds['phonenumber']}" class="btn btn-default btn-xs"
title="{$ds['phonenumber']}"><i
class="glyphicon glyphicon-earphone"></i></a>
title="{$ds['phonenumber']}"><i class="glyphicon glyphicon-earphone"></i></a>
{/if}
{if $ds['email']}
<a href="mailto:{$ds['email']}" class="btn btn-default btn-xs"
@ -139,7 +144,7 @@
<td>{$ds['service_type']}</td>
<td>
{$ds['pppoe_username']}
{if !empty($ds['pppoe_username']) && !empty($ds['pppoe_ip'])}:{/if}
{if !empty($ds['pppoe_username']) && !empty($ds['pppoe_ip'])}:{/if}
{$ds['pppoe_ip']}
</td>
<td>{Lang::T($ds['status'])}</td>
@ -154,8 +159,8 @@
<a href="{$_url}customers/sync/{$ds['id']}&token={$csrf_token}" id="{$ds['id']}"
style="margin: 5px; color:black"
class="btn btn-success btn-xs">&nbsp;&nbsp;{Lang::T('Sync')}&nbsp;&nbsp;</a>
<a href="{$_url}plan/recharge/{$ds['id']}&token={$csrf_token}" id="{$ds['id']}" style="margin: 0px;"
class="btn btn-primary btn-xs">{Lang::T('Recharge')}</a>
<a href="{$_url}plan/recharge/{$ds['id']}&token={$csrf_token}" id="{$ds['id']}"
style="margin: 0px;" class="btn btn-primary btn-xs">{Lang::T('Recharge')}</a>
</td>
</tr>
{/foreach}