1
0
Fork 0

Initial Commit

Yay!
master
Ambrose Chua 2013-11-19 14:06:37 +08:00
parent dde7cced07
commit 686f6818ce
29 changed files with 2592 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
startup*.png, config-*.php

11
admin/checkadminlogin.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$obj = json_decode(stripslashes(($_COOKIE["adminlogin"])), true);
$shaedpass = sha1(ADMIN_PASSWORD);
if ($obj["username"] == ADMIN_USERNAME && $obj["password"] == $shaedpass) {
}
else {
header("Location: login.php");
exit();
}
?>

148
admin/index.php Normal file
View File

@ -0,0 +1,148 @@
<?php
require_once '../config.php';
include 'checkadminlogin.php';
include '../plugins/parsedown/Parsedown.php';
$allok = 2;
$txt=$_POST["txt"];
$tim=$_POST["tim"];
$txt = preg_replace("#((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie", "'<a href=\"$1\" target=\"_blank\">http://$3</a>$4'", $txt);
$txt = Parsedown::instance()->parse($txt);
if (isset($_FILES["file"])) {
$allok = 0;
$uploadLocation = "../" . UPLOAD_LOCATION . "";
$config['max_size'] = "100000000";
$target_path = $uploadLocation;
$extrl = " ";
$seperator = "-";
// $rndno=rand();
$rndno = substr(md5_file($_FILES['file']['tmp_name']), 0, 7);
if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path.$rndno.$seperator.$_FILES["file"]["name"])) { //.$_FILES["file"]["name"]
$fileurl = UPLOAD_LOCATION.$rndno.$seperator.$_FILES['file']['name'];
$filephp = "image.php?url=".$rndno.$seperator.$_FILES['file']['name'];
$extrl = '<br /><br /><a href="'.$fileurl.'" target="_blank"><img class="pim" src="'.$filephp.'" /></a>';
}
else{
die("File upload error");
}
}
if (isset($_POST["txt"]) && isset($_POST["tim"])) {
include "../connect.php";
$mysql_table = MYSQL_TABLE;
$qry = "INSERT INTO `$mysql_table` (`id`, `txt`, `tim`) VALUES (NULL, '".mysql_escape_string(nl2br($txt.$extrl))."', '".mysql_escape_string($tim)."')";
$result = mysql_query($qry);
if (!$result) {
die("Error! ".mysql_error());
} else {
$allok = 1;
}
mysql_close($link);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>Create post</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="icon" type="image/png" href="http://ambc.net16.net/images/icon.png" />
<link rel="apple-touch-icon-precomposed" href="http://ambc.net16.net/images/iconH.png" />
<link rel="stylesheet" href="../css/tinystyles.css" />
</head>
<body>
<div class="statusbarpadd">&nbsp;</div>
<h1>Create post<?php
if ($allok == 2) {
echo '';
}
else if ($allok == 1) {
echo ' <span class="red">Sent</span>';
}
else {
echo ' <span class="red">Error</span>';
}
?></h1>
<form id="pform" method="post" enctype="multipart/form-data" action="index.php" onSubmit="clearInterval(inter); ">
<input type="file" value="Attach Photo" name="file" id="file" />
<textarea name="txt" placeholder="Post"></textarea><br />
<input type="text" name="tim" placeholder="12:12:12 PM - 12/12/12" value="12:12:12 PM - 12/12/12" id="time" />
<input type="submit" value="Post! " />
</form>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
inter=setInterval(function() {
h=new Date().getHours();
m=new Date().getMinutes();
s=new Date().getSeconds();
da=new Date().getDate();
mo=new Date().getMonth()+1;
ye=new Date().getFullYear();
if (mo==1) {
mon="January";
}
else if (mo==2) {
mon="Febuary";
}
else if (mo==3) {
mon="March";
}
else if (mo==4) {
mon="April";
}
else if (mo==5) {
mon="May";
}
else if (mo==6) {
mon="June";
}
else if (mo==7) {
mon="July";
}
else if (mo==8) {
mon="August";
}
else if (mo==9) {
mon="September";
}
else if (mo==10) {
mon="October";
}
else if (mo==11) {
mon="November";
}
else if (mo==12) {
mon="December";
}
pa="AM";
hn=h;
if (h>12) {
pa="PM";
hn=h-12;
}
document.getElementById("time").value=hn+":"+m+":"+s+" "+pa+" - "+da+" "+mon+" "+ye;
}, 100);
$("#pform").submit(function() {
$("#pform").append("<div class='loading'>&nbsp;</div>");
});
if (window.navigator.standalone == true) {
$(".statusbarpadd").css("display", "block");
}
if (window.screen.height==568) { // iPhone 4"
document.querySelector("meta[name=viewport]").content="width=320.1, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0";
}
</script>
</body>
</html>

44
admin/login.php Normal file
View File

@ -0,0 +1,44 @@
<?php
require_once '../config.php';
$sttype=0;
if (isset($_POST["un"]) && isset($_POST["ps"])) {
$sttype=1;
if ($_POST["un"] == ADMIN_USERNAME && $_POST["ps"] == ADMIN_PASSWORD) {
$sttype=2;
}
} else {
$sttype=3;
}
if ($sttype!=2) {
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>Please login to admin</title>
<link rel="stylesheet" href="../css/tinystyles.css" />
</head>
<body>
<div class="statusbarpadd">&nbsp;</div>
<h1>Please login to admin</h1>
<form method="post" action="login.php" class="login">
<input type="text" name="un" placeholder="Username" /><br />
<input type="password" name="ps" placeholder="Password" /><input type="submit" value="Login" />
</form>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
if (window.navigator.standalone == true) {
$(".statusbarpadd").css("display", "block");
}
</script>
</body>
</html>
<?php
} else if ($sttype==2) {
$shaedpass = sha1($_POST["ps"]);
$arr = array('username' => $_POST["un"], 'password' => $shaedpass);
setcookie("adminlogin", json_encode($arr), time()+86400);
header("Location: index.php");
}
?>

14
checklogin.php Normal file
View File

@ -0,0 +1,14 @@
<?php
$obj = json_decode(stripslashes(($_COOKIE["viewerlogin"])), true);
$shaedpass = sha1(VIEWER_PASSWORD);
if (
($obj["username"] == VIEWER_USERNAME && $obj["password"] == $shaedpass)
|| !USE_VIEWER
) {
}
else {
header("Location: login.php");
exit();
}
?>

31
config-sample.php Normal file
View File

@ -0,0 +1,31 @@
<?php
define('VIEWER_USERNAME','viewer');
define('VIEWER_PASSWORD','viewer');
define('USE_VIEWER', false); // Need viewers to log in?
define('UPLOAD_LOCATION', "uploads/");
define('ADMIN_USERNAME','admin');
define('ADMIN_PASSWORD','admin123');
define('DISQUS_SHORTNAME','YOUR DISQUS_SHORTNAME');
define('DISQUS_INITIAL_IDENTIFIER','homepg');
define('MYSQL_HOST', "localhost");
define('MYSQL_USERNAME', "DATABASE USRNAME");
define('MYSQL_PASSWORD', "DATABASE PASSWORD");
define('MYSQL_DATABASE', "DATABASE to store in");
define('MYSQL_TABLE', "microblog");
define('MBLOG_TITLE', "BLOG TITLE");
define('MBLOG_SUBTITLE', '
Source on <a href="https://github.com/ambrosechua/picobloggingsys">github</a>
');
define('MBLOG_DESC', '
<p>
BLOG DESCRIPTION
</p>');
define('MBLOG_PULLEY_TEXT', "What's this?");
define('MBLOG_TOOLTIPS_TEXT', "Tap post to comment and like. :)");
?>

10
connect.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$link = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD);
if(!$link) {
die("Failed to connect to mysql server. ");
}
$db = mysql_select_db(MYSQL_DATABASE);
if(!$db) {
die("Unable to select database. ");
}
?>

BIN
css/LondrinaSolid.ttf Executable file

Binary file not shown.

1
css/NOTICE.md Normal file
View File

@ -0,0 +1 @@
back.png is refrenced in script in index.php line 180.

BIN
css/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
css/bg.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

47
css/likebtnstyles.css Normal file
View File

@ -0,0 +1,47 @@
@import url(http://fonts.googleapis.com/css?family=Londrina+Solid);
* {
padding: 0;
margin: 0;
}
body, html {
width: 100%;
background-size: 100px 100px;
font-family: "Londrina Solid";
font-size: 12px;
text-align: right;
}
.btn, .btnm {
letter-spacing:1px;
font-family: "Londrina Solid";
background-color: rgba(0, 0, 0, 0.5) ;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border: 0;
padding: 5px 8px;
color: #eee;
margin: 1px;
font-size: 12px;
-webkit-appearance: none;
}
.btn:hover {
background-color: rgba(0, 0, 0, 0.6);
}
.btn:active {
background-color: rgba(0, 0, 0, 0.7);
}
.btnm {
display: inline-block;
border-bottom-left-radius: 20px;
border-top-left-radius: 20px;
-webkit-border-bottom-left-radius: 20px;
-webkit-border-top-left-radius: 20px;
-moz-border-bottom-left-radius: 20px;
-moz-border-top-left-radius: 20px;
-o-border-bottom-left-radius: 20px;
-o-border-top-left-radius: 20px;
-ms-border-bottom-left-radius: 20px;
-ms-border-top-left-radius: 20px;
}

BIN
css/startupPhone320.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
css/startupPhone640.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

372
css/styles.css Normal file
View File

@ -0,0 +1,372 @@
@import url(http://fonts.googleapis.com/css?family=Londrina+Solid);
* {
padding: 0;
margin: 0;
-webkit-tap-highlight-color: rgba(50, 205, 102, 0.65);
}
body, html {
width: 100%;
background: #aaa url(bg.gif) repeat center center;
background-size: 100px 100px;
font-family: "Londrina Solid", Helvitica;
font-size: 17px;
color: #444;
font-weight: 300;
height: 100%;
text-align: center;
overflow: hidden;
}
::-moz-selection {
background-color: rgba(50, 205, 102, 0.65);
}
::selection {
background-color: rgba(50, 205, 102, 0.65);
}
ul, ol {
padding: 0;
margin: 0;
padding-left: 20px;
}
li {
padding: 0;
margin: 0;
}
a {
color: inherit;
text-decoration: none;
}
#mbinfo a {
color: #ddf;
text-decoration: none;
}
#mbinfo a:hover {
color: #cce;
text-decoration: underline;
}
#mbinfo a:active {
color: #bbd;
text-decoration: underline;
}
h1 {
font-weight: 300;
padding: 5px 20px 0px 20px;
font-size: 30px;
color: #eee;
}
h2 {
font-weight: 300;
padding: 10px 20px 0px 20px;
font-size: 23px;
color: #eee;
}
div#bio {
padding: 0px 10px 0px 10px;
text-align: center;
width: 100%;
}
div#mbinfo {
width: 100%;
background-color: rgba(0, 0, 0, 0.5) ;
color: #ddd;
padding-bottom: 2px;
overflow: hidden;
transition-duration: 1s;
-moz-transition-duration: 1s;
-webkit-transition-duration: 1s;
-o-transition-duration: 1s;
transition-property: height;
-moz-transition-property: height;
-webkit-transition-property: height;
-o-transition-property: height;
height: 1px;
}
div#pulley {
background-color: rgba(0, 0, 0, 0.5) ;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-bottom-right-radius: 5px;
-moz-border-bottom-left-radius: 5px;
-o-border-bottom-right-radius: 5px;
-o-border-bottom-left-radius: 5px;
-ms-border-bottom-right-radius: 5px;
-ms-border-bottom-left-radius: 5px;
text-align: center;
color: #ddd;
width: 150px;
padding: 5px;
margin-right: 5px;
margin-left: auto;
}
#scrollable {
overflow-y: scroll;
overflow-scrolling: touch;
-webkit-overflow-scrolling: touch;
-moz-overflow-scrolling: touch;
-o-overflow-scrolling: touch;
-ms-overflow-scrolling: touch;
position: relative;
height: 100%;
background: #fff;
background: #aaa url(bg.gif) repeat center center;
background-size: 100px 100px;
}
#content {
min-height: 100%;
transform: translateZ(0);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-o-transform: translateZ(0);
-ms-transform: translateZ(0);
max-width: 720px;
text-align: left;
margin: 0 auto;
text-align: left;
}
#floating {
width: 100%;
position: absolute;
top: 0px;
z-index: 10;
}
.posts {
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
margin: 20px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
transition: all 1s;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-o-transition: all 1s;
-ms-transition: all 1s;
display: block;
}
.post {
padding: 10px 10px 11px 10px;
border: 1px solid #333;
border-bottom: none;
background-color: rgba(0, 0, 0, 0.075);
display: block;
width: auto;
transition: 1s background-color;
-webkit-transition: 1s background-color;
-moz-transition: 1s background-color;
-o-transition: 1s background-color;
-ms-transition: 1s background-color;
}
.post:first-child {
border-top-right-radius: 10px;
border-top-left-radius: 10px;
-webkit-top-bottom-right-radius: 10px;
-webkit-top-bottom-left-radius: 10px;
-moz-top-bottom-right-radius: 10px;
-moz-top-bottom-left-radius: 10px;
-o-top-bottom-right-radius: 10px;
-o-top-bottom-left-radius: 10px;
-ms-top-bottom-right-radius: 10px;
-ms-top-bottom-left-radius: 10px;
}
.post:last-child {
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-bottom-right-radius: 10px;
-moz-border-bottom-left-radius: 10px;
-o-border-bottom-right-radius: 10px;
-o-border-bottom-left-radius: 10px;
-ms-border-bottom-right-radius: 10px;
-ms-border-bottom-left-radius: 10px;
border-bottom: 1px solid #333;
}
.post:hover:not(.detail) {
background-color: rgba(0, 0, 0, 0.125);
transition: 1s background-color;
-webkit-transition: 1s background-color;
-moz-transition: 1s background-color;
-o-transition: 1s background-color;
-ms-transition: 1s background-color;
}
.post:active:not(.detail) {
background-color: rgba(0, 0, 0, 0.135);
transition: none;
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
-ms-transition: none;
}
#spacing {
height: 40px;
width: 100%;
}
.t {
padding: 4px 4px 6px 4px;
display: block;
width: auto;
word-wrap: break-word;
}
.i{
font-size: 10px;
text-align: right;
}
.tp {
font-size: 22px;
min-height: 50px;
}
.tp a:link {
color: #226;
text-decoration: none;
}
.tp a:hover {
color: #337;
text-decoration: underline;
}
.tp a:active {
color: #448;
text-decoration: underline;
}
.ip {
font-size: 15px;
}
hr.bfo {
border: none;
height: 1px;
background-color: #333;
margin: 10px 10px 7px 10px;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.6);
}
hr.aft {
border: none;
height: 1px;
background-color: #333;
margin: 0px 10px 20px 10px;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.6);
}
.toptips {
height: auto;
margin: 3px 30px 3px 30px;
padding: 5px;
}
#topbar {
display: block;
}
.backbutton {
height: auto;
padding: 5px 0px 0px 20px;
margin: 0px 30px -6px 30px;
}
.backbutton:hover {
transition: 1s background-color;
-webkit-transition: 1s background-color;
-moz-transition: 1s background-color;
-o-transition: 1s background-color;
-ms-transition: 1s background-color;
background-color: rgba(50, 205, 102, 0.65);
}
.backbutton:active {
transition: 1s background-color;
-webkit-transition: 1s background-color;
-moz-transition: 1s background-color;
-o-transition: 1s background-color;
-ms-transition: 1s background-color;
background-color: rgba(25, 100, 50, 0.70);
}
iframe.like {
height: 30px;
width: 100%;
border: none;
}
.iframeh {
width: auto;
margin: 0px 10px 0px 10px;
}
@keyframes loading {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@-moz-keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@-webkit-keyframes loading {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@-o-keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.loadingh {
text-align: right;
}
.loading {
width: 20px;
height: 20px;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 10px;
border-top-right-radius: 0px;
-webkit-border-radius: 10px;
-webkit-border-top-right-radius: 0px;
-moz-border-radius: 10px;
-moz-border-top-right-radius: 0px;
-o-border-radius: 10px;
-o-border-top-right-radius: 0px;
-ms-border-radius: 10px;
-ms-border-top-right-radius: 0px;
animation: loading 1s infinite;
-webkit-animation: loading 1s infinite;
-moz-animation: loading 1s infinite;
-o-animation: loading 1s infinite;
-ms-animation: loading 1s infinite;
display: inline-block;
margin-right: 5px;
}
.statusbarpadd {
display: none;
height: 20px;
width: 100%;
}
#list img.pim {
width: 150px;
}
#det img.pim {
width: 90%;
}
#det {
display: block;
}
#disqus_thread {
padding: 10px 10px 0px 10px;
}
@media all and (min-width: 750px) {
div#pulley {
margin-right: 100px;
}
}
@media all and (min-width: 950px) {
div#pulley {
margin-right: 200px;
}
}

141
css/tinystyles.css Normal file
View File

@ -0,0 +1,141 @@
@import url(http://fonts.googleapis.com/css?family=Londrina+Solid);
* {
padding: 0;
margin: 0;
}
body, html {
width: 100%;
background: #aaa url(bg.gif) repeat top left;
background-size: 100px 100px;
font-family: "Londrina Solid";
font-size: 17px;
text-align: center;
}
form.login {
text-align: left;
width: 250px;
margin: 10px auto 0 -100px;
position: relative;
left: 50%;
}
h1 {
font-weight: 300;
padding: 5px 20px 0px 20px;
font-size: 30px;
color: #444;
}
input, textarea {
letter-spacing:1px;
font-family: "Londrina Solid";
background-color: rgba(0, 0, 0, 0.5) ;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border: 0;
padding: 10px;
color: #eee;
margin: 3px 5px 3px 5px;
font-size: 17px;
font-width: 15px;
}
textarea {
width: 90%;
height: 200px;
}
input:focus, textarea:focus {
background-color: rgba(0, 0, 0, 0.6);
}
form {
text-align: center;
width: 100%;
}
#time {
width: 170px;
font-size: 12px;
padding-top: 13px;
padding-bottom: 13px;
}
input[type=submit], input[type=file] {
width: 33%;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
-ms-appearance: none;
}
input[type=submit]:hover {
background-color: rgba(0, 0, 0, 0.6);
}
input[type=submit]:active {
background-color: rgba(0, 0, 0, 0.7);
}
input[type=file] {
width: 90%;
padding: 2px 5px;
}
.red {
color: #f00;
font-size: 10px;
}
.statusbarpadd {
display: none;
height: 20px;
width: 100%;
}
@keyframes loading {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@-moz-keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@-webkit-keyframes loading {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@-o-keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.loading {
width: 20px;
height: 20px;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 10px;
border-top-right-radius: 0px;
-webkit-border-radius: 10px;
-webkit-border-top-right-radius: 0px;
-moz-border-radius: 10px;
-moz-border-top-right-radius: 0px;
-o-border-radius: 10px;
-o-border-top-right-radius: 0px;
-ms-border-radius: 10px;
-ms-border-top-right-radius: 0px;
animation: loading 1s infinite;
-webkit-animation: loading 1s infinite;
-moz-animation: loading 1s infinite;
-o-animation: loading 1s infinite;
-ms-animation: loading 1s infinite;
display: inline-block;
margin-right: 5px;
}

33
detail.php Normal file
View File

@ -0,0 +1,33 @@
<?php
require_once 'config.php';
include 'checklogin.php';
include "connect.php";
$mysql_table = MYSQL_TABLE;
$qry="SELECT * FROM `$mysql_table` WHERE `id`='".mysql_escape_string($_GET["id"])."'";
$result=mysql_query($qry);
if($result) {
if(mysql_num_rows($result) == 1) {
$row = mysql_fetch_array($result);
?>
<div class="t tp">
<?php
// $postlinked = preg_replace("#((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie", "' <a href=\"$1\" target=\"_blank\">http://$3</a>$4'", stripslashes($row["txt"]));
// echo $postlinked;
echo stripslashes($row["txt"]);
?>
</div>
<div class="i ip">
at <?php
echo $row["tim"];
?>
</div>
<hr class="bfo" />
<div class="iframeh"><iframe src="like.php?id=<?php echo $_GET["id"]; ?>" class="like"></iframe></div>
<hr class="aft" />
<?php
}
}
mysql_close($link);
?>

19
get.php Normal file
View File

@ -0,0 +1,19 @@
<?php
require_once 'config.php';
include 'checklogin.php';
include "connect.php";
$mysql_table = MYSQL_TABLE;
$qry="SELECT * FROM `$mysql_table` ORDER BY `$mysql_table`.`id` ASC LIMIT ".mysql_escape_string($_GET["lastid"])." , 1000";
$result=mysql_query($qry);
$newlastid=$_GET["lastid"];
$jspo=array();
while ($row = mysql_fetch_array($result)) {
$newlastid=$newlastid+1;
array_push($jspo, array("txt"=>stripslashes($row["txt"]), "tim"=>$row["tim"], "id"=>$row["id"]));
}
echo json_encode(array("posts"=>$jspo, "lastid"=>$newlastid));
mysql_close($link);
?>

89
image.php Normal file
View File

@ -0,0 +1,89 @@
<?php
require_once 'config.php';
$url = str_replace("image.php?".$_SERVER["QUERY_STRING"], "", $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
).UPLOAD_LOCATION.$_GET['url'];
$allowed = array('jpg','gif','png');
$pos = strrpos($url, ".");
$str = substr($url,($pos + 1));
$ch = curl_init();
$timeout = 0;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$image = curl_exec($ch);
curl_close($ch);
// output to browser
$im = @imagecreatefromstring($image);
$tw = @imagesx($im);
if(!$tw){
// Font directory + font name
$font = 'css/LondrinaSolid.ttf';
// Size of the font
$fontSize = 18;
// Height of the image
$height = 80;
// Width of the image
$width = 250;
// Text
$str = 'omg. an error occurred';
$img_handle = imagecreate ($width, $height) or die ("Cannot Create image");
// Set the Background Color RGB
$backColor = imagecolorallocate($img_handle, 100, 100, 100);
// Set the Text Color RGB
$txtColor = imagecolorallocate($img_handle, 200, 200, 200);
$textbox = imagettfbbox($fontSize, 0, $font, $str) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($img_handle, $fontSize, 0, $x, $y, $txtColor, $font , $str) or die('Error in imagettftext function');
header('Content-Type: image/jpeg');
imagejpeg($img_handle,NULL,100);
imagedestroy($img_handle);
}else{
if($str == 'jpg' || $str == 'jpeg')
header("Content-type: image/jpeg");
if($str == 'gif')
header("Content-type: image/gif");
if($str == 'png')
header("Content-type: image/png");
$th = imagesy($im);
$thumbWidth = 585;
if($tw <= $thumbWidth){
$thumbWidth = $tw;
}
$thumbHeight = $th * ($thumbWidth / $tw);
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
if($str == 'gif'){
$colorTransparent = imagecolortransparent($im);
imagefill($thumbImg, 0, 0, $colorTransparent);
imagecolortransparent($thumbImg, $colorTransparent);
}
if($str == 'png'){
imagealphablending($thumbImg, false);
imagesavealpha($thumbImg,true);
$transparent = imagecolorallocatealpha($thumbImg, 255, 255, 255, 127);
imagefilledrectangle($thumbImg, 0, 0, $thumbWidth, $thumbHeight, $transparent);
}
imagecopyresampled($thumbImg, $im, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $tw, $th);
if($str == 'jpg' || $str == 'jpeg'){
imagejpeg($thumbImg, NULL, 75);
}
if($str == 'gif'){
imagegif($thumbImg);
}
if($str == 'png'){
imagealphablending($thumbImg,TRUE);
imagepng($thumbImg, NULL, 9, PNG_ALL_FILTERS);
}
imagedestroy($thumbImg);
}
?>

224
index.php Normal file
View File

@ -0,0 +1,224 @@
<?php
require_once 'config.php';
include 'checklogin.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title><?php echo MBLOG_TITLE; ?></title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="ambc's microblog" />
<link rel="icon" type="image/png" href="http://ambc.net16.net/images/icon.png" />
<link rel="apple-touch-icon-precomposed" href="http://ambc.net16.net/images/iconH.png" />
<link rel="stylesheet" href="plugins/add2home.css" />
<!--
<link rel="apple-touch-startup-image" href="css/startupPhone320.png" media="screen and (max-device-width: 320px)" />
<link rel="apple-touch-startup-image" href="css/startupPhone640.png" media="(max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)" />
-->
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div id="floating">
<div class="statusbarpadd">&nbsp;</div>
<div id="mbinfo">
<h1><?php echo MBLOG_TITLE; ?></h1>
<h2><?php echo MBLOG_SUBTITLE; ?></h2>
<div id="bio">
<?php echo MBLOG_DESC; ?>
</div>
</div>
<div id="pulley"><?php echo MBLOG_PULLEY_TEXT; ?></div>
</div>
<div id="scrollable" class="scrollable">
<div id="content">
<div class="statusbarpadd">&nbsp;</div>
<div id="spacing">&nbsp;</div>
<div id="topbar"><div class="toptips"><?php echo MBLOG_TOOLTIPS_TEXT; ?></div></div>
<div id="list" class="posts">
<?php
include "connect.php";
$mysql_table = MYSQL_TABLE;
$qry="SELECT * FROM `$mysql_table` ORDER BY `$mysql_table`.`id` DESC LIMIT 0, 30 ";
$result=mysql_query($qry);
$iffirst=0;
while ($row = mysql_fetch_array($result)) {
$postlinked = stripslashes($row["txt"]);
echo '<span class="post postid'.$row["id"].'"><div class="t"><span class="loadingh"></span>'.$postlinked.'</div><div class="i">'.$row["tim"].'</div></span>';
if ($iffirst==0) {
$newlastid=$row["id"]+1;
$iffirst=1;
}
}
mysql_close($link);
?>
</div><!--
<br /><br /> -->
<div id="det" class="posts">
<div class="post detail">
<div id="detailp">
</div>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '<?php echo DISQUS_SHORTNAME; ?>'; // required: replace example with your forum shortname
var disqus_identifier = "<?php echo DISQUS_INITIAL_IDENTIFIER; ?>";
var disqus_url = window.location.href.replace("index.php", "");
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
</div>
<div id="spacing">&nbsp;</div>
</div>
</div>
<audio id="audioalert" preload="auto">
<source src="sounds/alert.ogg" type="audio/ogg" />
<source src="sounds/alert.mp3" type="audio/mpeg" />
<source src="sounds/alert.wav" type="audio/x-wav" />
</audio>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var lastid=<?php echo $newlastid; ?>;
var barvisible=true;
if (window.navigator.standalone == true) {
$(".statusbarpadd").css("display", "block");
}
$(window).on("hashchange", function() {
if (window.location.hash.indexOf("#!") > -1) {
godet(window.location.hash.replace("#!", ""));
}
});
if (window.location.hash.indexOf("#!") > -1) {
godet(window.location.hash.replace("#!", ""));
}
document.getElementById("audioalert").load();
$("#pulley").click(function() {
if ($("#pulley").html()=="Tap to close") {
$("#mbinfo").css("height", "1px");
$("#pulley").html("<?php echo MBLOG_PULLEY_TEXT; ?>");
} else {
$("#mbinfo").css("height", "210px");
$("#pulley").html("Tap to close");
}
});
$("#scrollable").scroll(function() {
if ($("#scrollable").scrollTop()>=75) {
newbarvisible=false;
}
else {
newbarvisible=true;
}
if (barvisible != newbarvisible) {
barvisible=newbarvisible;
if (barvisible==false) {
$("#floating").fadeOut("slow");
}
else {
$("#floating").fadeIn("slow");
}
}
});
$("#list").on("click", ".post", function() {
postid=$(this).attr("class");
postid=postid.replace("post postid", "");
window.location.hash="#!"+postid;
// alert("tapped"+postid);
});
function gobac() {
// $("#det").css("display", "none");
$("#list").css("display", "block");
$("#topbar").html('<div class="toptips"><?php echo MBLOG_TOOLTIPS_TEXT; ?></div>');
$("#detailp").html("");
$("#scrollable").scrollTop(lastscroll);
window.location.hash="";
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = "<?php echo DISQUS_INITIAL_IDENTIFIER; ?>";
this.page.url = window.location.href.replace("index.php", "");
}
});
}
function godet(id) {
$("#list .postid"+id+" .loadingh").html("<div class='loading'>&nbsp;</div>");
try {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = id;
this.page.url = window.location.href.replace("index.php", "") + "#!"+id;
}
});
lastscroll=$("#scrollable").scrollTop();
$.ajax({
type: 'GET',
url: 'detail.php?id='+id,
success: exceptiong
});
function exceptiong(data, status){
$("#topbar").html('<a href="javascript: gobac();"><div class="toptips backbutton"><img src="css/back.png" height="30" /></div></a>');
$("#list").css("display", "none");
$("#detailp").html(data);
$("#det").css("display", "block");
$(".loading").remove();
}
}
catch (e) {
setTimeout(function() {
godet(id);
}, 500);
}
}
if (window.screen.height==568) { // iPhone 4"
document.querySelector("meta[name=viewport]").content="width=320.1, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0";
}
if (window.location.hash.indexOf("#!") > -1) {
godet(window.location.hash.replace("#!", ""));
}
setInterval(function() {
$.ajax({
type: 'GET',
url: 'get.php?lastid='+lastid,
dataType: "json",
success: exception
});
function exception(data, status){
lastid=data.lastid;
var nplay=false;
$(data.posts).each(function(index, domele) {
str='<span class="post postid'+this.id+'"><div class="t"><span class="loadingh"></span>'+this.txt+'</div><div class="i">'+this.tim+'</div></span>';
$("#list").prepend(str);
nplay=true;
});
if (nplay==true) {
document.getElementById("audioalert").play();
}
nplay=false;
}
}, 5000);
</script>
<script type="text/javascript">
var addToHomeConfig = {
message: 'Install this as a app: tap %icon and then <strong>Add to Home Screen</strong>. ',
expire: 720,
touchIcon: true,
animationOut: 'bubble',
animationIn: 'bubble'
};
</script>
<script type="text/javascript" src="plugins/add2home.js" charset="utf-8"></script>
</body>
</html>

49
like.php Normal file
View File

@ -0,0 +1,49 @@
<?php
require_once 'config.php';
include 'checklogin.php';
include "connect.php";
$stars=0;
$starred="";
$mysql_table = MYSQL_TABLE;
$qrya="SELECT * FROM `$mysql_table` WHERE `id`='".mysql_escape_string($_GET["id"])."'";
$resulta=mysql_query($qrya);
if($resulta) {
if(mysql_num_rows($resulta) == 1) {
$rowa = mysql_fetch_array($resulta);
$stars=$rowa["pluses"];
}
}
$stars=$stars+1;
if (isset($_GET["plusone"])) {
$qryb="UPDATE `$mysql_table` SET `pluses`='".($stars)."' WHERE `id`='".mysql_escape_string($_GET["id"])."'";
$resultb=mysql_query($qryb);
if($resultb) {
$starred="Thanks for a ★! ";
} else {
$starred="Error! ";
$stars=$stars-1;
}
} else {
$stars=$stars-1;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Like</title>
<link rel="stylesheet" href="css/likebtnstyles.css" />
</head>
<body>
<form action="like.php" method="get">
<input type="hidden" name="id" value="<?php echo $_GET["id"]; ?>" />
<?php echo $starred; ?><input type="submit" name="plusone" class="btn" value="+1 ★" /><span class="btnm"><?php echo $stars; ?></span>
</form>
</body>
</html>

44
login.php Normal file
View File

@ -0,0 +1,44 @@
<?php
require_once 'config.php';
$sttype=0;
if (isset($_POST["un"]) && isset($_POST["ps"])) {
$sttype=1;
if ($_POST["un"] == VIEWER_USERNAME && $_POST["ps"] == VIEWER_PASSWORD) {
$sttype=2;
}
} else {
$sttype=3;
}
if ($sttype!=2) {
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>Please login</title>
<link rel="stylesheet" href="css/tinystyles.css" />
</head>
<body>
<div class="statusbarpadd">&nbsp;</div>
<h1>Please login<sup class="red"><?php if ($sttype == 1) {echo "Incorrect";} ?></sup></h1>
<form method="post" action="login.php" class="login">
<input type="text" name="un" placeholder="Username" /><br />
<input type="password" name="ps" placeholder="Password" /><input type="submit" value="Login" />
</form>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
if (window.navigator.standalone == true) {
$(".statusbarpadd").css("display", "block");
}
</script>
</body>
</html>
<?php
} else if ($sttype==2) {
$shaedpass = sha1($_POST["ps"]);
$arr = array('username' => $_POST["un"], 'password' => $shaedpass);
setcookie("viewerlogin", json_encode($arr), time()+86400);
header("Location: index.php");
}
?>

158
plugins/add2home.css Normal file
View File

@ -0,0 +1,158 @@
/**
*
* Main container
*
*/
#addToHomeScreen {
z-index:9999;
-webkit-user-select:none;
-webkit-box-sizing:border-box;
width:240px;
font-size:15px;
padding:12px 14px;
text-align:left;
font-family:helvetica;
background-image:-webkit-gradient(linear,0 0,0 100%,color-stop(0,#fff),color-stop(0.02,#eee),color-stop(0.98,#ccc),color-stop(1,#a3a3a3));
border:1px solid #505050;
-webkit-border-radius:8px;
-webkit-background-clip:padding-box;
color:#333;
text-shadow:0 1px 0 rgba(255,255,255,0.75);
line-height:130%;
-webkit-box-shadow:0 0 4px rgba(0,0,0,0.5);
}
#addToHomeScreen.addToHomeIpad {
width:268px;
font-size:18px;
padding:14px;
}
/**
*
* The 'wide' class is added when the popup contains the touch icon
*
*/
#addToHomeScreen.addToHomeWide {
width:296px;
}
#addToHomeScreen.addToHomeIpad.addToHomeWide {
width:320px;
font-size:18px;
padding:14px;
}
/**
*
* The balloon arrow
*
*/
#addToHomeScreen .addToHomeArrow {
position:absolute;
background-image:-webkit-gradient(linear,0 0,100% 100%,color-stop(0,rgba(204,204,204,0)),color-stop(0.4,rgba(204,204,204,0)),color-stop(0.4,#ccc));
border-width:0 1px 1px 0;
border-style:solid;
border-color:#505050;
width:16px; height:16px;
-webkit-transform:rotateZ(45deg);
bottom:-9px; left:50%;
margin-left:-8px;
-webkit-box-shadow:inset -1px -1px 0 #a9a9a9;
-webkit-border-bottom-right-radius:2px;
}
/**
*
* The balloon arrow for iPad
*
*/
#addToHomeScreen.addToHomeIpad .addToHomeArrow {
-webkit-transform:rotateZ(-135deg);
background-image:-webkit-gradient(linear,0 0,100% 100%,color-stop(0,rgba(238,238,238,0)),color-stop(0.4,rgba(238,238,238,0)),color-stop(0.4,#eee));
-webkit-box-shadow:inset -1px -1px 0 #fff;
top:-9px; bottom:auto; left:50%;
}
/**
*
* Close button
*
*/
#addToHomeScreen .addToHomeClose {
-webkit-box-sizing:border-box;
position:absolute;
right:4px;
top:4px;
width:18px;
height:18px; line-height:14px;
text-align:center;
text-indent:1px;
-webkit-border-radius:9px;
background:rgba(0,0,0,0.12);
color:#707070;
-webkit-box-shadow:0 1px 0 #fff;
font-size:16px;
}
/**
*
* The '+' icon, displayed only on iOS < 4.2
*
*/
#addToHomeScreen .addToHomePlus {
font-weight:bold;
font-size:1.3em;
}
/**
*
* The 'share' icon, displayed only on iOS >= 4.2
*
*/
#addToHomeScreen .addToHomeShare {
display:inline-block;
width:18px;
height:15px;
background-repeat:no-repeat;
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAPCAQAAABDj1eZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAUdJREFUKFNtkLtLw1AYxS/qJLhXVKr2ZRulUNtiqgSb3CziICI6ucTFVYcOnaQOFRwUnNTRwUWXgpP/QdHNUEQUHGxofYBTlRs83iZNjKTncOGe7/vx3QchXUWn6FL3jhfKUdCCr5zuifV5oDiHQM+c+CIhiiCSWNu08iq9oHXKLAiqrgR4UXqlOEYZt++ExEL0wW7+OW0G10muLv9gmqfe5FAWKmTMYQYiFL7PYwyLOD8lSjNh2gdnPzMII4QUBxc4OothbAF7GCBKQ0YbSWyPQsIhqvetS+y0ygGMo/KFZfviDvR4AhwgZU9dGYnA0J/6ndc15i3ouYIMcVVUcEXIoOxCeRCfwP8sXBSdjtpUv/1QW+K16kCCIUC4id9Fa0JtkluwVkSfqPL6RwfSDA0aNlx7k/bWgViB7bMS2/1vk5sdsZLN/ALSuL3tylO4RAAAAABJRU5ErkJggg==);
background-size:18px 15px;
text-indent:-9999em;
overflow:hidden;
}
/**
*
* The touch icon (if available)
*
*/
#addToHomeScreen .addToHomeTouchIcon {
display:block;
float:left;
-webkit-border-radius:6px;
-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.5),
inset 0 0 2px rgba(255,255,255,0.9);
background-repeat:no-repeat;
width:57px; height:57px;
-webkit-background-size:57px 57px;
margin:0 12px 0 0;
border:1px solid #333;
-webkit-background-clip:padding-box;
}
/**
*
* The 'share' icon for retina display
*
*/
@media all and (-webkit-min-device-pixel-ratio: 2) {
#addToHomeScreen .addToHomeShare {
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAeCAQAAADu6HTYAAADPElEQVR4Xq3TX2gcRRzA8e/M7mVv2+TSNpc/TZtrY6jUGqgaSAmEChKLrYK0YH0RFC2CSCkEfCghiKU04J8qNigq6os+iQV98MHWFwVBrQQRWs21lBw5cw3NNb1/udu72RGG5Y77IzXW77D7sAwf5scyYoL6BGXSDKFZwaGpLvIUaeoCkvX1MmsM0Ny6oRSQYOLuIS+YZOpfQdqslpUxcZrzTVAz4qPwW2O3CeIwC/RSzeY6Ow1QhUrkr+YOWfEKDkEP8Rij7CHKJmrFSDHBdwGEE5wiGChPN+PnT8VdRtEIl1d4gRj/1EVe5ZSBKGh8iqQpo/Fo5+3C/gz0MYg4zgwbqday1/Q4B8BGQ45d/Hi54lakCrU5obOcidJpu1+Lg9whjabyaOYLnrIBFFaRD+xe2ybMDWY66GmP/WA9cGfGp0CWhy0wkMN8inepFiH2rV1j0NQSNQbFLRQnS8/8YSDBBpadfv4CYDub2fmeHDNAsL1MBWUel0iA+Xik6eHcyvD3vAMSU1TGuA/YRS+dD7ovCQN43GKRFCU20Kd3V/avDVVyAZ5niTEuLA5/zBGWg9EEEhfJKN200Tat8CmRAQb9+wv7soPlHt2tQorsz1uPbr0HTY4sJwrH47zJZwABBAKLMBoQXepwgTwdHCo+fXMkQ4lrxEmQ5AaXipPqDY9V2vn09tgvTPI71EEGYxM+/uMJLJ4svpgaWGKOi/xKgmqLSUGSUd5f2vIVJ/CgBaTIUsZ7ZBsn0+NzfMOXLFCXQyTcybN6ep5ZZgUOHn7jpfUpsZshdugPGf+E5zjbyHTSRyQ8xfRPPM/s63RHeuknSoT22mjmmnAOIMkUZ6D1xSfPPAfd1WFKM3sO2CMaHx8M1NjnXKHaAGGkOW0C02WeYHUz4qMtx+w5gUDS8NckYe5lHsMYwCZEPyEEmjLDZFmAS7CDviMdxyTkMNVBKEmYLvbiQQBIBBbCQG04bGQvFWz6CfsCQLWCigILFwcfkGYBiOpbYuOizTAyYyDdCtrGaRG1LCkIgMYEFhI0WqQZoSlbGRyHKe4qOx7iv2bVQW9dp4dlM/x6kmwnWQcd/Q3FCqwTEiT5s+6D5v/pb0SSHyg7uhMWAAAAAElFTkSuQmCC);
}
}

351
plugins/add2home.js Normal file
View File

@ -0,0 +1,351 @@
/*!
* Add to Homescreen v2.0.4 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
* Released under MIT license, http://cubiq.org/license
*/
var addToHome = (function (w) {
var nav = w.navigator,
isIDevice = 'platform' in nav && (/iphone|ipod|ipad/gi).test(nav.platform),
isIPad,
isRetina,
isSafari,
isStandalone,
OSVersion,
startX = 0,
startY = 0,
lastVisit = 0,
isExpired,
isSessionActive,
isReturningVisitor,
balloon,
overrideChecks,
positionInterval,
closeTimeout,
options = {
autostart: true, // Automatically open the balloon
returningVisitor: false, // Show the balloon to returning visitors only (setting this to true is HIGHLY RECCOMENDED)
animationIn: 'drop', // drop || bubble || fade
animationOut: 'fade', // drop || bubble || fade
startDelay: 2000, // 2 seconds from page load before the balloon appears
lifespan: 15000, // 15 seconds before it is automatically destroyed
bottomOffset: 14, // Distance of the balloon from bottom
expire: 0, // Minutes to wait before showing the popup again (0 = always displayed)
message: '', // Customize your message or force a language ('' = automatic)
touchIcon: false, // Display the touch icon
arrow: true, // Display the balloon arrow
hookOnLoad: true, // Should we hook to onload event? (really advanced usage)
iterations: 100 // Internal/debug use
},
intl = {
ar: '<span dir="rtl">قم بتثبيت هذا التطبيق على <span dir="ltr">%device:</span>انقر<span dir="ltr">%icon</span> ،<strong>ثم اضفه الى الشاشة الرئيسية.</strong></span>',
ca_es: 'Per instal·lar aquesta aplicació al vostre %device premeu %icon i llavors <strong>Afegir a pantalla d\'inici</strong>.',
cs_cz: 'Pro instalaci aplikace na Váš %device, stiskněte %icon a v nabídce <strong>Přidat na plochu</strong>.',
da_dk: 'Tilføj denne side til din %device: tryk på %icon og derefter <strong>Føj til hjemmeskærm</strong>.',
de_de: 'Installieren Sie diese App auf Ihrem %device: %icon antippen und dann <strong>Zum Home-Bildschirm</strong>.',
el_gr: 'Εγκαταστήσετε αυτήν την Εφαρμογή στήν συσκευή σας %device: %icon μετά πατάτε <strong>Προσθήκη σε Αφετηρία</strong>.',
en_us: 'Install this web app on your %device: tap %icon and then <strong>Add to Home Screen</strong>.',
es_es: 'Para instalar esta app en su %device, pulse %icon y seleccione <strong>Añadir a pantalla de inicio</strong>.',
fi_fi: 'Asenna tämä web-sovellus laitteeseesi %device: paina %icon ja sen jälkeen valitse <strong>Lisää Koti-valikkoon</strong>.',
fr_fr: 'Ajoutez cette application sur votre %device en cliquant sur %icon, puis <strong>Ajouter à l\'écran d\'accueil</strong>.',
he_il: '<span dir="rtl">התקן אפליקציה זו על ה-%device שלך: הקש %icon ואז <strong>הוסף למסך הבית</strong>.</span>',
hr_hr: 'Instaliraj ovu aplikaciju na svoj %device: klikni na %icon i odaberi <strong>Dodaj u početni zaslon</strong>.',
hu_hu: 'Telepítse ezt a web-alkalmazást az Ön %device-jára: nyomjon a %icon-ra majd a <strong>Főképernyőhöz adás</strong> gombra.',
it_it: 'Installa questa applicazione sul tuo %device: premi su %icon e poi <strong>Aggiungi a Home</strong>.',
ja_jp: 'このウェブアプリをあなたの%deviceにインストールするには%iconをタップして<strong>ホーム画面に追加</strong>を選んでください。',
ko_kr: '%device에 웹앱을 설치하려면 %icon을 터치 후 "홈화면에 추가"를 선택하세요',
nb_no: 'Installer denne appen på din %device: trykk på %icon og deretter <strong>Legg til på Hjem-skjerm</strong>',
nl_nl: 'Installeer deze webapp op uw %device: tik %icon en dan <strong>Voeg toe aan beginscherm</strong>.',
pl_pl: 'Aby zainstalować tę aplikacje na %device: naciśnij %icon a następnie <strong>Dodaj jako ikonę</strong>.',
pt_br: 'Instale este aplicativo em seu %device: aperte %icon e selecione <strong>Adicionar à Tela Inicio</strong>.',
pt_pt: 'Para instalar esta aplicação no seu %device, prima o %icon e depois o <strong>Adicionar ao ecrã principal</strong>.',
ru_ru: 'Установите это веб-приложение на ваш %device: нажмите %icon, затем <strong>Добавить в «Домой»</strong>.',
sv_se: 'Lägg till denna webbapplikation på din %device: tryck på %icon och därefter <strong>Lägg till på hemskärmen</strong>.',
th_th: 'ติดตั้งเว็บแอพฯ นี้บน %device ของคุณ: แตะ %icon และ <strong>เพิ่มที่หน้าจอโฮม</strong>',
tr_tr: '%device için bu uygulamayı kurduktan sonra %icon simgesine dokunarak <strong>Ana Ekrana Ekle</strong>yin.',
zh_cn: '您可以将此应用程式安装到您的 %device 上。请按 %icon 然后点选<strong>添加至主屏幕</strong>。',
zh_tw: '您可以將此應用程式安裝到您的 %device 上。請按 %icon 然後點選<strong>加入主畫面螢幕</strong>。'
};
function init () {
// Preliminary check, all further checks are performed on iDevices only
if ( !isIDevice ) return;
var now = Date.now(),
i;
// Merge local with global options
if ( w.addToHomeConfig ) {
for ( i in w.addToHomeConfig ) {
options[i] = w.addToHomeConfig[i];
}
}
if ( !options.autostart ) options.hookOnLoad = false;
isIPad = (/ipad/gi).test(nav.platform);
isRetina = w.devicePixelRatio && w.devicePixelRatio > 1;
isSafari = (/Safari/i).test(nav.appVersion) && !(/CriOS/i).test(nav.appVersion);
isStandalone = nav.standalone;
OSVersion = nav.appVersion.match(/OS (\d+_\d+)/i);
OSVersion = OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0;
lastVisit = +w.localStorage.getItem('addToHome');
isSessionActive = w.sessionStorage.getItem('addToHomeSession');
isReturningVisitor = options.returningVisitor ? lastVisit && lastVisit + 28*24*60*60*1000 > now : true;
if ( !lastVisit ) lastVisit = now;
// If it is expired we need to reissue a new balloon
isExpired = isReturningVisitor && lastVisit <= now;
if ( options.hookOnLoad ) w.addEventListener('load', loaded, false);
else if ( !options.hookOnLoad && options.autostart ) loaded();
}
function loaded () {
w.removeEventListener('load', loaded, false);
if ( !isReturningVisitor ) w.localStorage.setItem('addToHome', Date.now());
else if ( options.expire && isExpired ) w.localStorage.setItem('addToHome', Date.now() + options.expire * 60000);
if ( !overrideChecks && ( !isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor ) ) return;
var icons = options.touchIcon ? document.querySelectorAll('head link[rel=apple-touch-icon],head link[rel=apple-touch-icon-precomposed]') : [],
sizes,
touchIcon = '',
closeButton,
platform = nav.platform.split(' ')[0],
language = nav.language.replace('-', '_'),
i, l;
balloon = document.createElement('div');
balloon.id = 'addToHomeScreen';
balloon.style.cssText += 'left:-9999px;-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0;-webkit-transform:translate3d(0,0,0);position:' + (OSVersion < 5 ? 'absolute' : 'fixed');
// Localize message
if ( options.message in intl ) { // You may force a language despite the user's locale
language = options.message;
options.message = '';
}
if ( options.message === '' ) { // We look for a suitable language (defaulted to en_us)
options.message = language in intl ? intl[language] : intl['en_us'];
}
// Search for the apple-touch-icon
if ( icons.length ) {
for ( i = 0, l = icons.length; i < l; i++ ) {
sizes = icons[i].getAttribute('sizes');
if ( sizes ) {
if ( isRetina && sizes == '114x114' ) {
touchIcon = icons[i].href;
break;
}
} else {
touchIcon = icons[i].href;
}
}
touchIcon = '<span style="background-image:url(' + touchIcon + ')" class="addToHomeTouchIcon"></span>';
}
balloon.className = (isIPad ? 'addToHomeIpad' : 'addToHomeIphone') + (touchIcon ? ' addToHomeWide' : '');
balloon.innerHTML = touchIcon +
options.message.replace('%device', platform).replace('%icon', OSVersion >= 4.2 ? '<span class="addToHomeShare"></span>' : '<span class="addToHomePlus">+</span>') +
(options.arrow ? '<span class="addToHomeArrow"></span>' : '') +
'<span class="addToHomeClose">\u00D7</span>';
document.body.appendChild(balloon);
// Add the close action
closeButton = balloon.querySelector('.addToHomeClose');
if ( closeButton ) closeButton.addEventListener('click', clicked, false);
if ( !isIPad && OSVersion >= 6 ) window.addEventListener('orientationchange', orientationCheck, false);
setTimeout(show, options.startDelay);
}
function show () {
var duration,
iPadXShift = 208;
// Set the initial position
if ( isIPad ) {
if ( OSVersion < 5 ) {
startY = w.scrollY;
startX = w.scrollX;
} else if ( OSVersion < 6 ) {
iPadXShift = 160;
}
balloon.style.top = startY + options.bottomOffset + 'px';
balloon.style.left = startX + iPadXShift - Math.round(balloon.offsetWidth / 2) + 'px';
switch ( options.animationIn ) {
case 'drop':
duration = '0.6s';
balloon.style.webkitTransform = 'translate3d(0,' + -(w.scrollY + options.bottomOffset + balloon.offsetHeight) + 'px,0)';
break;
case 'bubble':
duration = '0.6s';
balloon.style.opacity = '0';
balloon.style.webkitTransform = 'translate3d(0,' + (startY + 50) + 'px,0)';
break;
default:
duration = '1s';
balloon.style.opacity = '0';
}
} else {
startY = w.innerHeight + w.scrollY;
if ( OSVersion < 5 ) {
startX = Math.round((w.innerWidth - balloon.offsetWidth) / 2) + w.scrollX;
balloon.style.left = startX + 'px';
balloon.style.top = startY - balloon.offsetHeight - options.bottomOffset + 'px';
} else {
balloon.style.left = '50%';
balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 ? 40 : 0 ) + 'px';
balloon.style.bottom = options.bottomOffset + 'px';
}
switch (options.animationIn) {
case 'drop':
duration = '1s';
balloon.style.webkitTransform = 'translate3d(0,' + -(startY + options.bottomOffset) + 'px,0)';
break;
case 'bubble':
duration = '0.6s';
balloon.style.webkitTransform = 'translate3d(0,' + (balloon.offsetHeight + options.bottomOffset + 50) + 'px,0)';
break;
default:
duration = '1s';
balloon.style.opacity = '0';
}
}
balloon.offsetHeight; // repaint trick
balloon.style.webkitTransitionDuration = duration;
balloon.style.opacity = '1';
balloon.style.webkitTransform = 'translate3d(0,0,0)';
balloon.addEventListener('webkitTransitionEnd', transitionEnd, false);
closeTimeout = setTimeout(close, options.lifespan);
}
function manualShow (override) {
if ( !isIDevice || balloon ) return;
overrideChecks = override;
loaded();
}
function close () {
clearInterval( positionInterval );
clearTimeout( closeTimeout );
closeTimeout = null;
var posY = 0,
posX = 0,
opacity = '1',
duration = '0',
closeButton = balloon.querySelector('.addToHomeClose');
if ( closeButton ) closeButton.removeEventListener('click', close, false);
if ( !isIPad && OSVersion >= 6 ) window.removeEventListener('orientationchange', orientationCheck, false);
if ( OSVersion < 5 ) {
posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY;
posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth)/2) - startX;
}
balloon.style.webkitTransitionProperty = '-webkit-transform,opacity';
switch ( options.animationOut ) {
case 'drop':
if ( isIPad ) {
duration = '0.4s';
opacity = '0';
posY = posY + 50;
} else {
duration = '0.6s';
posY = posY + balloon.offsetHeight + options.bottomOffset + 50;
}
break;
case 'bubble':
if ( isIPad ) {
duration = '0.8s';
posY = posY - balloon.offsetHeight - options.bottomOffset - 50;
} else {
duration = '0.4s';
opacity = '0';
posY = posY - 50;
}
break;
default:
duration = '0.8s';
opacity = '0';
}
balloon.addEventListener('webkitTransitionEnd', transitionEnd, false);
balloon.style.opacity = opacity;
balloon.style.webkitTransitionDuration = duration;
balloon.style.webkitTransform = 'translate3d(' + posX + 'px,' + posY + 'px,0)';
}
function clicked () {
w.sessionStorage.setItem('addToHomeSession', '1');
isSessionActive = true;
close();
}
function transitionEnd () {
balloon.removeEventListener('webkitTransitionEnd', transitionEnd, false);
balloon.style.webkitTransitionProperty = '-webkit-transform';
balloon.style.webkitTransitionDuration = '0.2s';
// We reached the end!
if ( !closeTimeout ) {
balloon.parentNode.removeChild(balloon);
balloon = null;
return;
}
// On iOS 4 we start checking the element position
if ( OSVersion < 5 && closeTimeout ) positionInterval = setInterval(setPosition, options.iterations);
}
function setPosition () {
var matrix = new WebKitCSSMatrix(w.getComputedStyle(balloon, null).webkitTransform),
posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY,
posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth) / 2) - startX;
// Screen didn't move
if ( posY == matrix.m42 && posX == matrix.m41 ) return;
balloon.style.webkitTransform = 'translate3d(' + posX + 'px,' + posY + 'px,0)';
}
// Clear local and session storages (this is useful primarily in development)
function reset () {
w.localStorage.removeItem('addToHome');
w.sessionStorage.removeItem('addToHomeSession');
}
function orientationCheck () {
balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 ? 40 : 0 ) + 'px';
}
// Bootstrap!
init();
return {
show: manualShow,
close: close,
reset: reset
};
})(window);

20
plugins/parsedown/LICENSE.txt Executable file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

785
plugins/parsedown/Parsedown.php Executable file
View File

@ -0,0 +1,785 @@
<?php
#
#
# Parsedown
# http://parsedown.org
#
# (c) Emanuil Rusev
# http://erusev.com
#
# For the full license information, please view the LICENSE file that was
# distributed with this source code.
#
#
class Parsedown
{
#
# Multiton (http://en.wikipedia.org/wiki/Multiton_pattern)
#
static function instance($name = 'default')
{
if (isset(self::$instances[$name]))
return self::$instances[$name];
$instance = new Parsedown();
self::$instances[$name] = $instance;
return $instance;
}
private static $instances = array();
#
# Fields
#
private $reference_map = array();
private $escape_sequence_map = array();
#
# Public Methods
#
function parse($text)
{
# removes UTF-8 BOM and marker characters
$text = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $text);
# removes \r characters
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text);
# replaces tabs with spaces
$text = str_replace("\t", ' ', $text);
# encodes escape sequences
if (strpos($text, '\\') !== FALSE)
{
$escape_sequences = array('\\\\', '\`', '\*', '\_', '\{', '\}', '\[', '\]', '\(', '\)', '\>', '\#', '\+', '\-', '\.', '\!');
foreach ($escape_sequences as $index => $escape_sequence)
{
if (strpos($text, $escape_sequence) !== FALSE)
{
$code = "\x1A".'\\'.$index.';';
$text = str_replace($escape_sequence, $code, $text);
$this->escape_sequence_map[$code] = $escape_sequence;
}
}
}
# ~
$text = preg_replace('/\n\s*\n/', "\n\n", $text);
$text = trim($text, "\n");
$lines = explode("\n", $text);
$text = $this->parse_block_elements($lines);
# decodes escape sequences
foreach ($this->escape_sequence_map as $code => $escape_sequence)
{
$text = str_replace($code, $escape_sequence[1], $text);
}
$text = rtrim($text, "\n");
return $text;
}
#
# Private Methods
#
private function parse_block_elements(array $lines, $context = '')
{
$elements = array();
$element = array(
'type' => '',
);
foreach ($lines as $line)
{
#
# fenced elements
switch ($element['type'])
{
case 'fenced_code_block':
if ( ! isset($element['closed']))
{
if (preg_match('/^[ ]*'.$element['fence'][0].'{3,}[ ]*$/', $line))
{
$element['closed'] = true;
}
else
{
$element['text'] !== '' and $element['text'] .= "\n";
$element['text'] .= $line;
}
continue 2;
}
break;
case 'markup':
if ( ! isset($element['closed']))
{
if (preg_match('{<'.$element['subtype'].'>$}', $line)) # opening tag
{
$element['depth']++;
}
if (preg_match('{</'.$element['subtype'].'>$}', $line)) # closing tag
{
$element['depth'] > 0
? $element['depth']--
: $element['closed'] = true;
}
$element['text'] .= "\n".$line;
continue 2;
}
break;
}
# *
if ($line === '')
{
$element['interrupted'] = true;
continue;
}
#
# composite elements
switch ($element['type'])
{
case 'blockquote':
if ( ! isset($element['interrupted']))
{
$line = preg_replace('/^[ ]*>[ ]?/', '', $line);
$element['lines'] []= $line;
continue 2;
}
break;
case 'li':
if (preg_match('/^([ ]{0,3})(\d+[.]|[*+-])[ ](.*)/', $line, $matches))
{
if ($element['indentation'] !== $matches[1])
{
$element['lines'] []= $line;
}
else
{
unset($element['last']);
$elements []= $element;
$element = array(
'type' => 'li',
'indentation' => $matches[1],
'last' => true,
'lines' => array(
preg_replace('/^[ ]{0,4}/', '', $matches[3]),
),
);
}
continue 2;
}
if (isset($element['interrupted']))
{
if ($line[0] === ' ')
{
$element['lines'] []= '';
$line = preg_replace('/^[ ]{0,4}/', '', $line);
$element['lines'] []= $line;
continue 2;
}
}
else
{
$line = preg_replace('/^[ ]{0,4}/', '', $line);
$element['lines'] []= $line;
continue 2;
}
break;
}
#
# indentation sensitive types
$deindented_line = $line;
switch ($line[0])
{
case ' ':
# ~
$deindented_line = ltrim($line);
if ($deindented_line === '')
{
continue 2;
}
# code block
if (preg_match('/^[ ]{4}(.*)/', $line, $matches))
{
if ($element['type'] === 'code_block')
{
if (isset($element['interrupted']))
{
$element['text'] .= "\n";
unset ($element['interrupted']);
}
$element['text'] .= "\n".$matches[1];
}
else
{
$elements []= $element;
$element = array(
'type' => 'code_block',
'text' => $matches[1],
);
}
continue 2;
}
break;
case '#':
# atx heading (#)
if (preg_match('/^(#{1,6})[ ]*(.+?)[ ]*#*$/', $line, $matches))
{
$elements []= $element;
$level = strlen($matches[1]);
$element = array(
'type' => 'h.',
'text' => $matches[2],
'level' => $level,
);
continue 2;
}
break;
case '-':
# setext heading (---)
if ($line[0] === '-' and $element['type'] === 'p' and ! isset($element['interrupted']) and preg_match('/^[-]+[ ]*$/', $line))
{
$element['type'] = 'h.';
$element['level'] = 2;
continue 2;
}
break;
case '=':
# setext heading (===)
if ($line[0] === '=' and $element['type'] === 'p' and ! isset($element['interrupted']) and preg_match('/^[=]+[ ]*$/', $line))
{
$element['type'] = 'h.';
$element['level'] = 1;
continue 2;
}
break;
}
#
# indentation insensitive types
switch ($deindented_line[0])
{
case '<':
# self-closing tag
if (preg_match('{^<.+?/>$}', $deindented_line))
{
$elements []= $element;
$element = array(
'type' => '',
'text' => $deindented_line,
);
continue 2;
}
# opening tag
if (preg_match('{^<(\w+)(?:[ ].*?)?>}', $deindented_line, $matches))
{
$elements []= $element;
$element = array(
'type' => 'markup',
'subtype' => strtolower($matches[1]),
'text' => $deindented_line,
'depth' => 0,
);
preg_match('{</'.$matches[1].'>\s*$}', $deindented_line) and $element['closed'] = true;
continue 2;
}
break;
case '>':
# quote
if (preg_match('/^>[ ]?(.*)/', $deindented_line, $matches))
{
$elements []= $element;
$element = array(
'type' => 'blockquote',
'lines' => array(
$matches[1],
),
);
continue 2;
}
break;
case '[':
# reference
if (preg_match('/^\[(.+?)\]:[ ]*([^ ]+)/', $deindented_line, $matches))
{
$label = strtolower($matches[1]);
$this->reference_map[$label] = trim($matches[2], '<>');;
continue 2;
}
break;
case '`':
case '~':
# fenced code block
if (preg_match('/^([`]{3,}|[~]{3,})[ ]*(\S+)?[ ]*$/', $deindented_line, $matches))
{
$elements []= $element;
$element = array(
'type' => 'fenced_code_block',
'text' => '',
'fence' => $matches[1],
);
isset($matches[2]) and $element['language'] = $matches[2];
continue 2;
}
break;
case '*':
case '+':
case '-':
case '_':
# hr
if (preg_match('/^([-*_])([ ]{0,2}\1){2,}[ ]*$/', $deindented_line))
{
$elements []= $element;
$element = array(
'type' => 'hr',
);
continue 2;
}
# li
if (preg_match('/^([ ]*)[*+-][ ](.*)/', $line, $matches))
{
$elements []= $element;
$element = array(
'type' => 'li',
'ordered' => false,
'indentation' => $matches[1],
'last' => true,
'lines' => array(
preg_replace('/^[ ]{0,4}/', '', $matches[2]),
),
);
continue 2;
}
}
# li
if ($deindented_line[0] <= '9' and $deindented_line >= '0' and preg_match('/^([ ]*)\d+[.][ ](.*)/', $line, $matches))
{
$elements []= $element;
$element = array(
'type' => 'li',
'ordered' => true,
'indentation' => $matches[1],
'last' => true,
'lines' => array(
preg_replace('/^[ ]{0,4}/', '', $matches[2]),
),
);
continue;
}
# paragraph
if ($element['type'] === 'p')
{
if (isset($element['interrupted']))
{
$elements []= $element;
$element['text'] = $line;
unset($element['interrupted']);
}
else
{
$element['text'] .= "\n".$line;
}
}
else
{
$elements []= $element;
$element = array(
'type' => 'p',
'text' => $line,
);
}
}
$elements []= $element;
unset($elements[0]);
#
# ~
#
$markup = '';
foreach ($elements as $element)
{
switch ($element['type'])
{
case 'p':
$text = $this->parse_span_elements($element['text']);
$text = preg_replace('/[ ]{2}\n/', '<br />'."\n", $text);
if ($context === 'li' and $markup === '')
{
if (isset($element['interrupted']))
{
$markup .= "\n".'<p>'.$text.'</p>'."\n";
}
else
{
$markup .= $text;
}
}
else
{
$markup .= '<p>'.$text.'</p>'."\n";
}
break;
case 'blockquote':
$text = $this->parse_block_elements($element['lines']);
$markup .= '<blockquote>'."\n".$text.'</blockquote>'."\n";
break;
case 'code_block':
case 'fenced_code_block':
$text = htmlentities($element['text'], ENT_NOQUOTES);
strpos($text, "\x1A\\") !== FALSE and $text = strtr($text, $this->escape_sequence_map);
$markup .= '<pre><code>'.$text.'</code></pre>'."\n";
break;
case 'h.':
$text = $this->parse_span_elements($element['text']);
$markup .= '<h'.$element['level'].'>'.$text.'</h'.$element['level'].'>'."\n";
break;
case 'hr':
$markup .= '<hr />'."\n";
break;
case 'li':
if (isset($element['ordered'])) # first
{
$list_type = $element['ordered'] ? 'ol' : 'ul';
$markup .= '<'.$list_type.'>'."\n";
}
if (isset($element['interrupted']) and ! isset($element['last']))
{
$element['lines'] []= '';
}
$text = $this->parse_block_elements($element['lines'], 'li');
$markup .= '<li>'.$text.'</li>'."\n";
isset($element['last']) and $markup .= '</'.$list_type.'>'."\n";
break;
default:
$markup .= $element['text']."\n";
}
}
return $markup;
}
private function parse_span_elements($text)
{
$map = array();
$index = 0;
# code span
if (strpos($text, '`') !== FALSE and preg_match_all('/`(.+?)`/', $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $matches)
{
$element_text = $matches[1];
$element_text = htmlentities($element_text, ENT_NOQUOTES);
# decodes escape sequences
$this->escape_sequence_map
and strpos($element_text, "\x1A") !== FALSE
and $element_text = strtr($element_text, $this->escape_sequence_map);
# composes element
$element = '<code>'.$element_text.'</code>';
# encodes element
$code = "\x1A".'$'.$index;
$text = str_replace($matches[0], $code, $text);
$map[$code] = $element;
$index ++;
}
}
# inline link or image
if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)(\[((?:[^\[\]]|(?2))*)\])\((.*?)\)/', $text, $matches, PREG_SET_ORDER)) # inline
{
foreach ($matches as $matches)
{
$url = $matches[4];
strpos($url, '&') !== FALSE and $url = preg_replace('/&(?!#?\w+;)/', '&amp;', $url);
if ($matches[1]) # image
{
$element = '<img alt="'.$matches[3].'" src="'.$url.'">';
}
else
{
$element_text = $this->parse_span_elements($matches[3]);
$element = '<a href="'.$url.'">'.$element_text.'</a>';
}
# ~
$code = "\x1A".'$'.$index;
$text = str_replace($matches[0], $code, $text);
$map[$code] = $element;
$index ++;
}
}
# reference link or image
if ($this->reference_map and strpos($text, '[') !== FALSE and preg_match_all('/(!?)\[(.+?)\](?:\n?[ ]?\[(.*?)\])?/ms', $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $matches)
{
$link_definition = isset($matches[3]) && $matches[3]
? $matches[3]
: $matches[2]; # implicit
$link_definition = strtolower($link_definition);
if (isset($this->reference_map[$link_definition]))
{
$url = $this->reference_map[$link_definition];
strpos($url, '&') !== FALSE and $url = preg_replace('/&(?!#?\w+;)/', '&amp;', $url);
if ($matches[1]) # image
{
$element = '<img alt="'.$matches[2].'" src="'.$url.'">';
}
else # anchor
{
$element_text = $this->parse_span_elements($matches[2]);
$element = '<a href="'.$url.'">'.$element_text.'</a>';
}
# ~
$code = "\x1A".'$'.$index;
$text = str_replace($matches[0], $code, $text);
$map[$code] = $element;
$index ++;
}
}
}
# automatic link
if (strpos($text, '<') !== FALSE and preg_match_all('/<((https?|ftp|dict):[^\^\s]+?)>/i', $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $matches)
{
$url = $matches[1];
strpos($url, '&') !== FALSE and $url = preg_replace('/&(?!#?\w+;)/', '&amp;', $url);
$element = '<a href=":href">:text</a>';
$element = str_replace(':text', $url, $element);
$element = str_replace(':href', $url, $element);
# ~
$code = "\x1A".'$'.$index;
$text = str_replace($matches[0], $code, $text);
$map[$code] = $element;
$index ++;
}
}
# ~
strpos($text, '&') !== FALSE and $text = preg_replace('/&(?!#?\w+;)/', '&amp;', $text);
strpos($text, '<') !== FALSE and $text = preg_replace('/<(?!\/?\w.*?>)/', '&lt;', $text);
# ~
if (strpos($text, '_') !== FALSE)
{
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '<strong>$1</strong>', $text);
$text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/s', '<em>$1</em>', $text);
}
if (strpos($text, '*') !== FALSE)
{
$text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*(?!\*)/s', '<strong>$1</strong>', $text);
$text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/s', '<em>$1</em>', $text);
}
$text = strtr($text, $map);
return $text;
}
}

BIN
sounds/alert.mp3 Normal file

Binary file not shown.

BIN
sounds/alert.ogg Normal file

Binary file not shown.

BIN
sounds/alert.wav Normal file

Binary file not shown.