Example #1
0
function deleteData()
{
    global $wpdb;
    delete_option('asgarosforum_options');
    delete_option('asgarosforum_db_version');
    // For site options in multisite
    delete_site_option('asgarosforum_options');
    delete_site_option('asgarosforum_db_version');
    // Delete user meta data
    delete_metadata('user', 0, 'asgarosforum_moderator', '', true);
    delete_metadata('user', 0, 'asgarosforum_banned', '', true);
    delete_metadata('user', 0, 'asgarosforum_subscription_topic', '', true);
    delete_metadata('user', 0, 'asgarosforum_subscription_forum', '', true);
    delete_metadata('user', 0, 'asgarosforum_subscription_global_topics', '', true);
    delete_metadata('user', 0, 'asgarosforum_unread_cleared', '', true);
    delete_metadata('user', 0, 'asgarosforum_unread_exclude', '', true);
    // Delete terms
    $terms = $wpdb->get_col('SELECT t.term_id FROM ' . $wpdb->terms . ' AS t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = "asgarosforum-category";');
    foreach ($terms as $term) {
        wp_delete_term($term, 'asgarosforum-category');
    }
    // Drop custom tables
    $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_forums;");
    $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_threads;");
    $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_posts;");
    // Delete uploaded files
    $upload_dir = wp_upload_dir();
    $upload_path = $upload_dir['basedir'] . '/asgarosforum/';
    recursiveDelete($upload_path);
    // Delete themes
    $theme_path = WP_CONTENT_DIR . '/themes-asgarosforum';
    recursiveDelete($theme_path);
    // Delete data which has been used in old versions of the plugin.
    delete_metadata('user', 0, 'asgarosforum_lastvisit', '', true);
}
Example #2
0
 /**
  * @param $name
  */
 public function clearThumbnail($name)
 {
     $dir = $this->getImageThumbnailSavePath() . "/thumb__" . $name;
     if (is_dir($dir)) {
         recursiveDelete($dir);
     }
 }
Example #3
0
function recursiveDelete($typeid)
{
    $res = sqlStatement("SELECT procedure_type_id FROM " . "procedure_type WHERE parent = '{$typeid}'");
    while ($row = sqlFetchArray($res)) {
        recursiveDelete($row['procedure_type_id']);
    }
    sqlStatement("DELETE FROM procedure_type WHERE " . "procedure_type_id = '{$typeid}'");
}
function recursiveDelete($id, $db)
{
    $db_conn = $db;
    $query = $db->query("select * from tbl_menu where parent = '" . $id . "' ");
    if ($query->rowCount() > 0) {
        while ($current = $query->fetch(PDO::FETCH_ASSOC)) {
            recursiveDelete($current['id'], $db_conn);
        }
    }
    $db->exec("delete from tbl_menu where id = '" . $id . "' ");
}
Example #5
0
function recursiveDelete($str)
{
    if (is_file($str)) {
        return @unlink($str);
    } elseif (is_dir($str)) {
        $scan = glob(rtrim($str, '/') . '/*');
        foreach ($scan as $index => $path) {
            recursiveDelete($path);
        }
        return @rmdir($str);
    }
}
Example #6
0
/**
 * Delete a file or recursively delete a directory
 *
 * @param string $str Path to file or directory
 */
function recursiveDelete($str)
{
    //diagrafei anadromika ta pada mesa sto path
    if (is_file($str)) {
        return @unlink($str);
    } elseif (is_dir($str)) {
        $scan = glob(rtrim($str, '/') . '/*');
        foreach ($scan as $index => $path) {
            recursiveDelete($path);
        }
        return @rmdir($str);
    }
}
Example #7
0
/**
 * Delete a file or recursively delete a directory
 *
 * @param string $str Path to file or directory
 */
function recursiveDelete($str)
{
    if (is_file($str)) {
        return @unlink($str);
    } elseif (is_dir($str)) {
        $scan = glob(rtrim($str, '/') . '/{,.}*', GLOB_BRACE);
        foreach ($scan as $path) {
            if (!preg_match("@/\\.\\.?\$@")) {
                recursiveDelete($path);
            }
        }
        return @rmdir($str);
    }
}
Example #8
0
/**
 * Recursively delete a directory.
 *
 * @param string $path The directory path to delete.
 */
function recursiveDelete($path)
{
    if (is_dir($path)) {
        $directory = dir($path);
        while (false !== ($entry = $directory->read())) {
            if ($entry != '.' && $entry != '..') {
                recursiveDelete($path . '/' . $entry);
            }
        }
        rmdir($path);
    } else {
        unlink($path);
    }
}
Example #9
0
function verifyPGPKey($content, $email)
{
    global $config;
    //allow blank "keys" if this is set
    //this means that encryption for $email will be disabled by the cron if it
    // was enabled originally
    if ($config['pgpverify_allowblank'] && trim($content) == '') {
        return true;
    }
    require_once "Crypt/GPG.php";
    //try to create a random subdirectory of $config['pgpverify_tmpdir']
    do {
        $path = $config['pgpverify_tmpdir'] . '/' . uid(16);
    } while (file_exists($path));
    $result = @mkdir($path);
    if ($result === false) {
        if ($config['debug']) {
            die("Failed to create directory [" . $path . "] for PGP verification.");
        } else {
            return false;
        }
    }
    $gpg = new Crypt_GPG(array('homedir' => $path));
    //import the key to our GPG temp directory
    try {
        $gpg->importKey($content);
    } catch (Crypt_GPG_NoDataException $e) {
        //user supplied an invalid key!
        recursiveDelete($path);
        return false;
    }
    //verify the email address matches
    $keys = $gpg->getKeys();
    if (count($keys) != 1) {
        if ($config['debug']) {
            die("Error in PGP verification: key count is " . count($keys) . "!");
        } else {
            recursiveDelete($path);
            return false;
        }
    }
    $userIds = $keys[0]->getUserIds();
    if (count($userIds) != 1 || strtolower($userIds[0]->getEmail()) != strtolower($email)) {
        recursiveDelete($path);
        return false;
    }
    recursiveDelete($path);
    return true;
}
Example #10
0
 /**
  * @return void
  */
 public function clearThumbnails($force = false)
 {
     if ($this->_dataChanged || $force) {
         // clear the thumbnail custom settings
         $this->setCustomSetting("thumbnails", null);
         // video thumbnails and image previews
         $files = glob(PIMCORE_TEMPORARY_DIRECTORY . "/video-image-cache/video_" . $this->getId() . "__*");
         if (is_array($files)) {
             foreach ($files as $file) {
                 unlink($file);
             }
         }
         recursiveDelete($this->getImageThumbnailSavePath());
         recursiveDelete($this->getVideoThumbnailSavePath());
     }
 }
function moveFiles($src, $dst)
{
    if (file_exists($dst)) {
        recursiveDelete($dst);
    }
    if (is_dir($src)) {
        mkdir($dst);
        $files = scandir($src);
        foreach ($files as $file) {
            if ($file != "." && $file != "..") {
                moveFiles("{$src}/{$file}", "{$dst}/{$file}");
            }
        }
    } elseif (file_exists($src)) {
        copy($src, $dst);
    }
}
    @fclose($fpc);
}
if (!file_exists($repertip . 'index.html')) {
    $fpb = @fopen($repertip . 'index.html', "a+");
    @fclose($fpb);
    $creafile = 1;
}
// File creation
if ($creafile == 1) {
    $fpd = @fopen($repertip . $lastaccess, "a+");
    @fclose($fpd);
}
//Debug Mode
if ($debugdaily == 1) {
    if (file_exists($repertip)) {
        recursiveDelete($repertip);
    }
    $creafile = 1;
}
if ($creafile == 1) {
    $db = JFactory::getDBO();
    $doc = JFactory::getDocument();
    // Include Style & Script to show PopUp
    $doc->addStyleSheet(JURI::Root(true) . '/modules/mod_jq-dailypop/style/css.css');
    $doc->addStyleSheet(JURI::Root(true) . '/modules/mod_jq-dailypop/style/' . $style . '/css.css');
    //Modificado para que el PopUp aparezc cuando la URL indique el error.
    $url = $_SERVER['REQUEST_URI'];
    //Obtenemos la URL de la página actual.
    $error = substr($url, -11);
    //Substraemos únicamente el index.php?e que indica el error de búsqueda.
    $arreglo = [1 => "BLA", 2 => "BNS", 3 => "BRM", 4 => "CAJ", 5 => "CCS", 6 => "CBL", 7 => "CZE", 8 => "CUM", 9 => "VIG", 10 => "GDO", 11 => "LSP", 12 => "MAR", 13 => "PMV", 14 => "MUN", 15 => "MRD", 16 => "PYH", 17 => "PZO", 18 => "SFD", 19 => "SOM", 20 => "STD", 21 => "VLN", 22 => "VLV"];
 public function importZipAction()
 {
     $success = true;
     $importId = uniqid();
     $tmpDirectory = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/asset-zip-import-" . $importId;
     $zip = new ZipArchive();
     if ($zip->open($_FILES["Filedata"]["tmp_name"]) === TRUE) {
         $zip->extractTo($tmpDirectory);
         $zip->close();
     }
     $this->importFromFileSystem($tmpDirectory, $this->_getParam("parentId"));
     // cleanup
     recursiveDelete($tmpDirectory);
     $this->_helper->json(array("success" => $success));
 }
<?php

$dir = PIMCORE_DOCUMENT_ROOT . "/PIMCORE_DEPLOYMENT_DIRECTORY";
if (is_dir($dir)) {
    recursiveDelete($dir);
}
Example #15
0
 public static function tearDownAfterClass()
 {
     recursiveDelete('/tmp/gitlist');
 }
Example #16
0
/**
 * Recursive delete
 *
 * @param string $path
 * @return bool
 */
function recursiveDelete($path)
{
    if (is_dir($path)) {
        $files = glob($path . '/' . '*');
        foreach ($files as $file) {
            if (is_dir($file)) {
                recursiveDelete($file);
            } else {
                if (is_file($file)) {
                    unlink($file);
                }
            }
        }
        return rmdir($path);
    } else {
        if (is_file($path)) {
            return unlink($path);
        }
    }
}
Example #17
0
 public function delete() {
     try {
         recursiveDelete(Projects::$folder.$this->slug);
     } catch (Exception $e) {
         throw new Exception("Cannot delete project ".$this->slug);
     }
 }
Example #18
0
                }
            }
            $error_log .= "\r\n------------------------------ \r\n\r\n\r\n\r\n\r\n";
            ## Remove the source folder
            @unlink($destination_path);
            if ($fail) {
                if (!empty($error_log)) {
                    $fp = fopen(CC_ROOT_DIR . '/backup/upgrade_error_log', 'a+');
                    fwrite($fp, $error_log);
                    fclose($fp);
                }
                $GLOBALS['main']->setACPWarning($lang['maintain']['files_upgrade_fail']);
                httpredir('?_g=maintenance&node=index#upgrade');
            } elseif ($_POST['force']) {
                ## Try to delete setup folder
                recursiveDelete(CC_ROOT_DIR . '/setup');
                unlink(CC_ROOT_DIR . '/setup');
                ## If that failes we try an obscure rename
                if (file_exists(CC_ROOT_DIR . '/setup')) {
                    rename(CC_ROOT_DIR . '/setup', CC_ROOT_DIR . '/setup_' . md5(time() . $_GET['upgrade']));
                }
                $GLOBALS['main']->setACPNotify($lang['maintain']['current_version_restored']);
                $GLOBALS['cache']->clear();
                httpredir('?_g=maintenance&node=index#upgrade');
            } else {
                httpredir(CC_ROOT_REL . 'setup/index.php?autoupdate=1');
            }
        }
    }
    // end if $contents
}
Example #19
0
 /**
  *
  */
 public static function cleanup()
 {
     // remove database tmp table
     $db = Db::get();
     $db->query("DROP TABLE IF EXISTS `" . self::$tmpTable . "`");
     //delete tmp data
     recursiveDelete(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update", true);
 }
Example #20
0
 /**
  * Deletes file from filesystem
  */
 protected function deletePhysicalFile()
 {
     $fsPath = $this->getFileSystemPath();
     if ($this->getType() != "folder") {
         if (is_file($fsPath) && is_writable($fsPath)) {
             unlink($fsPath);
         }
     } else {
         if (is_dir($fsPath) && is_writable($fsPath)) {
             recursiveDelete($fsPath, true);
         }
     }
 }
Example #21
0
/**
 * Recursively delete a directory
 *
 * @param string $dir Directory name
 * @param boolean $deleteRootToo Delete specified top-level directory as well
 */
function recursiveDelete($directory, $empty = true)
{
    if (substr($directory, -1) == "/") {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return false;
    } elseif (!is_readable($directory)) {
        return false;
    } else {
        $directoryHandle = opendir($directory);
        while ($contents = readdir($directoryHandle)) {
            if ($contents != '.' && $contents != '..') {
                $path = $directory . "/" . $contents;
                if (is_dir($path)) {
                    recursiveDelete($path);
                } else {
                    unlink($path);
                }
            }
        }
        closedir($directoryHandle);
        if ($empty == true) {
            if (!rmdir($directory)) {
                return false;
            }
        }
        return true;
    }
}
Example #22
0
         echo 'error||' . translate("The folder path was tampered with!");
         break;
     }
     break;
 case "delete":
     $files = $_POST["files"];
     $result = true;
     foreach ($files as $key => $file) {
         // Check if file path is valid
         $file = urldecode($file);
         if (!($file = checkpath($file, $uploadpath))) {
             echo 'error||' . translate("The folder path was tampered with!");
             break;
         }
         // Delete file
         if (!recursiveDelete(DOCUMENTROOT . $file)) {
             $result = false;
         }
     }
     if ($result) {
         echo 'success||' . sprintf(translate("%d file(s) successfully removed!"), count($files));
     } else {
         echo 'error||' . translate("Deleting file failed!");
     }
     break;
 case "create_folder":
     $folderpath = urldecode($_POST["folderpath"]);
     $foldername = urldecode($_POST["foldername"]);
     //Check if foldername isn't empty
     if ($foldername == "") {
         echo 'error||' . translate("Creating new folder failed!");
Example #23
0
 /**
  * @return void
  */
 public function clearThumbnails($force = false)
 {
     if ($this->_dataChanged || $force) {
         // video thumbnails and image previews
         $files = glob(PIMCORE_TEMPORARY_DIRECTORY . "/document-image-cache/document_" . $this->getId() . "__*");
         if (is_array($files)) {
             foreach ($files as $file) {
                 unlink($file);
             }
         }
         recursiveDelete($this->getImageThumbnailSavePath());
     }
 }
Example #24
0
        $record = array('doc_lang' => $_SESSION['setup']['long_lang_identifier'], 'doc_home' => 1, 'doc_name' => $home['title'], 'doc_content' => str_replace('images/uploads', 'images/source', $home['copy']));
        $db->insert('CubeCart_documents', $record);
    }
}
$from = CC_ROOT_DIR . '/images/uploads';
$to = CC_ROOT_DIR . '/images/source';
$regex_slash_keep = '#[^\\w\\.\\-\\_\\/]#i';
$regex_slash_remove = '#[^\\w\\.\\-\\_]#i';
## Delete the images/source/ folder from the upload (it should be empty)
if (file_exists($to)) {
    recursiveDelete($to);
}
if (file_exists($from) && is_writable(dirname($from))) {
    if (!file_exists($to) && rename($from, $to)) {
        ## Delete thumbs/ dir recursively
        recursiveDelete($to . '/' . 'thumbs');
    } else {
        ## NOTIFY: They need to update manually
        $errors[] = $strings['setup']['error_rename_images'];
    }
}
## rename images and folder acordingly
function update_image_paths($pattern, $flags = 0)
{
    global $regex_slash_keep;
    foreach (glob($pattern, $flags) as $filename) {
        rename($filename, preg_replace($regex_slash_keep, '_', $filename));
    }
    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        update_image_paths($dir . '/' . basename($pattern), $flags);
    }
Example #25
0
 /**
  * @param $id
  * @param $type
  */
 public static function delete($id, $type)
 {
     if ($type == "plugin") {
         $pluginDir = PIMCORE_PLUGINS_PATH . "/" . $id;
         if (is_writeable($pluginDir)) {
             recursiveDelete($pluginDir, true);
         }
     } else {
         if ($type == "brick") {
             $brickDirs = self::getBrickDirectories();
             $brickDir = $brickDirs[$id];
             if (is_writeable($brickDir)) {
                 recursiveDelete($brickDir, true);
             }
         }
     }
 }
 public function clearTemporaryFilesAction()
 {
     $this->checkPermission("clear_temp_files");
     // public files
     recursiveDelete(PIMCORE_TEMPORARY_DIRECTORY, false);
     // system files
     recursiveDelete(PIMCORE_SYSTEM_TEMP_DIRECTORY, false);
     // recreate .dummy files # PIMCORE-2629
     \Pimcore\File::put(PIMCORE_TEMPORARY_DIRECTORY . "/.dummy", "");
     \Pimcore\File::put(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/.dummy", "");
     $this->_helper->json(array("success" => true));
 }
Example #27
0
function wrk_restore($backupfile)
{
    $path = "/run/" . $backupfile;
    $cmdstring = "tar xzf " . $path . " --overwrite --directory /";
    if (sysCmd($cmdstring)) {
        recursiveDelete($path);
    }
}
Example #28
0
 /**
  * @return void
  */
 public function delete()
 {
     if ($this->getId() == 1) {
         throw new Exception("root-node cannot be deleted");
     }
     Pimcore_API_Plugin_Broker::getInstance()->preDeleteAsset($this);
     // remove childs
     if ($this->hasChilds()) {
         foreach ($this->getChilds() as $child) {
             $child->delete();
         }
     }
     // remove file on filesystem
     $fsPath = PIMCORE_ASSET_DIRECTORY . $this->getPath() . $this->getFilename();
     if ($this->getType() != "folder") {
         if (is_file($fsPath) && is_writable($fsPath)) {
             unlink($fsPath);
         }
     } else {
         if (is_dir($fsPath) && is_writable($fsPath)) {
             recursiveDelete($fsPath, true);
         }
     }
     $versions = $this->getVersions();
     foreach ($versions as $version) {
         $version->delete();
     }
     // remove permissions
     $this->getResource()->deleteAllPermissions();
     // remove all properties
     $this->getResource()->deleteAllProperties();
     // remove all tasks
     $this->getResource()->deleteAllTasks();
     // remove dependencies
     $d = $this->getDependencies();
     $d->cleanAllForElement($this);
     // remove from resource
     $this->getResource()->delete();
     // empty object cache
     $this->clearDependedCache();
     //set object to registry
     Zend_Registry::set("asset_" . $this->getId(), null);
 }
Example #29
0
 public function doExportJobsAction()
 {
     $exportSession = new Zend_Session_Namespace("element_export");
     $exportName = "export_" . Zend_Session::getId();
     $exportDir = PIMCORE_WEBSITE_PATH . "/var/tmp/" . $exportName;
     if (!$exportSession->elements) {
         $exportSession->type = $this->_getParam("type");
         $exportSession->id = $this->_getParam("id");
         $exportSession->includeRelations = (bool) $this->_getParam("includeRelations");
         $exportSession->recursive = (bool) $this->_getParam("recursive");
         $exportSession->counter = 0;
         $element = Element_Service::getElementById($exportSession->type, $exportSession->id);
         $exportSession->rootPath = $element->getPath();
         $exportSession->rootType = Element_Service::getType($element);
         $exportSession->elements = array(Element_Service::getType($element) . "_" . $element->getId() => array("elementType" => Element_Service::getType($element), "element" => $element->getId(), "recursive" => $exportSession->recursive));
         $exportSession->apiElements = array();
         if (is_dir($exportDir)) {
             recursiveDelete($exportDir);
         }
         mkdir($exportDir, 0755, true);
         $this->_helper->json(array("more" => true, "totalElementsDone" => 0, "totalElementsFound" => 0));
     } else {
         $data = array_pop($exportSession->elements);
         $element = Element_Service::getElementById($data["elementType"], $data["element"]);
         $recursive = $data["recursive"];
         $exportService = new Element_Export_Service();
         $apiElement = $exportService->getApiElement($element);
         $exportSession->foundRelations = $exportService->extractRelations($element, array_keys($exportSession->apiElements), $recursive, $exportSession->includeRelations);
         //make path relative to root
         if (Element_Service::getType($element) == $exportSession->rootType and $exportSession->rootPath == $element->getPath()) {
             $apiElement->path = "";
         } else {
             if (Element_Service::getType($element) == $exportSession->rootType and strpos($element->getPath(), $exportSession->rootPath) === 0) {
                 if ($exportSession->rootPath === "/") {
                     $len = 1;
                 } else {
                     $len = strlen($exportSession->rootPath) - 1;
                 }
                 $apiElement->path = substr($element->getPath(), $len);
             } else {
                 $apiElement->path = $element->getPath();
             }
         }
         $path = $apiElement->path;
         //convert the Webservice _Out element to _In elements
         $outClass = get_class($apiElement);
         $inClass = str_replace("_Out", "_In", $outClass);
         $apiElementIn = new $inClass();
         $objectVars = get_object_vars($apiElementIn);
         foreach ($objectVars as $var => $value) {
             if (property_exists(get_class($apiElement), $var)) {
                 $apiElementIn->{$var} = $apiElement->{$var};
             }
         }
         //remove parentId, add path
         $apiElementIn->parentId = null;
         $apiElement = $apiElementIn;
         $key = Element_Service::getType($element) . "_" . $element->getId();
         $exportSession->apiElements[$key] = array("element" => $apiElement, "path" => $path);
         $exportFile = $exportDir . "/" . $exportSession->counter . "_" . $key;
         file_put_contents($exportFile, serialize(array("element" => $apiElement, "path" => $path)));
         chmod($exportFile, 0766);
         $exportSession->elements = array_merge($exportSession->elements, $exportSession->foundRelations);
         if (count($exportSession->elements) == 0) {
             $exportArchive = $exportDir . ".zip";
             if (is_file($exportArchive)) {
                 unlink($exportArchive);
             }
             $zip = new ZipArchive();
             $created = $zip->open($exportArchive, ZipArchive::CREATE);
             if ($created === TRUE) {
                 $dh = opendir($exportDir);
                 while ($file = readdir($dh)) {
                     if ($file != '.' && $file != '..') {
                         $fullFilePath = $exportDir . "/" . $file;
                         if (is_file($fullFilePath)) {
                             $zip->addFile($fullFilePath, str_replace($exportDir . "/", "", $fullFilePath));
                         }
                     }
                 }
                 closedir($dh);
                 $zip->close();
             }
         }
         $exportSession->counter++;
         $this->_helper->json(array("more" => count($exportSession->elements) != 0, "totalElementsDone" => count($exportSession->apiElements), "totalElementsFound" => count($exportSession->foundRelations)));
     }
 }
Example #30
0
/**
 * @param $directory
 * @param bool $empty
 * @return bool
 */
function recursiveDelete($directory, $empty = true)
{
    if (is_dir($directory)) {
        $directory = rtrim($directory, "/");
        if (!file_exists($directory) || !is_dir($directory)) {
            return false;
        } elseif (!is_readable($directory)) {
            return false;
        } else {
            $directoryHandle = opendir($directory);
            $contents = ".";
            while ($contents) {
                $contents = readdir($directoryHandle);
                if (strlen($contents) && $contents != '.' && $contents != '..') {
                    $path = $directory . "/" . $contents;
                    if (is_dir($path)) {
                        recursiveDelete($path);
                    } else {
                        unlink($path);
                    }
                }
            }
            closedir($directoryHandle);
            if ($empty == true) {
                if (!rmdir($directory)) {
                    return false;
                }
            }
            return true;
        }
    } elseif (is_file($directory)) {
        return unlink($directory);
    }
}