Beispiel #1
0
 public function logout()
 {
     if ($this->isAuthenticated()) {
         $this->auth->logout();
         $this->user = null;
     }
 }
Beispiel #2
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return OW_Auth
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #3
0
 public function authenticate($params)
 {
     $token = null;
     if (!OW::getUser()->isAuthenticated()) {
         $params["username"] = empty($params["username"]) ? "" : $params["username"];
         $params["password"] = empty($params["password"]) ? "" : $params["password"];
         $result = OW::getUser()->authenticate(new BASE_CLASS_StandardAuth($params["username"], $params["password"]));
         if (!$result->isValid()) {
             $messages = $result->getMessages();
             throw new ApiResponseErrorException(array("message" => empty($messages) ? "" : $messages[0]));
         }
         $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     }
     $userId = OW::getUser()->getId();
     $avatarService = BOL_AvatarService::getInstance();
     $userService = BOL_UserService::getInstance();
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $userData = array("userId" => $userId, "displayName" => $userService->getDisplayName($userId), "avatar" => array("url" => $avatarService->getAvatarUrl($userId)), "suspended" => BOL_UserService::getInstance()->isSuspended($userId), "approved" => BOL_UserService::getInstance()->isApproved($userId));
     $this->assign("user", $userData);
     $this->assign("token", $token);
     $mainMenu = $service->getMenu($userId, 'main');
     $this->assign("mainMenu", $mainMenu);
     $bottomMenu = $service->getMenu($userId, 'bottom');
     $this->assign("bottomMenu", $bottomMenu);
     $this->assign('newCounter', $service->getNewItemsCount($mainMenu));
 }
Beispiel #4
0
 /**
  * Application init actions.
  */
 public function init()
 {
     require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'json_err_output.php';
     OW_ErrorManager::getInstance()->setErrorOutput(new BASE_CLASS_JsonErrOutput());
     $authToken = empty($_SERVER["HTTP_API_AUTH_TOKEN"]) ? null : $_SERVER["HTTP_API_AUTH_TOKEN"];
     OW_Auth::getInstance()->setAuthenticator(new OW_TokenAuthenticator($authToken));
     if (!empty($_SERVER["HTTP_API_LANGUAGE"])) {
         $tag = $_SERVER["HTTP_API_LANGUAGE"];
         $languageDto = BOL_LanguageService::getInstance()->findByTag($tag);
         if (empty($languageDto)) {
             $tag = mb_substr($tag, 0, 2);
             $languageDto = BOL_LanguageService::getInstance()->findByTag($tag);
         }
         if (!empty($languageDto) && $languageDto->status == "active") {
             BOL_LanguageService::getInstance()->setCurrentLanguage($languageDto);
         }
     }
     $this->detectLanguage();
     // setting default time zone
     date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone'));
     if (OW::getUser()->isAuthenticated()) {
         $userId = OW::getUser()->getId();
         $timeZone = BOL_PreferenceService::getInstance()->getPreferenceValue('timeZoneSelect', $userId);
         if (!empty($timeZone)) {
             date_default_timezone_set($timeZone);
         }
     }
     // synchronize the db's time zone
     OW::getDbo()->setTimezone();
     //        OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel');
     //        OW::getRequestHandler()->setStaticPageAttributes('BASE_CTRL_StaticDocument');
     //
     //        // router init - need to set current page uri and base url
     $router = OW::getRouter();
     $router->setBaseUrl(OW_URL_HOME . 'api/');
     $uri = OW::getRequest()->getRequestUri();
     // before setting in router need to remove get params
     if (strstr($uri, '?')) {
         $uri = substr($uri, 0, strpos($uri, '?'));
     }
     $router->setUri($uri);
     $router->setDefaultRoute(new OW_ApiDefaultRoute());
     OW::getPluginManager()->initPlugins();
     $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT);
     OW::getEventManager()->trigger($event);
     $beckend = OW::getEventManager()->call('base.cache_backend_init');
     if ($beckend !== null) {
         OW::getCacheManager()->setCacheBackend($beckend);
         OW::getCacheManager()->setLifetime(3600);
         OW::getDbo()->setUseCashe(true);
     }
     OW::getResponse()->setDocument($this->newDocument());
     if (OW::getUser()->isAuthenticated()) {
         BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext());
     }
 }
Beispiel #5
0
 public function init($dbReady)
 {
     OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator());
     $router = OW::getRouter();
     $router->setBaseUrl(OW_URL_HOME);
     $uri = OW::getRequest()->getRequestUri();
     $router->setUri($uri);
     $router->setDefaultRoute(new INSTALL_DefaultRoute());
     include INSTALL_DIR_ROOT . 'init.php';
 }
Beispiel #6
0
 public function ajaxCropPhoto($params)
 {
     if (isset($params['coords']) && isset($params['view_size'])) {
         $coords = $params['coords'];
         $viewSize = $params['view_size'];
         $userId = OW_Auth::getInstance()->getUserId();
         $avatarService = BOL_AvatarService::getInstance();
         $avatar = $avatarService->findByUserId($userId);
         $oldHash = $avatar->hash;
         $hash = time();
         try {
             $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'avatarId' => $avatar->id, 'upload' => false, 'crop' => true));
             OW::getEventManager()->trigger($event);
             $avatarService->cropAvatar($userId, $coords, $viewSize, $hash);
             // remove old avatar
             $oldAvatarPath = $avatarService->getAvatarPath($userId, 1, $oldHash);
             $avatarService->removeAvatarImage($oldAvatarPath);
             // update hash
             $avatar->hash = $hash;
             $avatarService->updateAvatar($avatar);
             // rename original
             $avatarService->renameAvatarOriginal($userId, $oldHash, $avatar->hash);
             $oldBigAvatarPath = $avatarService->getAvatarPath($userId, 2, $oldHash);
             $avatarService->removeAvatarImage($oldBigAvatarPath);
             $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'avatarId' => $avatar->id, 'upload' => false, 'crop' => true));
             OW::getEventManager()->trigger($event);
             $avatarService->trackAvatarChangeActivity($userId, $avatar->id);
             return array('result' => true, 'location' => OW_Router::getInstance()->urlForRoute('base_avatar_crop'));
         } catch (Exception $e) {
             return array('result' => false);
         }
     } else {
         return array('result' => false);
     }
 }
Beispiel #7
0
 /**
  * Application init actions.
  */
 public function init()
 {
     // router init - need to set current page uri and base url
     $router = OW::getRouter();
     $router->setBaseUrl(OW_URL_HOME);
     $this->urlHostRedirect();
     OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator());
     $this->userAutoLogin();
     // setting default time zone
     date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone'));
     // synchronize the db's time zone
     OW::getDbo()->setTimezone();
     //        OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel');
     OW::getRequestHandler()->setStaticPageAttributes('BASE_MCTRL_BaseDocument', 'staticDocument');
     $uri = OW::getRequest()->getRequestUri();
     // before setting in router need to remove get params
     if (strstr($uri, '?')) {
         $uri = substr($uri, 0, strpos($uri, '?'));
     }
     $router->setUri($uri);
     $defaultRoute = new OW_DefaultRoute();
     //$defaultRoute->setControllerNamePrefix('MCTRL');
     $router->setDefaultRoute($defaultRoute);
     $navService = BOL_NavigationService::getInstance();
     //
     //        // try to find static document with current uri
     //        $document = $navService->findStaticDocument($uri);
     //
     //        if ( $document !== null )
     //        {
     //            $this->documentKey = $document->getKey();
     //        }
     OW::getPluginManager()->initPlugins();
     $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT);
     OW::getEventManager()->trigger($event);
     $beckend = OW::getEventManager()->call('base.cache_backend_init');
     if ($beckend !== null) {
         OW::getCacheManager()->setCacheBackend($beckend);
         OW::getCacheManager()->setLifetime(3600);
         OW::getDbo()->setUseCashe(true);
     }
     $this->devActions();
     OW::getThemeManager()->initDefaultTheme(true);
     // setting current theme
     $activeThemeName = OW::getEventManager()->call('base.get_active_theme_name');
     $activeThemeName = $activeThemeName ? $activeThemeName : OW::getConfig()->getValue('base', 'selectedTheme');
     if ($activeThemeName !== BOL_ThemeService::DEFAULT_THEME && OW::getThemeManager()->getThemeService()->themeExists($activeThemeName)) {
         OW_ThemeManager::getInstance()->setCurrentTheme(BOL_ThemeService::getInstance()->getThemeObjectByName(trim($activeThemeName), true));
     }
     // adding static document routes
     $staticDocs = $navService->findAllMobileStaticDocuments();
     $staticPageDispatchAttrs = OW::getRequestHandler()->getStaticPageAttributes();
     /* @var $value BOL_Document */
     foreach ($staticDocs as $value) {
         OW::getRouter()->addRoute(new OW_Route($value->getKey(), $value->getUri(), $staticPageDispatchAttrs['controller'], $staticPageDispatchAttrs['action'], array('documentKey' => array(OW_Route::PARAM_OPTION_HIDDEN_VAR => $value->getKey()))));
         // TODO refactor - hotfix for TOS page
         if (UTIL_String::removeFirstAndLastSlashes($value->getUri()) == 'terms-of-use') {
             OW::getRequestHandler()->addCatchAllRequestsExclude('base.members_only', $staticPageDispatchAttrs['controller'], $staticPageDispatchAttrs['action'], array('documentKey' => $value->getKey()));
         }
     }
     //adding index page route
     $item = BOL_NavigationService::getInstance()->findFirstLocal(OW::getUser()->isAuthenticated() ? BOL_NavigationService::VISIBLE_FOR_MEMBER : BOL_NavigationService::VISIBLE_FOR_GUEST, OW_Navigation::MOBILE_TOP);
     if ($item !== null) {
         if ($item->getRoutePath()) {
             $route = OW::getRouter()->getRoute($item->getRoutePath());
             $ddispatchAttrs = $route->getDispatchAttrs();
         } else {
             $ddispatchAttrs = OW::getRequestHandler()->getStaticPageAttributes();
         }
         $router->addRoute(new OW_Route('base_default_index', '/', $ddispatchAttrs['controller'], $ddispatchAttrs['action'], array('documentKey' => array(OW_Route::PARAM_OPTION_HIDDEN_VAR => $item->getDocumentKey()))));
         $this->indexMenuItem = $item;
         OW::getEventManager()->bind(OW_EventManager::ON_AFTER_REQUEST_HANDLE, array($this, 'activateMenuItem'));
     } else {
         $router->addRoute(new OW_Route('base_default_index', '/', 'BASE_MCTRL_WidgetPanel', 'index'));
     }
     if (!OW::getRequest()->isAjax()) {
         OW::getResponse()->setDocument($this->newDocument());
         OW::getDocument()->setMasterPage(new OW_MobileMasterPage());
         OW::getResponse()->setHeader(OW_Response::HD_CNT_TYPE, OW::getDocument()->getMime() . '; charset=' . OW::getDocument()->getCharset());
     } else {
         OW::getResponse()->setDocument(new OW_AjaxDocument());
     }
     /* additional actions */
     if (OW::getUser()->isAuthenticated()) {
         BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext());
     }
     // adding global template vars
     $currentThemeImagesDir = OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl();
     $viewRenderer = OW_ViewRenderer::getInstance();
     $viewRenderer->assignVar('themeImagesUrl', $currentThemeImagesDir);
     $viewRenderer->assignVar('siteName', OW::getConfig()->getValue('base', 'site_name'));
     $viewRenderer->assignVar('siteTagline', OW::getConfig()->getValue('base', 'site_tagline'));
     $viewRenderer->assignVar('siteUrl', OW_URL_HOME);
     $viewRenderer->assignVar('isAuthenticated', OW::getUser()->isAuthenticated());
     $viewRenderer->assignVar('bottomPoweredByLink', '<a href="http://www.oxwall.org/" target="_blank" title="Powered by Oxwall Community Software"><img src="' . $currentThemeImagesDir . 'powered-by-oxwall.png" alt="Oxwall Community Software" /></a>');
     $viewRenderer->assignVar('adminDashboardIframeUrl', "http://static.oxwall.org/spotlight/?platform=oxwall&platform-version=" . OW::getConfig()->getValue('base', 'soft_version') . "&platform-build=" . OW::getConfig()->getValue('base', 'soft_build'));
     if (function_exists('ow_service_actions')) {
         call_user_func('ow_service_actions');
     }
     $this->handleHttps();
 }
Beispiel #8
0
 private function respondUserData($userId)
 {
     OW::getUser()->login($userId);
     $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     $baseCtrl = new SKANDROID_ACTRL_Base();
     $baseCtrl->siteInfo();
     foreach ($baseCtrl->assignedVars as $key => $val) {
         $this->assign($key, $val);
     }
     $this->assign("token", $token);
     $this->assign('loggedIn', true);
 }
Beispiel #9
0
function admin_set_admin_cookie()
{
    if (OW::getAuthorization()->isUserAuthorized(OW_Auth::getInstance()->getUserId(), 'admin') && !isset($_COOKIE['isAdmin'])) {
        setcookie('isAdmin', 1, time() + 3600 * 24 * 300, '/');
    }
}
Beispiel #10
0
 public function login($params)
 {
     $backUri = empty($_GET['backUri']) ? '' : urldecode($_GET['backUri']);
     $backUrl = OW_URL_HOME . $backUri;
     $language = OW::getLanguage();
     $fbUser = $this->service->fbRequireUser();
     $authAdapter = new FBCONNECT_CLASS_AuthAdapter($fbUser);
     // Login and redirect if already registered
     if ($authAdapter->isRegistered()) {
         $authResult = OW::getUser()->authenticate($authAdapter);
         if ($authResult->isValid()) {
             OW::getFeedback()->info($language->text('fbconnect', 'login_success_msg'));
         } else {
             OW::getFeedback()->error($language->text('fbconnect', 'login_failure_msg'));
         }
         $this->redirect($backUrl);
     }
     //Register if not registered
     $questions = $this->service->requestQuestionValueList($fbUser);
     if (empty($questions["email"]) || empty($questions["username"])) {
         OW::getFeedback()->error($language->text('fbconnect', 'join_incomplete'));
         $this->redirect($backUrl);
     }
     $username = $questions['username'];
     $password = uniqid();
     $userByEmail = BOL_UserService::getInstance()->findByEmail($questions['email']);
     if ($userByEmail !== null) {
         OW::getUser()->login($userByEmail->id);
         OW::getFeedback()->info($language->text('fbconnect', 'login_success_msg'));
         $this->redirect($backUrl);
     }
     $validUsername = UTIL_Validator::isUserNameValid($username);
     $username = $validUsername ? $username : uniqid("user_");
     try {
         $user = BOL_UserService::getInstance()->createUser($username, $password, $questions['email'], null, true);
         if (!$validUsername) {
             $user->username = "******" . $user->id;
             BOL_UserService::getInstance()->saveOrUpdate($user);
         }
         unset($questions['username']);
         unset($questions['email']);
     } catch (Exception $e) {
         switch ($e->getCode()) {
             case BOL_UserService::CREATE_USER_DUPLICATE_EMAIL:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_dublicate_email_msg'));
                 $this->redirect($backUrl);
                 break;
             case BOL_UserService::CREATE_USER_INVALID_USERNAME:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_incorrect_username'));
                 $this->redirect($backUrl);
                 break;
             default:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_incomplete'));
                 $this->redirect($backUrl);
         }
     }
     if (!empty($questions['picture_big'])) {
         BOL_AvatarService::getInstance()->setUserAvatar($user->id, $questions['picture_big']);
         unset($questions['picture_small']);
         unset($questions['picture_medium']);
         unset($questions['picture_big']);
     }
     BOL_QuestionService::getInstance()->saveQuestionsData(array_filter($questions), $user->id);
     $authAdapter->register($user->id);
     $authResult = OW_Auth::getInstance()->authenticate($authAdapter);
     if ($authResult->isValid()) {
         $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('method' => 'facebook', 'userId' => $user->id, 'params' => $_GET));
         OW::getEventManager()->trigger($event);
         OW::getFeedback()->info($language->text('fbconnect', 'join_success_msg'));
     } else {
         OW::getFeedback()->error($language->text('fbconnect', 'join_failure_msg'));
     }
     $this->redirect($backUrl);
 }
Beispiel #11
0
 public function login($params)
 {
     $backUri = empty($_GET['backUri']) ? '' : urldecode($_GET['backUri']);
     $backUrl = OW_URL_HOME . $backUri;
     $language = OW::getLanguage();
     $fbUser = $this->service->fbRequireUser();
     $authAdapter = new FBCONNECT_CLASS_AuthAdapter($fbUser);
     // Login and redirect if already registered
     if ($authAdapter->isRegistered()) {
         $authResult = OW::getUser()->authenticate($authAdapter);
         if ($authResult->isValid()) {
             OW::getFeedback()->info($language->text('fbconnect', 'login_success_msg'));
         } else {
             OW::getFeedback()->error($language->text('fbconnect', 'login_failure_msg'));
         }
         $this->redirect($backUrl);
     }
     //Register if not registered
     $questions = $this->service->requestQuestionValueList($fbUser);
     $username = $questions['username'];
     $password = uniqid();
     $userByEmail = BOL_UserService::getInstance()->findByEmail($questions['email']);
     if ($userByEmail !== null) {
         OW::getUser()->login($userByEmail->id);
         OW::getFeedback()->info($language->text('fbconnect', 'login_success_msg'));
         $this->redirect($backUrl);
     }
     try {
         $user = BOL_UserService::getInstance()->createUser($username, $password, $questions['email'], null, true);
         unset($questions['username']);
         unset($questions['email']);
     } catch (Exception $e) {
         switch ($e->getCode()) {
             case BOL_UserService::CREATE_USER_DUPLICATE_EMAIL:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_dublicate_email_msg'));
                 $this->redirect($backUrl);
                 break;
             case BOL_UserService::CREATE_USER_INVALID_USERNAME:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_incorrect_username'));
                 $this->redirect($backUrl);
                 break;
             default:
                 OW::getFeedback()->error($language->text('fbconnect', 'join_incomplete'));
                 $this->redirect($backUrl);
         }
     }
     if (!empty($questions['picture_small'])) {
         $avatarSaveResult = 0;
         $avatar = new BOL_Avatar();
         $avatar->hash = time();
         $avatar->userId = $user->id;
         $avatarService = BOL_AvatarService::getInstance();
         $pfSmallPicDir = $avatarService->getAvatarPluginFilesPath($user->id, 1, $avatar->hash);
         $pfMediumPicDir = $avatarService->getAvatarPluginFilesPath($user->id, 2, $avatar->hash);
         $pfBigPicDir = $avatarService->getAvatarPluginFilesPath($user->id, 3, $avatar->hash);
         $smallPicDir = $avatarService->getAvatarPath($user->id, 1, $avatar->hash);
         $mediumPicDir = $avatarService->getAvatarPath($user->id, 2, $avatar->hash);
         $bigPicDir = $avatarService->getAvatarPath($user->id, 3, $avatar->hash);
         $storage = OW::getStorage();
         if (rename($questions['picture_small'], $pfSmallPicDir)) {
             $avatarSaveResult += (int) $storage->copyFile($pfSmallPicDir, $smallPicDir);
         }
         if (!empty($questions['picture_medium'])) {
             if (rename($questions['picture_medium'], $pfMediumPicDir)) {
                 $avatarSaveResult += (int) $storage->copyFile($pfMediumPicDir, $mediumPicDir);
             }
         } else {
             $avatarSaveResult += (int) $storage->copyFile($pfSmallPicDir, $mediumPicDir);
         }
         if (!empty($questions['picture_big'])) {
             if (rename($questions['picture_big'], $pfBigPicDir)) {
                 $avatarSaveResult += (int) $storage->copyFile($pfBigPicDir, $bigPicDir);
             }
         } else {
             $avatarSaveResult += (int) $storage->copyFile($pfSmallPicDir, $bigPicDir);
         }
         if ($avatarSaveResult) {
             $avatarService->updateAvatar($avatar);
         }
         unset($questions['picture_small']);
         unset($questions['picture_medium']);
         unset($questions['picture_big']);
     }
     BOL_QuestionService::getInstance()->saveQuestionsData(array_filter($questions), $user->id);
     $authAdapter->register($user->id);
     $authResult = OW_Auth::getInstance()->authenticate($authAdapter);
     if ($authResult->isValid()) {
         $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('method' => 'facebook', 'userId' => $user->id, 'params' => $_GET));
         OW::getEventManager()->trigger($event);
         OW::getFeedback()->info($language->text('fbconnect', 'join_success_msg'));
     } else {
         OW::getFeedback()->error($language->text('fbconnect', 'join_failure_msg'));
     }
     $this->redirect($backUrl);
 }
Beispiel #12
0
 public function ajaxCropPhoto($params)
 {
     if (!isset($params['coords']) || !isset($params['view_size'])) {
         return array('result' => false, 'case' => 0);
     }
     $coords = $params['coords'];
     $viewSize = $params['view_size'];
     $path = null;
     $localFile = false;
     $avatarService = BOL_AvatarService::getInstance();
     if (!empty($params['entityType']) && !empty($params['id'])) {
         $item = $avatarService->getAvatarChangeGalleryItem($params['entityType'], $params['entityId'], $params['id']);
         if (!$item || empty($item['path']) || !OW::getStorage()->fileExists($item['path'])) {
             return array('result' => false, 'case' => 1);
         }
         $path = $item['path'];
     } else {
         if (isset($params['url'])) {
             $path = UTIL_Url::getLocalPath($params['url']);
             if (!OW::getStorage()->fileExists($path)) {
                 if (!file_exists($path)) {
                     return array('result' => false, 'case' => 2);
                 }
                 $localFile = true;
             }
         }
     }
     $userId = OW_Auth::getInstance()->getUserId();
     if ($userId) {
         $avatar = $avatarService->findByUserId($userId);
         try {
             $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'avatarId' => $avatar ? $avatar->id : null, 'upload' => false, 'crop' => true));
             OW::getEventManager()->trigger($event);
             if (!$avatarService->cropAvatar($userId, $path, $coords, $viewSize, array('isLocalFile' => $localFile))) {
                 return array('result' => false, 'case' => 6);
             }
             $avatar = $avatarService->findByUserId($userId, false);
             $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'avatarId' => $avatar ? $avatar->id : null, 'upload' => false, 'crop' => true));
             OW::getEventManager()->trigger($event);
             return array('result' => true, 'modearationStatus' => $avatar->status, 'url' => $avatarService->getAvatarUrl($userId, 1, null, false, false), 'bigUrl' => $avatarService->getAvatarUrl($userId, 2, null, false, false));
         } catch (Exception $e) {
             return array('result' => false, 'case' => 4);
         }
     } else {
         $key = $avatarService->getAvatarChangeSessionKey();
         $path = $avatarService->getTempAvatarPath($key, 3);
         if (!file_exists($path)) {
             return array('result' => false, 'case' => 5);
         }
         $avatarService->cropTempAvatar($key, $coords, $viewSize);
         return array('result' => true, 'url' => $avatarService->getTempAvatarUrl($key, 1), 'bigUrl' => $avatarService->getTempAvatarUrl($key, 2));
     }
 }
Beispiel #13
0
 public function login(array $params)
 {
     $post = $_POST;
     $token = null;
     // if (!OW::getUser()->isAuthenticated()) {
     if (empty($post["username"]) || empty($post["password"])) {
         throw new ErrorException();
     }
     $result = OW::getUser()->authenticate(new BASE_CLASS_StandardAuth($post["username"], $post["password"]));
     if (!$result->isValid()) {
         $messages = $result->getMessages();
         //                throw new ApiResponseErrorException(array(
         //            "message" => empty($messages) ? "" : $messages[0]
         //                ));
         //                throw new ErrorException(array(
         //            "message" => empty($messages) ? "" : $messages[0]
         //                ));
         $return_data = array("status" => "false", "message" => "unsuccess");
         echo json_encode($return_data);
         exit;
     } else {
         $token = OW_Auth::getInstance()->getAuthenticator()->getId();
         $tokenauth = new OW_TokenAuthenticator($token);
         //echo "newuser->" . $user_id = BOL_AuthTokenDao::getInstance()->findUserIdByToken($token);
         $service = PHOTO_BOL_PhotoService::getInstance();
         $this->user = BOL_UserService::getInstance()->findUserById($result->getUserId());
         $user_id = $result->getUserId();
         $email = $this->user->getEmail();
         $username = $this->user->getUsername();
         $avatars = BOL_AvatarService::getInstance()->getAvatarsUrlList(array($user_id));
         $tokenauth->login($user_id);
         $token = $tokenauth->getToken();
         //                $status = PHOTO_BOL_PhotoDao::STATUS_APPROVED;
         //                $list = $service->findPhotoListByUserId($user_id, 1, 500, array());
         //                echo '<pre>list->';
         //                print_r($avatars);
         //                echo '</pre>';
         //                if ($list) {
         //                    foreach ($list as $photo) {
         //                        $result[] = self::preparePhotoData($photo['id'], $photo['hash'], $photo['dimension'], $photo['status']);
         //                    }
         //                }
         // $profile_pic = $result;
         $status = "true";
         $messages = "success";
         $return_data = array("userid" => $user_id, "username" => $username, "email" => $email, "image" => $avatars[$user_id], "status" => "true", "message" => "success");
         echo json_encode($return_data);
         // }
         // $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     }
     //
     //        $baseCtrl = new SKANDROID_ACTRL_Base();
     //        $baseCtrl->siteInfo();
     //        foreach ($baseCtrl->assignedVars as $key => $val) {
     //            $this->assign($key, $val);
     //        }
     //        echo "token->" . $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     //        $tokenauth = new OW_TokenAuthenticator($token);
     //        echo "user_id->" . $tokenauth->getUserId();
     //        $this->assign("token", $token);
     exit;
 }
Beispiel #14
0
 private function respondUserData($userId)
 {
     $avatarService = BOL_AvatarService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->assign("userId", $userId);
     $this->assign("displayName", $userService->getDisplayName($userId));
     $this->assign("avatar", array("url" => $avatarService->getAvatarUrl($userId)));
     $this->assign("suspended", BOL_UserService::getInstance()->isSuspended($userId));
     $this->assign("approved", BOL_UserService::getInstance()->isApproved($userId));
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $mainMenu = $service->getMenu($userId, 'main');
     $this->assign("mainMenu", $mainMenu);
     $bottomMenu = $service->getMenu($userId, 'bottom');
     $this->assign("bottomMenu", $bottomMenu);
     $this->assign('newCounter', $service->getNewItemsCount($mainMenu));
     $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     $this->assign("token", $token);
 }
Beispiel #15
0
 *
 *
 * This example instantiates a Slim application using
 * its default settings. However, you will usually configure
 * your Slim application now by passing an associative array
 * of setting names and values into the application constructor.
 *
 *
 *
 */
//$app = new \Slim\Slim();
$app = new \Slim\Slim();
//$baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
$BOL_UserDao = BOL_UserDao::getInstance();
$ow_user = OW::getUser();
$OW_Auth_inst = OW_Auth::getInstance();
$Userservice = BOL_UserService::getInstance();
$EmailVerifyService = BOL_EmailVerifyService::getInstance();
$BOL_AvatarService_inst = BOL_AvatarService::getInstance();
$SKAPI_BOL_Service_inst = SKAPI_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService_inst = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$PHOTO_BOL_PhotoTemporaryService = PHOTO_BOL_PhotoTemporaryService::getInstance();
$UserResetPassword = BOL_UserResetPasswordDao::getInstance();
$QuestionService = BOL_QuestionService::getInstance();
$AccountTypeToGenderService = SKADATE_BOL_AccountTypeToGenderService::getInstance();
$BOL_AuthorizationService = BOL_AuthorizationService::getInstance();
$BOL_UserOnlineDao = BOL_UserOnlineDao::getInstance();
$USEARCH_BOL_Service = USEARCH_BOL_Service::getInstance();
$BOL_SearchService = BOL_SearchService::getInstance();
$getPluginManager = OW::getPluginManager();
Beispiel #16
0
 public function login()
 {
     $post = $_POST;
     $token = null;
     $required_data = array("username", "password");
     foreach ($required_data as $rdata) {
         if (!array_key_exists($rdata, $post) || empty($post[$rdata])) {
             $return = array("response_message" => "Please enter " . $rdata, "response_status" => "0");
             echo json_encode($return);
             exit;
         }
     }
     if (empty($post["username"]) || empty($post["password"])) {
         throw new ErrorException();
     }
     $deviceId = $post["token"];
     $deviceType = $post["type"];
     $email_check = BOL_UserDao::getInstance()->findUserByUsernameOrEmail($post["username"]);
     $email_exits = count($email_check);
     if ($email_exits != '1') {
         $messages = "Sorry!!!�Your�email is not �registered";
         $return_data = array("response_status" => '0', "response_message" => $messages);
         echo json_encode($return_data);
         exit;
     } else {
         $result = OW::getUser()->authenticate(new BASE_CLASS_StandardAuth($post["username"], $post["password"]));
         if (!$result->isValid()) {
             $messages = $result->getMessages();
             $messages = "Sorry!!! Your password doesnot match. Please try again";
             $return_data = array("response_status" => '0', "response_message" => $messages);
             echo json_encode($return_data);
             exit;
         } else {
             $token = OW_Auth::getInstance()->getAuthenticator()->getId();
             $tokenauth = new OW_TokenAuthenticator($token);
             $service = PHOTO_BOL_PhotoService::getInstance();
             $this->user = BOL_UserService::getInstance()->findUserById($result->getUserId());
             $email = $this->user->getEmail();
             $account_type = $this->user->getAccountType();
             if ($account_type == "8cc28eaddb382d7c6a94aeea9ec029fb") {
                 $sex = "lady";
             } else {
                 $sex = "gentleman";
             }
             $username = $this->user->getUsername();
             $user_id = $result->getUserId();
             $avatars = BOL_AvatarService::getInstance()->getAvatarsUrlList(array($user_id));
             $check_exist_value = SKAPI_BOL_Service::getInstance()->findValueExistOrNot($user_id);
             //                echo "<pre>";
             //                print_r($check_exist_value);
             //                exit;
             $count_content = count($check_exist_value);
             if ($count_content == "0") {
                 $user_details = SKAPI_BOL_Service::getInstance()->createUserDetails($user_id, $deviceId, $deviceType);
             }
             $messages = "Login Successfully";
             $return_data = array("response_status" => '1', "response_message" => $messages, "data" => array("user_id" => $user_id, "user_name" => $username, "email" => $email, "profile_picture" => $avatars[$user_id], "user_type" => $sex));
             echo json_encode($return_data);
             exit;
         }
     }
 }
Beispiel #17
0
 * http://www.oxwall.org/license. The License is based on the Mozilla Public License Version 1.1
 * but Sections 14 and 15 have been added to cover use of software over a computer network and provide for
 * limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent
 * with Exhibit B. Software distributed under the License is distributed on an “AS IS” basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language
 * governing rights and limitations under the License. The Original Code is Oxwall software.
 * The Initial Developer of the Original Code is Oxwall Foundation (http://www.oxwall.org/foundation).
 * All portions of the code written by Oxwall Foundation are Copyright (c) 2011. All Rights Reserved.
 * EXHIBIT B. Attribution Information
 * Attribution Copyright Notice: Copyright 2011 Oxwall Foundation. All rights reserved.
 * Attribution Phrase (not exceeding 10 words): Powered by Oxwall community software
 * Attribution URL: http://www.oxwall.org/
 * Graphic Image as provided in the Covered Code.
 * Display of Attribution Information is required in Larger Works which are defined in the CPAL as a work
 * which combines Covered Code or portions thereof with code not governed by the terms of the CPAL.
 */
define('OW_USE_CONTEXT', 8);
// CLI context
define('DS', DIRECTORY_SEPARATOR);
define('OW_DIR_ROOT', __DIR__ . DS);
require_once OW_DIR_ROOT . 'ow_includes' . DS . 'init.php';
require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'cli_err_output.php';
OW_ErrorManager::getInstance()->setErrorOutput(new BASE_CLASS_CliErrOutput());
// setting default time zone
date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone'));
OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator());
OW::getPluginManager()->initPlugins();
$event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT);
OW::getEventManager()->trigger($event);
$event = new OW_Event(OW_EventManager::ON_CLI_RUN, array('args' => $argv));
OW::getEventManager()->trigger($event);
Beispiel #18
0
 public function authenticate($post, $params)
 {
     $token = null;
     if (!OW::getUser()->isAuthenticated()) {
         if (empty($post["username"]) || empty($post["password"])) {
             throw new ApiResponseErrorException();
         }
         $result = OW::getUser()->authenticate(new BASE_CLASS_StandardAuth($post["username"], $post["password"]));
         if (!$result->isValid()) {
             $messages = $result->getMessages();
             throw new ApiResponseErrorException(array("message" => empty($messages) ? "" : $messages[0]));
         }
         $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     }
     $baseCtrl = new SKANDROID_ACTRL_Base();
     $baseCtrl->siteInfo();
     foreach ($baseCtrl->assignedVars as $key => $val) {
         $this->assign($key, $val);
     }
     $this->assign("token", $token);
 }