aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-31 17:50:47 -0700
committerredmatrix <git@macgirvin.com>2016-05-31 17:50:47 -0700
commitdfb6255f59980835d364402b372dd39f2b41ee7c (patch)
treef8d97437d713311a9cd3cf13e0e8faa5b617fa8f
parent00b4843425371e4ff55c82be577a279e248c29fc (diff)
downloadvolse-hubzilla-dfb6255f59980835d364402b372dd39f2b41ee7c.tar.gz
volse-hubzilla-dfb6255f59980835d364402b372dd39f2b41ee7c.tar.bz2
volse-hubzilla-dfb6255f59980835d364402b372dd39f2b41ee7c.zip
more removal of reserved words from DB schemas
-rw-r--r--Zotlabs/Module/Api.php2
-rw-r--r--Zotlabs/Module/Settings.php6
-rw-r--r--Zotlabs/Web/SessionHandler.php6
-rw-r--r--Zotlabs/Zot/Verify.php6
-rwxr-xr-xboot.php2
-rw-r--r--include/account.php6
-rw-r--r--include/api.php2
-rw-r--r--include/oauth.php12
-rw-r--r--install/schema_mysql.sql14
-rw-r--r--install/schema_postgres.sql14
-rw-r--r--install/update.php19
-rwxr-xr-xview/tpl/settings_oauth.tpl2
12 files changed, 54 insertions, 37 deletions
diff --git a/Zotlabs/Module/Api.php b/Zotlabs/Module/Api.php
index 3e7f23b6c..e4744c29f 100644
--- a/Zotlabs/Module/Api.php
+++ b/Zotlabs/Module/Api.php
@@ -107,7 +107,7 @@ class Api extends \Zotlabs\Web\Controller {
$r = q("SELECT `clients`.*
FROM `clients`, `tokens`
WHERE `clients`.`client_id`=`tokens`.`client_id`
- AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'",
+ AND `tokens`.`id`='%s' AND `tokens`.`auth_scope`='request'",
dbesc($token));
if (!count($r))
diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php
index 5687ce84b..43162a2b0 100644
--- a/Zotlabs/Module/Settings.php
+++ b/Zotlabs/Module/Settings.php
@@ -78,7 +78,7 @@ class Settings extends \Zotlabs\Web\Controller {
$r = q("UPDATE clients SET
client_id='%s',
pw='%s',
- name='%s',
+ clname='%s',
redirect_uri='%s',
icon='%s',
uid=%d
@@ -91,7 +91,7 @@ class Settings extends \Zotlabs\Web\Controller {
intval(local_channel()),
dbesc($key));
} else {
- $r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid)
+ $r = q("INSERT INTO clients (client_id, pw, clname, redirect_uri, icon, uid)
VALUES ('%s','%s','%s','%s','%s',%d)",
dbesc($key),
dbesc($secret),
@@ -615,7 +615,7 @@ class Settings extends \Zotlabs\Web\Controller {
'$title' => t('Add application'),
'$submit' => t('Update'),
'$cancel' => t('Cancel'),
- '$name' => array('name', t('Name'), $app['name'] , ''),
+ '$name' => array('name', t('Name'), $app['clname'] , ''),
'$key' => array('key', t('Consumer Key'), $app['client_id'], ''),
'$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''),
'$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''),
diff --git a/Zotlabs/Web/SessionHandler.php b/Zotlabs/Web/SessionHandler.php
index 6980a6408..6e7333b4b 100644
--- a/Zotlabs/Web/SessionHandler.php
+++ b/Zotlabs/Web/SessionHandler.php
@@ -18,10 +18,10 @@ class SessionHandler implements \SessionHandlerInterface {
function read ($id) {
if($id) {
- $r = q("SELECT `data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
+ $r = q("SELECT `sess_data` FROM `session` WHERE `sid`= '%s'", dbesc($id));
if($r) {
- return $r[0]['data'];
+ return $r[0]['sess_data'];
}
else {
q("INSERT INTO `session` (sid, expire) values ('%s', '%s')",
@@ -59,7 +59,7 @@ class SessionHandler implements \SessionHandlerInterface {
}
q("UPDATE `session`
- SET `data` = '%s', `expire` = '%s' WHERE `sid` = '%s'",
+ SET `sess_data` = '%s', `expire` = '%s' WHERE `sid` = '%s'",
dbesc($data),
dbesc($expire),
dbesc($id)
diff --git a/Zotlabs/Zot/Verify.php b/Zotlabs/Zot/Verify.php
index 1192202db..06bd3188c 100644
--- a/Zotlabs/Zot/Verify.php
+++ b/Zotlabs/Zot/Verify.php
@@ -6,7 +6,7 @@ namespace Zotlabs\Zot;
class Verify {
function create($type,$channel_id,$token,$meta) {
- return q("insert into verify ( type, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )",
+ return q("insert into verify ( vtype, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )",
dbesc($type),
intval($channel_id),
dbesc($token),
@@ -16,7 +16,7 @@ class Verify {
}
function match($type,$channel_id,$token,$meta) {
- $r = q("select id from verify where type = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1",
+ $r = q("select id from verify where vtype = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1",
dbesc($type),
intval($channel_id),
dbesc($token),
@@ -32,7 +32,7 @@ class Verify {
}
function purge($type,$interval) {
- q("delete from verify where type = '%s' and created < %s - INTERVAL %s",
+ q("delete from verify where vtype = '%s' and created < %s - INTERVAL %s",
dbesc($type),
db_utcnow(),
db_quoteinterval($interval)
diff --git a/boot.php b/boot.php
index 4ea2dc279..24ff3c5d1 100755
--- a/boot.php
+++ b/boot.php
@@ -48,7 +48,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.7.1' );
define ( 'ZOT_REVISION', 1.1 );
-define ( 'DB_UPDATE_VERSION', 1171 );
+define ( 'DB_UPDATE_VERSION', 1172 );
/**
diff --git a/include/account.php b/include/account.php
index a442f3073..caf12878e 100644
--- a/include/account.php
+++ b/include/account.php
@@ -229,7 +229,7 @@ function verify_email_address($arr) {
$hash = random_string();
- $r = q("INSERT INTO register ( hash, created, uid, password, language ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
+ $r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
dbesc($hash),
dbesc(datetime_convert()),
intval($arr['account']['account_id']),
@@ -283,7 +283,7 @@ function send_reg_approval_email($arr) {
$hash = random_string();
- $r = q("INSERT INTO register ( hash, created, uid, password, language ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
+ $r = q("INSERT INTO register ( hash, created, uid, password, lang ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
dbesc($hash),
dbesc(datetime_convert()),
intval($arr['account']['account_id']),
@@ -387,7 +387,7 @@ function account_allow($hash) {
intval($register[0]['uid'])
);
- push_lang($register[0]['language']);
+ push_lang($register[0]['lang']);
$email_tpl = get_intltext_template("register_open_eml.tpl");
$email_tpl = replace_macros($email_tpl, array(
diff --git a/include/api.php b/include/api.php
index af5a22a74..0833ae7b9 100644
--- a/include/api.php
+++ b/include/api.php
@@ -368,7 +368,7 @@ require_once('include/api_auth.php');
else
$redirect = trim($_REQUEST['redirect_uris']);
$icon = trim($_REQUEST['logo_uri']);
- $r = q("INSERT INTO clients (client_id, pw, name, redirect_uri, icon, uid)
+ $r = q("INSERT INTO clients (client_id, pw, clname, redirect_uri, icon, uid)
VALUES ('%s','%s','%s','%s','%s',%d)",
dbesc($key),
dbesc($secret),
diff --git a/include/oauth.php b/include/oauth.php
index ec41a5dd2..984e0e6c6 100644
--- a/include/oauth.php
+++ b/include/oauth.php
@@ -37,7 +37,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
logger(__function__.":".$consumer.", ". $token_type.", ".$token, LOGGER_DEBUG);
- $r = q("SELECT id, secret, scope, expires, uid FROM tokens WHERE client_id = '%s' AND scope = '%s' AND id = '%s'",
+ $r = q("SELECT id, secret, auth_scope, expires, uid FROM tokens WHERE client_id = '%s' AND auth_scope = '%s' AND id = '%s'",
dbesc($consumer->key),
dbesc($token_type),
dbesc($token)
@@ -45,7 +45,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
if (count($r)){
$ot=new OAuth1Token($r[0]['id'],$r[0]['secret']);
- $ot->scope=$r[0]['scope'];
+ $ot->scope=$r[0]['auth_scope'];
$ot->expires = $r[0]['expires'];
$ot->uid = $r[0]['uid'];
return $ot;
@@ -79,7 +79,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
$k = $consumer;
}
- $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', %d)",
+ $r = q("INSERT INTO tokens (id, secret, client_id, auth_scope, expires) VALUES ('%s','%s','%s','%s', %d)",
dbesc($key),
dbesc($sec),
dbesc($k),
@@ -110,7 +110,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore {
$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', %d, %d)",
+ $r = q("INSERT INTO tokens (id, secret, client_id, auth_scope, expires, uid) VALUES ('%s','%s','%s','%s', %d, %d)",
dbesc($key),
dbesc($sec),
dbesc($consumer->key),
@@ -249,7 +249,7 @@ class FKOAuth2 extends OAuth2 {
protected function getAuthCode($code) {
- $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'",
+ $r = q("SELECT id, client_id, redirect_uri, expires, auth_scope FROM auth_codes WHERE id = '%s'",
dbesc($code));
if (count($r))
@@ -259,7 +259,7 @@ class FKOAuth2 extends OAuth2 {
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
+ (id, client_id, redirect_uri, expires, auth_scope) VALUES
('%s', '%s', '%s', %d, '%s')",
dbesc($code),
dbesc($client_id),
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index 63be37f80..2b48afe98 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
`client_id` varchar(20) NOT NULL DEFAULT '',
`redirect_uri` varchar(200) NOT NULL DEFAULT '',
`expires` int(11) NOT NULL DEFAULT '0',
- `scope` varchar(250) NOT NULL DEFAULT '',
+ `auth_scope` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -342,7 +342,7 @@ CREATE TABLE IF NOT EXISTS `clients` (
`client_id` varchar(20) NOT NULL DEFAULT '',
`pw` varchar(20) NOT NULL DEFAULT '',
`redirect_uri` varchar(200) NOT NULL DEFAULT '',
- `name` text,
+ `clname` text,
`icon` text,
`uid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`client_id`)
@@ -1054,7 +1054,7 @@ CREATE TABLE IF NOT EXISTS `register` (
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`password` char(255) NOT NULL DEFAULT '',
- `language` char(16) NOT NULL DEFAULT '',
+ `lang` char(16) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `hash` (`hash`),
KEY `created` (`created`),
@@ -1064,7 +1064,7 @@ CREATE TABLE IF NOT EXISTS `register` (
CREATE TABLE IF NOT EXISTS `session` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`sid` char(255) NOT NULL DEFAULT '',
- `data` text NOT NULL,
+ `sess_data` text NOT NULL,
`expire` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `sid` (`sid`),
@@ -1176,7 +1176,7 @@ CREATE TABLE IF NOT EXISTS `tokens` (
`secret` text NOT NULL,
`client_id` varchar(20) NOT NULL DEFAULT '',
`expires` bigint(20) unsigned NOT NULL DEFAULT '0',
- `scope` varchar(200) NOT NULL DEFAULT '',
+ `auth_scope` varchar(512) NOT NULL DEFAULT '',
`uid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`),
@@ -1204,13 +1204,13 @@ CREATE TABLE IF NOT EXISTS `updates` (
CREATE TABLE IF NOT EXISTS `verify` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`channel` int(10) unsigned NOT NULL DEFAULT '0',
- `type` char(32) NOT NULL DEFAULT '',
+ `vtype` char(32) NOT NULL DEFAULT '',
`token` char(255) NOT NULL DEFAULT '',
`meta` char(255) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `channel` (`channel`),
- KEY `type` (`type`),
+ KEY `vtype` (`vtype`),
KEY `token` (`token`),
KEY `meta` (`meta`),
KEY `created` (`created`)
diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql
index 1ae65068c..05b53e1a3 100644
--- a/install/schema_postgres.sql
+++ b/install/schema_postgres.sql
@@ -184,7 +184,7 @@ CREATE TABLE "auth_codes" (
"client_id" varchar(20) NOT NULL,
"redirect_uri" varchar(200) NOT NULL,
"expires" bigint NOT NULL,
- "scope" varchar(250) NOT NULL,
+ "auth_scope" varchar(512) NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "cache" (
@@ -333,7 +333,7 @@ CREATE TABLE "clients" (
"client_id" varchar(20) NOT NULL,
"pw" varchar(20) NOT NULL,
"redirect_uri" varchar(200) NOT NULL,
- "name" text,
+ "clname" text,
"icon" text,
"uid" bigint NOT NULL DEFAULT '0',
PRIMARY KEY ("client_id")
@@ -1043,7 +1043,7 @@ CREATE TABLE "register" (
"created" timestamp NOT NULL,
"uid" bigint NOT NULL,
"password" text NOT NULL,
- "language" varchar(16) NOT NULL,
+ "lang" varchar(16) NOT NULL,
PRIMARY KEY ("id")
);
create index "reg_hash" on register ("hash");
@@ -1052,7 +1052,7 @@ create index "reg_uid" on register ("uid");
CREATE TABLE "session" (
"id" serial,
"sid" text NOT NULL,
- "data" text NOT NULL,
+ "sess_data" text NOT NULL,
"expire" numeric(20) NOT NULL,
PRIMARY KEY ("id")
);
@@ -1159,7 +1159,7 @@ CREATE TABLE "tokens" (
"secret" text NOT NULL,
"client_id" varchar(20) NOT NULL,
"expires" numeric(20) NOT NULL,
- "scope" varchar(200) NOT NULL,
+ "auth_scope" varchar(512) NOT NULL,
"uid" bigint NOT NULL,
PRIMARY KEY ("id")
);
@@ -1186,14 +1186,14 @@ create index "ud_last" on updates ("ud_last");
CREATE TABLE "verify" (
"id" serial NOT NULL,
"channel" bigint NOT NULL DEFAULT '0',
- "type" varchar(32) NOT NULL DEFAULT '',
+ "vtype" varchar(32) NOT NULL DEFAULT '',
"token" text NOT NULL DEFAULT '',
"meta" text NOT NULL DEFAULT '',
"created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY ("id")
);
create index "verify_channel" on verify ("channel");
-create index "verify_type" on verify ("type");
+create index "verify_vtype" on verify ("vtype");
create index "verify_token" on verify ("token");
create index "verify_meta" on verify ("meta");
create index "verify_created" on verify ("created");
diff --git a/install/update.php b/install/update.php
index 0bd8d59f9..4883d6561 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1171 );
+define( 'UPDATE_VERSION' , 1172 );
/**
*
@@ -2146,4 +2146,21 @@ function update_r1170() {
return UPDATE_SUCCESS;
return UPDATE_FAILED;
+}
+
+function update_r1171() {
+
+ $r1 = q("ALTER TABLE verify CHANGE `type` `vtype` varchar(32) NOT NULL DEFAULT '' ");
+ $r2 = q("ALTER TABLE tokens CHANGE `scope` `auth_scope` varchar(512) NOT NULL DEFAULT '' ");
+ $r3 = q("ALTER TABLE auth_codes CHANGE `scope` `auth_scope` varchar(512) NOT NULL DEFAULT '' ");
+ $r4 = q("ALTER TABLE clients CHANGE `name` `clname` TEXT ");
+ $r5 = q("ALTER TABLE session CHANGE `data` `sess_data` TEXT NOT NULL ");
+ $r6 = q("ALTER TABLE register CHANGE `language` `lang` varchar(16) NOT NULL DEFAULT '' ");
+
+ if($r1 && $r2 && $r3 && $r4 && $r5 && $r6)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+
+
+
} \ No newline at end of file
diff --git a/view/tpl/settings_oauth.tpl b/view/tpl/settings_oauth.tpl
index 02ca26234..9582ef52d 100755
--- a/view/tpl/settings_oauth.tpl
+++ b/view/tpl/settings_oauth.tpl
@@ -18,7 +18,7 @@
{{foreach $apps as $app}}
<div class='oauthapp'>
<img src='{{$app.icon}}' class="{{if $app.icon}} {{else}}noicon{{/if}}">
- {{if $app.name}}<h4>{{$app.name}}</h4>{{else}}<h4>{{$noname}}</h4>{{/if}}
+ {{if $app.clname}}<h4>{{$app.clname}}</h4>{{else}}<h4>{{$noname}}</h4>{{/if}}
{{if $app.my}}
{{if $app.oauth_token}}
<div class="settings-submit-wrapper" ><button class="settings-submit" type="submit" name="remove" value="{{$app.oauth_token}}">{{$remove}}</button></div>