Skip to content

Commit

Permalink
YOu can upload photo for the user and delete ofphan files
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed May 3, 2017
1 parent cc07a4a commit 26c6adf
Show file tree
Hide file tree
Showing 10 changed files with 1,926 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
RewriteRule ^users$ view/managerUsers.php [NC,L]
RewriteRule ^users.json$ objects/users.json.php [NC,L]
RewriteRule ^updateUser$ objects/userUpdate.json.php [NC,L]
RewriteRule ^savePhoto$ objects/userSavePhoto.php [NC,L]
RewriteRule ^addNewUser$ objects/userAddNew.json.php [NC,L]
RewriteRule ^deleteUser$ objects/userDelete.json.php [NC,L]
RewriteRule ^recoverPass$ objects/userRecoverPass.php [NC,L]
Expand All @@ -52,6 +53,7 @@
RewriteRule ^deleteCategory$ objects/categoryDelete.json.php [NC,L]

#manager videos
RewriteRule ^orphanFiles$ view/orphanFiles.php [NC,L]
RewriteRule ^mvideos$ view/managerVideos.php [NC,L]
RewriteRule ^videos.json$ objects/videos.json.php [NC,L]
RewriteRule ^deleteVideo$ objects/videoDelete.json.php [NC,L]
Expand Down
2 changes: 1 addition & 1 deletion objects/bootGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static function getSqlFromPost($searchFieldsNames = array(), $keyPrefix = "") {
}
$sql .= " ORDER BY ".implode(",", $orderBy);
}else{
$sql .= " ORDER BY CREATED DESC ";
//$sql .= " ORDER BY CREATED DESC ";
}

if(!empty($_POST['rowCount']) && !empty($_POST['current']) && $_POST['rowCount']>0){
Expand Down
47 changes: 47 additions & 0 deletions objects/userSavePhoto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

header('Content-Type: application/json');
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = "../";
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
$obj = new stdClass();
if (!User::isLogged()) {
$obj->error = __("You must be logged");
die(json_encode($obj));
}
$imagePath = "videos/userPhoto/";

//Check write Access to Directory
if (!file_exists($global['systemRootPath'].$imagePath)) {
mkdir($global['systemRootPath'].$imagePath, 0777, true);
}

if (!is_writable($global['systemRootPath'].$imagePath)) {
$response = Array(
"status" => 'error',
"message" => 'Can`t upload File; no write Access'
);
print json_encode($response);
return;
}

$img = $_POST['imgBase64'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$fileData = base64_decode($img);
$fileName = 'photo'. User::getId().'.png';
$photoURL = $imagePath.$fileName;
file_put_contents($global['systemRootPath'].$photoURL, $fileData);
$response = array(
"status" => 'success',
"url" => $global['systemRootPath'].$photoURL
);

$user = new User(User::getId());
$user->setPhotoURL($photoURL);
$user->save();
User::updateSessionInfo();
print json_encode($response);
?>
19 changes: 19 additions & 0 deletions objects/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,31 @@ function delete() {
die('Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
} else {
foreach (self::$types as $value) {
/*
$cmd = "rm -f {$global['systemRootPath']}videos/original_{$video['filename']}.{$value}";
exec($cmd);
$cmd = "rm -f {$global['systemRootPath']}videos/{$video['filename']}.{$value}";
exec($cmd);
$cmd = "rm -f {$global['systemRootPath']}videos/{$video['filename']}_progress_{$value}.txt";
exec($cmd);
*
*/
$file = "{$global['systemRootPath']}videos/original_{$video['filename']}";
if(file_exists($file)){
unlink($file);
}
$file = "{$global['systemRootPath']}videos/{$video['filename']}.{$value}";
if(file_exists($file)){
unlink($file);
}
$file = "{$global['systemRootPath']}videos/{$video['filename']}_progress_{$value}.txt";
if(file_exists($file)){
unlink($file);
}
$file = "{$global['systemRootPath']}videos/{$video['filename']}.jpg";
if(file_exists($file)){
unlink($file);
}
}
}
return $resp;
Expand Down
200 changes: 200 additions & 0 deletions view/js/Croppie/croppie.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
.croppie-container {
width: 100%;
height: 100%;
}

.croppie-container .cr-image {
z-index: -1;
position: absolute;
top: 0;
left: 0;
transform-origin: 0 0;
max-height: none;
max-width: none;
}

.croppie-container .cr-boundary {
position: relative;
overflow: hidden;
margin: 0 auto;
z-index: 1;
width: 100%;
height: 100%;
}

.croppie-container .cr-viewport {
position: absolute;
border: 2px solid #fff;
margin: auto;
top: 0;
bottom: 0;
right: 0;
left: 0;
box-shadow: 0 0 2000px 2000px rgba(0, 0, 0, 0.5);
z-index: 0;
}

.croppie-container .cr-original-image {
display: none;
}

.croppie-container .cr-vp-circle {
border-radius: 50%;
}

.croppie-container .cr-overlay {
z-index: 1;
position: absolute;
cursor: move;
}

.croppie-container .cr-slider-wrap {
width: 75%;
margin: 15px auto;
text-align: center;
}

.croppie-result {
position: relative;
overflow: hidden;
}

.croppie-result img {
position: absolute;
}

.croppie-container .cr-image,
.croppie-container .cr-overlay,
.croppie-container .cr-viewport {
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}

/*************************************/
/***** STYLING RANGE INPUT ***********/
/*************************************/
/*https://brennaobrien.com/blog/2014/05/style-input-type-range-in-every-browser.html */
/*************************************/

.cr-slider {
-webkit-appearance: none;
/*removes default webkit styles*/
/*border: 1px solid white; *//*fix for FF unable to apply focus style bug */
width: 300px;
/*required for proper track sizing in FF*/
max-width: 100%;
padding-top: 8px;
padding-bottom: 8px;
background-color: transparent;
}

.cr-slider::-webkit-slider-runnable-track {
width: 100%;
height: 3px;
background: rgba(0, 0, 0, 0.5);
border: 0;
border-radius: 3px;
}

.cr-slider::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #ddd;
margin-top: -6px;
}

.cr-slider:focus {
outline: none;
}
/*
.cr-slider:focus::-webkit-slider-runnable-track {
background: #ccc;
}
*/

.cr-slider::-moz-range-track {
width: 100%;
height: 3px;
background: rgba(0, 0, 0, 0.5);
border: 0;
border-radius: 3px;
}

.cr-slider::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #ddd;
margin-top: -6px;
}

/*hide the outline behind the border*/
.cr-slider:-moz-focusring {
outline: 1px solid white;
outline-offset: -1px;
}

.cr-slider::-ms-track {
width: 100%;
height: 5px;
background: transparent;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
border-color: transparent;/*leave room for the larger thumb to overflow with a transparent border */
border-width: 6px 0;
color: transparent;/*remove default tick marks*/
}
.cr-slider::-ms-fill-lower {
background: rgba(0, 0, 0, 0.5);
border-radius: 10px;
}
.cr-slider::-ms-fill-upper {
background: rgba(0, 0, 0, 0.5);
border-radius: 10px;
}
.cr-slider::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #ddd;
margin-top:1px;
}
.cr-slider:focus::-ms-fill-lower {
background: rgba(0, 0, 0, 0.5);
}
.cr-slider:focus::-ms-fill-upper {
background: rgba(0, 0, 0, 0.5);
}
/*******************************************/

/***********************************/
/* Rotation Tools */
/***********************************/
.cr-rotate-controls {
position: absolute;
bottom: 5px;
left: 5px;
z-index: 1;
}
.cr-rotate-controls button {
border: 0;
background: none;
}
.cr-rotate-controls i:before {
display: inline-block;
font-style: normal;
font-weight: 900;
font-size: 22px;
}
.cr-rotate-l i:before {
content: '↺';
}
.cr-rotate-r i:before {
content: '↻';
}
Loading

0 comments on commit 26c6adf

Please sign in to comment.