function ajax_mediaupload() { global $NS, $MSG, $INPUT; if ($_FILES['qqfile']['tmp_name']) { $id = $INPUT->post->str('mediaid', $_FILES['qqfile']['name']); } elseif ($INPUT->get->has('qqfile')) { $id = $INPUT->get->str('qqfile'); } $id = cleanID($id); $NS = $INPUT->str('ns'); $ns = $NS . ':' . getNS($id); $AUTH = auth_quickaclcheck("{$ns}:*"); if ($AUTH >= AUTH_UPLOAD) { io_createNamespace("{$ns}:xxx", 'media'); } if ($_FILES['qqfile']['error']) { unset($_FILES['qqfile']); } if ($_FILES['qqfile']['tmp_name']) { $res = media_upload($NS, $AUTH, $_FILES['qqfile']); } if ($INPUT->get->has('qqfile')) { $res = media_upload_xhr($NS, $AUTH); } if ($res) { $result = array('success' => true, 'link' => media_managerURL(array('ns' => $ns, 'image' => $NS . ':' . $id), '&'), 'id' => $NS . ':' . $id, 'ns' => $NS); } if (!$result) { $error = ''; if (isset($MSG)) { foreach ($MSG as $msg) { $error .= $msg['msg']; } } $result = array('error' => $msg['msg'], 'ns' => $NS); } $json = new JSON(); echo htmlspecialchars($json->encode($result), ENT_NOQUOTES); }
function ajax_mediaupload() { global $NS, $MSG; if ($_FILES['qqfile']['tmp_name']) { $id = empty($_POST['mediaid']) ? $_FILES['qqfile']['name'] : $_POST['mediaid']; } elseif (isset($_GET['qqfile'])) { $id = $_GET['qqfile']; } $id = cleanID($id, false, true); $NS = $_REQUEST['ns']; $ns = $NS . ':' . getNS($id); $AUTH = auth_quickaclcheck("{$ns}:*"); if ($AUTH >= AUTH_UPLOAD) { io_createNamespace("{$ns}:xxx", 'media'); } if ($_FILES['qqfile']['error']) { unset($_FILES['qqfile']); } if ($_FILES['qqfile']['tmp_name']) { $res = media_upload($NS, $AUTH, $_FILES['qqfile']); } if (isset($_GET['qqfile'])) { $res = media_upload_xhr($NS, $AUTH); } if ($res) { $result = array('success' => true, 'link' => media_managerURL(array('ns' => $ns, 'image' => $NS . ':' . $id), '&'), 'id' => $NS . ':' . $id, 'ns' => $NS); } if (!$result) { $error = ''; if (isset($MSG)) { foreach ($MSG as $msg) { $error .= $msg['msg']; } } $result = array('error' => $msg['msg'], 'ns' => $NS); } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); }
} // give info on PHP catched upload errors if ($_FILES['upload']['error']) { switch ($_FILES['upload']['error']) { case 1: case 2: msg(sprintf($lang['uploadsize'], filesize_h(php_to_byte(ini_get('upload_max_filesize')))), -1); break; default: msg($lang['uploadfail'] . ' (' . $_FILES['upload']['error'] . ')', -1); } unset($_FILES['upload']); } // handle upload if ($_FILES['upload']['tmp_name']) { $JUMPTO = media_upload($NS, $AUTH); if ($JUMPTO) { $NS = getNS($JUMPTO); } } // handle meta saving if ($IMG && $_REQUEST['do']['save']) { $JUMPTO = media_metasave($IMG, $AUTH, $_REQUEST['meta']); } // handle deletion if ($DEL) { $INUSE = media_inuse($DEL); if (!$INUSE) { if (media_delete($DEL, $AUTH)) { msg(sprintf($lang['deletesucc'], noNS($DEL)), 1); } else {
} // check ticket $aActionsNotToCheck = array('selectmedia', _MEDIA_FILTER_APPLY, _MEDIA_COLLECTION_SELECT); if (!in_array($action, $aActionsNotToCheck)) { if (!$manager->checkTicket()) { media_doError(_ERROR_BADTICKET); } } switch ($action) { case 'chooseupload': case _MEDIA_UPLOAD_TO: case _MEDIA_UPLOAD_NEW: media_choose(); break; case 'uploadfile': media_upload(); break; case _MEDIA_FILTER_APPLY: case 'selectmedia': case _MEDIA_COLLECTION_SELECT: default: media_select(); break; } // select a file function media_select() { global $member, $CONF, $DIR_MEDIA, $manager; // show 10 files + navigation buttons // show msg when no files // show upload form