Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bpierre committed Jun 27, 2011
1 parent d736079 commit a6e5f4b
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 54 deletions.
39 changes: 0 additions & 39 deletions admin/pages/list.php

This file was deleted.

File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config-example.php
@@ -1,5 +1,5 @@
<?php
define('SCRICH_URL', 'http://192.168.1.29/scri.ch/');
define('SCRICH_URL', 'http://localhost/scri.ch/');
define('DB_DSN', 'mysql:dbname=scrich;host=localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
Expand Down
Binary file removed favicon.ico
Binary file not shown.
3 changes: 1 addition & 2 deletions admin/index.php → gallery/index.php
@@ -1,6 +1,5 @@
<?php
require_once '../lib/scrich.php';
require_once SCRICH_ROOT.'/lib/draw_model.php';

$draw_m = new DrawModel();

Expand All @@ -15,4 +14,4 @@
$draws_count = $draw_m->get_count();
$nb_pages = (int)ceil($draws_count/$draws_by_page);

include SCRICH_ROOT.'/admin/pages/list.php';
include_once './template.php';
39 changes: 39 additions & 0 deletions gallery/template.php
@@ -0,0 +1,39 @@
<?php if (!defined('SCRICH_VERSION')) { header('HTTP/1.0 403 Forbidden'); exit; } ?>
<?php
function tpl_pagination() {
global $page, $nb_pages;
echo '<p class="pagination">';
if ($page > 1) {
echo '<a href="'. SCRICH_URL . 'gallery/?p='. ($page-1) .'" class="prev">Previous</a>';
}
if ($page < $nb_pages) {
echo '<a href="' . SCRICH_URL.'gallery/?p='. ($page+1) .'" class="next">Next</a>';
}
echo '</p>';
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>scri.ch - Gallery</title>
<link rel="stylesheet" href="<?php echo SCRICH_URL ?>assets/admin.css?<?php echo SCRICH_VERSION ?>">
<link rel="icon" type="image/png" href="<?php echo SCRICH_URL ?>assets/favicon.png">
<link rel="apple-touch-icon" href="<?php echo SCRICH_URL ?>assets/apple-touch-icon.png">
</head>
<body>
<h1>Drawings - <?php echo $page ?>/<?php echo $nb_pages ?> - (total <?php echo $draws_count ?>)</h1>
<?php tpl_pagination(); ?>
<ul id="draw-list">
<?php foreach ($draws as $draw): ?>
<li>
<h2>/<?php echo $draw->short_id ?> <span>(<?php echo date("G:i j/m/Y", strtotime($draw->date)) ?>)</span></h2>
<a href="<?php echo SCRICH_URL.$draw->short_id ?>">
<img src="<?php echo SCRICH_URL.$draw->short_id ?>.png">
</a>
</li>
<?php endforeach ?>
</ul>
<?php tpl_pagination(); ?>
</body>
</html>
2 changes: 0 additions & 2 deletions index.php
@@ -1,5 +1,3 @@
<?php

require_once './lib/scrich.php';

scrich_init();
File renamed without changes.
20 changes: 14 additions & 6 deletions lib/scrich.php
Expand Up @@ -3,7 +3,14 @@
define('SCRICH_ROOT', realpath(__DIR__ . '/..'));

require_once SCRICH_ROOT.'/config.php';
require_once SCRICH_ROOT.'/lib/draw_model.php';
require_once SCRICH_ROOT.'/lib/draw-model.php';

function serve_image($img) {
header("Content-type: image/png");
header('Content-Length: ' . filesize($img));
readfile($img);
exit;
}

function scrich_init() {
global $cur_img, $title;
Expand All @@ -21,12 +28,13 @@ function scrich_init() {

// Direct image
if (preg_match('/^[a-z0-9]+\.png$/', $request) && file_exists('draws/'.$request)) {
header("Content-type: image/png");
header('Content-Length: ' . filesize('draws/'.$request));
readfile('draws/'.$request);
exit();
serve_image('draws/'.$request);

} elseif ($request === '404.png') {
serve_image('assets/404.png');

} else {

$draw_m = new DrawModel();

// Get drawing
Expand All @@ -42,6 +50,6 @@ function scrich_init() {
}

// Include template
include_once SCRICH_ROOT.'/pages/draw.php';
include_once SCRICH_ROOT.'/lib/template.php';
}
}
9 changes: 5 additions & 4 deletions pages/draw.php → lib/template.php
@@ -1,3 +1,4 @@
<?php if (!defined('SCRICH_VERSION')) { header('HTTP/1.0 403 Forbidden'); exit; } ?>
<!doctype html>
<!--
Expand Down Expand Up @@ -33,9 +34,9 @@
<title><?php if (isset($title)) { echo $title . ' | '; } ?>scri.ch</title>
<meta name="description" content="scri.ch is a website that lets you draw.">
<meta name="keywords" content="scrich">
<link rel="stylesheet" href="<?php echo SCRICH_URL ?>css/scrich.css?<?php echo SCRICH_VERSION ?>">
<link rel="icon" type="image/png" href="<?php echo SCRICH_URL ?>favicon.png">
<link rel="apple-touch-icon" href="<?php echo SCRICH_URL ?>apple-touch-icon.png">
<link rel="stylesheet" href="<?php echo SCRICH_URL ?>assets/scrich.css?<?php echo SCRICH_VERSION ?>">
<link rel="icon" type="image/png" href="<?php echo SCRICH_URL ?>assets/favicon.png">
<link rel="apple-touch-icon" href="<?php echo SCRICH_URL ?>assets/apple-touch-icon.png">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;">
<style><?php if ($cur_img): ?>#save{display:none;}<?php else: ?>#buttons button,#about{display:none;}<?php endif; ?></style>
</head>
Expand All @@ -50,6 +51,6 @@
<?php if ($cur_img): ?>
<img id="img" src="<?php echo SCRICH_URL.$cur_img ?>.png" /><?php endif; ?>
<script>var SCRICH_URL = '<?php echo SCRICH_URL ?>';</script>
<script src="<?php echo SCRICH_URL ?>js/scrich<?php if (!DEBUG): ?>-min<?php endif; ?>.js?<?php echo SCRICH_VERSION ?>"></script>
<script src="<?php echo SCRICH_URL ?>assets/scrich<?php if (!DEBUG): ?>-min<?php endif; ?>.js?<?php echo SCRICH_VERSION ?>"></script>
</body>
</html>

0 comments on commit a6e5f4b

Please sign in to comment.