Example #1
0
/**
 * delete directory contents
 */
function delDirConts($dir)
{
    try {
        if (strlen($dir) - 1 === strrpos($dir, DIRECTORY_SEPARATOR)) {
            $dir = substr($dir, 0, strlen($dir) - 1);
        }
        $odir = scandir($dir);
        foreach ($odir as $elm) {
            if (0 === strcmp($elm, '.') || 0 === strcmp($elm, '..')) {
                continue;
            }
            $ftype = filetype($dir . DIRECTORY_SEPARATOR . $elm);
            if (0 === strcmp($ftype, 'dir')) {
                delDir($dir . DIRECTORY_SEPARATOR . $elm);
            } else {
                $ret = unlink($dir . DIRECTORY_SEPARATOR . $elm);
                if (false === $ret) {
                    throw new Exception();
                }
            }
        }
    } catch (Exception $e) {
        throw $e;
    }
}
Example #2
0
function delDir($dirName)
{
    if (empty($dirName)) {
        return;
    }
    global $Message;
    if (file_exists($dirName)) {
        $dir = dir($dirName);
        while (false !== ($file = $dir->read())) {
            if ($file != '.' && $file != '..') {
                if (is_dir($dirName . '/' . $file)) {
                    delDir($dirName . '/' . $file);
                    $path_dir = "<span class=\"error\">" . str_replace("./", "", $dirName) . "</span>";
                    $Message = sprintf(A_CHAT_LOGS_34, A_CHAT_LOGS_33, $path_dir);
                } else {
                    $path_dir = "<span class=\"error\">" . str_replace("./", "", $dirName) . "</span>";
                    $path_file = "<span class=\"error\">" . str_replace("./", "", $dirName . '/' . $file) . "</span>";
                    @fclose($dirName . '/' . $file);
                    @unlink($dirName . '/' . $file) or die(sprintf(A_CHAT_LOGS_37, A_CHAT_LOGS_32, $path_dir));
                    $Message = sprintf(A_CHAT_LOGS_34, A_CHAT_LOGS_32, $path_file);
                }
            }
        }
        @rmdir($dirName . '/' . $file) or die(sprintf(A_CHAT_LOGS_37, A_CHAT_LOGS_33, $path_dir));
        $Message = sprintf(A_CHAT_LOGS_34, A_CHAT_LOGS_33, $path_dir);
    } else {
        $path_dir = "<span class=\"error\">" . str_replace("./", "", $dirName) . "</span>";
        $Message = sprintf(A_CHAT_LOGS_36, A_CHAT_LOGS_33, $path_dir);
    }
}
Example #3
0
File: lib.php Project: prototux/old
function delDir($dir)
{
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        is_dir($dir . '/' . $file) ? delDir($dir . '/' . $file) : unlink($dir . '/' . $file);
    }
    return rmdir($dir);
}
Example #4
0
 public function exec()
 {
     try {
         /* check installed module */
         if (false === isInstalled($this->parm)) {
             /* target module is already installed */
             throw new \err\ComErr('specified module is not installed', 'please check \'spac mod list\'');
         }
         /* confirm */
         echo 'Uninstall ' . $this->parm . ' module.' . PHP_EOL;
         echo 'Are you sure ?(y,n):';
         $line = rtrim(fgets(STDIN), "\n");
         if (!(0 === strcmp($line, 'y') || 0 === strcmp($line, 'Y'))) {
             exit;
         }
         /* delete module files */
         if (true === isDirExists(__DIR__ . '/../../mod/' . $this->parm)) {
             try {
                 delDir(__DIR__ . '/../../mod/' . $this->parm);
             } catch (\Exception $e) {
                 throw new \err\ComErr('could not delete ' . __DIR__ . '/../../mod/' . $this->parm, 'please check directory');
             }
         }
         /* edit module config */
         $modcnf = yaml_parse_file(__DIR__ . '/../../../../conf/module.yml');
         if (false === $modcnf) {
             throw new \err\ComErr('could not read module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
         }
         $newcnf = array();
         foreach ($modcnf as $elm) {
             if (0 === strcmp($this->parm, $elm['name'])) {
                 continue;
             }
             $newcnf[] = $elm;
         }
         if (0 === count($newcnf)) {
             $newcnf = null;
         }
         if (false === copy(__DIR__ . '/../../../../conf/module.yml', __DIR__ . '/../../../../conf/module.yml_')) {
             throw new \err\ComErr('could not create backup of module config', 'please check ' . __DIR__ . '/../../../../conf');
         }
         if (false === file_put_contents(__DIR__ . '/../../../../conf/module.yml', yaml_emit($newcnf))) {
             throw new \err\ComErr('could not edit module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
         }
         unlink(__DIR__ . '/../../../../conf/module.yml_');
         echo 'Successful uninstall ' . $this->parm . ' module ' . PHP_EOL;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Example #5
0
 function deleteUser($deleteFlights = 0, $deleteFiles = 0)
 {
     global $db, $pilotsTable;
     $err = 0;
     $sql = "DELETE FROM {$pilotsTable} WHERE pilotID=" . $this->pilotID . " AND serverID=" . $this->serverID;
     $res = $db->sql_query($sql);
     if ($res <= 0) {
         echo "Error deleting pilot from DB {$sql}<BR>";
         $err = 1;
     }
     if ($deleteFiles) {
         $pilotPath = $this->getAbsPath();
         delDir($pilotPath);
     }
     return $err;
 }
Example #6
0
function delDir($id)
{
    global $db;
    $sql = "SELECT *\n\t\t\tFROM `dir_data`\n\t\t\tWHERE `dir_parent` = " . $id;
    $result = $db->query($sql);
    //尋找有無子資料夾
    while ($arr = $db->getarray($result)) {
        delDir($arr['dir_id']);
    }
    //刪除該資料夾下所有檔案
    $sql = "DELETE from file_data\n\t\t\twhere file_dir = " . $id;
    $db->query($sql);
    //刪除該資料夾
    $sql = "DELETE from dir_data\n\t\t\twhere dir_id = " . $id;
    $db->query($sql);
    return;
}
Example #7
0
/**
 * 删除整个目录
 * @param $dir
 * @return bool
 */
function delDir($dir)
{
    //先删除目录下的所有文件:
    $dh = opendir($dir);
    while ($file = readdir($dh)) {
        if ($file != "." && $file != "..") {
            $fullpath = $dir . "/" . $file;
            if (!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                delDir($fullpath);
            }
        }
    }
    closedir($dh);
    //删除当前文件夹:
    return rmdir($dir);
}
Example #8
0
function delDir($directory)
{
    if (file_exists($directory)) {
        if ($dir_handle = @opendir($directory)) {
            while ($filename = readdir($dir_handle)) {
                if ($filename != "." && $filename != "..") {
                    $subFile = $directory . "/" . $filename;
                    if (is_dir($subFile)) {
                        delDir($subFile);
                    }
                    if (is_file($subFile)) {
                        unlink($subFile);
                    }
                }
            }
            closedir($dir_handle);
            rmdir($directory);
        }
    }
}
Example #9
0
function delDir($dir)
{
    $dh = opendir($dir);
    while ($file = readdir($dh)) {
        if ($file != "." && $file != "..") {
            $fullpath = $dir . "/" . $file;
            if (!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                delDir($fullpath);
            }
        }
    }
    closedir($dh);
    if (rmdir($dir)) {
        return true;
    } else {
        return false;
    }
}
Example #10
0
File: test.php Project: kison30/new
function delDir($path)
{
    //不是目录,直接返回
    if (!is_dir($path)) {
        return NULL;
    }
    $dh = opendir($path);
    while (($row = readdir($dh)) !== false) {
        if ($row == '.' || $row == '..') {
            continue;
        }
        //判断是否是普通文件
        if (!is_dir($path . '/' . $row)) {
            unlink($path . '/' . $row);
        } else {
            delDir($path . '/' . $row);
        }
        echo $row, "<br />";
    }
    closedir($dh);
    rmdir($path);
    return true;
}
Example #11
0
 /**
  * Обработчик действия: Импорт каталога.
  */
 function Import()
 {
     @set_time_limit(0);
     require_once "Structures/DataGrid.php";
     require_once "Structures/DataGrid/DataSource/Excel.php";
     require_once "Structures/DataGrid/DataSource/CSV.php";
     require_once 'Image/Transform.php';
     mk_dir("files/" . DOMAIN . "/tmp");
     clearDir("files/" . DOMAIN . "/tmp");
     if (isset($_FILES['file']['tmp_name']) && file_exists($_FILES['file']['tmp_name'])) {
         $path_parts = pathinfo($_FILES['file']['name']);
         $ext = preg_replace("/[^a-z0-9]+/i", "", mb_strtolower($path_parts['extension']));
         if ($ext == 'xls' || $ext == 'csv' || $ext == 'gz') {
             if ($ext == 'gz') {
                 if (extractArchive($_FILES['file']['tmp_name'], "files/" . DOMAIN . "/tmp")) {
                     $sourcefile1 = preg_replace("/tar\\.gz\$/i", "xls", $_FILES['file']['name']);
                     $sourcefile2 = preg_replace("/tar\\.gz\$/i", "csv", $_FILES['file']['name']);
                     if (is_file("files/" . DOMAIN . "/tmp/{$sourcefile1}")) {
                         $sourcefile = "files/" . DOMAIN . "/tmp/{$sourcefile1}";
                         $ext = "xls";
                     } elseif (is_file("files/" . DOMAIN . "/tmp/{$sourcefile2}")) {
                         $sourcefile = "files/" . DOMAIN . "/tmp/{$sourcefile2}";
                         $content = @file_get_contents($sourcefile);
                         if ($content && !mb_check_encoding($content, 'UTF-8')) {
                             file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251'));
                         }
                         $ext = "csv";
                     } else {
                         return false;
                     }
                 } else {
                     return false;
                 }
             } elseif ($ext == 'csv') {
                 $sourcefile = $_FILES['file']['tmp_name'];
                 $content = @file_get_contents($sourcefile);
                 if ($content && !mb_check_encoding($content, 'UTF-8')) {
                     file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251'));
                 }
             } else {
                 $sourcefile = $_FILES['file']['tmp_name'];
             }
             if (!empty($_REQUEST['clear'])) {
                 switch ($_REQUEST['clear']) {
                     case 1:
                         A::$DB->execute("TRUNCATE " . SECTION . "_categories");
                     case 2:
                         A::$DB->execute("TRUNCATE " . SECTION . "_catalog");
                         A::$DB->execute("DELETE FROM " . DOMAIN . "_images WHERE idsec=" . SECTION_ID . " AND iditem>0");
                         A::$DB->execute("DELETE FROM " . DOMAIN . "_files WHERE idsec=" . SECTION_ID . " AND iditem>0");
                         A::$DB->execute("DELETE FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID);
                         A_SearchEngine::getInstance()->deleteSection(SECTION_ID);
                         break;
                 }
             }
             A::$OPTIONS['imgpath'] = !empty(A::$OPTIONS['imgpath']) ? preg_replace("/[^a-zA-Z0-9-_\\/]/i", "", A::$OPTIONS['imgpath']) : "ifiles";
             A::$OPTIONS['filepath'] = !empty(A::$OPTIONS['filepath']) ? preg_replace("/[^a-zA-Z0-9-_\\/]/i", "", A::$OPTIONS['filepath']) : "ifiles";
             $categories = array();
             $fields = array();
             $cfiles = array();
             A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort");
             $i = 0;
             while ($row = A::$DB->fetchRow()) {
                 if ($row['type'] == 'select' || $row['type'] == 'mselect') {
                     if ($row['idvar'] = A::$DB->getOne("SELECT property FROM " . DOMAIN . "_fields WHERE item='" . SECTION . "' AND field='{$row['field']}'")) {
                         if (isset($vars[$row['idvar']])) {
                             $row['vars'] =& $vars[$row['idvar']];
                         } else {
                             $row['vars'] = array();
                             $_vars = loadList($row['idvar']);
                             foreach ($_vars as $key => $name) {
                                 $row['vars'][$key] = is_array($name) ? $name['name'] : $name;
                             }
                             $vars[$row['idvar']] =& $row['vars'];
                         }
                     }
                 }
                 $row['id'] = $i++;
                 if (preg_match("/^category[0-9]{1}\$/i", $row['field'])) {
                     $categories[$row['field']] = $row;
                 } elseif ($row['type'] == 'image' || $row['type'] == 'file') {
                     $cfiles[$row['field']] = $row;
                 } else {
                     $fields[$row['field']] = $row;
                 }
             }
             A::$DB->free();
             if ($ext == 'xls') {
                 $datasource = new Structures_DataGrid_DataSource_Excel();
                 $datasource->bind($sourcefile);
             } elseif ($ext == 'csv') {
                 $datasource = new Structures_DataGrid_DataSource_CSV();
                 $datasource->bind($sourcefile, array('delimiter' => ';', 'enclosure' => '"'));
             } else {
                 return false;
             }
             $datagrid = new Structures_DataGrid();
             $datagrid->bindDataSource($datasource);
             A::$DB->caching = false;
             $prevgoods = A::$DB->getCount(SECTION . "_catalog", "active='Y'");
             $curgoods = 0;
             $arts = array();
             $catn = array();
             $catr = array();
             $cats = array();
             $i = 0;
             $gsort = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . "_catalog") + 1;
             foreach ($datagrid->recordSet as $row) {
                 $i++;
                 if ($i == 1) {
                     continue;
                 }
                 if (empty($row)) {
                     continue;
                 }
                 if ($ext == 'xls') {
                     $trow = array();
                     foreach ($row as $j => $value) {
                         if (!empty($value)) {
                             $trow[$j - 1] = $value;
                         }
                     }
                     $row = $trow;
                 }
                 $idcat = 0;
                 for ($j = 0; $j < 3; $j++) {
                     if (isset($categories['category' . $j]) && !empty($row[$categories['category' . $j]['id']])) {
                         if ($cname = strip_tags(trim($row[$categories['category' . $j]['id']]))) {
                             $ch = md5($idcat . '|' . $cname);
                             if (isset($catn[$ch])) {
                                 $idcat = $catn[$ch];
                             } elseif ($_idcat = A::$DB->getOne("SELECT id FROM " . SECTION . "_categories WHERE idker={$idcat} AND name=?", $cname)) {
                                 $idcat = $catn[$ch] = $_idcat;
                             } else {
                                 if (!isset($catr[$idcat])) {
                                     $catr[$idcat] = A::$DB->getRowById($idcat, SECTION . "_categories");
                                 }
                                 $category = array();
                                 $category['name'] = $cname;
                                 $category['urlname'] = getURLName($cname);
                                 $category['idker'] = $idcat;
                                 $category['level'] = isset($catr[$idcat]['level']) ? $catr[$idcat]['level'] + 1 : 0;
                                 $category['sort'] = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . "_categories WHERE idker={$idcat}") + 1;
                                 $idcat = $catn[$ch] = A::$DB->Insert(SECTION . "_categories", $category);
                             }
                         }
                     }
                 }
                 if ($idcat == 0 && empty($row[$fields['art']['id']])) {
                     continue;
                 }
                 $data = array();
                 $data['date'] = time();
                 if ($idcat > 0) {
                     $data['idcat'] = $idcat;
                     if (!isset($cats[$idcat])) {
                         $cats[$idcat] = 1;
                     } else {
                         $cats[$idcat]++;
                     }
                 }
                 $data['idcat1'] = 0;
                 $data['idcat2'] = 0;
                 foreach ($fields as $field => $frow) {
                     if (!isset($_REQUEST['iempty']) || !empty($row[$frow['id']])) {
                         switch ($frow['type']) {
                             default:
                                 $data[$field] = !empty($row[$frow['id']]) ? trim($row[$frow['id']]) : "";
                                 break;
                             case 'int':
                                 $data[$field] = !empty($row[$frow['id']]) ? (int) $row[$frow['id']] : 0;
                                 break;
                             case 'float':
                                 $data[$field] = !empty($row[$frow['id']]) ? (double) str_replace(',', '.', $row[$frow['id']]) : 0;
                                 break;
                             case 'select':
                                 if (!empty($row[$frow['id']])) {
                                     if (isset($frow['vars'])) {
                                         $row[$frow['id']] = trim($row[$frow['id']]);
                                         $key = array_search($row[$frow['id']], $frow['vars']);
                                         if (empty($key) && !empty($row[$frow['id']])) {
                                             $key = addToList($frow['idvar'], $row[$frow['id']]);
                                             $fields[$field]['vars'][$key] = $frow['vars'][$key] = $row[$frow['id']];
                                         }
                                         if (!empty($key)) {
                                             $data[$field] = $key;
                                         }
                                     }
                                 }
                                 break;
                             case 'mselect':
                                 if (!empty($row[$frow['id']])) {
                                     if (isset($frow['vars'])) {
                                         $row[$frow['id']] = explode(',', $row[$frow['id']]);
                                         $data[$field] = array();
                                         foreach ($row[$frow['id']] as $value) {
                                             $value = trim($value);
                                             $key = array_search($value, $frow['vars']);
                                             if (empty($key) && !empty($value)) {
                                                 $key = addToList($frow['idvar'], $value);
                                                 $fields[$field]['vars'][$key] = $frow['vars'][$key] = $value;
                                             }
                                             if (!empty($key)) {
                                                 $data[$field][] = sprintf("%04d", $key);
                                             }
                                         }
                                         $data[$field] = implode(",", $data[$field]);
                                     }
                                 }
                                 break;
                             case 'bool':
                                 $data[$field] = !empty($row[$frow['id']]) && $row[$frow['id']] != 'N' ? "Y" : "N";
                                 break;
                         }
                     }
                 }
                 if (isset($data['name'])) {
                     $data['name'] = strip_tags(trim($data['name']));
                 }
                 if (!empty(A::$OPTIONS['idrule'])) {
                     $_data = $data;
                     prepareValues(SECTION, $_data);
                     $litems = array();
                     $idrule = A::$OPTIONS['idrule'];
                     $idrule = explode("+", $idrule);
                     foreach ($idrule as $fname) {
                         if (!empty($_data[$fname])) {
                             $litems[] = getURLName($_data[$fname]);
                         }
                     }
                     $data['urlname'] = implode(!empty($GLOBALS['A_URL_SEPARATOR']) ? $GLOBALS['A_URL_SEPARATOR'] : "_", $litems);
                 } elseif (!empty($data['art'])) {
                     $data['urlname'] = getURLName($data['art']);
                 }
                 if (empty($data['urlname'])) {
                     $data['urlname'] = getURLName($data['name']);
                 }
                 if (!empty($data['content']) && empty($data['description'])) {
                     $data['description'] = truncate($data['content'], A::$OPTIONS['anonslen']);
                 }
                 if (!empty($data['art'])) {
                     $grow = A::$DB->getRow("SELECT id,mprices FROM " . SECTION . "_catalog WHERE art=? LIMIT 0,1", $data['art']);
                     if (A::$OPTIONS['usecats']) {
                         if (!empty($arts[$data['art']]) && !empty($data['idcat'])) {
                             if ($arts[$data['art']] < 3) {
                                 $data['idcat' . $arts[$data['art']]] = $data['idcat'];
                                 unset($data['idcat']);
                             }
                             $arts[$data['art']]++;
                         } else {
                             $arts[$data['art']] = 1;
                         }
                     }
                 } else {
                     $grow = A::$DB->getRow("SELECT id,mprices FROM " . SECTION . "_catalog WHERE idcat=? AND name=? LIMIT 0,1", array($data['idcat'], $data['name']));
                 }
                 if ($grow) {
                     $id = $grow['id'];
                     $mprices = !empty($grow['mprices']) ? unserialize($grow['mprices']) : array();
                 } else {
                     $id = 0;
                 }
                 if ($id) {
                     if (isset($fields['mprice']) && !empty($data['mprice'])) {
                         $inm = false;
                         foreach ($mprices as $mp) {
                             if ($mp['name'] == trim($data['mprice'])) {
                                 $inm = true;
                                 break;
                             }
                         }
                         if (!$inm) {
                             $mprices[] = array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : '');
                         }
                         $data['mprices'] = serialize($mprices);
                         unset($data['price']);
                         $cats[$idcat]--;
                         $curgoods--;
                     }
                     if (isset($data['mprice'])) {
                         unset($data['mprice']);
                     }
                     A::$DB->Update(SECTION . "_catalog", $data, "id={$id}");
                     $images = A::$DB->getAssoc("SELECT sort,id,path FROM " . DOMAIN . "_images\r\r\n\t\t\tWHERE idsec=" . SECTION_ID . " AND iditem={$id}");
                     $images = array_values($images);
                     $files = A::$DB->getAssoc("SELECT sort,id,path FROM " . DOMAIN . "_files\r\r\n\t\t\tWHERE idsec=" . SECTION_ID . " AND iditem={$id}");
                     $files = array_values($files);
                     $curgoods++;
                 } elseif (!empty($data['idcat'])) {
                     if (isset($fields['mprice']) && !empty($data['mprice'])) {
                         $mprices = array(array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : ''));
                         $data['mprices'] = serialize($mprices);
                     }
                     if (isset($data['mprice'])) {
                         unset($data['mprice']);
                     }
                     if (empty($data['name'])) {
                         continue;
                     }
                     $data['sort'] = $gsort++;
                     $id = A::$DB->Insert(SECTION . "_catalog", $data);
                     $images = array();
                     $files = array();
                     $curgoods++;
                 } else {
                     continue;
                 }
                 foreach ($cfiles as $field => $frow) {
                     if (!empty($row[$frow['id']])) {
                         switch ($frow['type']) {
                             case 'image':
                                 $row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]);
                                 $path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : "";
                                 $path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['imgpath'] . "/" . $row[$frow['id']];
                                 $path2 = "files/" . DOMAIN . "/reg_images/" . $row[$frow['id']];
                                 $path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : ""));
                                 if ($path) {
                                     preg_match("/^idimg([0-9]+)\$/i", $field, $mathes);
                                     $sort = $mathes[1];
                                     if (!isset($images[$sort]) || $images[$sort]['path'] != $path) {
                                         $image = array();
                                         $image['path'] = $path;
                                         $image['name'] = basename($row[$frow['id']]);
                                         $image['mime'] = getMimeByFile($row[$frow['id']]);
                                         $image['caption'] = !empty($data['name']) ? $data['name'] : "";
                                         $it = Image_Transform::factory('GD');
                                         $it->load($path);
                                         $image['width'] = $it->img_x;
                                         $image['height'] = $it->img_y;
                                         $image['idsec'] = SECTION_ID;
                                         $image['iditem'] = $id;
                                         $image['sort'] = $sort;
                                         if (isset($images[$sort])) {
                                             A::$DB->Update(DOMAIN . "_images", $image, "id=" . $images[$sort]['id']);
                                         } else {
                                             A::$DB->Insert(DOMAIN . "_images", $image);
                                         }
                                     }
                                 }
                                 break;
                             case 'file':
                                 $row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]);
                                 $path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : "";
                                 $path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['filepath'] . "/" . $row[$frow['id']];
                                 $path2 = "files/" . DOMAIN . "/reg_files/" . $row[$frow['id']];
                                 $path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : ""));
                                 if ($path) {
                                     preg_match("/^idfile([0-9]+)\$/i", $field, $mathes);
                                     $sort = $mathes[1];
                                     if (!isset($files[$sort]) || $files[$sort]['path'] != $path) {
                                         $file = array();
                                         $file['path'] = $path;
                                         $file['name'] = basename($row[$frow['id']]);
                                         $file['mime'] = getMimeByFile($row[$frow['id']]);
                                         $file['caption'] = !empty($data['name']) ? $data['name'] : "";
                                         $file['idsec'] = SECTION_ID;
                                         $file['iditem'] = $id;
                                         $file['sort'] = $sort;
                                         $file['size'] = filesize($path);
                                         $file['dwnl'] = 0;
                                         if (isset($files[$sort])) {
                                             A::$DB->Update(DOMAIN . "_files", $file, "id=" . $files[$sort]['id']);
                                         } else {
                                             A::$DB->Insert(DOMAIN . "_files", $file);
                                         }
                                     }
                                 }
                                 break;
                         }
                     }
                 }
             }
             if ($prevgoods > 0 && $prevgoods != $curgoods) {
                 $this->updateCItems();
             } else {
                 A::$DB->Update(SECTION . "_categories", array('citems' => 0));
                 foreach ($cats as $id => $count) {
                     A::$DB->Update(SECTION . "_categories", array('citems' => $count), "id={$id}");
                 }
                 $this->updateCItems(0, true);
             }
             A::$CACHE->resetSection(SECTION);
             delDir("files/" . DOMAIN . "/tmp");
             return true;
         }
     }
     return false;
 }
Example #12
0
function annotate()
{
    require_once 'externals.php';
    $filename = $_SESSION['filename'];
    $tempdir = get_directory();
    chdir($tempdir);
    $file = fopen("{$tempdir}/{$filename}", "w");
    fwrite($file, $_SESSION['plfile']);
    fclose($file);
    $annotations = $_POST['annotations'];
    $annotations = '[' . $annotations . '].';
    if (isset($_POST['filters'])) {
        $filters = $_POST['filters'];
    } else {
        $filters = $_SESSION['filters'];
    }
    $output = modify_annotations("{$tempdir}/{$filename}", "{$tempdir}/{$filename}.ann", $annotations, $filters);
    if ($output[0] != 0) {
        $_SESSION['editerror'] = $output[2];
        delDir($tempdir);
        if (isset($_POST['textedit'])) {
            redirect('edit_filters.php');
        } else {
            redirect('upload_annfile.php');
        }
    }
    $_SESSION['editerror'] = '';
    $_SESSION['annfile'] = file_get_contents("{$tempdir}/{$filename}.ann");
    $_SESSION['filters'] = $filters;
    delDir($tempdir);
}
Example #13
0
            qiMsg("插件停用成功!");
        } elseif ($isused == '1') {
            array_push($app_plugins, $pname);
            if (file_exists('plugins/' . $apps . '/' . $pname . '/install.sql')) {
                $sql = file_get_contents('plugins/' . $apps . '/' . $pname . '/install.sql');
                $sql = str_replace('ts_', '' . dbprefix . '', $sql);
                $ret = $db->query($sql);
                if ($ret == '1') {
                    fileWrite($apps . '_plugins.php', 'data', $app_plugins);
                    $tsMySqlCache->set($apps . '_plugins', $app_plugins);
                    $msg = '插件启用成功!';
                } else {
                    $msg = $ret;
                }
            } else {
                fileWrite($apps . '_plugins.php', 'data', $app_plugins);
                $tsMySqlCache->set($apps . '_plugins', $app_plugins);
                $msg = '插件启用成功!';
            }
            qiMsg($msg);
        }
        break;
        //删除插件
    //删除插件
    case "delete":
        $apps = tsUrlCheck($_GET['apps']);
        $pname = tsUrlCheck($_GET['pname']);
        delDir('plugins/' . $apps . '/' . $pname);
        qiMsg('删除成功!');
        break;
}
Example #14
0
     }
     if ($sitePublish == 'true') {
         delDir('project_sites/' . $pieces[$i]);
     }
     // if CVS repository enabled
     if ($enable_cvs == 'true') {
         cvs_delete_repository($pieces[$i]);
     }
 }
 $tmpquery = 'WHERE tas.project IN(' . $id . ')';
 $listTasks = new request();
 $listTasks->openTasks($tmpquery);
 $comptListTasks = count($listTasks->tas_id);
 for ($i = 0; $i < $comptListTasks; $i++) {
     if ($fileManagement == 'true') {
         delDir('../files/' . $id . '/' . $listTasks->tas_id[$i]);
     }
     $tasks .= $listTasks->tas_id[$i];
     if ($i != $comptListTasks - 1) {
         $tasks .= ',';
     }
 }
 $tmpquery = 'WHERE topic.project IN(' . $id . ')';
 $listTopics = new request();
 $listTopics->openTopics($tmpquery);
 $comptListTopics = count($listTopics->top_id);
 for ($i = 0; $i < $comptListTopics; $i++) {
     $topics .= $listTopics->top_id[$i];
     if ($i != $comptListTopics - 1) {
         $topics .= ',';
     }
 * (at your option) any later version.
 */
$checkSession = true;
require_once "../includes/library.php";
if ($action == "delete") {
    $id = str_replace("**", ",", $id);
    $tmpquery1 = "DELETE FROM " . $tableCollab["tasks"] . " WHERE id IN({$id})";
    $tmpquery2 = "DELETE FROM " . $tableCollab["assignments"] . " WHERE task IN({$id})";
    $tmpquery3 = "DELETE FROM " . $tableCollab["tasks_time"] . " WHERE task IN({$id})";
    $tmpquery = "WHERE tas.id IN({$id})";
    $listTasks = new request();
    $listTasks->openTasks($tmpquery);
    $comptListTasks = count($listTasks->tas_id);
    for ($i = 0; $i < $comptListTasks; $i++) {
        if ($fileManagement == "true") {
            delDir("../files/" . $listTasks->tas_project[$i] . "/" . $listTasks->tas_id[$i]);
        }
    }
    connectSql("{$tmpquery1}");
    connectSql("{$tmpquery2}");
    connectSql("{$tmpquery3}");
    if ($project != "") {
        header("Location: ../projects/viewproject.php?id={$project}&msg=delete");
        exit;
    } else {
        header("Location: ../general/home.php?msg=delete");
        exit;
    }
}
$tmpquery = "WHERE pro.id = '{$project}'";
$projectDetail = new request();
Example #16
0
<?php

require 'init.php';
if (!isAdmin()) {
    render('403');
}
if (getVar('delete')) {
    //Delete gallery and all related pictures
    $delGallery = $dbh->prepare("DELETE FROM galleries WHERE id = :id");
    $delGallery->execute(array(':id' => getVar('delete')));
    $delPictures = $dbh->prepare("DELETE FROM pictures WHERE gallery_id = :id");
    $delPictures->execute(array(':id' => getVar('delete')));
    //Delete files
    delDir('images/galleries/' . getVar('delete'));
    //Render pictures like pictures.php
    $galleriesQuery = $dbh->prepare("SELECT id, title, description FROM galleries WHERE private = 0 OR private = :private");
    $galleriesQuery->execute(array('private' => isGuest()));
    $galleries = $galleriesQuery->fetchAll();
    render('pictures', array('galleries' => $galleries));
}
$categoriesQuery = $dbh->prepare("SELECT id, name FROM categories ");
$categoriesQuery->execute();
$categories = $categoriesQuery->fetchAll();
render('delgallery', array('categories' => $categories));
										) 
			) ;
			 
			 if ($res==1) { 
					echo _ADDED_SUCESSFULLY."<BR>";
					$igcFilesSubmited++;					
			 } else  {
				$errMsg=getAddFlightErrMsg($res,$flightID);
				echo _PROBLEM.": ".$errMsg."<br>";
			 }
			 echo "<hr>";
			 flush2Browser();
			// flush2Browser();
		}
	 }
	 closedir($current_dir);

	 echo "<br><br>"._TOTAL." ".$igcFiles." "._IGC_FILES_PROCESSED."<br>";
	 echo "<br>"._TOTAL." ".$igcFilesSubmited." "._IGC_FILES_SUBMITED."<br><br>";
	 @unlink($tmpZIPPath);
	 delDir($tmpZIPfolder);

 	 flush2Browser();
	 //while (@ob_end_flush()); 

	}
	

	closeMain(); 

?>
Example #18
0
/**
 * Handles the global widget administration interface.
 * @param $pageId Id of the current page
 * @return HTML code of the widget admin page
 */
function handleWidgetAdmin($pageId)
{
    global $ICONS, $urlRequestRoot, $cmsFolder, $moduleFolder, $sourceFolder, $widgetFolder;
    $html = "";
    if (isset($_GET['subsubaction'])) {
        if ($_GET['subsubaction'] == "installwidget") {
            require_once "{$sourceFolder}/module.lib.php";
            $uploadId = processUploaded("Widget");
            if ($uploadId != -1) {
                $ret = installModule($uploadId, "Widget");
                if ($ret != "") {
                    return $ret;
                }
            }
        }
    }
    if (isset($_GET["deletewidget"])) {
        $widgetId = escape($_GET['deletewidget']);
        if (is_numeric($widgetId)) {
            $widget = mysql_fetch_assoc(mysql_query("SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "widgetsinfo` WHERE `widget_id` = '{$widgetId}'"));
            $error = false;
            $deletelist = array("widgets", "widgetsinfo", "widgetsconfiginfo", "widgetsconfig", "widgetsdata");
            $rowCount = 0;
            foreach ($deletelist as $deleteitem) {
                $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . $deleteitem . "` WHERE `widget_id` = '{$widgetId}'";
                mysql_query($query) or die($query . "<br><br>" . mysql_error());
                $ans = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM `" . MYSQL_DATABASE_PREFIX . $deleteitem . "` WHERE `widget_id` = '{$widgetId}'"));
                $rowCount += $ans[0];
            }
            if (is_dir("{$sourceFolder}/{$widgetFolder}/{$widget['widget_foldername']}")) {
                if (!delDir("{$sourceFolder}/{$widgetFolder}/{$widget['widget_foldername']}")) {
                    $error = true;
                }
            }
            if ($rowCount != 0 || $error) {
                displayerror("There was some error in deleting widget {$widget['widget_name']}");
            } else {
                displayinfo("{$widget['widget_name']} successfully deleted.");
            }
        }
    }
    if (isset($_GET['widgetid'])) {
        $widgetid = escape($_GET['widgetid']);
        $query = "SELECT `widget_name` AS 'name', `widget_classname` AS 'classname', `widget_foldername` AS 'foldername' FROM `" . MYSQL_DATABASE_PREFIX . "widgetsinfo` WHERE `widget_id`='{$widgetid}'";
        $res = mysql_query($query);
        if (mysql_num_rows($res) == 0) {
            displayerror("Required widget is not registered with Pragyan CMS properly.");
            return false;
        }
        $row = mysql_fetch_array($res);
        global $widgetFolder;
        $classname = $row['classname'];
        require_once "{$widgetFolder}/{$row['foldername']}/widget.class.php";
        ///Initializing as global instance.
        $widget = new $classname($widgetid, -1, $pageId);
        if (!$widget instanceof widgetFramework) {
            displayerror("The widget {$row['name']} doesn't extends widgetFramework class");
            return false;
        }
        if (!$widget->validInstall()) {
            if (!$widget->installWidget()) {
                displayerror("{$row['name']} widget is not installed properly.");
                return false;
            }
            $widget->loadWidget();
        }
        /// POST variables are processed inside this function
        if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == "globalconf") {
            updateWidgetConf($widgetid, -1, TRUE);
        }
        $widgetinfo = getWidgetInfo($widgetid);
        $widgetglobalconfigs = getWidgetGlobalConfigInfo($widgetid);
        $containsFileUploadFields = false;
        $formElements = getConfigFormAsArray($widgetglobalconfigs, $containsFileUploadFields, -1, TRUE);
        $jsPath = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/formValidator.js";
        //validation.js
        $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/calendar";
        $jsPathMooTools = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/mootools-1.11-allCompressed.js";
        $html = '<link rel="stylesheet" type="text/css" media="all" href="' . $calpath . '/calendar.css" title="Aqua" />' . '<script type="text/javascript" src="' . $calpath . '/calendar.js"></script>';
        $html .= '<div class="registrationform"><form class="fValidator-form" name="widgetglobalsettings" action="./+admin&subaction=widgets&subsubaction=globalconf&widgetid=' . $widgetid . '" method="post"';
        if ($containsFileUploadFields) {
            $html .= ' enctype="multipart/form-data"';
        }
        $html .= '>';
        $html .= "<table width=100%><tr><th colspan=2>Widget : {$widgetinfo['name']}</th></tr>";
        $html .= "<tr><td>Description : </td><td> {$widgetinfo['description']}</td></tr>";
        //Uncomment when support for retrieving instances is there
        /*$html.="<tr><td>Instances : </td><td>";
        		$instances=getWidgetInstances($widgetid);
        		if(count($instances)>0) $html.="<ol>";
        		else $html.="None"; 
        		foreach($instances as $instance)
        		{
        			$html.="<li><a href='$urlRequestRoot/{$instance['url']}/+settings&subaction=widgets'>".
        					"{$instance['name']} [{instance['url']}]</li>";
        		}
        		if(count($instances)>0) $html.="</ol>";
        		$html.="</td></tr>";
        		*/
        $html .= "<tr>" . join($formElements, "</tr>\n<tr>") . "</tr>";
        $html .= "</table><input name='update_global_settings' type='submit' value='Update'/>" . "<input type='reset' value='Reset'/>";
        $html .= "</form><br/>";
    }
    $widgetsarr = getAllWidgetsInfo();
    $html .= "<fieldset><legend>{$ICONS['Widgets']['small']}Available Widgets</legend>";
    $html .= "<table width=100%><tr><th colspan=4>Available Widgets<br/><i>Mouse over for description and Click for configuration</i></th></tr>\n\t<tr><th>Name</th><th>Version</th><th>Author</th><th>Actions</th></tr>";
    foreach ($widgetsarr as $widget) {
        $html .= "<tr><td><a title='" . $widget['description'] . "' href='./+admin&subaction=widgets&widgetid=" . $widget['id'] . "'>" . $widget['name'] . "</a></td><td>{$widget['version']}</td><td>{$widget['author']}</td><td><a href='./+admin&subaction=widgets&widgetid={$widget['id']}'>{$ICONS['Edit']['small']}</a><a href='./+admin&subaction=widgets&deletewidget={$widget['id']}'>{$ICONS['Delete']['small']}</a></td></tr>";
    }
    $html .= <<<HTML
<tr><td>Install new widget:</td><td colspan=3>
<form method='POST' action='./+admin&subaction=widgets&subsubaction=installwidget' enctype="multipart/form-data">
<input type='file' name='file' id='file'><input type='submit' name='btn_install' value='Upload'>
</form>
</td></tr></table></fieldset>
HTML;
    return $html;
}
Example #19
0
function delDir($dirname)
{
    if (is_dir($dirname)) {
        $dir_handle = opendir($dirname);
    }
    if (!isset($dir_handle) || !$dir_handle) {
        return false;
    }
    while ($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            if (!is_dir($dirname . "/" . $file)) {
                unlink($dirname . "/" . $file);
            } else {
                delDir($dirname . '/' . $file);
            }
        }
    }
    closedir($dir_handle);
    rmdir($dirname);
    return true;
}
Example #20
0
     if (PATH_SEPARATOR != ':') {
         $phinxCommand = ROOT_PATH . 'Package\\bin\\phinx.bat';
     } else {
         $phinxCommand = PHP_BINARY . ' ' . ROOT_PATH . 'Package/robmorgan/phinx/bin/phinx';
     }
     exec($phinxCommand . ' migrate', $return_arr, $return_arr2);
     print_arr($return_arr);
     if (stripos($return_arr[count($return_arr) - 1], 'All Done.') === false) {
         echo colorize(PHP_EOL . PHP_EOL . 'Failed to migrate database, you can try it manually: ', 'WARNING') . colorize('./Package/bin/phinx migrate', 'WARNING') . PHP_EOL;
         // rollback
         exec($phinxCommand . ' rollback', $return_arr, $return_arr2);
         break;
     }
     echo 'Now installing resources...' . PHP_EOL;
     echo 'Deleting old resources...  ' . PHP_EOL;
     echo delDir(ROOT_PATH . 'Public/Resource') ? 'Done.' . PHP_EOL : 'old resources not exist.' . PHP_EOL;
     echo 'Copying resources...' . PHP_EOL;
     copyDir(ROOT_PATH . 'Resource', ROOT_PATH . 'Public/Resource');
     echo colorize('All done~ Cheers! open site: ' . BASE_URL . 'yourdomain.com/', 'NOTE') . PHP_EOL;
     break;
 case 'import-sspanel':
     // TODO: 从 ss-panel 导入用户数据
     break;
 case 'test':
     echo colorize('FAILED!' . PHP_EOL, 'SUCCESS');
     echo colorize('FAILED!' . PHP_EOL, 'FAILURE');
     echo colorize('FAILED!' . PHP_EOL, 'WARNING');
     echo colorize('FAILED!' . PHP_EOL, 'NOTE');
     break;
 default:
     echo 'Unknown command';
Example #21
0
 */
$checkSession = true;
require_once "../includes/library.php";
if ($action == "delete") {
    $id = str_replace("**", ",", $id);
    $tmpquery1 = "DELETE FROM " . $tableCollab["meetings"] . " WHERE id IN({$id})";
    $tmpquery2 = "DELETE FROM " . $tableCollab["attendants"] . " WHERE meeting IN({$id})";
    $tmpquery3 = "DELETE FROM " . $tableCollab["meetings_attachment"] . " WHERE meeting IN({$id})";
    $tmpquery4 = "DELETE FROM " . $tableCollab["meetings_time"] . " WHERE meeting IN({$id})";
    $tmpquery = "WHERE mee.id IN({$id})";
    $listMeetings = new request();
    $listMeetings->openMeetings($tmpquery);
    $comptListMeetings = count($listMeetings->mee_id);
    for ($i = 0; $i < $comptListMeetings; $i++) {
        if ($fileManagement == "true") {
            delDir("../files/" . $listMeetings->mee_project[$i] . "/meetings/" . $listMeetings->mee_id[$i]);
        }
    }
    connectSql("{$tmpquery1}");
    connectSql("{$tmpquery2}");
    connectSql("{$tmpquery3}");
    connectSql("{$tmpquery4}");
    if ($project != "") {
        header("Location: ../projects/viewproject.php?id={$project}&msg=delete");
        exit;
    } else {
        header("Location: ../general/home.php?msg=delete");
        exit;
    }
}
$tmpquery = "WHERE pro.id = '{$project}'";
Example #22
0
 function delDir($directory)
 {
     //判断目录是否存在,如果不存在rmdir()函数会出错
     if (file_exists($directory)) {
         //打开目录返回目录资源,并判断是否成功
         if ($dir_handle = @opendir($directory)) {
             //遍历目录,读出目录中的文件或文件夹
             while ($filename = readdir($dir_handle)) {
                 //一定要排除两个特殊的目录
                 if ($filename != "." && $filename != "..") {
                     //将目录下的文件和当前目录相连
                     $subFile = $directory . "/" . $filename;
                     //如果是目录条件则成立
                     if (is_dir($subFile)) {
                         //递归调用自己删除子目录
                         delDir($subFile);
                     }
                     //如果是文件条件则成立
                     if (is_file($subFile)) {
                         //直接删除这个文件
                         unlink($subFile);
                     }
                 }
             }
             //关闭目录资源
             closedir($dir_handle);
             //删除空目录
             rmdir($directory);
         }
     }
 }
                            }
                            if (mysql_affected_rows() > 0) {
                                $recordsper++;
                                //header("Location:bulkupload.php?stat=Y");
                            }
                        }
                        // end if thumb check
                        // End if
                    }
                    // end foreach
                } else {
                    $message .= "Can not Extaract Folder , Error in Uploding.<br>";
                }
                // Delete Images from Folder
                if (is_dir($dirpaths) and file_exists($dirpaths)) {
                    delDir($dirpaths);
                }
                if (is_dir($image_file_path) and file_exists($image_file_path)) {
                    delFiles($image_file_path);
                }
                // end delete
            } else {
                $message .= "Image folder doesnot exists , Error in Uploding.<br>";
            }
        }
        // end  if message check
    }
    // end if 	 zip upload chek
}
// end if button check
include "../includes/htmltop.php";
Example #24
0
/**
 * 删除文件夹和文件夹下所有的文件
 * @param string $dir
 * @return boolean
 */
function delDir($dir = '')
{
    if (empty($dir)) {
        $dir = rtrim(RUNTIME_PATH, '/');
    }
    if (substr($dir, -1) == '/') {
        $dir = rtrim($dir, '/');
    }
    if (!file_exists($dir)) {
        return true;
    }
    if (!is_dir($dir) || is_link($dir)) {
        return @unlink($dir);
    }
    foreach (scandir($dir) as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        if (!delDir($dir . "/" . $item)) {
            @chmod($dir . "/" . $item, 0777);
            if (!delDir($dir . "/" . $item)) {
                return false;
            }
        }
    }
    return @rmdir($dir);
}
 function delete($target)
 {
     // Make real path.
     $realPath = $_SERVER["DOCUMENT_ROOT"] . $target;
     append_to_log("attempting to DELETE: {$realPath}");
     // Check if the file actually exists (NULL compliance).
     if (file_exists($realPath)) {
         append_to_log("File/dir exists...");
         if (is_dir($realPath)) {
             // Attempt to remove the target directory.
             $status = delDir($realPath);
         } else {
             append_to_log("File is a file...");
             // Attempt to remove the file.
             $status = unlink($realPath);
         }
         // Check the return code:
         if ($status) {
             append_to_log("delete was OK");
             return eZWebDAVServer::OK;
         } else {
             append_to_log("delete FAILED");
             return eZWebDAVServer::FAILED_FORBIDDEN;
         }
     } else {
         return eZWebDAVServer::FAILED_NOT_FOUND;
     }
 }
Example #26
0
function delDir($dirName)
{
    if (empty($dirName)) {
        return;
    }
    if (file_exists($dirName)) {
        $dir = dir($dirName);
        while ($file = $dir->read()) {
            if ($file != '.' && $file != '..') {
                if (is_dir($dirName . '/' . $file)) {
                    delDir($dirName . '/' . $file);
                } else {
                    @unlink($dirName . '/' . $file) or die('File ' . $dirName . '/' . $file . ' couldn\'t be deleted!');
                }
            }
        }
        @rmdir($dirName . '/' . $file) or die('Folder ' . $dirName . '/' . $file . ' couldn\'t be deleted!');
    } else {
        echo 'Folder "<b>' . $dirName . '</b>" doesn\'t exist.';
    }
}
Example #27
0
		<td>
		<input type="submit" value="Submit Bug Report" />
		<input type="hidden" name="stage" value="spec" />
		</td>
		<td>
		This is almost certainly a bug in Weblogen. Please submit it so that our
		developers can solve it.
		</td>
		</tr>
		</table>
		</form>
		<?php 
    }
    print_save_link_and_save_output_to_session($filename, $spec, $tempdir);
}
delDir($tempdir);
html_end();
function print_save_link_and_save_output_to_session($filename, $type, $tempdir)
{
    if ($type == 1) {
        $specfilename = substr($filename, 0, strlen($filename) - 3) . '.spec';
    } else {
        $specfilename = "{$filename}.gx";
    }
    $_SESSION['specfile'] = file_get_contents("{$tempdir}/{$specfilename}");
    if ($type == 1) {
        echo '<p><a href="get_spec.php">Download residual program</a></p>';
    } else {
        echo '<p><a href="get_gx.php">Download generating extension</a></p>';
    }
}
Example #28
0
function installModule($uploadId, $type)
{
    global $sourceFolder;
    $result = mysql_fetch_assoc(mysql_query("SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "tempuploads` WHERE `id` = '{$uploadId}'"));
    if ($result != NULL) {
        $zipFile = $result['filePath'];
        $temp = explode(";", $result['info']);
        $extractedPath = $temp[0];
        $moduleActualPath = $temp[1];
        $moduleName = $temp[2];
    }
    $function = "checkFor{$type}Issues";
    $issueType = $function($moduleActualPath, $moduleName, $issues);
    if ($issues == "") {
        return finalizeInstallation($uploadId, $type);
    }
    $issues = "\n\t<table name='issues_table'>\n\t<tr><th>S.No.</th><th>Issue Details</th><th>Issue Type</th><th>Ignore ?</th></tr>\n\t{$issues}\n\t</table>\n\t<b>Installation cannot proceed for the above mentioned issues, fix them and <a href='./+admin&subaction=widgets&subsubaction=installwidget'>try again</a>.</b>";
    delDir($extractedPath);
    unlink($zipFile);
    mysql_query("DELETE FROM `" . MYSQL_DATABASE_PREFIX . "tempuploads` WHERE `id` = '{$uploadId}'") or displayerror(mysql_error());
    return $issues;
}
Example #29
0
function handleTemplateManagement()
{
    global $sourceFolder;
    if (isset($_POST['btn_install'])) {
        $uploadId = processUploaded("Template");
        if ($uploadId != -1) {
            return installModule($uploadId, "Template");
        }
    } else {
        if (isset($_POST['btn_uninstall'])) {
            $query = "SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE attribute= 'default_template'";
            $res = mysql_query($query);
            $row1 = array();
            $row1 = mysql_fetch_row($res);
            if (!isset($_POST['Template']) || $_POST['Template'] == "") {
                return "";
            }
            $toDelete = escape($_POST['Template']);
            $query = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "templates` WHERE `template_name` = '" . $toDelete . "'";
            $query2 = "SELECT `page_id` FROM `" . MYSQL_DATABASE_PREFIX . "pages` WHERE `page_template` = '{$toDelete}' LIMIT 10";
            $result2 = mysql_query($query2) or displayerror(mysql_error());
            if ($row1[0] == $toDelete) {
                displayerror("The default template cannot be deleted! If you want to delete this template, first change the default template from 'Global Settings'.");
                return "";
            }
            if (mysql_num_rows($result2) == 0 || isset($_POST['confirm'])) {
                if ($row = mysql_fetch_array(mysql_query($query))) {
                    $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "templates` WHERE `template_name` = '" . $toDelete . "'";
                    mysql_query($query);
                    $query = "UPDATE `" . MYSQL_DATABASE_PREFIX . "pages` SET `page_template` = '" . $row1[0] . "' WHERE `page_template` = '" . $toDelete . "'";
                    mysql_query($query) or displayerror(mysql_error());
                    $templateDir = $sourceFolder . "/templates/" . $toDelete . "/";
                    if (file_exists($templateDir)) {
                        delDir($templateDir);
                    }
                    displayinfo("Template " . safe_html($_POST['Template']) . " uninstalled!");
                    return "";
                } else {
                    displayerror("Template uninstallation failed!");
                    return "";
                }
            }
            $pageList = "";
            while ($row = mysql_fetch_assoc($result2)) {
                $pageList .= "/home" . getPagePath($row['page_id']) . "<br>";
            }
            $templatename = safe_html($_POST['Template']);
            $ret = <<<RET
<fieldset>
<legend>{$ICONS['Templates Management']['small']}Template Management</legend>
Some of the page with {$templatename} template are:<br>
{$pageList}
<div class='cms-error'>The templates of these pages will be reset to default template if you proceed deleting the template.</div>
<form method=POST action='./+admin&subaction=template&subsubaction=uninstall'>
<input type=hidden value='{$templatename}' name='Template' />
<input type=submit value='Delete template' name='btn_uninstall' />
<input type=hidden value='confirm' name='confirm' />
</form>
</fieldset>
RET;
            return $ret;
        }
    }
    /*
    	this finalize and cancel subsubactions are vulnerabilities, any one can vary $_POST['path'] and make cms to delete itself.
    	so template installation is also merged with module and widget installation,
    	but some extra features specific to template installation(ie ignoring missing template variables and changing template name)
    	are missing in that installation, these will remain commented for reference till those features are implemented the other way
    	else if(isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'finalize') 
    	{		
    	
    		$issues = "";
    		$ret = reportIssues(escape($_POST['path']),$issues);
    		if($ret[0] == 1) 
    		{
    			displayerror("Your template is still not compatible with Pragyan CMS. Please fix the reported issues during installation.");
    			delDir(escape($_POST['del']));
    			unlink(escape($_POST['file']));
    			return "";
    		}
    			
    		$templates=getAvailableTemplates();
    		$flag=false;
    		foreach ($templates as $template) 
    			if($template==$_POST['template'])
    			{
    				$flag=true;
    				break;
    			}
    		if($_POST['template']=="common" || $flag || file_exists($sourceFolder . "/templates/" . escape($_POST['template']) . "/")) 
    		{
    			displayerror("Template Installation failed : A folder by the template name already exists.");
    			$templatePath=safe_html($_POST['del']);
    			$str=safe_html($_POST['file']);
    			$ret=<<<RET
    			<form method=POST action='./+admin&subaction=canceltemplate'>
    			Please click the following button to start a fresh installation : 
    			<input type=hidden name='path' value='{$templatePath}'>
    			<input type=hidden name='file' value='{$str}'>
    			<input type=submit value="Fresh Installation">
    			</form>
    RET;
    			return $ret;
    			
    		}
    		rename(escape($_POST['path']), $sourceFolder . "/templates/" . escape($_POST['template']) . "/");
    		delDir(escape($_POST['del']));
    		unlink(escape($_POST['file']));
    		mysql_query("INSERT INTO `" . MYSQL_DATABASE_PREFIX . "templates` VALUES('" . escape($_POST['template']) . "')");
    		displayinfo("Template installation complete");
    		return "";
    		
    	} 
    	else if(isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'cancel') 
    	{
    		delDir(escape($_POST['path']));
    		unlink(escape($_POST['file']));
    		return "";
    	}*/
}
Example #30
0
     }
     if ($sitePublish == "true") {
         delDir("project_sites/{$pieces[$i]}");
     }
     //if CVS repository enabled
     if ($enable_cvs == "true") {
         cvs_delete_repository($pieces[$i]);
     }
 }
 $tmpquery = "WHERE tas.project IN({$id})";
 $listTasks = new request();
 $listTasks->openTasks($tmpquery);
 $comptListTasks = count($listTasks->tas_id);
 for ($i = 0; $i < $comptListTasks; $i++) {
     if ($fileManagement == "true") {
         delDir("../files/{$id}/" . $listTasks->tas_id[$i]);
     }
     $tasks .= $listTasks->tas_id[$i];
     if ($i != $comptListTasks - 1) {
         $tasks .= ",";
     }
 }
 $tmpquery = "WHERE topic.project IN({$id})";
 $listTopics = new request();
 $listTopics->openTopics($tmpquery);
 $comptListTopics = count($listTopics->top_id);
 for ($i = 0; $i < $comptListTopics; $i++) {
     $topics .= $listTopics->top_id[$i];
     if ($i != $comptListTopics - 1) {
         $topics .= ",";
     }