public function __construct() { Import::pH7App(PH7_SYS . PH7_MOD . 'im.models.MessengerModel'); $this->_oHttpRequest = new HttpRequest(); $this->_oMessengerModel = new MessengerModel(); switch ($this->_oHttpRequest->get('act')) { case 'heartbeat': $this->heartbeat(); break; case 'send': $this->send(); break; case 'close': $this->close(); break; case 'startsession': $this->startSession(); break; default: Framework\Http\Http::setHeadersByCode(400); exit('Bad Request Error!'); } if (empty($_SESSION['messenger_history'])) { $_SESSION['messenger_history'] = []; } if (empty($_SESSION['messenger_openBoxes'])) { $_SESSION['messenger_openBoxes'] = []; } }
/** * @return void */ public function __construct() { parent::__construct(); // Import the library Import::lib('Service.Twitter.tmhOAuth'); Import::lib('Service.Twitter.tmhUtilities'); $this->_oTwOAuth = new \tmhOAuth(Config::getInstance()->values['module.api']['twitter.consumer_key'], Config::getInstance()->values['module.api']['twitter.consumer_secret_key']); // determine the authentication status // default to 0 $this->_iState = 0; if (isset($_COOKIE['access_token'], $_COOKIE['access_token_secret'])) { // 2 (authenticated) if the cookies are set $this->_iState = 2; } elseif (isset($_SESSION['authstate'])) { // otherwise use value stored in session $this->_iState = (int) $_SESSION['authstate']; } if ($this->_iState == 1) { // if we are in the process of authentication we continue $this->auth(); } elseif ($this->_iState == 2 && !$this->auth()) { // verify authentication, clearing cookies if it fails $this->endSession(); } if ($this->auth()) { $aProfile = $this->_oTwOAuth->extract_params($this->_oTwOAuth->response['response']); if (empty($aProfile['error'])) { // User info is ok? Here we will be connect the user and/or adding the login and registering routines... $oUserModel = new UserCoreModel(); if (!($iId = $oUserModel->getId($aProfile['email']))) { // Add User if it does not exist in our database $this->add(escape($aProfile, true), $oUserModel); // Add User Avatar $this->setAvatar($aProfile); $this->oDesign->setFlashMsg(t('You have now been registered! %0%', (new Registration())->sendMail($this->_aUserInfo, true)->getMsg())); $this->sUrl = Uri::get('connect', 'main', 'register'); } else { // Login $this->setLogin($iId, $oUserModel); $this->sUrl = Uri::get('connect', 'main', 'home'); } unset($oUserModel); } else { // For testing purposes, if there was an error, let's kill the script $this->oDesign->setFlashMsg(t('Oops! An error has occurred. Please try again later.')); $this->sUrl = Uri::get('connect', 'main', 'index'); } } else { $this->sUrl = Uri::get('connect', 'main', 'index'); } }
/** * Constructor. * * @param object \PH7\Framework\Session\Session $oSession * @param object \PH7\Framework\Mvc\Request\Http $oHttpRequest * @param object \PH7\Framework\Registry\Registry $oRegistry * @return void */ public function __construct(Session $oSession, HttpRequest $oHttpRequest, Registry $oRegistry) { parent::__construct(); /*** Import the libraries ***/ Import::lib('Service.Google.OAuth.Google_Client'); Import::lib('Service.Google.OAuth.contrib.Google_Oauth2Service'); $oClient = new \Google_Client(); $oClient->setApplicationName($oRegistry->site_name); $this->_setConfig($oClient); $oOauth = new \Google_Oauth2Service($oClient); if ($oHttpRequest->getExists('code')) { $oClient->authenticate(); $oSession->set('token', $oClient->getAccessToken()); $this->sUrl = Uri::get('connect', 'main', 'home'); } if ($oSession->exists('token')) { $oClient->setAccessToken($oSession->get('token', false)); } if ($oClient->getAccessToken()) { // User info is ok? Here we will be connect the user and/or adding the login and registering routines... $oUserModel = new UserCoreModel(); // Get information of user $aUserData = $oOauth->userinfo->get(); if (!($iId = $oUserModel->getId($aUserData['email']))) { // Add User if it does not exist in our database $this->add(escape($aUserData, true), $oUserModel); // Add User Avatar if (!empty($aUserData['picture'])) { $this->setAvatar($aUserData['picture']); } $this->oDesign->setFlashMsg(t('You have now been registered! %0%', (new Registration())->sendMail($this->_aUserInfo, true)->getMsg())); $this->sUrl = Uri::get('connect', 'main', 'register'); } else { // Login $this->setLogin($iId, $oUserModel); $this->sUrl = Uri::get('connect', 'main', 'home'); } // Add the access token $oSession->set('token', $oClient->getAccessToken()); unset($oUserModel); } else { $this->sUrl = $oClient->createAuthUrl(); } unset($oClient, $oOauth); }
/** * @return void */ public function __construct() { parent::__construct(); // Import the library Import::lib('Service.Microsoft.Live.oauth_client'); Import::lib('Service.Microsoft.Live.http'); $this->_oClient = new \oauth_client_class(); $this->_setConfig(); /* API permissions */ $this->_oClient->scope = 'wl.basic wl.emails wl.birthday'; if ($bSuccess = $this->_oClient->Initialize()) { if ($bSuccess = $this->_oClient->Process()) { if (strlen($this->_oClient->authorization_error)) { $this->_oClient->error = $this->_oClient->authorization_error; $bSuccess = false; } elseif (strlen($this->_oClient->access_token)) { $bSuccess = $this->_oClient->CallAPI('https://apis.live.net/v5.0/me', 'GET', array(), array('FailOnAccessError' => true), $oUserData); } } $bSuccess = $this->_oClient->Finalize($bSuccess); } if ($this->_oClient->exit) { exit(1); } if ($bSuccess) { // User info is ok? Here we will be connect the user and/or adding the login and registering routines... $oUserModel = new UserCoreModel(); if (!($iId = $oUserModel->getId($oUserData->emails->account))) { // Add User if it does not exist in our database $this->add(escape($oUserData, true), $oUserModel); $this->oDesign->setFlashMsg(t('You have now been registered! %0%', (new Registration())->sendMail($this->_aUserInfo, true)->getMsg())); $this->sUrl = Uri::get('connect', 'main', 'register'); } else { // Login $this->setLogin($iId, $oUserModel); $this->sUrl = Uri::get('connect', 'main', 'home'); } unset($oUserModel); } else { // For testing purposes, if there was an error, let's kill the script $this->oDesign->setFlashMsg(t('Oops! An error has occurred. Please try again later.')); $this->sUrl = Uri::get('connect', 'main', 'index'); } }
/** * @return void */ public function __construct() { parent::__construct(); Import::lib('Service.Facebook.Facebook'); // Import the library $oFb = new \Facebook(array('appId' => Config::getInstance()->values['module.api']['facebook.id'], 'secret' => Config::getInstance()->values['module.api']['facebook.secret_key'])); $sUserId = $oFb->getUser(); if ($sUserId) { try { // Proceed knowing you have a logged in user who's authenticated. $aProfile = $oFb->api('/me'); } catch (\FacebookApiException $oE) { Framework\Error\CException\PH7Exception::launch($oE); $sUserId = null; } if ($aProfile) { // User info is ok? Here we will be connect the user and/or adding the login and registering routines... $oUserModel = new UserCoreModel(); if (!($iId = $oUserModel->getId($aProfile['email']))) { // Add User if it does not exist in our database $this->add(escape($aProfile, true), $oUserModel); // Add User Avatar $this->setAvatar($sUserId); $this->oDesign->setFlashMsg(t('You have now been registered! %0%', (new Registration())->sendMail($this->_aUserInfo, true)->getMsg())); $this->sUrl = Uri::get('connect', 'main', 'register'); } else { // Login $this->setLogin($iId, $oUserModel); $this->sUrl = Uri::get('connect', 'main', 'home'); } unset($oUserModel); } else { // For testing purposes, if there was an error, let's kill the script $this->oDesign->setFlashMsg(t('Oops! An error has occurred. Please try again later.')); $this->sUrl = Uri::get('connect', 'main', 'index'); } } else { // There's no active session, let's generate one $this->sUrl = $oFb->getLoginUrl(array('scope' => 'email,user_birthday,user_relationships,user_relationship_details,user_hometown,user_location,user_interests,user_about_me,user_likes,user_website')); } unset($oFb); }
public static function display() { if (isset($_POST['submit_ads'])) { if (\PFBC\Form::isValid($_POST['submit_ads'])) { new AdsFormProcess(); } Framework\Url\Header::redirect(); } $aAdSizes = Import::file(PH7_PATH_APP_CONFIG . 'ad_sizes'); $oForm = new \PFBC\Form('form_ads', 500); $oForm->configure(array('action' => '')); $oForm->addElement(new \PFBC\Element\Hidden('submit_ads', 'form_ads')); $oForm->addElement(new \PFBC\Element\Token('ads')); $oForm->addElement(new \PFBC\Element\Textbox(t('Title:'), 'title', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 40)))); $oForm->addElement(new \PFBC\Element\Select(t('Size of the Banner:'), 'size', $aAdSizes, array('required' => 1))); $sText = AdsCore::getTable() == 'AdsAffiliates' ? t('The predefined variable for the URL of an affiliate account to put in the HTML is: %0%.', '<strong>#!%affiliate_url%!#</strong>') : t('The predefined variable to the URL of your site to indicate this in the HTML is: %0%.', '<strong>#!%site_url%!#</strong>'); $oForm->addElement(new \PFBC\Element\Textarea(t('Banner:'), 'code', array('description' => $sText, 'required' => 1))); $oForm->addElement(new \PFBC\Element\Button()); $oForm->render(); }
/** * Get the instructions. * * @param string $sInstFile Instruction file. * @return mixed (string or boolean) Returns "false" if the file does not exist or if it fails, otherwise returns the "file contents" */ private function _readInstruction($sInstFile) { try { return F\Import::file(PH7_PATH_REPOSITORY . static::DIR . PH7_DS . $this->_sUpgradesDirUpgradeFolder . static::INFO_DIR . PH7_DS . $sInstFile); } catch (Framework\File\Exception $e) { return '<p class="error">' . t('Instruction file not found!') . '</p>'; } }
} // Loading Framework Classes require PH7_PATH_FRAMEWORK . 'Loader/Autoloader.php'; Framework\Loader\Autoloader::getInstance()->init(); /** Loading configuration files environments **/ // For All environment Import::file(PH7_PATH_APP . 'configs/environment/all.env'); // Specific to the current environment Import::file(PH7_PATH_APP . 'configs/environment/' . Config::getInstance()->values['application']['environment'] . '.env'); // Loading Class ~/protected/app/includes/classes/* Import::pH7App('includes.classes.Loader.Autoloader'); App\Includes\Classes\Loader\Autoloader::getInstance()->init(); // Loading Debug class Import::pH7FwkClass('Error.Debug'); // Loading String Class Import::pH7FwkClass('Str.Str'); /* Structure/General.class.php functions are not currently used */ // Import::pH7FwkClass('Structure.General'); /*** End Loading Files ***/ //** Temporary code. In the near future, pH7CMS will be usable without mod_rewrite if (!Server::isRewriteMod()) { $sMsg = '<p class="warning"><a href="' . Framework\Core\Kernel::SOFTWARE_WEBSITE . '">pH7CMS</a> requires Apache "mod_rewrite".</p> <p>Please install it so that pH7CMS can works.<br /> Click <a href="http://ph7cms.com/doc/en/how-to-install-rewrite-module" target="_blank">here</a> if you want to get more information on how to install the rewrite module.<br /><br /> After doing this, please <a href="' . PH7_URL_ROOT . '">retry</a>.</p>'; echo html_body("Apache's mod_rewrite is required", $sMsg); exit; } //*/ // Enable client browser cache (new Browser())->cache(); // Starting zlib-compressed output
/** * @access private * @return void */ private function ajaxRouter($sMod = null) { \PH7\Framework\File\Import::pH7FwkClass('Ajax.Ajax'); // Option for Content Type if ($this->oHttpRequest->getExists('option')) { if ($this->oHttpRequest->get('option') == 'plain') { header('Content-Type: text/plain; charset=utf-8'); } } if (!empty($sMod)) { // For module only! $this->_pathInitialize(); $sFolder = $this->oUri->fragment(4) && preg_match('#^[\\w]+$#', $this->oUri->fragment(4)) ? PH7_DS . $this->oUri->fragment(4) : ''; if (is_file($sMod . 'assets/ajax/' . $this->oUri->fragment(3) . $sFolder . 'Ajax.php')) { include_once $sMod . 'assets/ajax/' . $this->oUri->fragment(3) . $sFolder . 'Ajax.php'; } else { $this->notFound('Error while loading the library of module ajax<br />File: ' . $sMod . 'assets' . PH7_DS . 'ajax' . PH7_DS . $this->oUri->fragment(3) . $sFolder . 'Ajax.php does not exist', 1); } } else { // For all scripts of the pH7 DatingCms $sFolder = $this->oUri->fragment(3) && preg_match('#^[\\w]+$#', $this->oUri->fragment(3)) ? PH7_DS . $this->oUri->fragment(3) : ''; if (is_file(PH7_PATH_SYS . 'core/assets/ajax/' . $this->oUri->fragment(2) . $sFolder . 'CoreAjax.php')) { include_once PH7_PATH_SYS . 'core/assets/ajax/' . $this->oUri->fragment(2) . $sFolder . 'CoreAjax.php'; } else { $this->notFound('Error while loading the library of ajax<br />File: ' . PH7_PATH_SYS . 'core' . PH7_DS . 'assets' . PH7_DS . 'ajax' . PH7_DS . $this->oUri->fragment(2) . $sFolder . 'CoreAjax.php does not exist', 1); } } }
public function process($sProvider = '') { switch ($sProvider) { case 'paypal': $oPayPal = new PayPal($this->config->values['module.setting']['sandbox.enable']); if ($oPayPal->valid() && $this->httpRequest->postExists('item_number') && $this->httpRequest->postExists('custom')) { if ($this->oUserModel->updateMembership($this->httpRequest->post('item_number'), $this->httpRequest->post('custom', 'int'), $this->httpRequest->post('amount'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->_bStatus = true; // Status is OK // PayPal will call automatically the "notification()" method thanks its IPN feature and "notify_url" form attribute. } } unset($oPayPal); break; case 'stripe': if ($this->httpRequest->postExists('stripeToken')) { Framework\File\Import::lib('Service.Stripe.init'); // Import the Stripe library \Stripe\Stripe::setApiKey($this->config->values['module.setting']['stripe.secret_key']); $oCharge = \Stripe\Charge::create(array('source' => $this->httpRequest->post('stripeToken'), 'email' => $this->httpRequest->post('stripeEmail'))); if ($this->oUserModel->updateMembership($this->httpRequest->post('item_number'), $this->httpRequest->post('member_id', 'int'), $this->httpRequest->post('amount'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->_bStatus = true; // Status is OK $this->notification('Stripe'); // Add info into the log file } } break; case '2co': $o2CO = new TwoCO($this->config->values['module.setting']['sandbox.enable']); $sVendorId = $this->config->values['module.setting']['2co.vendor_id']; $sSecretWord = $this->config->values['module.setting']['2co.secret_word']; if ($o2CO->valid($sVendorId, $sSecretWord) && $this->httpRequest->postExists('sale_id')) { if ($this->oUserModel->updateMembership($this->httpRequest->post('sale_id'), $this->iProfileId, $this->httpRequest->post('price'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->_bStatus = true; // Status is OK $this->notification('TwoCO'); // Add info into the log file } } unset($o2CO); break; case 'ccbill': // In developing... // Contact us at <*****@*****.**> if you want to help us develop the payment system CCBill break; default: $this->displayPageNotFound(t('Provinder Not Found!')); } // Set the page titles $this->sTitle = $this->_bStatus ? t('Thank you!') : t('Error occurred!'); $this->view->page_title = $this->sTitle; $this->view->h2_title = $this->sTitle; if ($this->_bStatus) { $this->updateAffCom(); } // Set the valid page $sPage = $this->_bStatus ? 'success' : 'error'; $this->manualTplInclude($sPage . $this->view->getTplExt()); // Output $this->output(); }
/** * Get the instructions. * * @param string $sInstFile Instruction file. * @return mixed (string or boolean) Returns "false" if the file does not exist or if it fails, otherwise returns the "file contents" */ private function _readInstruction($sInstFile) { $mInstruction = F\Import::file(PH7_PATH_REPOSITORY . static::DIR . PH7_DS . $this->_sUpgradesDirUpgradeFolder . static::INFO_DIR . PH7_DS . $sInstFile); return !$mInstruction ? '<p class="error">' . t('Instruction file not found!') . '</p>' : $mInstruction; }
/** * Get the instructions. * * @param string $sSwitch Module::INSTALL or Module::UNINSTALL constant. * @return mixed (string or boolean) Returns "false" if the file does not exist or if it fails, otherwise returns the "file contents". */ public function readInstruction($sSwitch) { $sValue = $this->_checkParam($sSwitch); $sDir = $this->_sModsDirModFolder . static::INSTALL_DIR . PH7_DS . static::INFO_DIR . PH7_DS; $sPath = $sValue == static::INSTALL ? PH7_PATH_MOD . $sDir . static::INSTALL_INST_CONCL_FILE : PH7_PATH_REPOSITORY . static::DIR . PH7_DS . $sDir . static::UNINSTALL_INST_CONCL_FILE; $mInstruction = F\Import::file($sPath); return !$mInstruction ? '<p class="error">' . t('Instruction file not found!') . '</p>' : $mInstruction; }
/** * @access private * @return void */ private function ajaxRouter($sMod = null) { \PH7\Framework\File\Import::pH7FwkClass('Ajax.Ajax'); // Option for Content Type if ($this->oHttpRequest->getExists('option')) { if ($this->oHttpRequest->get('option') == 'plain') { header('Content-Type: text/plain; charset=utf-8'); } } if (!empty($sMod)) { // For module only! /***** SHORTCUTS PATH THE MODULE *****/ $this->oRegistry->path_module_controllers = $this->oRegistry->path_module . PH7_CTRL; $this->oRegistry->path_module_models = $this->oRegistry->path_module . PH7_MODELS; $this->oRegistry->path_module_views = $this->oRegistry->path_module . PH7_VIEWS; $this->oRegistry->path_module_forms = $this->oRegistry->path_module . PH7_FORMS; $this->oRegistry->path_module_inc = $this->oRegistry->path_module . PH7_INC; $this->oRegistry->path_module_config = $this->oRegistry->path_module . PH7_CONFIG; $this->oRegistry->path_module_lang = $this->oRegistry->path_module . PH7_LANG; $sFolder = $this->oUri->fragment(4) && preg_match('#^[\\w]+$#', $this->oUri->fragment(4)) ? PH7_DS . $this->oUri->fragment(4) : ''; if (is_file($sMod . 'assets/ajax/' . $this->oUri->fragment(3) . $sFolder . 'Ajax.php')) { include_once $sMod . 'assets/ajax/' . $this->oUri->fragment(3) . $sFolder . 'Ajax.php'; } else { $this->notFound('Error while loading the library of module ajax<br />File: ' . $sMod . 'assets' . PH7_DS . 'ajax' . PH7_DS . $this->oUri->fragment(3) . $sFolder . 'Ajax.php does not exist', 1); } } else { // For all scripts of the pH7 DatingCms $sFolder = $this->oUri->fragment(3) && preg_match('#^[\\w]+$#', $this->oUri->fragment(3)) ? PH7_DS . $this->oUri->fragment(3) : ''; if (is_file(PH7_PATH_SYS . 'core/assets/ajax/' . $this->oUri->fragment(2) . $sFolder . 'CoreAjax.php')) { include_once PH7_PATH_SYS . 'core/assets/ajax/' . $this->oUri->fragment(2) . $sFolder . 'CoreAjax.php'; } else { $this->notFound('Error while loading the library of ajax<br />File: ' . PH7_PATH_SYS . 'core' . PH7_DS . 'assets' . PH7_DS . 'ajax' . PH7_DS . $this->oUri->fragment(2) . $sFolder . 'CoreAjax.php does not exist', 1); } } }
/** * Get the instructions. * * @param string $sSwitch Module::INSTALL or Module::UNINSTALL constant. * @return mixed (string or boolean) Returns "false" if the file does not exist or if it fails, otherwise returns the "file contents". */ public function readInstruction($sSwitch) { $sValue = $this->_checkParam($sSwitch); $sDir = $this->_sModsDirModFolder . static::INSTALL_DIR . PH7_DS . static::INFO_DIR . PH7_DS; $sPath = $sValue == static::INSTALL ? PH7_PATH_MOD . $sDir . static::INSTALL_INST_CONCL_FILE : PH7_PATH_REPOSITORY . static::DIR . PH7_DS . $sDir . static::UNINSTALL_INST_CONCL_FILE; try { return F\Import::file($sPath); } catch (Framework\File\Exception $e) { return '<p class="error">' . t('Instruction file not found!') . '</p>'; } }