public function run()
 {
     Eloquent::unguard();
     Configuration::create(array('id' => 1, 'site_id' => currentSite()->id, 'name' => 'site.name', 'value' => 'Nome do síte'));
     Configuration::create(array('id' => 2, 'site_id' => currentSite()->id, 'name' => 'site.telephone', 'value' => 'Telefone'));
     Configuration::create(array('id' => 3, 'site_id' => currentSite()->id, 'name' => 'site.address', 'value' => 'Endereço'));
 }
예제 #2
0
 public function testCurrentSiteScope()
 {
     $site = currentSite();
     $banner = new Banner();
     $banner->name = 'Yes, It is a banner';
     $banner->save();
     $this->assertEquals($site->id, $banner->site_id);
 }
예제 #3
0
 public function run()
 {
     Eloquent::unguard();
     $banner = new Banner();
     $banner->id = 1;
     $banner->name = 'Banner Principal';
     $banner->site_id = currentSite()->id;
     $banner->save();
 }
예제 #4
0
 /**
  * Boot the current site trait
  *
  * @return void
  */
 public static function bootCurrentSiteTrait()
 {
     static::addGlobalScope(new CurrentSiteScope());
     $setSite = function ($model) {
         if (!$model->site_id) {
             $model->site_id = currentSite()->id;
         }
     };
     static::creating($setSite);
     static::updating($setSite);
 }
예제 #5
0
 public function throwError($errorId, $newPage = true)
 {
     /* @todo check if exists */
     if (!$newPage) {
         require currentSite()->absolutePath . 'page/error.php';
         return;
     }
     $page = currentSite()->getPage('error');
     $GLOBALS['currentPage'] = $page;
     $_SESSION['error_id'] = $errorId;
     View::publishForPage();
 }
예제 #6
0
파일: page.php 프로젝트: loonpwn/Lunor-CMS
 public function publishMETA()
 {
     $title = trigger('page_title', $this->pageTitle);
     if (empty($title) || !isset($title)) {
         publish('<title>' . $this->pageTitle . '</title>');
     } else {
         publish('<title>' . $title . '</title>');
     }
     publish('<meta name="description" content="' . $this->pageDesc . '">');
     publish('<meta name="keywords" content="' . $this->pageTags . '">');
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
         publish('<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>');
     }
     publish('<script>var resourceURL = "/' . currentSite()->relativePath . 'res/' . '";</script>');
 }
예제 #7
0
 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @return void
  */
 public function apply(Builder $builder)
 {
     $model = $builder->getModel();
     $site = currentSite();
     $builder->where('site_id', '=', $site->id);
 }
예제 #8
0
function resourceURL($type, $name)
{
    $folder = $type;
    switch ($type) {
        case 'javascript':
            $folder = 'js';
            break;
        case 'stylesheet':
            $folder = 'css';
            break;
        case 'image':
            $folder = 'img';
            break;
    }
    return RELPATH . currentSite()->relativePath . 'res/' . $folder . '/' . $name;
}
예제 #9
0
 public function testCurrent()
 {
     $site = currentSite();
     $this->assertTrue($site instanceof Site);
 }
예제 #10
0
 public static function upload(&$return)
 {
     if (!isset($_POST['meta']) || empty($_POST['meta'])) {
         $return['sucess'] = false;
         $return['error'] = 'Please provide a meta type for the file upload (TEXT, FILE).';
         return;
     }
     $meta = strtoupper($_POST['meta']);
     if ($meta != 'FILE' && $meta != 'TEXT') {
         $return['sucess'] = false;
         $return['error'] = 'Invalid meta type! : ' . $meta;
         return;
     }
     if ($meta == 'FILE') {
         $err = isValidFile(PASTE_FILE_TMP_NAME, PASTE_MAX_LENGTH_MB * 1000 * 1000);
         if ($err != true) {
             $return['sucess'] = false;
             $return['error'] = 'Bad file! Error: ' . $err;
             return;
         }
     }
     /* ensure that no output is sent to the json output */
     /* create and fill the paste object */
     $paste = new PasteHandler_Paste();
     $paste->fill($_POST);
     $paste->type = $meta;
     if ($meta == 'FILE') {
         $fileName = $_FILES[PASTE_FILE_TMP_NAME]['name'];
         if (!get_magic_quotes_gpc()) {
             $fileName = addslashes($fileName);
         }
         $dir = currentSite()->relativePath . 'uploads/';
         $permFile = $dir . getRandomString() . '_' . $fileName;
         $tmp = $_FILES[PASTE_FILE_TMP_NAME]["tmp_name"];
         /* change name so there's no colissions if someone uploads a file named the same thing */
         //	$_FILES[PASTE_FILE_TMP_NAME]["tmp_name"] = $_FILES[PASTE_FILE_TMP_NAME]["name"] = getRandomString() . $_FILES[PASTE_FILE_TMP_NAME]["name"] ;
         /* move the file out of the tmp directory */
         move_uploaded_file($tmp, $permFile);
         //echo 'tmp: ' . $tmp;
         //echo 'path : '  . currentSite()->absolutePath . 'uploads/' . getRandomString() . $_FILES[PASTE_FILE_TMP_NAME]["name"];
         if (exif_imagetype($permFile) !== false) {
             $paste->type = 'IMAGE';
         }
         $paste->datapath = $permFile;
         $paste->title = $fileName;
     }
     if (strlen($paste->data) > PASTE_MAX_LENGTH_MB * 1000 * 1000) {
         $return['sucess'] = false;
         $return['error'] = 'Paste too big. Please paste below ' . PASTE_MAX_LENGTH_MB . 'MB of data!';
         return;
     }
     if ($paste->exposure === 'private' && !Account_AccountAPI::getLoggedIn()) {
         $return['sucess'] = false;
         $return['error'] = 'You cannot use private pastes without being logged in.';
         return;
     }
     $longIP = findIPLong();
     /* check that this ip has not submitted more then the limit of pastes in last hour */
     $res = Lunor::$base->db->query('SELECT id from ' . TABLE_PREFIX . PASTE_TABLE_PREFIX . 'paste where `ip` = \'' . $longIP . '\' and DATE_SUB(NOW(), INTERVAL 1 HOUR) <= `since`;');
     if ($res !== false) {
         $res = Lunor::$base->dbi->fetchAll($res);
         $entries = sizeof($res);
         if ($entries >= PASTE_MAX_UPLOADS_PER_HOUR) {
             $return['sucess'] = false;
             $return['error'] = 'You have pasted too many items within the last hour. Please slow down. This is in place to stop spam bots.';
             return;
         }
     }
     /* give generated id */
     $paste->id = self::generateUID();
     $cur = new ORM_Operator(new PasteHandler_Paste(), array('id' => $paste->id));
     while (!$cur->isEmpty()) {
         $paste->id = self::generateUID();
         $cur = new ORM_Operator(new PasteHandler_Paste(), array('id' => $paste->id));
     }
     $paste->views = 0;
     $paste->since = 'CURRENT_TIMESTAMP';
     $paste->ip = $longIP;
     /* inset data into db */
     Lunor::$base->dbi->beginTransaction();
     Lunor::$base->dbi->setAdditionalPrefix(PASTE_TABLE_PREFIX);
     /*	insert base class into the db */
     $paste->insert();
     /* now need to put in variable table data */
     if ($_POST['expiration'] === 'views') {
         /* we are using the views table*/
         Lunor::$base->dbi->insert('expiration_views')->map(array('paste_id' => $paste->id, 'view_limit' => $_POST['views']))->go();
     } else {
         /* otherwise we use the time table */
         Lunor::$base->dbi->insert('expiration_time')->map(array('paste_id' => $paste->id, 'expires' => self::getTimestamp()))->go();
     }
     if ($_POST['meta'] === 'text') {
         /* if type is text we need to insert for the syntax highlighting */
         Lunor::$base->dbi->insert('paste_text')->map(array('paste_id' => $paste->id, 'syntax_highlighting' => $_POST['paste_mode']))->go();
     }
     /* adds our ip to the viewed list so we don't increment it ourself */
     Lunor::$base->dbi->insert('paste_view')->map(array('paste_id' => $paste->id, 'ip_address' => $longIP))->go();
     /* poster is not Guest! */
     if (Account_AccountAPI::getLoggedIn()) {
         Lunor::$base->dbi->insert('user_paste')->map(array('paste_id' => $paste->id, 'user_id' => Account_AccountAPI::getUserId()))->go();
     }
     /* if the transaction has to rollback then we let the client know it failed */
     if (Lunor::$base->dbi->endTransaction() === false) {
         $return['sucess'] = false;
         return;
     }
     $return['id'] = $paste->id;
     $return['sucess'] = true;
     return;
 }
예제 #11
0
파일: view.php 프로젝트: loonpwn/Lunor-CMS
 private static function requireTemplate()
 {
     require currentSite()->absolutePath . 'template.php';
 }