Beispiel #1
0
 public static function parse($xmlpath)
 {
     libxml_use_internal_errors(true);
     $xml = simplexml_load_file($xmlpath, 'SimpleXMLElement', LIBXML_NOCDATA);
     foreach (libxml_get_errors() as $error) {
         ErrorHelper::logError('XML Error on line ' . $error->line . ' column ' . $error->column . ': ' . $error->message);
     }
     if (!$xml) {
         return null;
     }
     $data = XMLHelper::xml2array($xml);
     XMLHelper::collapse($data, 'socials', 'social');
     XMLHelper::collapse($data, 'histories', 'history');
     XMLHelper::collapse($data, 'trailers', 'trailer');
     XMLHelper::collapse($data, 'awards', 'award');
     XMLHelper::collapse($data, 'quotes', 'quote');
     XMLHelper::collapse($data, 'additionals', 'additional');
     XMLHelper::collapse($data, 'credits', 'credit');
     XMLHelper::collapse($data, 'contacts', 'contact');
     XMLHelper::collapse($data, 'platforms', 'platform');
     XMLHelper::collapse($data, 'features', 'feature');
     XMLHelper::collapse($data, 'prices', 'price');
     // transforms the pricing data to be indexed by the optional platform-tag
     if (isset($data['prices'])) {
         $priceByPlatform = array();
         foreach ($data['prices'] as $price) {
             if (!isset($price['platform'])) {
                 $price['platform'] = '';
             }
             $priceByPlatform[$price['platform']][] = $price;
         }
         $data['prices'] = $priceByPlatform;
     }
     return $data;
 }
Beispiel #2
0
 public function __construct($directory)
 {
     parent::__construct($directory, XMLHelper::parse('data/' . $directory . '/data.xml'));
     if ($this->data == null) {
         ErrorHelper::logError('Failed to load game data in ' . $directory);
     }
     $this->directory = $directory;
 }
Beispiel #3
0
 public static function loadCached($url, $expires, $debug = false)
 {
     if (!function_exists('curl_version')) {
         ErrorHelper::logWarning('Could not fetch data, cURL unavailable');
         return null;
     }
     if ($debug) {
         ErrorHelper::logDebug('cURL for: ' . $url);
     }
     $filename = LoadHelper::getFilename($url);
     if (!LoadHelper::hasCache($url, $expires)) {
         if ($debug) {
             ErrorHelper::logDebug('No cache or expired, making new request');
         }
         $rawData = LoadHelper::load($url);
         if (!$rawData) {
             if ($debug) {
                 ErrorHelper::logDebug('cURL request failed: ' . LoadHelper::$error);
             }
             if (LoadHelper::hasCache($url, -1)) {
                 if ($debug) {
                     ErrorHelper::logDebug('Using expired cache');
                 }
                 $cache = file_get_contents($filename);
                 return $cache;
             } else {
                 if ($debug) {
                     ErrorHelper::logDebug('Request failed, no cache');
                 }
                 return false;
             }
         }
         if ($debug) {
             ErrorHelper::logDebug('Data returned, saving it to cache');
         }
         $folder = LoadHelper::getCacheDir();
         if (!file_exists($folder)) {
             mkdir($folder);
         }
         $cache = @fopen($filename, 'wb');
         $write = $cache ? fwrite($cache, $rawData) : null;
         if (!$write) {
             ErrorHelper::logWarning('Writing to cache failed. Make sure the folder ' . $folder . ' exists and is writeable (chmod 777)');
         }
         if ($cache) {
             fclose($cache);
         }
         return $rawData;
     }
     if ($debug) {
         ErrorHelper::logDebug('Cache hit, using that');
     }
     return file_get_contents($filename);
 }
Beispiel #4
0
 public function __construct()
 {
     parent::__construct('', XMLHelper::parse('data/data.xml'));
     $this->isDeveloper = true;
     if ($this->data == null) {
         ErrorHelper::logError('Failed to load developer data');
         return;
     }
     $gamedirs = FileHelper::getGames('data');
     foreach ($gamedirs as $gamedir) {
         $this->games[$gamedir] = new Game($gamedir);
     }
     // sorts the games according to the sort_order property
     // if no value is set, zero is assumed
     uasort($this->games, 'Developer::_sort');
 }
Beispiel #5
0
 public static function getMessageError($message)
 {
     self::$html = '';
     self::$html .= '<div id="parentPopup">';
     //родительский затемняющий экран
     self::$html .= '<div class="popup">';
     //основной div
     self::$html .= '<span class="popupButtonExit" style="cursor: pointer;" onclick="document.getElementById(\'parentPopup\').style.display=\'none\';">';
     self::$html .= '<b><p>X</p></b>';
     self::$html .= '</span>';
     self::$html .= '<div >';
     self::$html .= '<p>' . $message . '</p>';
     self::$html .= '</div>';
     self::$html .= '</div>';
     //основной div
     self::$html .= '</div>';
     //родительский затемняющий экран
     echo self::$html;
 }
Beispiel #6
0
 public function game($directory)
 {
     if (!isset($this->developer->games[$directory])) {
         ErrorHelper::logError('Could not find game data in directory or incorrect BASE_PATH set in config.php');
     }
     $game = $this->developer->games[$directory];
     if (isset($game->promoter['product'])) {
         PromoterHelper::getData($game);
     }
     ViewHelper::$title = 'presskit for ' . $game->title . ' by ' . $this->developer->title;
     ViewHelper::$header = $game->title;
     ViewHelper::render('gamefacts', array('data' => $game, 'developer' => $this->developer));
     ViewHelper::render('historydescription', array('data' => $game));
     ViewHelper::render('images', array('data' => $game));
     ViewHelper::render('trailers', array('trailers' => $game->trailers, 'directory' => $directory));
     ViewHelper::render('awardspress', array('data' => $game));
     ViewHelper::render('presscopy', array('data' => $game));
     ViewHelper::render('about', array('data' => $this->developer));
     ViewHelper::render('teamcontact', array('data' => $game, 'developer' => $this->developer));
 }
 private function generationButtonAdd()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $status = $this->getDataIPStatus($ip);
     if ($status['status'] == 'blocked') {
         $this->html .= '<div id="errorCommentBlocked" style="display: none;">';
         $this->html .= ErrorHelper::getMessageErrorFeedbackNoComments("Этот IP заблокирован. Вы не можете оставлять отзывы и комментарии ", 'errorCommentBlocked');
         $this->html .= '</div>';
         $this->html .= '<input type="button" value="Оставить отзыв" onclick="errorComments(\'errorCommentBlocked\');">';
     } else {
         if ($status['timeLimit'] != 1) {
             $this->html .= '<center><a id="formFeedbackFancybox" class="fancybox-doc" href="#formFeedback">';
             $this->html .= '<input type="button" value="Оставить отзыв">';
             $this->html .= '</center></a>';
         } else {
             if (floor($this->checkDifferenceBetweenVisits($ip)) < $this->timeValide) {
                 $this->html .= '<div id="errorCommentTimeLimit" style="display: none;">';
                 $this->html .= ErrorHelper::getMessageErrorFeedbackNoComments("Вы можете добавить отзыв только один раз в " . $this->timeValide . " дней", 'errorCommentTimeLimit');
                 $this->html .= '</div>';
             }
             $this->html .= '<center><input type="button" value="Оставить отзыв" onclick="errorComments(\'errorCommentTimeLimit\');"></center>';
         }
     }
 }
 private function generationButtonAddComments($id)
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $status = $this->getDataIPStatus($ip);
     if ($status['status'] == 'blocked') {
         $this->html .= '<div id="errorCommentBlocked" style="display: none;">';
         $this->html .= ErrorHelper::getMessageErrorFeedbackNoComments("Этот IP заблокирован. Вы не можете оставлять отзывы и комментарии ", 'errorCommentBlocked');
         $this->html .= '</div>';
         $this->html .= '<a><div class="feedbackCommentButton" onclick="errorComments(\'errorCommentBlocked\');">';
         //                $this->html .= 'Комментировать';
         $this->html .= '</div></a>';
     } else {
         if ($status['commentYourself'] == 0 && $this->getDataIP($id) == $ip) {
             $this->html .= '<div id="errorCommentYourself" style="display: none;">';
             $this->html .= ErrorHelper::getMessageErrorFeedbackNoComments("Вы не можете комментировать свои отзывы", 'errorCommentYourself');
             $this->html .= '</div>';
             $this->html .= '<a><div class="feedbackCommentButton" onclick="errorComments(\'errorCommentYourself\');">';
             //                    $this->html .= 'Комментировать';
             $this->html .= '</div></a>';
         } else {
             $this->html .= '<a id="formFeedbackFancybox" class="fancybox-doc" href="#formFeedbackComment' . $id . '">';
             $this->html .= '<div class="feedbackCommentButton">';
             //                        $this->html .= 'Комментировать';
             $this->html .= '</div>';
             $this->html .= '</a>';
         }
     }
 }
Beispiel #9
0
 private function checkingModerator()
 {
     if ($this->status['checkingModerator'] == 1) {
         ErrorHelper::getMessageError("Ваш отзыв направлен модератору.");
     }
 }
 private function insertComments()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $this->getDataIPStatus($ip);
     $queryFeedbacks = "INSERT INTO `Feedbacks` SET ";
     $queryFeedbacks .= "`fio` = '" . $this->insertValue['fio'] . "', ";
     $queryFeedbacks .= "`title` = " . InputValueHelper::mayByNull($this->insertValue['title']) . ", ";
     $queryFeedbacks .= "`text` = '" . $this->insertValue['text'] . "', ";
     $queryFeedbacks .= "`email` = " . InputValueHelper::mayByNull($this->insertValue['email']) . ", ";
     $queryFeedbacks .= "`phone` = " . InputValueHelper::mayByNull($this->insertValue['phone']) . ", ";
     $queryFeedbacks .= "`ip` = '" . $ip . "', ";
     $queryFeedbacks .= "`date` = '" . date("Y-m-d h:i:s") . "', ";
     $queryFeedbacks .= "`rating` = 'noRating', ";
     $queryFeedbacks .= "`show` = '1', ";
     $queryFeedbacks .= "`like` = '0', ";
     $queryFeedbacks .= "`dislike` = '0' ; ";
     $queryListIP = "INSERT INTO `FeedbacksListIP` SET ";
     $queryListIP .= "`ip` = '" . $ip . "', ";
     $queryListIP .= "`status` = 'default';";
     // если статус IP 'blocked'
     if ($this->status['status'] == 'blocked') {
         return ErrorHelper::getMessageError("Этот IP заблокирован. Вы не можете оставлять отзывы и комментарии ");
     }
     // проверка существования IP в таблице `FeedbacksListIP`
     if (!isset($this->status['ip'])) {
         $this->SQL_HELPER->insert($queryListIP);
         $this->SQL_HELPER->insert($queryFeedbacks);
         $addCom = $this->SQL_HELPER->lastInsertID();
         $this->SQL_HELPER->insert($this->queryFeedbacksIsComments($addCom));
     } else {
         if ($this->status['commentYourself'] == 0 && $this->getDataIP() == $ip) {
             ErrorHelper::getMessageError("Вы не можете комментировать свои отзывы");
         } else {
             $this->SQL_HELPER->insert($queryFeedbacks);
             $addCom = $this->SQL_HELPER->lastInsertID();
             $this->SQL_HELPER->insert($this->queryFeedbacksIsComments($addCom));
         }
     }
 }
Beispiel #11
0
if (ViewHelper::$mod_rewrite && isset($_GET['p'])) {
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: /' . BASE_PATH . $requestUrl);
    exit;
}
// checks for new updates and installs them if updates are enabled
if (UpdateHelper::check()) {
    // if it did install updates, redirects to this page again to make sure nothing gets broken as files are changed
    header('Location: /' . BASE_PATH . '/' . $requestUrl . '?updated=1');
    exit;
}
ob_start();
if (!ErrorHelper::hasErrors()) {
    $presskit = new PresskitController();
}
if (!ErrorHelper::hasErrors()) {
    if (isset($_POST['email'])) {
        $presskit->email($requestUrl);
    } else {
        if ($requestUrl == '') {
            $presskit->index();
        } else {
            if ($requestUrl == 'credits') {
                $presskit->credits();
            } else {
                $presskit->game($requestUrl);
            }
        }
    }
}
$content = ob_get_contents();
Beispiel #12
0
 private function run()
 {
     $url = "/";
     if (isset($_GET["url"])) {
         $url = "/" . $_GET["url"];
     }
     if (!(substr($url, strlen($url) - 1, 1) == "/")) {
         $url .= "/";
     }
     $hit = false;
     foreach ($this->routes as $route) {
         if (preg_match("/" . $route->regex . "/", $url)) {
             if (is_callable($route->result)) {
                 $hit = true;
                 call_user_func($route->result);
                 break;
             }
             if (is_object($route->result)) {
                 if (isset($route->result->filter)) {
                     $filters = StringHelper::explode($route->result->filter, "|");
                     $break = false;
                     foreach ($filters as $filter) {
                         $name = $filter;
                         $params = array();
                         if (strpos($filter, ":")) {
                             $name = substr($filter, 0, strpos($filter, ":", 1));
                             $params = StringHelper::between($filter, "(", ")");
                             $params = explode(",", $params);
                             foreach ($params as $i => $param) {
                                 $params[$i] = StringHelper::between($param, "'", "'");
                             }
                         }
                         if (isset($this->filters[$name])) {
                             if (!call_user_func_array($this->filters[$name], $params)) {
                                 $hit = true;
                                 ErrorHelper::notFound("Filter error (" . $name . ")");
                                 $break = true;
                                 break;
                             }
                         } else {
                             $hit = true;
                             ErrorHelper::notFound("Filter not found");
                             $break = true;
                             break;
                         }
                     }
                     if ($break) {
                         break;
                     }
                 }
                 if (isset($route->result->view)) {
                     if (is_string($route->result->view)) {
                         $parts = explode("::", $route->result->view);
                         if (count($parts) == 2) {
                             $class = $parts[0];
                             $method = $parts[1];
                             if (file_exists(ROOT . "/game/views/" . strtolower($class) . ".php")) {
                                 require_once ROOT . "/game/views/" . strtolower($class) . ".php";
                                 $class .= "View";
                                 $view = new $class();
                                 if (method_exists($view, $method)) {
                                     $hit = true;
                                     $view->{$method}();
                                     break;
                                 }
                             }
                         }
                     }
                     if (is_callable($route->result->view)) {
                         $hit = true;
                         call_user_func($route->result->view);
                         break;
                     }
                 }
                 ErrorHelper::notFound("Page not found.");
             }
         }
     }
     if (!$hit) {
         ErrorHelper::notFound("Page not found.");
     }
 }
Beispiel #13
0
 private static function install($debug = false)
 {
     if (!extension_loaded('zip')) {
         ErrorHelper::logWarning('zip extensions unavailable on server, can\'t extract updates without it');
         return;
     }
     LoadHelper::loadCached(UpdateHelper::$new->zipball_url, 1000, $debug);
     $zip = new ZipArchive();
     if ($zip->open(LoadHelper::getFilename(UpdateHelper::$new->zipball_url)) === TRUE) {
         // make sure temp directory is empty
         UpdateHelper::removeTemp();
         $success = $zip->extractTo(LoadHelper::getCacheDir() . UpdateHelper::tmp_path);
         $zip->close();
         if ($debug) {
             ErrorHelper::logDebug('Update archive ' . ($success ? 'extracted successfully' : 'failed to extract'));
         }
     } else {
         if ($debug) {
             ErrorHelper::logWarning('Failed extracting update archive');
         }
         return;
     }
     // updates from github are packed in a folder within the zip, we need the name of this folder
     $rootFolder = '';
     $iterator = UpdateHelper::getUpdateIterator(false);
     foreach ($iterator as $item) {
         // the first folder we hit when iterating will be the root folder, save that
         if ($item->isDir() && $rootFolder == '') {
             $rootFolder = $iterator->getSubPathName();
             if ($debug) {
                 ErrorHelper::logDebug('Update root folder is ' . $rootFolder);
             }
             // we won't ever need to create the root folder, so we skip to the next item
             continue;
         }
         // figure out destination path
         $destination = realpath(UpdateHelper::destination . UpdateHelper::removePrefix($iterator->getSubPathName(), $rootFolder));
         if ($item->isDir()) {
             if (file_exists($destination)) {
                 continue;
             }
             if ($debug) {
                 ErrorHelper::logDebug('Create directory ' . $destination);
             }
             mkdir($destination);
         } else {
             $success = copy($item, $destination);
             if ($debug) {
                 ErrorHelper::logDebug('Copy file from ' . $item . ' to ' . $destination . ($success ? ' OK' : ' Failed'));
             }
         }
     }
     // remove any temporary files extracted in the process
     UpdateHelper::removeTemp();
     // remove the update zip file, we won't need it anymore
     unlink(LoadHelper::getFilename(UpdateHelper::$new->zipball_url));
     return true;
 }