function delete_directory($directory)
 {
     // Retrieve all of the files
     $files = glob($directory . '*', GLOB_MARK);
     // Check if files exist
     if ($files) {
         // Files exist, loop through each file
         foreach ($files as $file) {
             // Check if file is a folder
             if (substr($file, -1) == '/') {
                 // File is a folder, delete the folder
                 delete_directory($file);
             } else {
                 // File is a file, delete the file
                 unlink($file);
             }
         }
     }
     // Check if the directory exists
     if (is_dir($directory)) {
         // Directory exists, remove the directory
         rmdir($directory);
         // Return TRUE
         return TRUE;
     } else {
         // Directory doesn't exist, return FALSE
         return FALSE;
     }
 }
Ejemplo n.º 2
0
/**
 * This function delete temp files (mostly image temporaly serialize data)
 */
function delete_tmp_files()
{
    if (function_exists(sys_get_temp_dir)) {
        $dir = sys_get_temp_dir();
    } else {
        $dir = "/tmp";
    }
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (strpos("___" . $file, "integria_serialize") || strpos("___" . $file, "tmpIntegriaFileSharing")) {
                if (file_exists($dir . "/" . $file)) {
                    if (is_dir($dir . "/" . $file)) {
                        delete_directory($dir . "/" . $file);
                    } else {
                        $fdate = filemtime($dir . "/" . $file);
                        $now = time();
                        if ($now - $fdate > 3600) {
                            @unlink($dir . "/" . $file);
                        }
                    }
                }
            }
        }
        closedir($dh);
    }
}
Ejemplo n.º 3
0
function delete_directory($dirname)
{
    global $db_path, $msgstr;
    $ix = strlen($db_path);
    $dir_handle = false;
    if (is_dir($dirname)) {
        echo "<p>" . $msgstr["dirname"] . ": " . substr($dirname, $ix) . "<br>";
        $dir_handle = opendir($dirname);
    }
    if (!$dir_handle) {
        return false;
    }
    while ($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            echo $msgstr["file"] . ": " . $file . "<br>";
            if (!is_dir($dirname . "/" . $file)) {
                unlink($dirname . "/" . $file);
            } else {
                delete_directory("{$dirname}" . '/' . $file);
            }
        }
    }
    closedir($dir_handle);
    rmdir($dirname);
    return true;
}
Ejemplo n.º 4
0
function delete_directory($directory)
{
    foreach (glob("{$directory}/*") as $file) {
        if (is_dir($file)) {
            delete_directory($file);
        } else {
            unlink($file);
        }
    }
    rmdir($directory);
}
Ejemplo n.º 5
0
/**
 * Delete a directory.
 *
 * @param string $dir    the directory deleting
 * @return boolean whether success true
 *
 */
function delete_directory($dir)
{
    $deleteOk = true;
    $current_dir = opendir($dir);
    while ($entryname = readdir($current_dir)) {
        if (is_dir("{$dir}/{$entryname}") && ($entryname != "." && $entryname != '..')) {
            delete_directory("{$dir}/{$entryname}");
        } elseif ($entryname != '.' && $entryname != '..') {
            unlink("{$dir}/{$entryname}");
        }
    }
    closedir($current_dir);
    rmdir(${dir} . "/");
    return $deleteOk;
}
Ejemplo n.º 6
0
function delete_directory($dir)
{
    if ($dh = @opendir($dir)) {
        while (($file = readdir($dh)) != false) {
            if ($file == "." || $file == "..") {
                continue;
            }
            if (is_dir($dir . '/' . $file)) {
                delete_directory($dir . '/' . $file);
            } else {
                unlink($dir . '/' . $file);
            }
        }
        @closedir($dh);
        rmdir($dir);
    }
}
function delete_files($path, $del_dir = FALSE)
{
    if (!($current_dir = @opendir($path))) {
        return;
    }
    while ($filename = @readdir($current_dir)) {
        if (@is_dir($path . '/' . $filename) and ($filename != "." and $filename != "..")) {
            delete_directory($path . '/' . $filename, TRUE);
        } elseif ($filename != "." and $filename != "..") {
            @unlink($path . '/' . $filename);
        }
    }
    @closedir($current_dir);
    if ($del_dir == TRUE) {
        @rmdir($path);
    }
}
function delete_directory($dirname) {
   if (is_dir($dirname))
      $dir_handle = opendir($dirname);
   if (!$dir_handle)
      return false;
   while($file = readdir($dir_handle)) {
      if ($file != "." && $file != "..") {
         if (!is_dir($dirname."/".$file))
            unlink($dirname."/".$file);
         else
            delete_directory($dirname.'/'.$file);
      }
   }
   closedir($dir_handle);
   rmdir($dirname);
   return true;
}
Ejemplo n.º 9
0
function delete_directory($dir)
{
    if (!file_exists($dir)) {
        return true;
    }
    if (!is_dir($dir)) {
        return unlink($dir);
    }
    foreach (scandir($dir) as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        if (!delete_directory($dir . DIRECTORY_SEPARATOR . $item)) {
            return false;
        }
    }
    return rmdir($dir);
}
Ejemplo n.º 10
0
function delete_directory($dir)
{
    if ($handle = opendir($dir)) {
        $array = array();
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . $file)) {
                    if (!@rmdir($dir . $file)) {
                        delete_directory($dir . $file . '/');
                        // Not empty? Delete the files inside it
                    }
                } else {
                    @unlink($dir . $file);
                }
            }
        }
        closedir($handle);
        @rmdir($dir);
    }
}
function delete_directory($dir)
{
    if (!preg_match("/\\/\$/", $dir)) {
        $dir .= '/';
    }
    if ($handle = @opendir($dir)) {
        while (strlen($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($dir . $file)) {
                    if (!@rmdir($dir . $file)) {
                        delete_directory($dir . $file . '/');
                    }
                } else {
                    @unlink($dir . $file);
                }
            }
        }
    }
    @closedir($handle);
    @rmdir($dir);
}
Ejemplo n.º 12
0
 public function index($page = 0)
 {
     if ($_POST) {
         if (!is_dir(MODULEPATH)) {
             mkdir(MODULEPATH, 0777);
         }
         if ($this->Parameter->_get('network_proxy') !== '') {
             $context = stream_context_create(array('http' => array('proxy' => 'tcp://' . $this->Parameter->_get('network_proxy'))));
             file_put_contents(MODULEPATH . "/module.zip", fopen($_POST['url'], 'r', false, $context));
         } else {
             file_put_contents(MODULEPATH . "/module.zip", fopen($_POST['url'], 'r'));
         }
         $zip = new ZipArchive();
         if ($zip->open(MODULEPATH . '/module.zip') === TRUE) {
             $zip->extractTo(MODULEPATH);
             $zip->close();
             $name = explode('-', $_POST['name']);
             chmod(MODULEPATH . '/module.zip', 0777);
             if (is_dir(MODULEPATH . '/' . $name[0])) {
                 delete_directory(MODULEPATH . '/' . $_POST['name']);
             } else {
                 rename(MODULEPATH . '/' . $_POST['name'], MODULEPATH . '/' . $name[0]);
             }
             if (file_exists(MODULEPATH . '/' . $name[0] . '/database.sql')) {
                 $queries = file(MODULEPATH . '/' . $name[0] . '/database.sql');
                 for ($i = 0; $i < count($queries); $i++) {
                     $this->db->query($queries[$i]);
                 }
             }
             $this->data['message_type'] = "success";
             $this->data['message'] = 'Module Installed into "' . MODULEPATH . '/' . $name[0] . '"';
             unlink(MODULEPATH . '/module.zip');
         }
     }
     $this->load->library('GitHubClient');
     $this->githubclient->setCredentials('brajola', 'h4n6iui0');
     $this->data['available_modules'] = $this->githubclient->repos->listUserRepositories('brajola');
     $this->render();
 }
Ejemplo n.º 13
0
 /**
  * Returns array('success'=>true) or array('error'=>'error message')
  */
 function handleUpload($uploadDirectory, $random_dir, $p_api_id, $replaceOldFile = FALSE)
 {
     $uploadDirectory .= '/' . $random_dir . '/';
     if (!is_writable($uploadDirectory)) {
         return array('error' => "Server error. Upload directory isn't writable.");
     }
     if (!$this->file) {
         return array('error' => 'No files were uploaded.');
     }
     $size = $this->file->getSize();
     if ($size == 0) {
         return array('error' => 'File is empty');
     }
     if ($size > $this->sizeLimit) {
         return array('error' => 'File is too large');
     }
     $pathinfo = pathinfo($this->file->getName());
     $filename = $pathinfo['filename'];
     //$filename = md5(uniqid());
     $ext = @$pathinfo['extension'];
     // hide notices if extension is empty
     if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
         $these = implode(', ', $this->allowedExtensions);
         return array('error' => 'File has an invalid extension, it should be one of ' . $these . '.');
     }
     $ext = $ext == '' ? $ext : '.' . $ext;
     if (!$replaceOldFile) {
         /// don't overwrite previous files that were uploaded
         while (file_exists($uploadDirectory . $filename . $ext)) {
             $filename .= rand(10, 99);
         }
     }
     $this->uploadName = $filename . $ext;
     if ($this->file->save($uploadDirectory . $filename . $ext)) {
         // If file pushed to temp directory, push it to MMC agent
         $filename = $filename . $ext;
         $upload_tmp_dir = sys_get_temp_dir();
         $files = array();
         // If mmc-agent is not on the same machine than apache server
         // send binary files with XMLRPC (base64 encoded)
         // else mmc-agent will directly get it from tmp directory
         $mmc_ip = xmlrpc_getMMCIP();
         $local_mmc = in_array($mmc_ip, array('127.0.0.1', 'localhost', $_SERVER['SERVER_ADDR'])) ? True : False;
         $filebinary = False;
         if (!$local_mmc) {
             $file = $upload_tmp_dir . '/' . $random_dir . '/' . $filename;
             // Read and put content of $file to $filebinary
             $filebinary = fread(fopen($file, "r"), filesize($file));
         }
         $files[] = array("filename" => $filename, "filebinary" => $local_mmc ? False : base64_encode($filebinary), "tmp_dir" => $local_mmc ? $upload_tmp_dir : False);
         $push_package_result = pushPackage($p_api_id, $random_dir, $files, $local_mmc);
         // Delete package from PHP /tmp dir
         delete_directory($upload_tmp_dir . '/' . $random_dir);
         if (!isXMLRPCError() and $push_package_result) {
             return array('success' => true);
         } else {
             return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
         }
     } else {
         return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
     }
 }
Ejemplo n.º 14
0
<?php

session_start();
if (!isset($_SESSION["user_id"])) {
    header("location: ../index.php");
    exit;
}
require_once "../../classes/db_class.php";
require_once "includes/functions.php";
$objDb = new db();
$data = array();
if (isset($_GET["id"]) && $_GET["id"] != "" && $_GET["id"] != 1) {
    $sqlLanguage = "select * from job_language where id = " . $_GET["id"] . "";
    $resultLang = $objDb->ExecuteQuery($sqlLanguage);
    $rowCount = mysql_num_rows($resultLang);
    if ($rowCount == 1) {
        $rsLang = mysql_fetch_object($resultLang);
        delete_directory("../../langues/" . $rsLang->language_name . "/");
        $sql = "ALTER TABLE `language` DROP `" . $rsLang->language_shortname . "`";
        $result = $objDb->ExecuteQuery($sql);
        $objDb->DeleteData("job_language", "id", $_GET["id"]);
    }
}
header("location:index.php");
/**
 * Deletes a folder and its contents (recursive)
 * TODO: error checking
 *
 * @param string $folder_path
 */
function delete_directory($dir)
{
    if (!file_exists($dir)) {
        return false;
    }
    if (!($dh = @opendir($dir))) {
        return false;
    }
    while (false !== ($obj = readdir($dh))) {
        if ($obj == '.' || $obj == '..') {
            continue;
        }
        if (!@unlink($dir . '/' . $obj)) {
            delete_directory($dir . '/' . $obj);
        }
    }
    @closedir($dh);
    return @rmdir($dir);
}
Ejemplo n.º 16
0
function deleteVideo($vid)
{
    global $config, $conn;
    $vid = intval($vid);
    $sql = "SELECT vdoname, channel FROM video WHERE VID = " . $vid . " LIMIT 1";
    $rs = $conn->execute($sql);
    $vdoname = $rs->fields['vdoname'];
    $chid = $rs->fields['channel'];
    if ($config['multi_server'] == '1') {
        delete_video_ftp($vid);
    }
    // Define All Video Formats Possible
    $vdo = $config['VDO_DIR'] . '/' . $vdoname;
    $flv = $config['FLVDO_DIR'] . '/' . $vid . '.flv';
    $iphone = $config['IPHONE_DIR'] . '/' . $vid . '.mp4';
    $mp4 = $config['HD_DIR'] . '/' . $vid . '.mp4';
    if (file_exists($flv)) {
        @chmod($flv, 0777);
        @unlink($flv);
    }
    if (file_exists($vdo)) {
        @chmod($vdo, 0777);
        @unlink($vdo);
    }
    if (file_exists($mp4)) {
        @chmod($mp4, 0777);
        @unlink($mp4);
    }
    if (file_exists($iphone)) {
        @chmod($iphone, 0777);
        @unlink($iphone);
    }
    // AVS thumbs format
    delete_directory(get_thumb_dir($vid));
    // Update Channel Video Totals
    $sql = "UPDATE channel SET total_videos = total_videos - 1 WHERE CHID = " . $chid;
    $conn->execute($sql);
    $tables = array('video_comments', 'favourite', 'playlist', 'video');
    foreach ($tables as $table) {
        $sql = "DELETE FROM " . $table . " WHERE VID = " . $vid;
        $conn->execute($sql);
    }
}
Ejemplo n.º 17
0
/**
 * Removes all user files
 *
 * @warning This only deletes the physical files and not their entities.
 * This will result in FileExceptions being thrown.  Don't use this function.
 *
 * @param ElggUser $user And ElggUser
 *
 * @return void
 */
function clear_user_files($user)
{
    global $CONFIG;
    $time_created = date('Y/m/d', (int) $user->time_created);
    $file_path = "{$CONFIG->dataroot}{$time_created}/{$user->guid}";
    if (file_exists($file_path)) {
        delete_directory($file_path);
    }
}
Ejemplo n.º 18
0
function upload_edit_profile_picture($params, $file)
{
    if (isset($params['id'])) {
        $profile = json_decode(httpResponse(dbUrl() . '/profiles/' . $params['id'], null, null), true);
        if ($profile != null and isset($profile['id']) == true) {
            $id = $params['id'];
            $mainDir = dirname(__DIR__);
            $fileFolder = '\\uploads\\profile\\' . $id;
            if (is_dir($mainDir . $fileFolder)) {
                delete_directory($mainDir . $fileFolder);
            }
            if (mkdir($mainDir . $fileFolder, 0755)) {
                $name_file = basename($file['file']['name']);
                $type = substr($name_file, strripos($name_file, '.'));
                $name_file = date('YmdHisu') . $type;
                $uploadFile = $mainDir . $fileFolder . '\\' . $name_file;
                if (move_uploaded_file($file['file']['tmp_name'], $uploadFile)) {
                    $otherName = '/uploads/profile/' . $id . '/' . $name_file;
                    $file['name'] = $otherName;
                    $profile['image'] = $otherName;
                    $changed_item = json_decode(httpResponse(dbUrl() . '/profiles/' . $params['id'], 'PUT', json_encode($profile)), true);
                    return json_encode(array('result' => 'file saved', 'file' => $file));
                } else {
                    return json_encode(array('error' => 'Possible attacks via file download'));
                }
            } else {
                return json_encode(array('error' => 'Unable create directory '));
            }
        } else {
            return json_encode(array('error' => 'Profile does not exist'));
        }
    } else {
        return json_encode(array('error' => 'Profile id does not exist'));
    }
}
Ejemplo n.º 19
0
 public function delete()
 {
     qdb("DELETE FROM `PREFIX_packages` WHERE `id` = %d", $this->id);
     delete_directory(dirname(__FILE__) . "/../packages/" . $this->name);
     self::update_lists();
 }
Ejemplo n.º 20
0
function generatePDFByResult($result, $targetDirectory, $sectionheader, $extrainfo = "PDF output")
{
    global $config;
    $body_string = "";
    while ($row = mysql_fetch_row($result)) {
        $body_string .= latexAppendQuestion($row[0], $row[1], $row[2], $row[3]);
    }
    if ($body_string == "") {
        $body_string = "No content in this application.";
    }
    if (substr($targetDirectory, -1) != "/") {
        //add trailing slash if not present
        $targetDirectory .= "/";
    }
    //make a new file for this submission
    do {
        $outFile = uid(32);
    } while (file_exists($targetDirectory . $outFile));
    //make temporary directory to store the output file
    mkdir($targetDirectory . $outFile . "/");
    $fin = fopen($targetDirectory . "template.tex", 'r');
    $fout = fopen($targetDirectory . $outFile . "/" . $outFile . ".tex", 'w');
    while ($line = fgets($fin)) {
        $line = str_replace('$TIME$', timeString(), $line);
        $line = str_replace('$EXTRAINFO$', $extrainfo, $line);
        $line = str_replace('$ORGANIZATION$', $config['organization_name'], $line);
        $line = str_replace('$SECTIONNAME$', $sectionheader, $line);
        $line = str_replace('$BODY$', $body_string, $line);
        fwrite($fout, $line);
    }
    fclose($fin);
    fclose($fout);
    //make the PDF
    $config = $GLOBALS['config'];
    $cdCommand = "cd " . $targetDirectory . $outFile;
    $pdfCommand = $config['latex_path'] . " --interaction=nonstopmode " . $outFile . ".tex";
    //execute pdf twice for lastpage to work (page # out of n)
    exec($cdCommand . " && " . $pdfCommand . " && " . $pdfCommand);
    if (!file_exists($targetDirectory . $outFile . "/" . $outFile . ".pdf")) {
        //failed; PDF not created
        //delete temp directory
        //delete_directory($targetDirectory . $outFile); //no trailing slash on outFile
        return array(FALSE, "generation failure");
    }
    //move the PDF and delete temporary directory
    rename($targetDirectory . $outFile . "/" . $outFile . ".pdf", $targetDirectory . $outFile . ".pdf");
    delete_directory($targetDirectory . $outFile);
    //no trailing slash on outFile
    return array(TRUE, $outFile);
}
Ejemplo n.º 21
0
 // Esto se usar con Album visible/no visible
 if ($act == "borrarAlbum") {
     updateTable("albumes", "a_status = 'N'", "a_id = '{$_REQUEST['a_id']}' AND a_user_id = '{$_COOKIE['id']}'");
     $arreglo[] = array('resp' => "Se ha enviado la información");
     echo json_encode($arreglo);
 }
 if ($act == "deleteAlbum") {
     $userInfo = getCurrentUser();
     $currentUser = $userInfo->id;
     $albumToDelete = listAll("albumes", "WHERE a_id = " . $_REQUEST['a']);
     $albumToDelete = mysql_fetch_object($albumToDelete);
     if ($albumToDelete->a_user_id == $currentUser) {
         // Delete images
         $albumPath = 'profiles/' . sha1($currentUser) . '/' . sha1($albumToDelete->a_id);
         if (file_exists('../' . $albumPath)) {
             $deletedDirectory = delete_directory($albumPath);
         } else {
             $deletedDirectory = true;
         }
         if ($deletedDirectory) {
             // Delete db album's photos
             eliminarRegistro('albumes_det', 'ad_a_id', $albumToDelete->a_id);
             // Delete album
             eliminarRegistro('albumes', 'a_id', $albumToDelete->a_id);
             // Reactive referrals' credit if exists
             $newCredit = Credit::renewCredit($userInfo->id, $albumToDelete->a_id);
             $userInfo = getUserInfo($_COOKIE['id']);
             $app->redirect($app->getConfig()->getUrl("perfil?us=" . $userInfo->act_code . "&act=portafolio"));
         }
     }
 }
Ejemplo n.º 22
0
/**
 * Removes all entity files
 *
 * @warning This only deletes the physical files and not their entities.
 * This will result in FileExceptions being thrown.  Don't use this function.
 *
 * @warning This must be kept in sync with \ElggDiskFilestore.
 *
 * @todo Remove this when all files are entities.
 *
 * @param \ElggEntity $entity An \ElggEntity
 *
 * @return void
 * @access private
 */
function _elgg_clear_entity_files($entity)
{
    $dir = new \Elgg\EntityDirLocator($entity->guid);
    $file_path = elgg_get_config('dataroot') . $dir;
    if (file_exists($file_path)) {
        delete_directory($file_path);
    }
}
function delete_directory($path)
{
    echo "Deleting Contents Of: {$path}<br /><br />";
    if (is_file($path)) {
        unlink($path);
        echo "Deleted File: {$path}<br />";
        return true;
    }
    $files = array_diff(scandir($path), array('.', '..'));
    foreach ($files as $file) {
        if (is_dir("{$path}/{$file}")) {
            delete_directory("{$path}/{$file}");
        } else {
            if (unlink("{$path}/{$file}")) {
                echo "Deleted File: {$path}/{$file}<br />";
            }
        }
    }
    if (rmdir($path)) {
        echo "Deleted directory: {$path}<br />";
    }
    return true;
}
Ejemplo n.º 24
0
function extract_video_thumbs($video_path, $video_id)
{
    global $config, $conn;
    // Logfile
    $logfile = $config['LOG_DIR'] . '/' . $video_id . '.thumbs.log';
    @chmod($logfile, 0777);
    @unlink($logfile);
    // Default Thumbs Width & Height
    $thumb_width = $config['img_max_width'];
    $thumb_height = $config['img_max_height'];
    // Get Duration of Video from Database
    $duration = get_video_duration($video_path, $video_id);
    // Only continue if source video exists
    if (file_exists($video_path)) {
        // Temp & Final Thumbnails Directories
        $temp_thumbs_folder = $config['TMP_DIR'] . '/thumbs/' . $video_id;
        $final_thumbs_folder = get_thumb_dir($video_id);
        // Create Thumbs Directories
        @mkdir($temp_thumbs_folder, 0777);
        @mkdir($final_thumbs_folder, 0777);
        // Duration - set se = start/end
        if ($duration > 5) {
            $seconds = $duration - 4;
            $se = 2;
        } elseif ($duration > 3) {
            $seconds = $duration - 2;
            $se = 1;
        } elseif ($duration > 2) {
            $seconds = $duration - 1;
            $se = 0.5;
        } else {
            $seconds = $duration;
            $se = 0;
        }
        // Divided by 20 thumbs
        $timeseg = $seconds / 20;
        // Loop for 20 thumbs
        for ($i = 0; $i <= 20; $i++) {
            if ($i == 0) {
                // Thumbnail Size
                $mplayer_scale = "scale=640:360";
                $ffmpeg_scale = "640x360";
                // Destination
                $final_thumbnail = $final_thumbs_folder . '/default.jpg';
                // Get Seek Time
                $ss = 5 * $timeseg + $se;
            } else {
                // Thumbnail Size
                $mplayer_scale = "scale=" . $thumb_width . ":" . $thumb_height . "";
                $ffmpeg_scale = $thumb_width . "x" . $thumb_height;
                // Destination
                $final_thumbnail = $final_thumbs_folder . '/' . $i . '.jpg';
                // Get Seek Time
                $ss = $i * $timeseg + $se;
            }
            // Work out seconds to hh:mm:ss format
            $hms = "";
            $hours = intval($ss / 3600);
            $hms .= str_pad($hours, 2, "0", STR_PAD_LEFT) . ':';
            $minutes = intval($ss / 60 % 60);
            $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':';
            $secs = intval($ss % 60);
            $hms .= str_pad($secs, 2, "0", STR_PAD_LEFT);
            $seek = $hms;
            // Temporary filename convention. used by ffmpeg only.
            $temp_thumbs = $temp_thumbs_folder . '/%08d.jpg';
            // Temporary Thumbnail File
            $temp_thumb_file = $temp_thumbs_folder . '/00000001.jpg';
            // Set Permission and Delete Temporary Thumbnail File
            @chmod($temp_thumb_file, 0777);
            @unlink($temp_thumb_file);
            // Thumbnails extraction commands
            if ($config['thumbs_tool'] == 'ffmpeg') {
                // FFMPEG Command
                $cmd = $config['ffmpeg'] . " -ss " . $seek . " -i '" . $video_path . "' -r 1 -s " . $ffmpeg_scale . " -vframes 1 -an -vcodec mjpeg -y " . $temp_thumbs;
            } else {
                // Mplayer Command
                $cmd = $config['mplayer'] . " -zoom " . $video_path . " -ss " . $seek . " -nosound -frames 1 -vf " . $mplayer_scale . " -vo jpeg:outdir=" . $temp_thumbs_folder;
            }
            // Send data to logfile
            log_conversion($logfile, $cmd);
            // Execute Command
            exec($cmd, $output);
            // Send data to logfile
            log_conversion($logfile, implode("\n", $output));
            // Check if file exists
            if (file_exists($temp_thumb_file)) {
                copy($temp_thumb_file, $final_thumbnail);
                // Set permission
                @chmod($temp_thumb_file, 0777);
            }
        }
        // Delete Temporary Thumbnail
        delete_directory($temp_thumbs_folder);
        // Figure out which was last thumb
        $i = 20;
        // Update Thumbs count in database
        $sql = "UPDATE video SET thumb = '1', thumbs = '" . $i . "' WHERE VID = '" . $video_id . "' LIMIT 1";
        $conn->execute($sql);
    }
    return;
}
Ejemplo n.º 25
0
function minecraftRestoreWorld($service_id, $label)
{
    global $config;
    $label = stripAlphaNumeric($label);
    //get the identifier
    $id = stripAlphaNumeric(getServiceParam($service_id, "id"));
    if ($id === false) {
        return "Error: the identifier for this service is not set.";
    }
    //require stopped to restore
    $pid = getServiceParam($service_id, "pid");
    if ($pid !== false && $pid != 0) {
        return "Error: please stop the server before restoring the world.";
    }
    //check for existence
    $jail = jailEnabled($service_id);
    $filename = $label . ".uxbakzip";
    if ($jail) {
        $path = jailPath($service_id) . $filename;
    } else {
        $path = $config['minecraft_path'] . $id . "/" . $filename;
    }
    if ($jail && !jailFileExists($filename) || !$jail && !file_exists($path)) {
        return "Error: the requested backup doesn't appear to exist.";
    }
    //unzip and move the world directory
    if ($jail) {
        jailExecute($service_id, "unzip " . escapeshellarg(jailPath($service_id) . $label . ".uxbakzip") . " -d " . escapeshellarg(jailPath($service_id)));
        jailExecute($service_id, "rm -r " . escapeshellarg(jailPath($service_id) . "world"));
        jailFileMove($service_id, "world_tmp", "world");
    } else {
        exec("unzip " . escapeshellarg($config['minecraft_path'] . $id . "/" . $label . ".uxbakzip") . " -d " . escapeshellarg($config['minecraft_path'] . $id));
        delete_directory($config['minecraft_path'] . $id . "/world");
        rename($config['minecraft_path'] . $id . "/world_tmp", $config['minecraft_path'] . $id . "/world");
    }
    return true;
}
Ejemplo n.º 26
0
function delete_directory($item_path, $mode)
{
    if ($mode == 0) {
        $dh = opendir($item_path);
        while (false !== ($item = readdir($dh))) {
            $dir_content[] = $item;
        }
        closedir($dh);
        array_shift($dir_content);
        array_shift($dir_content);
        foreach ($dir_content as $val) {
            $sub_item_path = $item_path . $val;
            if (is_file($sub_item_path)) {
                unlink($sub_item_path);
            } elseif (is_dir($sub_item_path)) {
                delete_directory($sub_item_path . '/', 0);
            }
        }
        rmdir($item_path);
    } elseif ($mode == 1) {
        global $ftp_stream;
        $content = ftp_rawlist($ftp_stream, $item_path);
        if (!in_array(substr($content[0], 0, 1), array('d', '-'))) {
            //check if the ftp server is an IIS FTP server
            $iis_ftp = TRUE;
        }
        $item_name_index = $iis_ftp ? 3 : 8;
        $item_size_index = $iis_ftp ? 2 : 4;
        foreach ($content as $key => $val) {
            $item = $iis_ftp ? preg_split("/[\\s]+/", $val, 4) : preg_split("/[\\s]+/", $val, 9);
            if ($item[2] == '<DIR>' || substr($item[0], 0, 1) == 'd') {
                if (!in_array($item[$item_name_index], array('.', '..'))) {
                    $folders[] = $item[$item_name_index];
                }
            } else {
                $files[] = $item[$item_name_index];
            }
        }
        foreach ($files as $val) {
            ftp_delete($ftp_stream, $item_path . $val);
        }
        foreach ($folders as $val) {
            delete_directory($item_path . $val . '/', 1);
        }
        ftp_rmdir($ftp_stream, $item_path);
    }
}
Ejemplo n.º 27
0
    header('Location: index.php');
}
if (optional_param('dis', '', PARAM_ALPHAEXT) == 'fl_count') {
    $error[] = "Either your account is inactive or your access permission has been revoked. Please contact the school administration.\n";
}
if (optional_param('dis', '', PARAM_ALPHAEXT) == 'assoc_mis') {
    $error[] = "No student is associated with the parent. Please contact the school administration.";
}
if (isset($_GET['ins'])) {
    $install = optional_param('ins', '', PARAM_ALPHAEXT);
}
if ($install == 'comp') {
    if (is_dir('install')) {
        $dir = 'install/';
        // IMPORTANT: with '/' at the end
        $remove_directory = delete_directory($dir);
    }
}
require_once 'Warehouse.php';
if (optional_param('modfunc', '', PARAM_ALPHAEXT) == 'logout') {
    if ($_SESSION) {
        DBQuery("DELETE FROM log_maintain WHERE SESSION_ID = '" . $_SESSION['X'] . "'");
        header("Location: {$_SERVER['PHP_SELF']}?modfunc=logout" . ($_REQUEST['reason'] ? '&reason=' . $_REQUEST['reason'] : ''));
    }
    session_destroy();
}
if (optional_param('register', '', PARAM_NOTAGS)) {
    if (optional_param('R1', '', PARAM_ALPHA) == 'register') {
        header("Location:register.php");
    }
}
Ejemplo n.º 28
0
 /**
  * delete method
  *
  * @param string $id
  * @return void
  */
 public function delete($id = null)
 {
     /*
     			!!! TODO: pcastconfig --sync_library !!!
     */
     $this->Item->id = $id;
     if (!$this->Item->exists()) {
         throw new NotFoundException(__('Invalid item'));
     }
     if (isset($this->request->named['confirmed']) && $this->request->named == true) {
         $item = $this->Item->find('first', array('conditions' => array('Item.id' => $id)));
         // trying to delete data from harddisk
         $path = Configure::read('Fdmngr.library-path');
         $path .= $item['Item']['path'];
         if ($path == Configure::read('Fdmngr.library-path')) {
             die('Shit happens: ' . $path);
         }
         $deletedDir = delete_directory($path);
         // if actual asset was deleted, delete db entry, otherwise set db item to 'deleted'
         if ($deletedDir) {
             $this->Item->delete();
             // tried cascading, didn't work, doing it by hand...
             $this->Item->Asset->deleteAll(array('Asset.item_id' => $id));
         } else {
             $this->Item->id = $id;
             $this->Item->saveField('deleted', true);
         }
         $this->redirect('/items/index');
     } else {
         $item = $this->Item->find('first', array('contain' => array('Asset', 'Feed'), 'conditions' => array('Item.id' => $id)));
         $this->set(compact('item'));
     }
     /*		if ($this->Item->delete()) {
     			$this->flash(__('Item deleted'), array('action' => 'index'));
     		}
     		$this->flash(__('Item was not deleted'), array('action' => 'index'));
     		$this->redirect(array('action' => 'index')); */
 }
Ejemplo n.º 29
0
 /**
  * Delete directory function used to remove old directories during upgrade from versions prior to 1.4
  *
  * @param mixed $dirname
  */
 function delete_directory($dirname)
 {
     if (is_dir($dirname)) {
         $dir_handle = opendir($dirname);
     }
     if (!$dir_handle) {
         return false;
     }
     while ($file = readdir($dir_handle)) {
         if ($file != '.' && $file != '..') {
             if (!is_dir($dirname . '/' . $file)) {
                 unlink($dirname . '/' . $file);
             } else {
                 delete_directory($dirname . '/' . $file);
             }
         }
     }
     closedir($dir_handle);
     rmdir($dirname);
     return true;
 }
Ejemplo n.º 30
0
function delete_directory($dirname, $maintain_dir = false)
{
    if (is_dir($dirname)) {
        $dir_handle = opendir($dirname);
    }
    if (!$dir_handle) {
        return false;
    }
    while ($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            if (!is_dir($dirname . "/" . $file)) {
                unlink($dirname . "/" . $file);
            } else {
                delete_directory($dirname . '/' . $file, $maintain_dir);
            }
        }
    }
    closedir($dir_handle);
    if (!$maintain_dir) {
        rmdir($dirname);
    }
    return true;
}