public function ajax_updatenext()
 {
     $time_start = microtime(true);
     $response["error"] = "none";
     $response["file"] = "none";
     $response["nextId"] = null;
     if (!empty($_POST["id"])) {
         $id = intval($_POST["id"]);
         if ($id < 1) {
             $i = 1;
         }
         $history = new History();
         $themeInfo = $history->getFewInfo($id);
         if (!empty($themeInfo)) {
             $unzippath = TC_VAULTDIR . '/unzip/' . $themeInfo["hash"] . "/";
             if (file_exists($unzippath)) {
                 $nextId = $history->getNextId($themeInfo["id"]);
                 $response["nextId"] = $nextId;
                 $themeInfo = $history->loadThemeFromHash($themeInfo["hash"]);
                 // need an objet and not an array
                 $r = $themeInfo->initFromUnzippedArchive($unzippath, $themeInfo->zipfilename, $themeInfo->zipmimetype, $themeInfo->zipfilesize);
                 // merchant...
                 $this->fileValidator = new FileValidator($themeInfo);
                 $this->fileValidator->validate();
                 if (UserMessage::getCount(ERRORLEVEL_FATAL) > 0) {
                     $response["error"] = "fatal error:\n";
                     foreach (UserMessage::getMessages(ERRORLEVEL_FATAL) as $m) {
                         $response["error"] .= "\n" . $m;
                     }
                 } else {
                     if ($this->fileValidator->serialize(true)) {
                         if (UserMessage::getCount(ERRORLEVEL_FATAL) > 0) {
                             // at least one error occured while serializing (no thumbnail...)
                             $response["error"] = "fatal error, could not serialize validation results:\n";
                             foreach (UserMessage::getMessages(ERRORLEVEL_FATAL) as $m) {
                                 $response["error"] .= "\n" . $m;
                             }
                             foreach (UserMessage::getMessages(ERRORLEVEL_CRITICAL) as $m) {
                                 $response["error"] .= "\n" . $m;
                             }
                         } else {
                             $this->validationResults = $this->fileValidator->getValidationResults(I18N::getCurLang());
                             $themeInfo = $this->fileValidator->themeInfo;
                             $response["name"] = $themeInfo->name;
                         }
                     } else {
                         // at least one error occured while serializing (no thumbnail...)
                         if (UserMessage::getCount(ERRORLEVEL_CRITICAL) > 0) {
                             $response["error"] = "could not serialize validation results";
                         }
                         foreach (UserMessage::getMessages(ERRORLEVEL_CRITICAL) as $m) {
                             $response["error"] .= "\n" . $m;
                         }
                     }
                 }
             } else {
                 $response["error"] .= "No zip file " . $unzippath;
             }
         } else {
             if (UserMessage::getCount(ERRORLEVEL_FATAL) > 0) {
                 // at least one error occured while serializing (no thumbnail...)
                 $response["error"] = "could not execute validation:\n";
                 foreach (UserMessage::getMessages(ERRORLEVEL_FATAL) as $m) {
                     $response["error"] .= "\n" . $m;
                 }
                 foreach (UserMessage::getMessages(ERRORLEVEL_CRITICAL) as $m) {
                     $response["error"] .= "\n" . $m;
                 }
             } else {
                 $response["error"] = "could not execute validation (unknown error).";
             }
         }
     }
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     $response["duration"] = $time;
     //ob_clean();
     header('Content-Type: application/json');
     echo json_encode($response);
 }
Beispiel #2
0
 public function assemble($route = array())
 {
     $i18n = I18N::getInstance();
     $lang = "";
     if (isset($route["lang"])) {
         if ($route["lang"] == TC_DEFAULT_LANG) {
             $lang = "";
         } else {
             $lang = $route["lang"];
         }
     }
     $url = "";
     if (!empty($lang)) {
         $url = $lang . '/';
     }
     if (!isset($route["phpfile"])) {
         return "Error : phpfile not defined";
     }
     if ($route["phpfile"] == "home") {
         $url = trim($url, '/ ');
     } else {
         if ($route["phpfile"] == "results") {
             $data = array();
             if (isset($route["hash"])) {
                 $url = trim($url . $i18n->url($route["lang"], 'score'), '/ ');
                 if (!USE_DB) {
                     echo 'error in route. cannot assemble route without DB';
                     die;
                 }
                 $history = new History();
                 $themeInfo = $history->loadThemeFromHash($route["hash"]);
                 if (empty($themeInfo)) {
                     return null;
                 }
                 $data["name"] = $themeInfo->namesanitized;
                 if ($themeInfo->themetype == TT_WORDPRESS) {
                     $data["themetype"] = 'wordpress_theme';
                 }
                 if ($themeInfo->themetype == TT_JOOMLA) {
                     $data["themetype"] = 'joomla_template';
                 }
                 if ($themeInfo->themetype == TT_WORDPRESS_CHILD) {
                     $data["themetype"] = 'wordpress_theme';
                 }
                 $url .= '/' . trim($i18n->url($route["lang"], $data["themetype"])) . '_' . trim($data["name"]) . '.html';
             } else {
                 if (isset($route["namesanitized"]) && isset($route["themetype"])) {
                     $url = trim($url . $i18n->url($route["lang"], 'score'), '/ ');
                     if ($route["themetype"] == TT_WORDPRESS) {
                         $data["themetype"] = 'wordpress_theme';
                     }
                     if ($route["themetype"] == TT_JOOMLA) {
                         $data["themetype"] = 'joomla_template';
                     }
                     if ($route["themetype"] == TT_WORDPRESS_CHILD) {
                         $data["themetype"] = 'wordpress_theme';
                     }
                     $url .= '/' . trim($i18n->url($route["lang"], $data["themetype"])) . '_' . trim($route["namesanitized"]) . '.html';
                 } else {
                     if (isset($route["ut"])) {
                         $url = trim($url . $i18n->url($route["lang"], 'score'), '/ ') . '?ut=' . urlencode($route["ut"]);
                     } else {
                         $url = trim($url . $i18n->url($route["lang"], 'score'), '/ ');
                     }
                 }
             }
         } else {
             if ($route["phpfile"] == "unittests") {
                 $url = trim($url . $i18n->url($route["lang"], 'unittests'), '/ ');
             } else {
                 if ($route["phpfile"] == "massimport") {
                     $url = "massimport";
                 } else {
                     if ($route["phpfile"] == "contact") {
                         $url = trim($url . $i18n->url($route["lang"], 'contact'), '/ ');
                     } else {
                         if ($route["phpfile"] == "error404.php") {
                             $url = trim($url . $i18n->url($route["lang"], $route["phpfile"]), '/ ');
                         }
                     }
                 }
             }
         }
     }
     return strtolower($url);
 }
Beispiel #3
0
 /** 
  *		Restore check results from a JSON file.
  **/
 public static function unserialize($hash)
 {
     if (!USE_DB) {
         return null;
     }
     $directory = ThemeInfo::getReportDirectory($hash);
     if (!file_exists($directory)) {
         return null;
     }
     $history = new History();
     $themeInfo = $history->loadThemeFromHash($hash);
     if (empty($themeInfo)) {
         return null;
     }
     $fileValidator = new FileValidator($themeInfo);
     global $ExistingLangs;
     foreach ($ExistingLangs as $l) {
         $_validationResults = ValidationResults::unserialize($hash, $l);
         if (empty($_validationResults)) {
             continue;
         }
         $fileValidator->validationResults[$l] = $_validationResults;
     }
     if (!empty($themeInfo->parentId)) {
         $fewInfo = $history->getFewInfo($themeInfo->parentId);
         if (!empty($fewInfo["id"])) {
             $themeInfo->parentNameSanitized = $fewInfo["namesanitized"];
         }
         $themeInfo->parentThemeType = $fewInfo["themetype"];
     }
     if ($themeInfo->isThemeForest) {
         $fileValidator->generateThemeForestReport();
     }
     return $fileValidator;
 }
Beispiel #4
0
include_once 'include/shield.php';
$lang = 'en';
if (isset($_GET['lang']) && in_array(strtolower($_GET['lang']), $ExistingLangs)) {
    $lang = strtolower($_GET['lang']);
}
$size = '80';
if (isset($_GET['size']) && $_GET['size'] == "big") {
    $size = '240';
}
if (isset($_GET['size']) && $_GET['size'] == "small") {
    $size = '40';
}
$hash = $_GET['id'];
if (preg_match("/^[a-zA-Z0-9]{25}\$/", $hash)) {
    $history = new History();
    $themeInfo = $history->loadThemeFromHash($hash);
    if (!empty($themeInfo)) {
        ?>
		<script>
		var loc = window.location.protocol + "//" + window.location.hostname + window.location.pathname + window.location.search;
		ga('send', 'pageview', loc, '<?php 
        if ($themeInfo->themetype == 1) {
            echo '[WP] ';
        }
        if ($themeInfo->themetype == 2) {
            echo '[Joomla] ';
        }
        if ($themeInfo->themetype == 4) {
            echo '[WP child] ';
        }
        echo $themeInfo->namesanitized;