+
+
+
+EOT;
+
+
+}
+
function js_upload_post_init(&$a,&$b) {
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
@@ -26,7 +104,9 @@ function js_upload_post_init(&$a,&$b) {
$sizeLimit = 6 * 1024 * 1024;
$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
$a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
@@ -36,22 +116,26 @@ function js_upload_post_init(&$a,&$b) {
killme();
}
+ $a->data['upload_result'] = $result;
}
-function js_upload_photo_post_file(&$a,&$b) {
+function js_upload_post_file(&$a,&$b) {
- $b['src'] = 'uploads/'.$result['filename'];
+ $result = $a->data['upload_result'];
+
+ $b['src'] = $result['path'];
$b['filename'] = $result['filename'];
- $b['filesize'] = filesize($src);
+ $b['filesize'] = filesize($b['src']);
+
}
-function js_upload_photo_post_end(&$a,&$b) {
+function js_upload_post_end(&$a,&$b) {
+logger('upload_post_end');
if(x($a->data,'upload_jsonresponse')) {
echo $a->data['upload_jsonresponse'];
- @unlink($src);
killme();
}
@@ -62,30 +146,36 @@ function js_upload_photo_post_end(&$a,&$b) {
* 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'];
}
+
function getSize() {
if (isset($_SERVER["CONTENT_LENGTH"])){
return (int)$_SERVER["CONTENT_LENGTH"];
@@ -98,17 +188,24 @@ class qqUploadedFileXhr {
/**
* Handle file uploads via regular form post (uses the $_FILES array)
*/
+
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'];
}
@@ -116,6 +213,7 @@ class qqUploadedFileForm {
return $_FILES['qqfile']['size'];
}
}
+
class qqFileUploader {
private $allowedExtensions = array();
private $sizeLimit = 10485760;
@@ -136,6 +234,7 @@ class qqFileUploader {
} else {
$this->file = false;
}
+
}
private function checkServerSettings(){
@@ -162,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.'));
@@ -192,7 +288,7 @@ class qqFileUploader {
$pathinfo = pathinfo($this->file->getName());
$filename = $pathinfo['filename'];
- //$filename = md5(uniqid());
+
$ext = $pathinfo['extension'];
if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
@@ -200,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 adb1b96f8..3cc98cc9b 100644
--- a/boot.php
+++ b/boot.php
@@ -3,7 +3,7 @@
set_time_limit(0);
define ( 'BUILD_ID', 1033 );
-define ( 'FRIENDIKA_VERSION', '2.01.1006' );
+define ( 'FRIENDIKA_VERSION', '2.10.0902' );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', " \r\n" );
@@ -1692,7 +1692,7 @@ function get_tags($s) {
$s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
- if(preg_match_all('/([@#][^ \x0D\x0A,:?]*)([ \x0D\x0A,:?]|$)/',$s,$match)) {
+ if(preg_match_all('/([@#][^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) {
foreach($match[1] as $match) {
if(strstr($match,"]")) {
// we might be inside a bbcode color tag - leave it alone
@@ -1878,7 +1878,7 @@ function aes_encrypt($val,$ky)
if(! function_exists('linkify')) {
function linkify($s) {
- $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' $1', $s);
+ $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' $1', $s);
return($s);
}}
diff --git a/htconfig.php b/htconfig.php
index 6f6e3faf9..13c065e69 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/include/bbcode.php b/include/bbcode.php
index 9e5f5a371..8382cc804 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -22,10 +22,10 @@ function bbcode($Text) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]+)/", ' $2', $Text);
+ $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]+)/", ' $2', $Text);
- $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '$1', $Text);
- $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text);
+ $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '$1', $Text);
+ $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text);
//$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '$2', $Text);
diff --git a/jumploader_z.jar b/jumploader_z.jar
deleted file mode 100644
index 9ef2abd89..000000000
Binary files a/jumploader_z.jar and /dev/null differ
diff --git a/mod/photos.php b/mod/photos.php
index e811ca395..2a55fa5e9 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 bb16a47da..92ec8501c 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 8b58a6b7a..5233c5619 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 c7c19bf69..0182dbe5c 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/fr/head.tpl b/view/fr/head.tpl
index 04dd39bdb..81011f422 100644
--- a/view/fr/head.tpl
+++ b/view/fr/head.tpl
@@ -11,7 +11,7 @@