SHARE
TWEET

themesite

copper Mar 20th, 2014 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- themesite/private/themesite.class.php       2014-03-20 14:51:33.484324931 +0100
  2. +++ themesite-new/private/themesite.class.php   2014-03-20 15:46:00.236270202 +0100
  3. @@ -958,7 +958,8 @@
  4.          $rsbsfound = array();
  5.          $cfgfound = array();
  6.          $shortname = '';
  7. -        $cfg = '';
  8. +        $cfg = array();
  9. +        $checkCfgFilenamesAgain = FALSE;
  10.  
  11.          if (is_int($zip)) {
  12.              $err[] = sprintf("'Couldn't open zipfile %s", $themezipupload['name']);
  13. @@ -995,8 +996,21 @@
  14.              switch(strtolower($pathinfo['extension'])) {
  15.                  case 'cfg':
  16.                      /* Save the contents for later checking */
  17. -                    $cfg = $this->getzipentrycontents($zip, $ze);
  18. +                    $cfg[] = $this->getzipentrycontents($zip, $ze);
  19.                      $cfgfound[] = $filename;
  20. +                    if ($shortname === '') {
  21. +                        // we're gonna need to check cfg filenames again because shortname isn't set yet
  22. +                        $checkCfgFilenamesAgain = TRUE;
  23. +                    } else {
  24. +                        if ($pathinfo['filename'] !== "$shortname") {
  25. +                            if (strpos($pathinfo['filename'], "{$shortname}-") !== 0) {
  26. +                                // filename does not start with shortname-*
  27. +                                $err[] = sprintf('Filename invalid: %s (should be %s.%s or %s-*.%s)', $filename, $shortname, $pathinfo['extension'], $shortname, $pathinfo['extension']);
  28. +                            }
  29. +                        }
  30. +                    }
  31. +                    break;
  32. +
  33.                  case 'sbs':
  34.                  case 'rsbs':
  35.                  case 'wps':
  36. @@ -1046,10 +1060,30 @@
  37.              }
  38.          }
  39.  
  40. +        // we check cfg filenames a second time in case $shortname wasn't set the first time around
  41. +        if ($checkCfgFilenamesAgain) {
  42. +            while ($ze = zip_read($zip)) {
  43. +                $filename = zip_entry_name($ze);
  44. +                $pathinfo = $this->my_pathinfo($filename);
  45. +                if (strtolower($pathinfo['extension']) == 'cfg') {
  46. +                    if ($shortname === '') {
  47. +                        $shortname = $pathinfo['filename'];
  48. +                    } elseif ($pathinfo['filename'] !== $shortname) {
  49. +                        if (strpos($pathinfo['filename'], "{$shortname}-") !== 0) {
  50. +                            $err[] = sprintf('Filename invalid: %s (should be %s.%s or %s-*.%s)', $filename, $shortname, $pathinfo['extension'], $shortname, $pathinfo['extension']);
  51. +                        }
  52. +                    }
  53. +                }
  54. +            }
  55. +        }
  56. +
  57.          /* Now we check all the things that could be wrong */
  58. -        $error = $this->validatecfg($cfg, $files);
  59. -        if($error != '')
  60. -            $err[] = $error;
  61. +        foreach ($cfg as $cfgcontent) {
  62. +            $error = $this->validatecfg($cfgcontent, $files);
  63. +            if($error != '')
  64. +                $err[] = $error;
  65. +        }
  66. +
  67.          if ($themezipupload['size'] > config::maxzippedsize)
  68.              $err[] = sprintf("Theme zip too large at %s (max size is %s)", $themezipupload['size'], config::maxzippedsize);
  69.          if ($totalsize > config::maxthemesize)
  70. @@ -1062,9 +1096,7 @@
  71.          elseif (count($wpsfound) == 0)
  72.              $err[] = "No .wps files found.";
  73.  
  74. -        if (count($cfgfound) > 1)
  75. -            $err[] = sprintf("More than one .cfg found (%s).", implode(', ', $cfgfound));
  76. -        elseif (count($cfgfound) == 0)
  77. +        if (count($cfgfound) == 0)
  78.              $err[] = "No .cfg files found.";
  79.  
  80.          if (count($rwpsfound) > 1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top