From: Hypolite Petovan Date: Sun, 30 Apr 2017 04:01:26 +0000 (-0400) Subject: Cleanup /format pre-move X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=56ee734b00aead633d5d213a6b140b75bc17ba96;p=friendica.git Cleanup /format pre-move --- diff --git a/boot.php b/boot.php index b689b73eec..afee3ac77d 100644 --- a/boot.php +++ b/boot.php @@ -19,7 +19,7 @@ require_once(__DIR__ . DIRECTORY_SEPARATOR. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'); -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once('include/config.php'); require_once('include/network.php'); diff --git a/include/Probe.php b/include/Probe.php index f67a821f9d..653e90b535 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -5,8 +5,8 @@ * */ -use \Friendica\Core\Config; -use \Friendica\Core\PConfig; +use Friendica\Core\Config; +use Friendica\Core\PConfig; require_once("include/feed.php"); require_once('include/email.php'); diff --git a/include/api.php b/include/api.php index 97c09c20a9..2e0409cb7a 100644 --- a/include/api.php +++ b/include/api.php @@ -6,7 +6,7 @@ * @todo Automatically detect if incoming data is HTML or BBCode */ -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once 'include/HTTPExceptions.php'; require_once 'include/bbcode.php'; diff --git a/include/auth.php b/include/auth.php index c1a6120dbb..76662d666c 100644 --- a/include/auth.php +++ b/include/auth.php @@ -1,6 +1,6 @@ gen_token(); $sec = $this->gen_token(); - + if ($consumer->key){ $k = $consumer->key; } else { $k = $consumer; } - + $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d)", dbesc($key), dbesc($sec), @@ -80,19 +80,19 @@ class FKOAuthDataStore extends OAuthDataStore { function new_access_token($token, $consumer, $verifier = null) { logger(__function__.":".$token.", ". $consumer.", ". $verifier); - + // return a new access token attached to this consumer // for the user associated with this token if the request token // is authorized // should also invalidate the request token - + $ret=Null; - + // get user for this verifier $uverifier = get_config("oauth", $verifier); logger(__function__.":".$verifier.",".$uverifier); if (is_null($verifier) || ($uverifier!==false)){ - + $key = $this->gen_token(); $sec = $this->gen_token(); $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d, %d)", @@ -103,13 +103,13 @@ class FKOAuthDataStore extends OAuthDataStore { intval(ACCESS_TOKEN_DURATION), intval($uverifier)); if ($r) - $ret = new OAuthToken($key,$sec); + $ret = new OAuthToken($key,$sec); } - - + + q("DELETE FROM tokens WHERE id='%s'", $token->key); - - + + if (!is_null($ret) && $uverifier!==false){ del_config("oauth", $verifier); /* $apps = get_pconfig($uverifier, "oauth", "apps"); @@ -117,9 +117,9 @@ class FKOAuthDataStore extends OAuthDataStore { $apps[] = $consumer->key; set_pconfig($uverifier, "oauth", "apps", $apps);*/ } - + return $ret; - + } } @@ -172,9 +172,9 @@ class FKOAuth1 extends OAuthServer { intval($_SESSION['uid']) ); - call_hooks('logged_in', $a->user); + call_hooks('logged_in', $a->user); } - + } /* class FKOAuth2 extends OAuth2 { @@ -190,13 +190,13 @@ class FKOAuth2 extends OAuth2 { dbesc($client_secret), dbesc($redirect_uri) ); - + return $r; } protected function checkClientCredentials($client_id, $client_secret = NULL) { $client_secret = $this->db_secret($client_secret); - + $r = q("SELECT pw FROM clients WHERE client_id = '%s'", dbesc($client_id)); @@ -218,21 +218,21 @@ class FKOAuth2 extends OAuth2 { protected function getAccessToken($oauth_token) { $r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'", dbesc($oauth_token)); - + if (dbm::is_result($r)) return $r[0]; return null; } - + protected function setAccessToken($oauth_token, $client_id, $expires, $scope = NULL) { $r = q("INSERT INTO tokens (id, client_id, expires, scope) VALUES ('%s', '%s', %d, '%s')", dbesc($oauth_token), dbesc($client_id), intval($expires), dbesc($scope)); - + return $r; } @@ -246,23 +246,23 @@ class FKOAuth2 extends OAuth2 { protected function getAuthCode($code) { $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'", dbesc($code)); - + if (dbm::is_result($r)) return $r[0]; return null; } protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) { - $r = q("INSERT INTO auth_codes - (id, client_id, redirect_uri, expires, scope) VALUES + $r = q("INSERT INTO auth_codes + (id, client_id, redirect_uri, expires, scope) VALUES ('%s', '%s', '%s', %d, '%s')", dbesc($code), dbesc($client_id), dbesc($redirect_uri), intval($expires), dbesc($scope)); - return $r; - } - + return $r; + } + } */ diff --git a/include/oembed.php b/include/oembed.php index 0b8b713667..564626317b 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -4,8 +4,8 @@ * @file include/oembed.php */ -use \Friendica\ParseUrl; -use \Friendica\Core\Config; +use Friendica\ParseUrl; +use Friendica\Core\Config; function oembed_replacecb($matches){ $embedurl=$matches[1]; diff --git a/include/plaintext.php b/include/plaintext.php index 6ab4ec77d6..246f7c31fa 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -4,7 +4,7 @@ * @file include/plaintext.php */ -use \Friendica\ParseUrl; +use Friendica\ParseUrl; require_once("include/Photo.php"); require_once("include/bbcode.php"); diff --git a/include/plugin.php b/include/plugin.php index 83f6f1ab95..f7423d7c69 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1,7 +1,7 @@ apps)==0) - notice( t('No installed applications.') . EOL); + $title = t('Applications'); + if (count($a->apps) == 0) { + notice(t('No installed applications.') . EOL); + } $tpl = get_markup_template("apps.tpl"); return replace_macros($tpl, array( '$title' => $title, '$apps' => $a->apps, )); - - - } diff --git a/mod/community.php b/mod/community.php index 45326e291d..6d318a539e 100644 --- a/mod/community.php +++ b/mod/community.php @@ -1,6 +1,6 @@ t('Credits'), - '$thanks' => t('Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!'), - '$names' => $arr, - )); + +function credits_content(App $a) { + /* fill the page with credits */ + $f = fopen('util/credits.txt', 'r'); + $names = fread($f, filesize('util/credits.txt')); + $arr = explode("\n", htmlspecialchars($names)); + fclose($f); + $tpl = get_markup_template('credits.tpl'); + return replace_macros($tpl, array( + '$title' => t('Credits'), + '$thanks' => t('Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!'), + '$names' => $arr, + )); } diff --git a/mod/delegate.php b/mod/delegate.php index 4212ec9b13..ade6737f62 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -5,7 +5,6 @@ function delegate_init(App $a) { return settings_init($a); } - function delegate_content(App $a) { if (! local_user()) { diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 506f9f162f..9a19cfc8d3 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -3,10 +3,7 @@ require_once('include/items.php'); require_once('include/auth.php'); require_once('include/dfrn.php'); - function dfrn_poll_init(App $a) { - - $dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : ''); $type = ((x($_GET,'type')) ? $_GET['type'] : 'data'); $last_update = ((x($_GET,'last_update')) ? $_GET['last_update'] : ''); diff --git a/mod/directory.php b/mod/directory.php index ba48bb3926..4f7af868d5 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -9,24 +9,18 @@ function directory_init(App $a) { $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); - } else { unset($_SESSION['theme']); unset($_SESSION['mobile-theme']); } - - } - function directory_post(App $a) { if(x($_POST,'search')) $a->data['search'] = $_POST['search']; } - - function directory_content(App $a) { global $db; diff --git a/mod/dirfind.php b/mod/dirfind.php index c5844d13df..a62eded39d 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -21,8 +21,6 @@ function dirfind_init(App $a) { $a->page['aside'] .= follow_widget(); } - - function dirfind_content(App $a, $prefix = "") { $community = false; diff --git a/mod/display.php b/mod/display.php index 1f1fd11204..c2b5ef17c0 100644 --- a/mod/display.php +++ b/mod/display.php @@ -106,7 +106,6 @@ function display_init(App $a) { } profile_load($a, $nick, 0, $profiledata); - } function display_fetchauthor($a, $item) { diff --git a/mod/filer.php b/mod/filer.php index 47c4aa5e4c..2f07cb6eee 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -4,7 +4,6 @@ require_once('include/security.php'); require_once('include/bbcode.php'); require_once('include/items.php'); - function filer_content(App $a) { if (! local_user()) { diff --git a/mod/friendica.php b/mod/friendica.php index 7bfb7c8691..f4d7aac105 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -1,6 +1,6 @@ argv[1] == "json"){ diff --git a/mod/hovercard.php b/mod/hovercard.php index 65b03f2b94..9deb071eb3 100644 --- a/mod/hovercard.php +++ b/mod/hovercard.php @@ -15,6 +15,7 @@ function hovercard_init(App $a) { // Just for testing purposes $_GET["mode"] = "minimal"; } + function hovercard_content() { $profileurl = (x($_REQUEST,'profileurl') ? $_REQUEST['profileurl'] : ""); $datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json"); diff --git a/mod/install.php b/mod/install.php index d1d2fd0779..0b96e85512 100755 --- a/mod/install.php +++ b/mod/install.php @@ -1,8 +1,8 @@ config['register_policy'] == REGISTER_CLOSED) ? false : true); - } diff --git a/mod/maintenance.php b/mod/maintenance.php index c4839de792..b1fb2a53e1 100644 --- a/mod/maintenance.php +++ b/mod/maintenance.php @@ -1,6 +1,6 @@ App::get_baseurl(), - '$touch_icon' => $touch_icon, - '$title' => Config::get('config', 'sitename', 'Friendica'), - )); + $touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png'); + if ($touch_icon == '') { + $touch_icon = 'images/friendica-128.png'; + } - echo $o; + $o = replace_macros($tpl, array( + '$baseurl' => App::get_baseurl(), + '$touch_icon' => $touch_icon, + '$title' => Config::get('config', 'sitename', 'Friendica'), + )); - killme(); + echo $o; - } -?> + killme(); +} diff --git a/mod/match.php b/mod/match.php index 44f5141ad8..77fcbaa72c 100644 --- a/mod/match.php +++ b/mod/match.php @@ -1,5 +1,5 @@ ' . t('Welcome to Friendica') . ''; - $o .= '

' . t('New Member Checklist') . '

'; - $o .= '
'; - $o .= t('We would like to offer some tips and links to help make your experience enjoyable. Click any item to visit the relevant page. A link to this page will be visible from your home page for two weeks after your initial registration and then will quietly disappear.'); - $o .= '

' . t('Getting Started') . '

'; - $o .= ''; - $o .= '

' . t('Settings') . '

'; - $o .= ''; - $o .= '

' . t('Profile') . '

'; - $o .= ''; - $o .= '

' . t('Connecting') . '

'; - $o .= ''; - $o .= '

' . t('Groups') . '

'; - $o .= ''; - $o .= '

' . t('Getting Help') . '

'; - $o .= ''; - $o .= '
'; return $o; diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 7f010cee41..384f4e8dd6 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -5,7 +5,7 @@ * Documentation: http://nodeinfo.diaspora.software/schema.html */ -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once 'include/plugin.php'; diff --git a/mod/notice.php b/mod/notice.php index b7029397b5..03f0e24037 100644 --- a/mod/notice.php +++ b/mod/notice.php @@ -1,20 +1,20 @@ friendica items permanent-url compatibility */ - function notice_init(App $a) { - $id = $a->argv[1]; - $r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d", - intval($id) - ); - if (dbm::is_result($r)){ - $nick = $r[0]['nickname']; - $url = App::get_baseurl()."/display/$nick/$id"; - goaway($url); - } else { - $a->error = 404; - notice( t('Item not found.') . EOL); +/* identi.ca -> friendica items permanent-url compatibility */ - } - return; +function notice_init(App $a) { + + $id = $a->argv[1]; + $r = q("SELECT `user`.`nickname` FROM `user` LEFT JOIN `item` ON `item`.`uid` = `user`.`uid` WHERE `item`.`id` = %d", intval($id)); + if (dbm::is_result($r)) { + $nick = $r[0]['nickname']; + $url = App::get_baseurl() . "/display/$nick/$id"; + goaway($url); + } else { + $a->error = 404; + notice(t('Item not found.') . EOL); } + + return; +} diff --git a/mod/openid.php b/mod/openid.php index 60de55a509..ac90806d0c 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -3,7 +3,6 @@ require_once('library/openid.php'); - function openid_content(App $a) { $noid = get_config('system','no_openid'); diff --git a/mod/opensearch.php b/mod/opensearch.php index a599ddc1ed..325d5f59bc 100644 --- a/mod/opensearch.php +++ b/mod/opensearch.php @@ -1,18 +1,18 @@ App::get_baseurl(), - '$nodename' => $a->get_hostname(), - )); + $tpl = get_markup_template('opensearch.tpl'); - echo $o; + header("Content-type: application/opensearchdescription+xml"); - killme(); + $o = replace_macros($tpl, array( + '$baseurl' => App::get_baseurl(), + '$nodename' => $a->get_hostname(), + )); - } -?> \ No newline at end of file + echo $o; + + killme(); +} diff --git a/mod/parse_url.php b/mod/parse_url.php index 77529714f2..b2908455b7 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -10,7 +10,7 @@ * @see ParseUrl::getSiteinfo() for more information about scraping embeddable content */ -use \Friendica\ParseUrl; +use Friendica\ParseUrl; require_once("include/items.php"); diff --git a/mod/photos.php b/mod/photos.php index a22f919c89..67a8735a59 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1,4 +1,7 @@ argc > 1) { diff --git a/mod/ping.php b/mod/ping.php index dcef73ffb2..fa3c8ebcd9 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -1,5 +1,5 @@ get_theme_screenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits)); } + killme(); } diff --git a/mod/probe.php b/mod/probe.php index 8c951a7fcf..73630ded7d 100644 --- a/mod/probe.php +++ b/mod/probe.php @@ -5,27 +5,26 @@ require_once('include/Scrape.php'); function probe_content(App $a) { if (!local_user()) { - http_status_exit(403, - array("title" => t("Public access denied."), - "description" => t("Only logged in users are permitted to perform a probing."))); + http_status_exit(403, array("title" => t("Public access denied."), + "description" => t("Only logged in users are permitted to perform a probing."))); killme(); } $o .= '

Probe Diagnostic

'; $o .= '
'; - $o .= 'Lookup address: '; + $o .= 'Lookup address: '; $o .= '
'; $o .= '

'; - if(x($_GET,'addr')) { - + if (x($_GET, 'addr')) { $addr = trim($_GET['addr']); $res = probe_url($addr); $o .= '
';
-		$o .= str_replace("\n",'
',print_r($res,true)); + $o .= str_replace("\n", '
', print_r($res, true)); $o .= '
'; } + return $o; } diff --git a/mod/profile.php b/mod/profile.php index 838a550944..05f18c3627 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -3,7 +3,6 @@ require_once('include/contact_widgets.php'); require_once('include/redir.php'); - function profile_init(App $a) { if(! x($a->page,'aside')) diff --git a/mod/profile_photo.php b/mod/profile_photo.php index f9bf60cf54..8b3d3d371e 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -9,10 +9,8 @@ function profile_photo_init(App $a) { } profile_load($a,$a->user['nickname']); - } - function profile_photo_post(App $a) { if (! local_user()) { diff --git a/mod/qsearch.php b/mod/qsearch.php index 8512bea51e..76ff2a15e0 100644 --- a/mod/qsearch.php +++ b/mod/qsearch.php @@ -48,4 +48,3 @@ function qsearch_init(App $a) { echo json_encode((object) $results); killme(); } - diff --git a/mod/receive.php b/mod/receive.php index 3563f2d705..547e089672 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -9,10 +9,8 @@ require_once('include/salmon.php'); require_once('include/crypto.php'); require_once('include/diaspora.php'); - function receive_post(App $a) { - $enabled = intval(get_config('system','diaspora_enabled')); if(! $enabled) { logger('mod-diaspora: disabled'); diff --git a/mod/robots_txt.php b/mod/robots_txt.php index d150ff3de6..b839d6a03c 100644 --- a/mod/robots_txt.php +++ b/mod/robots_txt.php @@ -1,4 +1,5 @@ - - - Friendica - http://friendica.com/ - - - - http://status.net/wiki/TwitterCompatibleAPI - false - - - - - - '; -die(); + + + Friendica + http://friendica.com/ + + + + http://status.net/wiki/TwitterCompatibleAPI + false + + + + +'; + + killme(); } \ No newline at end of file diff --git a/mod/smilies.php b/mod/smilies.php index 4d8ab6bcaa..f69541824a 100644 --- a/mod/smilies.php +++ b/mod/smilies.php @@ -7,15 +7,14 @@ require_once("include/Smilies.php"); function smilies_content(App $a) { - if ($a->argv[1]==="json"){ + if ($a->argv[1] === "json") { $tmp = Smilies::get_list(); $results = array(); - for($i = 0; $i < count($tmp['texts']); $i++) { + for ($i = 0; $i < count($tmp['texts']); $i++) { $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); } json_return_and_die($results); - } - else { - return Smilies::replace('',true); + } else { + return Smilies::replace('', true); } } diff --git a/mod/statistics_json.php b/mod/statistics_json.php index 07444d2bb5..5cb6fb99e9 100644 --- a/mod/statistics_json.php +++ b/mod/statistics_json.php @@ -1,4 +1,5 @@ $a->config["sitename"], - "network" => FRIENDICA_PLATFORM, - "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION, - "registrations_open" => ($a->config['register_policy'] != 0), - "total_users" => get_config('nodeinfo','total_users'), - "active_users_halfyear" => get_config('nodeinfo','active_users_halfyear'), - "active_users_monthly" => get_config('nodeinfo','active_users_monthly'), - "local_posts" => get_config('nodeinfo','local_posts') - ); + "name" => $a->config["sitename"], + "network" => FRIENDICA_PLATFORM, + "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION, + "registrations_open" => ($a->config['register_policy'] != 0), + "total_users" => get_config('nodeinfo', 'total_users'), + "active_users_halfyear" => get_config('nodeinfo', 'active_users_halfyear'), + "active_users_monthly" => get_config('nodeinfo', 'active_users_monthly'), + "local_posts" => get_config('nodeinfo', 'local_posts') + ); $statistics["services"] = array(); $statistics["services"]["appnet"] = plugin_enabled("appnet"); @@ -53,7 +54,7 @@ function statistics_json_init(App $a) { $statistics["wordpress"] = $statistics["services"]["wordpress"]; header("Content-Type: application/json"); - echo json_encode($statistics, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); - logger("statistics_init: printed ".print_r($statistics, true), LOGGER_DATA); + echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + logger("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA); killme(); } diff --git a/mod/subthread.php b/mod/subthread.php index 646a4230c5..9d5533a03d 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -4,7 +4,6 @@ require_once('include/security.php'); require_once('include/bbcode.php'); require_once('include/items.php'); - function subthread_content(App $a) { if(! local_user() && ! remote_user()) { diff --git a/mod/tagger.php b/mod/tagger.php index 50099ac69c..8a6973e6ad 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -4,7 +4,6 @@ require_once('include/security.php'); require_once('include/bbcode.php'); require_once('include/items.php'); - function tagger_content(App $a) { if(! local_user() && ! remote_user()) { diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php index f858d8913e..51fdcf41a0 100644 --- a/mod/toggle_mobile.php +++ b/mod/toggle_mobile.php @@ -16,4 +16,3 @@ function toggle_mobile_init(App $a) { goaway($address); } - diff --git a/mod/uexport.php b/mod/uexport.php index 77a45f8a39..554c02225b 100644 --- a/mod/uexport.php +++ b/mod/uexport.php @@ -1,7 +1,7 @@ argc > 1) { header("Content-type: application/json"); - header('Content-Disposition: attachment; filename="'.$a->user['nickname'].'.'.$a->argv[1].'"'); - switch($a->argv[1]) { + header('Content-Disposition: attachment; filename="' . $a->user['nickname'] . '.' . $a->argv[1] . '"'); + switch ($a->argv[1]) { case "backup": uexport_all($a); killme(); @@ -51,9 +51,9 @@ function _uexport_multirow($query) { $result = array(); $r = q($query); if (dbm::is_result($r)) { - foreach($r as $rr){ + foreach ($r as $rr) { $p = array(); - foreach($rr as $k => $v) { + foreach ($rr as $k => $v) { $p[$k] = $v; } $result[] = $p; @@ -66,8 +66,8 @@ function _uexport_row($query) { $result = array(); $r = q($query); if (dbm::is_result($r)) { - foreach($r as $rr) { - foreach($rr as $k => $v) { + foreach ($r as $rr) { + foreach ($rr as $k => $v) { $result[$k] = $v; } } @@ -75,39 +75,38 @@ function _uexport_row($query) { return $result; } - -function uexport_account($a){ +function uexport_account($a) { $user = _uexport_row( - sprintf( "SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user()) ) + sprintf("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user())) ); $contact = _uexport_multirow( - sprintf( "SELECT * FROM `contact` WHERE `uid` = %d ",intval(local_user()) ) + sprintf("SELECT * FROM `contact` WHERE `uid` = %d ", intval(local_user())) ); - $profile =_uexport_multirow( - sprintf( "SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user()) ) + $profile = _uexport_multirow( + sprintf("SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user())) ); $photo = _uexport_multirow( - sprintf( "SELECT * FROM `photo` WHERE uid = %d AND profile = 1", intval(local_user()) ) + sprintf("SELECT * FROM `photo` WHERE uid = %d AND profile = 1", intval(local_user())) ); foreach ($photo as &$p) { $p['data'] = bin2hex($p['data']); } $pconfig = _uexport_multirow( - sprintf( "SELECT * FROM `pconfig` WHERE uid = %d",intval(local_user()) ) + sprintf("SELECT * FROM `pconfig` WHERE uid = %d", intval(local_user())) ); $group = _uexport_multirow( - sprintf( "SELECT * FROM `group` WHERE uid = %d",intval(local_user()) ) + sprintf("SELECT * FROM `group` WHERE uid = %d", intval(local_user())) ); $group_member = _uexport_multirow( - sprintf( "SELECT * FROM `group_member` WHERE uid = %d",intval(local_user()) ) + sprintf("SELECT * FROM `group_member` WHERE uid = %d", intval(local_user())) ); $output = array( @@ -150,13 +149,13 @@ function uexport_all(App $a) { intval($x), intval(500) ); - /*if (dbm::is_result($r)) { - foreach($r as $rr) - foreach($rr as $k => $v) - $item[][$k] = $v; - }*/ + /* if (dbm::is_result($r)) { + foreach($r as $rr) + foreach($rr as $k => $v) + $item[][$k] = $v; + } */ $output = array('item' => $r); - echo json_encode($output)."\n"; + echo json_encode($output) . "\n"; } } diff --git a/mod/uimport.php b/mod/uimport.php index 336ec1c2dd..fd44df4fbc 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -1,35 +1,35 @@ config['register_policy']) { - case REGISTER_OPEN: - $blocked = 0; - $verified = 1; - break; + switch ($a->config['register_policy']) { + case REGISTER_OPEN: + $blocked = 0; + $verified = 1; + break; - case REGISTER_APPROVE: - $blocked = 1; - $verified = 0; - break; + case REGISTER_APPROVE: + $blocked = 1; + $verified = 0; + break; - default: - case REGISTER_CLOSED: - if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) { - notice( t('Permission denied.') . EOL ); - return; - } - $blocked = 1; - $verified = 0; - break; + default: + case REGISTER_CLOSED: + if ((!x($_SESSION, 'authenticated') && (!x($_SESSION, 'administrator')))) { + notice(t('Permission denied.') . EOL); + return; + } + $blocked = 1; + $verified = 0; + break; } - if (x($_FILES,'accountfile')){ + if (x($_FILES, 'accountfile')) { /// @TODO Pass $blocked / $verified, send email to admin on REGISTER_APPROVE import_account($a, $_FILES['accountfile']); return; @@ -38,26 +38,26 @@ function uimport_post(App $a) { function uimport_content(App $a) { - if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) { + if ((!local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) { notice("Permission denied." . EOL); return; } - $max_dailies = intval(get_config('system','max_daily_registrations')); + $max_dailies = intval(get_config('system', 'max_daily_registrations')); if ($max_dailies) { $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); if ($r && $r[0]['total'] >= $max_dailies) { logger('max daily registrations exceeded.'); - notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); + notice(t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); return; } } - if (x($_SESSION,'theme')) { + if (x($_SESSION, 'theme')) { unset($_SESSION['theme']); } - if (x($_SESSION,'mobile-theme')) { + if (x($_SESSION, 'mobile-theme')) { unset($_SESSION['mobile-theme']); } @@ -65,11 +65,11 @@ function uimport_content(App $a) { return replace_macros($tpl, array( '$regbutt' => t('Import'), '$import' => array( - 'title' => t("Move account"), - 'intro' => t("You can import an account from another Friendica server."), - 'instruct' => t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."), - 'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"), - 'field' => array('accountfile', t('Account file'),'', t('To export your account, go to "Settings->Export your personal data" and select "Export account"')), + 'title' => t("Move account"), + 'intro' => t("You can import an account from another Friendica server."), + 'instruct' => t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."), + 'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"), + 'field' => array('accountfile', t('Account file'), '', t('To export your account, go to "Settings->Export your personal data" and select "Export account"')), ), )); } diff --git a/mod/videos.php b/mod/videos.php index 269d537854..e8f8356fbd 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -5,7 +5,6 @@ require_once('include/bbcode.php'); require_once('include/security.php'); require_once('include/redir.php'); - function videos_init(App $a) { if($a->argc > 1) diff --git a/mod/wall_upload.php b/mod/wall_upload.php index d29efecc6a..1707040e6c 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -3,17 +3,16 @@ /** * @file mod/wall_upload.php * @brief Module for uploading a picture to the profile wall - * + * * By default the picture will be stored in the photo album with the name Wall Photos. * You can specify a different album by adding an optional query string "album=" * to the url */ -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once 'include/Photo.php'; - function wall_upload_post(App $a, $desktopmode = true) { logger("wall upload: starting new upload", LOGGER_DEBUG); diff --git a/util/db_update.php b/util/db_update.php index 32b44e6d00..3e3a89840a 100644 --- a/util/db_update.php +++ b/util/db_update.php @@ -3,7 +3,7 @@ * @package util */ -/* +/* * require boot.php */ require_once("boot.php"); diff --git a/util/maintenance.php b/util/maintenance.php index 614344ab93..b0728245c6 100644 --- a/util/maintenance.php +++ b/util/maintenance.php @@ -1,6 +1,6 @@ - * - * Output to - */ - - DEFINE("NORM_REGEXP", "|[\\\]|"); - - - if(! class_exists('App')) { - class TmpA { - public $strings = Array(); - } - $a = new TmpA(); - } +/** + * Read strings.php file and create messages.po + * + * php utils/php2po.php + * + * Output to + */ - if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) { - print "Usage: ".$argv[0]." [-p ] \n\n"; - print "Options:\n"; - print "p\tNumber of plural forms. Default: 2\n"; - print "\n"; - return; - } - $phpfile = $argv[1]; - $pofile = dirname($phpfile)."/messages.po"; +DEFINE("NORM_REGEXP", "|[\\\]|"); - if (!file_exists($phpfile)){ - print "Unable to find '$phpfile'\n"; - return; +if(! class_exists('App')) { + class TmpA { + public $strings = Array(); } + $a = new TmpA(); +} - // utility functions - function startsWith($haystack, $needle) { - // search backwards starting from haystack length characters from the end - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; - } +if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) { + print "Usage: ".$argv[0]." [-p ] \n\n"; + print "Options:\n"; + print "p\tNumber of plural forms. Default: 2\n"; + print "\n"; + return; +} + +$phpfile = $argv[1]; +$pofile = dirname($phpfile)."/messages.po"; + +if (!file_exists($phpfile)){ + print "Unable to find '$phpfile'\n"; + return; +} +// utility functions +function startsWith($haystack, $needle) { + // search backwards starting from haystack length characters from the end + return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; +} - // start ! - include_once($phpfile); - - $out = ''; - $out .= "# FRIENDICA Distributed Social Network\n"; - $out .= "# Copyright (C) 2010, 2011, 2012, 2013 the Friendica Project\n"; - $out .= "# This file is distributed under the same license as the Friendica package.\n"; - $out .= "# \n"; - $out .= 'msgid ""' ."\n"; - $out .= 'msgstr ""' ."\n"; - $out .= '"Project-Id-Version: friendica\n"' ."\n"; - $out .= '"Report-Msgid-Bugs-To: \n"' ."\n"; - $out .= '"POT-Creation-Date: '. date("Y-m-d H:i:sO").'\n"' ."\n"; - $out .= '"MIME-Version: 1.0\n"' ."\n"; - $out .= '"Content-Type: text/plain; charset=UTF-8\n"' ."\n"; - $out .= '"Content-Transfer-Encoding: 8bit\n"' ."\n"; - - // search for plural info - $lang = ""; - $lang_logic = ""; - $lang_pnum = 2; - - $_idx = array_search('-p', $argv); - if ($_idx !== false) { - $lang_pnum = $argv[$_idx+1]; + +// start ! +include_once($phpfile); + +$out = ''; +$out .= "# FRIENDICA Distributed Social Network\n"; +$out .= "# Copyright (C) 2010, 2011, 2012, 2013 the Friendica Project\n"; +$out .= "# This file is distributed under the same license as the Friendica package.\n"; +$out .= "# \n"; +$out .= 'msgid ""' ."\n"; +$out .= 'msgstr ""' ."\n"; +$out .= '"Project-Id-Version: friendica\n"' ."\n"; +$out .= '"Report-Msgid-Bugs-To: \n"' ."\n"; +$out .= '"POT-Creation-Date: '. date("Y-m-d H:i:sO").'\n"' ."\n"; +$out .= '"MIME-Version: 1.0\n"' ."\n"; +$out .= '"Content-Type: text/plain; charset=UTF-8\n"' ."\n"; +$out .= '"Content-Transfer-Encoding: 8bit\n"' ."\n"; + +// search for plural info +$lang = ""; +$lang_logic = ""; +$lang_pnum = 2; + +$_idx = array_search('-p', $argv); +if ($_idx !== false) { + $lang_pnum = $argv[$_idx+1]; +} + +$infile = file($phpfile); +foreach($infile as $l) { + $l = trim($l); + if (startsWith($l, 'function string_plural_select_')) { + $lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) ); } - - $infile = file($phpfile); - foreach($infile as $l) { - $l = trim($l); - if (startsWith($l, 'function string_plural_select_')) { - $lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) ); - } - if (startsWith($l, 'return')) { - $lang_logic = str_replace( '$', '', trim( str_replace( 'return ' , '', $l) , ';') ); - break; - } + if (startsWith($l, 'return')) { + $lang_logic = str_replace( '$', '', trim( str_replace( 'return ' , '', $l) , ';') ); + break; } - - echo "Language: $lang\n"; - echo "Plural forms: $lang_pnum\n"; - echo "Plural logic: $lang_logic;\n"; - - $out .= sprintf('"Language: %s\n"', $lang) ."\n"; - $out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic) ."\n"; - $out .= "\n"; +} - print "\nLoading base message.po..."; - - // load base messages.po and extract msgids - $base_msgids = array(); - $norm_base_msgids = array(); - $base_f = file("util/messages.po") or die("No base messages.po\n"); - $_f = 0; $_mid = ""; $_mids = array(); - foreach( $base_f as $l) { - $l = trim($l); - //~ print $l."\n"; - - if (startsWith($l, 'msgstr')) { - if ($_mid != '""') { - $base_msgids[$_mid] = $_mids; - $norm_base_msgids[preg_replace(NORM_REGEXP, "", $_mid)] = $_mid; - //~ print "\t\t\t".$_mid. print_r($base_msgids[$_mid], true); - } - - $_f = 0; - $_mid = ""; - $_mids = array(); - - } - - if (startsWith($l, '"') && $_f==2) { - $_mids[count($_mids)-1] .= "\n".$l; - //~ print "\t\t+mids: ".print_t($_mids, true); - } - if (startsWith($l, 'msgid_plural ')) { - $_f = 2; - $_mids[] = str_replace('msgid_plural ', '' , $l); - //~ print "\t\t mids: ".print_r($_mids, true); - } - - if (startsWith($l, '"') && $_f==1) { - $_mid .= "\n".$l; - $_mids[count($_mids)-1] .= "\n".$l; - //~ print "\t+mid: $_mid \n"; - } - if (startsWith($l, 'msgid ')) { - $_f = 1; - $_mid = str_replace('msgid ', '' , $l); - $_mids = array($_mid); - //~ print "\t mid: $_mid \n"; +echo "Language: $lang\n"; +echo "Plural forms: $lang_pnum\n"; +echo "Plural logic: $lang_logic;\n"; + +$out .= sprintf('"Language: %s\n"', $lang) ."\n"; +$out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic) ."\n"; +$out .= "\n"; + +print "\nLoading base message.po..."; + +// load base messages.po and extract msgids +$base_msgids = array(); +$norm_base_msgids = array(); +$base_f = file("util/messages.po") or die("No base messages.po\n"); +$_f = 0; $_mid = ""; $_mids = array(); +foreach( $base_f as $l) { + $l = trim($l); + //~ print $l."\n"; + + if (startsWith($l, 'msgstr')) { + if ($_mid != '""') { + $base_msgids[$_mid] = $_mids; + $norm_base_msgids[preg_replace(NORM_REGEXP, "", $_mid)] = $_mid; + //~ print "\t\t\t".$_mid. print_r($base_msgids[$_mid], true); } - //~ print "\t\t\t\t$_f\n\n"; + + $_f = 0; + $_mid = ""; + $_mids = array(); + } - - print " done\n"; - print "Creating '$pofile'..."; - // create msgid and msgstr - - /** - * Get a string and retun a message.po ready text - * - replace " with \" - * - replace tab char with \t - * - manage multiline strings - */ - function massage_string($str) { - $str = str_replace('\\','\\\\',$str); - $str = str_replace('"','\"',$str); - $str = str_replace("\t",'\t',$str); - $str = str_replace("\n",'\n"'."\n".'"',$str); - if (strpos($str, "\n")!==false && $str[0]!=='"') $str = '"'."\n".$str; - $str = preg_replace("|\n([^\"])|", "\n\"$1", $str); - return sprintf('"%s"', $str); + + if (startsWith($l, '"') && $_f==2) { + $_mids[count($_mids)-1] .= "\n".$l; + //~ print "\t\t+mids: ".print_t($_mids, true); } - - function find_original_msgid($str) { - global $norm_base_msgids; - $norm_str = preg_replace(NORM_REGEXP, "", $str); - if (array_key_exists($norm_str, $norm_base_msgids)) { - return $norm_base_msgids[$norm_str]; - } - return $str; + if (startsWith($l, 'msgid_plural ')) { + $_f = 2; + $_mids[] = str_replace('msgid_plural ', '' , $l); + //~ print "\t\t mids: ".print_r($_mids, true); } - - $warnings = ""; - foreach($a->strings as $key=>$str) { - $msgid = massage_string($key); - - if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) { - $out .= "#, php-format\n"; - } - $msgid = find_original_msgid($msgid); - $out .= 'msgid '. $msgid . "\n"; - - if (is_array($str)) { - if (array_key_exists($msgid, $base_msgids) && isset($base_msgids[$msgid][1])) { - $out .= 'msgid_plural '. $base_msgids[$msgid][1] . "\n"; - } else { - $out .= 'msgid_plural '. $msgid . "\n"; - $warnings .= "[W] No source plural form for msgid:\n". str_replace("\n","\n\t", $msgid) . "\n\n"; - } - foreach ( $str as $n => $msgstr) { - $out .= 'msgstr['.$n.'] '. massage_string($msgstr) . "\n"; - } - } else { - $out .= 'msgstr '. massage_string($str) . "\n"; - } - - $out .= "\n"; - + + if (startsWith($l, '"') && $_f==1) { + $_mid .= "\n".$l; + $_mids[count($_mids)-1] .= "\n".$l; + //~ print "\t+mid: $_mid \n"; } + if (startsWith($l, 'msgid ')) { + $_f = 1; + $_mid = str_replace('msgid ', '' , $l); + $_mids = array($_mid); + //~ print "\t mid: $_mid \n"; + } + //~ print "\t\t\t\t$_f\n\n"; +} + +print " done\n"; +print "Creating '$pofile'..."; +// create msgid and msgstr + +/** + * Get a string and retun a message.po ready text + * - replace " with \" + * - replace tab char with \t + * - manage multiline strings + */ +function massage_string($str) { + $str = str_replace('\\','\\\\',$str); + $str = str_replace('"','\"',$str); + $str = str_replace("\t",'\t',$str); + $str = str_replace("\n",'\n"'."\n".'"',$str); + if (strpos($str, "\n")!==false && $str[0]!=='"') $str = '"'."\n".$str; + $str = preg_replace("|\n([^\"])|", "\n\"$1", $str); + return sprintf('"%s"', $str); +} + +function find_original_msgid($str) { + global $norm_base_msgids; + $norm_str = preg_replace(NORM_REGEXP, "", $str); + if (array_key_exists($norm_str, $norm_base_msgids)) { + return $norm_base_msgids[$norm_str]; + } + return $str; +} + +$warnings = ""; +foreach($a->strings as $key=>$str) { + $msgid = massage_string($key); - file_put_contents($pofile, $out); - - print " done\n"; - - if ($warnings=="") { - print "No warnings.\n"; + if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) { + $out .= "#, php-format\n"; + } + $msgid = find_original_msgid($msgid); + $out .= 'msgid '. $msgid . "\n"; + + if (is_array($str)) { + if (array_key_exists($msgid, $base_msgids) && isset($base_msgids[$msgid][1])) { + $out .= 'msgid_plural '. $base_msgids[$msgid][1] . "\n"; + } else { + $out .= 'msgid_plural '. $msgid . "\n"; + $warnings .= "[W] No source plural form for msgid:\n". str_replace("\n","\n\t", $msgid) . "\n\n"; + } + foreach ( $str as $n => $msgstr) { + $out .= 'msgstr['.$n.'] '. massage_string($msgstr) . "\n"; + } } else { - print $warnings; + $out .= 'msgstr '. massage_string($str) . "\n"; } - + + $out .= "\n"; + +} + +file_put_contents($pofile, $out); + +print " done\n"; + +if ($warnings=="") { + print "No warnings.\n"; +} else { + print $warnings; +} diff --git a/util/typo.php b/util/typo.php index d68ac2ac9b..cc05be4ccd 100644 --- a/util/typo.php +++ b/util/typo.php @@ -1,59 +1,59 @@ config,'php_path')) - $phpath = $a->config['php_path']; - else - $phpath = 'php'; +if(x($a->config,'php_path')) + $phpath = $a->config['php_path']; +else + $phpath = 'php'; - echo "Directory: mod\n"; - $files = glob('mod/*.php'); - foreach($files as $file) { - passthru("$phpath -l $file", $ret); $ret===0 or die(); - } +echo "Directory: mod\n"; +$files = glob('mod/*.php'); +foreach($files as $file) { + passthru("$phpath -l $file", $ret); $ret===0 or die(); +} - echo "Directory: include\n"; - $files = glob('include/*.php'); - foreach($files as $file) { - passthru("$phpath -l $file", $ret); $ret===0 or die(); - } +echo "Directory: include\n"; +$files = glob('include/*.php'); +foreach($files as $file) { + passthru("$phpath -l $file", $ret); $ret===0 or die(); +} - echo "Directory: object\n"; - $files = glob('object/*.php'); - foreach($files as $file) { - passthru("$phpath -l $file", $ret); $ret===0 or die(); - } +echo "Directory: object\n"; +$files = glob('object/*.php'); +foreach($files as $file) { + passthru("$phpath -l $file", $ret); $ret===0 or die(); +} - echo "Directory: addon\n"; - $dirs = glob('addon/*'); +echo "Directory: addon\n"; +$dirs = glob('addon/*'); - foreach($dirs as $dir) { - $addon = basename($dir); - $files = glob($dir . '/' . $addon . '.php'); - foreach($files as $file) { - passthru("$phpath -l $file", $ret); $ret===0 or die(); - } +foreach($dirs as $dir) { + $addon = basename($dir); + $files = glob($dir . '/' . $addon . '.php'); + foreach($files as $file) { + passthru("$phpath -l $file", $ret); $ret===0 or die(); } +} - echo "String files\n"; +echo "String files\n"; - echo 'util/strings.php' . "\n"; - passthru("$phpath -l util/strings.php", $ret); $ret===0 or die(); +echo 'util/strings.php' . "\n"; +passthru("$phpath -l util/strings.php", $ret); $ret===0 or die(); - $files = glob('view/lang/*/strings.php'); - foreach($files as $file) { - passthru("$phpath -l $file", $ret); $ret===0 or die(); - } +$files = glob('view/lang/*/strings.php'); +foreach($files as $file) { + passthru("$phpath -l $file", $ret); $ret===0 or die(); +} diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php index 381b067167..6b111d6ad4 100644 --- a/view/theme/duepuntozero/config.php +++ b/view/theme/duepuntozero/config.php @@ -1,4 +1,5 @@ var frio=""; - page['htmlhead'] .= <<< EOT + $a->page['htmlhead'] .= <<< EOT EOT; - /** custom css **/ + /** custom css **/ if (!is_null($cssFile)) { $a->page['htmlhead'] .= sprintf('', $cssFile); } -_js_in_foot(); - + _js_in_foot(); } if (! function_exists('_js_in_foot')) {