diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Module/Api.php | 16 | ||||
-rw-r--r-- | Zotlabs/Module/Import.php | 50 | ||||
-rw-r--r-- | Zotlabs/Module/Profiles.php | 6 |
3 files changed, 38 insertions, 34 deletions
diff --git a/Zotlabs/Module/Api.php b/Zotlabs/Module/Api.php index 4fd59acc4..0f2ca1e47 100644 --- a/Zotlabs/Module/Api.php +++ b/Zotlabs/Module/Api.php @@ -17,13 +17,13 @@ class Api extends \Zotlabs\Web\Controller { function get() { - if(\App::$cmd=='api/oauth/authorize'){ + if(\App::$cmd === 'api/oauth/authorize'){ /* * api/oauth/authorize interact with the user. return a standard page */ - \App::$page['template'] = "minimal"; + \App::$page['template'] = 'minimal'; // get consumer/client from request token try { @@ -42,8 +42,8 @@ class Api extends \Zotlabs\Web\Controller { $consumer = new OAuth1Consumer($app['client_id'], $app['pw'], $app['redirect_uri']); - $verifier = md5($app['secret'].local_channel()); - set_config("oauth", $verifier, local_channel()); + $verifier = md5($app['secret'] . local_channel()); + set_config('oauth', $verifier, local_channel()); if($consumer->callback_url != null) { @@ -78,11 +78,11 @@ class Api extends \Zotlabs\Web\Controller { $tpl = get_markup_template('oauth_authorize.tpl'); $o = replace_macros($tpl, array( - '$title' => t('Authorize application connection'), - '$app' => $app, + '$title' => t('Authorize application connection'), + '$app' => $app, '$authorize' => t('Do you want to authorize this application to access your posts and contacts, and/or create new posts for you?'), - '$yes' => t('Yes'), - '$no' => t('No'), + '$yes' => t('Yes'), + '$no' => t('No'), )); //echo "<pre>"; var_dump($app); killme(); diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 9574de07c..bf47f2e4c 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -77,23 +77,27 @@ class Import extends \Zotlabs\Web\Controller { $channelname = substr($old_address,0,strpos($old_address,'@')); $servername = substr($old_address,strpos($old_address,'@')+1); - - $scheme = 'https://'; - $api_path = '/api/red/channel/export/basic?f=&channel=' . $channelname; + + $api_path = probe_api_path($servername); + if(! $api_path) { + notice( t('Unable to download data from old server') . EOL); + return; + } + + $api_path .= 'channel/export/basic?f=&channel=' . $channelname; if($import_posts) $api_path .= '&posts=1'; $binary = false; $redirects = 0; $opts = array('http_auth' => $email . ':' . $password); - $url = $scheme . $servername . $api_path; - $ret = z_fetch_url($url, $binary, $redirects, $opts); - if(! $ret['success']) - $ret = z_fetch_url('http://' . $servername . $api_path, $binary, $redirects, $opts); - if($ret['success']) + $ret = z_fetch_url($api_path, $binary, $redirects, $opts); + if($ret['success']) { $data = $ret['body']; - else + } + else { notice( t('Unable to download data from old server') . EOL); - + return; + } } if(! $data) { @@ -297,9 +301,9 @@ class Import extends \Zotlabs\Web\Controller { dbesc_array($xchan); - $r = dbq("INSERT INTO xchan (`" - . implode("`, `", array_keys($xchan)) - . "`) VALUES ('" + $r = dbq("INSERT INTO xchan (" . TQUOT + . implode(TQUOT . ", " . TQUOT, array_keys($xchan)) + . TQUOT . ") VALUES ('" . implode("', '", array_values($xchan)) . "')" ); @@ -383,9 +387,9 @@ class Import extends \Zotlabs\Web\Controller { } dbesc_array($abook); - $r = dbq("INSERT INTO abook (`" - . implode("`, `", array_keys($abook)) - . "`) VALUES ('" + $r = dbq("INSERT INTO abook (" . TQUOT + . implode(TQUOT . ", " . TQUOT, array_keys($abook)) + . TQUOT . ") VALUES ('" . implode("', '", array_values($abook)) . "')" ); @@ -425,13 +429,13 @@ class Import extends \Zotlabs\Web\Controller { unset($group['id']); $group['uid'] = $channel['channel_id']; dbesc_array($group); - $r = dbq("INSERT INTO groups (`" - . implode("`, `", array_keys($group)) - . "`) VALUES ('" + $r = dbq("INSERT INTO groups (" . TQUOT + . implode(TQUOT . ", " . TQUOT, array_keys($group)) + . TQUOT . ") VALUES ('" . implode("', '", array_values($group)) . "')" ); } - $r = q("select * from `groups` where uid = %d", + $r = q("select * from groups where uid = %d", intval($channel['channel_id']) ); if($r) { @@ -452,9 +456,9 @@ class Import extends \Zotlabs\Web\Controller { $group_member['gid'] = $x['new']; } dbesc_array($group_member); - $r = dbq("INSERT INTO group_member (`" - . implode("`, `", array_keys($group_member)) - . "`) VALUES ('" + $r = dbq("INSERT INTO group_member (" . TQUOT + . implode(TQUOT . ", " . TQUOT, array_keys($group_member)) + . TQUOT . ") VALUES ('" . implode("', '", array_values($group_member)) . "')" ); } diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 4cb8e7395..6f76cd1cf 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -119,9 +119,9 @@ class Profiles extends \Zotlabs\Web\Controller { dbesc_array($r1[0]); - $r2 = dbq("INSERT INTO profile (`" - . implode("`, `", array_keys($r1[0])) - . "`) VALUES ('" + $r2 = dbq("INSERT INTO profile (" . TQUOT + . implode(TQUOT . ", " . TQUOT, array_keys($r1[0])) + . TQUOT . ") VALUES ('" . implode("', '", array_values($r1[0])) . "')" ); |