X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fprofile_photo.php;h=b4723b215ff1e5bd8aeba1edfee74167c7b5c2a6;hb=10ede7314136edb1c475e1af546a59ff4c5648cf;hp=0b6dd8d13b31a73619d80fcbbfe4d26957b0c9f8;hpb=b6d11f21297331cda361ebadca3c1cf453027fdd;p=friendica.git
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 0b6dd8d13b..b4723b215f 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -1,19 +1,20 @@
user['nickname']);
-
}
-
-function profile_photo_post(App &$a) {
+function profile_photo_post(App $a) {
if (! local_user()) {
notice ( t('Permission denied.') . EOL );
@@ -102,15 +103,15 @@ function profile_photo_post(App &$a) {
);
$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
- dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
- dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
- dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
+ dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
+ dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
+ dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
intval(local_user())
);
} else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
- dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
- dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
+ dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
+ dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
intval($_REQUEST['profile']),
intval(local_user())
);
@@ -126,19 +127,18 @@ function profile_photo_post(App &$a) {
info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
// Update global directory in background
- $url = App::get_baseurl() . '/profile/' . $a->user['nickname'];
+ $url = System::baseUrl() . '/profile/' . $a->user['nickname'];
if ($url && strlen(get_config('system','directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
}
- require_once('include/profile_update.php');
- profile_change();
- }
- else
+ proc_run(PRIORITY_LOW, 'include/profile_update.php', local_user());
+ } else {
notice( t('Unable to process image') . EOL);
+ }
}
- goaway(App::get_baseurl() . '/profiles');
+ goaway(System::baseUrl() . '/profiles');
return; // NOTREACHED
}
@@ -146,11 +146,13 @@ function profile_photo_post(App &$a) {
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
- if ($filetype=="") $filetype=guess_image_type($filename);
-
+ if ($filetype == "") {
+ $filetype = guess_image_type($filename);
+ }
+
$maximagesize = get_config('system','maximagesize');
- if(($maximagesize) && ($filesize > $maximagesize)) {
+ if (($maximagesize) && ($filesize > $maximagesize)) {
notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
@unlink($src);
return;
@@ -159,7 +161,7 @@ function profile_photo_post(App &$a) {
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
- if(! $ph->is_valid()) {
+ if (! $ph->is_valid()) {
notice( t('Unable to process image.') . EOL );
@unlink($src);
return;
@@ -168,18 +170,17 @@ function profile_photo_post(App &$a) {
$ph->orient($src);
@unlink($src);
return profile_photo_crop_ui_head($a, $ph);
-
}
if(! function_exists('profile_photo_content')) {
-function profile_photo_content(App &$a) {
+function profile_photo_content(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL );
return;
}
-
+
$newuser = false;
if($a->argc == 2 && $a->argv[1] === 'new')
@@ -190,9 +191,9 @@ function profile_photo_content(App &$a) {
notice( t('Permission denied.') . EOL );
return;
};
-
+
// check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
-
+
$resource_id = $a->argv[2];
//die(":".local_user());
$r=q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' ORDER BY `scale` ASC",
@@ -204,7 +205,7 @@ function profile_photo_content(App &$a) {
return;
}
$havescale = false;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if($rr['scale'] == 5)
$havescale = true;
}
@@ -231,7 +232,7 @@ function profile_photo_content(App &$a) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
}
- goaway(App::get_baseurl() . '/profiles');
+ goaway(System::baseUrl() . '/profiles');
return; // NOTREACHED
}
$ph = new Photo($r[0]['data'], $r[0]['type']);
@@ -245,7 +246,7 @@ function profile_photo_content(App &$a) {
if(! x($a->config,'imagecrop')) {
-
+
$tpl = get_markup_template('profile_photo.tpl');
$o .= replace_macros($tpl,array(
@@ -256,7 +257,7 @@ function profile_photo_content(App &$a) {
'$submit' => t('Upload'),
'$profiles' => $profiles,
'$form_security_token' => get_form_security_token("profile_photo"),
- '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '')
+ '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '')
));
return $o;
@@ -269,7 +270,7 @@ function profile_photo_content(App &$a) {
'$filename' => $filename,
'$profile' => intval($_REQUEST['profile']),
'$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'],
- '$image_url' => App::get_baseurl() . '/photo/' . $filename,
+ '$image_url' => System::baseUrl() . '/photo/' . $filename,
'$title' => t('Crop Image'),
'$desc' => t('Please adjust the image cropping for optimum viewing.'),
'$form_security_token' => get_form_security_token("profile_photo"),
@@ -283,7 +284,7 @@ function profile_photo_content(App &$a) {
if(! function_exists('profile_photo_crop_ui_head')) {
-function profile_photo_crop_ui_head(&$a, $ph){
+function profile_photo_crop_ui_head(App $a, $ph) {
$max_length = get_config('system','max_image_length');
if (! $max_length) {
$max_length = MAX_IMAGE_LENGTH;
@@ -302,11 +303,11 @@ function profile_photo_crop_ui_head(&$a, $ph){
}
$hash = photo_new_resource();
-
+
$smallest = 0;
- $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );
+ $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );
if ($r) {
info( t('Image uploaded successfully.') . EOL );
@@ -316,7 +317,7 @@ function profile_photo_crop_ui_head(&$a, $ph){
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
- $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );
+ $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );
if ($r === false) {
notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL );