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
 public static function insert($vars)
 {
     if (is_array($vars)) {
         $slug = Typo::slugify($vars['title']);
         $vars = array_merge($vars, array('slug' => $slug));
         //print_r($vars);
         $ins = array('table' => 'posts', 'key' => $vars);
         $post = Db::insert($ins);
         self::$last_id = Db::$last_id;
         Hooks::run('post_sqladd_action', $vars, self::$last_id);
         $pinger = Options::get('pinger');
         if ($pinger != "") {
             Pinger::run($pinger);
         }
     }
     return $post;
 }
Exemple #3
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;
 }
* @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
*
*/
$data['sitetitle'] = CATEGORIES;
switch (isset($_POST['addcat'])) {
    case true:
        # code...
        // cleanup first
        $slug = Typo::slugify(Typo::cleanX($_POST['cat']));
        $cat = Typo::cleanX($_POST['cat']);
        if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) {
            // VALIDATE ALL
            $alertred[] = TOKEN_NOT_EXIST;
        }
        if (!isset($_POST['cat']) || $_POST['cat'] == "") {
            $alertred[] = CATEGORY_CANNOT_EMPTY;
        }
        if (isset($alertred)) {
            $data['alertred'] = $alertred;
        } else {
            $cat = Db::insert(sprintf("INSERT INTO `cat` VALUES (null, '%s', '%s', '%d', '', 'post' )", $cat, $slug, $_POST['parent']));
            //print_r($cat);
            $data['alertgreen'][] = MSG_CATEGORY_ADDED . " " . $_POST['cat'];
        }