From f5674558caf888fc8bdbad5fbb6c9b54868c1bb3 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 18:18:47 -0800 Subject: propagate name changes to 'self' contact record --- mod/settings.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mod/settings.php b/mod/settings.php index 1923c58da..32906d86e 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -87,11 +87,14 @@ function settings_post(&$a) { $err = ''; + $name_change = false; + if($username != $a->user['username']) { - if(strlen($username) > 40) - $err .= t(' Please use a shorter name.'); - if(strlen($username) < 3) - $err .= t(' Name too short.'); + $name_change = true; + if(strlen($username) > 40) + $err .= t(' Please use a shorter name.'); + if(strlen($username) < 3) + $err .= t(' Name too short.'); } if($email != $a->user['email']) { @@ -165,6 +168,15 @@ function settings_post(&$a) { intval(local_user()) ); + + if($name_change) { + q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1", + dbesc($username), + dbesc(datetime_convert()), + intval(local_user()) + ); + } + if($old_visibility != $net_publish) { // Update global directory in background $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); -- cgit v1.2.3 From 34502f1cde61f031a9303ae09bbd36daa5960164 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 18:54:32 -0800 Subject: main plugin files --- addon/java_upload/java_upload.php | 24 +++++ addon/js_upload/js_upload.php | 218 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 addon/java_upload/java_upload.php create mode 100644 addon/js_upload/js_upload.php diff --git a/addon/java_upload/java_upload.php b/addon/java_upload/java_upload.php new file mode 100644 index 000000000..92cd5326e --- /dev/null +++ b/addon/java_upload/java_upload.php @@ -0,0 +1,24 @@ +data['java_upload'] = true; + else + $a->data['java_upload'] = false; + + +} + + +function java_upload_photo_post_end(&$a,&$b) { + + if(x($a->data,'java_upload') && $a->data['java_upload']) + killme(); + +} \ No newline at end of file diff --git a/addon/js_upload/js_upload.php b/addon/js_upload/js_upload.php new file mode 100644 index 000000000..143f9ba33 --- /dev/null +++ b/addon/js_upload/js_upload.php @@ -0,0 +1,218 @@ +handleUpload('uploads/'); + + // to pass data through iframe you will need to encode all html tags + $a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES); + + if(isset($result['error'])) { + logger('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , 'LOGGER_DEBUG'); + killme(); + } + + +} + +function js_upload_photo_post_file(&$a,&$b) { + + $b['src'] = 'uploads/'.$result['filename']; + $b['filename'] = $result['filename']; + $b['filesize'] = filesize($src); +} + + +function js_upload_photo_post_end(&$a,&$b) { + + if(x($a->data,'upload_jsonresponse')) { + echo $a->data['upload_jsonresponse']; + @unlink($src); + killme(); + } + +} + + +/** + * Handle file uploads via XMLHttpRequest + */ +class qqUploadedFileXhr { + /** + * Save the file to the specified path + * @return boolean TRUE on success + */ + function save($path) { + $input = fopen("php://input", "r"); + $temp = tmpfile(); + $realSize = stream_copy_to_stream($input, $temp); + fclose($input); + + 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 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.'); + } + } +} + +/** + * 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; + } + return true; + } + function getName() { + return $_FILES['qqfile']['name']; + } + function getSize() { + return $_FILES['qqfile']['size']; + } +} +class qqFileUploader { + private $allowedExtensions = array(); + private $sizeLimit = 10485760; + private $file; + + function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){ + $allowedExtensions = array_map("strtolower", $allowedExtensions); + + $this->allowedExtensions = $allowedExtensions; + $this->sizeLimit = $sizeLimit; + + $this->checkServerSettings(); + + if (isset($_GET['qqfile'])) { + $this->file = new qqUploadedFileXhr(); + } elseif (isset($_FILES['qqfile'])) { + $this->file = new qqUploadedFileForm(); + } else { + $this->file = false; + } + } + + private function checkServerSettings(){ + $postSize = $this->toBytes(ini_get('post_max_size')); + $uploadSize = $this->toBytes(ini_get('upload_max_filesize')); + logger('mod/photos.php: qqFileUploader(): upload_max_filesize=' . $uploadSize , 'LOGGER_DEBUG'); + if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit){ + $size = max(1, $this->sizeLimit / 1024 / 1024) . 'M'; + die("{'error':'increase post_max_size and upload_max_filesize to $size'}"); + } + } + + 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; + } + + /** + * 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.')); + } + + if (!$this->file){ + return array('error' => t('No files were uploaded.')); + } + + $size = $this->file->getSize(); + + if ($size == 0) { + return array('error' => t('Uploaded file is empty')); + } + + if ($size > $this->sizeLimit) { + + return array('error' => t('Uploaded file is too large')); + } + + + $maximagesize = get_config('system','maximagesize'); + + if(($maximagesize) && ($size > $maximagesize)) { + return array('error' => t('Image exceeds size limit of ') . $maximagesize ); + + } + + $pathinfo = pathinfo($this->file->getName()); + $filename = $pathinfo['filename']; + //$filename = md5(uniqid()); + $ext = $pathinfo['extension']; + + if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ + $these = implode(', ', $this->allowedExtensions); + 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); + } else { + return array('error'=> t('Could not save uploaded file.') . + t('The upload was cancelled, or server error encountered'),'filename' => $filename . '.' . $ext); + } + + } +} -- cgit v1.2.3 From 8e3c2634cb3065837cfef09c3435f85a15dc6755 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 18:56:25 -0800 Subject: wrong branch --- addon/java_upload/java_upload.php | 24 ----- addon/js_upload/js_upload.php | 218 -------------------------------------- 2 files changed, 242 deletions(-) delete mode 100644 addon/java_upload/java_upload.php delete mode 100644 addon/js_upload/js_upload.php diff --git a/addon/java_upload/java_upload.php b/addon/java_upload/java_upload.php deleted file mode 100644 index 92cd5326e..000000000 --- a/addon/java_upload/java_upload.php +++ /dev/null @@ -1,24 +0,0 @@ -data['java_upload'] = true; - else - $a->data['java_upload'] = false; - - -} - - -function java_upload_photo_post_end(&$a,&$b) { - - if(x($a->data,'java_upload') && $a->data['java_upload']) - killme(); - -} \ No newline at end of file diff --git a/addon/js_upload/js_upload.php b/addon/js_upload/js_upload.php deleted file mode 100644 index 143f9ba33..000000000 --- a/addon/js_upload/js_upload.php +++ /dev/null @@ -1,218 +0,0 @@ -handleUpload('uploads/'); - - // to pass data through iframe you will need to encode all html tags - $a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES); - - if(isset($result['error'])) { - logger('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'] , 'LOGGER_DEBUG'); - killme(); - } - - -} - -function js_upload_photo_post_file(&$a,&$b) { - - $b['src'] = 'uploads/'.$result['filename']; - $b['filename'] = $result['filename']; - $b['filesize'] = filesize($src); -} - - -function js_upload_photo_post_end(&$a,&$b) { - - if(x($a->data,'upload_jsonresponse')) { - echo $a->data['upload_jsonresponse']; - @unlink($src); - killme(); - } - -} - - -/** - * Handle file uploads via XMLHttpRequest - */ -class qqUploadedFileXhr { - /** - * Save the file to the specified path - * @return boolean TRUE on success - */ - function save($path) { - $input = fopen("php://input", "r"); - $temp = tmpfile(); - $realSize = stream_copy_to_stream($input, $temp); - fclose($input); - - 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 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.'); - } - } -} - -/** - * 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; - } - return true; - } - function getName() { - return $_FILES['qqfile']['name']; - } - function getSize() { - return $_FILES['qqfile']['size']; - } -} -class qqFileUploader { - private $allowedExtensions = array(); - private $sizeLimit = 10485760; - private $file; - - function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){ - $allowedExtensions = array_map("strtolower", $allowedExtensions); - - $this->allowedExtensions = $allowedExtensions; - $this->sizeLimit = $sizeLimit; - - $this->checkServerSettings(); - - if (isset($_GET['qqfile'])) { - $this->file = new qqUploadedFileXhr(); - } elseif (isset($_FILES['qqfile'])) { - $this->file = new qqUploadedFileForm(); - } else { - $this->file = false; - } - } - - private function checkServerSettings(){ - $postSize = $this->toBytes(ini_get('post_max_size')); - $uploadSize = $this->toBytes(ini_get('upload_max_filesize')); - logger('mod/photos.php: qqFileUploader(): upload_max_filesize=' . $uploadSize , 'LOGGER_DEBUG'); - if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit){ - $size = max(1, $this->sizeLimit / 1024 / 1024) . 'M'; - die("{'error':'increase post_max_size and upload_max_filesize to $size'}"); - } - } - - 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; - } - - /** - * 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.')); - } - - if (!$this->file){ - return array('error' => t('No files were uploaded.')); - } - - $size = $this->file->getSize(); - - if ($size == 0) { - return array('error' => t('Uploaded file is empty')); - } - - if ($size > $this->sizeLimit) { - - return array('error' => t('Uploaded file is too large')); - } - - - $maximagesize = get_config('system','maximagesize'); - - if(($maximagesize) && ($size > $maximagesize)) { - return array('error' => t('Image exceeds size limit of ') . $maximagesize ); - - } - - $pathinfo = pathinfo($this->file->getName()); - $filename = $pathinfo['filename']; - //$filename = md5(uniqid()); - $ext = $pathinfo['extension']; - - if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ - $these = implode(', ', $this->allowedExtensions); - 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); - } else { - return array('error'=> t('Could not save uploaded file.') . - t('The upload was cancelled, or server error encountered'),'filename' => $filename . '.' . $ext); - } - - } -} -- cgit v1.2.3 From 08d6fe5ae74cc223e4385344f8e0edfde4208a23 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 19:36:20 -0800 Subject: allow RSS for feed contacts, but no comments --- include/Scrape.php | 2 ++ include/items.php | 26 ++++++++++++++++++++++---- mod/follow.php | 5 ++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index 8478ea407..e4f7a0878 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -161,6 +161,8 @@ function scrape_feed($url) { $x = $item->getAttribute('rel'); if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml')) $ret['feed_atom'] = $item->getAttribute('href'); + if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml')) + $ret['feed_rss'] = $item->getAttribute('href'); } return $ret; diff --git a/include/items.php b/include/items.php index 5f8264beb..cbe0e970d 100644 --- a/include/items.php +++ b/include/items.php @@ -423,19 +423,29 @@ function get_atom_elements($feed,$item) { else $res['private'] = 0; - $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published'); - if($rawcreated) - $res['created'] = unxmlify($rawcreated[0]['data']); $rawlocation = $item->get_item_tags(NAMESPACE_DFRN, 'location'); if($rawlocation) $res['location'] = unxmlify($rawlocation[0]['data']); + $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published'); + if($rawcreated) + $res['created'] = unxmlify($rawcreated[0]['data']); + + $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated'); if($rawedited) $res['edited'] = unxmlify($rawcreated[0]['data']); + + if(! $res['created']) + $res['created'] = $item->get_date(); + + if(! $res['edited']) + $res['edited'] = $item->get_date(); + + $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) $res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); @@ -1155,6 +1165,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { ); $datarray['last-child'] = 1; } + if(($contact['network'] === 'feed') || (! strlen($contact['poll']))) { + // one way feed - no remote comment ability + $datarray['last-child'] = 0; + } $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; @@ -1207,6 +1221,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { $datarray['last-child'] = 1; } + if(($contact['network'] === 'feed') || (! strlen($contact['poll']))) { + // one way feed - no remote comment ability + $datarray['last-child'] = 0; + } + $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; @@ -1216,7 +1235,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { } } } - } function new_follower($importer,$contact,$datarray,$item) { diff --git a/mod/follow.php b/mod/follow.php index e5eb7763b..bad2e74f9 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -74,8 +74,8 @@ function follow_post(&$a) { $ret = scrape_feed($url); - if(count($ret) && $ret['feed_atom']) { - $poll = $ret['feed_atom']; + if(count($ret) && ($ret['feed_atom'] || $ret['feed_rss'])) { + $poll = ((x($ret,'feed_atom')) ? $ret['feed_atom'] : $ret['feed_rss']); $vcard = array(); require_once('simplepie/simplepie.inc'); $feed = new SimplePie(); @@ -115,7 +115,6 @@ function follow_post(&$a) { logger('follow: poll=' . $poll . ' notify=' . $notify . ' profile=' . $profile . ' vcard=' . print_r($vcard,true)); - // do we have enough information? if(! ((x($vcard['fn'])) && ($poll) && ($profile))) { -- cgit v1.2.3 From 0f64e1e623b492e005032e42b69df5d8b2f35d05 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 20:13:52 -0800 Subject: restrict post height, we may back this out later and replace with [show all] toggles --- view/theme/default/style.css | 5 +++++ view/theme/duepuntozero/style.css | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/view/theme/default/style.css b/view/theme/default/style.css index e34b622c6..49a8f2d73 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -1996,3 +1996,8 @@ a.mail-list-link { margin-bottom: 15px; } + +.wall-item-content { + max-height: 350px; + overflow:auto; +} diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index b00f24cc2..13d396e78 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -1879,4 +1879,7 @@ a.mail-list-link { margin-bottom: 15px; } - +.wall-item-content { + max-height: 350px; + overflow:auto; +} -- cgit v1.2.3 From fc5316fe21d567802adf784d4b984852f0c7ee90 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 20:21:14 -0800 Subject: allow a video and/or photo to fit with scrollbars --- view/theme/default/style.css | 2 +- view/theme/duepuntozero/style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 49a8f2d73..18b2ee67a 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -1998,6 +1998,6 @@ a.mail-list-link { .wall-item-content { - max-height: 350px; + max-height: 400px; overflow:auto; } diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 13d396e78..388f1e230 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -1880,6 +1880,6 @@ a.mail-list-link { } .wall-item-content { - max-height: 350px; + max-height: 400px; overflow:auto; } -- cgit v1.2.3 From b0ab3e468b5c20cfe369ff282b7906d1690a3510 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 24 Jan 2011 23:08:39 -0800 Subject: leave room for vertical scrollbar (when needed) --- boot.php | 14 ++++++++++++++ view/theme/default/style.css | 9 ++++----- view/theme/duepuntozero/style.css | 7 +++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/boot.php b/boot.php index 86ad29296..adb1b96f8 100644 --- a/boot.php +++ b/boot.php @@ -2215,3 +2215,17 @@ function link_compare($a,$b) { return true; return false; }} + + +if(! function_exists('prepare_body')) { +function prepare_body($item) { + + require_once('include/bbcode.php'); + + $s = smilies(bbcode($item['body'])); + + return $s; + + + +}} \ No newline at end of file diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 18b2ee67a..fcc9c94a8 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -985,6 +985,10 @@ input#dfrn-url { width: 450px; margin-left: 10px; margin-bottom: 20px; + padding: 20px; + max-height: 400px; + overflow: auto; + } .wall-item-title { @@ -1996,8 +2000,3 @@ a.mail-list-link { margin-bottom: 15px; } - -.wall-item-content { - max-height: 400px; - overflow:auto; -} diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 388f1e230..3351b35a1 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -854,6 +854,9 @@ input#dfrn-url { width: 450px; margin-left: 10px; margin-bottom: 20px; + padding: 20px; + max-height: 400px; + overflow: auto; } .wall-item-title { @@ -1879,7 +1882,3 @@ a.mail-list-link { margin-bottom: 15px; } -.wall-item-content { - max-height: 400px; - overflow:auto; -} -- cgit v1.2.3