- Addon::registerHook('photo_upload_form', 'addon/js_upload/js_upload.php', 'js_upload_form');
- Addon::registerHook('photo_post_init', 'addon/js_upload/js_upload.php', 'js_upload_post_init');
- Addon::registerHook('photo_post_file', 'addon/js_upload/js_upload.php', 'js_upload_post_file');
- Addon::registerHook('photo_post_end', 'addon/js_upload/js_upload.php', 'js_upload_post_end');
+ Hook::register('photo_upload_form', 'addon/js_upload/js_upload.php', 'js_upload_form');
+ Hook::register('photo_post_init', 'addon/js_upload/js_upload.php', 'js_upload_post_init');
+ Hook::register('photo_post_file', 'addon/js_upload/js_upload.php', 'js_upload_post_file');
+ Hook::register('photo_post_end', 'addon/js_upload/js_upload.php', 'js_upload_post_end');
- Addon::unregisterHook('photo_upload_form', 'addon/js_upload/js_upload.php', 'js_upload_form');
- Addon::unregisterHook('photo_post_init', 'addon/js_upload/js_upload.php', 'js_upload_post_init');
- Addon::unregisterHook('photo_post_file', 'addon/js_upload/js_upload.php', 'js_upload_post_file');
- Addon::unregisterHook('photo_post_end', 'addon/js_upload/js_upload.php', 'js_upload_post_end');
+ Hook::unregister('photo_upload_form', 'addon/js_upload/js_upload.php', 'js_upload_form');
+ Hook::unregister('photo_post_init', 'addon/js_upload/js_upload.php', 'js_upload_post_init');
+ Hook::unregister('photo_post_file', 'addon/js_upload/js_upload.php', 'js_upload_post_file');
+ Hook::unregister('photo_post_end', 'addon/js_upload/js_upload.php', 'js_upload_post_end');
- var selected = new Array();
- var index = 0;
- for (var intLoop = 0; intLoop < opt.length; intLoop++) {
- if ((opt[intLoop].selected) ||
- (opt[intLoop].checked)) {
- index = selected.length;
- //selected[index] = new Object;
- selected[index] = opt[intLoop].value;
- //selected[index] = intLoop;
- }
- }
- return selected;
- }
+ var selected = new Array();
+ var index = 0;
+ for (var intLoop = 0; intLoop < opt.length; intLoop++) {
+ if ((opt[intLoop].selected) ||
+ (opt[intLoop].checked)) {
+ index = selected.length;
+ //selected[index] = new Object;
+ selected[index] = opt[intLoop].value;
+ //selected[index] = intLoop;
+ }
+ }
+ return selected;
+ }
function createUploader() {
uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: '{$b['post_url']}',
function createUploader() {
uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: '{$b['post_url']}',
- template: '<div class="qq-uploader">' +
- '<div class="qq-upload-drop-area"><span>$drop_msg</span></div>' +
- '<div class="qq-upload-button">$upload_msg</div>' +
- '<ul class="qq-upload-list"></ul>' +
- '</div>',
-
- // template for one item in file list
- fileTemplate: '<li>' +
- '<span class="qq-upload-file"></span>' +
- '<span class="qq-upload-spinner"></span>' +
- '<span class="qq-upload-size"></span>' +
- '<a class="qq-upload-cancel" href="#">$cancel</a>' +
- '<span class="qq-upload-failed-text">$failed</span>' +
- '</li>',
+ template: '<div class="qq-uploader">' +
+ '<div class="qq-upload-drop-area"><span>$drop_msg</span></div>' +
+ '<div class="qq-upload-button">$upload_msg</div>' +
+ '<ul class="qq-upload-list"></ul>' +
+ '</div>',
+
+ // template for one item in file list
+ fileTemplate: '<li>' +
+ '<span class="qq-upload-file"></span>' +
+ '<span class="qq-upload-spinner"></span>' +
+ '<span class="qq-upload-size"></span>' +
+ '<a class="qq-upload-cancel" href="#">$cancel</a>' +
+ '<span class="qq-upload-failed-text">$failed</span>' +
+ '</li>',
if(isset($result['error'])) {
Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , Logger::DEBUG);
echo json_encode($result);
if(isset($result['error'])) {
Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , Logger::DEBUG);
echo json_encode($result);
- $b['src'] = $result['path'];
- $b['filename'] = $result['filename'];
- $b['filesize'] = filesize($b['src']);
+ $b['src'] = $result['path'];
+ $b['filename'] = $result['filename'];
+ $b['filesize'] = filesize($b['src']);
function js_upload_post_end(&$a,&$b) {
Logger::log('upload_post_end');
function js_upload_post_end(&$a,&$b) {
Logger::log('upload_post_end');
- /**
- * Save the file in the temp dir.
- * @return boolean TRUE on success
- */
- function save() {
- $input = fopen("php://input", "r");
+ /**
+ * Save the file in the temp dir.
+ * @return boolean TRUE on success
+ */
+ function save() {
+ $input = fopen("php://input", "r");
$upload_dir = Config::get('system','tempdir');
if(! $upload_dir)
$upload_dir = sys_get_temp_dir();
$upload_dir = Config::get('system','tempdir');
if(! $upload_dir)
$upload_dir = sys_get_temp_dir();
- function getName() {
- return $_GET['qqfile'];
- }
-
- function getSize() {
- if (isset($_SERVER["CONTENT_LENGTH"])){
- return (int)$_SERVER["CONTENT_LENGTH"];
- } else {
- throw new Exception('Getting content length is not supported.');
- }
- }
+ function getName() {
+ return $_GET['qqfile'];
+ }
+
+ function getSize() {
+ if (isset($_SERVER["CONTENT_LENGTH"])){
+ return (int)$_SERVER["CONTENT_LENGTH"];
+ } else {
+ throw new Exception('Getting content length is not supported.');
+ }
+ }
- private $allowedExtensions = [];
- private $sizeLimit = 10485760;
- private $file;
-
- function __construct(array $allowedExtensions = [], $sizeLimit = 10485760){
- $allowedExtensions = array_map("strtolower", $allowedExtensions);
-
- $this->allowedExtensions = $allowedExtensions;
- $this->sizeLimit = $sizeLimit;
-
- if (isset($_GET['qqfile'])) {
- $this->file = new qqUploadedFileXhr();
- } elseif (isset($_FILES['qqfile'])) {
- $this->file = new qqUploadedFileForm();
- } else {
- $this->file = false;
- }
+ private $allowedExtensions = [];
+ private $sizeLimit = 10485760;
+ private $file;
+
+ function __construct(array $allowedExtensions = [], $sizeLimit = 10485760){
+ $allowedExtensions = array_map("strtolower", $allowedExtensions);
+
+ $this->allowedExtensions = $allowedExtensions;
+ $this->sizeLimit = $sizeLimit;
+
+ if (isset($_GET['qqfile'])) {
+ $this->file = new qqUploadedFileXhr();
+ } elseif (isset($_FILES['qqfile'])) {
+ $this->file = new qqUploadedFileForm();
+ } else {
+ $this->file = false;
+ }
- private function toBytes($str){
- $val = trim($str);
- $last = strtolower($str[strlen($str)-1]);
- switch($last) {
- case 'g': $val *= 1024;
- case 'm': $val *= 1024;
- case 'k': $val *= 1024;
- }
- return $val;
- }
+ private function toBytes($str){
+ $val = trim($str);
+ $last = strtolower($str[strlen($str)-1]);
+ switch($last) {
+ case 'g': $val *= 1024;
+ case 'm': $val *= 1024;
+ case 'k': $val *= 1024;
+ }
+ return $val;
+ }
- $ext = $pathinfo['extension'];
+ if (!isset($pathinfo['extension'])) {
+ Logger::warning('extension isn\'t set.', ['filename' => $filename]);
+ }
+ $ext = defaults($pathinfo, 'extension', '');
- if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
- $these = implode(', ', $this->allowedExtensions);
- return ['error' => L10n::t('File has an invalid extension, it should be one of ') . $these . '.'];
- }
+ if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
+ $these = implode(', ', $this->allowedExtensions);
+ return ['error' => L10n::t('File has an invalid extension, it should be one of ') . $these . '.'];
+ }
- if ($this->file->save()){
- return [
- 'success'=>true,
- 'path' => $this->file->getPath(),
+ if ($this->file->save()){
+ return [
+ 'success' => true,
+ 'path' => $this->file->getPath(),
- } else {
- return [
- 'error'=> L10n::t('Upload was cancelled, or server error encountered'),
- 'path' => $this->file->getPath(),
+ } else {
+ return [
+ 'error' => L10n::t('Upload was cancelled, or server error encountered'),
+ 'path' => $this->file->getPath(),