From ac13bf95a7d8cb05541a0d52531e02ae775e868c Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Tue, 10 Sep 2024 16:20:14 +0100 Subject: [PATCH] Backporting FOAG changes into Neo devstream --- cms/backups/nothing.txt | 0 cms/core/createsession.php | 2 - cms/core/fileload.php | 167 +++++----- cms/core/save.php | 47 +-- cms/functions/checkbrand.php | 11 - cms/functions/checkpath.php | 66 ---- cms/functions/cleaner.php | 109 ------- cms/functions/createsession.php | 35 --- cms/functions/fileload.php | 181 ----------- cms/functions/folderload.php | 111 ------- cms/functions/forgotpassword.php | 35 --- cms/functions/ftpclear.php | 67 ---- cms/functions/ftpconnect.php | 34 -- cms/functions/ftpcreate.php | 82 ----- cms/functions/ftpstart.php | 10 - cms/functions/ftpvars.php | 8 - cms/functions/getpage.php | 13 - cms/functions/getpath.php | 27 -- cms/functions/getsaveprefs.php | 35 --- cms/functions/getsaveusers.php | 98 ------ cms/functions/geturi.php | 16 - cms/functions/login.php | 49 --- cms/functions/logout.php | 14 - cms/functions/restore.php | 180 ----------- cms/functions/save.php | 525 ------------------------------- cms/functions/upload.php | 120 ------- cms/functions/urldissect.php | 21 -- 27 files changed, 84 insertions(+), 1979 deletions(-) create mode 100644 cms/backups/nothing.txt delete mode 100644 cms/functions/checkbrand.php delete mode 100644 cms/functions/checkpath.php delete mode 100644 cms/functions/cleaner.php delete mode 100644 cms/functions/createsession.php delete mode 100644 cms/functions/fileload.php delete mode 100644 cms/functions/folderload.php delete mode 100644 cms/functions/forgotpassword.php delete mode 100644 cms/functions/ftpclear.php delete mode 100644 cms/functions/ftpconnect.php delete mode 100644 cms/functions/ftpcreate.php delete mode 100644 cms/functions/ftpstart.php delete mode 100644 cms/functions/ftpvars.php delete mode 100644 cms/functions/getpage.php delete mode 100644 cms/functions/getpath.php delete mode 100644 cms/functions/getsaveprefs.php delete mode 100644 cms/functions/getsaveusers.php delete mode 100644 cms/functions/geturi.php delete mode 100644 cms/functions/login.php delete mode 100644 cms/functions/logout.php delete mode 100644 cms/functions/restore.php delete mode 100644 cms/functions/save.php delete mode 100644 cms/functions/upload.php delete mode 100644 cms/functions/urldissect.php diff --git a/cms/backups/nothing.txt b/cms/backups/nothing.txt new file mode 100644 index 0000000..e69de29 diff --git a/cms/core/createsession.php b/cms/core/createsession.php index d6c73cf..5bc9533 100644 --- a/cms/core/createsession.php +++ b/cms/core/createsession.php @@ -26,6 +26,4 @@ if (!isset($_SESSION['neoCMSSess'])) { } else $sessname = $_SESSION['neoCMSSess']; -session_name($sessname); -session_cache_expire(240); // 4 hours @session_start(); \ No newline at end of file diff --git a/cms/core/fileload.php b/cms/core/fileload.php index a750dcd..d2fa83d 100644 --- a/cms/core/fileload.php +++ b/cms/core/fileload.php @@ -12,7 +12,6 @@ if (isset($_SESSION['neoCMSSess']) && strstr($_SESSION['neoCMSSess'], 'neoCMSses $pageurl = $_SERVER['HTTP_REFERER']; //incoming page url if (stristr($pageurl, $_SERVER['HTTP_HOST'])) { - $type = $_GET['type']; if ($type == 'img') $files = 'bmp,gif,jpeg,jpg,png,svg,svgx,webp'; @@ -34,91 +33,10 @@ if (isset($_SESSION['neoCMSSess']) && strstr($_SESSION['neoCMSSess'], 'neoCMSses $pattern = trim($pattern, '|') . ')/i'; - function findfiles($path, $pattern) - { - global $matches, $pathdefault, $type; - $path = rtrim(str_replace("\\", "/", $path), '/') . '/'; - - $entries = array(); - $dir = dir($path); - $neocmspath = "/\/" . $_SESSION['neoCMSPath'] . "\//"; - - while (false !== ($entry = $dir->read())) { - - if (!preg_match($neocmspath, $path)) $entries[] = $entry; - - } - - $dir->close(); - - foreach ($entries as $entry) { - - $fullname = $path . $entry; - $pathname = str_replace('../..', '', $path); - - $exFolders = preg_replace('/,\s*/', '/|', $_SESSION['neoCMSExFolders']); - $exFolders = str_replace('-', '\-', $exFolders); - $exFolders = str_replace('.', '\.', $exFolders); - $exFolders = '/' . str_replace('/', '\/', $exFolders) . '\//'; - - if ($entry != '.' && $entry != '..' && is_dir($fullname) && is_readable($fullname) && (!preg_match($exFolders, $fullname) || $_SESSION['neoCMSExFolders'] == '')) findfiles($fullname, $pattern); - elseif ($entry != '.' && $entry != '..' && is_file($fullname) && preg_match($pattern, $entry)) { - - if (!in_array($pathname, $matches)) { - - if (preg_match('/\.html|\.htm|\.php|\.cfm|\.phtml|\.shtml|\.asp/', $fullname)) { - - $content = file_get_contents($fullname); - - if (checkContent($content)) $matches[] = $fullname; - - } else $matches[] = $fullname; - - } - - } - - } - - } - - function checkContent($content) - { - - global $type; - - if (stristr($content, '[^<]+read())) { + + if (!preg_match($neocmspath, $path)) $entries[] = $entry; + + } + + $dir->close(); + + foreach ($entries as $entry) { + $fullname = $path . $entry; + $pathname = str_replace('../..', '', $path); + + $exFolders = preg_replace('/,\s*/', '/|', $_SESSION['neoCMSExFolders']); + $exFolders = str_replace('-', '\-', $exFolders); + $exFolders = str_replace('.', '\.', $exFolders); + $exFolders = '/' . str_replace('/', '\/', $exFolders) . '\//'; + + if ($entry != '.' && $entry != '..' && is_dir($fullname) && is_readable($fullname) && (!preg_match($exFolders, $fullname) || $_SESSION['neoCMSExFolders'] == '')) findfiles($fullname, $pattern); + elseif ($entry != '.' && $entry != '..' && is_file($fullname) && preg_match($pattern, $entry)) { + + if (!in_array($pathname, $matches)) { + if (preg_match('/\.html|\.htm|\.php|\.cfm|\.phtml|\.shtml|\.asp/', $fullname)) { + + $content = file_get_contents($fullname); + if (checkContent($content)) { + $matches[] = $fullname; + } + + } else $matches[] = $fullname; + } + + } + } +return $matches; +} + +function checkContent($content) +{ + + global $type; + + if (stristr($content, '[^<]+Error: neocms publish this page: ' . $remotefile . ''; - - fclose($doc); - if (isset($docp)) unlink($docp); - - } elseif (is_writable($fkey)) { + if (is_writable($fkey)) { $doc = fopen($fkey, "w"); fwrite($doc, $fpost); @@ -489,8 +446,6 @@ if (isset($_SESSION['neoCMSSess']) && strstr($_SESSION['neoCMSSess'], 'neoCMSses output(); } else output(); - - if ($ftpconn) ftp_close($ftpconn); } } else { $message = 'Error: neocms is unable find your session.'; diff --git a/cms/functions/checkbrand.php b/cms/functions/checkbrand.php deleted file mode 100644 index bb347f8..0000000 --- a/cms/functions/checkbrand.php +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/checkpath.php b/cms/functions/checkpath.php deleted file mode 100644 index b93eedc..0000000 --- a/cms/functions/checkpath.php +++ /dev/null @@ -1,66 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/cleaner.php b/cms/functions/cleaner.php deleted file mode 100644 index 510512e..0000000 --- a/cms/functions/cleaner.php +++ /dev/null @@ -1,109 +0,0 @@ -/'; - $aspreg = '/<%(.|\n|\r)+?\%>/'; - $jsreg = '/]*>\s*[^<](.|\n)*?<\/\s*script>/'; - $prereg = '/]*>(.|\n)*?<\/\s*pre>/'; - $codereg = '/]*>(.|\n)*?<\/\s*code>/'; - $cssreg = '/]*>(.|\n)*?<\/\s*style>/'; - - $stufflen = strlen($stuff); - - try { - - //grab php - preg_match_all($phpreg, $stuff, $code['PHP']); - $stuff = preg_replace($phpreg, '----||PHPTagGoesH3r3||----', $stuff); - - //grab asp - preg_match_all($aspreg, $stuff, $code['ASP']); - $stuff = preg_replace($aspreg, '----||ASPTagGoesH3r3||----', $stuff); - - //grab on-page js - preg_match_all($jsreg, $stuff, $code['JS']); - $stuff = preg_replace($jsreg, '----||JSTagGoesH3r3||----', $stuff); - - //grab on-page CSS - preg_match_all($cssreg, $stuff, $code['CSS']); - $stuff = preg_replace($cssreg, '----||CSSTagGoesH3r3||----', $stuff); - - } catch (Exception $e) { - - $message = 'Error: There may be too much on-page Javascript or CSS. Please try moving them to external files and/or validating your HTML.'; - output(); - - } - - $stuff = stripslashes($stuff); - $stuff = trim($stuff); - - //grab pre - preg_match_all($prereg, $stuff, $code['PRE']); - $stuff = preg_replace($prereg, '----||PreTagGoesH3r3||----', $stuff); - - //grab code - preg_match_all($codereg, $stuff, $code['CODE']); - $stuff = preg_replace($codereg, '----||CodeTagGoesH3r3||----', $stuff); - - //fix uppercase tags - $stuff = preg_replace_callback('/<(\/|)[A-Z]+[A-Z0-9]*\b/', function ($matches) { - return strtolower($matches[0]); - }, $stuff); - - //fix attribute quotes - $stuff = preg_replace('/(<(?!meta)[^>]*\s[A-Za-z]+=)([^>\'\"\s]+)(\s*[^>]*)/', '$1"$2"$3', $stuff); - - // fix self-closing tags - if (preg_match('/XHTML/', $doctype)) { - $stuff = preg_replace("/(%]*[^\/%])(>)/i", "$1/>", $stuff); - $stuff = preg_replace("//", "
", $stuff); - } - - $nstuff = htmlentities($stuff, ENT_QUOTES, $encode); - if ($nstuff == '') $nstuff = htmlentities($stuff, ENT_QUOTES, 'ISO-8859-15'); - $stuff = $nstuff; - - $stuff = str_replace("<", "<", $stuff); - $stuff = str_replace(">", ">", $stuff); - $stuff = str_replace("&", '&', $stuff); - $stuff = str_replace("'", "'", $stuff); - $stuff = str_replace(""", '"', $stuff); - - // remove TinyMCE stuff - preg_match_all('/(?:<[^>]*)(_mce_[^=]+=(?:\"|\'|)[^\"]*(?:\"|\'|)\s*)/', $stuff, $mces); - foreach ($mces[1] as $mce) { - $stuff = str_replace($mce, "", $stuff); - } - - // add back original code - - $replace = array('CODE', 'PRE', 'CSS', 'JS', 'ASP', 'PHP'); - - foreach ($replace as $r) { - $rreg = '/\-\-\-\-\|\|' . $r . 'TagGoesH3r3\|\|\-\-\-\-/'; - $c = 0; - - preg_match_all($rreg, $stuff, $newcode); - foreach ($newcode[0] as $ncode) { - $stuff = preg_replace($rreg, $code[$r][0][$c], $stuff, 1); - $c++; - } - $c = 0; - - } - - // remove extra line breaks - $stuff = preg_replace("/\r\n/", "\n", $stuff); - - if ($stuff != '' || $stufflen == 0) return $stuff; - else $message = 'Error: Some characters couldn’t be recognised. Try switching to UTF-8 encoding and be sure all special characters are properly encoded.'; - -} - -?> \ No newline at end of file diff --git a/cms/functions/createsession.php b/cms/functions/createsession.php deleted file mode 100644 index 79a2605..0000000 --- a/cms/functions/createsession.php +++ /dev/null @@ -1,35 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/fileload.php b/cms/functions/fileload.php deleted file mode 100644 index 345d258..0000000 --- a/cms/functions/fileload.php +++ /dev/null @@ -1,181 +0,0 @@ -read())) { - - if (!preg_match($neocmspath, $path)) $entries[] = $entry; - - } - - $dir->close(); - - foreach ($entries as $entry) { - - $fullname = $path . $entry; - $pathname = str_replace('../..', '', $path); - - $exFolders = preg_replace('/,\s*/', '/|', $_SESSION['neoCMSExFolders']); - $exFolders = str_replace('-', '\-', $exFolders); - $exFolders = str_replace('.', '\.', $exFolders); - $exFolders = '/' . str_replace('/', '\/', $exFolders) . '\//'; - - if ($entry != '.' && $entry != '..' && is_dir($fullname) && is_readable($fullname) && (!preg_match($exFolders, $fullname) || $_SESSION['neoCMSExFolders'] == '')) findfiles($fullname, $pattern); - elseif ($entry != '.' && $entry != '..' && is_file($fullname) && preg_match($pattern, $entry)) { - - if (!in_array($pathname, $matches)) { - - if (preg_match('/\.html|\.htm|\.php|\.cfm|\.phtml|\.shtml|\.asp/', $fullname)) { - - $content = file_get_contents($fullname); - - if (checkContent($content)) $matches[] = $fullname; - - } else $matches[] = $fullname; - - } - - } - - } - - } - - function checkContent($content) - { - - global $type; - - if (stristr($content, '[^<]+ 0) { - - foreach ($matches as $match) { - - $fname = str_replace('../../', '', $match); - $flink = siteURL() . $fname; - - if (preg_match('/\.bmp|\.gif|\.jpeg|\.jpg|\.png/i', $fname)) { - - if (!strstr($imghtml, 'neoCMSImgUL')) $imghtml = '
    '; - - if (($_SESSION['neoCMSImagePath'] == null || $_SESSION['neoCMSImagePath'] == '') || strstr($fname, $_SESSION['neoCMSImagePath'])) $imghtml = str_replace('', '
  • ' . $fname . ' Thumbnail

    ' . $fname . '

  • ', $imghtml); - - } elseif (preg_match('/\.html|\.htm|\.php|\.phtml|\.cfm|\.shtml|\.asp/i', $fname)) { - - if (!strstr($pagehtml, 'neoCMSPagesUL')) $pagehtml = '
      '; - - $pagehtml = str_replace('', '
    • ' . $fname . '
    • ', $pagehtml); - - } else { - - if (!strstr($filehtml, 'neoCMSFileUL')) $filehtml = '
        '; - - if (($_SESSION['neoCMSFilePath'] == null || $_SESSION['neoCMSFilePath'] == '') || strstr($fname, $_SESSION['neoCMSFilePath'])) $filehtml = str_replace('', '
      • ' . $fname . '
      • ', $filehtml); - - } - - } - - $matches = $imghtml . $pagehtml . $filehtml; - - $script = ""; - echo $script; - - } else { - - $script = ''; - echo $script; - - } - - $endscript = ""; - echo $endscript; - - } - - } - -} - -?> \ No newline at end of file diff --git a/cms/functions/folderload.php b/cms/functions/folderload.php deleted file mode 100644 index d8e1fff..0000000 --- a/cms/functions/folderload.php +++ /dev/null @@ -1,111 +0,0 @@ -read())) { - - if (!preg_match('/(\/neocms\-js\/|\/neocms\-images\/)/', $path)) $entries[] = $entry; - - } - - $dir->close(); - - foreach ($entries as $entry) { - - $fullname = $path . $entry; - $pathname = str_replace('../..', '', $path); - - $exFolders = preg_replace('/,\s*/', '|', $_SESSION['neoCMSExFolders']); - $exFolders = str_replace('-', '\-', $exFolders); - $exFolders = str_replace('.', '\.', $exFolders); - $exFolders = '/' . str_replace('/', '\/', $exFolders) . '/'; - - if ($entry != '.' && $entry != '..' && is_dir($fullname)) { - - if (preg_match($pathpatt, $path) && !in_array($pathname, $matches) && is_writable($path)) $matches[] = $pathname; - if (!preg_match($exFolders, $fullname) || $_SESSION['neoCMSExFolders'] == '') findfiles($fullname, $pattern, $pathpatt); - - } elseif (($entry == '.' || $entry == '..') && is_dir($fullname)) { - - if (preg_match($pathpatt, $path) && !in_array($pathname, $matches) && is_writable($path)) $matches[] = $pathname; - - } elseif (is_file($fullname) && preg_match($pattern, $entry)) { - - if (!in_array($pathname, $matches) && is_writable($path)) $matches[] = $pathname; - - } - - } - - } - - findfiles("../../$pathdefault", $pattern, $pathpatt); - - if (sizeof($matches) > 0) { - - foreach ($matches as $match) { - - $script = ''; - echo $script; - - } - - } else { - $script = ''; - echo $script; - } - - $endscript = ''; - echo $endscript; - - } - - } - -} - -?> \ No newline at end of file diff --git a/cms/functions/forgotpassword.php b/cms/functions/forgotpassword.php deleted file mode 100644 index d9e93eb..0000000 --- a/cms/functions/forgotpassword.php +++ /dev/null @@ -1,35 +0,0 @@ -window.top.window.forgotReset("' . $getmessage . '");'; - echo $script; - - } -} - -?> \ No newline at end of file diff --git a/cms/functions/ftpclear.php b/cms/functions/ftpclear.php deleted file mode 100644 index 52a830e..0000000 --- a/cms/functions/ftpclear.php +++ /dev/null @@ -1,67 +0,0 @@ -'; - - $fftp = ''; - - include_once('ftpvars.php'); - include_once('ftpconnect.php'); - - ftpconnect(); - - if ($ftpconn) { - - $ftpdoc = tmpfile(); - if (!$ftpdoc) { - $ftpdocp = tempnam(dirname(__FILE__) . '/../settings/tmp', 'Ftpdoc'); - chmod($ftpdocp, 0777); - $ftpdoc = fopen($ftpdocp, 'w+'); - } - - fwrite($ftpdoc, $ftpvars); - rewind($ftpdoc); - - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 1); - - $remotefile = $ftpwd . $path . 'ftpvars.php'; - - if (ftp_fput($ftpconn, $remotefile, $ftpdoc, FTP_BINARY)) { - - $getmessage = "Your FTP information has been successfully cleared."; - $savescript = ''; - echo $savescript; - - } else { - $getmessage = 'Error: neocms could not find this page: ' . $remotefile . ''; - $savescript = ''; - echo $savescript; - } - - fclose($ftpdoc); - if (isset($ftpdocp)) unlink($ftpdocp); - } - - echo ''; - - } - -} - -?> \ No newline at end of file diff --git a/cms/functions/ftpconnect.php b/cms/functions/ftpconnect.php deleted file mode 100644 index 9c9c30d..0000000 --- a/cms/functions/ftpconnect.php +++ /dev/null @@ -1,34 +0,0 @@ -Error: FTP is not enabled for your install of PHP. More info here."; - $savescript = ''; - echo $savescript; - - } - - } - -} - -?> \ No newline at end of file diff --git a/cms/functions/ftpcreate.php b/cms/functions/ftpcreate.php deleted file mode 100644 index 6240809..0000000 --- a/cms/functions/ftpcreate.php +++ /dev/null @@ -1,82 +0,0 @@ -'; - - include_once('ftpconnect.php'); - ftpconnect(); - - if ($ftpconn) { - - $ftpdoc = tmpfile(); - if (!$ftpdoc) { - $ftpdocp = tempnam(dirname(__FILE__) . '/../settings/tmp', 'Ftpdoc'); - chmod($ftpdocp, 0777); - $ftpdoc = fopen($ftpdocp, 'w+'); - } - - fwrite($ftpdoc, $ftpvars); - rewind($ftpdoc); - - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 1); - - $remotefile = $ftpwd . $path . 'ftpvars.php'; - - if (ftp_fput($ftpconn, $remotefile, $ftpdoc, FTP_BINARY)) { - - $getmessage = "Your FTP information was successfully saved."; - $savescript = ''; - echo $savescript; - - } else { - $getmessage = "Error: There is an error in your FTP credentials. Please try entering them again."; - $savescript = ''; - echo $savescript; - } - - fclose($ftpdoc); - if (isset($ftpdocp)) unlink($ftpdocp); - } - - echo ''; - - } else { - - $getmessage = 'Error: All fields are required.'; - $savescript = ''; - echo $savescript; - - echo ''; - - } - - } - -} - -?> \ No newline at end of file diff --git a/cms/functions/ftpstart.php b/cms/functions/ftpstart.php deleted file mode 100644 index 61acbcb..0000000 --- a/cms/functions/ftpstart.php +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/ftpvars.php b/cms/functions/ftpvars.php deleted file mode 100644 index f7af05b..0000000 --- a/cms/functions/ftpvars.php +++ /dev/null @@ -1,8 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/getpage.php b/cms/functions/getpage.php deleted file mode 100644 index 6c95841..0000000 --- a/cms/functions/getpage.php +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/getpath.php b/cms/functions/getpath.php deleted file mode 100644 index 631505c..0000000 --- a/cms/functions/getpath.php +++ /dev/null @@ -1,27 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/getsaveprefs.php b/cms/functions/getsaveprefs.php deleted file mode 100644 index 00cce9b..0000000 --- a/cms/functions/getsaveprefs.php +++ /dev/null @@ -1,35 +0,0 @@ -window.top.window.userBar("' . $getmessage . '");'; - echo $savescript; - - } - - $script = ''; - echo $script; - - } - -} \ No newline at end of file diff --git a/cms/functions/getsaveusers.php b/cms/functions/getsaveusers.php deleted file mode 100644 index 81766b5..0000000 --- a/cms/functions/getsaveusers.php +++ /dev/null @@ -1,98 +0,0 @@ - $val) { - - if (strstr($key, '-A')) $admin[str_replace('-A', '', $key)] = $val; - elseif (!strstr($key, 'neoCMSSess') && !strstr($key, 'neoCMSUserMessage')) { - - $num = explode('-', $key); - $users[$num[1]][$num[0]] = $val; - - } - - } - - $adminscript = ''; - echo $adminscript; - - foreach ($users as $user) { - - $userscript = ''; - echo $userscript; - - } - - if ($_GET['neoCMSUserMessage'] != '0') { - - $m = $_GET['neoCMSUserMessage']; - - if ($m == '1') $getmessage = "Your account settings were successfully saved."; - elseif ($m == '2') $getmessage = "Your new account has been successfully created."; - elseif ($m == '3') $getmessage = "Error: This account has already been created."; - elseif ($m == '4') $getmessage = "Account successfully deleted."; - elseif ($m == '5') $getmessage = "Error: There was an error deleting this account."; - else $getmessage = "Error: There was an error saving."; - - $savescript = ''; - echo $savescript; - - $_SESSION['neoCMSUserid'] = $admin['neoCMSUsername']; - } - - echo ''; - } - } -} - -?> \ No newline at end of file diff --git a/cms/functions/geturi.php b/cms/functions/geturi.php deleted file mode 100644 index 003f3b0..0000000 --- a/cms/functions/geturi.php +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/login.php b/cms/functions/login.php deleted file mode 100644 index 35607b4..0000000 --- a/cms/functions/login.php +++ /dev/null @@ -1,49 +0,0 @@ -window.top.window.location="../";'; - echo $script; - } - - } elseif (isset($_GET['error'])) { - - if ($_GET['error'] == 'login') $message = "Incorrect username or password"; - elseif ($_GET['error'] == 'domain') $message = "Domain not registered. Please contact."; - - $script = ''; - echo $script; - } - -} else { - - $script = ''; - echo $script; - -} - -?> diff --git a/cms/functions/logout.php b/cms/functions/logout.php deleted file mode 100644 index a4f9618..0000000 --- a/cms/functions/logout.php +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/cms/functions/restore.php b/cms/functions/restore.php deleted file mode 100644 index ac5638f..0000000 --- a/cms/functions/restore.php +++ /dev/null @@ -1,180 +0,0 @@ -Error: There was an error restoring your page. Please try again.'; - - if (@file_exists($pageurl)) { - - function loadfile($url, $incpath, $inc) - { - - global $message, $pagepath; - - // read the file - - $doc = fopen($url, "r"); - $content = stream_get_contents($doc); - fclose($doc); - - $reginclude = '/(?:include\b|include_once\b|require\b|require_once\b)(?:\s*\(*[^;\?>]*)(?:\"|\')([^\"\'<>]*)(?:(\"|\')\)*(;|[\s\t\r\n]*\?>))/i'; // php include regexp - if (!preg_match($reginclude, $content)) $reginclude = '/(?:)/i'; // SSI regexp - - // read the backup - $pagename = (strstr($url, $_SERVER['DOCUMENT_ROOT'])) ? explode($_SERVER['DOCUMENT_ROOT'], $url) : explode('../../', $url); - $pagename = trim($pagename[1], '/'); - $pagename = str_ireplace('/', '-', $pagename); - - $pageext = explode('.', $pagename); - $pagename = preg_replace('/(\.php|\.asp|\.html|\.htm|\.phtml|\.shtml|\.cfm)/', '', $pagename); - $backup = dirname(__FILE__) . '/../backups/' . $pagename . '_Bak.' . $pageext[1]; - - if (@file_exists($backup)) { - - $backdoc = fopen($backup, "r"); - $backcontent = stream_get_contents($backdoc); - - fclose($backdoc); - - echo "File Found: $backup\n\n"; - - editfile($content, $backcontent, $url, $incpath, $inc); - - } - - if (preg_match($reginclude, $content)) { - - preg_match_all($reginclude, $content, $includes); - - foreach ($includes[1] as &$value) { - - if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $value) && $value != '') { - - $incfile = $_SERVER['DOCUMENT_ROOT'] . $value; - $incpath = false; - - } elseif (!stristr($value, 'http://')) { - - $incfile = "$pagepath/$value"; - - if ($incpath) { - - $incpathreg = preg_replace('/\//', '\/', $incpath); - $incpathreg = '/(^' . $incpathreg . '\/|\/' . $incpathreg . '\/)/'; - - $incorigpath = preg_replace($incpathreg, '', $value, 1); - - $newinc = "$pagepath/$incpath/$incorigpath"; - - $incfile = (@file_exists($newinc)) ? $newinc : $incfile; - - $incpatharr = explode('/', $incorigpath); - array_pop($incpatharr); - $incpath = (sizeof($incpatharr) > 0) ? $incpath . implode('/', $incpatharr) : false; - - } else { - - $incpatharr = explode('/', $value); - array_pop($incpatharr); - $incpath = (sizeof($incpatharr) > 0) ? $incpath . implode('/', $incpatharr) : false; - - } - - } else $incpath = false; - - if (!preg_match('/\/$/', $incfile)) loadfile($incfile, $incpath, true); - - } - - } - } - - function editfile($content, $backcontent, $url, $incpath, $inc) - { - - global $ftpconn, $ftpwd; - - if ($content != $backcontent && ((!stristr($content, '[^<]+Error: neocms could not find this page: ' . $remotefile . ''; - - fclose($restdoc); - if (isset($restdocp)) unlink($restdocp); - - } elseif (is_writable($url)) { - //restores file - $restdoc = fopen($url, "w"); - fputs($restdoc, $backcontent); - fclose($restdoc); - } else $message = "Error: You do not have permission to edit this page."; - - } - - } - - loadfile($pageurl, false, false); - - $message = 'Your page was successfully restored.'; - $script = ''; - echo $script; - - } else { - $message = 'Error: neocms could not find this page: ' . $url . ''; - $script = ''; - echo $script; - } - - if ($ftpconn) ftp_close($ftpconn); - - } -} - -?> \ No newline at end of file diff --git a/cms/functions/save.php b/cms/functions/save.php deleted file mode 100644 index 17d4393..0000000 --- a/cms/functions/save.php +++ /dev/null @@ -1,525 +0,0 @@ - $post) { - - $post = thecleaner($post); - if (preg_match("/^edit/", $key)) $edit[$key] = $post; - - } - - } - - function loadfile($url, $incpath, $f) - { - - global $message, $includes, $pagepath, $ftpconn, $ftpwd, $doctype, $encode, $edit; - - $ssi = false; - - $pagename = (strstr($url, $_SERVER['DOCUMENT_ROOT'])) ? explode($_SERVER['DOCUMENT_ROOT'], $url) : explode('../../', $url); - $pagename = trim($pagename[1], '/'); - $pagename = str_ireplace('/', '-', $pagename); - $pagefile = $pagename; - - if (@file_exists($url)) { - - // read the file - $doc = fopen($url, "r"); - $content = stream_get_contents($doc); - fclose($doc); - - if ((!stristr($content, '[^<]+]*>/', $content)) { - preg_match_all('/]*>/', $content, $dtarr); - $doctype = $dtarr[0][0]; - } - if (preg_match('/(?:]*charset=\"*)([^\"<]+)/', $stuff)) { - preg_match_all($charreg, $stuff, $enc); - $encode = $enc[1][0]; - } - - if ($f) cleanpost(); - - $elereg = '/<[^>]*class=(?:\"|\'|)[^>]*(\bneocms\b|\bneocmsRepeatArea\b)[^>]*?(?:\"|\'|)[^>]*>/'; - $reginclude = '/(?:include\b|include_once\b|require\b|require_once\b)(?:\s*\(*[^;\?>]*)(?:\"|\')([^\"\'<>]*)(?:(\"|\')\)*(;|[\s\t\r\n]*\?>))/i'; // php include regexp - if (!preg_match($reginclude, $content)) $reginclude = '/(?:)/i'; // SSI regexp - - // create a backup - $pageext = explode('.', $pagename); - $pagename = preg_replace('/(\.php|\.asp|\.html|\.htm|\.phtml|\.shtml|\.cfm)/', '', $pagename); - $backup = dirname(__FILE__) . '/../backups/' . $pagename . '_Bak.' . $pageext[1]; - - if ($ftpconn) { - - $backdoc = tmpfile(); - if (!$backdoc) { - $backdocp = tempnam(dirname(__FILE__) . '/../settings/tmp', 'Back'); - chmod($backdocp, 0777); - $backdoc = fopen($backdocp, 'w+'); - } - - fwrite($backdoc, $content); - rewind($backdoc); - - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 2); - - $remotefile = $ftpwd . $path . 'backups/' . $pagename . '_Bak.' . $pageext[1]; - - echo "Backup File: $remotefile\n\n"; - - if (ftp_fput($ftpconn, $remotefile, $backdoc, FTP_BINARY)) echo "Uploaded Backup: $remotefile!\n\n"; - else $message = 'Error: neocms failed creating backup for: ' . $remotefile . ''; - - fclose($backdoc); - if (isset($backdocp)) unlink($backdocp); - - } elseif (is_writable($url)) { - - $backdoc = fopen($backup, "w+"); - fwrite($backdoc, $content); - fclose($backdoc); - - } else $message = 'Error: You do not have permission to edit this page: ' . $pagefile . ". Try saving your FTP info here."; - - // clean up content - - if (preg_match($reginclude, $content)) { - - preg_match_all($reginclude, $content, $includes[$url]); - - $incArr = preg_split($reginclude, $content); - $incfiles = $includes[$url][1]; - $neoCon = array(); - - foreach ($incArr as $k => $v) { - - $docroot = $_SERVER['DOCUMENT_ROOT']; - - if (@file_exists($docroot . $incfiles[$k]) && $incfiles[$k] != '') { - - $neoCon[$k] = $v; - - $incfile = $docroot . $incfiles[$k]; - $incpath = false; - - } elseif (!stristr($incfiles[$k], 'http://')) { - - $neoCon[$k] = $v; - - $incfile = "$pagepath/$incfiles[$k]"; - - if ($incpath) { - - $incpathreg = str_replace('/', '\/', $incpath); - $incpathreg = '/(^' . $incpathreg . '\/|\/' . $incpathreg . '\/)/'; - - $incorigpath = preg_replace($incpathreg, '', $incfiles[$k], 1); - - $newinc = "$pagepath/$incpath/$incorigpath"; - - $incfile = (@file_exists($newinc)) ? $newinc : $incfile; - - $incpatharr = explode('/', $incorigpath); - array_pop($incpatharr); - $incpath = (sizeof($incpatharr) > 0) ? $incpath . implode('/', $incpatharr) : false; - - } else { - - $incpatharr = explode('/', $incfiles[$k]); - array_pop($incpatharr); - $incpath = (sizeof($incpatharr) > 0) ? $incpath . implode('/', $incpatharr) : false; - - } - - } else $incpath = false; - - if (!preg_match('/\/$/', $incfile)) $neoCon[$incfile] = loadfile($incfile, $incpath, false); - - } - - return $neoCon; - - } else return $content; - } - } else return false; - - } - - function output() - { - - global $message; - - $script = ''; - echo $script; - - } - - function conArray($content) - { - - $conArray = false; - - foreach ($content as $con) { - - if (is_array($con)) $conArray = true; - - } - - return conArray; - - } - - function makeEdits($conpost) - { - - global $edit, $eles, $inc, $count; - - $commreg = '//'; - - preg_match_all($commreg, $conpost, $comments); - - $conpost = preg_replace($commreg, '', $conpost); - - $elereg = '/<[^>]*class\s*=\s*(?:\"|\'|)[^\"|\']*(\bneocms\b|\bneocmsRepeatArea\b)[^\"|\'|=]*?(?:\"|\'|)[^>]*>/'; - - preg_match_all($elereg, $conpost, $neocmseles); - - if ($neocmseles[0]) { - - $newsplice = ''; - - foreach ($neocmseles[0] as $neocmsele) { - - $splice = explode($neocmsele, $conpost, 2); - - $newsplice = $splice[0]; - - $post = $splice[1]; - - $rest = ''; - - preg_match_all("/^<([^>\s]*)\b/i", $neocmsele, $eleTag); - - $eleTag = $eleTag[1][0]; - - if (stristr($eleTag, 'img')) { - - if (isset($edit["editImg$count"])) { - - $editStr = array(); - - $editIncom = $edit["editImg$count"]; - $editIncom = explode(',', $editIncom); - foreach ($editIncom as $eikey => $eipost) { - $eipost = explode('::', $eipost); - $editStr[$eipost[0]] = $eipost[1]; - } - - $editContent = ''; - - if (isset($editStr['link']) && $editStr['link'] != '') { - - if (preg_match('/(]*>)$/', $newsplice)) { - - preg_match_all('/(]*href=(?:\"|\'))([^\"\s]*)((?:\"|\')[^>]*>)$/', $newsplice, $lastlink); - $newlink = $lastlink[1][0] . $editStr['link']; - if ($editStr['rel'] != '') $newlink .= '" rel="' . $editStr['rel']; - $newlink .= $lastlink[3][0]; - - $newsplice = preg_replace('/(]*>)$/', "$newlink", $newsplice); - - } else { - - $newsplice .= ']*>)$/', $newsplice)) $newsplice = preg_replace('/(]*>)$/', '', $newsplice); - if (preg_match('/^(<\/a>)/', $post)) $post = preg_replace('/^(<\/a>)/', '', $post); - - } - - $editContent .= '' . $editStr['alt'] . ']*>/i'; - - preg_match_all($eleTagReg, $post, $tags); - - $contents = preg_split($eleTagReg, $post); - - $track = 1; - - foreach ($tags[0] as $tag) { - - if (strpos($tag, ' 1) { - - foreach ($tags[0] as $tag) { - - if (isset($edit["editVid$count"])) $rest .= $contents[0]; - else $rest .= $tag . $contents[0]; - - array_shift($contents); - - } - - } else { - - if (isset($edit["editVid$count"])) $rest = $contents[0]; - else $rest = $tags[0][0] . $contents[0]; - - } - - } - - $neocmsele = preg_replace('/neocms\b|neocmsRepeatArea\b/', '$0--D0n3--', $neocmsele); - - if (isset($edit["edit$count"])) $newsplice .= $neocmsele . "\n" . $edit["edit$count"] . "\n" . $rest; - elseif (isset($edit["editImg$count"]) && stristr($eleTag, 'img')) $newsplice .= $post; - elseif (isset($edit["editVid$count"]) && (stristr($eleTag, 'embed') || stristr($eleTag, 'object'))) $newsplice .= "\n" . $edit["editVid$count"] . "\n" . $rest; - elseif (sizeof($splice) <= 1) $newsplice .= $post; - else $newsplice .= $neocmsele . $post; - - $conpost = $newsplice; - - $count++; - - $rest = ''; - } - - $newsplice = preg_replace('/--D0n3--/', '', $newsplice); - - } else $newsplice = $conpost; - - foreach ($comments[0] as $com) { - - $newsplice = preg_replace('//', $com, $newsplice, 1); - - } - - return $newsplice; - - } - - function editFile($content, $url) - { - - global $message, $includes, $edit, $inc; - - $fileedits = array(); - - if (is_array($content)) { - - foreach ($content as $conkey => $conpost) { - - if (is_array($conpost)) $content[$conkey] = editFile($conpost, $conkey); - else $content[$conkey] = makeEdits($conpost); - - } - - foreach ($content as $ckey => $cpost) { - - if (preg_match('/^(\d+)$/', $ckey)) { - - if (isset($includes[$url][0][$inc])) $fileedits[$url] .= $cpost . $includes[$url][0][$inc]; - else $fileedits[$url] .= $cpost; - $inc++; - } else $fileedits["$ckey"] = $cpost; - - } - } else $fileedits[$url] = makeEdits($content); - - $inc = 0; - - return $fileedits; - - } - - function cleanFilecon($files) - { - - global $filecon; - - foreach ($files as $fkey => $fpost) { - - if (is_array($fpost)) cleanFilecon($fpost); - else { - - if (!$filecon[$fkey]) $filecon[$fkey] = $fpost; - - } - - } - - } - - function flatten($ar) - { - $toflat = array($ar); - $res = array(); - - while (($r = array_shift($toflat)) !== NULL) { - foreach ($r as $v) { - if (is_array($v)) { - $toflat[] = $v; - } else { - $res[] = $v; - } - } - } - - return $res; - } - - $conArr = loadfile($pageurl, false, true); - - if (is_array($conArr)) { - $missing = array_search(false, $conArr); - if ($conArr[$missing] == '') $missing = false; - } elseif ($conArr) $missing = false; - - if ($missing === false) { - - cleanFilecon(editFile($conArr, $pageurl)); - - if (preg_match('/successfully/', $message)) { - - foreach ($filecon as $fkey => $fpost) { - - if ($fpost != '') { - - if (@file_exists($fkey)) { - - if ($ftpconn) { - - $doc = tmpfile(); - if (!$doc) { - $docp = tempnam(dirname(__FILE__) . '/../settings/tmp', 'Doc'); - chmod($docp, 0777); - $doc = fopen($docp, 'w+'); - } - $remotefile = ''; - - fwrite($doc, $fpost); - rewind($doc); - - $incs = flatten($includes); - - if (strstr($fkey, $_SERVER['DOCUMENT_ROOT'])) { - - $nfkey = explode($_SERVER['DOCUMENT_ROOT'], $fkey); - $nfkey = $nfkey[1]; - - if (in_array($nfkey, $incs)) $remotefile = $ftpwd . $nfkey; - else { - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 3); - $fkey = explode('../../', $fkey, 2); - - $remotefile = $ftpwd . $path . $fkey[1]; - } - - } else { - - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 3); - $fkey = explode('../../', $fkey, 2); - - $remotefile = $ftpwd . $path . $fkey[1]; - - } - - if (ftp_fput($ftpconn, $remotefile, $doc, FTP_BINARY)) echo "Uploaded: $remotefile!\n\n"; - else $message = 'Error: neocms publish this page: ' . $remotefile . ''; - - fclose($doc); - if (isset($docp)) unlink($docp); - - } elseif (is_writable($fkey)) { - - $doc = fopen($fkey, "w"); - fwrite($doc, $fpost); - fclose($doc); - - } else $message = "Error: You do not have permission to edit this page."; - - } else $message = 'Error: neocms is unable find this page.'; - - } - - } - } - - } else $message = 'Error: neocms is unable find this page: ' . $missing . ''; - - output(); - - } else output(); - - if ($ftpconn) ftp_close($ftpconn); - } -} else { - $message = 'Error: neocms is unable find your session.'; - output(); -} - -?> diff --git a/cms/functions/upload.php b/cms/functions/upload.php deleted file mode 100644 index 79dd51a..0000000 --- a/cms/functions/upload.php +++ /dev/null @@ -1,120 +0,0 @@ -Error: There was an error uploading your image. Please try again."; - list($fileWidth, $fileHeight) = getimagesize($file['tmp_name']); - - if (preg_match('/(.jpg|.png|.gif)$/i', $fileName) && $fileSize < 5000000) { - - if (move_uploaded_file($file['tmp_name'], $uploadfile)) { - $alert = "Your file was successfully uploaded."; - } elseif ($ftpconn) { - - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 3); - $uploadfile = str_ireplace('../../', '', $uploadfile); - - $remotefile = $ftpwd . $path . $uploadfile; - $tempfile = fopen($file['tmp_name'], 'r'); - - if (ftp_fput($ftpconn, $remotefile, $tempfile, FTP_BINARY)) $alert = "Your file was successfully uploaded."; - - } - - } else { - $alert = "Error: You may only upload .jpg, .gif, or .png image files, under 5.0 MB in size."; - $fileName = ""; - } - - $script = ''; - echo $script; - - } else { - - $script = ''; - echo $script; - - } - - } else { - - $file = $_FILES['neoCMSUpload']; - - $uploaddir = ($_POST['neoCMSFolder']) ? '../..' . $_POST['neoCMSFolder'] : '../../'; - $uploaddir = ($_SESSION['neoCMSFilePath']) ? '../../' . $_SESSION['neoCMSFilePath'] : $uploaddir; - $uploadfile = $uploaddir . basename($file['name']); - - if (!@file_exists($uploadfile) || $_GET['over']) { - - $fileName = $file['name']; - $fileSize = $file['size']; - $alert = "Error: There was an error uploading your image. Please try again."; - - if (!preg_match('/(\.html|\.php|\.js|\.css|\.htm|\.shtml|\.asp|\.cfm|\.phtml)$/i', $fileName) && $fileSize < 100000000) { - - if ($ftpconn) { - - $path = urldissect($_SERVER['SCRIPT_NAME'], false, 3); - $uploadfile = str_ireplace('../../', '', $uploadfile); - - $remotefile = $ftpwd . $path . $uploadfile; - $tempfile = fopen($file['tmp_name'], 'r'); - - if (ftp_fput($ftpconn, $remotefile, $tempfile, FTP_BINARY)) $alert = "Your file was successfully uploaded."; - else { - $alert = "Error: You do not have permission to upload files to this folder."; - $script = ''; - echo $script; - } - - } elseif (move_uploaded_file($file['tmp_name'], $uploadfile)) { - $alert = "Your file was successfully uploaded."; - } else { - $alert = "Error: You do not have permission to upload files to this folder."; - $fileName = ""; - } - } else { - $alert = "Error: You may not upload .html, .htm, .php, .js, or .css files, under 100 MB in size."; - $fileName = ""; - } - - $script = ''; - echo $script; - - } else { - - $script = ''; - echo $script; - - } - - } - - if ($ftpconn) ftp_close($ftpconn); - - } - -} - -?> \ No newline at end of file diff --git a/cms/functions/urldissect.php b/cms/functions/urldissect.php deleted file mode 100644 index 51a6d5e..0000000 --- a/cms/functions/urldissect.php +++ /dev/null @@ -1,21 +0,0 @@ - \ No newline at end of file