Example #1
0
 /**
  * sp_Installer::updateRewriteBases() - this method updates all the htaccess files
  * RewriteBase line based on current installation path
  *
  * @return boolean
  */
 private function updateRewriteBases()
 {
     //get rewrite base
     $lstrRewriteBase = getRewriteBase();
     //get root to subjectsplus path
     $lstrRootPath = dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR;
     //all htaccess files needing to update
     $lobjFiles = array($lstrRootPath . 'subjects' . DIRECTORY_SEPARATOR . '.htaccess', $lstrRootPath . 'api' . DIRECTORY_SEPARATOR . '.htaccess');
     //go through each path and replace existing rewrite base with new rewrite base
     foreach ($lobjFiles as $lstrPath) {
         $lobjFile = file($lstrPath);
         foreach ($lobjFile as $lintLineNumber => $lstrLine) {
             $lstrLine = preg_replace('/RewriteBase.*sp\\//', "RewriteBase {$lstrRewriteBase}", $lstrLine);
             $lobjFile[$lintLineNumber] = $lstrLine;
         }
         //open the file for writing which will truncate all data on the file.
         $lhndFile = fopen($lstrPath, 'w');
         //if opening of the file givers error, return false
         if ($lhndFile === FALSE) {
             return FALSE;
         }
         //go through and write file array to file
         foreach ($lobjFile as $lstrLine) {
             $lboolSuccess = fwrite($lhndFile, $lstrLine);
             //if the file cannot be written to, return false.
             if ($lboolSuccess === FALSE) {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
Example #2
0
/**
 * moveFile() - tries to move uploaded file to desired path and returns the uploaded files url
 *
 * @param string $lstrDesiredPath
 * @return string
 */
function moveFile($lstrDesiredPath)
{
    if (move_uploaded_file($_FILES['upload']['tmp_name'], $lstrDesiredPath)) {
        $lobjTemp = explode(DIRECTORY_SEPARATOR, $lstrDesiredPath);
        return getRewriteBase("ckeditor") . 'assets/users/' . $lobjTemp[count($lobjTemp) - 2] . '/' . $lobjTemp[count($lobjTemp) - 1];
    } else {
        return false;
    }
}