Kaynağa Gözat

Add appid column to notifications table, remove unused code

tags/v2.0
Skylar Ittner 1 yıl önce
ebeveyn
işleme
1a01f67662
4 değiştirilmiş dosya ile 8 ekleme ve 110 silme
  1. 0
    105
      apps/sync_mobile.php
  2. BIN
      database.mwb
  3. 2
    0
      database.sql
  4. 6
    5
      database_upgrade/1.0.1_2.0.sql

+ 0
- 105
apps/sync_mobile.php Dosyayı Görüntüle

@@ -1,105 +0,0 @@
<?php

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

dieifnotloggedin();

use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\QrCode;

if (MOBILE_ENABLED) {

$APPS["sync_mobile"]["title"] = $Strings->get("sync mobile", false);
$APPS["sync_mobile"]["icon"] = "mobile";

if (!is_empty($_GET['delsynccode'])) {
if ($database->has("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['delsynccode']]])) {
$database->delete("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['delsynccode']]]);
}
}

if ($_GET['mobilecode'] == "generate") {
if (!is_empty($_GET['showsynccode']) && $database->has("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['showsynccode']]])) {
$code = $database->get("mobile_codes", 'code', ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['showsynccode']]]);
} else {
$code = strtoupper(substr(md5(mt_rand() . uniqid("", true)), 0, 20));
$database->insert('mobile_codes', ['uid' => $_SESSION['uid'], 'code' => $code]);
}
if (strpos(URL, "http") !== FALSE) {
$url = URL . "mobile/index.php";
} else {
$url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . (($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) ? ":" . $_SERVER['SERVER_PORT'] : "") . URL . "mobile/index.php";
}
$encodedurl = str_replace("/", "\\", $url);
$codeuri = "bizsync://" . $encodedurl . "/" . $_SESSION['username'] . "/" . $code;
$qrCode = new QrCode($codeuri);
$qrCode->setWriterByName('svg');
$qrCode->setSize(550);
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH);
$qrcode = $qrCode->writeDataUri();
$chunk_code = trim(chunk_split($code, 5, ' '));
$lang_done = $Strings->get("done adding sync code", false);
$APPS["sync_mobile"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> '
. $Strings->get("scan sync qrcode", false)
. '</div>'
. <<<END
<style nonce="$SECURE_NONCE">
.margintop-15px {
margin-top: 15px;
}
.mono-chunk {
text-align: center;
font-size: 110%;
font-family: monospace;
}
</style>
<img src="$qrcode" class="img-responsive qrcode" />
<div class="panel panel-default margintop-15px">
<div class="panel-body">
END
. "<b>" . $Strings->get("manual setup", false) . "</b><br /><label>" . $Strings->get("username", false) . ":</label>"
. '<div class="well well-sm mono-chunk">' . $_SESSION['username'] . '</div>'
. "<label>" . $Strings->get("sync key", false) . "</label>"
. <<<END
<div class="well well-sm mono-chunk">$chunk_code</div>
END
. "<label>" . $Strings->get("url", false) . "</label>"
. <<<END
<div class="well well-sm mono-chunk">$url</div>
</div>
</div>
<a class="btn btn-success btn-sm btn-block" href="home.php?page=sync">$lang_done</a>
END;
} else {
$activecodes = $database->select("mobile_codes", ["codeid", "code"], ["uid" => $_SESSION['uid']]);
$content = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . $Strings->get("sync explained", false) . '</div>'
. '<a class="btn btn-success btn-sm btn-block" href="home.php?page=sync&mobilecode=generate">'
. $Strings->get("generate sync", false) . '</a>';
$content .= "<br /><b>" . $Strings->get("active sync codes", false) . ":</b><br />";
$content .= "<div class='list-group'>";
if (count($activecodes) > 0) {
foreach ($activecodes as $c) {
$content .= "<div class='list-group-item mobilekey'><span id=\"mobilecode\">" . trim(chunk_split($c['code'], 5, ' ')) . "</span> <span class='tinybuttons'><a class='btn btn-primary btn-sm' href='home.php?page=sync&mobilecode=generate&showsynccode=" . $c['codeid'] . "'><i class='fa fa-qrcode'></i></a> <a class='btn btn-danger btn-sm' href='home.php?page=sync&delsynccode=" . $c['codeid'] . "'><i class='fa fa-trash'></i></a></span></div>";
}
} else {
$content .= "<div class='list-group-item'>" . $Strings->get("no active codes", false) . "</div>";
}
$content .= "</div>";
$content .= <<<END
<style nonce="$SECURE_NONCE">
.mobilekey {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.mobilekey #mobilecode {
font-family: Ubuntu Mono,monospace;
flex-shrink: 0;
}
</style>
END;
$APPS["sync_mobile"]["content"] = $content;
}
}

BIN
database.mwb Dosyayı Görüntüle


+ 2
- 0
database.sql Dosyayı Görüntüle

@@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench
-- Sat 28 Jul 2018 03:55:27 PM MDT
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering

@@ -301,6 +301,7 @@ CREATE TABLE IF NOT EXISTS `notifications` (
`url` VARCHAR(255) NOT NULL,
`seen` TINYINT(1) NOT NULL DEFAULT 0,
`sensitive` TINYINT(1) NOT NULL,
`appid` VARCHAR(255) NULL,
PRIMARY KEY (`notificationid`, `uid`),
UNIQUE INDEX `notificationid_UNIQUE` (`notificationid` ASC),
INDEX `fk_notifications_accounts1_idx` (`uid` ASC),

+ 6
- 5
database_upgrade/1.0.1_2.0.sql Dosyayı Görüntüle

@@ -14,24 +14,25 @@ ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `notifications` (
`notificationid` INT(11) NOT NULL AUTO_INCREMENT,
`uid` INT(11) NOT NULL,
`notificationid` INT NOT NULL AUTO_INCREMENT,
`uid` INT NOT NULL,
`timestamp` DATETIME NOT NULL,
`title` VARCHAR(255) NOT NULL,
`content` TINYTEXT NOT NULL,
`url` VARCHAR(255) NOT NULL,
`seen` TINYINT(1) NOT NULL DEFAULT 0,
`sensitive` TINYINT(1) NOT NULL DEFAULT 0,
`sensitive` TINYINT(1) NOT NULL,
`appid` VARCHAR(255) NULL,
PRIMARY KEY (`notificationid`, `uid`),
UNIQUE INDEX `notificationid_UNIQUE` (`notificationid` ASC),
INDEX `fk_notifications_accounts1_idx` (`uid` ASC),
CONSTRAINT `fk_notifications_accounts1`
FOREIGN KEY (`uid`)
REFERENCES `accounthub`.`accounts` (`uid`)
REFERENCES `accounts` (`uid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
DEFAULT CHARACTER SET = utf8;


SET FOREIGN_KEY_CHECKS = 0;

Loading…
İptal
Kaydet