From 1f1430fd218f70fe02db5e01490a38a39a863794 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Thu, 31 Oct 2024 14:46:51 +0700 Subject: [PATCH] Fix delete old photo --- system/controllers/accounts.php | 12 +++---- system/controllers/customers.php | 16 +++++----- system/controllers/settings.php | 8 ++--- system/lan/indonesia.json | 17 +++++++++- system/uploads/admin.default.png | Bin 0 -> 1914 bytes .../php-facedetection/FaceDetector.php | 30 +++++++++--------- ui/ui/admin-edit.tpl | 2 +- ui/ui/customer/profile.tpl | 2 +- ui/ui/customers-edit.tpl | 2 +- ui/ui/customers.tpl | 17 ++++++---- 10 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 system/uploads/admin.default.png diff --git a/system/controllers/accounts.php b/system/controllers/accounts.php index d68e0623..52c0dba6 100644 --- a/system/controllers/accounts.php +++ b/system/controllers/accounts.php @@ -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'); } } } diff --git a/system/controllers/customers.php b/system/controllers/customers.php index cee428d9..81483e44 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -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'); } } } diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 8f3ca5a9..62445e06 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -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')){ diff --git a/system/lan/indonesia.json b/system/lan/indonesia.json index f8029c50..891a74be 100644 --- a/system/lan/indonesia.json +++ b/system/lan/indonesia.json @@ -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" } \ No newline at end of file diff --git a/system/uploads/admin.default.png b/system/uploads/admin.default.png new file mode 100644 index 0000000000000000000000000000000000000000..3bc948ce2d1186f1a6ca21fed530dd3853c15a3f GIT binary patch literal 1914 zcmV-=2Zi{FP)5NytMo5b|Yt+BHY)Khwf7D-uE| zn?ArO38z1c2K)aM$?LXL_bBd0CLwIS$No!snu3!j+dV;fTj$unD#I)*!w=TGx8(HT z-jvLe5$3x>=)o=T+9aWfzVl!WcQfqY9!-AYqWaEuY+Z4z85=qO9%13yg`pa6LOFeB zGX@d%|9>S4Bn|j$MqXnp_`+7mgT5j>S?zFkL{VP{Sy?<8PYP4;3SC+o;%qcnu!kin zwv^YLGzsh^237`fYi$C1i53pjg_b!uKwInFO~!Q!>?9W0iXPZ&9HJM<0$bA^d7`?| zKf^0*Rkv)ELbW%97I~XYtCty|D{NhVw zUPHEc3L68{u(RO_Pho9f8sa7xAO)yr5O-=?6ON`!q0m;u*oZz%R|6lE{whQZP4$=Z zUqjbe3ZZkuKZR&HB5VQU3SKD#K6Uz4h_)au40#&7*xQuC=@RRRjaTRujs?%tm`N=# z6`EQP@y=zKNq{j^;K-B>(W-4nQ@I7+e*V&oLc~qPA2T^V!8@>EWwVGq+>z}%Rb7^&-X+!NpM1x4%w-!Z`P z=X*lz!_d%S4NI^udL4niDVZY+1ot%z|2TUD8o60<>jKn>#D>d3Dd2)(g$XB<1Dr&L z?MN@=U;>c?wkt4KX7IzA8&)vR2K(^r4LOLyFvHe$14ICB(HQN~?@uu+Y%eKw4^(1X zhYa0m6nfJ1OuE!5(aHuOd*!AdS3=|~2ycjlJ14yrc)-^3hW&HjIXQuLTChj4{mvi| zKdpaH-YTz)jN1}!zd^Nw3$?#f)LhA>hJ|I3%qt@Kk;?43f&ZDq*oKJ@kkX!X=?l?H zVyKe9rflge+g32|r(}U&85LrdO$9<65<1x4v$JFQsr~G&`KGSf?~naD_~vvNp~cpY znxPzVwGQ|@Q!*NoqIPk3-ZP8l1>qr~l>JUj#u)88UYCo?f%SbP$EH3MWt&`RSEpTN zeRL*8JnO;!3(phjVFP29%!>XylWN5&X#pnH?8JGSp%3Y*JV!17Nx?ZqVI-+h-EC9; zMcAa!8rStT*qJ~{nZYa(nR z`7d!+e#n{`Gd5D2<(HhVOZg}Vb zPZrIncx0B=qaLK`AO>!+3G_{3ln0wS`s{epYF&ooYmcOW4pisDMM4t%tg}~dSH)4a zD_Z*EDX5PUfx8dPWsX{&OBUhsXS3eTFC0!q680~6No+X64pgP%U5wJVv>h>cuH zmw~l<(qU6wXe7|oZNb8&@DHlP*)&FaUr3^*zmlOovyyQ2LbzoS_ahn_f7)$A4fos3 z^w?2A*@y<-K2SvQew3-6a|$TBQ=8Yqfl#Gp1KUkN6H4XNlLIE~B+3hnT`*y%P(Bs5 zuy*kZh4!Ylul57d3x=tt^2$)z;_1N&Khq<5?K@7ee|$8O9smH3cAv_UHJ>{egCc2sE)@s-j2<8_q6xr?(+`)ivo~s?f&@^``D7_%K zTe^2opcCIA2c07*qoM6N<$f=8I0 AT>t<8 literal 0 HcmV?d00001 diff --git a/system/vendor/yosiazwan/php-facedetection/FaceDetector.php b/system/vendor/yosiazwan/php-facedetection/FaceDetector.php index 57ea021f..6455b464 100644 --- a/system/vendor/yosiazwan/php-facedetection/FaceDetector.php +++ b/system/vendor/yosiazwan/php-facedetection/FaceDetector.php @@ -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'); diff --git a/ui/ui/admin-edit.tpl b/ui/ui/admin-edit.tpl index 4aaad2e4..9e406d9f 100644 --- a/ui/ui/admin-edit.tpl +++ b/ui/ui/admin-edit.tpl @@ -21,7 +21,7 @@
-
+
diff --git a/ui/ui/customer/profile.tpl b/ui/ui/customer/profile.tpl index 7475a416..fb7164d2 100644 --- a/ui/ui/customer/profile.tpl +++ b/ui/ui/customer/profile.tpl @@ -19,7 +19,7 @@
-
+
diff --git a/ui/ui/customers-edit.tpl b/ui/ui/customers-edit.tpl index a62726bf..04e8893e 100644 --- a/ui/ui/customers-edit.tpl +++ b/ui/ui/customers-edit.tpl @@ -19,7 +19,7 @@
-
+
diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl index 1e8b2999..6d2a95a0 100644 --- a/ui/ui/customers.tpl +++ b/ui/ui/customers.tpl @@ -26,7 +26,7 @@