コード例 #1
0
        /**
     * @param PCRequest $request
     */
    public function profileAction($request) {

        $auth = $request->getAuthHandler();
        $auth->authorize();
         $params = $request->getParams();
        
       

        if (isset($params['id']) && $auth->isAuthorized() && (strcmp($params['id'], $auth->getUserIdentifier()) == 0)) {

            $result = array();
            $user = PCModelUser::getCurrentUser();

            $result['username'] = $user->getUsername();
            $result['name'] = $user->getName();
            $result['surname'] = $user->getSurname();
            $result['member_since'] = $user->getCreation_date()->format("Y-m-d");
            $result['user_id'] = $user->getIdentifier();
            $result['email'] = $user->getEmail();
            $result['title'] = "WebSherpa - " . $user->getUsername();
            return PCRendererHTML::rendererForView('user', $result);
        }


        return null;
    }
コード例 #2
0
 public function contactAction($request)
 {
     $attributes = $request->getParams();
     $name = $attributes['name'];
     $email = $attributes['email'];
     $object = $attributes['object'];
     $text = $attributes['text'];
     $challenge = $attributes['recaptcha_challenge_field'];
     $response = $attributes['recaptcha_response_field'];
     if (!isset($name) || !isset($email) || !isset($object) || !isset($text)) {
         return new PCRendererJSON(array("error" => "Please check fields!!!"), 200);
     }
     require_once __EXTERNAL_LIBRARIES__ . '/recaptcha/recaptchalib.php';
     $privatekey = "6Lfm39cSAAAAAFpyN0tQr4TYNt1zqiaHn9E22lYb";
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $challenge, $response);
     if (!$resp->is_valid) {
         // What happens when the CAPTCHA was entered incorrectly
         error_log($resp->error);
         return new PCRendererJSON(array("error" => "Incorrect Captcha"));
     }
     $user = PCModelUser::getCurrentUser();
     $attributes['user'] = $user;
     $mail = PCEmailBuilder::buildContactUsEmail($attributes);
     PCEmailSender::sendMail($mail);
     return new PCRendererJSON(array("result" => "Ok"));
 }
コード例 #3
0
ファイル: PCRendererHTML.php プロジェクト: Natio/WebSherpa
 function __construct($result, $templateName, $pages, $scripts = NULL, $styleSheets = NULL)
 {
     parent::__construct($result);
     $user = PCModelUser::getCurrentUser();
     if (isset($user)) {
         $this->result['user'] = $user;
     }
     $this->scripts = $scripts == NULL ? array() : $scripts;
     $this->styleSheets = $styleSheets == NULL ? array() : $styleSheets;
     $this->templateName = $templateName;
     $this->pages = $pages;
 }
コード例 #4
0
 /**
  * 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);
     
 }