Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #44 from NeoRazorX/cloudflare
Browse files Browse the repository at this point in the history
Cloudflare
  • Loading branch information
NeoRazorX authored Aug 26, 2017
2 parents eb9de5e + 02ed751 commit d70ffde
Show file tree
Hide file tree
Showing 30 changed files with 1,009 additions and 937 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2017.024
2017.025
8 changes: 3 additions & 5 deletions base/config2.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
define('FS_MYDOCS', '');
}

if (FS_TMP_NAME != '' AND ! file_exists('tmp/' . FS_TMP_NAME)) {
if (!file_exists('tmp')) {
if (mkdir('tmp')) {
file_put_contents('tmp/index.php', "<?php\necho 'No me toques los cojones!!!';");
}
if (FS_TMP_NAME != '' && ! file_exists('tmp/' . FS_TMP_NAME)) {
if (!file_exists('tmp') && mkdir('tmp')) {
file_put_contents('tmp/index.php', "<?php\necho 'ACCESO DENEGADO';");
}

mkdir('tmp/' . FS_TMP_NAME);
Expand Down
7 changes: 6 additions & 1 deletion base/fs_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class fs_cache
{

private static $memcache;

/**
*
* @var php_file_cache
*/
private static $php_file_cache;
private static $connected;
private static $error;
Expand Down Expand Up @@ -71,7 +76,7 @@ public function error_msg()

public function close()
{
if (isset(self::$memcache) AND self::$connected) {
if (isset(self::$memcache) && self::$connected) {
self::$memcache->close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion base/fs_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function check_fs_page($name, $title, $folder, $shmenu, $important)
);

/// ahora debemos comprobar si guardar o no
if ($name) {
if ($name !== 'fs_controller') {
$page = $this->page->get($name);
if ($page) {
/// la página ya existe ¿Actualizamos?
Expand Down
23 changes: 19 additions & 4 deletions base/fs_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
function fatal_handler()
{
$error = error_get_last();
if ($error !== NULL && substr($error["message"], 0, 19) != 'Memcache::connect()' && strpos($error["file"], '/tcpdf/') === FALSE) {
if ($error !== NULL && $error["type"] == 1) {
echo "<h1>Error fatal</h1>"
. "<ul>"
. "<li><b>Tipo:</b> " . $error["type"] . "</li>"
Expand Down Expand Up @@ -171,13 +171,28 @@ function fs_file_get_contents($url, $timeout = 10)
$data = curl_exec($ch);
$info = curl_getinfo($ch);

if ($info['http_code'] == 301 OR $info['http_code'] == 302) {
if ($info['http_code'] == 200) {
curl_close($ch);
return $data;
} else if ($info['http_code'] == 301 || $info['http_code'] == 302) {
$redirs = 0;
return fs_curl_redirect_exec($ch, $redirs);
}

/// guardamos en el log
if (class_exists('fs_core_log')) {
$error = curl_error($ch);
if($error == '') {
$error = 'ERROR '.$info['http_code'];
}

$core_log = new fs_core_log();
$core_log->new_error($error);
$core_log->save($error);
}

curl_close($ch);
return $data;
return 'ERROR';
}

return file_get_contents($url);
Expand Down Expand Up @@ -233,7 +248,7 @@ function fs_file_download($url, $filename, $timeout = 30)

try {
$data = fs_file_get_contents($url, $timeout);
if ($data && file_put_contents($filename, $data) !== FALSE) {
if ($data && $data != 'ERROR' && file_put_contents($filename, $data) !== FALSE) {
$ok = TRUE;
}
} catch (Exception $e) {
Expand Down
4 changes: 2 additions & 2 deletions base/fs_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ protected function str2bin($val)
*/
public function str2bool($val)
{
return ($val == 't' OR $val == '1');
return ($val == 't' || $val == '1');
}

/**
Expand Down Expand Up @@ -319,7 +319,7 @@ public function intval($str)
*/
public function floatcmp($f1, $f2, $precision = 10, $round = FALSE)
{
if ($round OR ! function_exists('bccomp')) {
if ($round || ! function_exists('bccomp')) {
return( abs($f1 - $f2) < 6 / pow(10, $precision + 1) );
}

Expand Down
26 changes: 13 additions & 13 deletions base/fs_mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function exec($sql, $transaction = TRUE)
if (self::$link->multi_query($sql)) {
do {
$i++;
} while (self::$link->more_results() AND self::$link->next_result());
} while (self::$link->more_results() && self::$link->next_result());
}

if (self::$link->errno) {
Expand Down Expand Up @@ -541,18 +541,18 @@ private function compare_data_types($db_type, $xml_type)
return TRUE;
} else if (strtolower($xml_type) == 'serial') {
return TRUE;
} else if ($db_type == 'tinyint(1)' AND $xml_type == 'boolean') {
} else if ($db_type == 'tinyint(1)' && $xml_type == 'boolean') {
return TRUE;
} else if (substr($db_type, 0, 4) == 'int(' AND $xml_type == 'INTEGER') {
} else if (substr($db_type, 0, 4) == 'int(' && $xml_type == 'INTEGER') {
return TRUE;
} else if (substr($db_type, 0, 6) == 'double' AND $xml_type == 'double precision') {
} else if (substr($db_type, 0, 6) == 'double' && $xml_type == 'double precision') {
return TRUE;
} else if (substr($db_type, 0, 4) == 'time' AND substr($xml_type, 0, 4) == 'time') {
} else if (substr($db_type, 0, 4) == 'time' && substr($xml_type, 0, 4) == 'time') {
return TRUE;
} else if (substr($db_type, 0, 8) == 'varchar(' AND substr($xml_type, 0, 18) == 'character varying(') {
} else if (substr($db_type, 0, 8) == 'varchar(' && substr($xml_type, 0, 18) == 'character varying(') {
/// comprobamos las longitudes
return (substr($db_type, 8, -1) == substr($xml_type, 18, -1));
} else if (substr($db_type, 0, 5) == 'char(' AND substr($xml_type, 0, 18) == 'character varying(') {
} else if (substr($db_type, 0, 5) == 'char(' && substr($xml_type, 0, 18) == 'character varying(') {
/// comprobamos las longitudes
return (substr($db_type, 5, -1) == substr($xml_type, 18, -1));
} else {
Expand All @@ -574,11 +574,11 @@ private function compare_defaults($db_default, $xml_default)
return in_array($xml_default, array('0', 'false', 'FALSE'));
} else if (in_array($db_default, array('1', 'true', 'TRUE'))) {
return in_array($xml_default, array('1', 'true', 'TRUE'));
} else if ($db_default == '00:00:00' AND $xml_default == 'now()') {
} else if ($db_default == '00:00:00' && $xml_default == 'now()') {
return TRUE;
} else if ($db_default == date('Y-m-d') . ' 00:00:00' AND $xml_default == 'CURRENT_TIMESTAMP') {
} else if ($db_default == date('Y-m-d') . ' 00:00:00' && $xml_default == 'CURRENT_TIMESTAMP') {
return TRUE;
} else if ($db_default == 'CURRENT_DATE' AND $xml_default == date("'Y-m-d'")) {
} else if ($db_default == 'CURRENT_DATE' && $xml_default == date("'Y-m-d'")) {
return TRUE;
} else if (substr($xml_default, 0, 8) == 'nextval(') {
return TRUE;
Expand Down Expand Up @@ -611,7 +611,7 @@ public function compare_constraints($table_name, $xml_cons, $db_cons, $delete_on
$found = FALSE;
if (!empty($xml_cons)) {
foreach ($xml_cons as $xml_con) {
if ($db_con['name'] == 'PRIMARY' OR $db_con['name'] == $xml_con['nombre']) {
if ($db_con['name'] == 'PRIMARY' || $db_con['name'] == $xml_con['nombre']) {
$found = TRUE;
break;
}
Expand Down Expand Up @@ -643,7 +643,7 @@ public function compare_constraints($table_name, $xml_cons, $db_cons, $delete_on
}
}

if (!empty($xml_cons) AND ! $delete_only AND FS_FOREIGN_KEYS) {
if (!empty($xml_cons) && ! $delete_only && FS_FOREIGN_KEYS) {
/// comprobamos una a una las nuevas
foreach ($xml_cons as $xml_con) {
$found = FALSE;
Expand Down Expand Up @@ -733,7 +733,7 @@ private function generate_table_constraints($xml_cons)
foreach ($xml_cons as $res) {
if (strstr(strtolower($res['consulta']), 'primary key')) {
$sql .= ', ' . $res['consulta'];
} else if (FS_FOREIGN_KEYS OR substr($res['consulta'], 0, 11) != 'FOREIGN KEY') {
} else if (FS_FOREIGN_KEYS || substr($res['consulta'], 0, 11) != 'FOREIGN KEY') {
$sql .= ', CONSTRAINT ' . $res['nombre'] . ' ' . $res['consulta'];
}
}
Expand Down
6 changes: 3 additions & 3 deletions base/fs_postgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private function compare_data_types($db_type, $xml_type)
return TRUE;
} else if (strtolower($xml_type) == 'serial') {
return TRUE;
} else if (substr($db_type, 0, 4) == 'time' AND substr($xml_type, 0, 4) == 'time') {
} else if (substr($db_type, 0, 4) == 'time' && substr($xml_type, 0, 4) == 'time') {
return TRUE;
}

Expand Down Expand Up @@ -589,7 +589,7 @@ public function compare_constraints($table_name, $xml_cons, $db_cons, $delete_on
}
}

if (!empty($xml_cons) AND ! $delete_only) {
if (!empty($xml_cons) && ! $delete_only) {
/// comprobamos una a una las nuevas
foreach ($xml_cons as $xml_con) {
$found = FALSE;
Expand Down Expand Up @@ -638,7 +638,7 @@ public function generate_table($table_name, $xml_cols, $xml_cons)
$sql .= ' NOT NULL';
}

if ($col['defecto'] !== NULL AND ! in_array($col['tipo'], array('serial', 'bigserial'))) {
if ($col['defecto'] !== NULL && ! in_array($col['tipo'], array('serial', 'bigserial'))) {
$sql .= ' DEFAULT ' . $col['defecto'];
}
}
Expand Down
Loading

0 comments on commit d70ffde

Please sign in to comment.