diff --git a/addon/java_upload/java_upload.php b/addon/java_upload/java_upload.php
index 3d627b08f9..8b8a57604c 100644
--- a/addon/java_upload/java_upload.php
+++ b/addon/java_upload/java_upload.php
@@ -1,12 +1,43 @@
get_baseurl() . '/addon/java_upload/jumploader_z.jar';
+ $filestext = t('Select files to upload: ');
-$b .= <<< EOT;
+ $nojava = t('Use the following controls only if the Java uploader [above] fails to launch.');
+
+ $b['default_upload'] = true;
+
+
+$b['addon_text'] .= <<< EOT
$filestext
diff --git a/addon/java_upload/jumploader_z.jar b/addon/java_upload/jumploader_z.jar
new file mode 100644
index 0000000000..30a85a33fb
Binary files /dev/null and b/addon/java_upload/jumploader_z.jar differ
diff --git a/addon/js_upload/js_upload.php b/addon/js_upload/js_upload.php
index b738ade241..dc2dc37dcb 100644
--- a/addon/js_upload/js_upload.php
+++ b/addon/js_upload/js_upload.php
@@ -105,7 +105,7 @@ function js_upload_post_init(&$a,&$b) {
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
- $result = $uploader->handleUpload('uploads/');
+ $result = $uploader->handleUpload();
// to pass data through iframe you will need to encode all html tags
@@ -124,11 +124,10 @@ function js_upload_post_file(&$a,&$b) {
$result = $a->data['upload_result'];
- $b['src'] = 'uploads/' . $result['filename'];
+ $b['src'] = $result['path'];
$b['filename'] = $result['filename'];
$b['filesize'] = filesize($b['src']);
-logger('post_file' . print_r($b, true));
}
@@ -147,28 +146,32 @@ logger('upload_post_end');
* Handle file uploads via XMLHttpRequest
*/
class qqUploadedFileXhr {
+
+ private $pathnm = '';
+
/**
- * Save the file to the specified path
+ * Save the file in the temp dir.
* @return boolean TRUE on success
*/
- function save($path) {
+ function save() {
$input = fopen("php://input", "r");
- $temp = tmpfile();
+ $this->pathnm = tempnam(sys_get_temp_dir(),'frn');
+ $temp = fopen($this->pathnm,"w");
$realSize = stream_copy_to_stream($input, $temp);
+
fclose($input);
+ fclose($temp);
if ($realSize != $this->getSize()){
return false;
}
-
- $target = fopen($path, "w");
- fseek($temp, 0, SEEK_SET);
- stream_copy_to_stream($temp, $target);
- fclose($target);
-
return true;
}
+ function getPath() {
+ return $this->pathnm;
+ }
+
function getName() {
return $_GET['qqfile'];
}
@@ -187,16 +190,22 @@ class qqUploadedFileXhr {
*/
class qqUploadedFileForm {
+
+
/**
* Save the file to the specified path
* @return boolean TRUE on success
*/
- function save($path) {
- if(!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)){
- return false;
- }
+
+
+ function save() {
return true;
}
+
+ function getPath() {
+ return $_FILES['qqfile']['tmp_name'];
+ }
+
function getName() {
return $_FILES['qqfile']['name'];
}
@@ -225,6 +234,7 @@ class qqFileUploader {
} else {
$this->file = false;
}
+
}
private function checkServerSettings(){
@@ -251,10 +261,7 @@ class qqFileUploader {
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
- function handleUpload($uploadDirectory, $replaceOldFile = FALSE){
- if (!is_writable($uploadDirectory)){
- return array('error' => t('Server error. Upload directory isn\'t writable.'));
- }
+ function handleUpload(){
if (!$this->file){
return array('error' => t('No files were uploaded.'));
@@ -289,18 +296,18 @@ class qqFileUploader {
return array('error' => t('File has an invalid extension, it should be one of ') . $these . '.');
}
- if(!$replaceOldFile){
- /// don't overwrite previous files that were uploaded
- while (file_exists($uploadDirectory . $filename . '.' . $ext)) {
- $filename .= rand(10, 99);
- }
- }
-
- if ($this->file->save($uploadDirectory . $filename . '.' . $ext)){
- return array('success'=>true,'filename' => $filename . '.' . $ext);
+ if ($this->file->save()){
+ return array(
+ 'success'=>true,
+ 'path' => $this->file->getPath(),
+ 'filename' => $filename . '.' . $ext
+ );
} else {
- return array('error'=> t('Could not save uploaded file.') .
- t('The upload was cancelled, or server error encountered'),'filename' => $filename . '.' . $ext);
+ return array(
+ 'error'=> t('Upload was cancelled, or server error encountered'),
+ 'path' => $this->file->getPath(),
+ 'filename' => $filename . '.' . $ext
+ );
}
}
diff --git a/boot.php b/boot.php
index e984489e7c..589068fb2a 100644
--- a/boot.php
+++ b/boot.php
@@ -3,7 +3,7 @@
set_time_limit(0);
define ( 'BUILD_ID', 1033 );
-define ( 'FRIENDIKA_VERSION', '2.10.0901' );
+define ( 'FRIENDIKA_VERSION', '2.10.0902' );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', " \r\n" );
diff --git a/htconfig.php b/htconfig.php
index 6f6e3faf96..13c065e697 100644
--- a/htconfig.php
+++ b/htconfig.php
@@ -64,4 +64,12 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com';
$a->config['system']['rino_encrypt'] = true;
+
+// Addons or plugins are configured here.
+// This is a comma seperated list of addons to enable. Example:
+// $a->config['system']['addon'] = 'js_upload,randplace,oembed';
+
+$a->config['system']['addon'] = 'js_upload';
+
+
\ No newline at end of file
diff --git a/jumploader_z.jar b/jumploader_z.jar
deleted file mode 100644
index 9ef2abd896..0000000000
Binary files a/jumploader_z.jar and /dev/null differ
diff --git a/mod/photos.php b/mod/photos.php
index e811ca3957..2a55fa5e9a 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -1,5 +1,4 @@
$val) {
+ logger('mod/photos.php: photos_post(): $_REQUEST key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG');
+}
+
+foreach($_FILES AS $key => $val) {
+ logger('mod/photos.php: photos_post(): $_FILES key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG');
+}
+
$can_post = false;
$visitor = 0;
@@ -466,18 +474,20 @@ function photos_post(&$a) {
}
- // default post action - upload a photo
+ /**
+ * default post action - upload a photo
+ */
- if(! x($_FILES,'userfile'))
- killme();
+ call_hooks('photo_post_init', $_POST);
- if($_POST['partitionCount'])
- $java_upload = true;
- else
- $java_upload = false;
+ /**
+ * Determine the album to use
+ */
- $album = notags(trim($_POST['album']));
- $newalbum = notags(trim($_POST['newalbum']));
+ $album = notags(trim($_REQUEST['album']));
+ $newalbum = notags(trim($_REQUEST['newalbum']));
+
+ logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , 'LOGGER_DEBUG');
if(! strlen($album)) {
if(strlen($newalbum))
@@ -486,6 +496,16 @@ function photos_post(&$a) {
$album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
}
+ /**
+ *
+ * We create a wall item for every photo, but we don't want to
+ * overwhelm the data stream with a hundred newly uploaded photos.
+ * So we will make one photo (the first one uploaded to this album)
+ * visible by default, the rest will become visible over time when and if
+ * they acquire comments, likes, dislikes, and/or tags
+ *
+ */
+
$r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
dbesc($album),
intval($page_owner_uid)
@@ -495,15 +515,25 @@ function photos_post(&$a) {
else
$visible = 0;
+ $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow'])));
+ $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
+ $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny'])));
+ $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny'])));
- $str_group_allow = perms2str($_POST['group_allow']);
- $str_contact_allow = perms2str($_POST['contact_allow']);
- $str_group_deny = perms2str($_POST['group_deny']);
- $str_contact_deny = perms2str($_POST['contact_deny']);
+ $ret = array('src' => '', 'filename' => '', 'filesize' => 0);
- $src = $_FILES['userfile']['tmp_name'];
- $filename = basename($_FILES['userfile']['name']);
- $filesize = intval($_FILES['userfile']['size']);
+ call_hooks('photo_post_file',$ret);
+
+ if(x($ret,'src') && x($ret,'filesize')) {
+ $src = $ret['src'];
+ $filename = $ret['filename'];
+ $filesize = $ret['filesize'];
+ }
+ else {
+ $src = $_FILES['userfile']['tmp_name'];
+ $filename = basename($_FILES['userfile']['name']);
+ $filesize = intval($_FILES['userfile']['size']);
+ }
$maximagesize = get_config('system','maximagesize');
@@ -513,10 +543,13 @@ function photos_post(&$a) {
return;
}
+ logger('mod/photos.php: photos_post(): loading the contents of ' . $src , 'LOGGER_DEBUG');
+
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata);
if(! $ph->is_valid()) {
+ logger('mod/photos.php: photos_post(): unable to process image' , 'LOGGER_DEBUG');
notice( t('Unable to process image.') . EOL );
@unlink($src);
killme();
@@ -524,7 +557,7 @@ function photos_post(&$a) {
@unlink($src);
- $width = $ph->getWidth();
+ $width = $ph->getWidth();
$height = $ph->getHeight();
$smallest = 0;
@@ -534,6 +567,7 @@ function photos_post(&$a) {
$r = $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if(! $r) {
+ logger('mod/photos.php: photos_post(): image store failed' , 'LOGGER_DEBUG');
notice( t('Image upload failed.') . EOL );
killme();
}
@@ -555,7 +589,6 @@ function photos_post(&$a) {
// Create item container
-
$arr = array();
$arr['uid'] = $page_owner_uid;
@@ -584,14 +617,13 @@ function photos_post(&$a) {
$item_id = item_store($arr);
- if(! $java_upload) {
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- return; // NOTREACHED
- }
+ call_hooks('photo_post_end',intval($item_id));
- killme();
- return; // NOTREACHED
+ // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
+ // if they do not wish to be redirected
+ goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ // NOTREACHED
}
@@ -737,6 +769,22 @@ function photos_content(&$a) {
$celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
$albumselect .= '';
+
+ $uploader = '';
+
+ $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
+ 'addon_text' => $uploader,
+ 'default_upload' => true);
+
+
+ call_hooks('photo_upload_form',$ret);
+
+ $default_upload = '
+
';
+
+
+
+
$tpl = load_view_file('view/photos_upload.tpl');
$o .= replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
@@ -744,14 +792,13 @@ function photos_content(&$a) {
'$nickname' => $a->data['user']['nickname'],
'$newalbum' => t('New album name: '),
'$existalbumtext' => t('or existing album name: '),
- '$filestext' => t('Select files to upload: '),
'$albumselect' => $albumselect,
'$permissions' => t('Permissions'),
'$aclselect' => (($visitor) ? '' : populate_acl($a->user, $celeb)),
- '$archive' => $a->get_baseurl() . '/jumploader_z.jar',
- '$nojava' => t('Use the following controls only if the Java uploader [above] fails to launch.'),
- '$uploadurl' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
- '$submit' => t('Submit')
+ '$uploader' => $ret['addon_text'],
+ '$default' => (($ret['default_upload']) ? $default_upload : ''),
+ '$uploadurl' => $ret['post_url']
+
));
return $o;
@@ -1154,3 +1201,4 @@ function photos_content(&$a) {
$o .= paginate($a);
return $o;
}
+
diff --git a/util/extract.php b/util/extract.php
index bb16a47da1..92ec8501ce 100644
--- a/util/extract.php
+++ b/util/extract.php
@@ -3,7 +3,7 @@
$arr = array();
$files = array('index.php','boot.php');
- $files = array_merge($files,glob('mod/*'),glob('include/*'));
+ $files = array_merge($files,glob('mod/*'),glob('include/*'),glob('addon/*/*'));
foreach($files as $file) {
diff --git a/util/strings.php b/util/strings.php
index 8b58a6b7a5..5233c56197 100644
--- a/util/strings.php
+++ b/util/strings.php
@@ -163,6 +163,7 @@ $a->strings['Private Message'] = 'Private Message';
$a->strings['This is you'] = 'This is you';
$a->strings['View $name\'s profile'] = 'View $name\'s profile';
$a->strings['Item has been removed.'] = 'Item has been removed.';
+$a->strings['Shared content is covered by the Creative Commons Attribution 3.0 license.'] = 'Shared content is covered by the Creative Commons Attribution 3.0 license.';
$a->strings['The profile address specified does not provide adequate information.'] = 'The profile address specified does not provide adequate information.';
$a->strings['Limited profile. This person will be unable to receive direct/personal notifications from you.'] = 'Limited profile. This person will be unable to receive direct/personal notifications from you.';
$a->strings['Unable to retrieve contact information.'] = 'Unable to retrieve contact information.';
@@ -211,7 +212,6 @@ $a->strings['Send invitations'] = 'Send invitations';
$a->strings['Enter email addresses, one per line:'] = 'Enter email addresses, one per line:';
$a->strings['Your message:'] = 'Your message:';
$a->strings['Please join my social network on '] = 'Please join my social network on ';
-$a->strings["\r\n"] = "\r\n";
$a->strings['To accept this invitation, please visit:'] = 'To accept this invitation, please visit:';
$a->strings['Once you have registered, please connect with me via my profile page at:'] = 'Once you have registered, please connect with me via my profile page at:';
$a->strings['Unable to locate original post.'] = 'Unable to locate original post.';
@@ -287,9 +287,7 @@ $a->strings['No photos selected'] = 'No photos selected';
$a->strings['Upload Photos'] = 'Upload Photos';
$a->strings['New album name: '] = 'New album name: ';
$a->strings['or existing album name: '] = 'or existing album name: ';
-$a->strings['Select files to upload: '] = 'Select files to upload: ';
$a->strings['Permissions'] = 'Permissions';
-$a->strings['Use the following controls only if the Java uploader [above] fails to launch.'] = 'Use the following controls only if the Java uploader [above] fails to launch.';
$a->strings['Edit Album'] = 'Edit Album';
$a->strings['View Photo'] = 'View Photo';
$a->strings['Photo not available'] = 'Photo not available';
@@ -340,7 +338,6 @@ $a->strings['Your registration is pending approval by the site owner.'] = 'Your
$a->strings["You may \x28optionally\x29 fill in this form via OpenID by supplying your OpenID and clicking 'Register'."] = "You may \x28optionally\x29 fill in this form via OpenID by supplying your OpenID and clicking 'Register'.";
$a->strings['If you are not familiar with OpenID, please leave that field blank and fill in the rest of the items.'] = 'If you are not familiar with OpenID, please leave that field blank and fill in the rest of the items.';
$a->strings["Your OpenID \x28optional\x29: "] = "Your OpenID \x28optional\x29: ";
-$a->strings['Shared content is covered by the Creative Commons Attribution 3.0 license.'] = 'Shared content is covered by the Creative Commons Attribution 3.0 license.';
$a->strings['Registration'] = 'Registration';
$a->strings['Your Full Name ' . "\x28" . 'e.g. Joe Smith' . "\x29" . ': '] = 'Your Full Name ' . "\x28" . 'e.g. Joe Smith' . "\x29" . ': ';
$a->strings['Your Email Address: '] = 'Your Email Address: ';
@@ -467,6 +464,16 @@ $a->strings['Uncertain'] = 'Uncertain';
$a->strings['Complicated'] = 'Complicated';
$a->strings['Don\'t care'] = 'Don\'t care';
$a->strings['Ask me'] = 'Ask me';
+$a->strings['Facebook status update failed.'] = 'Facebook status update failed.';
+$a->strings['Select files to upload: '] = 'Select files to upload: ';
+$a->strings['Use the following controls only if the Java uploader [above] fails to launch.'] = 'Use the following controls only if the Java uploader [above] fails to launch.';
+$a->strings['No files were uploaded.'] = 'No files were uploaded.';
+$a->strings['Uploaded file is empty'] = 'Uploaded file is empty';
+$a->strings['Uploaded file is too large'] = 'Uploaded file is too large';
+$a->strings['File has an invalid extension, it should be one of '] = 'File has an invalid extension, it should be one of ';
+$a->strings['Upload was cancelled, or server error encountered'] = 'Upload was cancelled, or server error encountered';
+$a->strings['Randplace Settings'] = 'Randplace Settings';
+$a->strings['Enable Randplace Plugin'] = 'Enable Randplace Plugin';
$a->strings['Africa/Abidjan'] = 'Africa/Abidjan';
$a->strings['Africa/Accra'] = 'Africa/Accra';
$a->strings['Africa/Addis_Ababa'] = 'Africa/Addis_Ababa';
diff --git a/view/en/htconfig.tpl b/view/en/htconfig.tpl
index c7c19bf69e..0182dbe5c0 100644
--- a/view/en/htconfig.tpl
+++ b/view/en/htconfig.tpl
@@ -62,3 +62,9 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com';
$a->config['system']['rino_encrypt'] = true;
+// Addons or plugins are configured here.
+// This is a comma seperated list of addons to enable. Example:
+// $a->config['system']['addon'] = 'js_upload,randplace,oembed';
+
+$a->config['system']['addon'] = 'js_upload';
+
diff --git a/view/photos_upload.tpl b/view/photos_upload.tpl
index 8a9dc3c683..2dbcddefd0 100644
--- a/view/photos_upload.tpl
+++ b/view/photos_upload.tpl
@@ -23,41 +23,12 @@
-