/** * @param PCHelperSocialAdapter $adapter * @return PCModelUserOauth */ public static function createUserForOauthServiceWithAdapter($adapter){ $values = $adapter->getValuesForCreatingUser(); $mapper = PCModelUser::getMapper(); //creo il 'vero' utente nel db if (PCModelManager::insertObject($mapper, $values) == FALSE) return NULL; $instances = PCModelManager::fetchModelObjectInstances($mapper, $values); if(count($instances) == 0) return NULL; $user = $instances[0]; $user_identifier = $user->getIdentifier(); $token = $adapter->getTokenValue(); $secret = $adapter->getSecretValue(); $service_u_id = $adapter->getServiceUserIdentifier(); $service_type = $adapter->getServiceType(); if(PCMapperUserOauth::insertUserOauth($service_type, $service_u_id, $token, $secret, $user_identifier)){ $adapter->addOauthInfoToUser($user); if (PCConfigManager::sharedManager()->getBoolValue('NOTIF_ON_REGISTER')) { $email = $values['email']; $surname = $values['surname']; $name = $values['name']; $username = $values['username']; $serv = $adapter->getServiceName(); PCHelperNotificationSender::sendPushNotificationToAdmin("User Registered", "uname: $username Name: $name Sur: $surname mail: $email service_id: $service_u_id via: $serv"); } return $user; } return NULL; }
<style> body{ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; } p{ font-weight:200; font-size:20px; } </style> </head> <body> <h2>Hi <? echo $this->result['username']?>,</h2> <p>You requested a link to reset your <a href="<? echo 'http://'.PCConfigManager::sharedManager()->getValue('DOMAIN_NAME')?>">WebSherpa</a> password. Please set a new password by following the link below:</p> <p>oYour new password is: <? echo $this->result['pass'];?></p> <p>Please <? if(defined("DEBUG")): ?> <a href="http://localhost:8888">login</a> <? else: ?> <a href="http://websherpa.me">login</a> <? endif;?> and change it now!!</p> </body> </html>
<div class="popupOverlay" id="passwordLostPopup"> <div class="popupBox" style="margin-left:-200px;margin-top:-100px;width:400px;height:200px;"> <a class="closePopup" href="#">close</a> <div class="inputContainer" id="resetPassInputContainer" style="text-align:center; "> <input type="text" name="email" id="lostPasswordMailField" placeholder="You email:" /> <div class="ajaxIndicator"><img src="/public/fresh/img/ajax-loader.gif" height="16" width="16"/></div> <label id="lostPasswordLabel">Insert your email. You will recive a mail with the instruction to reset your password</label> <button type="submit" id="sendLostPasswordButton" class="blueButton">Send</button> </div> </div> </div> <div class="popupOverlay" id="loginPopup"> <? $showSocial = PCConfigManager::sharedManager()->getBoolValue('SOCIAL_LOGIN'); ?> <div class="popupBox" style="margin-left:-200px;margin-top:-100px;width:400px; <?echo $showSocial ? "height:380px;" : "height:250px;";?>"> <a class="closePopup" href="#">close</a><a class="lostPassword" href="#">Password Lost?</a> <? if ($showSocial): ?> <div class="inputContainer socialLoginContainer"> <a href="/social/tw_login"><div class="socialSprite twitterBackground"></div></a> <a href="/social/fb_login"><div class="socialSprite facebookBackground"></div></a> <h3>Or</h3> </div> <? endif; ?> <div class="inputContainer" <? if(!$showSocial) echo 'style="margin-top:40px;"'; ?>> <input type="text" name="username" id="usernameLogin" placeholder="Username..." /> <input name="password" type="password" id="passwordLogin" placeholder="Password" /> <p id="loginErrorLabel" style="display:none;">dfqfqwefqrwfqerferfw erg erg</p> <div class="ajaxIndicator"><img src="/public/fresh/img/ajax-loader.gif" height="16" width="16"/></div>
<? define('__LIBRARY__', __ROOT__ . '/library'); define('__MODEL__',__ROOT__.'/model'); define('__EXTERNAL_LIBRARIES__', __ROOT__ . '/external'); require (__LIBRARY__ . '/autoloader/PCAutoloader.php'); PCCache::setDefaultCacheProvider(PCCache::getTestCacheProvider()); $rootDomain = PCConfigManager::sharedManager()->getValue('DOMAIN_NAME'); ini_set('session.cookie_domain', ".$rootDomain"); $apiSubdomain = "api.".$rootDomain; $ajaxSubdomain = "ajax.".$rootDomain; $router = PCRouter::sharedRouter(); $router->setControllersBaseDirectory(__ROOT__."/controllers"); $router->addSubdomain("/^$apiSubdomain/", PCRequest::TYPE_API); $router->addSubdomain("/^$ajaxSubdomain/", PCRequest::TYPE_AJAX); $router->addSubdomain("/^$rootDomain/", PCRequest::TYPE_WEB); $pages = new PCRouterRoute("/web/PCPageController.php", "page", "PCPageController"); $pages->addSubroute(new PCRouterSubroute("me","meAction")); $pages->setType(PCRequest::TYPE_AJAX); $router->addRoute($pages, PCRequest::TYPE_AJAX);
/** * @param PCRequest $request */ public function facebookLoginAction($request){ PCAutoloader::importLibrary('facebook'); $facebook = new Facebook(array( "appId" => FB_APP_ID, "secret" => FB_APP_SECRET, "cookie" => true )); $redirectURL = "http://".(PCConfigManager::sharedManager()->getValue('DOMAIN_NAME'))."/social/facebookcallback"; $loginUrl = $facebook->getLoginUrl(array( 'scope' => 'email,publish_actions,offline_access,publish_stream', 'redirect_uri' => $redirectURL, )); throw new PCExceptionRedirection($loginUrl); }
/** * * @param string $user * @param int $offset * @return array */ public static function getReviewsWithUserIdentifier($user, $offset){ $offset = (int)$offset; if($offset<0){ return NULL; } $keys = array('user_identifier' => $user); //$elementsToReturn = 10; $elementsToReturn = PCConfigManager::sharedManager()->getIntegerValue('REVIEWS_PER_CALL'); $limit = ($offset*$elementsToReturn)." , ".$elementsToReturn." "; $elements = PCModelManager::fetchModelObjectInstances(PCModelReview::getMapper(), $keys, NULL, FALSE, $limit); return $elements; }
/** * * @return boolean */ public function cacheIsExpired() { if ($this->cached_date == NULL) { return TRUE; } $now = new DateTime('now', new DateTimeZone('UTC')); $diff = $now->getTimestamp() - $this->cached_date->getTimestamp(); if ($diff === NULL) { return TRUE; } //1/2 ora, cioè la durate della cache $chacheTime = PCConfigManager::sharedManager()->getIntegerValue('WEBSITE_CACHE_TIME'); return $diff > $chacheTime; }
/** * * @param PCRequest $request */ public function registerAction($request) { require_once __EXTERNAL_LIBRARIES__ . '/recaptcha/recaptchalib.php'; $auth = $request->getAuthHandler(); if ($auth->isAuthorized()) { return new PCRendererJSON(array("error" => "you can't register a new user while logged"), 400); } $attributes = $request->getParams(); $privatekey = "6Lfm39cSAAAAAFpyN0tQr4TYNt1zqiaHn9E22lYb"; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $attributes["recaptcha_challenge_field"], $attributes["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly error_log($resp->error); return new PCRendererJSON(array("captcha_error" => "Incorrect Captcha")); } if (!isset($attributes['username']) || !isset($attributes['name']) || !isset($attributes['surname']) || !isset($attributes['email']) || !isset($attributes['password'])) { throw new PCExceptionAuth("Missing param", 400); } $inputError = NULL; if (PCHelperValidator::validatePassword($attributes['password'], $inputError) == FALSE) { return new PCRendererJSON(array("error" => $inputError), 400); } if (PCHelperValidator::validateUsername($attributes['username'], $inputError) == FALSE) { return new PCRendererJSON(array("error" => $inputError), 400); } if (PCHelperValidator::validateName($attributes['name'], $inputError) == FALSE) { return new PCRendererJSON(array("error" => $inputError), 400); } if (PCHelperValidator::validateSurname($attributes['surname'], $inputError) == FALSE) { return new PCRendererJSON(array("error" => $inputError), 400); } if (PCHelperValidator::validateEmail($attributes['email'], $inputError) == FALSE) { return new PCRendererJSON(array("error" => $inputError), 400); } $username = $attributes['username']; $name = $attributes['name']; $surname = $attributes['surname']; $email = $attributes['email']; $password = $attributes['password']; $store = array(); $store['username'] = $username; $store['name'] = $name; $store['surname'] = $surname; $store['email'] = $email; $store['password'] = PCAuth::computeHashForString($password); $error = NULL; if (PCMapperUser::createUserWithAttributes($store, $error)) { if (PCConfigManager::sharedManager()->getBoolValue('NOTIF_ON_REGISTER')) { PCHelperNotificationSender::sendPushNotificationToAdmin("User Registered", "uname: {$username} Name: {$name} Sur: {$surname} mail: {$email}"); } return new PCRendererJSON(array("OK" => "User added")); } return new PCRendererJSON(array("error" => $error), 400); }
</div> </div> <div class="reviewTextConteiner"> <p><? echo $review["comment"]; ?></p> </div> <? if ($isSite) : ?> <!-- <div data-revid="<? echo $review['reviewId']; ?>" class="reportSpam">Report as Spam</div>--> <? endif; ?> </div> </article> <? endforeach; ?> </div> <button id="moreReviews" class="orangeButton">More</button> <div class="ajaxIndicator"><img src="/public/fresh/img/ajax-loader.gif" height="16" width="16"/></div> <? if(PCConfigManager::sharedManager()->getBoolValue('SHOW_AD_ON_SITES')): ?> <div class="bannerContainer"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- Banner pagina sito WebSherpa --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-7297125817538961" data-ad-slot="5687707634"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <? endif;?> <div class="popupOverlay" id="segnalazionePopup"> <div class="popupBox" style="margin-left:-200px;margin-top:-100px;width:400px;height:250px;"> <a class="closePopup" href="#">close</a> <textarea id="testoSegnalazione" placeholder="Why this review should be considered spam?" maxlength="200"></textarea>
/** * Aggiunge una recensione * @param PCRequest $request */ public function addReviewAction($request){ $auth = $request->getAuthHandler(); if($auth->isAuthorized() == FALSE){ throw new PCExceptionAuth("Auth Required", 401); } $params = $request->getParams(); $url = PCHelperInputCleaner::cleanInputString($params['siteUrl']); $comment = PCHelperInputCleaner::cleanInputString($params['comment']); $contents = PCHelperInputCleaner::cleanInputString($params['contents']); $reliability = PCHelperInputCleaner::cleanInputString($params['reliability']); $usability = PCHelperInputCleaner::cleanInputString( $params['usability']); $category = PCHelperInputCleaner::cleanInputString($params['category']); $language = PCHelperInputCleaner::cleanInputString($params['language_code']); $siteIdentifier = PCHelperInputCleaner::cleanInputString($params['site_identifier']); if((!empty($url) || !empty($siteIdentifier)) && isset($comment) && isset($contents) && isset($reliability) && isset($usability) && isset($category) && isset($language)){ $error = NULL; $user = PCModelUser::getCurrentUser(); $result = PCMapperWebsite::addSiteWithReview($url, $user, $comment, $usability, $contents, $reliability, $category, $language, $error, $siteIdentifier); if($result){ if(PCConfigManager::sharedManager()->getBoolValue('SOCIAL_POST_ON_REVIEW')){ $userName = $user->getUsername(); PCHelperNotificationSender::sendPushNotificationToAdmin("Aggiunta Recensione", "User: $userName r($reliability) u($usability) c($contents) url: $url"); } return new PCRendererJSON(array("OK"=>"Site Added")); } else{ error_log($error); return new PCRendererJSON(array("error"=>$error),401); } } return new PCRendererJSON("Error adding site", 400); }