dbQuery("delete from Zones where MonitorId = ?", array($markMid)); if (ZM_OPT_X10) { dbQuery("delete from TriggersX10 where MonitorId=?", array($markMid)); } fixSequences(); // If fast deletes are on, then zmaudit will clean everything else up later // If fast deletes are off and there are lots of events then this step may // well time out before completing, in which case zmaudit will still tidy up if (!ZM_OPT_FAST_DELETE) { // Slight hack, we maybe should load *, but we happen to know that the deleteEvent function uses Id and StartTime. $markEids = dbFetchAll("SELECT Id,StartTime FROM Events WHERE MonitorId=?", NULL, array($markMid)); foreach ($markEids as $markEid) { deleteEvent($markEid, $markMid); } deletePath(ZM_DIR_EVENTS . "/" . basename($monitor['Name'])); deletePath(ZM_DIR_EVENTS . "/" . $monitor['Id']); // I'm trusting the Id. } } } } } } } // Device view actions if (canEdit('Devices')) { if ($action == "device") { if (!empty($_REQUEST['command'])) { setDeviceStatusX10($_REQUEST['key'], $_REQUEST['command']); } elseif (isset($_REQUEST['newDevice'])) { if (isset($_REQUEST['did'])) {
function deleteEvent($event, $mid = false) { if (empty($event)) { Error("Empty event passed to deleteEvent."); return; } if (gettype($event) != 'array') { # $event could be an eid, so turn it into an event hash $event = dbFetchOne('SELECT Id, MonitorId, StartTime FROM Events WHERE Id=?', NULL, array($event)); } global $user; if (!$mid) { $mid = $event['MonitorId']; } if ($user['Events'] == 'Edit') { dbQuery('DELETE FROM Events WHERE Id = ?', array($event['Id'])); if (!ZM_OPT_FAST_DELETE) { dbQuery('DELETE FROM Stats WHERE EventId = ?', array($event['Id'])); dbQuery('DELETE FROM Frames WHERE EventId = ?', array($event['Id'])); if (ZM_USE_DEEP_STORAGE) { # Assumption: All events haev a start time $start_date = date_parse($event['StartTime']); $start_date['year'] = $start_date['year'] % 100; # So this is because ZM creates a link under teh day pointing to the time that the event happened. $eventlink_path = sprintf('%s/%d/%02d/%02d/%02d/.%d', ZM_DIR_EVENTS, $mid, $start_date['year'], $start_date['month'], $start_date['day'], $event['Id']); if ($id_files = glob($eventlink_path)) { # I know we are using arrays here, but really there can only ever be 1 in the array $eventPath = preg_replace('/\\.' . $event['Id'] . '$/', readlink($id_files[0]), $id_files[0]); deletePath($eventPath); deletePath($id_files[0]); $pathParts = explode('/', $eventPath); for ($i = count($pathParts) - 1; $i >= 2; $i--) { $deletePath = join('/', array_slice($pathParts, 0, $i)); if (!glob($deletePath . "/*")) { deletePath($deletePath); } } } else { Warning("Found no event files under {$eventlink_path}"); } # end if found files } else { $eventPath = implode('/', array(ZM_DIR_EVENTS, $mid, $event['Id'])); deletePath($eventPath); } # USE_DEEP_STORAGE OR NOT } # ! ZM_OPT_FAST_DELETE } # CAN EDIT }
} else { $sitename = $argv[1]; $exportpath = $argv[2]; // Fetch the site. $site =& new Site($sitename); $site->fetchDown(TRUE); $site->fetchSiteAtOnceForeverAndEverAndDontForgetThePermissionsAsWell_Amen(); // Fetch the location of the media files. $imagepath = $uploaddir . '/' . $sitename . '/'; // Get the XML for the site $siteExporter =& new DomitSiteExporter(); $siteXML =& $siteExporter->export($site); // make a directory for the site contents $siteDir = $exportpath . '/' . $sitename . '/'; if (file_exists($siteDir)) { deletePath($siteDir); } mkdir($siteDir); // Copy the Media Files to the sitedir. dir_copy($imagepath, $siteDir . 'media/'); // Save the XML to a file. $xmlFile = $siteDir . 'site.xml'; if (!($handle = fopen($xmlFile, 'a'))) { echo "Cannot open file ({$xmlFile})"; exit; } // Write $somecontent to our opened file. if (!fwrite($handle, $siteXML)) { echo "Cannot write to file ({$xmlFile})"; exit; }
$i = 1; while ($a = db_fetch_assoc($r)) { $sitename = $a['name']; if ($verbose) { print "\n" . $i . "\t" . $sitename . "\t"; } $i++; $cmd = "php"; if ($_ENV["_"]) { $cmd = $_ENV["_"]; } // print $php . "\n"; print shell_exec("php " . dirname(__FILE__) . "/export_site.php " . $sitename . " " . $exportpath); } // If we are compressing, make a tarball and delete the temp directory if ($compress) { if ($verbose) { print "\ncd " . $backupdir; } print shell_exec("cd " . $backupdir); if ($verbose) { print "\ntar -czf " . $backupdir . "/segue_backup.tar.gz segue_backup"; } print shell_exec("tar -czf " . $backupdir . "/segue_backup.tar.gz segue_backup"); deletePath($exportpath); } if ($verbose) { print "\n"; } } exit(0);
public function delete() { dbQuery('DELETE FROM Events WHERE Id = ?', array($this->{'Id'})); if (!ZM_OPT_FAST_DELETE) { dbQuery('DELETE FROM Stats WHERE EventId = ?', array($this->{'Id'})); dbQuery('DELETE FROM Frames WHERE EventId = ?', array($this->{'Id'})); if (ZM_USE_DEEP_STORAGE) { # Assumption: All events haev a start time $start_date = date_parse($this->{'StartTime'}); $start_date['year'] = $start_date['year'] % 100; $Storage = $this->Storage(); # So this is because ZM creates a link under teh day pointing to the time that the event happened. $eventlink_path = $Storage->Path() . '/' . $this->Link_Path(); if ($id_files = glob($eventlink_path)) { # I know we are using arrays here, but really there can only ever be 1 in the array $eventPath = preg_replace('/\\.' . $event['Id'] . '$/', readlink($id_files[0]), $id_files[0]); deletePath($eventPath); deletePath($id_files[0]); $pathParts = explode('/', $eventPath); for ($i = count($pathParts) - 1; $i >= 2; $i--) { $deletePath = join('/', array_slice($pathParts, 0, $i)); if (!glob($deletePath . "/*")) { deletePath($deletePath); } } } else { Warning("Found no event files under {$eventlink_path}"); } # end if found files } else { $eventPath = $this->Path(); deletePath($eventPath); } # USE_DEEP_STORAGE OR NOT } # ! ZM_OPT_FAST_DELETE }
function deletePath($path) { // posted by georg@spieleflut.de on PHP.net 24-Dec-2001 10:28 // This function will completely delete even a non-empty directory. chmod($path, 0777); if (is_dir($path)) { $handle = opendir($path); while ($filename = readdir($handle)) { if ($filename != "." && $filename != "..") { deletePath($path . "/" . $filename); } } closedir($handle); rmdir($path); } else { unlink($path); } }
function deleteEvent( $eid, $mid=false ) { global $user; if ( !$mid ) $mid = '*'; $eid = dbEscape($eid); if ( $user['Events'] == 'Edit' && !empty($eid) ) { dbQuery( "delete from Events where Id = '$eid'" ); if ( !ZM_OPT_FAST_DELETE ) { dbQuery( "delete from Stats where EventId = '$eid'" ); dbQuery( "delete from Frames where EventId = '$eid'" ); if ( ZM_USE_DEEP_STORAGE ) { if ( $id_files = glob( ZM_DIR_EVENTS.'/'.$mid.'/*/*/*/.'.$eid ) ) $eventPath = preg_replace( "/\.$eid$/", readlink($id_files[0]), $id_files[0] ); deletePath( $eventPath ); deletePath( $id_files[0] ); $pathParts = explode( '/', $eventPath ); for ( $i = count($pathParts)-1; $i >= 2; $i-- ) { $deletePath = join( '/', array_slice( $pathParts, 0, $i ) ); if ( !glob( $deletePath."/*" ) ) { deletePath( $deletePath ); } } } else { $eventPath = ZM_DIR_EVENTS.'/'.$mid.'/'.$eid; deletePath( $eventPath ); } } } }
function delete() { // delete from db global $cfg; if (!$this->id) { return false; } $this->fetchDown(); $siteName = $this->getField("name"); $query = "DELETE FROM site WHERE site_id= '" . addslashes($this->id) . "'"; db_query($query); $query = "DELETE FROM permission WHERE FK_scope_id='" . addslashes($this->id) . "' AND permission_scope_type='site';"; db_query($query); $query = "DELETE FROM media WHERE FK_site='" . addslashes($this->id) . "'"; db_query($query); $query = " UPDATE slot SET FK_site=NULL WHERE FK_site='" . addslashes($this->id) . "'"; db_query($query); // remove sections if ($this->sections) { foreach ($this->sections as $s => $o) { $o->delete(); } } /* print "<pre>this: "; print_r($this); print "</pre>"; */ $this->clearPermissions(); /* print "<pre>this: "; print_r($this); print "</pre>"; */ $this->updatePermissionsDB(); // remove all editors from db // echo $query = "DELETE FROM site_editors WHERE FK_site = ".$this->id; db_query($query); // exit(0); // delete the userfiles if (ereg("[0-9a-zA-Z]", $siteName)) { $file_path = $cfg['uploaddir'] . "/" . $siteName; deletePath($file_path); } }