title: "Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 3 in..."
body: <p>I've searched other questions but can't find a workable solution. This is a CMS program, I've tried to upload files to any directory and am getting the following the error:</p>
  
  <pre><code>Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 3 in /home/...on line 1017 
  </code></pre>
  
  <p>Here is the code, any suggestions?:</p>
  
  <pre><code>function _IsValidPath($Path)
  { // First check if the path starts with the starting directory     
  $basePath = preg_replace("/{1,}/", "/", $_SESSION['rootdirectory'] . '/' . // this line (1017) causing the error
   $_SESSION["startingdirectory"]);
  $sdPos = strpos($basePath, $Path);
  if (!is_numeric($sdPos))
          {
              $sdPos = strpos($Path, $basePath);
          }
  
          if(is_numeric($sdPos) &amp;&amp; $sdPos == 0)
          {
              // Make sure it doesn't contain any invalid characters
              if(is_numeric(strpos($Path, "..")) ||
              (is_numeric(strpos($Path, "./"))) ||
              (is_numeric(strpos($Path, "//"))) ||
              (is_numeric(strpos($Path, "\\"))) ||
              (is_numeric(strpos($Path, "../"))) ||
              (is_numeric(strpos($Path, "&amp;"))) ||
              (is_numeric(strpos($Path, "*"))) ||
              (is_numeric(strpos($Path, " "))) ||
              (is_numeric(strpos($Path, "'"))) ||
              (is_numeric(strpos($Path, "\?"))) ||
              (is_numeric(strpos($Path,"&lt;"))) ||
              (is_numeric(strpos($Path, "&gt;"))))
              {
                  return false;
              }
              else
              {
                  // The path is OK
                  return true;
              }
          }
          else
          {
              return false;
          }
      }
  </code></pre>