Merge branch 'master' of git://github.com/friendika/friendika

This commit is contained in:
root 2010-12-21 07:14:58 +01:00
commit 8cfa93b730
15 changed files with 227 additions and 31 deletions

View file

@ -23,6 +23,7 @@ encryption support
- PHP *command line* access with register_argc_argv set to true in the
php.ini file
- curl, gd, mysql, and openssl extensions
- some form of email server or email gateway such that PHP mail() works
- mcrypt (optional; used for end-to-end message encryption)
- Mysql 5.x

View file

@ -2,7 +2,7 @@
set_time_limit(0);
define ( 'BUILD_ID', 1024 );
define ( 'BUILD_ID', 1027 );
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
define ( 'EOL', "<br />\r\n" );
@ -174,8 +174,10 @@ class App {
public $pager;
public $strings;
public $path;
public $hooks;
public $interactive = true;
private $scheme;
private $hostname;
private $baseurl;
@ -1924,7 +1926,7 @@ function profile_sidebar($profile) {
$gender = ((x($profile,'gender') == 1) ? '<div class="mf"><span class="gender-label">' . t('Gender:') . '</span> <span class="x-gender">' . $profile['gender'] . '</span></div><div class="profile-clear"></div>' : '');
$pubkey = ((x($profile,'key') == 1) ? '<div class="key" style="display:none;">' . $profile['pubkey'] . '</div>' : '');
$pubkey = ((x($profile,'pubkey') == 1) ? '<div class="key" style="display:none;">' . $profile['pubkey'] . '</div>' : '');
$marital = ((x($profile,'marital') == 1) ? '<div class="marital"><span class="marital-label"><span class="heart">&hearts;</span> ' . t('Status:') . ' </span><span class="marital-text">' . $profile['marital'] . '</span></div></div><div class="profile-clear"></div>' : '');
@ -1946,3 +1948,57 @@ function profile_sidebar($profile) {
return $o;
}}
if(! function_exists('register_hook')) {
function register_hook($hook,$file,$function) {
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`) VALUES ( '%s', '%s', '%s' ) ",
dbesc($hook),
dbesc($file),
dbesc($function)
);
return $r;
}}
if(! function_exists('unregister_hook')) {
function unregister_hook($hook,$file,$function) {
$r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
dbesc($hook),
dbesc($file),
dbesc($function)
);
return $r;
}}
if(! function_exists('load_hooks')) {
function load_hooks() {
$a = get_app();
$r = q("SELECT * FROM `hook` WHERE 1");
if(count($r)) {
foreach($r as $rr) {
$a->hooks[] = array($rr['hook'], $rr['file'], $rr['function']);
}
}
}}
if(! function_exists('call_hooks')) {
function call_hooks($name, $data = null) {
$a = get_app();
if(count($a->hooks)) {
foreach($a->hooks as $hook) {
if($hook[0] === $name) {
@require_once($hook[1]);
if(function_exists($hook[2])) {
$func = $hook[2];
$func($a,$data);
}
}
}
}
}}

View file

@ -292,6 +292,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`sexual` char(255) NOT NULL,
`politic` char(255) NOT NULL,
`religion` char(255) NOT NULL,
`keywords` text NOT NULL,
`about` text NOT NULL,
`summary` char(255) NOT NULL,
`music` text NOT NULL,
@ -371,6 +372,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`notify-flags` int(11) unsigned NOT NULL DEFAULT '65535',
`page-flags` int(11) unsigned NOT NULL DEFAULT '0',
`pwdreset` char(255) NOT NULL,
`maxreq` int(11) NOT NULL DEFAULT '10',
`allow_cid` mediumtext NOT NULL,
`allow_gid` mediumtext NOT NULL,
`deny_cid` mediumtext NOT NULL,
@ -431,3 +433,11 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `hook` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`hook` CHAR( 255 ) NOT NULL ,
`file` CHAR( 255 ) NOT NULL ,
`function` CHAR( 255 ) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

View file

@ -16,7 +16,7 @@ function gender_selector($current="",$suffix="") {
function sexpref_selector($current="",$suffix="") {
$o = '';
$select = array('', t('Males'), t('Females'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual'));
$select = array('', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual'));
$o .= "<select name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >";
foreach($select as $selection) {

View file

@ -220,7 +220,7 @@ function dfrn_request_post(&$a) {
$nickname = $a->profile['nickname'];
$notify_flags = $a->profile['notify-flags'];
$uid = $a->profile['uid'];
$maxreq = intval($a->profile['maxreq']);
$contact_record = null;
$failed = false;
$parms = null;
@ -228,6 +228,23 @@ function dfrn_request_post(&$a) {
if( x($_POST,'dfrn_url')) {
/**
* Block friend request spam
*/
if($maxreq) {
$r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d",
dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
intval($uid)
);
if(count($r) > $maxreq) {
notice( $a->profile['name'] . t(' has received too many connection requests today.') . EOL);
notice( t('Spam protection measures have been invoked.') . EOL);
notice( t('Friends are advised to please try again in 24 hours.') . EOL);
return;
}
}
$url = trim($_POST['dfrn_url']);
if(! strlen($url)) {
notice( t("Invalid locator") . EOL );

View file

@ -18,7 +18,7 @@ function directory_content(&$a) {
if(x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$tpl = load_view_file('view/directory_header.tpl');
@ -37,7 +37,7 @@ function directory_content(&$a) {
if($search)
$search = dbesc($search);
$sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`) AGAINST ('$search' IN BOOLEAN MODE) " : "");
$sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `publish` = 1 AND `user`.`blocked` = 0 $sql_extra ");

View file

@ -55,6 +55,17 @@ function item_post(&$a) {
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
if(($parent_item) &&
(($parent_item['private'])
|| strlen($parent_item['allow_cid'])
|| strlen($parent_item['allow_gid'])
|| strlen($parent_item['deny_cid'])
|| strlen($parent_item['deny_gid'])
)
) {
$private = 1;
}
$title = notags(trim($_POST['title']));
$body = escape_tags(trim($_POST['body']));
$location = notags(trim($_POST['location']));
@ -242,7 +253,6 @@ function item_post(&$a) {
);
// Inherit ACL's from the parent item.
// TODO merge with subsequent UPDATE operation and save a db write
$r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d
WHERE `id` = %d LIMIT 1",
@ -327,7 +337,7 @@ function item_post(&$a) {
* Post to Facebook stream
*/
if((local_user()) && (local_user() == $profile_uid)) {
if((local_user()) && (local_user() == $profile_uid) && (! $private)) {
$appid = get_config('system', 'facebook_appid' );
$secret = get_config('system', 'facebook_secret' );
if($appid && $secret) {

View file

@ -2,10 +2,13 @@
require_once('library/HTML5/Parser.php');
function parse_url_content(&$a) {
$url = trim($_GET['url']);
$text = null;
$template = "<a href=\"%s\" >%s</a>%s";
if($url)
@ -20,7 +23,7 @@ function parse_url_content(&$a) {
killme();
}
$dom = HTML5_Parser::parse($s);
$dom = @HTML5_Parser::parse($s);
if(! $dom)
return $ret;
@ -34,6 +37,28 @@ function parse_url_content(&$a) {
}
}
$divs = $dom->getElementsByTagName('div');
if($divs) {
foreach($divs as $div) {
$class = $div->getAttribute('class');
if($class && stristr($class,'article')) {
$items = $div->getElementsByTagName('p');
if($items) {
foreach($items as $item) {
$text = $item->textContent;
$text = strip_tags($text);
if(strlen($text) < 100)
continue;
$text = substr($text,0,250) . '...' ;
break;
}
}
}
}
}
if(! $text) {
$items = $dom->getElementsByTagName('p');
if($items) {
foreach($items as $item) {
@ -45,6 +70,7 @@ function parse_url_content(&$a) {
break;
}
}
}
if(strlen($text)) {
$text = '<br />' . $text;

View file

@ -52,7 +52,7 @@ function profiles_post(&$a) {
$region = notags(trim($_POST['region']));
$postal_code = notags(trim($_POST['postal_code']));
$country_name = notags(trim($_POST['country_name']));
$keywords = notags(trim($_POST['keywords']));
$marital = notags(trim($_POST['marital']));
if($marital != $orig[0]['marital'])
$maritalchanged = true;
@ -138,6 +138,7 @@ function profiles_post(&$a) {
`homepage` = '%s',
`politic` = '%s',
`religion` = '%s',
`keywords` = '%s',
`about` = '%s',
`interest` = '%s',
`contact` = '%s',
@ -165,6 +166,7 @@ function profiles_post(&$a) {
dbesc($homepage),
dbesc($politic),
dbesc($religion),
dbesc($keywords),
dbesc($about),
dbesc($interest),
dbesc($contact),
@ -369,6 +371,7 @@ function profiles_content(&$a) {
'$homepage' => $r[0]['homepage'],
'$politic' => $r[0]['politic'],
'$religion' => $r[0]['religion'],
'$keywords' => $r[0]['keywords'],
'$music' => $r[0]['music'],
'$book' => $r[0]['book'],
'$tv' => $r[0]['tv'],

View file

@ -53,6 +53,7 @@ function settings_post(&$a) {
$timezone = ((x($_POST,'timezone')) ? notags(trim($_POST['timezone'])) : '');
$defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
$openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');
$maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
$allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
$publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
@ -105,7 +106,7 @@ function settings_post(&$a) {
$str_group_deny = perms2str($_POST['group_deny']);
$str_contact_deny = perms2str($_POST['contact_deny']);
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s' WHERE `uid` = %d LIMIT 1",
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d WHERE `uid` = %d LIMIT 1",
dbesc($username),
dbesc($email),
dbesc($openid),
@ -119,6 +120,7 @@ function settings_post(&$a) {
dbesc($defloc),
intval($allow_location),
dbesc($theme),
intval($maxreq),
intval(local_user())
);
if($r)
@ -179,6 +181,7 @@ function settings_content(&$a) {
$notify = $a->user['notify-flags'];
$defloc = $a->user['default-location'];
$openid = $a->user['openid'];
$maxreq = $a->user['maxreq'];
if(! strlen($a->user['timezone']))
$timezone = date_default_timezone_get();
@ -290,6 +293,7 @@ function settings_content(&$a) {
'$sel_notify3' => (($notify & NOTIFY_WALL) ? ' checked="checked" ' : ''),
'$sel_notify4' => (($notify & NOTIFY_COMMENT) ? ' checked="checked" ' : ''),
'$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : ''),
'$maxreq' => $maxreq,
'$theme' => $theme_selector,
'$pagetype' => $pagetype
));

View file

@ -243,3 +243,21 @@ function update_1023() {
ADD `login_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `register_date` ");
}
function update_1024() {
q("ALTER TABLE `profile` ADD `keywords` TEXT NOT NULL AFTER `religion` ");
}
function update_1025() {
q("ALTER TABLE `user` ADD `maxreq` int(11) NOT NULL DEFAULT '10' AFTER `pwdreset` ");
}
function update_1026() {
q("CREATE TABLE IF NOT EXISTS `hook` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`hook` CHAR( 255 ) NOT NULL ,
`file` CHAR( 255 ) NOT NULL ,
`function` CHAR( 255 ) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
}

View file

@ -117,6 +117,20 @@ $a->strings['Your introduction has been sent.'] = 'Your introduction has been se
$a->strings["Please login to confirm introduction."] = "Please login to confirm introduction.";
$a->strings["Incorrect identity currently logged in. Please login to <strong>this</strong> profile."] = "Incorrect identity currently logged in. Please login to <strong>this</strong> profile.";
$a->strings['[Name Withheld]'] = '[Name Withheld]';
$a->strings['Friend/Connection Request'] = 'Friend/Connection Request';
$a->strings['Please answer the following:'] = 'Please answer the following:';
$a->strings['Does $name know you?'] = 'Does $name know you?';
$a->strings['Yes'] = 'Yes';
$a->strings['No'] = 'No';
$a->strings['Add a personal note:'] = 'Add a personal note:';
$a->strings['Please enter your profile address from one of the following supported social networks:'] = 'Please enter your profile address from one of the following supported social networks:';
$a->strings['Friendika'] = 'Friendika';
$a->strings['StatusNet/Federated Social Web'] = 'StatusNet/Federated Social Web';
$a->strings["Private \x28secure\x29 network"] = "Private \x28secure\x29 network";
$a->strings["Public \x28insecure\x29 network"] = "Public \x28insecure\x29 network";
$a->strings['Your profile address:'] = 'Your profile address:';
$a->strings['Submit Request'] = 'Submit Request';
$a->strings['Cancel'] = 'Cancel';
$a->strings['Global Directory'] = 'Global Directory';
$a->strings['Item not found.'] = 'Item not found.';
$a->strings['Private Message'] = 'Private Message';
@ -176,6 +190,7 @@ $a->strings['Unable to locate original post.'] = 'Unable to locate original post
$a->strings['Empty post discarded.'] = 'Empty post discarded.';
$a->strings[" commented on your item at "] = " commented on your item at ";
$a->strings[" posted on your profile wall at "] = " posted on your profile wall at ";
$a->strings['Facebook status update failed.'] = 'Facebook status update failed.';
$a->strings['photo'] = 'photo';
$a->strings['status'] = 'status';
$a->strings['likes'] = 'likes';
@ -311,7 +326,6 @@ $a->strings['OpenID: '] = 'OpenID: ';
$a->strings["&nbsp;\x28Optional\x29 Allow this OpenID to login to this account."] = "&nbsp;\x28Optional\x29 Allow this OpenID to login to this account.";
$a->strings['Profile is <strong>not published</strong>.'] = 'Profile is <strong>not published</strong>.';
$a->strings['Default Post Permissions'] = 'Default Post Permissions';
$a->strings['Cancel'] = 'Cancel';
$a->strings['Tag removed'] = 'Tag removed';
$a->strings['Remove Item Tag'] = 'Remove Item Tag';
$a->strings['Select a tag to remove: '] = 'Select a tag to remove: ';
@ -376,6 +390,8 @@ $a->strings['Other'] = 'Other';
$a->strings['Undecided'] = 'Undecided';
$a->strings['Males'] = 'Males';
$a->strings['Females'] = 'Females';
$a->strings['Gay'] = 'Gay';
$a->strings['Lesbian'] = 'Lesbian';
$a->strings['No Preference'] = 'No Preference';
$a->strings['Bisexual'] = 'Bisexual';
$a->strings['Autosexual'] = 'Autosexual';

View file

@ -40,6 +40,7 @@ $gender
<div id="profile-edit-dob" >
$dob $age
</div>
</div>
<div id="profile-edit-dob-end"></div>
$hide_friends
@ -93,7 +94,7 @@ $hide_friends
<div class="profile-edit-submit-end"></div>
<div id="profile-edit-marital-wrapper" >
<label id="profile-edit-marital-label" for="profile-edit-marital" >Marital Status: </label>
<label id="profile-edit-marital-label" for="profile-edit-marital" ><span class="heart">&hearts;</span> (Marital) Status: </label>
$marital
</div>
<label id="profile-edit-with-label" for="profile-edit-with" > Who: (if applicable) </label>
@ -126,6 +127,13 @@ $sexual
</div>
<div id="profile-edit-religion-end"></div>
<div id="profile-edit-keywords-wrapper" >
<label id="profile-edit-keywords-label" for="profile-edit-keywords" >Keywords: </label>
<input type="text" size="32" name="keywords" id="profile-edit-keywords" title="Example: fishing photography software" value="$keywords" />
</div><div id="profile-edit-keywords-desc">(Used for searching public profiles, never shown to others)</div>
<div id="profile-edit-keywords-end"></div>
<div class="profile-edit-submit-wrapper" >
<input type="submit" name="submit" class="profile-edit-submit-button" value="Submit" />
</div>

View file

@ -54,15 +54,27 @@ $theme
</div>
<h3 class="settings-heading">Privacy Settings</h3>
<h3 class="settings-heading">Security and Privacy Settings</h3>
<input type="hidden" name="visibility" value="$visibility" />
<div id="settings-maxreq-wrapper">
<label id="settings-maxreq-label" for="settings-maxreq" >Maximum Friend Requests/Day</label>
<input id="settings-maxreq" name="maxreq" value="$maxreq" />
<div id="settings-maxreq-desc">(to prevent spam abuse)</div>
</div>
<div id="settings-maxreq-end"></div>
$profile_in_dir
$profile_in_net_dir
<div id="settings-default-perms" class="settings-default-perms" >
<div id="settings-default-perms-menu" class="fakelink" onClick="openClose('settings-default-perms-select');" >$permissions</div>
<div id="settings-default-perms-menu-end"></div>

View file

@ -496,6 +496,7 @@ input#dfrn-url {
#settings-password-end,
#settings-confirm-end,
#settings-openid-end,
#settings-maxreq-end,
#notify1-end,
#notify2-end,
#notify3-end,
@ -515,6 +516,7 @@ input#dfrn-url {
#settings-password-label,
#settings-confirm-label,
#settings-openid-label,
#settings-maxreq-label,
#settings-label-notify1,
#settings-label-notify2,
#settings-label-notify3,
@ -533,6 +535,7 @@ input#dfrn-url {
#theme-select,
#settings-password,
#settings-confirm,
#settings-maxreq,
#notify1,
#notify2,
#notify3,
@ -548,7 +551,10 @@ input#dfrn-url {
width: 127px;
}
#settings-maxreq-desc {
float: left;
margin-left: 20px;
}
#settings-theme-label,
#settings-defloc-label {
@ -720,6 +726,7 @@ input#dfrn-url {
#profile-edit-sexual-label,
#profile-edit-politic-label,
#profile-edit-religion-label,
#profile-edit-keywords-label,
#profile-edit-homepage-label {
float: left;
width: 175px;
@ -738,6 +745,7 @@ input#dfrn-url {
#sexual-select,
#profile-edit-politic,
#profile-edit-religion,
#profile-edit-keywords,
#profile-in-dir-yes,
#profile-in-dir-no,
#profile-in-netdir-yes,
@ -768,6 +776,12 @@ input#dfrn-url {
margin-left: 20px;
}
#profile-edit-keywords-desc {
float: left;
margin-left: 20px;
}
#profile-edit-homepage {
float: left;
margin-bottom: 35px;
@ -800,6 +814,7 @@ input#dfrn-url {
#profile-edit-sexual-end,
#profile-edit-politic-end,
#profile-edit-religion-end,
#profile-edit-keywords-end,
#profile-edit-homepage-end,
#profile-in-dir-break,
#profile-in-dir-end,