function check_dir($dir)
{
    global $tocheck, $exitabnormal;
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                if ($file == '.' or $file == '..' or $file == 'CVS') {
                    continue;
                }
                if (is_dir($dir . '/' . $file . '/')) {
                    check_dir($dir . '/' . $file . '/');
                } else {
                    if (in_array(strrchr($file, '.'), $tocheck)) {
                        $phpout = "";
                        exec("/usr/bin/env php -l {$dir}/{$file} 2>&1", $phpout);
                        if (!stristr($phpout[0], "No syntax errors detected in")) {
                            $exitabnormal = true;
                            print "{$dir}{$file}\n-----";
                            foreach ($phpout as $errline) {
                                print "{$errline}\n";
                            }
                            print "\n";
                        }
                    }
                }
            }
        }
    }
    return;
}
Exemple #2
0
function is_writeable_dir($path)
{
    $patharray = explode("/", $path);
    array_shift($patharray);
    $path = "themes";
    foreach ($patharray as $child) {
        if (!file_exists($path . "/" . $child)) {
            break;
        }
        $path = $path . "/" . $child;
    }
    return check_dir($path);
}
Exemple #3
0
function check_dir($id)
{
    $dir = $GLOBALS['db']->select("dir", ['id' => $id]);
    if ($dir[0]["recycle"] == "1" || $dir[0]["share"] == "0") {
        return false;
    }
    if ($dir[0]["parent"] != "0") {
        $updir = $GLOBALS['db']->select("dir", ['id' => $dir[0]["parent"]]);
        if ($updir[0]["recycle"] == "1" || $updir[0]["share"] == "0") {
            return false;
        } else {
            return check_dir($updir[0]["id"]);
        }
    } else {
        return true;
    }
}
 public function item_edit()
 {
     $this->load->library('form_validation');
     $this->load->model('db_model');
     $this->load->model('tags_model');
     $this->load->helper('directory');
     $item = json_decode(file_get_contents('php://input'), true);
     $_POST = $item;
     $this->db_model->set_validation_rules('portfolio_categories', $_POST['id']);
     $errors = array();
     if (!$this->form_validation->run()) {
         $this->form_validation->set_error_delimiters('', '');
         $errors = $this->form_validation->error_array();
         $message = "Le formulaire contiend des erreurs";
     } else {
         // on créé si l'élément n'a pas d'id
         if (!array_key_exists('id', $item)) {
             $_POST['id'] = $this->portfolio_model->PortfolioCreate($_POST);
             // on déplace le thumb dans le bon répertoire
             if (file_exists(APPPATH . 'assets/images/portfolio/new/thumbs/' . $_POST['src'])) {
                 $dossier = check_dir(APPPATH . 'assets/images/portfolio/' . $_POST['id'] . '/thumbs/');
                 rename(APPPATH . 'assets/images/portfolio/new/thumbs/' . $_POST['src'], $dossier . $_POST['src']);
             }
         } else {
             $this->portfolio_model->PortfolioUpdate($_POST);
         }
         try {
             foreach ($this->lang->languages as $lang) {
                 $this->tags_model->save_meta($_POST['meta_keywords_' . $lang], $_POST['id'], 'portfolio_item_' . $lang, 'meta_keyword');
             }
         } catch (Exception $e) {
         }
         $message = "Portfolio enregitrée avec succès !";
         $this->cache_manager->DeletePagesCache();
         $this->cache_manager->DeleteDbCache();
     }
     $output = array('id' => $_POST['id'], 'error' => count($errors), 'errors' => $errors, 'message' => $message);
     $this->output->set_output($output);
     // on supprime le cache
     //delete_files(APPPATH.'cache/');
 }
Exemple #5
0
}
if (@$save) {
    $public = (int) @$public;
    $name = escape_string(from_form(@$name));
    $url = escape_string(from_form(@$url));
    $text = escape_string(from_form(@$text));
    $ord = (int) @$ord;
    $tour = (int) @$tour;
    $dir = escape_string(from_form(@$dir));
    $object_id = (int) @$object_id;
    $sql = mysql_query("SELECT ord, dir FROM " . TABLE_HOTEL . " WHERE hotel_id={$hotel_id}") or Error(1, __FILE__, __LINE__);
    $arr = @mysql_fetch_array($sql);
    $oldord = (int) @$arr[0];
    $olddir = @$arr[1];
    if ($dir != $olddir) {
        $dir = check_dir($dir, $olddir);
    }
    mysql_query("UPDATE " . TABLE_HOTEL . " SET public='{$public}', ord='{$ord}', name='{$name}', dir='{$dir}', url='{$url}', \n\t\t\t\ttext='{$text}', object_id='{$object_id}', tour='{$tour}'" . " WHERE hotel_id='{$hotel_id}'") or Error(1, __FILE__, __LINE__);
    if ($ord > $oldord) {
        mysql_query("UPDATE " . TABLE_HOTEL . " SET ord=ord-1 " . "WHERE ord>'{$oldord}' AND ord<='{$ord}' AND hotel_id!='{$hotel_id}'") or Error(1, __FILE__, __LINE__);
    } elseif ($ord < $oldord) {
        mysql_query("UPDATE " . TABLE_HOTEL . " SET ord=ord+1 " . "WHERE ord>='{$ord}' AND ord<'{$oldord}' AND hotel_id!='{$hotel_id}'") or Error(1, __FILE__, __LINE__);
    }
    $url = ADMIN_URL . "?p={$part}&hotel_id={$hotel_id}";
    Header("Location: " . $url);
    exit;
}
if (@$addsuite) {
    $hotel_id = (int) $addsuite;
    $sql = mysql_query("SELECT COUNT(*) FROM " . TABLE_SUITE . " WHERE hotel_id={$hotel_id}") or Error(1, __FILE__, __LINE__);
    $arr = @mysql_fetch_array($sql);
Exemple #6
0
Cron is intended to process the xml feed of new releases from Spotify and get the data into the database.
This should take care of all the heavy lifting and scheduled processing, so index.php only has to work on display.
*/
error_reporting(E_ALL);
include_once '../config.php';
date_default_timezone_set('UTC');
$database = new Database();
$baseDir = dirname(realpath('./'));
$spotifyCountries = loadCountryCodesMap($baseDir . '/ISO-3166-1-alpha-2-country-codes-spotify.tsv');
function spotifyCountriesFilter($v)
{
    global $spotifyCountries;
    return isset($spotifyCountries[strtoupper($v)]);
}
$date = date('Y-m-d');
$cachePath = check_dir($baseDir . '/cache/');
if (!$cachePath) {
    echo "Could not create cache directory";
    die;
}
$cachePath .= $date;
$albums = array();
$vaAlbums = array();
$fetchPageLimit = 5;
$totalResults = $startIndex = $itemsPerPage = 0;
function loadCountryCodesMap($path)
{
    $map = array();
    $buf = file_get_contents($path);
    $buf = explode("\n", $buf);
    foreach ($buf as $line) {
function upload_file($temp_file, $file_name, $dir)
{
    global $cfg_upload_file;
    $tmp_name = time();
    $return = "";
    if ($temp_file != "") {
        if (check_dir($dir)) {
            $type = getFileType($file_name);
            if (checkFileType($file_name)) {
                $file_path = "{$dir}/{$tmp_name}.{$type}";
                $copy_result = @copy($temp_file, "{$file_path}");
                $return = $tmp_name . "." . $type;
            }
        }
    }
    return $return;
}
Exemple #8
0
Updates the ICU resources in Symfony2 from the given ICU data directory. You
can checkout the ICU data directory via SVN:

    \$ svn co http://source.icu-project.org/repos/icu/icu/trunk/source/data icu-data

MESSAGE
);
}
// Verify that all required directories exist
$source = $GLOBALS['argv'][1];
check_dir($source);
$source = realpath($source);
check_dir($source . DIRECTORY_SEPARATOR . 'curr');
check_dir($source . DIRECTORY_SEPARATOR . 'lang');
check_dir($source . DIRECTORY_SEPARATOR . 'locales');
check_dir($source . DIRECTORY_SEPARATOR . 'region');
check_command('genrb');
// Convert the *.txt resource bundles to *.res files
$target = __DIR__;
$currDir = $target . DIRECTORY_SEPARATOR . 'curr';
$langDir = $target . DIRECTORY_SEPARATOR . 'lang';
$localesDir = $target . DIRECTORY_SEPARATOR . 'locales';
$namesDir = $target . DIRECTORY_SEPARATOR . 'names';
$namesGeneratedDir = $namesDir . DIRECTORY_SEPARATOR . 'generated';
$regionDir = $target . DIRECTORY_SEPARATOR . 'region';
make_directory($currDir);
clear_directory($currDir);
genrb_file($currDir, $source . DIRECTORY_SEPARATOR . 'curr', 'en');
genrb_file($currDir, $source . DIRECTORY_SEPARATOR . 'curr', 'supplementalData');
// It seems \ResourceBundle does not like locale names with uppercase chars then we rename the binary file
// See: http://bugs.php.net/bug.php?id=54025
Exemple #9
0
 * along with WEIPDCRM.  If not, see <http://www.gnu.org/licenses/>.
 */
header('Content-Type: text/html; charset=utf-8');
define("DCRM", true);
error_reporting(E_ALL ^ E_WARNING);
require_once 'function.php';
$header_title = __('Installer');
// 检查数据库配置文件
if (!file_exists(CONF_PATH . 'connect.inc.php')) {
    header('location: setup-config.php?' . $step_language);
    exit;
}
// 检查环境
$disabled = true;
$env_vars = check_env($disabled);
$dir_file_vars = check_dir($disabled);
$func_vars = check_func($disabled);
$notice = check_notice(true);
$step = isset($_GET['step']) ? $_GET['step'] : 0;
require_once CONF_PATH . 'connect.inc.php';
// Test Connect
$con = mysql_connect(DCRM_CON_SERVER . ':' . (defined("DCRM_CON_SERVER_PORT") ? DCRM_CON_SERVER_PORT : '3306'), DCRM_CON_USERNAME, DCRM_CON_PASSWORD);
if (!$con) {
    $inst_alert = mysql_error();
    _e('<strong>ERROR</strong>: Can&#8217;t connect database server.') . '<br/>' . $inst_alert;
    exit;
}
// Make sure DCRM is not already installed.
// Check installed.lock file.
if (!defined("DEVELOP_ENABLED")) {
    if (file_exists(CONF_PATH . 'installed.lock')) {
Exemple #10
0
 /**
  * 根据不同模式存放不同的日志
  * @param int type 例如:sale,pay...
  */
 public static function record_log($info, $type = NULL)
 {
     $type = $type ? $type : 'debug';
     check_dir(RUNTIME_PATH . 'Logs/' . $type);
     file_put_contents(RUNTIME_PATH . 'Logs/' . $type . '/' . '' . $type . '_' . date('Ymd') . '.log', "[" . date('H:i:s') . "] " . $info . "\n", FILE_APPEND);
 }
function upload_rssfile($temp_file, $dir, $type)
{
    $tmp_name = time();
    $return = "";
    if ($temp_file != "") {
        if (check_dir($dir)) {
            $return = $tmp_name . "." . $type;
            $file_path = "{$dir}/{$return}";
            $copy_result = copy($temp_file, "{$file_path}");
        }
    }
    return $return;
}
function upload_file($temp_file, $file_name, $dir, $tmp_name = "")
{
    if (empty($tmp_name)) {
        $tmp_name = validCode(10);
    }
    $return = "";
    if ($temp_file != "") {
        if (check_dir($dir)) {
            $type = getFileType($file_name);
            if (checkFileType($file_name)) {
                $file_path = "{$dir}/{$tmp_name}.{$type}";
                //$copy_result=copy($temp_file,"$file_path");
                if (@copy($temp_file, $file_path) || function_exists('move_uploaded_file') && @move_uploaded_file($temp_file, $file_path)) {
                    @unlink($temp_file);
                    $check_info = true;
                }
                if (!$check_info && is_readable($temp_file)) {
                    $attachedfile = readfromfile($temp_file);
                    $fp = @fopen($file_path, 'wb');
                    @flock($fp, 2);
                    if (@fwrite($fp, $attachedfile)) {
                        @unlink($temp_file);
                        $check_info = true;
                    }
                    @fclose($fp);
                }
                $return = $check_info ? $tmp_name . "." . $type : "";
            }
        }
    }
    return $return;
}
 public function crop_image()
 {
     //$item = $_POST;
     $item = json_decode(file_get_contents('php://input'));
     $item = get_object_vars($item);
     // on vérifier que le dossier existe
     $dossier = check_dir(APPPATH . $item['folder']);
     $config['image_library'] = 'gd2';
     $config['source_image'] = APPPATH . $item['src'];
     $config['new_image'] = APPPATH . $item['newSrc'];
     $config['maintain_ratio'] = FALSE;
     $config['x_axis'] = $item['x'];
     $config['y_axis'] = $item['y'];
     $config['width'] = $item['w'];
     $config['height'] = $item['h'];
     $confif['quality'] = 100;
     $this->load->library('image_lib', $config);
     $this->image_lib->crop();
     $this->image_lib->clear();
     $config['width'] = $item['maxW'];
     $config['height'] = $item['maxH'];
     $config['x_axis'] = 0;
     $config['y_axis'] = 0;
     $confif['quality'] = 80;
     $config['maintain_ratio'] = TRUE;
     $config['source_image'] = APPPATH . $item['newSrc'];
     $config['new_image'] = APPPATH . $item['newSrc'];
     $this->image_lib->initialize($config);
     $this->image_lib->resize();
     $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
     $this->output->set_output(json_encode($item));
 }
        $fileHeight = intval($_POST['fileHeight']);
        $fileSize = intval($_POST['fileSize']);
        $fileTitle = encode($_POST['fileTitle']);
        $fileType = getFileType($fileName);
        $fileTitle = $fileTitle . "." . $fileType;
        $fileType = convertFileType($fileType);
        $sql = "update " . $DBPrefix . "attachments set name='{$fileName}',attTitle='{$fileTitle}',fileWidth='{$fileWidth}',fileHeight='{$fileHeight}',fileSize='{$fileSize}',fileType='{$fileType}',postTime='" . time() . "' where id='" . $file_id . "'";
        $DMC->query($sql);
        //echo $sql;
    }
}
//保存文件夹
if ($action == "savefolder") {
    $foldername = $_POST['myfolder'];
    if (check_fileName($foldername)) {
        if (!check_dir($basedir . $foldername)) {
            $ActionMessage = "{$strAttachmentNoFolder}";
            $action = "addfolder";
        }
    } else {
        $ActionMessage = "{$strAttachmentErrorFolder}";
        $action = "addfolder";
    }
}
//其它操作行为:编辑、删除等
if ($action == "operation") {
    $stritem = "";
    $itemlist = empty($_POST['itemlist']) ? array() : $_POST['itemlist'];
    if ($_POST['operation'] == "delete") {
        $Error_Message = "";
        for ($i = 0; $i < count($itemlist); $i++) {
Exemple #15
0
            if ($length > $longest) {
                $longest = $length;
            }
        }
    }
    sort($functions);
    $functions = array_unique($functions);
}
// parse_funclist() function end
/*********************************************************************/
/* Here starts the program                                           */
/*********************************************************************/
// Start with searching header
echo "Searching in {$docdir} for XML files...\n";
// Check the requested directory
check_dir("{$docdir}/", $func_documented);
// Process $funclist for PHP functions
parse_funclist($funclist, $longest, $func_in_php);
if ($argv[1] == "missing") {
    $undocumented = array_diff($func_in_php, array_keys($func_documented));
    echo "Functions in PHP source but not in documentation:\n\n";
    foreach ($undocumented as $func) {
        echo $func . "\n";
    }
} else {
    printf("%-{$longest}s    %s\n", "FUNCTION NAME", "DOCUMENTED IN");
    printf("%'-70s\n", '');
    foreach ($func_in_php as $function) {
        printf("%-{$longest}s    %s\n", $function, $func_documented[$function]);
    }
    $n_functions = count($func_in_php);
 $dir = $exportdir . $user['login'];
 $ret = check_dir($dir, true, true, 0755);
 if (!$ret) {
     $errorstring = "Error creating export directory\n<br>\n" . "Name: " . $dir . "\n<br>\n" . "\n<br>\n";
     die($errorstring);
 }
 $time = time();
 $date = date("Y-m-d - H-i-s", $time);
 $dir = $exportdir . $user['login'] . DIRECTORY_SEPARATOR . $date;
 $ret = check_dir($dir, true, true, 0755);
 if (!$ret) {
     $errorstring = "Error creating export directory\n<br>\n" . "Name: " . $dir . "\n<br>\n" . "\n<br>\n";
     die($errorstring);
 }
 $dir = $exportdir . $user['login'] . DIRECTORY_SEPARATOR . $date . DIRECTORY_SEPARATOR . 'xml';
 $ret = check_dir($dir, true, true, 0755);
 if (!$ret) {
     $errorstring = "Error creating export directory\n<br>\n" . "Name: " . $dir . "\n<br>\n" . "\n<br>\n";
     die($errorstring);
 }
 $dir = $exportdir . $user['login'] . DIRECTORY_SEPARATOR . $date . DIRECTORY_SEPARATOR . 'images';
 $ret = mkdir($dir, 0755);
 if (!$ret) {
     $errorstring = "Error creating export directory\n<br>\n" . "Name: " . $dir . "\n<br>\n" . "\n<br>\n";
     die($errorstring);
 }
 $dir = $exportdir . $user['login'] . DIRECTORY_SEPARATOR . $date . DIRECTORY_SEPARATOR . 'thumbnails';
 $ret = mkdir($dir, 0755);
 if (!$ret) {
     $errorstring = "Error creating export directory\n<br>\n" . "Name: " . $dir . "\n<br>\n" . "\n<br>\n";
     die($errorstring);
Exemple #17
0
function check_dir($dir, &$used_tags)
{
    // Collect files and directories in these arrays
    $directories = array();
    $files = array();
    // Open and traverse the directory
    $handle = @opendir($dir);
    while ($file = @readdir($handle)) {
        // Collect directories and XML files
        if ($file != 'CVS' && $file != '.' && $file != '..' && is_dir($dir . $file)) {
            $directories[] = $file;
        } elseif (strstr($file, ".xml")) {
            $files[] = $file;
        }
    }
    @closedir($handle);
    // Sort files and directories
    sort($directories);
    sort($files);
    // Files first...
    foreach ($files as $file) {
        check_file($dir . $file, $used_tags);
    }
    // than the subdirs
    foreach ($directories as $file) {
        check_dir($dir . $file . "/", $used_tags);
    }
}
function smarty_function_group_export($params, &$smarty)
{
    global $db, $db_prefix;
    global $exportdir, $exportdirlong;
    global $user;
    global $zip_binary;
    // print_r($params);
    // $db->debug = true;
    // check parameters
    if (empty($params['id'])) {
        $smarty->trigger_error("assign: missing 'id' parameter");
        return;
    } else {
        $id = $params['id'];
    }
    if (empty($params['name'])) {
        $smarty->trigger_error("assign: missing 'name' parameter");
        return;
    } else {
        $name = $params['name'];
    }
    if (empty($params['subgroups'])) {
        $smarty->trigger_error("assign: missing 'subgroups' parameter");
        return;
    } else {
        if ($params['subgroups'] == 'yes') {
            $subgroups = true;
        } else {
            $subgroups = false;
        }
    }
    if (empty($params['withviewer'])) {
        $smarty->trigger_error("assign: missing 'withviewer' parameter");
        return;
    } else {
        if ($params['withviewer'] == 'yes') {
            $withviewer = true;
        } else {
            $withviewer = false;
        }
    }
    if (empty($params['targetsystem'])) {
        $smarty->trigger_error("assign: missing 'targetsystem' parameter");
        return;
    } else {
        $targetsystem = $params['targetsystem'];
    }
    if (!empty($params['comment'])) {
        $comment = $params['comment'];
    } else {
        $comment = '';
    }
    if (empty($params['result'])) {
        $smarty->trigger_error("assign: missing 'result' parameter");
        return;
    }
    // generate unique filename for this export
    $tmpid = generate_random_string();
    while (file_exists($exportdir . DIRECTORY_SEPARATOR . $user['login'] . DIRECTORY_SEPARATOR . $tmpid . '.zip') || file_exists($exportdir . DIRECTORY_SEPARATOR . $user['login'] . DIRECTORY_SEPARATOR . $tmpid)) {
        $tmpid = generate_random_string();
    }
    // check if export sub-directories already exists and are writeable
    $create_directories = array($user['login'], $user['login'] . DIRECTORY_SEPARATOR . $tmpid, $user['login'] . DIRECTORY_SEPARATOR . $tmpid . DIRECTORY_SEPARATOR . 'xml', $user['login'] . DIRECTORY_SEPARATOR . $tmpid . DIRECTORY_SEPARATOR . 'images', $user['login'] . DIRECTORY_SEPARATOR . $tmpid . DIRECTORY_SEPARATOR . 'thumbnails');
    $ret = true;
    foreach ($create_directories as $dir) {
        $sret = check_dir($exportdir . DIRECTORY_SEPARATOR . $dir, true, true, 0755);
        $ret = $ret & $sret;
    }
    if (!$ret) {
        $result = 'E_CREATE_DIRECTORY';
    } else {
        // if we succeeded in creating the directories, this is our temporary directory
        $tmpdir = $exportdir . $user['login'] . DIRECTORY_SEPARATOR . $tmpid;
        $tmpdirlong = $exportdirlong . $user['login'] . DIRECTORY_SEPARATOR . $tmpid;
        // do we need to copy the viewer skeleton?
        if ($withviewer) {
            $viewerdir = '';
            if ($targetsystem == 'mac') {
                $viewerdir = $dilpsdir . 'viewer' . DIRECTORY_SEPARATOR . 'mac' . DIRECTORY_SEPARATOR;
            } else {
                $viewerdir = $dilpsdir . 'viewer' . DIRECTORY_SEPARATOR . 'windows' . DIRECTORY_SEPARATOR;
            }
            // copy viewer with PHP-functions
            $olddir = getcwd();
            chdir($viewerdir);
            $ret = copy_recursive('.', $tmpdirlong . DIRECTORY_SEPARATOR);
            chdir($olddir);
        }
        if (!$ret) {
            $result = 'E_COPY_VIEWER';
        } else {
            // start reading actual data
            $sql = "SELECT DISTINCT * FROM " . $db_prefix . "img, " . $db_prefix . "img_group, " . $db_prefix . "meta" . " WHERE " . $db_prefix . "img.collectionid = " . $db_prefix . "meta.collectionid" . " AND " . $db_prefix . "img.imageid = " . $db_prefix . "meta.imageid" . " AND " . $db_prefix . "img.collectionid = " . $db_prefix . "img_group.collectionid" . " AND " . $db_prefix . "img.imageid = " . $db_prefix . "img_group.imageid" . get_groupid_where($id, $db, $db_prefix, $subgroups);
            $rs = $db->Execute($sql);
            $xml_ret = true;
            $img_ret = true;
            // we continue, even when there are errors
            while (!$rs->EOF) {
                // print_r($rs->fields);
                $xmlout = "<?" . "xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n";
                $xmlout .= "<imgdata>\n";
                $xmlout .= "<width>" . utf8_encode($rs->fields['width']) . "</width>\n";
                $xmlout .= "<height>" . utf8_encode($rs->fields['height']) . "</height>\n";
                $xmlout .= "<name>" . utf8_encode($rs->fields['name1']) . "</name>\n";
                $xmlout .= "<vorname>" . utf8_encode($rs->fields['name2']) . "</vorname>\n";
                $xmlout .= "<titel>" . utf8_encode($rs->fields['title']) . "</titel>\n";
                $xmlout .= "<datierung>" . utf8_encode($rs->fields['dating']) . "</datierung>\n";
                $xmlout .= "<material>" . utf8_encode($rs->fields['material']) . "</material>\n";
                $xmlout .= "<technik>" . utf8_encode($rs->fields['technique']) . "</technik>\n";
                $xmlout .= "<format>" . utf8_encode($rs->fields['format']) . "</format>\n";
                $xmlout .= "<stadt>" . utf8_encode($rs->fields['location']) . "</stadt>\n";
                $xmlout .= "<institution>" . utf8_encode($rs->fields['institution']) . "</institution>\n";
                $xmlout .= "<literatur>" . utf8_encode($rs->fields['literature']) . "</literatur>\n";
                $xmlout .= "<url>" . utf8_encode("images" . DIRECTORY_SEPARATOR . $rs->fields['filename']) . "</url>\n";
                $xmlout .= "<thumbnail>" . utf8_encode("thumbnail" . DIRECTORY_SEPARATOR . $rs->fields['filename']) . "</thumbnail>\n";
                $xmlout .= "<schlagworte>" . utf8_encode($rs->fields['keyword']) . "</schlagworte>\n";
                $xmlout .= "<quelle>" . utf8_encode($rs->fields['imagerights']) . "</quelle>\n";
                $xmlout .= "<comment>" . utf8_encode($rs->fields['commentary']) . "</comment>\n";
                $xmlout .= "</imgdata>\n";
                // print_r($xmlout);
                $sql2 = "SELECT base FROM " . $db_prefix . "img_base WHERE " . $db_prefix . "img_base.img_baseid = " . $db->qstr($rs->fields['img_baseid']);
                $path = $db->GetOne($sql2);
                $copyfilename = $rs->fields['collectionid'] . "-" . $rs->fields['imageid'] . ".jpg";
                $source = $path . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . '1600x1200' . DIRECTORY_SEPARATOR . $copyfilename;
                $dest = $tmpdir . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $copyfilename;
                $img_sret = @copy($source, $dest);
                /*
                echo ("Source: ".$source."\n<br>\n");
                echo ("Dest: ".$dest."\n<br>\n");
                */
                $source = $path . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . '120x90' . DIRECTORY_SEPARATOR . $copyfilename;
                $dest = $tmpdir . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $copyfilename;
                $thumb_sret = @copy($source, $dest);
                $handle = @fopen($tmpdir . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . $rs->fields['collectionid'] . '-' . $rs->fields['imageid'] . '.xml', 'w');
                if (!$handle) {
                    $xml_sret = false;
                } else {
                    $xml_sret = @fwrite($handle, $xmlout);
                }
                // cleanup
                fclose($handle);
                unset($xmlout);
                flush();
                $img_ret = $img_sret & $thumb_sret & $img_ret;
                $xml_ret = $xml_ret & $xml_sret;
                $rs->MoveNext();
            }
            // create zip archive
            $old = getcwd();
            chdir($exportdirlong . $user['login']);
            $cmd = $zip_binary . ' -9 -r -m  ' . escapeshellarg($tmpid . '.zip') . ' ' . escapeshellarg($tmpid);
            exec($cmd, $result, $ret);
            /*
            echo ("CMD: {$cmd}\n<br>\n");
            echo ("Result:");
            nl2br(print_r($result));
            echo ("\n<br>\n");
            echo ("Ret: {$ret} \n<br>\n");
            */
            if ($ret != 0) {
                $result = 'E_CREATE_ZIP';
            } else {
                chdir($olddir);
                $ret = @chmod($tmpdirlong . '.zip', 0755);
                // echo ("Ret: {$ret} \n<br>\n");
                if (!$ret) {
                    $result = 'E_CREATE_ZIP';
                } else {
                    if (insert_export($user['login'], $name, $tmpid . '.zip', $comment)) {
                        $result = 'R_EXPORT_SUCCESSFUL';
                    } else {
                        $result = 'E_ACCESS_DB';
                    }
                }
            }
        }
    }
    // if something went wrong, clean up a little bit
    if (file_exists($tmpdirlong)) {
        @delete_recursive($tmpdirlong);
    }
    $smarty->assign($params['result'], $result);
    if (!empty($params['sql'])) {
        $smarty->assign($params['sql'], $sql);
    }
}
 public function news_edit()
 {
     $this->load->library('form_validation');
     $this->load->model('db_model');
     $this->load->model('tags_model');
     $this->load->helper('directory');
     $_POST = $item = json_decode(file_get_contents('php://input'), true);
     $this->db_model->set_validation_rules('news_items', $item['id']);
     $errors = array();
     if (!$this->form_validation->run()) {
         $this->form_validation->set_error_delimiters('', '');
         $errors = $this->form_validation->error_array();
         $message = "Le formulaire contient des erreurs";
     } else {
         if (!array_key_exists('id', $item)) {
             $output['id'] = $this->news_model->item_create($item);
             $_POST['id'] = $output['id'];
             // on déplace le thumb dans le bon répertoire
             if (file_exists(APPPATH . 'assets/images/news/new/thumbs/' . $_POST['src'])) {
                 $dossier = check_dir(APPPATH . 'assets/images/news/' . $_POST['id'] . '/thumbs/');
                 rename(APPPATH . 'assets/images/news/new/thumbs/' . $_POST['src'], $dossier . $_POST['src']);
             }
         } else {
             $this->news_model->news_update($item);
         }
         try {
             $this->tags_model->save_meta($_POST['meta_keywords'], $_POST['id'], 'news_item', 'meta_keyword');
         } catch (Exception $e) {
         }
         $message = "Modifications enregistrées";
         $this->cache_manager->DeletePagesCache();
         $this->cache_manager->DeleteDbCache();
     }
     $output['error'] = count($errors);
     $output['errors'] = $errors;
     $output['message'] = $message;
     $this->output->set_output($output);
 }
Exemple #20
0
 function check_dir($directory, $level)
 {
     global $virus_detected, $all, $detect_errors_only, $detected_Keyword_in_test_script;
     $indent = '';
     for ($count = 0; $count < $level; $count++) {
         $indent .= TAB;
     }
     $level++;
     $read_dir = opendir($directory);
     // M? thu m?c hi?n t?i
     while ($file = readdir($read_dir)) {
         $filepath = $directory . '/' . $file;
         if ($detect_errors_only && $virus_detected) {
             exit;
         }
         if (is_dir($filepath)) {
             // Thu m?c
             if ($file != '.' && $file != '..') {
                 check_dir($filepath, $level);
             }
         } else {
             if (is_file($filepath)) {
                 // T?p
                 if (is_readable($filepath) && !stristr(IGNORE_EXTENSIONS, findexts($file))) {
                     if (filesize($filepath) < MAX_SIZE && filemtime($filepath) > IGNORE_BEFORE) {
                         $fileentry = $directory . '/' . $file . ' - ' . date('j F Y H:i', filemtime($filepath));
                         $filestring = file_get_contents($filepath);
                         $found = stripos($filestring, Keyword);
                         // PHP 5 ONLY
                         $found = stristr($filestring, Keyword);
                         flush();
                         if ($found == false) {
                             if (!$detect_errors_only && !$all) {
                                 echo $filepath . '  <font color=#FFFFFF>OK</font><br/>';
                             }
                         } else {
                             if ($file == 'scan_file.php') {
                                 $detected_Keyword_in_test_script = true;
                             } else {
                                 $virus_detected = true;
                                 if ($detect_errors_only) {
                                     echo '<b style="color:#F00">T?p tin d? ngh? phát hi?n</b><br/>';
                                 } else {
                                     echo TAB . '<b style="color:#F00">' . $fileentry . '</b> - <b style="color:#FFFFF0">Phát hi?n</b><br/>';
                                 }
                             }
                         }
                         $found = '';
                     } else {
                         if (!$detect_errors_only && !$all) {
                             echo $filepath . '  <b style="color:yellow">NOT CHECKED - File quá l?n</b><br/>';
                         }
                     }
                 } else {
                     if (!$detect_errors_only && !$all) {
                         echo $filepath . '  <b style="color:yellow">NOT CHECKED - Không thu?c ki?u tìm ki?m</b><br/>';
                     }
                 }
             } else {
             }
         }
     }
     closedir($read_dir);
 }
 // check if we already have a cache directory structure, otherwise create
 $ret = check_dir($output_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, true, true, 0755);
 if (!$ret) {
     $errorstring = "Output directory cache does not exist or is not writable! \n<br>\n";
     die($errorstring);
 }
 // get new id for filename
 $sql = "SELECT max(imageid)+1 FROM " . $db_prefix . "img";
 $newid = $db->GetOne($sql);
 if (!$newid) {
     $newid = 1;
 }
 // iterate through all available resolutions and check whether the target directory exists
 // if yes, move the corresponding file, otherwise abort.
 foreach ($resolutions as $res) {
     $ret = check_dir($output_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $res, true, true, 0755);
     // check if cache subdirectories exist
     if (!$ret) {
         $errorstring = "Error creating directory for resolution " . $res . "\n<br>\n";
         $errorstring .= "or directory exists and is not writable\n<br>\n";
         die($errorstring);
     }
     $tmp_filename = $tmpdir . 'cache' . DIRECTORY_SEPARATOR . $res . DIRECTORY_SEPARATOR . $tmpid . '.jpg';
     $output_filename = $output_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $res . DIRECTORY_SEPARATOR . $query['collectionid'] . '-' . $newid . '.jpg';
     $ret = @copy($tmp_filename, $output_filename);
     if ($ret) {
         echo "Writing (" . $res . ")\t\t\t: success\n<br>\n";
         $convert_success = true;
     } else {
         echo "Writing (" . $res . ")\t\t\t: failed\n<br>\n";
         echo "Aborting...\n<br>\n";
Exemple #22
0
function check_dir($dir, &$defined_entities, $entity_regexp)
{
    // Collect files and diretcories in these arrays
    $directories = array();
    $files = array();
    // Skip old and unused functions directories (theoretically
    // it should only be in the English tree, but we are smart
    // and check for other language trees too...)
    if (preg_match("!/([a-z]{2}|pt_BR)/functions!", $dir)) {
        return;
    }
    // Open and traverse the directory
    $handle = @opendir($dir);
    while ($file = @readdir($handle)) {
        // Collect directories and XML files
        if ($file != 'CVS' && $file != '.' && $file != '..' && is_dir($dir . $file)) {
            $directories[] = $file;
        } elseif (strstr($file, ".xml")) {
            $files[] = $file;
        }
    }
    @closedir($handle);
    // Sort files and directories
    sort($directories);
    sort($files);
    // Files first...
    foreach ($files as $file) {
        check_file($dir . $file, $defined_entities, $entity_regexp);
    }
    // than the subdirs
    foreach ($directories as $file) {
        check_dir($dir . $file . "/", $defined_entities, $entity_regexp);
    }
}
Exemple #23
0
 /**
  * 用dropzone上传文件
  */
 function dropzoneUploadAndSaveAct()
 {
     $image = $_FILES["file"]["tmp_name"];
     $Fname = $_FILES["file"]["name"];
     $tmparr = explode('.', $Fname);
     $suffix = $tmparr[count($tmparr) - 1];
     $savename = uniqid() . '.' . $suffix;
     $module = $_POST['module'] ? $_POST['module'] : 'other';
     $keyId = $_POST['key_id'];
     $tableName = $_POST['table_name'];
     $updateField = $_POST['update_field'];
     $pkeyField = $_POST['pkey_field'];
     $logoUrlSrc = $_POST['logourl_src'];
     if (!$keyId || !$tableName || !$updateField || !$pkeyField) {
         exit;
     }
     $p = UPLOAD_PATH . '/' . $module . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/';
     if (stripos($logoUrlSrc, __BASE__) !== FALSE) {
         $logoUrlSrc = str_replace(__BASE__, '', $logoUrlSrc);
     }
     if (stripos($logoUrlSrc, __IMG_URL__) !== FALSE) {
         $logoUrlSrc = str_replace(__IMG_URL__, '', $logoUrlSrc);
     }
     $src = APP_ROOT . 'website/' . $logoUrlSrc;
     $whereSql[$pkeyField] = $keyId;
     $isExist = D($tableName)->where($whereSql)->count(1);
     // 判断数据是否存在
     if (!$isExist) {
         // 不存在
         if (file_exists($src)) {
             unlink($src);
         }
         // 存在文件就删除
     } else {
         check_dir($p);
         $paths = $p . $savename;
         $result = move_uploaded_file($image, $paths);
         if ($result) {
             // 上传图片成功
             $uploadUrl = 'data/img/pharmacy/' . $module . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $savename;
             $saveData[$updateField] = $uploadUrl;
             $update_result = D($tableName)->where($whereSql)->save($saveData);
             if ($update_result !== false) {
                 // 更新数据库字段成功
                 if (file_exists($src)) {
                     unlink($src);
                 }
                 // 存在文件就删除
                 echo $uploadUrl;
             }
         }
     }
     exit;
 }
    $icuBinPath .= DIRECTORY_SEPARATOR;
}
check_command($icuBinPath . 'genrb');
$version = normalize_icu_version($version);
$source = download_icu_data($version);
// Verify that all required directories exist
check_dir($source);
check_dir($source . DIRECTORY_SEPARATOR . '.svn');
$source = realpath($source);
// Currency, language and region data are bundled in the locales directory in ICU <= 4.2
if (!is_icu_version_42_or_earlier($version)) {
    check_dir($source . DIRECTORY_SEPARATOR . 'curr');
    check_dir($source . DIRECTORY_SEPARATOR . 'lang');
    check_dir($source . DIRECTORY_SEPARATOR . 'region');
}
check_dir($source . DIRECTORY_SEPARATOR . 'locales');
// Convert the *.txt resource bundles to *.res files
$target = $version;
$target = __DIR__ . DIRECTORY_SEPARATOR . $target;
$currDir = $target . DIRECTORY_SEPARATOR . 'curr';
$langDir = $target . DIRECTORY_SEPARATOR . 'lang';
$localesDir = $target . DIRECTORY_SEPARATOR . 'locales';
$namesDir = $target . DIRECTORY_SEPARATOR . 'names';
$namesGeneratedDir = $namesDir . DIRECTORY_SEPARATOR . 'generated';
$regionDir = $target . DIRECTORY_SEPARATOR . 'region';
make_directory($target);
clear_directory($target);
create_svn_info_file($source, $target);
make_directory($currDir);
clear_directory($currDir);
// Currency data is available at the locales data files in ICU <= 4.2 and the supplementalData file is available at the
Exemple #25
0
function process_image_directory($dir, $query, $debug = false)
{
    global $config;
    global $db, $db_prefix, $user;
    global $resolutions_available;
    global $formats_available;
    global $formats_suffix;
    global $imagemagick_identify;
    global $imagemagick_convert;
    global $file_binary, $zip_binary, $unzip_binary;
    $files = array();
    $remove = array();
    if (!read_recursive($dir, $files, $remove)) {
        echo "Error reading directory structure\n<br>\n";
    } else {
        if (!empty($dir)) {
            $offset = strlen($dir) + 1;
        } else {
            $offset = 0;
        }
        foreach ($files as $num => $val) {
            $files[$num] = substr($val, $offset);
        }
        foreach ($remove as $num => $val) {
            $remove[$num] = substr($val, $offset);
        }
        usort($remove, "cmp");
        if ($debug) {
            echo "Files: \n<br>\n<br>\n";
            foreach ($files as $num => $val) {
                echo "[" . $num . "]: " . $val . "\n<br>\n";
            }
            echo "Remove: \n<br>\n<br>\n";
            foreach ($remove as $num => $val) {
                echo "[" . $num . "]: " . $val . "\n<br>\n";
            }
        }
        echo "Reading directory structure done.\n<br>\n<br>\n";
        foreach ($files as $file) {
            echo "<em>Reading file: " . $file . "</em>\n<br>\n";
            if (!empty($dir)) {
                $filename = $dir . addslashes(DIRECTORY_SEPARATOR . $file);
            } else {
                $filename = $file;
            }
            if (is_file($filename)) {
                $mimetype = '';
                $fileext = '';
                $dotpos = strrpos($filename, '.');
                if (strlen($filename) - $dotpos > 3 && strlen($filename) - $dotpos < 6) {
                    $fileext = strtolower(substr($filename, $dotpos + 1));
                }
                $ret = read_mime($filename, $mimetype, $fileext);
                if (!$ret) {
                    $errorstring = "Error reading image mimetype! \n<br>\n";
                    $errorstring .= "File:" . $filename . "\n<br>\n";
                    echo $errorstring;
                } else {
                    echo "Mimetype: " . $mimetype . "\n<br>\n";
                    if (in_array($mimetype, $formats_available)) {
                        // extract image information
                        // we already have the mimetype
                        $img_data = array();
                        $img_data['mime'] = $mimetype;
                        // try to read the rest
                        $ret = read_image($filename, $img_data);
                        if (!$ret) {
                            $errorstring = "Error reading image information! \n<br>\n";
                            $errorstring .= "File:" . $filename . "\n<br>\n";
                            echo $errorstring;
                        } else {
                            echo "Type:\t\t" . $img_data["type"] . "\n<br>\n";
                            echo "Width:\t\t" . $img_data["width"] . "\n<br>\n";
                            echo "Height:\t\t" . $img_data["height"] . "\n<br>\n";
                            // get output directory
                            $baseid = $query['baseid'];
                            $sql = "SELECT base FROM " . $db_prefix . "img_base WHERE img_baseid=" . $db->qstr($baseid);
                            $output_dir = $db->GetOne($sql);
                            if (empty($output_dir)) {
                                $errorstring = "Error reading output directory! \n<br>\n";
                                $errorstring .= "BaseID: " . $baseid . "\n<br>\n";
                                $errorstring .= "Directory: " . $output_dir . "\n<br>\n";
                                die($errorstring);
                            }
                            // use a temporary directory, where we can store the converted files until we have
                            // completed the task for all resolutions.
                            // we will move files from there into the correct directory later
                            $tmpdir = $config['imageTmp'];
                            if (!is_dir($tmpdir)) {
                                $errorstring = "Could not find temporary directory! \n<br>\n";
                                $errorstring .= "Path: " . $tmpdir . "\n<br>\n";
                                die($errorstring);
                            }
                            // check if we already have a cache directory structure, otherwise create
                            $ret = check_dir($tmpdir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, true, true, 0755);
                            if (!$ret) {
                                $errorstring = "Temporary directory cache does not exist or is not writable! \n<br>\n";
                                die($errorstring);
                            }
                            // generate image in all necessary resolutions
                            // you can skip resolutions by changing the array at this point
                            $resolutions = $resolutions_available;
                            foreach ($resolutions as $res) {
                                $ret = check_dir($tmpdir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $res, true, true, 0755);
                                if (!$ret) {
                                    $errorstring = "Error creating temporary directory cache for resolution: {$res}! \n<br>\n";
                                    die($errorstring);
                                }
                            }
                            // generate temporary id string
                            $tmpid = generate_random_string();
                            // carry out conversion steps
                            echo "\n<br>\n<em>Generating image versions for all resolutions:</em>\n<br><br>\n";
                            if ($config['imagick_mode'] == 'fast') {
                                $ret = convert_image_batch($filename, $tmpdir . 'cache', $tmpid, $resolutions);
                                if ($ret) {
                                    echo "Generating images (batch mode)\t\t\t: success\n<br>\n";
                                    $convert_success = true;
                                } else {
                                    echo "Generating images (batch mode)\t\t\t: failed\n<br>\n";
                                    echo "Aborting...\n<br>\n";
                                    $convert_success = false;
                                }
                            } else {
                                // convert image to JPG at 1600x1200 as a base for the following conversion
                                $baseimage_filename = $tmpdir . 'cache' . DIRECTORY_SEPARATOR . $tmpid . '.jpg';
                                $res = '1600x1200';
                                $ret = convert_image($filename, $baseimage_filename, $res, false);
                                if ($ret) {
                                    echo "Generating base image\t\t\t: success\n<br>\n";
                                    $convert_success = true;
                                } else {
                                    echo "Generating base image\t\t\t: failed\n<br>\n";
                                    echo "Aborting...\n<br>\n";
                                    $convert_success = false;
                                }
                                // the following lines will generate a JPG-version of your original image
                                // uncomment them, if you need it (requires additional computation time)
                                /*
                                if ($convert_success)
                                {
                                	$output_filename = $tmpdir.'cache'.DIRECTORY_SEPARATOR.$tmpid.'.jpg';
                                	
                                	$res = $img_data['width'].'x'.$img_data['height'];
                                	
                                	$ret = convert_image($filename,$output_filename,$res, false);
                                	
                                	if ($ret)
                                	{
                                		echo ("Writing (".$res.")\t\t\t: success\n<br>\n");
                                		$convert_success = true;
                                	}
                                	else
                                	{
                                		echo ("Writing (".$res.")\t\t\t: failed\n<br>\n");
                                		echo ("Aborting...\n<br>\n");
                                		$convert_success = false;
                                	}
                                }
                                */
                                if ($convert_success) {
                                    foreach ($resolutions as $res) {
                                        $ret = check_dir($tmpdir . 'cache' . DIRECTORY_SEPARATOR . $res, true, true, 0755);
                                        // check if cache subdirectories exist
                                        if (!$ret) {
                                            $errorstring = "Error creating directory for resolution " . $res . "\n<br>\n";
                                            $errorstring .= "or directory exists and is not writable\n<br>\n";
                                            die($errorstring);
                                        }
                                        if ($res == '120x90') {
                                            $is_thumbnail = true;
                                        } else {
                                            $is_thumbnail = false;
                                        }
                                        $output_filename = $tmpdir . 'cache' . DIRECTORY_SEPARATOR . $res . DIRECTORY_SEPARATOR . $tmpid . '.jpg';
                                        $ret = convert_image($baseimage_filename, $output_filename, $res, $is_thumbnail);
                                        if ($ret) {
                                            echo "Writing (" . $res . ")\t\t\t: success\n<br>\n";
                                            $convert_success = true;
                                        } else {
                                            echo "Writing (" . $res . ")\t\t\t: failed\n<br>\n";
                                            echo "Aborting...\n<br>\n";
                                            $convert_success = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            if ($convert_success) {
                                // we have all necessary files now, so we get a correct id and move the files
                                //
                                // in unlikely cases this section will cause trouble, i.e. when someone gets
                                // a new id while we are copying and before we insert into the database
                                echo "\n<br>\n<em>Copying generated image versions to their correct locations:</em> \n<br><br>\n";
                                // check if we already have a cache directory structure, otherwise create
                                $ret = check_dir($output_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, true, true, 0755);
                                if (!$ret) {
                                    $errorstring = "Output directory cache does not exist or is not writable! \n<br>\n";
                                    die($errorstring);
                                }
                                // get new id for filename
                                $sql = "SELECT max(imageid)+1 FROM " . $db_prefix . "img";
                                $newid = $db->GetOne($sql);
                                if (!$newid) {
                                    $newid = 1;
                                }
                                // iterate through all available resolutions and check whether the target directory exists
                                // if yes, move the corresponding file, otherwise abort.
                                foreach ($resolutions as $res) {
                                    $ret = check_dir($output_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $res, true, true, 0755);
                                    // check if cache subdirectories exist
                                    if (!$ret) {
                                        $errorstring = "Error creating directory for resolution " . $res . "\n<br>\n";
                                        $errorstring .= "or directory exists and is not writable\n<br>\n";
                                        die($errorstring);
                                    }
                                    $tmp_filename = $tmpdir . 'cache' . DIRECTORY_SEPARATOR . $res . DIRECTORY_SEPARATOR . $tmpid . '.jpg';
                                    $output_filename = $output_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $res . DIRECTORY_SEPARATOR . $query['collectionid'] . '-' . $newid . '.jpg';
                                    $ret = @copy($tmp_filename, $output_filename);
                                    if ($ret) {
                                        echo "Writing (" . $res . ")\t\t\t: success\n<br>\n";
                                        $convert_success = true;
                                    } else {
                                        echo "Writing (" . $res . ")\t\t\t: failed\n<br>\n";
                                        echo "Aborting...\n<br>\n";
                                        $convert_success = false;
                                        break;
                                    }
                                    // if unlink fails, we just loose some disk space
                                    @unlink($tmp_filename);
                                }
                                // if you decided to enable JPG-Versions in original resolution,
                                // uncomment the following lines to copy them to the target
                                // directory
                                /*
                                // copy the JPEG version with original resolution
                                if ($convert_success)
                                {
                                	$tmp_filename = $tmpdir.'cache'.DIRECTORY_SEPARATOR.$tmpid.'.jpg';
                                											
                                	$output_filename = $output_dir.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$query['collectionid'].'-'.$newid.'.jpg';
                                		
                                	$ret = @copy($tmp_filename,$output_filename);
                                	
                                	$res = $img_data['width'].'x'.$img_data['height'];
                                	
                                	if ($ret)
                                	{
                                		echo ("Writing (".$res.")\t\t\t: success\n<br>\n");
                                		$convert_success = true;
                                	}
                                	else
                                	{
                                		echo ("Writing (".$res.")\t\t\t: failed\n<br>\n");
                                		echo ("Aborting...\n<br>\n");
                                		$convert_success = false;
                                	}
                                	
                                	// if unlink fails, we just loose some disk space
                                	@unlink($tmp_filename);	
                                }			
                                */
                                if ($config['imagick_mode'] != 'fast') {
                                    // try to delete temprorary base image
                                    // if unlink fails, we just loose some disk space
                                    @unlink($baseimage_filename);
                                }
                                if ($convert_success) {
                                    // all generated versions copied, so we finally try the original
                                    $newfilename = $query['collectionid'] . '-' . $newid . '.' . $formats_suffix[$img_data["mime"]];
                                    $source = $filename;
                                    $dest = $output_dir . DIRECTORY_SEPARATOR . $newfilename;
                                    $ret = @copy($filename, $output_dir . DIRECTORY_SEPARATOR . $newfilename);
                                    if (!$ret) {
                                        echo "Copying original image\t: failed\n<br>\n";
                                        echo "Aborting...\n<br>\n";
                                    } else {
                                        echo "Copying original image\t: success\n<br>\n";
                                        // set permissions
                                        $ret = @chmod($output_dir . DIRECTORY_SEPARATOR . $newfilename, 0755);
                                        if (!$ret) {
                                            echo "Modyfing permissions\t: failed\n<br>\n";
                                        } else {
                                            echo "Modyfing permissions\t: success\n<br>\n";
                                        }
                                        $ret = @unlink($filename);
                                        if (!$ret) {
                                            echo "Removing uploaded file\t: failed\n<br>\n";
                                        } else {
                                            echo "Removing uploaded file\t: success\n<br>\n";
                                        }
                                        echo "\n<br>\n";
                                        // here our critical section ends, after the next command, the image counter
                                        // is increased by 1
                                        // get current time
                                        $sql = "SELECT NOW()";
                                        $time = $db->GetOne($sql);
                                        $ret = insert_img($query['collectionid'], $newid, $baseid, $file, $img_data, $time);
                                        if (!$ret) {
                                            echo "Inserting into database (image)\t\t\t: failed\n<br>\n";
                                            echo "Aborting...\n<br>\n";
                                        } else {
                                            echo "Inserting into database (image)\t\t\t: success\n<br>\n";
                                            $ret = insert_meta($query['collectionid'], $newid, $time, $user['login'], $query['type']);
                                            if (!$ret) {
                                                echo "Inserting into database (meta)\t\t\t: failed\n<br>\n";
                                                echo "Aborting...\n<br>\n";
                                            } else {
                                                echo "Inserting into database (meta)\t\t\t: success\n<br>\n";
                                                if (!empty($query['group1id'])) {
                                                    $ret = insert_img_group($query['group1id'], $query['collectionid'], $newid);
                                                    if (!$ret) {
                                                        // a failed group insertion is non-critical, so we continue
                                                        echo "Inserting into database (group1)\t\t\t: failed\n<br>\n";
                                                    } else {
                                                        echo "Inserting into database (group1)\t\t\t: success\n<br>\n";
                                                    }
                                                }
                                                if (!empty($query['group2id'])) {
                                                    $ret = insert_img_group($query['group2id'], $query['collectionid'], $newid);
                                                    if (!$ret) {
                                                        // a failed group insertion is non-critical, so we continue
                                                        echo "Inserting into database (group2)\t\t\t: failed\n<br>\n";
                                                    } else {
                                                        echo "Inserting into database (group2)\t\t\t: success\n<br>\n";
                                                    }
                                                }
                                                if (!empty($query['group3id'])) {
                                                    $ret = insert_img_group($query['group3id'], $query['collectionid'], $newid);
                                                    if (!$ret) {
                                                        // a failed group insertion is non-critical, so we continue
                                                        echo "Inserting into database (group3)\t\t\t: failed\n<br>\n";
                                                    } else {
                                                        echo "Inserting into database (group3)\t\t\t: success\n<br>\n";
                                                    }
                                                }
                                            }
                                            // end of actions - output a newline
                                            echo "\n<br>\n";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // Image is processed completely
            echo "<em>" . $file . " done</em>\n<br><br>\n";
            flush();
        }
    }
    // after all images have been processed, we try to clean up the upload directory, so things do not get inserted twice
    foreach ($remove as $removethis) {
        if (!empty($dir)) {
            $removedir = $dir . DIRECTORY_SEPARATOR . $removethis;
        } else {
            $removedir = $removethis;
        }
        if ($debug) {
            echo "Purging possible thumbs.db file from: " . $removedir . "\n<br>\n";
        }
        $ret = @unlink($removedir . 'Thumbs.db');
        if ($debug) {
            echo "Now removing: " . $removedir . "\n<br>\n";
        }
        $ret = @rmdir($removedir);
        if (!$ret) {
            $errorstring = "Notice: " . $removedir . " could not be removed\n<br>\n";
            $errorstring .= "Insufficient permission or directory not empty\n<br>\n";
            echo $errorstring;
        }
    }
    if ($debug) {
        echo "Purging possible thumbs.db file from: " . $dir . "\n<br>\n";
    }
    $ret = @unlink($dir . 'Thumbs.db');
    if ($debug) {
        echo "Now removing: " . $dir . "\n<br>\n";
    }
    $ret = @rmdir($dir);
    if (!$ret) {
        $errorstring = "Notice: " . $dir . " could not be removed\n<br>\n";
        $errorstring .= "Insufficient permission or directory not empty\n<br>\n";
        echo $errorstring;
    }
    return;
}
Exemple #26
0
/**
 * 判断目录是否存在 创建目录
 * @param unknown $dir
 * @param number $mode
 * @return boolean
 */
function check_dir($dir, $mode = 0777)
{
    if (is_dir($dir) || @mkdir($dir, $mode)) {
        return true;
    }
    if (!check_dir(dirname($dir), $mode)) {
        return false;
    }
    return @mkdir($dir, $mode);
}
Exemple #27
0
function assign_dir($path)
{
    /*
       Silently checks the path for existence or creates it.
        Returns either the path or Null.
    */
    if ($path == null || !is_string($path)) {
        return null;
    }
    return check_dir($path);
}
Exemple #28
0
	function input(){

			$id = $this->pm->get_max_id();
		if($this->input->post('_INPUT'))
		{ #print_r($_FILES); break;
			
			// upload preference
			$config['allowed_types'] = 'gif|jpg|png';
			$config['max_width']  = '0';
			$config['max_height']  = '0';
			$this->load->library('upload', $config);
			// dir img for upload
    		$id=$this->input->post('id');
    		$dir_img="./uploads/promo/";

			
			
			// --------- LOOPING $_FILES dari group img BARU
			
				if(isset($_FILES["user_file"])){
						// jika filenya ada, lakukan upload
						if(!empty($_FILES['user_file']['name'])) 
						{
							// set upload dir
							$dir = $dir_img;
							if(check_dir($dir))
							{
								$exptest=explode("/",$_FILES['user_file']['name']);
								$test=$exptest[count($exptest)-1];
								$test_ext=strtolower(substr($test,strlen($test)-3,3));
								$config['upload_path'] = $dir;
								$config['file_name']	= $id.".".$test_ext;
								$this->upload->initialize($config);
								
								// upload new img
								if($this->upload->do_upload('user_file'))
								{ #echo 'upload new image --'.$idgbr.'<br>';
							// break;
									// format gambar di db (langsung pakai serialize)
									// array (
									//   img[big][1] = img1
									// 			 [2] = img2
									// 			 [..] = ...
									//   img[thumb][1] = img1
									// 			   [2] = img2
									// 			   [..] = ...
									//   img[intro] = img1
									// )
									$res=$this->upload->data();
									if(!file_exists($dir."thumbnail/")){
									mkdir($dir."thumbnail/");
									}
													$this->load->library('image_lib');
										$config['image_library'] = 'gd2';
						            $config['source_image'] = $dir.$res['file_name'];
						            $config['new_image'] = $dir."thumbnail/";
						            $config['maintain_ratio'] = TRUE;
						            $config['create_thumb'] = FALSE;
						            $config['overwrite'] = TRUE;
						            $config['width'] = 200;
						            $config['height'] = 124;

						            $this->image_lib->clear();
						            $this->image_lib->initialize($config);
						            $this->image_lib->resize();
								}else{
									// break;
									remove_dir($dir); // remove dir just idimg
									$data['ok']=false;$data['msg'] = $this->upload->display_errors();
									$next2=false;
								}
							}else{
								$data['ok']=false;$data['msg'] = lang('dir_not_exists');
								$next2=false;
								break;
							} // check_dir 
						} // if !empty(file)
					} // foreach dataurut
					
			// langjutkan dengan update gambar baru ke tabel, (jika ada)

                // input to table promo
				$promo = $this->input->post('promo');
				$desc = $this->input->post('desc');
				$image = $res['file_name'];
			    $this->pm->input_promo($id,$promo,$desc,$image);
				

				// all done and show message
				$id++;
				$data['ok']=true;
				$data['msg'] = "data terinput";#.meta_refresh(site_url(config_item('modulename').'/'.$this->router->class));

		}
		$data['id'] =$id ;
		$this->template
        ->set_metadata('stylesheet',module_css('promo_edit.css',false),'link')
        ->set_view ('promo_edit',$data,config_item('modulename'));
	}
Exemple #29
0
 /**
  * 记录后台操作日志
  * @param string $message 日志信息
  * @param string $file 日志文件
  * @return number
  */
 protected function _log($info, $file = NULL)
 {
     check_dir(RUNTIME_PATH . 'Logs/admin');
     file_put_contents($file ? $file : RUNTIME_PATH . 'Logs/admin/' . 'admin_' . date('Ymd') . '.log', "[" . date('H:i:s') . "] " . (is_array($info) || is_object($info) ? print_r($info, true) : $info) . "\n", FILE_APPEND);
 }
Exemple #30
0
?>
<script type="text/javascript">
$(function() {
  $(window).bind('mousewheel', function(e, d) {
    window.top.onMouseWheelFromChildFrame();
  });
});
</script>
</head>
<?php 
$dir_encode = htmlentities($r_dir, ENT_QUOTES, 'UTF-8');
echo <<<HTML
<body class="dir-browser modal" onLoad="window.parent.onDirBrowserLoaded('{$dir_encode}');">

HTML;
if (check_dir($r_dir)) {
    $dirs = do_list($r_dir, 'd');
    $files = do_list($r_dir, 'f');
} else {
    $dirs = false;
    $files = false;
}
if ($dirs !== false && $files !== false) {
    echo <<<HTML
  <div id="dir-list">

HTML;
    if (!is_root_dir($r_dir)) {
        $parent_dir = substr($r_dir, 0, strrpos($r_dir, '/', -2));
        $parent_url = get_url($parent_dir);
        echo <<<HTML