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); }