Пример #1
0
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $data = $data->fork();
     $apps = array();
     foreach (Typeframe::Registry()->pages() as $page) {
         if ($page->siteid() == Typeframe::CurrentPage()->siteid()) {
             if (strpos($page->uri(), '/admin/') !== false) {
                 if ($page->allow()) {
                     $apps[] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri());
                 }
             }
         }
     }
     $data['applications'] = $apps;
     if (class_exists('Model_Site')) {
         $sites = new Model_Site();
         if (Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) {
             $sites->innerJoin('perm', 'Model_User_Site', 'id = perm.siteid');
             $sites->where('perm.userid = ?', Typeframe::User()->get('userid'));
             $primary = new Model_User_Site();
             $primary->where('userid = ?', Typeframe::User()->get('userid'));
             $primary->where('siteid = ?', 0);
             $data['admin_primary'] = $primary->count() > 0;
         } else {
             $data['admin_primary'] = 1;
         }
         $data['sites'] = $sites;
     }
     $data->sortNodes(array('applications', 'title'));
     if (defined('TYPEF_HOST')) {
         $data['primary_host'] = TYPEF_HOST;
     }
     parent::output($data, $stream);
 }
Пример #2
0
 public function registerUser($data)
 {
     $Site = new Model_Site();
     //check required fields
     if (!$data['Email'] || !$data['esig1234'] || !$data['password1'] || !$data['password2'] || !$data['Firstname']) {
         return array('msg' => 'Missing Required fields.');
     }
     $fields = array();
     $fields['Created'] = date('Y-m-d H:i:s');
     $fields['LastEdited'] = date('Y-m-d H:i:s');
     foreach ($data as $key => $val) {
         $fields[$key] = $Site->sanitize($val);
     }
     //check if email matches
     if ($fields['esig1234'] != $fields['Email']) {
         return array('msg' => 'Emails did not match.');
     }
     //check if passwords reqs met
     if (strlen($fields['password1']) < 8) {
         return array('msg' => 'Password must be at least 8 characters.');
     }
     //check if passwords matches
     if ($fields['password1'] != $fields['password2']) {
         return array('msg' => 'Passwords did not match.');
     }
     //check if email exists
     $emailcheck = $this->getData("SiteUsers", " SiteEmail='" . $fields['Email'] . "'");
     if ($emailcheck) {
         return array('msg' => 'Email already exists.');
     }
     //check if SiteUsername exists
     $emailcheck = $this->getData("SiteUsers", " SiteUsername='******'SiteUsername'] . "'");
     if ($emailcheck) {
         return array('msg' => 'That username already exists or is reserved.');
     }
     //
     $fields['Type'] = 'Personal';
     $fields['SiteUsername'] = isset($fields['SiteUsername']) ? $fields['SiteUsername'] : $fields['Email'];
     $fields['SiteEmail'] = $fields['Email'];
     $fields['SitePassword'] = md5($fields['password1']);
     $fields['anAdmin'] = 0;
     unset($fields['esig1234']);
     unset($fields['Email']);
     unset($fields['password1']);
     unset($fields['password2']);
     $new_user = $this->insertData('SiteUsers', $fields);
     return $new_user;
 }
Пример #3
0
 private static function _AtResponse(Typeframe_Response $response)
 {
     $settings = $response->page()->settings();
     if (!empty($settings['skin'])) {
         return $settings['skin'];
     }
     $uri = $response->applicationUri();
     $admin_root = TYPEF_WEB_DIR . '/admin';
     if (Typeframe::CurrentPage()->siteid() != 0) {
         $site = Model_Site::Get(Typeframe::CurrentPage()->siteid());
         if ($site['directory']) {
             $admin_root = TYPEF_WEB_DIR . '/' . $site['directory'] . '/admin';
         }
     }
     if ($uri == $admin_root || substr($uri, 0, strlen($admin_root . '/')) == $admin_root . '/') {
         if (TYPEF_USE_MOBILE_SKINS && self::_IsMobile()) {
             return TYPEF_MOBILE_ADMIN_SKIN;
         }
         if (TYPEF_ADMIN_SKIN) {
             return TYPEF_ADMIN_SKIN;
         }
     }
     if (TYPEF_USE_MOBILE_SKINS && self::_IsMobile()) {
         return TYPEF_MOBILE_SITE_SKIN;
     }
     return TYPEF_SITE_SKIN ? TYPEF_SITE_SKIN : 'default';
 }
Пример #4
0
 public static function get_treasures($alias = null)
 {
     if ($alias !== null) {
         $site = \Model_Site::find_by_alias($alias);
         if (!$site instanceof \Model_Site) {
             die('abon');
         }
         $sites[] = $site;
     } else {
         $sites = \Model_Site::find('all');
     }
     $treasures = array();
     foreach ($sites as $site) {
         $captures = array(array('url' => $site->url));
         $patterns = explode('@@@@', $site->pattern);
         foreach ($patterns as $pattern) {
             $_captures = array();
             foreach ($captures as $capture) {
                 $url = $capture['url'];
                 $html = @file_get_contents($url);
                 if (preg_match_all('@' . $pattern . '@', $html, $matches)) {
                     foreach ($matches[1] as $match) {
                         if (strpos($match, 'http') !== 0) {
                             $info = parse_url($url);
                             $info['scheme'] .= ':/';
                             if (!isset($info['path'])) {
                                 $info['path'] = '/';
                             }
                             if ($info['path'] === '/') {
                                 $match = preg_replace('@../@', '', $match);
                                 $info['path'] = $match;
                             }
                             if (isset($info['port'])) {
                                 $info['host'] .= ':';
                             }
                             $match = join('/', $info);
                         }
                         // Url is starting 'http'
                         if (!empty($site->account)) {
                             // Put account information in url
                             $account = $site->account . ':' . $site->password . '@';
                             $match = preg_replace('@^(https?://)(.*)$@', '$1' . $account . '$2', $match);
                         }
                         $_capture = array('url' => $match);
                         if ($site->is_camouflage_referer) {
                             $_capture['referer'] = $url;
                         }
                         $_captures[] = $_capture;
                     }
                 } else {
                     // Match error
                 }
             }
             $captures = $_captures;
         }
         $treasures[$site->alias] = $captures;
     }
     return $treasures;
 }
Пример #5
0
 public static function show($alias = null)
 {
     $treasures = \Model_Site::get_treasures($alias);
     foreach ($treasures as $alias => $files) {
         echo sprintf('%s %s file(s)', $alias, count($files)) . "\n";
         foreach ($files as $file) {
             echo $file['url'] . "\n";
         }
     }
 }
Пример #6
0
 public function action_delete($id = null)
 {
     if ($site = Model_Site::find($id)) {
         $site->delete();
         Session::set_flash('success', e('Deleted site #' . $id));
     } else {
         Session::set_flash('error', e('Could not delete site #' . $id));
     }
     Response::redirect('admin/site');
 }
Пример #7
0
 public function indexAction()
 {
     $this->_helper->layout()->setLayout('redesign-2014');
     $Page = new Model_Page();
     if ($this->_getParam('pid') == 'index') {
         //$this->_redirect('/');
     }
     $pagedata = $Page->Display($this->_getParam('pid'));
     if (!$pagedata) {
         //check if product url
         $products = new Model_Products();
         $product = $products->ListProductByURL($this->_getParam('pid'));
         if ($product) {
             $this->_helper->layout()->setLayout('redesign-2014-product');
             $product_id = $product['ProductID'];
             $this->view->data = $product;
             $this->view->images = $products->DisplayProductImages($product_id);
             $this->view->pagetype = "product";
             $this->view->product_page = 1;
             $this->view->site_title = $product['Name'];
             $this->view->product_categories = $products->DisplayProductCategories($product_id);
             $this->view->product_attributes = $products->DisplayProductAttributes($product_id);
             $this->render('product');
         } else {
             throw new Zend_Controller_Action_Exception('This page does not exist', 404);
         }
     } else {
         $this->view->pagetype = "page";
         $this->view->data = $pagedata;
     }
     if ($pagedata['PageType'] == 'About') {
         $site = new Model_Site();
         $this->view->blurb_1 = $site->widget_blurb("Who We Are");
         $this->view->blurb_2 = $site->widget_blurb("Our Mission");
         $this->render('about');
     }
     if ($pagedata['PageType'] == 'Contact') {
         $this->render('contact');
     }
 }
Пример #8
0
<?php

$site = Model_Site::Get($_REQUEST['id']);
if ($site->exists()) {
    require_once 'options.inc.php';
    $pm->setVariable('site', $site);
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        include 'update.inc.php';
        Typeframe::Redirect('Site updated.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri()));
    }
} else {
    Typeframe::Redirect('Invalid site specified.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri()));
}
Пример #9
0
 private function isExist($siteId)
 {
     $site = DB::select('id')->from(Model_Site::table())->where('id', '=', $siteId)->execute()->current();
     return !empty($site);
 }
Пример #10
0
<?php

if ($page->exists() && $_POST['uri'] != $page['uri']) {
    $realPages = new Model_Page();
    $realPages->where('site.masterid = ?', $page['masterid']);
    $realPages->where('uri = ?', $page['uri']);
    //$realPages->updateQuery(array('uri' => $_POST['uri']));
    foreach ($realPages->select() as $rp) {
        $tmp = Model_Page::Get($rp['pageid']);
        $tmp['uri'] = $_POST['uri'];
        $tmp->save();
    }
}
$page->setArray($_POST, false);
$page->save();
$sites = new Model_Site();
$sites->where('masterid = ?', $master['id']);
foreach ($sites->select() as $site) {
    $realPages = new Model_Page();
    $realPages->where('siteid = ?', $site['id']);
    $realPages->where('uri = ?', $page['uri']);
    $realPage = $realPages->getFirst();
    if (!$realPage->exists()) {
        $realPage = Model_Page::Create();
        $realPage['siteid'] = $site['id'];
    }
    $realPage->setArray($page->getArray(), false);
    $realPage->save();
}
Typeframe::Registry()->purgeRegistryCache();
Пример #11
0
<?php

$site = Model_Site::Get($_REQUEST['id']);
if ($site->exists()) {
    $pm->setVariable('site', $site);
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        Model_Site::Delete($_POST['id']);
        Typeframe::Redirect('Site deleted.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri()));
    }
} else {
    Typeframe::Redirect('Invalid site specified.', Typeframe::CurrentPage()->applicationUri());
}
Пример #12
0
 public function siteid()
 {
     if (!is_null($this->_page->siteid())) {
         return $this->_page->siteid();
     } else {
         if (!defined('TYPEF_HOST')) {
             return 0;
         }
         if ($_SERVER['HTTP_HOST'] == TYPEF_HOST) {
             return 0;
         }
         $sites = new Model_Site();
         $sites->where('domain = ?', $_SERVER['HTTP_HOST']);
         foreach ($sites->select() as $site) {
             if ($site['directory'] == '' || strpos($this->uri(), $site['directory']) === 0) {
                 return $site['id'];
             }
         }
     }
 }
Пример #13
0
 private function _parseRegistry($xml)
 {
     // TODO: This is a clearly inefficient way of registering site pages
     // for hard-mapped applications. On the other hand, it might be efficient
     // enough after the registry is cached.
     static $sites = null;
     if (is_null($sites) && class_exists('Model_Site')) {
         $sites = array();
         $model = new Model_Site();
         foreach ($model->select() as $site) {
             $sites[] = $site->getArray();
         }
     }
     foreach ($xml->application as $app) {
         if ($app['map'] == 'hard') {
             // Load application as page
             $tmpApp = $this->_loadApplication($app);
             $fullPath = TYPEF_WEB_DIR . ($app['base'] != '/' ? $app['base'] : '');
             if ($fullPath == '') {
                 $fullPath = '/';
             }
             $this->_pages[$fullPath] = new Typeframe_Page($tmpApp, $fullPath, array('siteid' => 0));
             if (!is_null($sites)) {
                 foreach ($sites as $site) {
                     $fullPath = TYPEF_WEB_DIR . ($site['directory'] ? "/{$site['directory']}" : '') . ($app['base'] != '/' ? $app['base'] : '');
                     if ($fullPath == '') {
                         $fullPath = '/';
                     }
                     $this->_pages[$site['domain'] . $fullPath] = new Typeframe_Page($tmpApp, $fullPath, array('siteid' => $site['id']));
                 }
             }
         } else {
             // Load soft application
             $this->_applications["{$app['name']}"] = $this->_loadApplication($app);
         }
     }
 }
Пример #14
0
<?php

if (Typeframe::CurrentPage()->siteid()) {
    $site = Model_Site::Get(Typeframe::CurrentPage()->siteid());
    $pm->setVariable('typef_site', $site);
    $pm->setVariable('typef_siteid', $site['id']);
}
Пример #15
0
Файл: add.php Проект: ssrsfs/blg
<?php

require_once 'options.inc.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $site = Model_Site::Create();
    include 'update.inc.php';
    Typeframe::Redirect('New site created.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri()));
}
Пример #16
0
 public function settingsAction()
 {
     $isAdmin = $this->isAdmin();
     $site = new Model_Site();
     $blurbs = new Model_Widgetblurb();
     $this->view->pagetitles = $site->ListPageTitles();
     $this->view->widgetblurbs = $blurbs->listBlurbs();
     if ($_POST) {
         if (isset($_POST['widgetblurb'])) {
             $blurb = new Model_Widgetblurb();
             $data = array();
             foreach ($_POST['PageID'] as $k => $v) {
                 $data[$k]['PageID'] = $v;
             }
             foreach ($_POST['CharLimit'] as $k => $v) {
                 $data[$k]['CharLimit'] = $v;
             }
             //update the data
             foreach ($data as $row => $val) {
                 $blurb->add($val['PageID'], $val['CharLimit'], $row);
             }
             $this->_redirect('/admin/settings/');
         }
         if (isset($_POST['widgetblurbadd'])) {
             $blurb = new Model_Widgetblurb();
             $blurb->add($_POST['PageID'], $_POST['CharLimit']);
             $this->_redirect('/admin/settings/');
         }
     }
     if (isset($_GET['wbid'])) {
         $blurbs->oldSkul("delete from WidgetBlurb where ID = " . $_GET['wbid'], false);
         $this->_redirect('/admin/settings/');
     }
 }
Пример #17
0
 public function contactAction()
 {
     $site = new Model_Site();
     $contact_page = $site->getData("Pages", "PageType='Contact'");
     $contact_url = $contact_page[0]['URLSegment'];
     if ($_POST) {
         $save = $site->saveInquiry($_POST);
         if (!is_array($save)) {
             $this->_helper->layout()->setLayout('page');
             $this->view->inquirySaved = 1;
             $this->render('thankyou');
             //$this->_redirect($contact_url);
         } else {
             if ($contact_page) {
                 $contact_url = $contact_url . '?msg=Missing Fields';
             } else {
                 $contact_url = '/';
             }
             $this->_redirect($contact_url);
         }
     }
     $this->render('page');
 }
Пример #18
0
 public function delete_index($id)
 {
     DB::delete(Model_Site::table())->where('id', '=', $id)->execute();
     $this->response(array('ok' => true), 200);
 }