Пример #1
0
 /**
  * @method GET
  */
 function get()
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         Publish::PublishSite($authUser->SiteUniqId);
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Пример #2
0
 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         $site = Site::GetBySiteId($token->SiteId);
         parse_str($this->request->data, $request);
         // parse request
         $theme = $request['theme'];
         // publishes a theme for a site
         Publish::PublishTheme($site, $theme);
         // republish site with the new theme
         Publish::PublishSite($site['SiteId']);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Пример #3
0
 /**
  * @method GET
  */
 function get()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         Publish::PublishSite($token->SiteId);
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Пример #4
0
 /**
  * @method POST
  */
 function post($theme)
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         $site = Site::GetBySiteUniqId($authUser->SiteUniqId);
         // publishes a theme for a site
         Publish::PublishTheme($site, $theme);
         // republish site with the new theme
         Publish::PublishSite($site['SiteUniqId']);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         return $response;
     } else {
         // return an unauthorized exception (401)
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Пример #5
0
 /**
  * @method POST
  */
 function post()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         parse_str($this->request->data, $request);
         // parse request
         $name = $request['name'];
         $domain = $request['domain'];
         $primaryEmail = $request['primaryEmail'];
         $timeZone = $request['timeZone'];
         $language = $request['language'];
         $direction = $request['direction'];
         $currency = $request['currency'];
         $showCart = $request['showCart'];
         $showSettings = $request['showSettings'];
         $showLanguages = $request['showLanguages'];
         $showLogin = $request['showLogin'];
         $urlMode = $request['urlMode'];
         $weightUnit = $request['weightUnit'];
         $shippingCalculation = $request['shippingCalculation'];
         $shippingRate = $request['shippingRate'];
         $shippingTiers = $request['shippingTiers'];
         $taxRate = $request['taxRate'];
         $payPalId = $request['payPalId'];
         $payPalUseSandbox = $request['payPalUseSandbox'];
         $welcomeEmail = $request['welcomeEmail'];
         $receiptEmail = $request['receiptEmail'];
         $isSMTP = $request['isSMTP'];
         $SMTPHost = $request['SMTPHost'];
         $SMTPAuth = $request['SMTPAuth'];
         $SMTPUsername = $request['SMTPUsername'];
         $SMTPPassword = $request['SMTPPassword'];
         $SMTPSecure = $request['SMTPSecure'];
         $formPublicId = $request['formPublicId'];
         $formPrivateId = $request['formPrivateId'];
         $SMTPPasswordIV = '';
         // encyrpt password, #ref: http://stackoverflow.com/questions/10916284/how-to-encrypt-decrypt-data-in-php
         if ($SMTPPassword != '' && $SMTPPassword != 'temppassword') {
             // encrypt password
             $key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CFB);
             $encryption_key = SMTPENC_KEY;
             // create iv
             $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CFB);
             $iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_URANDOM);
             // 16 bytes output
             // encrypt password
             $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $encryption_key, $SMTPPassword, MCRYPT_MODE_CFB, $iv);
             // set password to encrypted password
             $SMTPPasswordIV = base64_encode($iv);
             $SMTPPassword = base64_encode($encrypted);
             // edit SMTP password
             Site::EditSMTPPassword($token->SiteId, $SMTPPassword, $SMTPPasswordIV);
         }
         // edit site
         Site::Edit($token->SiteId, $name, $domain, $primaryEmail, $timeZone, $language, $direction, $showCart, $showSettings, $showLanguages, $showLogin, $urlMode, $currency, $weightUnit, $shippingCalculation, $shippingRate, $shippingTiers, $taxRate, $payPalId, $payPalUseSandbox, $welcomeEmail, $receiptEmail, $isSMTP, $SMTPHost, $SMTPAuth, $SMTPUsername, $SMTPSecure, $formPublicId, $formPrivateId);
         // republish site settings
         Publish::PublishSiteJSON($token->SiteId);
         // republish site to push updates to all pages
         if ($urlMode == 'static') {
             Publish::PublishSite($token->SiteId);
         }
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
     return new Tonic\Response(Tonic\Response::NOTIMPLEMENTED);
 }