Ejemplo n.º 1
0
 public function process()
 {
     // $app = Phpfox_Module::instance()->get(($this->request()->get('id')));
     $App = (new Core\App())->get($this->request()->get('id'));
     if (!$App->is_module) {
         if ($val = $this->request()->get('val')) {
             if (!($error = User_Service_Auth::instance()->loginAdmin($val['email'], $val['password']))) {
                 throw new \Exception(implode('', Phpfox_Error::get()));
             }
             $App->delete();
             Phpfox::addMessage('App successfully uninstalled.');
             return ['redirect' => $this->url()->makeUrl('admincp/apps')];
         }
         if ($settings = $this->request()->get('setting')) {
             $Setting = new Core\Setting\Service($App);
             $Setting->save($settings);
             return ['updated' => true];
         }
         if ($this->request()->get('export')) {
             $App->export();
             exit;
         }
         $menus = [];
         if ($App->admincpMenu) {
             foreach ($App->admincpMenu as $key => $value) {
                 $menus[$key] = ['url' => $this->url()->makeUrl('admincp/' . $value)];
             }
         }
         $menus['Uninstall'] = ['url' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'uninstall' => 'yes'])];
         $settings = [];
         foreach ($App->settings as $key => $value) {
             if (!isset($value->type)) {
                 $value->type = 'input:text';
             }
             if (!isset($value->value)) {
                 $value->value = '';
             }
             if (setting($key) !== null) {
                 $value->value = setting($key);
             }
             $settings[$key] = ['info' => $value->info, 'value' => $value->value, 'type' => $value->type];
         }
         $this->template()->assign(['sSectionTitle' => $App->name, 'aSectionAppMenus' => $menus, 'ActiveApp' => $App, 'settings' => $settings]);
         if (defined('PHPFOX_IS_TECHIE') && PHPFOX_IS_TECHIE) {
             $this->template()->setActionMenu(['Export' => ['url' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'export' => '1']), 'class' => '']]);
         }
     }
     $customContent = '';
     // if ($App->storeId) {
     // $customContent = '<iframe src="http://store.phpfox.com/product/' . $App->storeId . '/go" frameborder="0" class="acp_frame_product"></iframe>';
     // }
     $this->template()->setTitle($App->name)->assign(['App' => $App, 'uninstall' => $this->request()->get('uninstall'), 'customContent' => $customContent]);
 }
Ejemplo n.º 2
0
 /**
  * Controller
  */
 public function process()
 {
     if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
         return ['goto' => $this->url()->makeUrl('admincp.login')];
     }
     if ($aVals = $this->request()->getArray('val')) {
         if (!empty($aVals['email']) && !empty($aVals['password'])) {
             if (User_Service_Auth::instance()->loginAdmin($aVals['email'], $aVals['password'])) {
                 $this->url()->send('current');
             }
         }
     }
     $this->template()->setHeader('login.css', 'style_css');
     $this->template()->setTemplate('blank');
 }
Ejemplo n.º 3
0
 /**
  * Create a new user or log them in if they exist
  *
  * @param \Facebook\GraphUser $fb
  * @return bool
  * @throws \Exception
  */
 public function create(\Facebook\GraphUser $fb)
 {
     $email = $fb->getId() . '@fb';
     $user = $this->db->select('*')->from(':user')->where(['email' => $email])->get();
     if (isset($user['user_id'])) {
         $_password = $fb->getId() . uniqid();
         $password = (new \Core\Hash())->make($_password);
         $this->db->update(':user', ['password' => $password], ['user_id' => $user['user_id']]);
     } else {
         $_password = $fb->getId() . uniqid();
         $password = (new \Core\Hash())->make($_password);
         $id = $this->db->insert(':user', ['user_group_id' => NORMAL_USER_ID, 'email' => $email, 'password' => $password, 'full_name' => $fb->getFirstName() . ' ' . $fb->getLastName(), 'user_name' => 'fb-' . $fb->getId(), 'user_image' => '{"fb":"' . $fb->getId() . '"}', 'joined' => PHPFOX_TIME, 'last_activity' => PHPFOX_TIME]);
         $tables = ['user_activity', 'user_field', 'user_space', 'user_count'];
         foreach ($tables as $table) {
             $this->db->insert(':' . $table, ['user_id' => $id]);
         }
     }
     \User_Service_Auth::instance()->login($email, $_password, true, 'email');
     if (!\Phpfox_Error::isPassed()) {
         throw new \Exception(implode('', \Phpfox_Error::get()));
     }
     return true;
 }
Ejemplo n.º 4
0
 private function _final()
 {
     $aForms = array();
     $aValidation = array('full_name' => 'full_name', 'email' => array('def' => 'email', 'title' => 'Provide a valid email.'), 'password' => array('def' => 'password', 'title' => 'Provide a valid password.'), 'user_name' => array('def' => 'username', 'title' => 'Provide a valid user name.'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aVals = $this->_oReq->getArray('val')) {
         Phpfox::getService('user.validate')->user($aVals['user_name'])->email($aVals['email']);
         if ($oValid->isValid($aVals)) {
             if ($iUserId = Phpfox::getService('user.process')->add($aVals, ADMIN_USER_ID)) {
                 list($bLogin, $aUser) = User_Service_Auth::instance()->login($aVals['email'], $aVals['password'], true, 'email');
                 if ($bLogin || isset($aVals['skip_user_login'])) {
                     define('PHPFOX_FEED_NO_CHECK', true);
                     User_Service_Auth::instance()->setUserId($iUserId);
                     $this->_db()->update(Phpfox::getT('user_field'), array('in_admincp' => PHPFOX_TIME), 'user_id = ' . $iUserId);
                     $this->_db()->update(Phpfox::getT('setting'), array('value_actual' => Phpfox::getVersion()), 'var_name = \'phpfox_version\'');
                     $this->_video(true);
                     User_Service_Process::instance()->updateStatus(['user_status' => 'Hello World!']);
                     // $this->_pass('completed');
                     return ['next' => 'completed'];
                 }
             }
         }
     } else {
         $aForms = array_merge($this->_video(), $aForms);
     }
     $this->_oTpl->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(false), 'aForms' => $aForms));
 }
Ejemplo n.º 5
0
 public function process()
 {
     // $app = Phpfox_Module::instance()->get(($this->request()->get('id')));
     $App = (new Core\App())->get($this->request()->get('id'));
     if (!$App->is_module) {
         if ($val = $this->request()->get('val')) {
             if (!($error = User_Service_Auth::instance()->loginAdmin($val['email'], $val['password']))) {
                 throw new \Exception(implode('', Phpfox_Error::get()));
             }
             $App->delete();
             Phpfox::addMessage('App successfully uninstalled.');
             return ['redirect' => $this->url()->makeUrl('admincp/apps')];
         }
         if ($settings = $this->request()->get('setting')) {
             $Setting = new Core\Setting\Service($App);
             $Setting->save($settings);
             return ['updated' => true];
         }
         if ($settings = $this->request()->get('user_group_setting')) {
             $UserGroupSetting = new Core\User\Setting();
             $UserGroupSetting->save($App, $settings);
             return ['updated' => true];
         }
         if ($this->request()->get('export')) {
             $App->export();
             exit;
         }
         $menus = [];
         if ($App->admincp_menu) {
             foreach ($App->admincp_menu as $key => $value) {
                 $menus[$key] = ['url' => $this->url()->makeUrl('admincp/' . trim($value, '/'))];
             }
         }
         /*
         $menus['Uninstall'] = [
         	'url' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'uninstall' => 'yes'])
         ];
         */
         $settings = [];
         foreach ($App->settings as $key => $value) {
             if (!isset($value->type)) {
                 $value->type = 'input:text';
             }
             if (!isset($value->value)) {
                 $value->value = '';
             }
             if (setting($key) !== null) {
                 $value->value = setting($key);
             }
             $settings[$key] = ['info' => $value->info, 'value' => $value->value, 'type' => $value->type];
         }
         $userGroups = User_Service_Group_Group::instance()->get();
         $userGroupSettings = [];
         if ($App->user_group_settings) {
             foreach ($userGroups as $group) {
                 $userGroupSettings[$group['user_group_id']] = ['id' => $group['user_group_id'], 'name' => $group['title'], 'settings' => []];
                 foreach ($App->user_group_settings as $key => $value) {
                     if (!isset($value->type)) {
                         $value->type = 'input:text';
                     }
                     if (!isset($value->value)) {
                         $value->value = '';
                     }
                     if (user($key) !== null) {
                         $value->value = user($key, null, $group['user_group_id']);
                     }
                     $userGroupSettings[$group['user_group_id']]['settings'][$key] = ['info' => $value->info, 'value' => $value->value, 'type' => $value->type];
                 }
             }
         }
         $this->template()->assign(['sSectionTitle' => $App->name, 'aSectionAppMenus' => $menus, 'ActiveApp' => $App, 'settings' => $settings, 'userGroupSettings' => $userGroupSettings]);
         if (defined('PHPFOX_IS_TECHIE') && PHPFOX_IS_TECHIE) {
             $this->template()->setActionMenu(['Export' => ['url' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'export' => '1']), 'class' => '']]);
         }
     }
     $customContent = $App->admincp_route;
     $this->template()->setTitle($App->name)->assign(['App' => $App, 'uninstall' => $this->request()->get('uninstall'), 'uninstallUrl' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'uninstall' => 'yes']), 'disableUrl' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'disable' => 'yes']), 'enableUrl' => $this->url()->makeUrl('admincp/app', ['id' => $App->id, 'enable' => 'yes']), 'customContent' => $customContent]);
 }
Ejemplo n.º 6
0
 protected function auth()
 {
     if (\Phpfox::isUser()) {
         return;
     }
     if (empty($_SERVER['HTTP_USER_ID'])) {
         throw new \Exception('This resource requires an HTTP USER_ID header.');
     }
     \User_Service_Auth::instance()->setUserId($_SERVER['HTTP_USER_ID']);
 }