Esempio n. 1
0
/**
 * save data to file (overwrites existing)
 * then chmod
 * @todo do we really need to chmod everytime ?
 *
 * @since  3.4
 *
 * @param  str $file filepath
 * @param  str $data data to save to file
 * @return bool success
 */
function save_file($file, $data = '')
{
    $status = file_put_contents($file, $data) !== false;
    // returns num bytes written, FALSE on failure
    fileLog(__FUNCTION__, $status, $file);
    if (getDef('GSDOCHMOD', true)) {
        $chmodstatus = gs_chmod($file);
    }
    // currently ignoring chmod failures
    return $status;
}
Esempio n. 2
0
    $tmpfile = GSADMININCPATH . 'tmp/tmp-404.xml';
    if (file_exists($dir)) {
        gs_chmod($dir, 0755);
        $result_755 = copy_file($tmpfile, $dir . 'tmp.tmp');
        if (!$result_755) {
            gs_chmod($dir, 0777);
            $result_777 = copy_file($tmpfile, $dir . 'tmp.tmp');
            if (!$result_777) {
                $kill = i18n_r('CHMOD_ERROR');
            }
        }
    } else {
        create_dir($dir, 0755);
        $result_755 = copy_file($tmpfile, $dir . 'tmp.tmp');
        if (!$result_755) {
            gs_chmod($dir, 0777);
            $result_777 = copy_file($tmpfile, $dir . 'tmp.tmp');
            if (!$result_777) {
                $kill = i18n_r('CHMOD_ERROR');
            }
        }
    }
    if (file_exists($dir . 'tmp.tmp')) {
        delete_file($dir . 'tmp.tmp');
    }
}
// get available language files
$filenames = getFiles(GSLANGPATH);
if ($LANG == '') {
    $LANG = GSDEFAULTLANG;
}
Esempio n. 3
0
 if ($_FILES["file"]["error"][$i] > 0) {
     $errors[] = i18n_r('ERROR_UPLOAD');
 } else {
     //set variables
     $count = '1';
     $file_base = clean_img_name(to7bit($_FILES["file"]["name"][$i]));
     $file_loc = $path . $file_base;
     //prevent overwriting
     if (!isset($_POST['fileoverwrite']) && file_exists($file_loc)) {
         list($file_base, $filecount) = getNextFileName($path, $file_base);
         $file_loc = $path . $file_base;
     }
     //validate file
     if (validate_safe_file($_FILES["file"]["tmp_name"][$i], $_FILES["file"]["name"][$i])) {
         move_uploaded_file($_FILES["file"]["tmp_name"][$i], $file_loc);
         gs_chmod($file_loc);
         exec_action('file-uploaded');
         // generate thumbnail
         genStdThumb($subFolder, $file_base);
         $messages[] = i18n_r('FILE_SUCCESS_MSG');
         if (requestIsAjax()) {
             header("HTTP/1.0 200");
             die;
         }
     } else {
         $messages[] = $_FILES["file"]["name"][$i] . ' - ' . i18n_r('ERROR_UPLOAD');
         if (requestIsAjax()) {
             header("HTTP/1.0 403");
             i18n('ERROR_UPLOAD');
             die;
         }
Esempio n. 4
0
 $PERMALINK = $datac->PERMALINK;
 $TIMEZONE = $datac->TIMEZONE;
 $LANG = $datac->LANG;
 $SITENAME = stripslashes($dataw->SITENAME);
 $SITEURL = $dataw->SITEURL;
 $TEMPLATE = $dataw->TEMPLATE;
 # creating new user file
 $xml = new SimpleXMLElement('<item></item>');
 $xml->addChild('USR', $USR);
 $xml->addChild('PWD', $PASSWD);
 $xml->addChild('EMAIL', $EMAIL);
 $xml->addChild('HTMLEDITOR', $HTMLEDITOR);
 $xml->addChild('TIMEZONE', $TIMEZONE);
 $xml->addChild('LANG', $LANG);
 $status = XMLsave($xml, GSUSERSPATH . _id($USR) . '.xml');
 gs_chmod(GSUSERSPATH . _id($USR) . '.xml');
 if (!$status) {
     $error .= msgError('Unable to create new  ' . _id($USR) . '.xml file!');
 } else {
     $message .= msgOK('Created new ' . _id($USR) . '.xml file');
 }
 # rename old wesbite.xml
 if (!file_exists(GSDATAOTHERPATH . '_legacy_website.xml')) {
     $status = rename_file(GSDATAOTHERPATH . 'website.xml', GSDATAOTHERPATH . '_legacy_website.xml');
     if (!$status) {
         $error .= msgError('Unable to rename website.xml to _legacy_website.xml');
     } else {
         $message .= msgOK('Renamed website.xml to _legacy_website.xml');
     }
 }
 #creating new website file