]> git.mxchange.org Git - friendica.git/blobdiff - mod/wall_attach.php
Update Addon functions and calls
[friendica.git] / mod / wall_attach.php
index 931dcb720024473179ee191d892bb1980fa65917..472a8073247e9a96d7150d50da9e6150a43367a7 100644 (file)
@@ -1,11 +1,13 @@
 <?php
-
+/**
+ * @file mod/wall_attach.php
+ */
 use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Database\DBM;
+use Friendica\Util\Mimetype;
 
-require_once('include/attach.php');
-require_once('include/datetime.php');
+require_once 'include/datetime.php';
 
 function wall_attach_post(App $a) {
 
@@ -18,7 +20,7 @@ function wall_attach_post(App $a) {
                );
                if (! DBM::is_result($r)) {
                        if ($r_json) {
-                               echo json_encode(array('error'=>t('Invalid request.')));
+                               echo json_encode(['error'=>t('Invalid request.')]);
                                killme();
                        }
                        return;
@@ -26,7 +28,7 @@ function wall_attach_post(App $a) {
 
        } else {
                if ($r_json) {
-                       echo json_encode(array('error'=>t('Invalid request.')));
+                       echo json_encode(['error'=>t('Invalid request.')]);
                        killme();
                }
                return;
@@ -68,7 +70,7 @@ function wall_attach_post(App $a) {
        }
        if(! $can_post) {
                if ($r_json) {
-                       echo json_encode(array('error'=>t('Permission denied.')));
+                       echo json_encode(['error'=>t('Permission denied.')]);
                        killme();
                }
                notice( t('Permission denied.') . EOL );
@@ -77,7 +79,7 @@ function wall_attach_post(App $a) {
 
        if(! x($_FILES,'userfile')) {
                if ($r_json) {
-                       echo json_encode(array('error'=>t('Invalid request.')));
+                       echo json_encode(['error'=>t('Invalid request.')]);
                }
                killme();
        }
@@ -97,7 +99,7 @@ function wall_attach_post(App $a) {
        if($filesize <=0) {
                $msg = t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(t('Or - did you try to upload an empty file?'));
                if ($r_json) {
-                       echo json_encode(array('error'=>$msg));
+                       echo json_encode(['error'=>$msg]);
                } else {
                        notice( $msg. EOL );
                }
@@ -108,7 +110,7 @@ function wall_attach_post(App $a) {
        if(($maxfilesize) && ($filesize > $maxfilesize)) {
                $msg = sprintf(t('File exceeds size limit of %s'), formatBytes($maxfilesize));
                if ($r_json) {
-                       echo json_encode(array('error'=>$msg));
+                       echo json_encode(['error'=>$msg]);
                } else {
                        echo  $msg. EOL ;
                }
@@ -117,13 +119,13 @@ function wall_attach_post(App $a) {
        }
 
        $filedata = @file_get_contents($src);
-       $mimetype = z_mime_content_type($filename);
+       $mimetype = Mimetype::getContentType($filename);
        $hash = get_guid(64);
        $created = datetime_convert();
 
-       $fields = array('uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype,
+       $fields = ['uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype,
                'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created,
-               'allow_cid' => '<' . $page_owner_cid . '>', 'allow_gid' => '','deny_cid' => '', 'deny_gid' => '');
+               'allow_cid' => '<' . $page_owner_cid . '>', 'allow_gid' => '','deny_cid' => '', 'deny_gid' => ''];
 
        $r = dba::insert('attach', $fields);
 
@@ -132,7 +134,7 @@ function wall_attach_post(App $a) {
        if(! $r) {
                $msg =  t('File upload failed.');
                if ($r_json) {
-                       echo json_encode(array('error'=>$msg));
+                       echo json_encode(['error'=>$msg]);
                } else {
                        echo  $msg. EOL ;
                }
@@ -148,7 +150,7 @@ function wall_attach_post(App $a) {
        if (! DBM::is_result($r)) {
                $msg = t('File upload failed.');
                if ($r_json) {
-                       echo json_encode(array('error'=>$msg));
+                       echo json_encode(['error'=>$msg]);
                } else {
                        echo  $msg. EOL ;
                }
@@ -156,7 +158,7 @@ function wall_attach_post(App $a) {
        }
 
        if ($r_json) {
-               echo json_encode(array('ok'=>true));
+               echo json_encode(['ok'=>true]);
                killme();
        }