diff options
| author | Bulletin <bulletin@bulletinalpha.tk> | 2016-12-29 16:42:32 -0500 |
|---|---|---|
| committer | Bulletin <bulletin@bulletinalpha.tk> | 2016-12-29 16:42:32 -0500 |
| commit | 1a7fa60f6cb2ee26843ca19e37bb4ff44104ad55 (patch) | |
| tree | 2fa1fbdea9992ab63ba2a7abbac8bbcd633d13f7 /inc | |
| download | bulletin-1a7fa60f6cb2ee26843ca19e37bb4ff44104ad55.tar.gz | |
Added existing progress
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/common.php | 9 | ||||
| -rw-r--r-- | inc/config.php | 18 | ||||
| -rw-r--r-- | inc/db.php | 10 | ||||
| -rw-r--r-- | inc/eml.tpl | 23 | ||||
| -rw-r--r-- | inc/fatal.tpl | 23 | ||||
| -rw-r--r-- | inc/forgot.tpl | 23 | ||||
| -rw-r--r-- | inc/functions.php | 67 | ||||
| -rw-r--r-- | inc/mobile.php | 9 | ||||
| -rw-r--r-- | inc/user.php | 18 |
9 files changed, 200 insertions, 0 deletions
diff --git a/inc/common.php b/inc/common.php new file mode 100644 index 0000000..ac55bde --- /dev/null +++ b/inc/common.php @@ -0,0 +1,9 @@ +<?php +define('INCLUDE_PATH', dirname(__FILE__).'/'); + +require(INCLUDE_PATH . 'config.php'); +require(INCLUDE_PATH . 'functions.php'); +require(INCLUDE_PATH . 'mobile.php'); +require(INCLUDE_PATH . 'db.php'); +require(INCLUDE_PATH . 'user.php'); +?> diff --git a/inc/config.php b/inc/config.php new file mode 100644 index 0000000..93050e7 --- /dev/null +++ b/inc/config.php @@ -0,0 +1,18 @@ +<?php +$b_config = array( + 'base_url' => 'https://www.bulletinalpha.tk/', + 'c_name' => 'bulletin', + 'c_expire' => 31536000, + 'c_dom' => '.bulletinalpha.tk', + 'c_path' => '/', + 'c_sec' => true, + 'c_http' => true, + 'db_host' => 'localhost', + 'db_name' => 'bulletin', + 'db_user' => 'bulletin', + 'db_pass' => 'chV`tX8B_:e4/><}$(KO2)dE:~:O1)r@', + 'mail_from' => 'Bulletin <noreply@bulletinalpha.tk>', + 'mobile_base' => 'https://m.bulletinalpha.tk/', + 'moblie_host' => 'm.bulletinalpha.tk', +); +?> diff --git a/inc/db.php b/inc/db.php new file mode 100644 index 0000000..bb4b9f7 --- /dev/null +++ b/inc/db.php @@ -0,0 +1,10 @@ +<?php +class bdb extends mysqli { + + public function __construct () { + global $b_config; + parent::__construct($b_config['db_host'], $b_config['db_user'], $b_config['db_pass'], $b_config['db_name']); + } + +} +?> diff --git a/inc/eml.tpl b/inc/eml.tpl new file mode 100644 index 0000000..e09831d --- /dev/null +++ b/inc/eml.tpl @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>Active Your Bulletin Account</title> + </head> + <body> + <div id="head" style="text-align: center; width: 100%; height: 110px; border-bottom: 1px solid #dddddd;"> + <a class="logolink" href="[config:base_url]"> + <img style="width: 334px; height: 80px; margin: 15px auto;" src="[config:base_url]img/5.png" alt="Bulletin" /> + </a> + </div> + <div style="width: 450px; display: table; margin: 1em auto;"> + <div style="font-family: sans-serif; font-size: 12pt; text-align: center; margin: 15px -15px; width: 100%; display: block;"> + <p style="width: 100%;">Congratulations on creating your Bulletin account! We hope we can help you to find as many useful work connections as possible.</p> + <p style="width: 100%;">To activate your account, <a style="color: #fb4d00;" href="[config:base_url]activate.php?[tpl:activation_vars]">click here</a>.</p> + </div> + </div> + <div style="width: 450px; height: 1px; margin: auto; background: #dddddd;"></div> + <p style="margin-top: 2em; text-align: center; font-family: sans-serif; font-size: 12pt; color: #aaaaaa;">Welcome to Bulletin!</p> + <p style="color: #dddddd; margin: 4em auto auto auto; text-align: center; font-size: x-small; font-family: sans-serif;">Copyright © 2016 Bulletin Team</p> + </body> +</html> diff --git a/inc/fatal.tpl b/inc/fatal.tpl new file mode 100644 index 0000000..610b2b4 --- /dev/null +++ b/inc/fatal.tpl @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>Message / Bulletin</title> + <link rel="stylesheet" type="text/css" href="/css/internal.css" /> + </head> + <body> + <div id="head"> + <a class="logolink" href="/"></a> + </div> + <div class="box"> + <p>[tpl:message]</p> + </div> + <div class="hr"></div> + <p class="back"> + <a href="[tpl:link]"> + [tpl:label] + </a> + </p> + <p class="copy">Copyright © 2016 Bulletin Team</p> + </body> +</html> diff --git a/inc/forgot.tpl b/inc/forgot.tpl new file mode 100644 index 0000000..4c4ed4d --- /dev/null +++ b/inc/forgot.tpl @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>Recover Your Bulletin Account</title> + </head> + <body> + <div id="head" style="text-align: center; width: 100%; height: 110px; border-bottom: 1px solid #dddddd;"> + <a class="logolink" href="[config:base_url]"> + <img style="width: 334px; height: 80px; margin: 15px auto;" src="[config:base_url]img/5.png" alt="Bulletin" /> + </a> + </div> + <div style="width: 450px; display: table; margin: 1em auto;"> + <div style="font-family: sans-serif; font-size: 12pt; text-align: center; margin: 15px -15px; width: 100%; display: block;"> + <p style="width: 100%;">We're sorry you've lost access to your account!</p> + <p style="width: 100%;">To log in and change your password, <a style="color: #fb4d00;" href="[config:base_url]forgot.php?[tpl:vars]">click here</a>.</p> + </div> + </div> + <div style="width: 450px; height: 1px; margin: auto; background: #dddddd;"></div> + <p style="margin-top: 2em; text-align: center; font-family: sans-serif; font-size: 12pt; color: #aaaaaa;">Welcome back to Bulletin!</p> + <p style="color: #dddddd; margin: 4em auto auto auto; text-align: center; font-size: x-small; font-family: sans-serif;">Copyright © 2016 Bulletin Team</p> + </body> +</html> diff --git a/inc/functions.php b/inc/functions.php new file mode 100644 index 0000000..4e98342 --- /dev/null +++ b/inc/functions.php @@ -0,0 +1,67 @@ +<?php +function eml_tpl ($options) { + return tpl($options, 'eml.tpl'); +} +function tpl ($options, $file) { + $tpl_htm = file_get_contents(INCLUDE_PATH.$file); + $tpl_htm = preg_replace_callback('/\[tpl:([^\]]*)\]/i', + function ($matches) use (&$options) { + if (!isset($options[$matches[1]])) return ''; + return $options[$matches[1]]; + }, $tpl_htm); + $tpl_htm = preg_replace_callback('/\[include:([^\]]*)\]/i', + function ($matches) { + ob_start(); + if (include INCLUDE_PATH.$matches[1]) { + $r = ob_get_clean(); + ob_end_clean(); + return $r; + } else { + ob_end_clean(); + return ''; + } + }, $tpl_htm); + $tpl_htm = preg_replace_callback('/\[config:([^\]]*)\]/i', + function ($matches) { + global $b_config; + if (!isset($b_config[$matches[1]])) return ''; + return $b_config[$matches[1]]; + }, $tpl_htm); + $tpl_htm = preg_replace_callback('/\[user:([^\]]*)\]/i', + function ($matches) { + global $b_user; + if (!isset($b_user[$matches[1]])) return ''; + return $b_user[$matches[1]]; + }, $tpl_htm); + return $tpl_htm; +} + +function fatal ($msg, $link, $label) { + if ($link === null) $link = 'javascript:history.go(-1);'; + if ($label === null) $label = '← Got It'; + die(tpl(array('message' => $msg, 'link' => $link, 'label' => $label), 'fatal.tpl')); +} + +function gohome () { + global $b_config; + redirect($b_config['base_url']); +} + +function goin () { + l_redirect('dash/'); +} + +function loggedin () { + goin(); +} + +function l_redirect ($page) { + global $b_config; + redirect($b_config['base_url'].$page); +} + +function redirect ($url) { + header('Location: '.$url); + fatal('Redirecting...', $url); +} +?> diff --git a/inc/mobile.php b/inc/mobile.php new file mode 100644 index 0000000..634b008 --- /dev/null +++ b/inc/mobile.php @@ -0,0 +1,9 @@ +<?php +$useragent=$_SERVER['HTTP_USER_AGENT']; +if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) { + if ($_SERVER['HTTP_HOST'] != $b_config['mobile_host']) { + fatal('Just wait, the Bulletin mobile app is coming soon!'); +// redirect($b_config['mobile_base'].substr($_SERVER['REQUEST_URI'], 1)); + } +} +?> diff --git a/inc/user.php b/inc/user.php new file mode 100644 index 0000000..789586f --- /dev/null +++ b/inc/user.php @@ -0,0 +1,18 @@ +<?php +global $b_user; +$guest_user = array( + 'id' => 0, +); + +if (empty($_COOKIE[$b_config['c_name']]) || !preg_match('/^(\d+);([0-9a-zA-Z\.]+)$/', $_COOKIE[$b_config['c_name']], $matches)) { + $b_user = $guest_user; +} +else { + $db = new bdb(); + $result = $db->query('SELECT * FROM users WHERE id = '.intval($matches[1]).' AND session = \''.hash('sha512', $matches[2]).'\' AND active = 1 LIMIT 1') or fatal($db->error); + if ($result->num_rows < 1) $b_user = $guest_user; + else $b_user = $result->fetch_assoc(); + $result->free(); + $db->close(); +} +?> |
