示例#1
1
/**
 * Restore Backup copy of a dataFile to where it belongs
 *
 * @since 3.4
 *
 * @param string $file filepath of data file to restore from backup, locked to GSDATAPATH
 * @param  bool $delete delete the backup
 * @return bool success
 */
function restore_datafile($filepath, $delete = true)
{
    if (!filepath_is_safe($filepath, GSDATAPATH)) {
        return false;
    }
    $bakfilepath = getBackupFilePath($filepath);
    // backup original before restoring
    if (file_exists($filepath)) {
        rename_file($bakfilepath, $bakfilepath . '.tmp');
        move_file($filepath, $bakfilepath);
        $bakfilepath .= '.tmp';
    }
    if (!$delete) {
        return copy_file($bakfilepath, $filepath);
    }
    return move_file($bakfilepath, $filepath);
}
示例#2
0
/**
 * publish a draft
 * @since  3.4
 * @param  str $id id of page draft to publish
 * @return bool    status
 */
function publishDraft($id)
{
    if (!pageHasDraft($id)) {
        return false;
    }
    backup_page($id);
    // backup live page
    backup_datafile(GSDATADRAFTSPATH . $id . '.xml');
    // backup draft before moving
    $status = move_file(GSDATADRAFTSPATH, GSDATAPAGESPATH, $id . '.xml');
    // restore_datafile(GSDATADRAFTSPATH . $id .".xml"); // debugging replays
    if ($status) {
        updatePageField($id, 'pubDate', date('r'));
    }
    // update pub date
    return $status;
}
function MOH_Files_ListGroup()
{
    global $mysqli;
    $session =& $_SESSION['MOH_Files_ListGroup'];
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $errors = array();
    // Init message (Message)
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    if ($_REQUEST['PK_Group']) {
        $selectedGroup = $_REQUEST['PK_Group'];
    } else {
        header("Location: /admin/MOH_Files_List.php");
        exit;
    }
    if ($_REQUEST['submit']) {
        $selectedPKFiles = $_REQUEST['Files'];
        if (is_array($selectedPKFiles)) {
            $move_PK_Group = $_REQUEST['move_group'];
            $copy_PK_Group = $_REQUEST['copy_group'];
            $submit = $_REQUEST['submit'];
            switch ($submit) {
                case 'delete':
                    foreach ($selectedPKFiles as $PK_File) {
                        $errors = delete_file($PK_File);
                    }
                    break;
                case 'move':
                    foreach ($selectedPKFiles as $PK_File) {
                        $errors = move_file($PK_File, $move_PK_Group);
                    }
                    break;
                case 'copy':
                    foreach ($selectedPKFiles as $PK_File) {
                        $errors = copy_file($PK_File, $copy_PK_Group);
                    }
                    break;
            }
            if (count($errors) == 0) {
                $Message = strtoupper($submit) . "_SUCCESSFULLY";
            }
        } else {
            $errors['EmptySelection'] = true;
        }
    }
    // Init sort order (Order)
    $Order = 'asc';
    $session['Order'] = $Order;
    // Init sort field (Sort)
    $Sort = 'Order';
    $session['Sort'] = $Sort;
    // Init files list (Files)
    $Files = array();
    $query = "\n\t\tSELECT\n\t\t\tPK_File               AS `_PK_`, \n\t\t\tFilename              AS `Filename`, \n\t\t\tFileext               AS `Fileext`, \n\t\t\t`Order`               AS `Order`, \t\t\t\n\t\t\tMoh_Files.DateCreated AS `DateCreated`,\n\t\t\tMoh_Groups.Name       AS `Group`,\n\t\t\tMoh_Groups.PK_Group   AS `_PK_Group_`\n\t\tFROM\n\t\t\tMoh_Files \n\t\t\tINNER JOIN Moh_Groups ON FK_Group = PK_Group\n\t\tWHERE\n\t\t\tFK_Group={$selectedGroup}\n\t\tORDER BY \n\t\t\t`{$Sort}` {$Order}\n\t";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Files[] = $row;
    }
    // Init available groups (Groups)
    $query = "SELECT * FROM Moh_Groups ORDER BY Name";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Groups[] = $row;
    }
    $smarty->assign('selectedGroup', $selectedGroup);
    $smarty->assign('Errors', $errors);
    $smarty->assign('Link', '/admin/MOH_Files_ListGroup.php?PK_Group=' . $_REQUEST['PK_Group']);
    $smarty->assign('Files', $Files);
    $smarty->assign('Groups', $Groups);
    $smarty->assign('Sort', $Sort);
    $smarty->assign('Order', $Order);
    $smarty->assign('Message', $Message);
    $smarty->assign('Hilight', isset($_REQUEST['hilight']) ? $_REQUEST['hilight'] : "");
    return $smarty->fetch('MOH_Files_ListGroup.tpl');
}
示例#4
0
									  `url_spanish`=".$db->sql($_POST['link_spanish']).",
									  `description_english`=".$db->sql($_POST['description_english']).",
									  `description_spanish`=".$db->sql($_POST['description_spanish']).",
									  `icon`=".$db->sql($_POST['icon']).",
									  `weight`=".$db->sql($_POST['weight']).",
									  `time`=".time()." WHERE `id`=".$db->sql($_POST['id']));
	
		if ($db->num_rows()) {
			if (file_exists($_FILES['file_english']['tmp_name'])) {
				if (!move_file($_FILES['file_english']['tmp_name'], $_FILES['file_english']['name'], $config['dir_article'], 'article', 'url_english', $_POST['id'])) {
					$possible_error = true;
				}
			}
						
			if (file_exists($_FILES['file_spanish']['tmp_name'])) {
				if (!move_file($_FILES['file_spanish']['tmp_name'], $_FILES['file_spanish']['name'], $config['dir_article'], 'article', 'url_spanish', $_POST['id'])) {
					$possible_error = true;
				}
			}
			
			if ($possible_error) {
				message($phrase['success_mixed']);
			}
			else {
				message($phrase['success_edit'], MESSAGE_SUCCESS);
			}
		}
		else {
			message($phrase['error_edit'], MESSAGE_ERROR);
		} 
	}
示例#5
0
/**
* Move directory
*
* @param $path
*	...
*
* @param $newLocation
*	...
*
* @return
*	...
*/
function move_dir($path, $newLocation)
{
    $path = suffix($path, '/');
    // Make sure we can work with the directory
    if (is_dir($path) and is_writable($path)) {
        $newLocation = suffix($newLocation, '/');
        // Create the new directory if it doesn't exist yet
        if (!is_dir($newLocation)) {
            if (!mkdir($newLocation, 0777, true)) {
                return false;
            }
        }
        // Move files individually
        foreach (rglob_files($path) as $filepath) {
            move_file($filepath, pathinfo($newLocation . unprefix($filepath, $path), PATHINFO_DIRNAME));
        }
        // Remove previous, now empty directories
        remove_dir($path);
        return true;
    }
    return false;
}
/**
 * Licensed to The Apereo Foundation under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.
 * The Apereo Foundation licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * 
 * copy to new folder page, the sites moves some items from one folder to another
 *
 * @author Patrick Lockley
 * @version 1.0
 * @package
 */
require_once '../../../config.php';
include '../folder_library.php';
if (isset($_POST['folder_id'])) {
    move_folder($_POST['folder_id'], $_POST['destination']);
} else {
    move_file($_POST['template_id'], $_POST['destination']);
}
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'setting.php';
$clean = filter_input_array(INPUT_GET, array('CKEditorFuncNum' => FILTER_VALIDATE_INT));
$clean['upload'] = check_file($_FILES['upload']);
move_file($clean['upload'], 'ckeditor', $_SESSION['USER_ID']);
if (class_exists("Imagick")) {
    /*** the image file ***/
    $image = UPLOAD_DIRECTORY . '/ckeditor/' . $_SESSION['USER_ID'] . '/' . $clean['upload']['name'];
    /*** a new imagick object ***/
    $im = new Imagick();
    /*** ping the image ***/
    $im->pingImage($image);
    /*** read the image into the object ***/
    $im->readImage($image);
    /*** thumbnail the image ***/
    $im->resizeImage(760, 0, Imagick::FILTER_LANCZOS, 1);
    /*** Write the thumbnail to disk ***/
    $im->writeImage();
    /*** Free resources associated with the Imagick object ***/
    $im->destroy();
    echo UPLOAD_DIRECTORY . '/ckeditor/' . $_SESSION['USER_ID'] . '/' . $clean['upload']['name'];
} else {
    echo '2';
}
// require WEBROOT_DIRECTORY . DIRECTORY_SEPARATOR . 'phpThumb' . DIRECTORY_SEPARATOR . 'phpThumb.config.php';
$url = '/uploads/ckeditor/' . $_SESSION['USER_ID'] . '/' . $clean['upload']['name'];
echo '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $clean['CKEditorFuncNum'] . ',"' . $url . '","업로드 완료")</script>';
示例#8
0
        }
    }
}
$output = '';
foreach ($config->sorter->sources->directory as $thisSource) {
    writelog($thisSource . ' überprüfen…', INFO);
    if ($handle = opendir($thisSource)) {
        while (false !== ($file = readdir($handle))) {
            $fullfile = $thisSource . '/' . $file;
            if (!is_dir($fullfile) && $file != '.' && $file != '..' && substr($file, 0, 1) != '.') {
                // Wenn Datei vor weniger als 20 Minuten modifiziert wurde, dann ueberspringen
                if (fileatime($fullfile) >= mktime() - $config->sorter->gracetime->attributes()->minutes * 60) {
                    if (NOW) {
                        $ETA = fileatime($fullfile) - (mktime() - $config->sorter->gracetime->attributes()->minutes * 60);
                        $ETA /= 60;
                        $ETA = round($ETA);
                        writelog("DELAYED ({$ETA} mins): {$fullfile}", INFO);
                    } else {
                        continue;
                    }
                }
                $output .= move_file($file, $thisSource);
            }
        }
        closedir($handle);
    }
}
//echo $output;
if ($output) {
    `growlnotify -t "Filme aufgeräumt" -m "{$output}" -I ~/Movies/`;
}
<?php

/**
 * 
 * copy to new folder page, the sites moves some items from one folder to another
 *
 * @author Patrick Lockley
 * @version 1.0
 * @copyright Copyright (c) 2008,2009 University of Nottingham
 * @package
 */
require_once '../../../config.php';
include '../folder_library.php';
move_file(mysql_real_escape_string($_POST['files']), mysql_real_escape_string($_POST['destination']));
fclose($t);
fclose($s);
/*
 * 郵便番号辞書(事業所)を出力する。
 */
$s = fopen(PATH_CSV . "/" . FIRM_OUT, "rb");
$t = fopen(PATH_TMP_IME_FIRM, "ab");
while ($cols = fgetcsv($s, 1024, ",")) {
    if (!isset($x0402[$cols[1]])) {
        continue;
    }
    fwrite($t, mb_convert_encoding(mb_convert_kana(substr($cols[0], 0, 3) . "-" . substr($cols[0], 3, 7) . "\t" . $x0401[substr($cols[1], 0, 2)] . $x0402[$cols[1]] . $cols[2] . $cols[3] . $cols[4] . "\t地名その他\r\n", "A", "UTF-8"), "Windows-31J", "UTF-8"));
}
fclose($t);
fclose($s);
move_data(PATH_TMP_IME_AREA, PATH_IME . "/" . date("YmdHis", filemtime(PATH_TMP_IME_AREA)) . PATH_IME_AREA);
move_data(PATH_TMP_IME_FIRM, PATH_IME . "/" . date("YmdHis", filemtime(PATH_TMP_IME_FIRM)) . PATH_IME_FIRM);
// 目次ページを更新する。
$tmp = PATH_TMP_IME . "/index.html";
$trg = PATH_IME . "/index.html";
$t = fopen($tmp, "wb");
eval(preg_replace(HTML_BEGIN, 'fwrite(\\$t, <<<EOP', preg_replace(HTML_END, "\nEOP\n);", IME_INDEX)));
fclose($t);
move_file($tmp, $trg);
log_info("Updated  : {$trg}");
rmdirs(array(PATH_TMP_IME));
/*
 * 処理完了
 */
log_info("End.");
exit(0);
/**
 * ワークデータを所定のディレクトリに移動する。
 */
function move_data($src, $trg)
{
    if (is_dir($trg)) {
        move_file($trg, "{$trg}_bak");
    }
    move_file($src, $trg);
    rmdirs(array("{$trg}_bak"));
    return true;
}
示例#12
0
									  `title_spanish`=".$db->sql($_POST['title_spanish']).",
									  `uri_english`=".$db->sql($_POST['uri_english']).",
									  `uri_spanish`=".$db->sql($_POST['uri_spanish']).",
									  `content_english`=".$db->sql($_POST['content_english']).",
									  `content_spanish`=".$db->sql($_POST['content_spanish']).",
									  `file`=".$db->sql($_POST['file']).",
									  `meta_english`=".($_POST['default_english'] != 1 ? $db->sql($_POST['meta_english']) : 'NULL').",
									  `meta_spanish`=".($_POST['default_spanish'] != 1 ? $db->sql($_POST['meta_spanish']) : 'NULL').",
									  `weight`=".($_POST['weight'] != "" ? $db->sql($_POST['weight']) : 'NULL').",
									  `banner`=".($_POST['banner_select'] != "" ? $db->sql($_POST['banner_select']) : 'NULL').",
									  `time`=".time()." WHERE `id`=".$db->sql($_POST['id']));
	
		if ($db->num_rows()) {
			if ($_POST['banner_select'] == "" && file_exists($_FILES['banner']['tmp_name'])) {
				$logger->log("going to attempt to move the file");
				if (move_file($_FILES['banner']['tmp_name'], $_FILES['banner']['name'], $config['dir_banner'], 'page', 'banner', $_POST['id'])) {
					message($phrase['success_edit'], MESSAGE_SUCCESS);
				}
				else {
					message($phrase['success_mixed']);
				}
			}
			else {
				message($phrase['success_edit'], MESSAGE_SUCCESS);
			}
		}
		else {
			message($phrase['error_edit'], MESSAGE_ERROR);
		} 
	}
}
示例#13
0
for ($i = 0; $i < $n; $i++) {
	if ($config['media_type'][$i] == $ext) {
		$type = $i;
	}
}

if ($type < 0) {
	echo "error: ".$ext;
	exit;
}

$db->query("INSERT INTO `media` (`name`,`type`,`time`,`x`,`y`) VALUES (".$db->sql($name).",".$db->sql($type).",".time().",".$db->sql($_POST['width']).",".$db->sql($_POST['height']).")");

if (($id = $db->insert_id()) > 0) {
	if (move_file($_FILES['Filedata']['tmp_name'], $_FILES['Filedata']['name'], $config['dir_media'], 'media', 'url', $id)) {
		
		if ($config['image_type'][$type]) {
			$media = $db->query_first("SELECT * FROM `media` WHERE `id`=".$id);
		
			$image = new Image($config['dir_media'].$media['url']);
			$image->resize($config['size_thumb']);
			$image->save($config['dir_media_thumb'].$media['url']);
		
			$db->query("UPDATE `media` SET `x`=".$db->sql($image->getX()).", `y`=".$db->sql($image->getY()).", `thumb`=".$db->sql($media['url'])." WHERE `id`=".$db->sql($media['id']));
			
			if ($db->num_rows() == 0) {
				echo "error3";
			}
		}
		
示例#14
0
/**
 * 履歴データの目次ページを更新する。
 */
function update_arc_index()
{
    $tmp = PATH_TMP . "/index.html";
    $trg = PATH_ARC . "/index.html";
    $t = fopen($tmp, "wb");
    eval(preg_replace(HTML_BEGIN, 'fwrite(\\$t, <<<EOP', preg_replace(HTML_END, "\nEOP\n);", ARC_INDEX)));
    fclose($t);
    move_file($tmp, $trg);
    log_info("Updated  : {$trg}");
    return true;
}