Skip to content

Commit

Permalink
Merge pull request #7 from TiagoDGomes/dev
Browse files Browse the repository at this point in the history
Version 2.5
  • Loading branch information
TiagoDGomes authored Oct 17, 2024
2 parents e3e4d09 + db53942 commit f3b9bac
Show file tree
Hide file tree
Showing 29 changed files with 545 additions and 221 deletions.
4 changes: 3 additions & 1 deletion classes/AccessCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ public static function hasQRCode(){
public static function isSystemMessageActive(){
return FALSE;
}

public static function inListMode(){
return isset($_GET['l']);
}
public static function isValidPage() {
return Database::isValidDatabase();
}
Expand Down
39 changes: 6 additions & 33 deletions classes/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,18 @@ public static function getCurrentPathStyle(){

}
public static function getStyleURL($style, $admin=FALSE){
$url = "?i=" . $_GET['i'] . "&s=" . $style;
$url = "?i=" . $_GET['i'];
if ($style){
$url .= "&s=" . $style;
}
if ($admin){
$url .= "&g=" . $_GET['g'];
}
return $url;
}
public static function HTMLMenu(){
echo '<hr>';
Style::HTMLMenuItems('media/custom', FALSE);
if (AccessCheck::isValidAdminPage()){
echo '<hr>';
Style::HTMLMenuItems('media/custom-admin', TRUE);
}
}
public static function HTMLMenuItems($path, $admin=FALSE){
global $HIDE_STYLES;
$files = array_diff(scandir($path), array('..', '.'));
foreach ($files as $file){
if (in_array($file, $HIDE_STYLES)){
//
} else {
if (file_exists("$path/$file/$file.png")){
$style_in_line = "background-image: url($path/$file/$file.png);";
} else if (file_exists("$path/$file/$file.svg")){
$style_in_line = "background-image: url($path/$file/$file.svg);";
} else {
$style_in_line = '';
}
?>

<div class="item selector">
<a title="<?=$file?>" href="<?= Style::getStyleURL($file,$admin) ?>"><i style="<?= $style_in_line ?>" class="icon <?= $file ?>"></i></a>
</div>

<?php
}

}
}


public static function getCurrentStyle(){
return @$_GET['s'];
}
Expand Down
47 changes: 47 additions & 0 deletions classes/Toolbar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
class Toolbar {

public static function HTMLMenu(){
if (AccessCheck::isValidAdminPage()){
Toolbar::HTMLLinkAnchor('javascript:edit()','Editar','edit','');
Toolbar::HTMLLinkAnchor('javascript:save()','Salvar','save','');
echo '<hr>';
Toolbar::HTMLLinkAnchor(Style::getStyleURL('',TRUE),'','','');
Toolbar::HTMLMenuItems('media/custom-admin', TRUE);
}
echo '<hr>';
Toolbar::HTMLMenuItems('media/custom', FALSE);
}

public static function HTMLLinkAnchor($url, $title, $class, $style_in_line){
?>

<div class="item <?= $class ?>">
<a title="<?= $title ?>" href="<?= $url ?>">
<i style="<?= $style_in_line ?>" class="icon <?= $class ?>"></i>
</a>
</div>

<?php
}

public static function HTMLMenuItems($path, $admin=FALSE){
global $HIDE_STYLES;
$files = array_diff(scandir($path), array('..', '.'));
foreach ($files as $file){
if (in_array($file, $HIDE_STYLES)){
//
} else {
if (file_exists("$path/$file/$file.png")){
$style_in_line = "background-image: url($path/$file/$file.png);";
} else if (file_exists("$path/$file/$file.svg")){
$style_in_line = "background-image: url($path/$file/$file.svg);";
} else {
$style_in_line = '';
}
$url = Style::getStyleURL($file,$admin);
Toolbar::HTMLLinkAnchor($url,$file,$file, $style_in_line);
}
}
}
}
12 changes: 11 additions & 1 deletion config.php-default
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ $ID_LENGTH = 12;
$HIDE_STYLES = array('blank');

// Número de pings para fazer a sincronização:
$SYNC_PING_COUNT = 4;
$SYNC_PING_COUNT = 4;

// Tags permitidas no editor
$ALLOW_TAGS = array(
'<span>','<p>','<br>','<div>',
'<strong>','<b>',
'<i>','<em>',
'<u>','<del>',
'<ul>','<ol>','<li>',
'<blockquote>','<hr>'
);
1 change: 1 addition & 0 deletions core/classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require_once 'classes/Filter.php';
require_once 'classes/Database.php';
require_once 'classes/Timer.php';
require_once 'classes/Toolbar.php';
require_once 'classes/Style.php';


12 changes: 11 additions & 1 deletion core/core.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$APP_VERSION = "2.4";
$APP_VERSION = "2.5";
$APP_TITLE = "Painel";

define('PCORE', true);
Expand All @@ -24,6 +24,16 @@
if (!isset($HIDE_STYLES)){
$HIDE_STYLES = array();
}
if (!isset($ALLOW_TAGS)){
$ALLOW_TAGS = array(
'<span>','<p>','<br>','<div>',
'<strong>','<b>',
'<i>','<em>',
'<u>','<del>',
'<ul>','<ol>','<li>',
'<blockquote>','<hr>'
);
}


require_once 'classes.php';
Expand Down
9 changes: 7 additions & 2 deletions core/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@
"INSERT INTO props (prop_name, prop_value) VALUES ('timer-end', NULL)",
"INSERT INTO props (prop_name, prop_value) VALUES ('message-title', '')",
"INSERT INTO props (prop_name, prop_value) VALUES ('message-content', '')",
"INSERT INTO props (prop_name, prop_value) VALUES ('system-message', '0')",

"INSERT INTO props (prop_name, prop_value) VALUES ('system-message', '0')",
);

Database::setGlobalDatabase($NEW_ID);
Database::startInstance();
Database::beginTransaction();
Database::executeQueries($queries);


$query = "INSERT OR REPLACE INTO props (prop_name, prop_value) VALUES ('text-content', ?)";
$params = array(file_get_contents('core/template.html'));
Database::execute($query, $params);

Database::commit();
HTTPResponse::redirect("?i=$NEW_ID&g=$NEW_ADMIN");
exit();
10 changes: 8 additions & 2 deletions core/set.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?php if (!defined('PCORE')) die("Nope");

require_once 'core.php';
switch ($_GET['prop_name']){

switch (@$_GET['prop_name']){
case 'timer-prepared':
Timer::setPreparedTime($_GET['prop_value']);
break;
case 'timer-start':
Timer::start($_GET['prop_value']);

break;
case 'text-content':
break;
}
if (isset($_POST['text-content'])){
Property::set('text-content', strip_tags($_POST['text-content'], $ALLOW_TAGS));
}

require_once 'info.php';
Expand Down
21 changes: 21 additions & 0 deletions core/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<p style="text-align:center">[ss] [pause]</p>
<p style="text-align:center">[0:30] [1:00] [1:30] [2:00] [3:00] [4:00] [5:00] [10:00] [15:00]</p>
<br><br><hr>
<p style="text-align:center">
Para alterar o tempo dos botões ou adicionar textos adicionais,
clique no botão "Editar" localizado na barra de ferramentas.
</p>
<hr>
<p>
Todos os exemplos:
<br>
[iniciar] : Botão iniciar sem o label de tempo atual
<br>
[ss]: Botão iniciar com o label de tempo atual
<br>
[2:30]: Botão de preparar tempo em minutos e segundos
<br>
[90]: Botão de preparar tempo em segundos (conversão automática)
<br>
[pause]: Botão para pausar o tempo (ele fica oculto caso já esteja pausado)
</p>
117 changes: 33 additions & 84 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,47 @@
<script>
var GLOBAL_ID = '<?= $_GET['i'] ?>';
var CURRENT_URL = window.location.href;
var SYNC_PING_COUNT = <?= $SYNC_PING_COUNT * 1 ?>;
var SYNC_PING_COUNT = <?= $SYNC_PING_COUNT * 1 ?>;
var originalTextContent = <?= json_encode(Property::get('text-content'), JSON_PRETTY_PRINT) ?> ;
</script>

<script src="scripts/default.js?v=<?= @$APP_VERSION ?>"></script>
<script src="scripts/classes.js?v=<?= @$APP_VERSION ?>"></script>
<script src="scripts/qrcode.js?v=<?= @$APP_VERSION ?>"></script>
<?php if (AccessCheck::isValidAdminPage()) : ?>

<script src="scripts/nicEdit/nicEdit.js"></script>
<script src="scripts/admin.js?v=<?= @$APP_VERSION ?>"></script>

<?php endif; ?>

</head>
<body class="<?= Style::getCurrentStyle() . ' ' . (AccessCheck::isValidAdminPage() ? 'admin': '') ?>">
<body class="<?= Style::getCurrentStyle() . ' ' . (AccessCheck::isValidAdminPage() ? 'admin': '') . ' ' . (AccessCheck::inListMode() ? 'list' : '') ?>">
<div id="main">
<div id="visible" style="display:none">

<div class="container-timer">
<div id="timer"></div>
</div>

</div>

<div class="container-timer-spacing"></div>

<div class="container-toolbar">

<div class="item full-screen">
<a title="Mostrar em tela inteira" href="javascript:fullScreen();"><i class="icon full-screen"></i></a>
</div>
<?php Toolbar::HTMLLinkAnchor('javascript:fullScreen()','Mostrar em tela inteira','full-screen',''); ?>

<div class="item qrcode">
<a title="Mostrar QRCode" href="javascript:alternarQRCode();"><i class="icon qrcode"></i></a>
</div>
<?php Toolbar::HTMLLinkAnchor('javascript:alternarQRCode()','Mostrar QRCode','qrcode',''); ?>

<?php if (AccessCheck::isValidAdminPage()): ?>

<?php Style::HTMLMenu(); ?>
<?php Toolbar::HTMLMenu(); ?>

<?php endif; ?>

<?php endif; ?>

</div>



<?php if (AccessCheck::isSystemMessageActive()): ?>

<div class="container-title">
Expand All @@ -60,78 +69,17 @@
<?php endif; ?>

<?php if (AccessCheck::isValidAdminPage()): ?>

<!--<admin>-->

<div class="container-admin">
<p>
<div class="timer-buttons command-buttons">
<button onclick="Timer.start()" class="big green start">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">▶️</span>
</button>
<button onclick="Timer.prepareTime(Timer.getRemainingSeconds())" class="big pause">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text"><i class="icon pause"></i></span>
</button>
<div class="container-admin">
<div class="textView"></div>

<div class="textEdit" style="visibility:hidden">
<textarea style="width: 100%" id="nEditor"><?= Property::get('text-content') ?></textarea>
</div>
<div class="timer-buttons prepare-buttons">
<button onclick="Timer.prepareTime(30)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">0:30</span>
</button>
<button onclick="Timer.prepareTime(60)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">1:00</span>
</button>
<button onclick="Timer.prepareTime(90)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">1:30</span>
</button>
<button onclick="Timer.prepareTime(120)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">2:00</span>
</button>
<button onclick="Timer.prepareTime(180)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">3:00</span>
</button>
<button onclick="Timer.prepareTime(240)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">4:00</span>
</button>
<button onclick="Timer.prepareTime(300)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">5:00</span>
</button>
<button onclick="Timer.prepareTime(600)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">10:00</span>
</button>
<button onclick="Timer.prepareTime(900)" class="big">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">15:00</span>
</button>
</div>
<div class="timer-buttons">
<button style="display: none" onclick="window.open('?i=<?= $_GET['i'] ?>')" class="big blue">
<span class="shadow"></span>
<span class="edge"></span>
<span class="front text">Tela inteira</span>
</button>
</div>
</div>

</div>

<!--</admin>-->

<?php else: ?>
Expand All @@ -150,7 +98,8 @@
</div>
<div class="container-debug">
<pre id="debug"><?php // var_dump($_SERVER); ?></pre>
</div>
</div>

</div>
</body>
</html>
Binary file added media/beep.mp3
Binary file not shown.
8 changes: 8 additions & 0 deletions media/blank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f3b9bac

Please sign in to comment.