public static function get($vars) { $op = Db::result("SELECT `value` FROM `options` WHERE `name` = '{$vars}' LIMIT 1"); if (Db::$num_rows > 0) { return $op[0]->value; } else { return false; } }
$where .= "AND `date` >= '{$_GET['from']}' "; $qpage .= "&from={$_GET['from']}"; } if (isset($_GET['to']) && $_GET['to'] != '') { $where .= "AND `date` <= '{$_GET['to']}' "; $qpage .= "&to={$_GET['to']}"; } if (isset($_GET['status']) && $_GET['status'] != '') { $status = Typo::int($_GET['status']); $where .= "AND `status` LIKE '%%{$status}%%' "; $qpage .= "&status={$status}"; } $max = "15"; if (isset($_GET['paging'])) { $paging = Typo::int($_GET['paging']); $offset = ($paging - 1) * $max; } else { $paging = 1; $offset = 0; } $data['posts'] = Db::result("SELECT * FROM `posts` \n WHERE `type` = 'page' {$where} \n ORDER BY `date` DESC \n LIMIT {$offset},{$max}"); $data['num'] = Db::$num_rows; Theme::admin('header', $data); System::inc('pages', $data); Theme::admin('footer'); $page = array('paging' => $paging, 'table' => 'posts', 'where' => "`type` = 'page'" . $where, 'max' => $max, 'url' => 'index.php?page=pages' . $qpage, 'type' => 'pager'); echo Paging::create($page); break; } /* End of file pages.control.php */ /* Location: ./inc/lib/Control/Backend/pages.control.php */
public static function existParam($param, $post_id) { $sql = "SELECT * FROM `posts_param` WHERE `post_id` = '{$post_id}' AND `param` = '{$param}' LIMIT 1"; $q = Db::result($sql); if (Db::$num_rows > 0) { return true; } else { return false; } }
* @copyright 2014-2015 Puguh Wijayanto * @license http://www.opensource.org/licenses/mit-license.php MIT * */ $post = ""; $data['max'] = Options::get('post_perpage'); if (isset($_GET['paging'])) { $paging = Typo::int($_GET['paging']); if ($paging > 0) { $offset = ($paging - 1) * $data['max']; } else { $offset = 0; } $pagingtitle = " - Page {$paging}"; } else { $offset = 0; $paging = 1; $pagingtitle = ""; } //echo $paging; $data['sitetitle'] = Site::$slogan . $pagingtitle; $data['posts'] = Db::result(sprintf("SELECT * FROM `posts` \n WHERE `type` = 'post' \n AND `status` = '1'\n ORDER BY `date` \n DESC LIMIT %d, %d", $offset, $data['max'])); $data['num'] = Db::$num_rows; $url = SMART_URL ? Site::$url : Site::$url . '/index.php?'; $paging = array('paging' => $paging, 'table' => 'posts', 'where' => '`type` = \'post\'', 'max' => $data['max'], 'url' => $url, 'type' => Options::get('pagination')); $data['paging'] = Paging::create($paging, SMART_URL); Theme::theme('header', $data); Theme::theme('index', $data); Theme::footer(); /* End of file default.control.php */ /* Location: ./inc/lib/Control/Frontend/default.control.php */
if (!isset($alertred)) { /*check if username is exist or not */ $username = Typo::cleanX(Typo::strip($_POST['username'])); $sql = sprintf("SELECT `userid`,`status`,`activation` FROM `user` WHERE `userid` = '%s'", $username); $usr = Db::result($sql); $c = Db::$num_rows; //echo $c; //print_r($usr); if ($c == "1") { //$alertgreen = ""; // check if user is active if ($usr[0]->status == '1') { /* get user password */ $pass = User::randpass($_POST['password']); $sql = "SELECT `pass`,`group` FROM `user` WHERE `userid` = '{$username}'"; $l = Db::result($sql); $c = Db::$num_rows; foreach ($l as $v) { # code... //print_r($v); $p = $v->pass; $g = $v->group; } //echo $p; if ($p == $pass) { $vars = array('username' => $username, 'loggedin' => true, 'group' => $g); Session::set_session($vars); /* $_SESSION['username'] = $_POST['username']; $_SESSION['login'] = "******"; $_SESSION['group'] = $group;
/** * URL Slug Function. * This will load the url slug from the database according to the posts id. * * @author Puguh Wijayanto (www.metalgenix.com) * @since 0.0.1 */ public static function slug($vars) { $s = Db::result("SELECT `slug` FROM `posts` WHERE `id` = '{$vars}' LIMIT 1"); $s = $s[0]->slug; return $s; }
public static function type($id) { $id = sprintf('%d', $id); if (isset($id)) { $cat = Db::result("SELECT `type` FROM `cat` \n WHERE `id` = '{$id}' LIMIT 1"); //print_r($cat); if (isset($cat['error'])) { return ''; } else { return $cat[0]->type; } } else { echo "No ID Selected"; } //print_r($cat); }
} if (isset($_POST['token'])) { Token::remove($_POST['token']); } break; default: # code... break; } if (isset($_GET['act']) == 'del') { if (!isset($_GET['token']) || !Token::isExist($_GET['token'])) { // VALIDATE ALL $alertred[] = TOKEN_NOT_EXIST; } if (isset($alertred)) { $data['alertred'] = $alertred; } else { Categories::delete($_GET['id']); $data['alertgreen'][] = MSG_CATEGORY_REMOVED; } if (isset($_GET['token'])) { Token::remove($_GET['token']); } } $data['cat'] = Db::result("SELECT * FROM `cat` WHERE `type` = 'post' ORDER BY `id` DESC"); $data['num'] = Db::$num_rows; Theme::admin('header', $data); System::inc('categories', $data); Theme::admin('footer'); /* End of file categories.control.php */ /* Location: ./inc/lib/Control/Backend/categories.control.php */
if (isset($_GET['from']) && $_GET['from'] != '') { $where .= "AND `join_date` >= '{$_GET['from']}' "; $qpage .= "&from={$_GET['from']}"; } if (isset($_GET['to']) && $_GET['to'] != '') { $where .= "AND `join_date` <= '{$_GET['to']}' "; $qpage .= "&to={$_GET['to']}"; } if (isset($_GET['status']) && $_GET['status'] != '') { $where .= "AND `status` LIKE '%%{$_GET['status']}%%' "; $qpage .= "&status={$_GET['status']}"; } $max = "10"; if (isset($_GET['paging'])) { $paging = Typo::int($_GET['paging']); $offset = ($paging - 1) * $max; } else { $paging = 1; $offset = 0; } $data['usr'] = Db::result("SELECT * FROM `user` WHERE {$where} ORDER BY `userid` ASC LIMIT {$offset}, {$max}"); $data['num'] = Db::$num_rows; $page = array('paging' => $paging, 'table' => 'user', 'where' => $where, 'max' => $max, 'url' => 'index.php?page=users' . $qpage, 'type' => 'pager'); $data['paging'] = Paging::create($page); Theme::admin('header', $data); System::inc('user', $data); Theme::admin('footer'); break; } /* End of file users.control.php */ /* Location: ./inc/lib/Control/Backend/users.control.php */
public static function totalUser($vars) { $posts = Db::result("SELECT `id` FROM `user`"); $npost = Db::$num_rows; return $npost; }
public static function avatar($id) { $usr = Db::result(sprintf("SELECT * FROM `user_detail` WHERE `id` = '%d' OR `userid` = '%s' LIMIT 1", Typo::int($id), Typo::cleanX($id))); return $usr[0]->avatar; }
die("Direct Access Not Allowed!"); } /** * GeniXCMS - Content Management System * * PHP Based Content Management System and Framework * * @package GeniXCMS * @since 0.0.1 build date 20141006 * @version 0.0.6 * @link https://github.com/semplon/GeniXCMS * @link http://genixcms.org * @author Puguh Wijayanto (www.metalgenix.com) * @copyright 2014-2015 Puguh Wijayanto * @license http://www.opensource.org/licenses/mit-license.php MIT * */ $post = $_GET[$vars]; $data['posts'] = Db::result(sprintf("SELECT * FROM `posts` \n WHERE `id` = '%d' \n AND `type` = 'post'\n AND `status` = '1' \n LIMIT 1", $post)); if (Db::$num_rows > 0) { Theme::theme('header', $data); Theme::theme('single', $data); Theme::footer(); Stats::addViews($post); exit; } else { Control::error('404'); exit; } /* End of file post.control.php */ /* Location: ./inc/lib/Control/Frontend/post.control.php */
* @link https://github.com/semplon/GeniXCMS * @link http://genixcms.org * @author Puguh Wijayanto (www.metalgenix.com) * @copyright 2014-2015 Puguh Wijayanto * @license http://www.opensource.org/licenses/mit-license.php MIT * */ switch ($_GET['page']) { case 'sitemap': # code... Sitemap::create(); exit; break; default: # code... $page = Typo::cleanX(Typo::strip($_GET['page'])); $data['posts'] = Db::result(sprintf("SELECT * FROM `posts` \n WHERE (`id` = '%d' OR `slug` = '%s')\n AND `type` = 'page'\n AND `status` = '1'\n LIMIT 1", $page, $page)); if (Db::$num_rows > 0) { Theme::theme('header', $data); Theme::theme('page', $data); Theme::footer(); Stats::addViews($page); exit; } else { Control::error('404'); exit; } break; } /* End of file page.control.php */ /* Location: ./inc/lib/Control/Frontend/page.control.php */
$msg = str_replace('{{siteurl}}', Site::$url, $msg); $msg = str_replace('{{sitemail}}', Site::$email, $msg); if ($_POST['recipient'] == '') { $usr = Db::result("SELECT * FROM `user`"); foreach ($usr as $u) { # code... $msgs = str_replace('{{userid}}', $u->userid, $msg); $vars = array('to' => $u->email, 'to_name' => $u->userid, 'message' => $msgs, 'subject' => $subject, 'msgtype' => $_POST['type']); $mailsend = Mail::send($vars); if ($mailsend !== null) { $alertmailsend[] = $mailsend; } sleep(3); } } elseif ($_POST['recipient'] != '') { $usr = Db::result("SELECT * FROM `user` WHERE `group` = '{$_POST['recipient']}'"); foreach ($usr as $u) { # code... $msgs = str_replace('{{userid}}', $u->userid, $msg); $vars = array('to' => $u->email, 'to_name' => $u->userid, 'message' => $msgs, 'subject' => $subject, 'msgtype' => $_POST['type']); $mailsend = Mail::send($vars); if ($mailsend !== null) { $alermailsend[] = $mailsend; } sleep(3); } } if (isset($alertmailsend)) { $data['alertred'] = $alertmailsend; } else { $data['alertgreen'][] = "Success Sending Email";
define('GX_MOD', GX_PATH . '/inc/mod/'); define('GX_THEME', GX_PATH . '/inc/themes/'); define('GX_ASSET', GX_PATH . '/assets/'); require "autoload.php"; try { new System(); } catch (Exception $e) { echo $e->getMessage(); } if (isset($_POST['forgotpass'])) { // Check token first if (isset($_POST['token']) && Token::isExist($_POST['token'])) { /*check if username is exist or not */ $username = Typo::cleanX(Typo::strip($_POST['username'])); $sql = sprintf("SELECT `userid`,`email`,`status`,`activation` FROM `user` WHERE `userid` = '%s'", $username); $usr = Db::result($sql); $c = Db::$num_rows; //echo $c; //print_r($usr); if ($c == "1") { //$alertgreen = ""; // check if user is active if ($usr[0]->status == '1') { /* get user password */ $newpass = User::generatePass(); $id = User::id($username); $pass = User::randpass($newpass); $vars = array('id' => $id, 'user' => array('pass' => $pass)); User::update($vars); $date = Date::format(date("Y-m-d H:i:s")); $msg = "\n\t\tHello {$usr[0]->userid},\n\n\t\tYou are requesting Password Reset at " . Site::$name . " on {$date}. \n\t\tBelow are your new Password :\n\n\t\t{$newpass}\n\n\t\tNow you can login with your new Password at " . Site::$url . "\n\n\n\t\tBest Regards,\n\n\n\t\t" . Site::$name . "\n\t\t" . Site::$email . "\n\t\t\t\t";
if ($mailsend != "") { $alertred[] = $mailsend; } else { $data['alertgreen'][] = REG_ACTIVATE_ACCOUNT; } echo Hooks::run('user_reg_action'); } else { $data['alertred'] = $alertred; } if (isset($_POST['token'])) { Token::remove($_POST['token']); } } if (isset($_GET['activation'])) { # code... $usr = Db::result(sprintf("SELECT * FROM `user` WHERE `activation` = '%s' LIMIT 1", $_GET['activation'])); if (Db::$num_rows > 0) { $act = Db::query(sprintf("UPDATE `user` SET `status` = '1',`activation` = NULL WHERE `id` = '%d' ", $usr[0]->id)); if ($act) { $data['alertgreen'][] = REG_ACCOUNT_ACTIVATED; $vars = array('to' => $usr[0]->email, 'to_name' => $usr[0]->userid, 'subject' => 'Welcome to ' . Site::$name, 'message' => ' Hi ' . $usr[0]->userid . ', Thank You for Registering with Us. Your Account is Activated. You can now login : '******'/login.php with your username and password Sincerely, {$sitename} ', 'mailtype' => 'text'); $mailsend = Mail::send($vars); if ($mailsend != "") {
public static function create($vars, $smart = false) { if (is_array($vars)) { if (isset($vars['where'])) { $where = ' WHERE ' . $vars['where']; } else { $where = ''; } if (isset($vars['table'])) { Db::result("SELECT * FROM `{$vars['table']}` {$where}"); $dbtotal = Db::$num_rows; } if (isset($vars['total'])) { $total = $vars['total']; } else { $total = $dbtotal; } if (isset($vars['type']) && $vars['type'] == 'number') { // NUMBER $r = "<ul class=\"pagination\">"; $maxpage = 7; $curr = $vars['paging']; if ($curr < $maxpage / 2) { # code... $p = 1; if ($maxpage > ceil($total / $vars['max'])) { # code... $limit = ceil($total / $vars['max']); } else { $limit = $maxpage; } } elseif ($curr + floor($maxpage / 2) >= ceil($total / $vars['max'])) { $p = $vars['paging'] - (ceil($maxpage / 2) - 1); $limit = ceil($total / $vars['max']); // echo "more total"; } elseif ($curr + floor($maxpage / 2) > $maxpage) { $p = $vars['paging'] - (ceil($maxpage / 2) - 1); $limit = $curr + ceil($maxpage / 2) - 1; // echo "more maxpage"; } else { $p = $vars['paging'] - (ceil($maxpage / 2) - 1); $limit = $curr + floor($maxpage / 2); } for ($i = $p; $i <= $limit; $i++) { # code... if ($smart == true) { $url = $vars['url'] . "/paging/" . $i; } else { $url = $vars['url'] . "&paging=" . $i; } if ($vars['paging'] == $i) { $sel = "class=\"active\""; } else { $sel = ''; } $r .= "<li {$sel}><a href=\"{$url}\">{$i}</a></li>"; } $r .= "</ul>"; } elseif (isset($vars['type']) && $vars['type'] == 'pager') { // PAGER $r = "<ul class=\"pager\">"; $limit = ceil($total / $vars['max']); if ($vars['paging'] == 1) { $prev = $vars['paging'] + 1; } elseif ($vars['paging'] < $limit || ($vars['paging'] = $limit)) { $prev = $vars['paging'] - 1; if ($smart == true) { $url = $vars['url'] . "/paging/" . $prev; } else { $url = $vars['url'] . "&paging=" . $prev; } $r .= "<li class=\"pull-left\"><a href=\"{$url}\">Previous</a></li>"; } if ($vars['paging'] < $limit) { $next = $vars['paging'] + 1; # code... if ($smart == true) { $url = $vars['url'] . "/paging/" . $next; } else { $url = $vars['url'] . "&paging=" . $next; } $r .= "\n <li class=\"pull-right\"><a href=\"{$url}\">Next</a></li>"; } $r .= "</ul>"; } } else { $r = "<alert>Query Error, in Array Please</alert>"; } return $r; }
public static function getId($id = '') { if (isset($id)) { $sql = sprintf("SELECT * FROM `menus` WHERE `id` = '%d'", $id); $menus = Db::result($sql); $n = Db::$num_rows; } else { $menus = ''; } return $menus; }