Last active
November 23, 2015 12:40
-
-
Save ad-m/e5781ea67cd284d0f7a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if(!isset($_GET['pg'])) | |
| { | |
| model\$PART = 'start'; | |
| } | |
| if(isset($_GET['pg']) && !is_string($_GET['pg'])) | |
| { | |
| //killim | |
| //something something | |
| } | |
| if(isset($_GET['pg']) && !in_array(model\$_wl_PART)) | |
| { | |
| //killim | |
| model\$CONTENT = 'Żądana strona nie istnieje!'; | |
| } | |
| if(isset($_GET['pg']) && in_array($_GET['pg'], model\$_wl_PART, true)) | |
| { | |
| include PROCEDURES . '/part.switch.php'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if(!isset($_COOKIE['rq'])) | |
| { | |
| setcookie('rq', '', time() - 18000, '/', $_SERVER['SERVER_NAME'], false, true); | |
| setcookie('rq', sha1(uniqid()), time() + 180, '/', $_SERVER['SERVER_NAME'], false, true); | |
| } | |
| if(!isset($_COOKIE['info']) or !$_COOKIE['info']) | |
| { | |
| setcookie('info', 'y', time() + 60 * 60 * 24 * 30, '/', $_SERVER['SERVER_NAME'], false, true); | |
| model\$COOKIE_BAR = include HTML . '/cookie_bar.php'; | |
| } | |
| //REQUEST INTERNAL CONTROLLER | |
| switch($_SERVER['REQUEST_METHOD']) | |
| { | |
| case 'GET': | |
| case 'POST': | |
| case 'HEAD': | |
| session(); | |
| case 'GET': | |
| require PROCEDURES . '/action.get.php'; | |
| break; | |
| case 'POST': | |
| require PROCEDURES . '/action.post.php'; | |
| break; | |
| case 'HEAD': | |
| require PROCEDURES . '/action.head.php'; | |
| break; | |
| default: | |
| require PROCEDURES . '/action.badrm.php'; | |
| break; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace auth_tools | |
| { | |
| function hash_browser() | |
| { | |
| } | |
| function is_admin() | |
| { | |
| } | |
| function login($name, $pw, $salt_path, MysqliStmt $q) | |
| { | |
| } | |
| function logout() | |
| { | |
| } | |
| function init_session_vars() | |
| { | |
| $keys = array('user','rank','hash','last_log'); | |
| foreach($keys as $key): | |
| if(!array_key_exists($key,$_SESSION)): | |
| $_SESSION[$key] = false; | |
| endif; | |
| endforeach; | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Last Modified : 23.06.2015 | Version: 1.00.01.REF.CUT*/ | |
| /*A uncutted file. | |
| * Provides extensions (classes) to run blog & gallery | |
| * & panel authorisaion so on son... | |
| * Everything described further.. | |
| */ | |
| /* | |
| * Group of classes to provide statement query | |
| * for MysqliStmt object. | |
| * Exact usage with example in file dbstm.php . | |
| */ | |
| class auth | |
| { | |
| //const GET_USER_DATA = 'SELECT * FROM Jusers WHERE name = ? LIMIT 0,1'; | |
| const GET_USER_DATA = 'SELECT * FROM Jusers WHERE name = ? and pswr = ? LIMIT 0,1'; | |
| } | |
| class auth_priviledged | |
| { | |
| const CHANGE_USER_PW = 'UPDATE Jusers SET pswr = ? WHERE name = ? AND pswr = ?'; | |
| const CHANGE_USER_EMAIL = 'UPDATE Jusers SET mail = ? WHERE name = ?'; | |
| const LOG_STAMP = 'UPDATE Jusers SET last_log = NOW() WHERE name = ? AND pswr = ?'; | |
| } | |
| class category | |
| { | |
| const PART_SYMS_PLAIN = 'SELECT symbol FROM categories WHERE part=?'; | |
| const PART_SYMS = 'SELECT symbol,title FROM categories WHERE part=?'; | |
| const FULL_CAT = 'SELECT * FROM categories WHERE part=? AND symbol=?'; | |
| const ADD = 'INSERT INTO categories VALUES(NULL, ?, ?, ?, ?)'; | |
| const DEL = 'DELETE FROM categories WHERE symbol=? AND part=?'; | |
| } | |
| class gallery | |
| { | |
| const COUNT_SYM = 'SELECT COUNT(*) FROM images2 WHERE csym=?'; | |
| const GET_SOME = 'SELECT * FROM images2 WHERE csym=? ORDER BY added DESC LIMIT ?'; | |
| const GET_ALL = 'SELECT * FROM images2 WHERE csym=?'; | |
| const GET_SOME_NEWEST = 'SELECT * FROM images2 ORDER BY added DESC LIMIT ?'; | |
| const GET_ENTRY = 'SELECT * FROM images2 WHERE csym=? AND id=?'; | |
| const ADD = 'INSERT INTO images2 VALUES(?, ?, ?, NOW(), ?, ?)'; | |
| const DEL = 'DELETE FROM images2 WHERE id=? AND csym=?'; | |
| const DEL_FOR_GROUP = 'DELETE FROM images2 WHERE csym=?'; | |
| const MODIFY_GROUP = 'UPDATE images2 SET csym=? WHERE csym=?'; | |
| const MODIFY_ITEM = 'UPDATE images2 SET csym=? , title=? , description=? WHERE csym=? AND id=?'; | |
| } | |
| class comments | |
| { | |
| const FOR_ITEM = 'SELECT addTime,signature,text FROM comments WHERE part=? AND csym=? AND itemId=?'; | |
| const COUNT_ITEM = 'SELECT COUNT(*) FROM comments WHERE part=? AND csym=? AND itemId=?'; | |
| const PUT_ITEM = 'INSERT INTO comments (part, csym, itemId, signature, text, ip) VALUES (?, ?, ?, ?, ?, ?)'; | |
| const DEL_FOR_ITEM = 'DELETE FROM comments WHERE part=? AND itemId=? AND csym=?'; | |
| const DEL_FOR_GROUP = 'DELETE FROM comments WHERE part=? AND csym=?'; | |
| const MODIFY_GROUP = 'UPDATE comments SET csym=? WHERE csym=?'; | |
| const MODIFY_ITEM = 'UPDATE comments SET csym=? WHERE csym=? AND itemId=?'; | |
| } | |
| class blog | |
| { | |
| const DEL_FOR_GROUP = 'DELETE FROM articles WHERE csym=?'; | |
| const ADD = 'INSERT INTO articles VALUES(NULL, ?, NOW(), ?, ?, ?)'; | |
| const DEL = 'DELETE FROM articles WHERE id=? AND csym=?'; | |
| const COUNT_SYM = 'SELECT COUNT(*) FROM articles WHERE csym=?'; | |
| const GET_SOME_NEWEST = 'SELECT * FROM articles ORDER BY added DESC LIMIT ?'; | |
| const GET_PARAMS_CSYM = 'SELECT id,title,added FROM articles WHERE csym=?'; | |
| const GET_ENTRY = 'SELECT id,title,added,text,autor FROM articles WHERE csym=? AND id=? LIMIT 0,1'; | |
| const MODIFY_GROUP = 'UPDATE articles SET csym=? WHERE csym=?'; | |
| const MODIFY_ENTRY = 'UPDATE articles SET csym=? ,autor=?, title=?, text=? WHERE csym=? AND id=?'; | |
| } | |
| class traffic | |
| { | |
| const PUT_NORM_ENT = 'INSERT INTO traffic VALUES(NOW(), ?, ?, "norm")'; | |
| const PUT_ERR_ENT = 'INSERT INTO traffic VALUES(NOW(), ?, ?, "err")'; | |
| const PUT_ATTCK_ENT = 'INSERT INTO traffic VALUES(NOW(), ?, ?, "attck")'; | |
| const GET_ALL_APART = 'SELECT * FROM traffic ORDER BY visit_time DESC LIMIT ?,?'; | |
| } | |
| class login_guardian | |
| { | |
| const ADD_ENTRY = 'INSERT INTO missed_logins VALUES(NOW(), ?)'; | |
| const COUNT_ATTEMPTS = 'SELECT COUNT(*) FROM missed_logins WHERE ip=?'; | |
| const CLEAN_SYSTEM = 'DELETE FROM missed_logins'; | |
| //NEW | |
| const GET_ALL_FOR_ADDR = 'SELECT * FROM missed_logins WHERE ip=?'; | |
| const GET_ALL = 'SELECT * FROM missed_logins LIMIT ?,?'; | |
| const COUNT_ATTEMPTS_ALL = 'SELECT COUNT(*) FROM missed_logins'; | |
| const GET_IPS = 'SELECT DISTINCT ip FROM missed_logins'; | |
| const DEL_BY_IP = 'DELETE FROM missed_logins WHERE ip=?'; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Last Modified : NEVER | Version: 1.00.00 */ | |
| /* ############################################### | |
| * Copyright <herbalist> @ herbalist.hekko.pl 2015 | |
| * ############################################### | |
| * | |
| * This class just makes prepared db queries. | |
| * Basic idea of it is verry easy extendable functionality profile. | |
| * Itself it just can: | |
| * BIND QUERY STRING TO MYSQSLI_STMT OBJ, | |
| * BIND PARAMS, | |
| * EXECUTE, | |
| * GET RESULT in one of three manners: | |
| * - yield array | |
| * - return array | |
| * - do not expect result. | |
| * | |
| * It can execute and retrieve any query (f.ex: INSERT||UPDATE||DELETE||SELECT , probably much more). | |
| * | |
| ***************************** | |
| **** Basic usage is like: *** | |
| ***************************** | |
| * | |
| * <?php | |
| * $q = new MysqliStmt($mysqli_database_object->stmt_init()); | |
| * $q->query(CONSTANT_NAME $str);/@@ | |
| * //then one of three mentioned methods of execution, | |
| * //than just next: | |
| * $q->query(CONSTANT_NAME $str);/@@ | |
| * ?> | |
| ***************************** | |
| * /@@ - here comes the way of executinq queries | |
| * /@@ - just example of extendindg (further more detailed example) : | |
| * | |
| * <?php | |
| * class gallery | |
| * { | |
| * const COUNT_SYM = 'SELECT COUNT(*) FROM images WHERE csym=?'; | |
| * const GET_SOME = 'SELECT * FROM images WHERE csym=? ORDER BY added DESC LIMIT ?'; | |
| * const GET_ALL = 'SELECT * FROM images WHERE csym=?'; | |
| * const GET_ENTRY = 'SELECT * FROM images WHERE csym=? AND (icon=? OR full=?)'; | |
| * } | |
| * ?> | |
| * | |
| */ | |
| class MysqliStmt | |
| { | |
| public function __construct(mysqli_stmt $stmt){ | |
| $this->stmt = $stmt; | |
| } | |
| public function __destruct(){ | |
| if(($this->stmt instanceof mysqli_stmt) and $this->stmt->sqlstate == '00000'): | |
| @$this->stmt->reset(); | |
| @$this->stmt->close(); | |
| endif; | |
| } | |
| /* | |
| * This function is used to bind string to prepared | |
| * statement. String must be defined before as constant. | |
| * This is the way of making particular queries. | |
| */ | |
| public function query($const_name) | |
| { | |
| $this->res = array(); | |
| if(($this->q !== '') && ($this->q instanceof mysqli_stmt)) | |
| @$this->stmt->reset(); | |
| if(is_string($const_name) and defined($const_name)) | |
| $this->stmt->prepare(constant($const_name)); | |
| else | |
| return false; | |
| $this->q = $const_name; | |
| return true; | |
| } | |
| /* EXECUTION METHOD 1 | |
| * SELECT || SELECT COUNT(*) queries | |
| * | |
| * Used for storing result and | |
| * returning it... | |
| * | |
| * array $result_var = $q->get_r(array($arg1,$arg2...)); | |
| * | |
| */ | |
| public function get_r(array $args) | |
| { | |
| $rat = array(); | |
| $ra = array(); | |
| if($this->execute($args)) | |
| while($this->stmt->fetch()): | |
| $rat = array(); | |
| foreach($this->res as $key => $val): | |
| $rat[$key] = $val; | |
| endforeach; | |
| array_push($ra, $rat); | |
| endwhile; | |
| return $ra; | |
| } | |
| /* EXECUTION METHOD 2 | |
| * SELECT || SELECT COUNT(*) queries | |
| * | |
| * foreach($q->yield_r(array($arg1,$arg2...)) as $res_pos): | |
| * //do something; | |
| * endforeach; | |
| * | |
| */ | |
| public function yield_r(array $args) | |
| { | |
| if($this->execute($args)) | |
| while($this->stmt->fetch()) | |
| yield $this->res; | |
| else | |
| return; | |
| } | |
| /* EXECUTION METHOD 3 | |
| * INSERT || DELETE || UPDATE quesries | |
| * | |
| * $q->query(WITH_SPECIAL_QUERY); | |
| * alter(array($arg1,$arg2...)); | |
| * | |
| */ | |
| public function alter(array $args) | |
| { | |
| if(!$this->bind_ps($args)) | |
| return false; | |
| return @$this->stmt->execute(); | |
| } | |
| /*INTERNAL STUFF*/ | |
| private $stmt; | |
| private $res = array(); | |
| private $q = ''; | |
| private function execute(array $args) | |
| { | |
| if(!$this->bind_ps($args)) | |
| return false; | |
| $this->stmt->execute(); | |
| $this->bind_rs(); | |
| return true; | |
| } | |
| private function bind_rs() | |
| { | |
| if($this->stmt->field_count === count($this->res)) | |
| return false; | |
| $this->res = array(); | |
| $res_ref = array(); | |
| $meta_res = $this->stmt->result_metadata(); | |
| for($i = 0; $i < $this->stmt->field_count; $i++): | |
| $meta = $meta_res->fetch_field_direct($i); | |
| if(substr_count($meta->name, '*') > 0): | |
| $this->res[$i] = ''; | |
| $res_ref[$i] = &$this->res[$i]; | |
| else: | |
| $this->res[$meta->name] = ''; | |
| $res_ref[$i] = &$this->res[$meta->name]; | |
| endif; | |
| endfor; | |
| $meta_res->close(); | |
| call_user_func_array(array($this->stmt, 'bind_result'), $res_ref); | |
| } | |
| private function bind_ps(array $args){ | |
| $tmpa = array(); | |
| $types = ''; | |
| foreach($args as $k => $arg): | |
| if(is_string($arg)) | |
| $types .= 's'; | |
| elseif(is_long($arg)) | |
| $types .= 'i'; | |
| elseif(is_float($arg)) | |
| $types .= 'd'; | |
| else return false; | |
| $tmpa[] = &$args[$k]; | |
| endforeach; | |
| array_unshift($tmpa,$types); | |
| @call_user_func_array(array($this->stmt, 'bind_param'), $tmpa); | |
| return true; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" /> | |
| <meta name="keywords" content="blog,programowanie,php,grafika,hobby, <?php echo model\$KEYWORDS; ?> " /> | |
| <script src="js/lib.js"></script> | |
| <link rel="stylesheet" type="text/css" href="css/style2.css" /> | |
| <title><?php echo model\$TITLE; ?></title> | |
| </head> | |
| <body> | |
| <?php echo model\$LOG_BAR; ?> | |
| <div id="sheet_con"> | |
| <div id="baner" class="smallf"> | |
| <div class="break3 w100"></div> | |
| <div id="baner_container"> | |
| <a href="index.php" > | |
| <div class="w100" id="baner_div"> | |
| <br /> | |
| <h2> Herbalist</h2> | |
| <span class="baner_opis2"> [noob's adVentures]</span> | |
| </div> | |
| <span class="baner_opis2"> </span> | |
| </a> | |
| </div> | |
| <div id="menu"> | |
| <a href="index.php?pg=start" class="baner_opis" title="Start!">Start</a> | |
| <a href="index.php?pg=gal" class="baner_opis" title="Lista Kategorii.">Galeria</a> | |
| <a href="index.php?pg=blog" class="baner_opis" title="Lista Artykułów">Blog</a> | |
| <a href="index.php?pg=contact" class="baner_opis" title="Napisz do mnie!">Kontakt</a> | |
| </div> | |
| </div> | |
| <div id="sheet"> | |
| <div id="container"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| ob_start(); | |
| //initialisation time configuration | |
| require_once '/home/jak_sieciowyaty/Pulpit/jb20.includes/pathz.php'; | |
| require_once SETTINGS . '/sett.php'; | |
| //necessary objects and utilities | |
| require_once CREDS . '/dbc.php'; | |
| require_once OBJECTS . '/session.php'; | |
| require_once OBJECTS . '/dbstm.php'; | |
| require_once OBJECTS . '/authut.php'; | |
| require_once OBJECTS . '/crudcom.php'; | |
| /*---------------------------------------------*/ | |
| /*---------------------------------------------*/ | |
| /*---------------------------------------------*/ | |
| /*------*/ | |
| //MODEL1\\ | |
| /*------*/ | |
| //TITLE LOGBAR COOKIEBAR KEYWORDS | |
| //$q cookies | |
| require_once PROCEDURES . '/model1.php'; | |
| /*-----------*/ | |
| //CONTROLLER1\\ | |
| /*-----------*/ | |
| require_once PROCEDURES . '/action.switch.php'; | |
| /*----*/ | |
| //VIEW\\ | |
| /*----*/ | |
| require_once PROCEDURES . '/view.php'; | |
| ob_end_flush(); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace model | |
| { | |
| //application core critical variables | |
| $KEYWORDS = ''; | |
| $TITLE = 'Herbaliść'; | |
| $LOG_BAR = ''; | |
| $COOKIE_BAR = ''; | |
| $_wl_PART = array('gal','blog','contact','start','panel'); | |
| $PART = ''; | |
| $CONTENT = ''; | |
| //database statement object | |
| $q = new MysqliStmt(init\$db->stmt_init()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //this is main configuration/scripts directory | |
| define('CONF', dirname(__FILE__)); | |
| //credentials directory | |
| define('CREDS', CONF . '/crd'); | |
| //objects directory | |
| define('OBJECTS', CONF . '/objs'); | |
| //html parts directory | |
| define('HTML', CONF . '/htmlf'); | |
| //procedures directory | |
| define('PROCEDURES', CONF . '/procs'); | |
| //lists directory | |
| define('LISTS', CONF . '/lists'); | |
| //settings directory | |
| define('SETTINGS', CONF . '/sett'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function session_getname() | |
| { | |
| $hash = (string)strrev($_SERVER['REMOTE_ADDR']); | |
| $hashed = 'xyz' . sha1($hash); | |
| return $hashed; | |
| } | |
| function session() | |
| { | |
| $n = session_getname(); | |
| session_set_cookie_params(900, "/", $_SERVER['SERVER_NAME'], true, true); | |
| session_cache_limiter('nocache'); | |
| session_cache_expire(15); | |
| session_name($n); | |
| session_start(); | |
| if(!isset($_SESSION['ip'])){ | |
| $_SESSION['ip'] = sha1(md5($_SERVER['REMOTE_ADDR'])); | |
| } | |
| } | |
| function session_truncate_data() | |
| { | |
| $_SESSION = array(); | |
| $params = session_get_cookie_params(); | |
| setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); | |
| session_destroy(); | |
| session(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| include HTML . '/head.php'; | |
| echo model\$CONTENT; | |
| include HTML . '/footer.php'; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment