Exemplo n.º 1
0
 private function writeBearerConfig($username, $password, $authBearer = null)
 {
     if (!$this->loadConfig()) {
         return false;
     }
     if (!$authBearer) {
         $authBearer = $this->guid();
     }
     $output = "<?php";
     $output .= "\n\$GLOBALS[\"LCMS\"][\"administrator\"][\"username\"]   = \"" . $username . "\";";
     $output .= "\n\$GLOBALS[\"LCMS\"][\"administrator\"][\"password\"]   = \"" . $password . "\";";
     $output .= "\n\$GLOBALS[\"LCMS\"][\"administrator\"][\"lastlogin\"]  = \"" . time() . "\";";
     $output .= "\n\$GLOBALS[\"LCMS\"][\"administrator\"][\"bearer\"]     = \"" . $authBearer . "\";";
     $output .= "\n\$GLOBALS[\"LCMS\"][\"administrator\"][\"bearer_exp\"] = \"" . (time() + 300) . "\";";
     $output .= "\n?>";
     $fileHandler = new LCMS_FileHandler();
     $fileHandler->save($GLOBALS["LCMS"]["authfile"], $output);
     return $authBearer;
 }
Exemplo n.º 2
0
 /**
  * Function will save a JSON stream
  * to a JSON file given in the local config.
  * @return: JSON || error 404
  */
 private function writeFEContent($incomingData)
 {
     if (isset($GLOBALS["LCMS"]["feContent"]) && is_file($GLOBALS["LCMS"]["feContent"])) {
         $arrJSON = json_decode($incomingData["content"]);
         // Load Image Engine
         $imageHandler = new LCMS_ImageHandler();
         // Iterate over sections
         for ($i = 0; $i < count($arrJSON->content[1]->content); $i++) {
             // Iterate over elements
             for ($j = 0; $j < count($arrJSON->content[1]->content[$i]); $j++) {
                 if ($arrJSON->content[1]->content[$i]->content[$j]->meta->type == "image" && $arrJSON->content[1]->content[$i]->content[$j]->file) {
                     $response = '';
                     if (isset($arrJSON->content[1]->content[$i]->content[$j]->meta->cropalgo) && $arrJSON->content[1]->content[$i]->content[$j]->meta->cropalgo && isset($arrJSON->content[1]->content[$i]->content[$j]->meta->width) && $arrJSON->content[1]->content[$i]->content[$j]->meta->width && isset($arrJSON->content[1]->content[$i]->content[$j]->meta->height) && $arrJSON->content[1]->content[$i]->content[$j]->meta->height) {
                         // Crop Image and save to stream
                         $response = $imageHandler->cropImage($arrJSON->content[1]->content[$i]->content[$j]->file, $arrJSON->content[1]->content[$i]->content[$j]->meta->width, $arrJSON->content[1]->content[$i]->content[$j]->meta->height, $arrJSON->content[1]->content[$i]->content[$j]->meta->cropalgo);
                     }
                     // Add folder
                     if ($response) {
                         $response = $this->getFrontendUrl($GLOBALS["LCMS"]["cachePath"] . "/" . $response);
                     }
                     $arrJSON->content[1]->content[$i]->content[$j]->croppedImage = $response;
                 }
             }
         }
         $fileSystem = new LCMS_FileHandler();
         $fileSystem->save($GLOBALS["LCMS"]["feContent"], json_encode($arrJSON));
     } else {
         return "ERROR404";
     }
 }