Commit d383a19b authored by Malcolm Blaney's avatar Malcolm Blaney

Shorten primary keys where they were too long for new versions of mysql.

parent a9f3a333
Pipeline #16435385 passed with stage
in 1 minute and 15 seconds
......@@ -14,7 +14,7 @@ minify_js() {
"@licstart The following is the entire license notice" \
"for the JavaScript code in this page." \
"" \
"Copyright (C) 2017 Malcolm Blaney" \
"Copyright (C) 2018 Malcolm Blaney" \
"" \
"This program is free software: you can redistribute it and/or modify" \
"it under the terms of the GNU Affero General Public License as" \
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -75,30 +75,31 @@ class Analytics extends Base {
public function Install($path) {
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS analytics ('.
'user VARCHAR(50) NOT NULL,'.
'page VARCHAR(200) NOT NULL,'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'referer VARCHAR(300),'.
'counter INT UNSIGNED NOT NULL,'.
'PRIMARY KEY(user, page, timestamp, referer)'.
$query = 'CREATE TABLE IF NOT EXISTS analytics (' .
'user VARCHAR(50) NOT NULL,' .
'page VARCHAR(200) NOT NULL,' .
'timestamp INT(10) UNSIGNED NOT NULL,' .
'referer VARCHAR(300),' .
'counter INT UNSIGNED NOT NULL,' .
'PRIMARY KEY(user, page(50), timestamp, referer(50))' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Analytics->Install 1: '.$mysqli->error);
$this->Log('Analytics->Install 1: ' . $mysqli->error);
}
// Install Analytics for all existing users. (New users will copy the
// module from the admin user.)
$query = 'INSERT INTO modules (user, page, label, class, box_order, '.
'placement, deleted) SELECT user, "", "analytics", "", 0, "footer", 0 '.
$query = 'INSERT INTO modules (user, page, label, class, box_order, ' .
'placement, deleted) SELECT user, "", "analytics", "", 0, "footer", 0 ' .
'FROM users';
if (!$mysqli->query($query)) {
$this->Log('Analytics->Install 2: '.$mysqli->error);
$this->Log('Analytics->Install 2: ' . $mysqli->error);
}
$query = 'INSERT INTO modules_history (user, page, label, class, '.
'box_order, placement, action, modified_by, timestamp) SELECT user, "", '.
'"analytics", "", 0, "footer", "add", "admin", '.time().' FROM users';
$query = 'INSERT INTO modules_history (user, page, label, class, ' .
'box_order, placement, action, modified_by, timestamp) SELECT user, ' .
'"", "analytics", "", 0, "footer", "add", "admin", ' . time() .
' FROM users';
if (!$mysqli->query($query)) {
$this->Log('Analytics->Install 3: '.$mysqli->error);
$this->Log('Analytics->Install 3: ' . $mysqli->error);
}
$mysqli->close();
}
......@@ -120,7 +121,17 @@ class Analytics extends Base {
}
public function Update() {
$mysqli = connect_db();
$query = 'ALTER TABLE analytics DROP PRIMARY KEY';
if (!$mysqli->query($query)) {
$this->Log('Analytics->Update 1: ' . $mysqli->error);
}
$query = 'ALTER TABLE analytics ADD PRIMARY KEY' .
'(user, page(50), timestamp, referer(50))';
if (!$mysqli->query($query)) {
$this->Log('Analytics->Update 2: ' . $mysqli->error);
}
$mysqli->close();
}
public function UpdateScript($path) {
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -265,106 +265,106 @@ class Cart extends Base {
// Append dobrado.cart.js to the existing dobrado.js file.
$this->AppendScript($path, 'dobrado.cart.js');
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS cart_items ('.
'user VARCHAR(50) NOT NULL,'.
'name VARCHAR(100) NOT NULL,'.
'image VARCHAR(200),'.
'short TEXT,'.
'full TEXT,'.
'weight DECIMAL(8,2),'.
'price DECIMAL(8,2),'.
'variable TINYINT(1),'.
'minimum DECIMAL(8,2),'.
'download VARCHAR(200),'.
'PRIMARY KEY(user, name)'.
$query = 'CREATE TABLE IF NOT EXISTS cart_items (' .
'user VARCHAR(50) NOT NULL,' .
'name VARCHAR(100) NOT NULL,' .
'image VARCHAR(200),' .
'short TEXT,' .
'full TEXT,' .
'weight DECIMAL(8,2),' .
'price DECIMAL(8,2),' .
'variable TINYINT(1),' .
'minimum DECIMAL(8,2),' .
'download VARCHAR(200),' .
'PRIMARY KEY(user, name)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Cart->Install 1: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_item_page ('.
'user VARCHAR(50) NOT NULL,'.
'name VARCHAR(100) NOT NULL,'.
'page VARCHAR(200),'.
'available TINYINT(1),'.
'tab VARCHAR(100),'.
'item_order INT UNSIGNED,'.
'PRIMARY KEY(user, name, page)'.
$this->Log('Cart->Install 1: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_item_page (' .
'user VARCHAR(50) NOT NULL,' .
'name VARCHAR(100) NOT NULL,' .
'page VARCHAR(200),' .
'available TINYINT(1),' .
'tab VARCHAR(100),' .
'item_order INT UNSIGNED,' .
'PRIMARY KEY(user, name, page(50))' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Cart->Install 2: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_shipping ('.
'user VARCHAR(50) NOT NULL,'.
'id INT UNSIGNED NOT NULL,'.
'type VARCHAR(100) NOT NULL,'.
'destination_name VARCHAR(100),'.
'destination_code VARCHAR(4),'.
'amount DECIMAL(8,2) NOT NULL,'.
'minimum DECIMAL(8,2),'.
'maximum DECIMAL(8,2),'.
'rule ENUM("weight", "fixed", "percent") NOT NULL,'.
'PRIMARY KEY(user, id)'.
$this->Log('Cart->Install 2: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_shipping (' .
'user VARCHAR(50) NOT NULL,' .
'id INT UNSIGNED NOT NULL,' .
'type VARCHAR(100) NOT NULL,' .
'destination_name VARCHAR(100),' .
'destination_code VARCHAR(4),' .
'amount DECIMAL(8,2) NOT NULL,' .
'minimum DECIMAL(8,2),' .
'maximum DECIMAL(8,2),' .
'rule ENUM("weight", "fixed", "percent") NOT NULL,' .
'PRIMARY KEY(user, id)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Cart->Install 3: '.$mysqli->error);
$this->Log('Cart->Install 3: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_checkout ('.
'user VARCHAR(50) NOT NULL,'.
'email VARCHAR(200) NOT NULL,'.
'currency VARCHAR(3) NOT NULL,'.
'PRIMARY KEY(user)'.
$query = 'CREATE TABLE IF NOT EXISTS cart_checkout (' .
'user VARCHAR(50) NOT NULL,' .
'email VARCHAR(200) NOT NULL,' .
'currency VARCHAR(3) NOT NULL,' .
'PRIMARY KEY(user)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Cart->Install 4: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_method ('.
'user VARCHAR(50) NOT NULL,'.
'name ENUM("credit", "paypal", "pickup") NOT NULL,'.
'available TINYINT(1),'.
'gateway ENUM("eway", "migs"),'.
'gateway_api_key TEXT,'.
'gateway_password VARCHAR(100),'.
'fee DECIMAL(8,2),'.
'PRIMARY KEY(user, name)'.
$this->Log('Cart->Install 4: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_method (' .
'user VARCHAR(50) NOT NULL,' .
'name ENUM("credit", "paypal", "pickup") NOT NULL,' .
'available TINYINT(1),' .
'gateway ENUM("eway", "migs"),' .
'gateway_api_key TEXT,' .
'gateway_password VARCHAR(100),' .
'fee DECIMAL(8,2),' .
'PRIMARY KEY(user, name)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Cart->Install 5: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_order ('.
'user VARCHAR(50) NOT NULL,'.
'id INT UNSIGNED NOT NULL AUTO_INCREMENT,'.
'email VARCHAR(200) NOT NULL,'.
'description TEXT,'.
'method ENUM("credit", "paypal", "pickup") NOT NULL,'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'completed INT(10) UNSIGNED,'.
'PRIMARY KEY(user, id)'.
$this->Log('Cart->Install 5: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS cart_order (' .
'user VARCHAR(50) NOT NULL,' .
'id INT UNSIGNED NOT NULL AUTO_INCREMENT,' .
'email VARCHAR(200) NOT NULL,' .
'description TEXT,' .
'method ENUM("credit", "paypal", "pickup") NOT NULL,' .
'timestamp INT(10) UNSIGNED NOT NULL,' .
'completed INT(10) UNSIGNED,' .
'PRIMARY KEY(user, id)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Cart->Install 6: '.$mysqli->error);
$this->Log('Cart->Install 6: ' . $mysqli->error);
}
$mysqli->close();
$template = ['"cart-price-text","","Price:"',
'"cart-quantity-text","","Quantity:"',
'"cart-title","","Shopping Cart"',
'"cart-checkout","","Your order will be sent to:<br>'.
'!first !last<br>!address<br>!postcode<br>!city<br>'.
'"cart-checkout","","Your order will be sent to:<br>' .
'!first !last<br>!address<br>!postcode<br>!city<br>' .
'!state<br>!country<br>"',
'"cart-display-item","","<h2>!name</h2><img src="!image">'.
'"cart-display-item","","<h2>!name</h2><img src="!image">' .
'!description',
'"cart-email","","To !first !last<br>Thanks for your order! '.
'The following is a confirmation of your purchases and '.
'contact details:<br><br>!items<br><b>Total: '.
'$!amount</b><br><br>Email: !email<br>Address:<br>!address'.
'"cart-email","","To !first !last<br>Thanks for your order! ' .
'The following is a confirmation of your purchases and ' .
'contact details:<br><br>!items<br><b>Total: ' .
'$!amount</b><br><br>Email: !email<br>Address:<br>!address' .
'<br>!city<br>!postcode<br>!state<br>!country<br><br>"'];
$this->AddTemplate($template);
$site_style = ['"","#cart-summary","margin-bottom","40px"',
'"","#cart-confirm-button","float","right"',
'"","#cart-customer-details-form","background-color",'.
'"","#cart-customer-details-form","background-color",' .
'"#eeeeee"',
'"","#cart-customer-details-form","border",'.
'"","#cart-customer-details-form","border",' .
'"1px solid #aaaaaa"',
'"","#cart-customer-details-form","border-radius","2px"',
'"","#cart-customer-details-form","padding","5px"',
......@@ -445,10 +445,13 @@ class Cart extends Base {
public function Update() {
$mysqli = connect_db();
$query = 'ALTER TABLE cart_order ADD COLUMN email VARCHAR(200) NOT NULL '.
'AFTER id';
$query = 'ALTER TABLE cart_item_page DROP PRIMARY KEY';
if (!$mysqli->query($query)) {
$this->Log('Cart->Update: '.$mysqli->error);
$this->Log('Cart->Update 1: ' . $mysqli->error);
}
$query = 'ALTER TABLE cart_item_page ADD PRIMARY KEY(user, name, page(50))';
if (!$mysqli->query($query)) {
$this->Log('Cart->Update 2: ' . $mysqli->error);
}
$mysqli->close();
}
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -139,7 +139,7 @@ class Escrow extends Base {
'amount INT UNSIGNED NOT NULL,' .
'confirmed TINYINT(1) NOT NULL,' .
'permalink VARCHAR(200) NOT NULL,' .
'PRIMARY KEY(user, recipient, permalink)' .
'PRIMARY KEY(user, recipient, permalink(100))' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Escrow->Install 2: ' . $mysqli->error);
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -220,62 +220,62 @@ class Graph extends Base {
public function Install($path) {
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS graph_data ('.
'user VARCHAR(50) NOT NULL,'.
'feed_id INT UNSIGNED NOT NULL,'.
'sample_id INT UNSIGNED NOT NULL AUTO_INCREMENT,'.
$this->LabelQuery(' DOUBLE, ', true).
'PRIMARY KEY(user, feed_id, sample_id)'.
$query = 'CREATE TABLE IF NOT EXISTS graph_data (' .
'user VARCHAR(50) NOT NULL,' .
'feed_id INT UNSIGNED NOT NULL,' .
'sample_id INT UNSIGNED NOT NULL AUTO_INCREMENT,' .
$this->LabelQuery(' DOUBLE, ', true) .
'PRIMARY KEY(user, feed_id, sample_id)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Graph->Install 1: '.$mysqli->error);
$this->Log('Graph->Install 1: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS graph_labels ('.
'user VARCHAR(50) NOT NULL,'.
'feed_id INT UNSIGNED NOT NULL,'.
$this->LabelQuery(' VARCHAR(100), ', true).
'PRIMARY KEY(user, feed_id)'.
$query = 'CREATE TABLE IF NOT EXISTS graph_labels (' .
'user VARCHAR(50) NOT NULL,' .
'feed_id INT UNSIGNED NOT NULL,' .
$this->LabelQuery(' VARCHAR(100), ', true) .
'PRIMARY KEY(user, feed_id)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Graph->Install 2: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS graph_instance ('.
'user VARCHAR(50) NOT NULL,'.
'box_id INT UNSIGNED NOT NULL,'.
'graph_id INT UNSIGNED NOT NULL,'.
'graph_type ENUM("time", "custom") NOT NULL,'.
'display_count INT UNSIGNED NOT NULL,'.
'x_axis_format VARCHAR(100),'.
'y_axis_format VARCHAR(100),'.
'title VARCHAR(200),'.
'PRIMARY KEY(user, box_id, graph_id)'.
$this->Log('Graph->Install 2: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS graph_instance (' .
'user VARCHAR(50) NOT NULL,' .
'box_id INT UNSIGNED NOT NULL,' .
'graph_id INT UNSIGNED NOT NULL,' .
'graph_type ENUM("time", "custom") NOT NULL,' .
'display_count INT UNSIGNED NOT NULL,' .
'x_axis_format VARCHAR(100),' .
'y_axis_format VARCHAR(100),' .
'title VARCHAR(200),' .
'PRIMARY KEY(user, box_id, graph_id)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Graph->Install 3: '.$mysqli->error);
$this->Log('Graph->Install 3: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS graph_pairs ('.
'user VARCHAR(50) NOT NULL,'.
'box_id INT UNSIGNED NOT NULL,'.
'graph_id INT UNSIGNED NOT NULL,'.
'x_label VARCHAR(100),'.
'y_label VARCHAR(100),'.
'PRIMARY KEY(user, box_id, graph_id, x_label, y_label)'.
$query = 'CREATE TABLE IF NOT EXISTS graph_pairs (' .
'user VARCHAR(50) NOT NULL,' .
'box_id INT UNSIGNED NOT NULL,' .
'graph_id INT UNSIGNED NOT NULL,' .
'x_label VARCHAR(100),' .
'y_label VARCHAR(100),' .
'PRIMARY KEY(user, box_id, graph_id, x_label(50), y_label(50))' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Graph->Install 4: '.$mysqli->error);
$this->Log('Graph->Install 4: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS graph_connect ('.
'user VARCHAR(50) NOT NULL,'.
'label VARCHAR(50) NOT NULL,'.
'feed_id INT UNSIGNED NOT NULL,'.
'PRIMARY KEY(user, label)'.
$query = 'CREATE TABLE IF NOT EXISTS graph_connect (' .
'user VARCHAR(50) NOT NULL,' .
'label VARCHAR(50) NOT NULL,' .
'feed_id INT UNSIGNED NOT NULL,' .
'PRIMARY KEY(user, label)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Graph->Install 5: '.$mysqli->error);
$this->Log('Graph->Install 5: ' . $mysqli->error);
}
$mysqli->close();
......@@ -342,7 +342,17 @@ class Graph extends Base {
}
public function Update() {
$mysqli = connect_db();
$query = 'ALTER TABLE graph_pairs DROP PRIMARY KEY';
if (!$mysqli->query($query)) {
$this->Log('Graph->Update 1: ' . $mysqli->error);
}
$query = 'ALTER TABLE graph_pairs ADD PRIMARY KEY' .
'(user, box_id, graph_id, x_label(50), y_label(50))';
if (!$mysqli->query($query)) {
$this->Log('Graph->Update 2: ' . $mysqli->error);
}
$mysqli->close();
}
public function UpdateScript($path) {
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -516,49 +516,49 @@ class Post extends Base {
public function Install($path) {
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS post ('.
'user VARCHAR(50) NOT NULL,'.
'box_id INT UNSIGNED NOT NULL,'.
'title VARCHAR(180),'.
'description TEXT,'.
'author VARCHAR(50),'.
'category VARCHAR(200),'.
'enclosure TEXT,'.
'permalink VARCHAR(200),'.
'feed VARCHAR(200),'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'PRIMARY KEY(user, box_id)'.
$query = 'CREATE TABLE IF NOT EXISTS post (' .
'user VARCHAR(50) NOT NULL,' .
'box_id INT UNSIGNED NOT NULL,' .
'title VARCHAR(180),' .
'description TEXT,' .
'author VARCHAR(50),' .
'category VARCHAR(200),' .
'enclosure TEXT,' .
'permalink VARCHAR(200),' .
'feed VARCHAR(200),' .
'timestamp INT(10) UNSIGNED NOT NULL,' .
'PRIMARY KEY(user, box_id)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Post->Install 1: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS post_history ('.
'user VARCHAR(50) NOT NULL,'.
'box_id INT UNSIGNED NOT NULL,'.
'title VARCHAR(180),'.
'description TEXT,'.
'author VARCHAR(50),'.
'category VARCHAR(200),'.
'enclosure TEXT,'.
'permalink VARCHAR(200),'.
'feed VARCHAR(200),'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'modified_by VARCHAR(50) NOT NULL,'.
'PRIMARY KEY(user, box_id, timestamp)'.
$this->Log('Post->Install 1: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS post_history (' .
'user VARCHAR(50) NOT NULL,' .
'box_id INT UNSIGNED NOT NULL,' .
'title VARCHAR(180),' .
'description TEXT,' .
'author VARCHAR(50),' .
'category VARCHAR(200),' .
'enclosure TEXT,' .
'permalink VARCHAR(200),' .
'feed VARCHAR(200),' .
'timestamp INT(10) UNSIGNED NOT NULL,' .
'modified_by VARCHAR(50) NOT NULL,' .
'PRIMARY KEY(user, box_id, timestamp)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Post->Install 2: '.$mysqli->error);
$this->Log('Post->Install 2: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS post_queue ('.
'source VARCHAR(200),'.
'target VARCHAR(200),'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'PRIMARY KEY(source, target)'.
$query = 'CREATE TABLE IF NOT EXISTS post_queue (' .
'source VARCHAR(200),' .
'target VARCHAR(200),' .
'timestamp INT(10) UNSIGNED NOT NULL,' .
'PRIMARY KEY(source(100), target(100))' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Post->Install 3: '.$mysqli->error);
$this->Log('Post->Install 3: ' . $mysqli->error);
}
$site_style = ['"",".post .thumb","width","20px"',
......@@ -572,34 +572,34 @@ class Post extends Base {
// The two formats are required because p-name needs to be either on the
// title or on the same div as e-content.
$post_no_title = '<article class="h-entry">'.
'<div class="published">'.
'By <span class="h-card p-author">!author</span> on !date</div>'.
'<div class="dobrado-editable p-name e-content">!description</div>'.
$post_no_title = '<article class="h-entry">' .
'<div class="published">' .
'By <span class="h-card p-author">!author</span> on !date</div>' .
'<div class="dobrado-editable p-name e-content">!description</div>' .
'<div class="options">!category</div>!navigation</article>';
$post_with_title = '<article class="h-entry">!title'.
'<div class="published">'.
'By <span class="h-card p-author">!author</span> on !date</div>'.
'<div class="dobrado-editable e-content">!description</div>'.
$post_with_title = '<article class="h-entry">!title' .
'<div class="published">' .
'By <span class="h-card p-author">!author</span> on !date</div>' .
'<div class="dobrado-editable e-content">!description</div>' .
'<div class="options">!category</div>!navigation</article>';
$permalink_no_title = '<article>'.
'<div class="published">'.
'By <span class="h-card p-author">!author</span> on !date</div>'.
'<div class="dobrado-editable p-name e-content">!description</div>'.
$permalink_no_title = '<article>' .
'<div class="published">' .
'By <span class="h-card p-author">!author</span> on !date</div>' .
'<div class="dobrado-editable p-name e-content">!description</div>' .
'<div class="options">!category</div>!navigation</article>';
$permalink_with_title = '<article>!title'.
'<div class="published">'.
'By <span class="h-card p-author">!author</span> on !date</div>'.
'<div class="dobrado-editable e-content">!description</div>'.
$permalink_with_title = '<article>!title' .
'<div class="published">' .
'By <span class="h-card p-author">!author</span> on !date</div>' .
'<div class="dobrado-editable e-content">!description</div>' .
'<div class="options">!category</div>!navigation</article>';
$template = ['"post-no-title", "", '.
'"'.$mysqli->escape_string($post_no_title).'"',
'"post-with-title", "", '.
'"'.$mysqli->escape_string($post_with_title).'"',
'"permalink-post-no-title", "", '.
'"'.$mysqli->escape_string($permalink_no_title).'"',
'"permalink-post-with-title", "", '.
'"'.$mysqli->escape_string($permalink_with_title).'"'];
$template = ['"post-no-title", "", ' .
'"' . $mysqli->escape_string($post_no_title) . '"',
'"post-with-title", "", ' .
'"' . $mysqli->escape_string($post_with_title) . '"',
'"permalink-post-no-title", "", ' .
'"' . $mysqli->escape_string($permalink_no_title) . '"',
'"permalink-post-with-title", "", ' .
'"' . $mysqli->escape_string($permalink_with_title) . '"'];
$mysqli->close();
$this->AddTemplate($template);
}
......@@ -998,14 +998,14 @@ class Post extends Base {
public function Update() {
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS post_queue ('.
'source VARCHAR(200),'.
'target VARCHAR(200),'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'PRIMARY KEY(source, target)'.
') ENGINE=MyISAM';
$query = 'ALTER TABLE post_queue DROP PRIMARY KEY';
if (!$mysqli->query($query)) {
$this->Log('Post->Update 1: ' . $mysqli->error);
}
$query = 'ALTER TABLE post_queue ADD PRIMARY KEY' .
'(source(100), target(100))';
if (!$mysqli->query($query)) {
$this->Log('Post->Update: '.$mysqli->error);
$this->Log('Post->Update 2: ' . $mysqli->error);
}
$mysqli->close();
}
......
This diff is collapsed.
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -221,24 +221,24 @@ class Writer extends Base {
// Note that this module is only available when logged in.
$this->AppendScript($path, 'dobrado.writer.js', false);
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS writer ('.
'user VARCHAR(50) NOT NULL,'.
'page VARCHAR(200) NOT NULL,'.
'action ENUM("like", "post", "reply", "share") NOT NULL,'.
'designate VARCHAR(200),'.
'PRIMARY KEY(user, page, action)'.
$query = 'CREATE TABLE IF NOT EXISTS writer (' .
'user VARCHAR(50) NOT NULL,' .
'page VARCHAR(200) NOT NULL,' .
'action ENUM("like", "post", "reply", "share") NOT NULL,' .
'designate VARCHAR(200),' .
'PRIMARY KEY(user, page(50), action)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Writer->Install 1: '.$mysqli->error);
$this->Log('Writer->Install 1: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS writer_settings ('.
'user VARCHAR(50) NOT NULL,'.
'page VARCHAR(200) NOT NULL,'.
'title VARCHAR(100),'.
'PRIMARY KEY(user, page)'.
$query = 'CREATE TABLE IF NOT EXISTS writer_settings (' .
'user VARCHAR(50) NOT NULL,' .
'page VARCHAR(200) NOT NULL,' .
'title VARCHAR(100),' .
'PRIMARY KEY(user, page(50))' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Writer->Install 2: '.$mysqli->error);
$this->Log('Writer->Install 2: ' . $mysqli->error);
}
$mysqli->close();
......@@ -265,11 +265,11 @@ class Writer extends Base {
'"","#writer-content","max-width","100%"',
'"","#writer-content","width","500px"',
'"","#writer-content","height","100px"',
'"",".writer-options label[for=writer-tags]",'.
'"",".writer-options label[for=writer-tags]",' .
'"margin-left","10px"',
'"",".writer-options label[for=writer-tags]","float","none"',
'"",".writer .designate","border-top","1px solid #aaaaaa"',
'"",".writer .designate","border-bottom",'.
'"",".writer .designate","border-bottom",' .
'"1px solid #aaaaaa"',
'"",".writer .designate","padding","5px"',
'"",".writer .designate","margin-bottom","10px"',
......@@ -286,11 +286,11 @@ class Writer extends Base {
'"",".writer-remove-title","float","left"',
'"",".writer label[for=writer-title]","width","4em"',
'"",".writer label[for=writer-title]","float","none"',
'"",".writer label[for=writer-title]","display",'.
'"",".writer label[for=writer-title]","display",' .
'"inline-block"',
'"",".writer label[for=writer-author]","width","4em"',
'"",".writer label[for=writer-author]","float","none"',
'"",".writer label[for=writer-author]","display",'.
'"",".writer label[for=writer-author]","display",' .
'"inline-block"',
'"",".writer-twitter","margin-left","10px"',
'"",".writer-facebook","margin-left","10px"',
......@@ -317,27 +317,23 @@ class Writer extends Base {
public function Update() {
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS writer_settings ('.
'user VARCHAR(50) NOT NULL,'.
'page VARCHAR(200) NOT NULL,'.
'title VARCHAR(100),'.
'PRIMARY KEY(user, page)'.
') ENGINE=MyISAM';
$query = 'ALTER TABLE writer DROP PRIMARY KEY';
if (!$mysqli->query($query)) {
$this->Log('Writer->Update 1: ' . $mysqli->error);
}
$query = 'ALTER TABLE writer ADD PRIMARY KEY(user, page(50), action)';
if (!$mysqli->query($query)) {
$this->Log('Writer->Update 2: ' . $mysqli->error);
}
$query = 'ALTER TABLE writer_settings DROP PRIMARY KEY';
if (!$mysqli->query($query)) {
$this->Log('Writer->Update 3: ' . $mysqli->error);
}
$query = 'ALTER TABLE writer_settings ADD PRIMARY KEY(user, page(50))';
if (!$mysqli->query($query)) {
$this->Log('Writer->Update: '.$mysqli->error);
$this->Log('Writer->Update 4: ' . $mysqli->error);
}
$mysqli->close();
$site_style = ['"",".writer .feed-title","display","none"',
'"",".writer .feed-author","display","none"',
'"",".writer .designate","border-bottom",'.
'"1px solid #aaaaaa"',
'"",".writer .designate","padding","5px"',
'"",".writer .designate","margin-bottom","10px"',
'"",".writer .designate label","width","15em"',
'"","#writer-feed-title-input","width","324px"',
'"","#writer-designate-input","width","250px"'];
$this->AddSiteStyle($site_style);
}
public function UpdateScript($path) {
......
This diff is collapsed.
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -149,78 +149,78 @@ class Notification extends Base {
public function Install($path) {