Exemple #1
0
 /**
  * Upload Proccess Function.
  * This will do the upload proccess. This function need some variables, eg: 
  * @param string $input This is the input field name.
  * @param string $path This is the path the file will be stored.
  * @param array $allowed This is the array of the allowed file extension.
  * @param false $uniq Set to true if want to use a unique name.
  * @param int $size File size maximum allowed.
  * @param int $width The width of the dimension.
  * @param int $height The height of the dimension.
  * 
  * @return array
  *
  * @author Puguh Wijayanto (www.metalgenix.com)
  * @since 0.0.1
  */
 public static function go($input, $path, $allowed = '', $uniq = false, $size = '', $width = '', $height = '')
 {
     $filename = Typo::cleanX($_FILES[$input]['name']);
     $filename = str_replace(' ', '_', $filename);
     if (isset($_FILES[$input]) && $_FILES[$input]['error'] == 0) {
         if ($uniq == true) {
             $site = Typo::slugify(Options::get('sitename'));
             $uniqfile = $site . '-' . sha1(microtime() . $filename) . '-';
         } else {
             $uniqfile = '';
         }
         $extension = pathinfo($_FILES[$input]['name'], PATHINFO_EXTENSION);
         $filetmp = $_FILES[$input]['tmp_name'];
         $filepath = GX_PATH . $path . $uniqfile . $filename;
         if (!in_array(strtolower($extension), $allowed)) {
             $result['error'] = 'File not allowed';
         } else {
             if (move_uploaded_file($filetmp, $filepath)) {
                 $result['filesize'] = filesize($filepath);
                 $result['filename'] = $uniqfile . $filename;
                 $result['path'] = $path . $uniqfile . $filename;
                 $result['filepath'] = $filepath;
                 $result['fileurl'] = Site::$url . $path . $uniqfile . $filename;
             } else {
                 $result['error'] = 'Cannot upload to directory, please check 
                 if directory is exist or You had permission to write it.';
             }
         }
     } else {
         //$result['error'] = $_FILES[$input]['error'];
         $result['error'] = '';
     }
     return $result;
 }
Exemple #2
0
 /**
  * Config File Creation Function.
  * This will create config file at inc/config/config.php during the installation
  * process. Data is gathered from the session.
  * 
  * @author Puguh Wijayanto (www.metalgenix.com)
  * @since 0.0.1
  */
 public static function makeConfig($file)
 {
     $config = "<?php if(!defined('GX_LIB')) die(\"Direct Access Not Allowed!\");\n/**\n* GeniXCMS - Content Management System\n* \n* PHP Based Content Management System and Framework\n*\n* @package GeniXCMS\n* @since 0.0.1 build date 20140925\n* @version 0.0.6\n* @link https://github.com/semplon/GeniXCMS\n* @link http://genixcms.org\n* @author Puguh Wijayanto (www.metalgenix.com)\n* @copyright 2014-2015 Puguh Wijayanto\n* @license http://www.opensource.org/licenses/mit-license.php MIT\n*\n*/error_reporting(0);\n\n// DB CONFIG\ndefine('DB_HOST', '" . Session::val('dbhost') . "');\ndefine('DB_NAME', '" . Session::val('dbname') . "');\ndefine('DB_PASS', '" . Session::val('dbpass') . "');\ndefine('DB_USER', '" . Session::val('dbuser') . "');\ndefine('DB_DRIVER', 'mysqli');\n\ndefine('SMART_URL', false); //set 'true' if you want use SMART URL (SEO Friendly URL)\ndefine('GX_URL_PREFIX', '.html');\n\n\n\n\n\n\n\n\n// DON't REMOVE or EDIT THIS.\ndefine('SECURITY_KEY', '" . Typo::getToken(200) . "'); // for security purpose, will be used for creating password\n\n        ";
     try {
         $f = fopen($file, "w");
         $c = fwrite($f, $config);
         fclose($f);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     return $config;
 }
Exemple #3
0
 public static function create($url = 'post', $type = 'post', $count = '20')
 {
     $posts = Posts::recent($count, $type);
     header("Content-Type: text/xml");
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
     $xml .= "\n            <rss version=\"2.0\">\n                <channel>\n                    <title>" . Site::$name . "</title>\n                    <link>" . Site::$url . "</link>\n                    <description>" . Site::$desc . "</description>\n            ";
     foreach ($posts as $p) {
         # code...
         $xml .= "\n                <item>\n                    <title>" . $p->title . "</title>\n                    <link>" . Url::$url($p->id) . "</link>\n                    <description>" . substr(strip_tags(Typo::Xclean($p->content)), 0, 260) . "</description>\n                </item>\n                ";
     }
     $xml .= "\n                </channel>\n            </rss>\n                ";
     echo $xml;
 }
Exemple #4
0
 public static function meta($cont_title = '', $cont_desc = '', $pre = '')
 {
     global $data;
     //print_r($data);
     //if(empty($data['posts'][0]->title)){
     if (is_array($data)) {
         $sitenamelength = strlen(self::$name);
         $limit = 70 - $sitenamelength - 6;
         if (isset($data['sitetitle'])) {
             $cont_title = substr(Typo::Xclean(Typo::strip($data['sitetitle'])), 0, $limit);
             $titlelength = strlen($data['sitetitle']);
         } elseif (isset($data['posts'][0]->title) && !isset($data['posts'][1]->title)) {
             $cont_title = substr(Typo::Xclean(Typo::strip($data['posts'][0]->title)), 0, $limit);
             $titlelength = strlen($data['posts'][0]->title);
         } else {
             $cont_title = substr(Typo::Xclean(Typo::strip(Options::get('siteslogan'))), 0, $limit);
             $titlelength = strlen(Options::get('siteslogan'));
         }
         if ($titlelength > $limit + 3) {
             $dotted = "...";
         } else {
             $dotted = "";
         }
         $cont_title = "{$pre} {$cont_title}{$dotted} - ";
     } else {
         $cont_title = "";
     }
     if (is_array($data) && isset($data['posts'][0]->content)) {
         $desc = Typo::strip($data['posts'][0]->content);
     } else {
         $desc = "";
     }
     $cont_title = Hooks::filter('site_title_filter', $cont_title);
     $keyword = Hooks::filter('site_key_filter', self::$key);
     echo "\n    <!--// Start Meta: Generated Automaticaly by GeniXCMS -->\n    <meta charset=\"" . Options::get('charset') . "\">";
     echo "\n    <!-- SEO: Title stripped 70chars for SEO Purpose -->\n    <title>{$cont_title}" . self::$name . "</title>\n    <meta name=\"Keyword\" content=\"" . $keyword . "\">\n    <!-- SEO: Description stripped 150chars for SEO Purpose -->\n    <meta name=\"Description\" content=\"" . self::desc($desc) . "\">";
     if (isset($data['posts'][0]->author) && !isset($data['posts'][1]->author)) {
         echo "\n    <meta name=\"Author\" content=\"{$data['posts'][0]->author}\">";
     }
     echo "\n    <meta name=\"Generator\" content=\"GeniXCMS " . System::v() . "\">\n    <meta name=\"robots\" content=\"" . Options::get('robots') . "\">\n    <link rel=\"shortcut icon\" href=\"" . Options::get('siteicon') . "\" />\n        ";
     echo Hooks::run('header_load_meta', $data);
     echo "\n    <!-- Generated Automaticaly by GeniXCMS :End Meta //-->";
     // echo $meta;
 }
Exemple #5
0
 public static function create()
 {
     $length = "80";
     $token = "";
     $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     $codeAlphabet .= "abcdefghijklmnopqrstuvwxyz";
     $codeAlphabet .= "0123456789";
     //$codeAlphabet.= SECURITY_KEY;
     for ($i = 0; $i < $length; $i++) {
         $token .= $codeAlphabet[Typo::crypto_rand_secure(0, strlen($codeAlphabet))];
     }
     $url = $_SERVER['REQUEST_URI'];
     $url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
     $ip = $_SERVER['REMOTE_ADDR'];
     $time = time();
     define('TOKEN', $token);
     define('TOKEN_URL', $url);
     define('TOKEN_IP', $ip);
     define('TOKEN_TIME', $time);
     $json = self::json();
     Options::update('tokens', $json);
     return $token;
 }
Exemple #6
0
<div class="col-sm-8 blog-main">
<?php 
foreach ($data['posts'] as $p) {
    # code...
    echo "\n        <div class=\"blog-post\">\n            <h2 class=\"blog-post-title\">{$p->title}</h2>\n           \n           " . Typo::Xclean($p->content) . "\n        </div>\n            ";
}
?>
</div>
<?php 
Theme::theme('rightside', $data);
Exemple #7
0
 switch ($submit) {
     case true:
         if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) {
             // VALIDATE ALL
             $alertred[] = TOKEN_NOT_EXIST;
         }
         if (!isset($_POST['name']) || $_POST['name'] == '') {
             $alertred[] = MENU_NAME_CANNOT_EMPTY;
         }
         if (!isset($_POST['type']) || $_POST['type'] == '') {
             $alertred[] = MENU_TYPE_CANNOT_EMPTY;
         }
         if (isset($alertred)) {
             $data['alertred'] = $alertred;
         } else {
             $vars = array('parent' => Typo::int($_POST['parent']), 'menuid' => Typo::strip($_POST['id']), 'name' => Typo::cleanX($_POST['name']), 'class' => Typo::cleanX($_POST['class']), 'type' => Typo::strip($_POST['type']), 'value' => Typo::cleanX($_POST[$_POST['type']]));
             Menus::insert($vars);
             $data['alertgreen'][] = 'Menu Item Added';
             Token::remove($_POST['token']);
         }
         break;
     default:
         # code...
         break;
 }
 // ADD MENU ITEM END
 // CHANGE ORDER START
 if (isset($_POST['changeorder'])) {
     $submit = true;
 } else {
     $submit = false;
Exemple #8
0
<?php

if (isset($_POST['sendmail'])) {
    // check token first
    if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) {
        # code...
        $alertred[] = TOKEN_NOT_EXIST;
    }
    if (isset($alertred)) {
        $data['alertred'] = $alertred;
    } else {
        $subject = Typo::cleanX($_POST['subject']);
        $msg = $_POST['message'];
        if ($_POST['type'] == 'text') {
            # code...
            $msg = str_replace('<br>', "\r\n\r\n", $msg);
            $msg = str_replace('</p><p>', "\r\n\r\n", $msg);
            $msg = str_replace('&nbsp;', " ", $msg);
            $msg = strip_tags($msg);
        } else {
            $msg = $msg;
        }
        $msg = str_replace('{{sitename}}', Site::$name, $msg);
        $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']);
            $flip = array_flip($_POST);
            $sql = "SELECT * FROM `options` WHERE `value` = 'on'";
            $q = Db::result($sql);
            foreach ($q as $ob) {
                if (isset($flip[$ob->name])) {
                    $vars[$ob->name] = 'on';
                    //echo $ob->name;
                } else {
                    $vars[$ob->name] = 'off';
                    //echo $ob->name;
                }
            }
            //print_r($ob);
            foreach ($_POST as $key => $val) {
                # code...
                $vars[$key] = Typo::cleanX($val);
            }
            unset($vars['change']);
            //print_r($vars);
            Options::update($vars);
            $data['alertgreen'][] = MSG_SETTINGS_SAVED;
        }
        if (isset($_POST['token'])) {
            Token::remove($_POST['token']);
        }
        break;
    default:
        # code...
        //print_r($data);
        break;
}
Exemple #10
0
 /**
  * Categories URL Function.
  * This will create the categories url automatically based on the SMART_URL 
  * will formatted as friendly url if SMART_URL is set to true.
  * 
  * @author Puguh Wijayanto (www.metalgenix.com)
  * @since 0.0.1
  */
 public static function cat($vars)
 {
     switch (SMART_URL) {
         case true:
             # code...
             $url = Site::$url . "/" . $vars . "/" . Typo::slugify(Categories::name($vars));
             break;
         default:
             # code...
             $url = Site::$url . "/index.php?cat={$vars}";
             break;
     }
     return $url;
 }
        # code...
        break;
}
switch (isset($_POST['updatecat'])) {
    case true:
        # code...
        // cleanup first
        $cat = Typo::cleanX($_POST['cat']);
        if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) {
            // VALIDATE ALL
            $alertred[] = TOKEN_NOT_EXIST;
        }
        if (isset($alertred)) {
            $data['alertred'] = $alertred;
        } else {
            $vars = array('table' => 'cat', 'id' => Typo::int($_POST['id']), 'key' => array('name' => $cat));
            $cat = Db::update($vars);
            $data['alertgreen'][] = MSG_CATEGORY_UPDATED . " " . $_POST['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;
Exemple #12
0
* @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 */
Exemple #13
0
        if (!Xaptcha::verify($_POST['g-recaptcha-response'])) {
            $alertred[] = "Your Captcha is not correct.";
        }
    }
    if (!User::is_exist($_POST['userid'])) {
        $alertred[] = MSG_USER_EXIST;
    }
    if (!User::is_same($_POST['pass1'], $_POST['pass1'])) {
        $alertred[] = MSG_USER_PWD_MISMATCH;
    }
    if (!User::is_email($_POST['email'])) {
        $alertred[] = MSG_USER_EMAIL_EXIST;
    }
    if (!isset($alertred)) {
        $activation = Typo::getToken(60);
        $vars = array('user' => array('userid' => Typo::cleanX(Typo::strip($_POST['userid'])), 'pass' => User::randpass($_POST['pass1']), 'email' => $_POST['email'], 'group' => '4', 'status' => '0', 'join_date' => date("Y-m-d H:i:s"), 'activation' => $activation), 'user_detail' => array('userid' => Typo::cleanX(Typo::strip($_POST['userid']))));
        if (User::create($vars) === true) {
            $data['alertgreen'][] = REG_ACTIVATE_ACCOUNT;
        } else {
            $alertred[] = REG_CANT_CREATE_ACCOUNT;
        }
        $vars = array('to' => $_POST['email'], 'to_name' => $_POST['userid'], 'subject' => 'Account Activation Needed at ' . Site::$name, 'message' => '
                            Hi ' . $_POST['userid'] . ', 

                            Thank You for Registering with Us. Please activate your account by clicking this link :
                            ' . Site::$url . '/register.php?activation=' . $activation . '

                            Sincerely,
                            {$sitename}
                            ', 'mailtype' => 'text');
        $mailsend = Mail::send($vars);
Exemple #14
0
define('GX_PATH', realpath(__DIR__ . '/'));
define('GX_LIB', GX_PATH . '/inc/lib/');
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);
    log_userLog("Edited definition {$definition->id} ({$definition->lexicon})");
    util_redirect('definitionEdit.php?definitionId=' . $definitionId);
}
$source = Source::get_by_id($definition->sourceId);
if (!$refreshButton && !$acceptButton && !$moveButton) {
    // If a button was pressed, then this is a POST request and the URL
    // does not contain the definition ID.
    RecentLink::createOrUpdate(sprintf("Definiție: %s (%s)", $definition->lexicon, $source->shortName));
}
smarty_assign('def', $definition);
smarty_assign('source', $source);
smarty_assign('user', User::get_by_id($definition->userId));
smarty_assign('comment', $comment);
smarty_assign('commentUser', $commentUser);
smarty_assign('lexems', $lexems);
smarty_assign('typos', Typo::get_all_by_definitionId($definition->id));
smarty_assign('homonyms', loadSetHomonyms($lexems));
smarty_assign("allStatuses", util_getAllStatuses());
smarty_assign("allModeratorSources", Model::factory('Source')->where('canModerate', true)->order_by_asc('displayOrder')->find_many());
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_displayWithoutSkin('admin/definitionEdit.ihtml');
/**
 * Load all lexems having the same form as one of the given lexems, but exclude the given lexems.
 **/
function loadSetHomonyms($lexems)
{
    if (count($lexems) == 0) {
        return array();
    }
    $names = array();
    $ids = array();
Exemple #16
0
 public static function deactivate($id)
 {
     $act = Db::query(sprintf("UPDATE `user` SET `status` = '0' WHERE `id` = '%d'", Typo::int($id)));
     if ($act) {
         return true;
     } else {
         return false;
     }
 }
Exemple #17
0
     * @param string $text
     * @return string
     */
    public static function rlQuotes($text)
    {
        return preg_replace(self::$_QUOTES_PATTERN, self::$_QUOTES_REPLACEMENT, $text);
    }
    /**
     * Typography applier
     * @param string $text Text for handle
     * @param array $rules Rules array. Look TypoRules class. By default using TypoRules::$STANDARD_RULES
     * @return string
     * @throws \InvalidArgumentException
     */
    public function typography($text, array $rules = null)
    {
        if ($rules === null) {
            $rules = TypoRules::$STANDARD_RULES;
        }
        if (array_diff($rules, TypoRules::$EXTENDED_RULES)) {
            throw new \InvalidArgumentException('Invalid typo rules');
        }
        foreach ($rules as $rule) {
            $funcName = 'rl' . $rule;
            $text = call_user_func(array($this, $funcName), $text);
        }
        return $text;
    }
}
Typo::staticConstructor();
Exemple #18
0
 public static function format($post, $id)
 {
     // split post for readmore...
     $post = Typo::Xclean($post);
     $more = explode('[[--readmore--]]', $post);
     //print_r($more);
     if (count($more) > 1) {
         $post = explode('[[--readmore--]]', $post);
         $post = $post[0] . " <a href=\"" . Url::post($id) . "\">" . READ_MORE . "</a>";
     } else {
         $post = $post;
     }
     $post = Hooks::filter('post_content_filter', $post);
     return $post;
 }
Exemple #19
0
     * @param string $text
     * @return string
     */
    public static function rlQuotes($text)
    {
        return preg_replace(self::$_QUOTES_PATTERN, self::$_QUOTES_REPLACEMENT, $text);
    }
    /**
     * Typography applier
     * @param string $text Text for handle
     * @param array $rules Rules array. Look TypoRules class. By default using TypoRules::$STANDARD_RULES
     * @return string
     * @throws \InvalidArgumentException
     */
    public function typography($text, array $rules = null)
    {
        if ($rules === null) {
            $rules = TypoRules::$STANDARD_RULES;
        }
        if (array_diff($rules, TypoRules::$EXTENDED_RULES)) {
            throw new \InvalidArgumentException('Invalid typo rules');
        }
        foreach ($rules as $rule) {
            $funcName = 'rl' . $rule;
            $text = call_user_func(array($this, $funcName), $text);
        }
        return $text;
    }
}
Typo::StaticConstructor();
Exemple #20
0
        if (isset($_GET['from']) && $_GET['from'] != '') {
            $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 */
Exemple #21
0
<?php

include "typos.class.php";
if (sizeof($_POST)) {
    $typo = new Typo();
    $dominios_mal_tipeados = $typo->get($_POST['name']);
}
?>
<form name="form1" method="post" action="">
  <p>
    <input name="name" type="text" id="name" value="<?php 
echo $_POST['name'];
?>
"> . <input name="tld" type="text" id="tld" size="5" maxlength="3" value="<?php 
echo $_POST['tld'];
?>
">
    <input type="submit" name="Submit" value="Enviar">
  </p>
  <p>
        <textarea name="domains" cols="50" rows="20" id="domains"><?php 
if (sizeof($_POST)) {
    foreach ($dominios_mal_tipeados as $dominios_mal_tipeado) {
        echo $dominios_mal_tipeado . "." . $_POST['tld'] . "\n";
    }
}
?>
        </textarea>
    </p>
</form>
Exemple #22
0
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
$typoId = util_getRequestParameter('id');
$typo = Typo::get_by_id($typoId);
if ($typo) {
    $typo->delete();
}
Exemple #23
0
 public static function updateMenuOrder($vars)
 {
     foreach ($vars as $k => $v) {
         # code...
         // print_r($v);
         $sql = array('table' => 'menus', 'id' => Typo::int($k), 'key' => $v);
         Db::update($sql);
     }
 }