Commit 434ca4cc authored by Malcolm Blaney's avatar Malcolm Blaney

Fix gitlab runner dependency conflict between php 7 and mysql 8.

Add support to Banking module for BuyerGroup to be called from
Cart module. Cart module now supports different price levels for
logged in users, and can display items from the Stock module.
The Stock module now supports updating images for stock items so
that they can also be used by the Cart module. The Browser module
is called from the stock grid, and it now shows upload progress
and image search. Cart sales are also saved to the purchase and
payment modules when items are tracked from the Stock module.
parent 5dfba66a
Pipeline #23602659 passed with stage
in 1 minute and 24 seconds
image: php:latest
services:
- mysql:latest
- mysql:5.7
variables:
MYSQL_DATABASE: dobrado_test
......
......@@ -30,11 +30,11 @@ class Banking extends Base {
$number = $mysqli->escape_string(htmlspecialchars($_POST['number']));
$bsb = $mysqli->escape_string(htmlspecialchars($_POST['bsb']));
$credit = (int)$_POST['credit'];
$query = 'UPDATE banking SET name = "'.$name.'", number = "'.$number.'", '.
'bsb = "'.$bsb.'", credit = '.$credit.
' WHERE user = "'.$this->user->name.'"';
$query = 'UPDATE banking SET name = "' . $name . '", ' .
'number = "' . $number . '", bsb = "' . $bsb . '", credit = ' . $credit .
' WHERE user = "' . $this->user->name . '"';
if (!$mysqli->query($query)) {
$this->Log('Banking->Callback: '.$mysqli->error);
$this->Log('Banking->Callback: ' . $mysqli->error);
}
$mysqli->close();
return ['done' => true];
......@@ -133,25 +133,25 @@ class Banking extends Base {
if (strlen($this->user->name) > 6) {
$start = substr($this->user->name, 0, 6);
$reference = $start;
$query = 'SELECT user FROM users WHERE user LIKE "'.$start.'%"';
$query = 'SELECT user FROM users WHERE user LIKE "' . $start . '%"';
if ($result = $mysqli->query($query)) {
// The first user with this start value get these 6 characters as a
// reference, subsequent users get an incremental suffix.
if ($result->num_rows > 1 && $result->num_rows < 10) {
$reference = substr($this->user->name, 0, 5).$result->num_rows;
$reference = substr($this->user->name, 0, 5) . $result->num_rows;
}
$result->close();
}
else {
$this->Log('Banking->Copy 1: '.$mysqli->error);
$this->Log('Banking->Copy 1: ' . $mysqli->error);
}
}
// References can also be modified, so need to check if the reference that
// was just created for the new user is already being used by someone else.
$count = 1;
while (true) {
$query = 'SELECT reference FROM banking WHERE '.
'reference = "'.$reference.'"';
$query = 'SELECT reference FROM banking WHERE ' .
'reference = "' . $reference . '"';
if ($result = $mysqli->query($query)) {
if ($result->num_rows === 0) {
$result->close();
......@@ -161,24 +161,24 @@ class Banking extends Base {
$result->close();
// Need to create a new reference, use the first 4 characters of the
// old one, add a suffix and check it again.
$reference = substr($reference, 0, 4).$count;
$reference = substr($reference, 0, 4) . $count;
$count++;
}
}
else {
$this->Log('Banking->Copy 2: '.$mysqli->error);
$this->Log('Banking->Copy 2: ' . $mysqli->error);
break;
}
}
$default_query =
isset($_SESSION['new-supplier']) && $_SESSION['new-supplier'] ?
'0, 0, 0, 0, ' : '1, 1, 1, 0, ';
$query = 'INSERT INTO banking VALUES ("'.$this->user->name.'", '.
'"'.$reference.'", "", "", "", '.$default_query.
'"'.$this->Substitute("banking-default-group").'") '.
'ON DUPLICATE KEY UPDATE reference = "'.$reference.'"';
$group = $mysqli->escape_string($this->Substitute('banking-default-group'));
$query = 'INSERT INTO banking VALUES ("' . $this->user->name . '", ' .
'"' . $reference . '", "", "", "", ' . $default_query .
'"' . $group . '") ON DUPLICATE KEY UPDATE reference = "' .$reference.'"';
if (!$mysqli->query($query)) {
$this->Log('Banking->Copy 3: '.$mysqli->error);
$this->Log('Banking->Copy 3: ' . $mysqli->error);
}
$mysqli->close();
}
......@@ -192,6 +192,9 @@ class Banking extends Base {
if ($fn === 'Settings') {
return $this->Settings($p);
}
if ($fn === 'BuyerGroup') {
return $this->BuyerGroup();
}
}
public function Group() {
......@@ -256,9 +259,9 @@ class Banking extends Base {
if (isset($id)) return;
$mysqli = connect_db();
$query = 'DELETE FROM banking WHERE user = "'.$this->owner.'"';
$query = 'DELETE FROM banking WHERE user = "' . $this->owner . '"';
if (!$mysqli->query($query)) {
$this->Log('Banking->Remove: '.$mysqli->error);
$this->Log('Banking->Remove: ' . $mysqli->error);
}
$mysqli->close();
}
......@@ -296,24 +299,24 @@ class Banking extends Base {
$group_query = '';
foreach ($joined as $group) {
if ($group_query !== '') $group_query .= ' OR ';
$group_query .= 'users.system_group = "'.$group.'"';
$group_query .= 'users.system_group = "' . $group . '"';
}
// Add the host group too.
$group_query .= ' OR users.system_group = "'.$this->user->group.'"';
$query = 'SELECT banking.user, buyer_group FROM banking LEFT JOIN '.
'users ON banking.user = users.user WHERE '.$active_query.
'('.$group_query.')';
$group_query .= ' OR users.system_group = "' . $this->user->group . '"';
$query = 'SELECT banking.user, buyer_group FROM banking LEFT JOIN ' .
'users ON banking.user = users.user WHERE ' . $active_query .
'(' . $group_query . ')';
}
else if ($organisation) {
$organiser = new Organiser($this->user, $this->owner);
$query = 'SELECT banking.user, buyer_group FROM banking LEFT JOIN '.
'users ON banking.user = users.user WHERE '.$active_query.
$query = 'SELECT banking.user, buyer_group FROM banking LEFT JOIN ' .
'users ON banking.user = users.user WHERE ' . $active_query .
$organiser->GroupQuery();
}
else {
$query = 'SELECT banking.user, buyer_group FROM banking LEFT JOIN '.
'users ON banking.user = users.user WHERE '.$active_query.
'users.system_group = "'.$this->user->group.'"';
$query = 'SELECT banking.user, buyer_group FROM banking LEFT JOIN ' .
'users ON banking.user = users.user WHERE ' . $active_query .
'users.system_group = "' . $this->user->group . '"';
}
$mysqli = connect_db();
if ($result = $mysqli->query($query)) {
......@@ -327,7 +330,7 @@ class Banking extends Base {
$result->close();
}
else {
$this->Log('Banking->AllBuyers: '.$mysqli->error);
$this->Log('Banking->AllBuyers: ' . $mysqli->error);
}
$mysqli->close();
return [$user_list, $buyer_groups];
......@@ -338,16 +341,16 @@ class Banking extends Base {
$query = '';
if ($organisation) {
$organiser = new Organiser($this->user, $this->owner);
$query = 'SELECT banking.user, reference, name, number, bsb, credit, '.
'surcharge, deposit, next_week, buyer_group, active FROM banking '.
'LEFT JOIN users ON banking.user = users.user WHERE '.
$query = 'SELECT banking.user, reference, name, number, bsb, credit, ' .
'surcharge, deposit, next_week, buyer_group, active FROM banking ' .
'LEFT JOIN users ON banking.user = users.user WHERE ' .
$organiser->GroupQuery();
}
else {
$query = 'SELECT banking.user, reference, name, number, bsb, credit, '.
'surcharge, deposit, next_week, buyer_group, active FROM banking '.
'LEFT JOIN users ON banking.user = users.user WHERE '.
'users.system_group = "'.$this->user->group.'"';
$query = 'SELECT banking.user, reference, name, number, bsb, credit, ' .
'surcharge, deposit, next_week, buyer_group, active FROM banking ' .
'LEFT JOIN users ON banking.user = users.user WHERE ' .
'users.system_group = "' . $this->user->group . '"';
}
$mysqli = connect_db();
if ($result = $mysqli->query($query)) {
......@@ -367,16 +370,19 @@ class Banking extends Base {
$result->close();
}
else {
$this->Log('Banking->AllSettings: '.$mysqli->error);
$this->Log('Banking->AllSettings: ' . $mysqli->error);
}
$mysqli->close();
return $settings;
}
public function BuyerGroup($user) {
public function BuyerGroup($user = '') {
if ($user === '') {
$user = $this->user->name;
}
$buyer_group = '';
$mysqli = connect_db();
$query = 'SELECT buyer_group FROM banking WHERE user = "'.$user.'"';
$query = 'SELECT buyer_group FROM banking WHERE user = "' . $user . '"';
if ($result = $mysqli->query($query)) {
if ($banking = $result->fetch_assoc()) {
$buyer_group = $banking['buyer_group'];
......@@ -384,7 +390,7 @@ class Banking extends Base {
$result->close();
}
else {
$this->Log('Banking->BuyerGroup: '.$mysqli->error);
$this->Log('Banking->BuyerGroup: ' . $mysqli->error);
}
$mysqli->close();
return $buyer_group === '' ? 'price' : $buyer_group;
......@@ -396,10 +402,10 @@ class Banking extends Base {
}
$mysqli = connect_db();
$query = 'UPDATE banking SET '.$field.' = "'.$value.'" WHERE '.
'user = "'.$user.'"';
$query = 'UPDATE banking SET ' . $field . ' = "' . $value . '" WHERE ' .
'user = "' . $user . '"';
if (!$mysqli->query($query)) {
$this->Log('Banking->UpdateField: '.$mysqli->error);
$this->Log('Banking->UpdateField: ' . $mysqli->error);
}
$mysqli->close();
return ['done' => true];
......@@ -412,12 +418,13 @@ class Banking extends Base {
}
$mysqli = connect_db();
$query = 'UPDATE banking SET reference = "'.$reference.'", '.
'name = "'.$name.'", number = "'.$number.'", bsb = "'.$bsb.'", '.
'credit = '.$credit.', surcharge = '.$surcharge.', deposit = '.$deposit.
', buyer_group = "'.$buyer_group.'" WHERE user = "'.$user.'"';
$query = 'UPDATE banking SET reference = "' . $reference . '", ' .
'name = "' . $name . '", number = "' . $number . '", ' .
'bsb = "' . $bsb . '", credit = ' . $credit . ', ' .
'surcharge = ' . $surcharge . ', deposit = ' . $deposit . ', ' .
'buyer_group = "' . $buyer_group . '" WHERE user = "' . $user . '"';
if (!$mysqli->query($query)) {
$this->Log('Banking->UpdateUser: '.$mysqli->error);
$this->Log('Banking->UpdateUser: ' . $mysqli->error);
}
$mysqli->close();
return ['done' => true];
......@@ -432,18 +439,19 @@ class Banking extends Base {
// Use the configured day of the week for the co-op to find the next time
// the co-op will be held.
$timestamp = strtotime('next '.$co_op_day);
$timestamp = strtotime('next ' . $co_op_day);
$mysqli = connect_db();
$user_query = '';
for ($i = 0; $i < count($us_next_week); $i++) {
if ($user_query !== '') $user_query .= ' OR ';
$user_query .= 'user = "'.$mysqli->escape_string($us_next_week[$i]).'"';
$user_query .= 'user = "' . $mysqli->escape_string($us_next_week[$i]).'"';
}
if ($user_query !== '') {
$query = 'UPDATE banking SET next_week='.$timestamp.' WHERE '.$user_query;
$query = 'UPDATE banking SET next_week = ' . $timestamp . ' WHERE ' .
$user_query;
if (!$mysqli->query($query)) {
$this->Log('Banking->SaveNextWeek: '.$mysqli->error);
$this->Log('Banking->SaveNextWeek: ' . $mysqli->error);
}
}
$mysqli->close();
......@@ -456,22 +464,22 @@ class Banking extends Base {
'Friday', 'Saturday'];
if (!in_array($co_op_day, $weekdays)) return [0, time()];
$timestamp = strtotime('this '.$co_op_day);
$timestamp = strtotime('this ' . $co_op_day);
// Want to make sure today is not set as the value if today is co-op day.
if ($timestamp < strtotime('24 hours')) {
$timestamp = strtotime('next '.$co_op_day);
$timestamp = strtotime('next ' . $co_op_day);
}
$count = 0;
$mysqli = connect_db();
$query = 'SELECT banking.user FROM banking LEFT JOIN users ON '.
'banking.user = users.user WHERE '.
'users.system_group = "'.$this->user->group.'" AND '.
'next_week = '.$timestamp;
$query = 'SELECT banking.user FROM banking LEFT JOIN users ON ' .
'banking.user = users.user WHERE ' .
'users.system_group = "' . $this->user->group . '" AND ' .
'next_week = ' . $timestamp;
if ($result = $mysqli->query($query)) {
$count = $result->num_rows;
}
else {
$this->Log('Banking->CountNextWeek: '.$mysqli->error);
$this->Log('Banking->CountNextWeek: ' . $mysqli->error);
}
$mysqli->close();
return [$count, $timestamp];
......@@ -480,14 +488,14 @@ class Banking extends Base {
public function Settings($user) {
$banking = [];
$mysqli = connect_db();
$query = 'SELECT reference, next_week FROM banking WHERE '.
'user = "'.$user.'"';
$query = 'SELECT reference, next_week FROM banking WHERE ' .
'user = "' . $user . '"';
if ($result = $mysqli->query($query)) {
$banking = $result->fetch_assoc();
$result->close();
}
else {
$this->Log('Banking->Settings: '.$mysqli->error);
$this->Log('Banking->Settings: ' . $mysqli->error);
}
$mysqli->close();
return $banking;
......@@ -501,14 +509,14 @@ class Banking extends Base {
$mysqli = connect_db();
// The banking reference needs to be unique so check if it already exists.
$query = 'SELECT reference FROM banking LEFT JOIN users ON '.
'banking.user = users.user WHERE reference = "'.$reference.'" '.
'AND banking.user != "'.$user.'" AND '.$organiser->GroupQuery();
$query = 'SELECT reference FROM banking LEFT JOIN users ON ' .
'banking.user = users.user WHERE reference = "' . $reference . '" ' .
'AND banking.user != "' . $user . '" AND ' . $organiser->GroupQuery();
if ($result = $mysqli->query($query)) {
$count = $result->num_rows;
}
else {
$this->Log('Banking->UniqueReference: '.$mysqli->error);
$this->Log('Banking->UniqueReference: ' . $mysqli->error);
}
$mysqli->close();
return $count === 0;
......
<?php
// Dobrado Content Management System
// Copyright (C) 2016 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
......@@ -51,13 +51,21 @@ class Browser extends Base {
public function Content($id) {
if (!$this->user->loggedIn) return '';
$content = '<form id="upload-form">'.
'Upload a file: <input id="upload-input" name="upload" type="file">'.
'<button class="upload">upload</button>'.
'</form>';
$content = '<form id="browser-upload-form">' .
'<div class="form-spacing">' .
'<label for="browser-upload-input">Upload a file:</label>' .
'<input id="browser-upload-input" name="upload" type="file">' .
'<button id="browser-upload">upload</button>' .
'</div>' .
'<div id="browser-upload-progress"></div>' .
'</form>' .
'<div class="form-spacing">' .
'<label for="browser-search">Search:</label>' .
'<input id="browser-search" type="text">' .
'</div>';
$html_path = $this->user->name === 'admin' ? '/public/' :
'/'.$this->user->name.'/public/';
'/' . $this->user->name . '/public/';
// Display thumbnails for all files in this user's public folder.
if ($handle = opendir($this->PublicDirectory())) {
while (($file = readdir($handle)) !== false) {
......@@ -70,18 +78,19 @@ class Browser extends Base {
$type = $matches[2];
$src = '';
if (in_array(strtolower($type), ['gif', 'jpeg', 'jpg', 'png'])) {
$name .= '_thumb.'.$type;
$name .= '_thumb.' . $type;
if (file_exists($this->PublicDirectory($name))) {
$src = '<img src="'.$html_path.$name.'">';
$src = '<img title = "' . $file . '" src="' . $html_path .
$name . '">';
}
else {
$src = '<b>no thumbnail</b>';
$src = '<b title="' . $file . '">no thumbnail</b>';
}
}
else {
$src = '<b>'.$type.'</b>';
$src = '<b title="' . $file . '">' . $type . '</b>';
}
$content .= $this->ImageContent($src, $html_path.$file);
$content .= $this->ImageContent($src, $html_path . $file);
}
}
}
......@@ -111,9 +120,11 @@ class Browser extends Base {
public function Install($path) {
$this->AppendScript($path, 'dobrado.browser.js', false);
$site_style = ['"",".browser","display","none"',
'"",".upload","float","right"',
'"","#upload-form","padding","20px 0px"',
'"","#upload-form","border-bottom","2px solid #777777"',
'"","#browser-upload","float","right"',
'"","#browser-upload-form","padding","20px 0px"',
'"","#browser-upload-form","border-bottom",' .
'"2px solid #777777"',
'"","#browser-upload-progress","display","none"',
'"",".thumbnail.highlight","background-color","#fffeee"',
'"",".thumbnail.highlight","border","2px solid #cccccc"',
'"",".thumbnail.highlight","padding","5px"',
......@@ -161,7 +172,7 @@ class Browser extends Base {
$type = $matches[2];
unlink($this->PublicDirectory($us_file));
if (in_array(strtolower($type), ['gif', 'jpeg', 'jpg', 'png'])) {
unlink($this->PublicDirectory($name.'_thumb.'.$type));
unlink($this->PublicDirectory($name . '_thumb.' . $type));
}
return ['done' => true];
}
......@@ -170,7 +181,7 @@ class Browser extends Base {
private function UploadFile() {
// First check if the user's upload directory is at capacity.
$handle = popen('/usr/bin/du -sm '.$this->PublicDirectory(), 'r');
$handle = popen('/usr/bin/du -sm ' . $this->PublicDirectory(), 'r');
$size = fgets($handle);
pclose($handle);
if (!preg_match('/^([0-9]+)/', $size, $matches)) {
......@@ -183,7 +194,8 @@ class Browser extends Base {
$max_file_size = $this->user->config->MaxFileSize();
// ['upload']['size'] is given in bytes, MaxFileSize is in megabytes.
if ($_FILES['upload']['size'] > $max_file_size * 1000000) {
return ['error' => 'Upload file is too large. (max '.$max_file_size.'M)'];
return ['error' => 'Upload file is too large. (max ' .
$max_file_size . 'M)'];
}
// Replace spaces in the uploaded file name.
$file = preg_replace('/ /', '_', basename($_FILES['upload']['name']));
......@@ -205,12 +217,12 @@ class Browser extends Base {
}
$tmp = $_FILES['upload']['tmp_name'];
if (!move_uploaded_file($tmp, $path)) {
return ['error' => 'File: '.$file.' was not uploaded.'];
return ['error' => 'File: ' . $file . ' was not uploaded.'];
}
$name .= '_thumb.'.$type;
$name .= '_thumb.' . $type;
$html_path = $this->user->name === 'admin' ? '/public/' :
'/'.$this->user->name.'/public/';
'/' . $this->user->name . '/public/';
$src = '';
if (in_array(strtolower($type), ['gif', 'jpeg', 'jpg', 'png'])) {
......@@ -244,20 +256,19 @@ class Browser extends Base {
$this->ResizeImage($new_width, $new_height, $old_width, $old_height,
$type, $path);
}
// Store the html for the new thumbnail.
$src = '<img src="'.$html_path.$name.'">';
$src = '<img title="' . $file . '" src="' . $html_path . $name . '">';
}
else {
$src = '<b>'.$type.'</b>';
$src = '<b title="' . $file . '">' . $type . '</b>';
}
return ['content' => $this->ImageContent($src, $html_path.$file)];
return ['content' => $this->ImageContent($src, $html_path . $file)];
}
private function ImageContent($src, $image) {
return '<span class="thumbnail hidden">'.$src.
'<span class="filename hidden">'.$image.'</span><br>'.
'<button class="select hidden">select</button>'.
'<button class="remove hidden">remove</button>'.
return '<span class="thumbnail hidden">' . $src .
'<span class="filename hidden">' . $image . '</span><br>' .
'<button class="select hidden">select</button>' .
'<button class="remove hidden">remove</button>' .
'</span>';
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -35,7 +35,7 @@ class Post extends Base {
}
$status = '';
$key = $this->owner.'-'.$this->user->page;
$key = $this->owner . '-' . $this->user->page;
if (isset($_SESSION['post-update'][$key])) {
$post = $_SESSION['post-update'][$key];
if ($post['published'] === 1) {
......@@ -60,8 +60,9 @@ class Post extends Base {
$object = [];
$mysqli = connect_db();
$id = (int)substr($_POST['id'], 9);
$query = 'SELECT title, description, author, category, enclosure, '.
'permalink FROM post WHERE user = "'.$this->owner.'" AND box_id = '.$id;
$query = 'SELECT title, description, author, category, enclosure, ' .
'permalink FROM post WHERE user = "' . $this->owner . '" AND ' .
'box_id = ' . $id;
if ($result = $mysqli->query($query)) {
if ($post = $result->fetch_assoc()) {
$object['editor'] = true;
......@@ -88,77 +89,78 @@ class Post extends Base {
// Set Webaction if a class name is found in the description.
$class = '';
$url = '';
$options = '<option></option><option>like</option>'.
$options = '<option></option><option>like</option>' .
'<option>reply</option><option>share</option>';
if (strpos($post['description'], 'u-like-of') !== false) {
$class = 'u-like-of';
$options = '<option></option>'.
'<option selected="selected">like</option>'.
$options = '<option></option>' .
'<option selected="selected">like</option>' .
'<option>reply</option><option>share</option>';
}
else if (strpos($post['description'], 'u-repost-of') !== false) {
$class = 'u-repost-of';
$options = '<option></option><option>like</option>'.
'<option>reply</option>'.
$options = '<option></option><option>like</option>' .
'<option>reply</option>' .
'<option selected="selected">share</option>';
}
else if (strpos($post['description'], 'u-in-reply-to') !== false) {
$class = 'u-in-reply-to';
$options = '<option></option><option>like</option>'.
'<option selected="selected">reply</option>'.
$options = '<option></option><option>like</option>' .
'<option selected="selected">reply</option>' .
'<option>share</option>';
}
if ($class !== '') {
$regex = '/<a href="(.*)" class="'.$class.'"/i';
$regex = '/<a href="(.*)" class="' . $class . '"/i';
if (preg_match($regex, $post['description'], $match)) {
$url = $match[1];
}
}
// The Extended module uses the name attribute to assign content.
$object['custom'] = '<form id="extended-custom-settings">'.
'<div class="form-spacing">'.
'<label for="post-title-input">Title:</label>'.
'<input id="post-title-input" name="title" type="text" '.
'value="'.htmlspecialchars($post['title']).'" maxlength="180">'.
'</div>'.
'<div class="form-spacing">'.
'<label for="post-author-input">Author:</label>'.
'<input id="post-author-input" name="author" type="text" '.
'value="'.$post['author'].'" maxlength="50">'.
'</div>'.
'<div class="form-spacing">'.
'<label for="post-category-input">Category:</label>'.
'<input id="post-category-input" name="category" type="text" '.
'value="'.htmlspecialchars($post['category']).'" '.
'maxlength="200">'.
'</div>'.
'<div class="form-spacing">'.
'<label for="post-action-url-input">Webaction Url:</label>'.
'<input id="post-action-url-input" name="webactionUrl" '.
'type="text" value="'.$url.'" maxlength="200">'.
'</div>'.
'<div class="form-spacing">'.
'<label for="post-action-type-input">Webaction Type:</label>'.
'<select id="post-action-type-input" name="webactionType">'.
$options.'</select>'.
'</div>'.
'<div class="form-spacing">'.
'<label for="post-twitter-input">Send to Twitter:</label>'.
'<input id="post-twitter-input" name="twitter" type="checkbox"'.
$twitter_checked.'>'.
'</div>'.
'<div class="form-spacing">'.
'<label for="post-facebook-input">Send to Facebook:</label>'.
'<input id="post-facebook-input" name="facebook" type="checkbox"'.
$facebook_checked.'>'.
'</div>'.
'<button type="submit">Submit</button>'.
$object['custom'] = '<form id="extended-custom-settings">' .
'<div class="form-spacing">' .
'<label for="post-title-input">Title:</label>' .
'<input id="post-title-input" name="title" type="text" ' .
'value="' . htmlspecialchars($post['title']) . '" ' .
'maxlength="180">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-author-input">Author:</label>' .
'<input id="post-author-input" name="author" type="text" ' .
'value="' . $post['author'] . '" maxlength="50">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-category-input">Category:</label>' .
'<input id="post-category-input" name="category" type="text" ' .
'value="' . htmlspecialchars($post['category']) . '" ' .
'maxlength="200">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-action-url-input">Webaction Url:</label>' .
'<input id="post-action-url-input" name="webactionUrl" ' .
'type="text" value="' . $url . '" maxlength="200">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-action-type-input">Webaction Type:</label>' .
'<select id="post-action-type-input" name="webactionType">' .
$options . '</select>' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-twitter-input">Send to Twitter:</label>' .
'<input id="post-twitter-input" name="twitter" type="checkbox"' .
$twitter_checked . '>' .
'</div>' .
'<div class="form-spacing">' .
'<label for="post-facebook-input">Send to Facebook:</label>' .
'<input id="post-facebook-input" name="facebook" type="checkbox"' .
$facebook_checked . '>' .
'</div>' .
'<button type="submit">Submit</button>' .
'</form>';
}
$result->close();
}
else {
$this->Log('Post->Callback: '.$mysqli->error);
$this->Log('Post->Callback: ' . $mysqli->error);
}
$mysqli->close();
return $object;
......@@ -254,7 +256,7 @@ class Post extends Base {
'<time class="dt-deleted" datetime="' . $atom_date . '">' .
'<a href="' . $permalink_url . '" class="u-url">' .
$formatted_date . '</a>'.
'</time></div>'.
'</time></div>' .
'<div class="p-name e-content">' . $description . '</div>' .
'</article>';
}
......@@ -370,9 +372,9 @@ class Post extends Base {
$permalink = '';
$timestamp = 0;
$mysqli = connect_db();
$query = 'SELECT title, description, author, category, enclosure, '.
'permalink, timestamp FROM post WHERE user = "'.$old_owner.'" AND '.
'box_id = '.$old_id;
$query = 'SELECT title, description, author, category, enclosure, ' .
'permalink, timestamp FROM post WHERE user = "' . $old_owner . '" AND ' .
'box_id = ' . $old_id;
if ($result = $mysqli->query($query)) {
if ($post = $result->fetch_assoc()) {
$title = $mysqli->escape_string($post['title']);
......@@ -386,14 +388,15 @@ class Post extends Base {
$result->close();
}
else {
$this->Log('Post->Copy 1: '.$mysqli->error);
$this->Log('Post->Copy 1: ' . $mysqli->error);
}
// Point the new module at the existing permalink page.
$query = 'INSERT INTO modules VALUES ("'.$this->owner.'", '.
'"'.$permalink.'", '.$id.', "post", "'.$this->Group().'", '.
$this->user->config->PermalinkOrder().', "'.$this->Placement().'", 0)';
$query = 'INSERT INTO modules VALUES ("' . $this->owner . '", ' .
'"' . $permalink . '", ' . $id . ', "post", "' . $this->Group() . '", ' .
$this->user->config->PermalinkOrder() . ', ' .
'"' . $this->Placement() . '", 0)';
if (!$mysqli->query($query)) {
$this->Log('Post->Copy 2: '.$mysqli->error);
$this->Log('Post->Copy 2: ' . $mysqli->error);
}
$mysqli->close();
......@@ -416,7 +419,7 @@ class Post extends Base {
$result->close();
}
else {
$this->Log('Post->Cron 1: '.$mysqli->error);
$this->Log('Post->Cron 1: ' . $mysqli->error);
}
$base_url = $this->user->config->Secure() ? 'https://' : 'http://';
$base_url .= $this->user->config->ServerName();
......@@ -425,7 +428,7 @@ class Post extends Base {
$us_target = $webmention['target'];
$full_target = $us_target;
if (stripos($full_target, 'http') !== 0) {
$full_target = $base_url.$us_target;
$full_target = $base_url . $us_target;
}
list($this->user->page, $this->owner) = page_owner($full_target);
$result = $this->ProcessReceivedWebmention($us_source, $us_target);
......@@ -438,13 +441,13 @@ class Post extends Base {
if (!in_array($us_target, $already_sent)) {
$full_target = $us_target;
if (stripos($full_target, 'http') !== 0) {
$full_target = $base_url.$us_target;
$full_target = $base_url . $us_target;
}
list($this->user->page, $this->owner) = page_owner($full_target);
if ($this->IsPermalink()) {
$query = 'SELECT box_id, description, category, feed FROM post '.
'WHERE user = "'.$this->owner.'" AND '.
'permalink = "'.$this->user->page.'"';
$query = 'SELECT box_id, description, category, feed FROM post ' .
'WHERE user = "' . $this->owner . '" AND ' .
'permalink = "' . $this->user->page . '"';
if ($result = $mysqli->query($query)) {
if ($post = $result->fetch_assoc()) {
$this->ContentUpdated($post['box_id'], $post['description'],
......@@ -454,7 +457,7 @@ class Post extends Base {
$result->close();
}
else {
$this->Log('Post->Cron 2: '.$mysqli->error);
$this->Log('Post->Cron 2: ' . $mysqli->error);
}
}
$already_sent[] = $us_target;
......@@ -462,17 +465,17 @@ class Post extends Base {
}
$query = 'DELETE FROM post_queue';
if (!$mysqli->query($query)) {
$this->Log('Post->Cron 3: '.$mysqli->error);
$this->Log('Post->Cron 3: ' . $mysqli->error);