Example #1
0
 function bbs()
 {
     $bbsid = intval($_GET['id']);
     import('@.ORG.Uc');
     $uc = new Uc();
     $uc->bbsid_login($bbsid);
     $this->success("转到论坛中...", $this->Config["bbs"]);
 }
Example #2
0
File: Uc.php Project: ukrcms/ukrcms
 /**
  *
  * @author  Ivan Scherbak <*****@*****.**>
  * @param string $appName
  * @param array  $config
  * @return \Uc\App
  */
 public static function initApp($appName, $config = array())
 {
     register_shutdown_function(array(__CLASS__, 'errorHandler'));
     set_error_handler(array(__CLASS__, 'errorHandler'));
     self::$app = new $appName($config);
     return self::$app;
 }
Example #3
0
 public function createMenu()
 {
     if (empty(\Uc::app()->params['bundles'])) {
         return false;
     }
     $menuTypes = array('leftMenu' => 'getAdminMenu', 'topMenu' => 'getAdminTopMenu');
     foreach ($menuTypes as $menuPosition => $methodName) {
         $bundles = \Uc::app()->params['bundles'];
         $menuItems = array();
         foreach ($bundles as $bundleClassName) {
             if (is_callable($bundleClassName . '::' . $methodName)) {
                 $menu = call_user_func($bundleClassName . '::' . $methodName);
                 $menuItems = array_merge($menuItems, $menu);
             }
         }
         $route = \Uc::app()->url->getRoute();
         foreach ($menuItems as $moduleName => $urls) {
             foreach ($urls as $k => $urlInfo) {
                 if (!empty($urlInfo['route'])) {
                     if ($urlInfo['route'] == $route) {
                         $menuItems[$moduleName][$k]['current'] = true;
                     }
                     $menuItems[$moduleName][$k]['href'] = \Uc::app()->url->create($urlInfo['route']);
                 }
             }
         }
         $this->{$menuPosition} = $menuItems;
     }
 }
Example #4
0
 public function getViewUrl()
 {
     if (Controller::MAIN_PAGE_SEF == $this->sef) {
         return \Uc::app()->url->create('ub/site/pages/mainpage');
     } else {
         return \Uc::app()->url->create('ub/site/pages/view', array('sef' => $this->sef));
     }
 }
Example #5
0
 /**
  *
  * @param $model
  */
 protected function setSeoMetaFromModel($model)
 {
     foreach (array('meta_title', 'meta_description', 'meta_keywords') as $property) {
         if (!empty($model->{$property})) {
             \Uc::app()->theme->setValue('seo_' . $property, $model->{$property});
         }
     }
     if (empty($model->meta_title) and !empty($model->title)) {
         \Uc::app()->theme->setValue('seo_meta_title', $model->title);
     }
 }
Example #6
0
 public function getViewUrl()
 {
     if (!empty($this->category_id)) {
         $categories = \Ub\Simpleblog\Categories\Table::instance()->getAllFromCache();
         if (!empty($categories)) {
             $category = $categories[$this->category_id];
         } else {
             $category = $this->category();
         }
         if (!empty($category)) {
             $params = array('postsef' => $this->sef, 'postpk' => $this->pk(), 'catsef' => $category->sef, 'catpk' => $category->pk());
             return \Uc::app()->url->create('ub/simpleblog/posts/view', $params);
         }
     }
     return '#error';
 }
Example #7
0
 /**
  *
  * @throws \Exception
  * @internal param string $sef
  */
 public function actionView()
 {
     $params = \Uc::app()->url->getParams();
     if (!empty($params['postpk'])) {
         $postTable = Table::instance();
         $post = $postTable->fetchOne($params['postpk']);
     }
     if (empty($post)) {
         throw new \Exception('Post not found', 404);
     }
     if (isset($_GET['addcomment'])) {
         return $this->actionAddComment($post);
     }
     \Uc::app()->theme->setValue('simpleblog_post_id', $post->pk());
     \Uc::app()->theme->setValue('simpleblog_category_id', $post->category->pk());
     # set meta tags
     $this->setSeoMetaFromModel($post);
     # init comments
     $this->render('view', array('model' => $post));
 }
Example #8
0
 /**
  * @author muhasjo <*****@*****.**>
  */
 public function actionContact()
 {
     $message = null;
     if (empty($_POST['email']) or filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
         $message = 'Поле email заповнено невірно';
     }
     if (!$message and empty($_POST['message'])) {
         $message = 'Заповність поле "повідомлення"';
     }
     if (empty($message)) {
         $mailFrom = $_POST['email'];
         $userName = !empty($_POST['name']) ? $_POST['name'] : 'noname';
         $message = $_POST['message'];
         $subject = "[UkrCMS]::[ContactForm] user " . $userName;
         $mailTo = \Ub\Site\Settings\Table::get('adminEmail');
         mail($mailTo, $subject, $message, "From: " . $mailFrom . "\r\n");
         $message = 'Ваші дані успішно відправлені';
     }
     \Uc::app()->theme->setValue('seo_meta_title', 'Зворотній звязок');
     $this->render('message', array('message' => $message));
 }
Example #9
0
 public function getViewUrl()
 {
     return \Uc::app()->url->create('ub/simpleblog/posts/category', array('catsef' => $this->sef, 'catpk' => $this->pk()));
 }
Example #10
0
 /**
  * @return \Uc\Core\Db
  */
 public function getAdapter()
 {
     return \Uc::app()->db;
 }
Example #11
0
 /**
  * @param string $file
  * @return string string
  */
 protected function getClassViewFilePath($file)
 {
     $object = new \ReflectionObject($this);
     $file = dirname($object->getFilename()) . DIRECTORY_SEPARATOR . \Uc::app()->theme->getViewsDir() . DIRECTORY_SEPARATOR . trim($file, DIRECTORY_SEPARATOR) . \Uc::app()->theme->getTemplateExtension();
     return $file;
 }
Example #12
0
 protected function getSessionKey()
 {
     return md5('user_id' . \Uc::app()->url->getBaseUrl());
 }
Example #13
0
 /**
  * Set default order
  *
  * @param string           $field
  * @param bool|\Uc\Db\type $exp
  * @return $this
  */
 public function order($field, $exp = false)
 {
     if (!empty($exp)) {
         $this->order['_def'] = \Uc::app()->db->quoteIdentifier($field) . " " . $exp;
     } else {
         $this->order['_def'] = $field;
     }
     return $this;
 }
Example #14
0
 public function getTableName()
 {
     return \Uc::app()->db->tablePrefix . 'pages';
 }
Example #15
0
 public function doreg()
 {
     $username = get_safe_replace($_POST['username']);
     $password = get_safe_replace($_POST['password']);
     $mobile = get_safe_replace($_POST['mobile']);
     $verifyCode = $_POST['verifyCode'];
     if (empty($username) || empty($password) || empty($mobile)) {
         $this->error(L('empty_username_empty_password_empty_email'));
     }
     if ($this->member_config['member_login_verify'] && md5($verifyCode) != $_SESSION['verify']) {
         $this->error(L('error_verify'));
     }
     $status = $this->member_config['member_registecheck'] ? 0 : 1;
     if ($this->member_config['member_emailcheck']) {
         $status = 1;
         $groupid = 5;
     }
     $groupid = $groupid ? $groupid : 3;
     /*-------------------------打入论坛----------------------------*/
     import('@.ORG.Uc');
     $uc = new Uc();
     $bbsuid = $uc->user_regeist($username, $password, $mobile . "@qq.com");
     $uc->bbsid_login($bbsuid);
     /*-----------------------------------------------------------*/
     $data = array();
     $data['username'] = $username;
     $data['fatherid'] = intval($_SESSION["uid"]);
     $data['mobile'] = $mobile;
     $data['groupid'] = $groupid;
     $data['login_count'] = 1;
     $data['createtime'] = time();
     $data['updatetime'] = time();
     $data['last_logintime'] = time();
     $data['reg_ip'] = get_client_ip();
     $data['status'] = $status;
     $data['bbs'] = $bbsuid;
     $authInfo['password'] = $data['password'] = sysmd5($password);
     if ($r = $this->dao->create($data)) {
         if (false !== $this->dao->add()) {
             $authInfo['id'] = $uid = $this->dao->getLastInsID();
             $authInfo['groupid'] = $ru['role_id'] = $data['groupid'];
             $ru['user_id'] = $uid;
             $roleuser = M('RoleUser');
             $roleuser->add($ru);
             session_start();
             $_SESSION["userid"] = $uid;
             if ($data['fatherid']) {
                 /*推广id*/
                 $sm["userid"] = $data['fatherid'];
                 $sm["share_ip"] = get_client_ip();
                 $sm["share_time"] = time();
                 $sm["mx"] = MODULE_NAME;
                 $sm["ma"] = ACTION_NAME;
                 $sm["mid"] = $uid;
                 $sm["type"] = 3;
                 //0点击,1,购买,3,注册
                 M("sharehistory")->add($sm);
             }
             /*				if($this->member_config['member_emailcheck']){
             					$yourphp_auth = authcode($uid."-".$username."-".$mobile, 'ENCODE',$this->sysConfig['ADMIN_ACCESS'],3600*24*3);//3天有效期
             					$url = 'http://'.$_SERVER['HTTP_HOST'].U('User/Login/regcheckemail?code='.$yourphp_auth);
             					$click = "<a href=\"$url\" target=\"_blank\">".L('CLICK_THIS')."</a>";
             					$message = str_replace(array('{click}','{url}','{sitename}'),array($click,$url,$this->Config['site_name']),$this->member_config['member_emailchecktpl']);
             					$r = sendmail($email,L('USER_REGISTER_CHECKEMAIL').'-'.$this->Config['site_name'],$message,$this->Config);
             					$this->assign('send_ok',1);
             					$this->assign('username',$username);
             					$this->assign('email',$email);
             					$this->display('Login:emailcheck');
             					exit;
             				}*/
             $yourphp_auth_key = sysmd5($this->sysConfig['ADMIN_ACCESS'] . $_SERVER['HTTP_USER_AGENT']);
             $yourphp_auth = authcode($authInfo['id'] . "-" . $authInfo['groupid'] . "-" . $authInfo['password'], 'ENCODE', $yourphp_auth_key);
             $authInfo['username'] = $data['username'];
             $authInfo['mobile'] = $data['mobile'];
             cookie('auth', $yourphp_auth, $cookietime);
             cookie('username', $authInfo['username'], $cookietime);
             cookie('groupid', $authInfo['groupid'], $cookietime);
             cookie('userid', $authInfo['id'], $cookietime);
             cookie('mobile', $authInfo['mobile'], $cookietime);
             $this->assign('jumpUrl', $this->forward);
             $this->success(L('reg_ok'));
         } else {
             $this->error(L('reg_error'));
         }
     } else {
         $this->error($this->dao->getError());
     }
 }
Example #16
0
echo \Uc::app()->url->create($listRoute);
?>
" class="<?php 
echo $statusRequest === null ? 'current' : '';
?>
">Усі</a>
      <?php 
foreach (\Ub\Simpleblog\Comments\Model::getStatusDescription() as $status => $statusName) {
    ?>
        <a href="<?php 
    echo \Uc::app()->url->create($listRoute, array('-w-status' => $status));
    ?>
" class="<?php 
    echo $statusRequest === $status ? 'current' : '';
    ?>
"><?php 
    echo $statusName;
    ?>
</a>
      <?php 
}
?>
      <div class="sep"></div>
    </div>
  </div>

<?php 
$widget = new \Ub\Admin\WidgetCrudList();
$widget->setData($data);
$widget->setOptions(array('hideTitle' => true, 'addRoute' => null, 'showFields' => array('name' => 'name', 'comment' => 'comment'), 'controllerRoute' => \Uc::app()->url->getControllerName()));
echo $widget->show();
Example #17
0
 public function getPath()
 {
     return \Uc::app()->params['basePath'] . \Uc::app()->params['filesPath'] . $this->fileStr();
 }
Example #18
0
 public function getPageTemplates()
 {
     \Uc::app()->theme->getViewFilePath();
 }
Example #19
0
 protected function validateLoginRoute()
 {
     $loginPageUrl = \Uc::app()->url->create(\Uc::app()->userIdentity->loginRoute);
     $currentUrl = \Uc::app()->url->getAbsoluteRequestUrl();
     return strpos($currentUrl, $loginPageUrl) === 0;
 }
Example #20
0
 function logout()
 {
     if ($this->_userid) {
         import('@.ORG.Uc');
         $uc = new Uc();
         $uc->logout();
         $_SESSION["uid"] = 0;
         $_SESSION["userid"] = 0;
         $this->_userid = 0;
         cookie(null, 'YP_');
         $this->assign('jumpUrl', $this->forward);
         $this->success(L('loginouted'));
     } else {
         $this->assign('jumpUrl', $this->forward);
         $this->error(L('logined'));
     }
 }
Example #21
0
 /**
  * @todo #phpstorm return application from \Uc\initApp
  * @return \Uc\Core\App
  */
 public function app()
 {
     return \Uc::app();
 }
Example #22
0
echo $model->published == 0 ? 'checked = "checked"' : '';
?>
/>
        No</label>
    </div>

    <div class="element">
      <label for="published">Коментарів #<?php 
echo count($model->Comments);
?>
</label>
      <?php 
foreach ($model->comments as $comment) {
    ?>
        <a href="<?php 
    echo \Uc::app()->url->create('ub/simpleblog/comments/admin/edit', array('pk' => $comment->pk()));
    ?>
" target="_blank">{<?php 
    echo $comment->status;
    ?>
          } <?php 
    echo $comment->name;
    ?>
</a>
        <br>
      <?php 
}
?>
    </div>

    <div class="entry">
Example #23
0
File: App.php Project: ukrcms/core
 /**
  * Run Application
  *
  * @throws \Exception
  */
 public function run()
 {
     try {
         $controllerRoute = $this->url->getControllerRoute();
         if (!$controllerRoute) {
             throw new \Uc\Core\Exception('Controller route is empty');
         }
         $actionRoute = $this->url->getActionRoute();
         if (!$actionRoute) {
             throw new \Uc\Core\Exception('Action route is empty');
         }
         # get names of controller and action
         $controllerRealName = $this->getControllerClassName($controllerRoute);
         $actionRelName = $this->getActionName($actionRoute);
         if (!class_exists($controllerRealName)) {
             throw new \Uc\Core\Exception('Controller class #' . $controllerRealName . ' does not exist');
         }
         $this->controller = new $controllerRealName();
         # validation of action
         if (!is_callable(array($this->controller, $actionRelName))) {
             throw new \Uc\Core\Exception('Action #' . $actionRelName . ' in controller #' . $controllerRealName . ' can not be call');
         }
         return $this->controller->{$actionRelName}();
     } catch (\Exception $exception) {
         $errorAction = (!empty($this->config) and !empty($this->config->errorAction)) ? $this->config->errorAction : null;
         if (!empty($errorAction)) {
             $errorControllerAction = \Uc::app()->url->getControllerActionFromRoute($this->config->errorAction);
         }
         if (!empty($errorControllerAction)) {
             try {
                 $controllerClass = $this->getControllerClassName($errorControllerAction[0]);
                 $actionRoute = $this->getActionName($errorControllerAction[1]);
                 $this->controller = new $controllerClass();
                 return $this->controller->{$actionRoute}($exception);
             } catch (\Exception $e) {
                 throw $e;
             }
         }
     }
     return;
 }
Example #24
0
 public function save()
 {
     if (!$this->beforeSave()) {
         return false;
     }
     # begin transaction
     $transactionKey = md5(microtime() . rand(0, 10)) . get_class($this);
     try {
         \Uc::app()->db->startTransaction($transactionKey);
         if (!empty($this->columnChanged) or $this->stored == false) {
             $table = $this->table;
             # insert or update
             if ($this->stored) {
                 # do Update of entity
                 $pk = $this->pk();
                 $fields = array_intersect_key($this->data, $this->columnChanged);
                 $result = $this->table->update($fields, $pk);
             } else {
                 # do Insert of entity
                 $result = $this->table->insert($this->data);
                 if ($result != false) {
                     # set primary key for entity
                     /*
                      * @todo update full data for Entity.
                      * For example we have fields id, name, title, date
                      * date is set automatically with database engine
                      * if we make insert in future we want to get date
                      * for this entity.
                      * So we need to set date for this model
                      * Look up to zend db
                      */
                     # Primary key can be set from modules.
                     $pk = $table->pk();
                     if (empty($this->{$pk})) {
                         $this->{$pk} = $result;
                         # last insert id
                     }
                 }
             }
             if ($result) {
                 # make entity new state
                 $this->stored = true;
                 $this->columnChanged = array();
             } else {
                 throw new \Exception('Can not save entity ' . get_class($this));
             }
         }
         # end transaction
         // @todo make rollback
         \Uc::app()->db->endTransaction($transactionKey);
     } catch (\Exception $exc) {
         echo $exc->getMessage() . "\n";
         echo $exc->getTraceAsString();
     }
     $this->afterSave();
     return true;
 }
Example #25
0
<?php

$widget = new \Ub\Admin\WidgetCrudList();
$widget->setData($data);
$widget->setOptions(array('showFields' => array('title' => 'title'), 'controllerRoute' => \Uc::app()->url->getControllerName()));
echo $widget->show();
Example #26
0
 public function showError(\Exception $exc)
 {
     # run custom controller for show error
     if (!empty($this->params) and !empty($this->params['errorHandler'])) {
         $controllerActionName = \Uc::app()->url->getControllerActionFromRoute($this->params['errorHandler']);
         if (!empty($controllerActionName[0]) and !empty($controllerActionName[1])) {
             $controllerClass = $this->getControllerClassName($controllerActionName[0]);
             $actionName = $this->getActionName($controllerActionName[1]);
             $this->controller = new $controllerClass();
             return $this->controller->{$actionName}($exc);
         }
     }
     return false;
 }
Example #27
0
 /**
  * @return bool
  */
 public function save()
 {
     if (!$this->beforeSave()) {
         return false;
     }
     # begin transaction
     $transactionKey = md5(microtime() . rand(0, 10)) . get_class($this);
     \Uc::app()->db->startTransaction($transactionKey);
     if (!empty($this->columnChanged) or $this->stored == false) {
         $table = $this->table;
         # insert or update
         if ($this->stored) {
             # do Update of entity
             $fields = array_intersect_key($this->data, $this->columnChanged);
             $result = $this->table->update($fields, $this->pk());
         } else {
             # do Insert of entity
             $result = $this->table->insert($this->data);
             if (!is_bool($result)) {
                 $pk = $table->pk();
                 $this->{$pk} = $result;
                 # last insert id
             }
         }
         if ($result) {
             # make entity new state
             $this->stored = true;
             $this->columnChanged = array();
         } else {
             #in fact if model not saved we have exception from DB
             throw new \Uc\Core\Exception('Can not save entity ' . get_class($this));
         }
     }
     # end transaction
     // @todo make rollback
     \Uc::app()->db->endTransaction($transactionKey);
     $this->afterSave();
     return true;
 }
Example #28
0
<?php

$widget = new \Ub\Admin\WidgetCrudList();
$widget->setData($data);
$widget->setOptions(array('showFields' => array('Логін' => 'login', 'Ім\'я' => 'name'), 'controllerRoute' => \Uc::app()->url->getControllerName()));
echo $widget->show();
Example #29
0
 /**
  * @throws \Exception
  */
 public function actionEdit()
 {
     $table = $this->getConnectedTable();
     if (!empty($_GET[static::PK_VAR])) {
         $model = $table->fetchOne($_GET[static::PK_VAR]);
     } else {
         $model = $table->createModel();
     }
     if (isset($_POST['save_and_list']) or isset($_POST['save_and_edit']) or isset($_POST['data'])) {
         $this->beforeSave($model);
         $this->setModelDataFromRequest($model);
         if ($model->save()) {
             # redirect user to edit page or list
             $this->afterSave($model);
             if (isset($_POST['save_and_list'])) {
                 $url = \Uc::app()->url->create(\Uc::app()->url->getControllerName() . '/list');
             } else {
                 $url = \Uc::app()->url->create(\Uc::app()->url->getRoute(), array('pk' => $model->pk()));
             }
             \Uc::app()->url->redirect($url);
         } else {
             throw new \Exception('Can not save entity ' . get_class($this));
         }
     }
     $this->renderView('edit', array('model' => $model));
 }
Example #30
0
<?php

$widget = new \Ub\Admin\WidgetCrudList();
$widget->setData($data);
$widget->setOptions(array('hideTitle' => true, 'showFields' => array('name' => 'title'), 'controllerRoute' => \Uc::app()->url->getControllerName()));
echo $widget->show();
?>
<div class="entry" style="text-align: center;">
  <?php 
foreach (array(30, 50, 100, 500) as $onPage) {
    ?>
    <a
      href="<?php 
    echo \Uc::app()->url->create(\Uc::app()->url->getRoute(), array('onPage' => $onPage, 'page' => 1));
    ?>
"
      class="<?php 
    echo (!empty($_GET['onPage']) and $onPage == $_GET['onPage']) ? 'current' : '';
    ?>
"
      ><?php 
    echo $onPage;
    ?>
</a>&nbsp;
  <?php 
}
?>
</div>