function GetODSContent($path, $fdoc) { $dirt = $path . $fdoc . '_temp'; //unzip if (is_dir($dirt)) { rm_rf($dirt); } else { } mkdir($dirt); $zip = new ZipArchive(); $zip->open($path . $fdoc); $zip->extractTo($dirt); $zip->close(); //get content $fc = file($dirt . '/content.xml'); $fc_str = implode('', $fc); $fc_str_r1 = str_replace(':', '__', $fc_str); $fc_str_r2 = str_replace('table-', 'table', $fc_str_r1); $content = simplexml_load_string($fc_str_r2); $body = $content->office__body; $sheet = $body->office__spreadsheet; $doc = array(); foreach ($sheet->table__table as $table) { $tablename = $table['table__name']; $doc["{$tablename}"] = array(); $nrow = 0; foreach ($table->table__tablerow as $row) { $doc["{$tablename}"][$nrow] = array(); $ncell = 0; foreach ($row->table__tablecell as $cell) { $text = $cell->text__p; $text = trim($text); $text = str_replace('&', '&', $text); $text = str_replace('__', ':', $text); $doc["{$tablename}"][$nrow][$ncell] = $text; $ncell = $ncell + 1; $rep = $cell['table__number-columns-repeated']; if ($rep > 0 && $rep < 5) { for ($ir = 0; $ir < $rep - 1; $ir++) { $doc["{$tablename}"][$nrow][$ncell] = $text; $ncell = $ncell + 1; } } else { } } $nrow = $nrow + 1; } } rm_rf($dirt); return $doc; }
function wait_previous_call_terminate($tmp_dir) { $timeout = 0; while (is_dir($tmp_dir)) { echo "waiting for previous call to end\n"; if ($timeout-- == 0) { // remove dead(?) dir rm_rf($tmp_dir); break; } sleep(1); } return mkdir($tmp_dir); }
function delete() { if ($this->input->post('bo_table')) { $bo_tables = array($this->input->post('bo_table')); } else { if ($this->input->post('chk')) { $bo_tables = $this->input->post('chk'); } else { alert('잘못된 접근입니다.'); } } // 게시판 폴더 삭제 $this->load->dbforge(); $this->load->helper('admin'); $ca_types = array(); foreach ($bo_tables as $bo_table) { $this->dbforge->drop_table('ki_extra_' . $bo_table); rm_rf(DATA_PATH . '/file/' . $bo_table); $ca_types[] = 'bo_' . $bo_table; } $this->Board_model->delete($bo_tables, $ca_types); goto_url(URL); }
function temp_dir($default = false) { global $ptmp, $prefix; if ($default) { if (!@is_dir($default)) { if (!mkdir_p($default)) { return false; } } /* try it really, is_writable is buggy with openbasedir */ $fh = @fopen(realpath($default) . "/test", "wb"); if ($fh) { $ptmp = $default; return true; } else { $ptmp = "failed"; return false; } } $_temp = false; if (WINDOWS) { if (my_env('TEMP')) { $_temp = my_env('TEMP'); } elseif (my_env('TMP')) { $_temp = my_env('TMP'); } elseif (my_env('windir')) { $_temp = my_env('windir') . '\\temp'; } elseif (my_env('SystemRoot')) { $_temp = my_env('SystemRoot') . '\\temp'; } // handle ugly ENV var like \Temp instead of c:\Temp $dirs = explode("\\", realpath($_temp)); if (strpos($_temp, ":") != 1) { unset($_temp); $_dirs = array(); foreach ($dirs as $val) { if ((bool) $val) { $_dirs[] = str_replace("/", "", $val); } } unset($dirs); $dirs = $_dirs; array_unshift($dirs, "c:"); $_temp = $dirs[0]; for ($i = 1; $i < count($dirs); $i++) { $_temp .= "//" . $dirs[$i]; } } $ptmp = $_temp; } else { $_temp = my_env('TMPDIR'); if (!$_temp) { if (is_writable('/tmp')) { $_temp = '/tmp'; } } } // If for some reason the user has no rights to access to // the standard tempdir, we assume that he has the right // to access his prefix and choose $prefix/tmp as tempdir if (!$_temp) { print "System's Tempdir failed, trying to use \$prefix/tmp ..."; $res = mkdir_p($prefix . '/tmp'); if (!$res) { bail('mkdir ' . $prefix . '/tmp' . ' ... failed'); } $ptmp = $prefix . '/tmp'; $_temp = tempnam($prefix . '/tmp', 'gope'); rm_rf($_temp); mkdir_p($_temp, 0700); $ok = @chdir($ptmp); if (!$ok) { // This should not happen, really ;) bail('chdir ' . $ptmp . ' ... failed'); } print "ok\n"; // Adjust TEMPDIR envvars if (!isset($_ENV)) { $_ENV = array(); } $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix . '/tmp'; } else { $_temp = tempnam($_temp . '/tmp', 'gope'); } $temp_dir = $ptmp = $_temp; return true; }
function rm_rf($file) { if (file_exists($file)) { if (is_dir($file)) { $handle = opendir($file); while ($filename = readdir($handle)) { if ($filename != '.' && $filename != '..') { rm_rf($file . '/' . $filename); } } closedir($handle); @chmod($file, G5_DIR_PERMISSION); @rmdir($file); } else { @chmod($file, G5_FILE_PERMISSION); @unlink($file); } } }
<?php // board_delete.php , boardgroup_delete.php 에서 include 하는 파일 if (!defined('_GNUBOARD_')) { exit; } if (!defined('_BOARD_DELETE_')) { exit; } // 개별 페이지 접근 불가 // $tmp_bo_table 에는 $bo_table 값을 넘겨주어야 함 if (!$tmp_bo_table) { return; } // 게시판 1개는 삭제 불가 (게시판 복사를 위해서) //$row = sql_fetch(" select count(*) as cnt from $g5['board_table'] "); //if ($row['cnt'] <= 1) { return; } // 게시판 설정 삭제 sql_query(" delete from {$g5['board_table']} where bo_table = '{$tmp_bo_table}' "); // 최신글 삭제 sql_query(" delete from {$g5['board_new_table']} where bo_table = '{$tmp_bo_table}' "); // 스크랩 삭제 sql_query(" delete from {$g5['scrap_table']} where bo_table = '{$tmp_bo_table}' "); // 파일 삭제 sql_query(" delete from {$g5['board_file_table']} where bo_table = '{$tmp_bo_table}' "); // 게시판 테이블 DROP sql_query(" drop table {$g5['write_prefix']}{$tmp_bo_table} ", FALSE); delete_cache_latest($tmp_bo_table); // 게시판 폴더 전체 삭제 rm_rf(G5_DATA_PATH . '/file/' . $tmp_bo_table);
function rm_rf($file) { if (is_dir($file)) { if (!($dh = opendir($file))) { return false; } while (($entry = readdir($dh)) !== false) { if ($entry == '.' || $entry == '..') { continue; } if (!rm_rf($file . DIRECTORY_SEPARATOR . $entry)) { closedir($dh); return false; } } closedir($dh); return rmdir($file); } else { return unlink($file); } }
$coll = GetColl_ODBC_Content($src_data['coll']['src'], $src_data['coll']['user'], $src_data['coll']['pass']); $src_coll = collODS2xml($coll); } else { } if ($src_data['coll']['type'] == 'ODS') { $coll = GetODSContent($src_path['coll'], $src_data['coll']['file']); $src_coll = geoODS2xml($coll); } else { } $result = ExtCollGeoByTax($result, $tax_names, $src_coll, $src_geo, $control); } $res_collections = MakeCollIndex($src_path['collections'], $result['coll']); //load the base $basedir = $upl_path . '/' . $set[$nset]['name']; if (is_dir($basedir)) { rm_rf($basedir); } else { } mkdir($basedir); $base_index = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><base></base>'); $base_index->addChild('title', $set[$nset]['title']); $base_index->addChild('description', $set[$nset]['description']); $base_index->addChild('collection', $set[$nset]['collection']); $base_index->addChild('geodata', $set[$nset]['geodata']); $base_index->addChild('taxonomy', $set[$nset]['taxonomy']); $base_index->asXML($basedir . '/index.xml'); $tax_xml->asXML($basedir . '/' . $set[$nset]['taxonomy']); $result['geo']->asXML($basedir . '/' . $set[$nset]['geodata']); $result['coll']->asXML($basedir . '/' . $set[$nset]['collection']); $res_collections->asXML($basedir . '/collections.xml'); copy($src_path['map'] . '/' . $set[$nset]['map'] . '/blank.jpg', $basedir . '/blank.jpg');
function rm_rf($file) { if (file_exists($file)) { @chmod($file, 0777); if (is_dir($file)) { $handle = opendir($file); while ($filename = readdir($handle)) { if ($filename != "." && $filename != "..") { rm_rf("{$file}/{$filename}"); } } closedir($handle); rmdir($file); } else { unlink($file); } } }
function rm_rf($path) { if (@is_dir($path)) { $dp = opendir($path); while ($ent = readdir($dp)) { if ($ent == '.' || $ent == '..') { continue; } $file = $path . DIRECTORY_SEPARATOR . $ent; if (@is_dir($file)) { rm_rf($file); } else { unlink($file); } } closedir($dp); return rmdir($path); } else { return @unlink($path); } }
} } if (!$error) { $tar = new Archive_Tar($pkg_name . '.tar.gz'); $create = $tar->create(array($pkg_name)); if (!$create) { $error = __("Could not re-tar"); } } # Chmod files after everything has been done. if (!$error && !chmod_group($incoming_pkgdir)) { $error = __("Could not chmod directory %s.", $incoming_pkgdir); } # Whether it failed or not we can clean this out if (file_exists($tempdir)) { rm_rf($tempdir); } # Update the backend database if (!$error) { $dbh = db_connect(); # This is an overwrite of an existing package, the database ID # needs to be preserved so that any votes are retained. However, # PackageDepends and PackageSources can be purged. $q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'"; $result = db_query($q, $dbh); $pdata = mysql_fetch_assoc($result); if ($pdata) { # Flush out old data that will be replaced with new data $q = "DELETE FROM PackageDepends WHERE PackageID = " . $pdata["ID"]; db_query($q, $dbh); $q = "DELETE FROM PackageSources WHERE PackageID = " . $pdata["ID"];
<?php // board_delete.php , boardgroup_delete.php 에서 include 하는 파일 if (!defined("_GNUBOARD_")) { exit; } if (!defined("_BOARD_DELETE_")) { exit; } // 개별 페이지 접근 불가 // $tmp_bo_table 에는 $bo_table 값을 넘겨주어야 함 if (!$tmp_bo_table) { return; } // 게시판 1개는 삭제 불가 (게시판 복사를 위해서) //$row = sql_fetch(" select count(*) as cnt from $g4[board_table] "); //if ($row[cnt] <= 1) { return; } // 게시판 설정 삭제 sql_query(" delete from {$g4['board_table']} where bo_table = '{$tmp_bo_table}' "); // 최신글 삭제 sql_query(" delete from {$g4['board_new_table']} where bo_table = '{$tmp_bo_table}' "); // 스크랩 삭제 sql_query(" delete from {$g4['scrap_table']} where bo_table = '{$tmp_bo_table}' "); // 파일 삭제 sql_query(" delete from {$g4['board_file_table']} where bo_table = '{$tmp_bo_table}' "); // 게시판 테이블 DROP sql_query(" drop table {$g4['write_prefix']}{$tmp_bo_table} ", FALSE); // 게시판 폴더 전체 삭제 rm_rf("{$g4['path']}/data/file/{$tmp_bo_table}");
function rm_rf($file) { if (file_exists($file)) { @chmod($file, 0777); if (is_dir($file)) { $handle = opendir($file); while ($filename = readdir($handle)) { if ($filename != '.' && $filename != '..') { rm_rf($file . '/' . $filename); } } closedir($handle); rmdir($file); } else { unlink($file); } } }
function clean() { $lock_fn = LIB_ROOT . 'install.lock'; $lock_f = \fopen($lock_fn, 'w'); @\chmod($lock_fn, 0666); if (!\flock($lock_f, LOCK_EX | LOCK_NB)) { echo 'Waiting for currently running installation to finish ...'; \flock($lock_f, LOCK_EX); echo "\n"; } foreach (get_libs() as $lib) { detect_props($lib); if (\array_key_exists('symlink', $lib)) { @\unlink(LIB_ROOT . $lib['symlink']); } rm_rf($lib['fn']); @\unlink($lib['fn'] . '.part'); if ($lib['type'] == 'zip') { @\unlink($lib['fn'] . '.zip'); @\unlink($lib['fn'] . '.zip.part'); } } \flock($lock_f, LOCK_UN); \fclose($lock_f); \unlink($lock_fn); }