コード例 #1
0
ファイル: editalbum_m.php プロジェクト: ATS001/PRSIT
function editalbum($titrfr, $titren, $titrar, $img, $id)
{
    global $db;
    $values["titrfr"] = MySQL::SQLValue($titrfr);
    $values["titren"] = MySQL::SQLValue($titren);
    $values["titrar"] = MySQL::SQLValue($titrar);
    if ($img != "") {
        $values["album"] = MySQL::SQLValue(changnom($img, $id, "album_"));
    }
    $where["id"] = MySQL::SQLValue($id);
    // Execute the insert
    $result = $db->UpdateRows("album", $values, $where);
    // If we have an error
    if (!$result) {
        // Show the error and kill the script
        $db->Kill($result);
        return false;
    } else {
        if ($img != "") {
            $olddir = "upload/album/";
            $newdir = "../upload/album/" . $id . "/";
            copyfile($img, $id, $olddir, "album_");
            clearDir($newdir);
            extractzip($olddir, "album_" . $id . ".zip", $id, $newdir);
        }
        return true;
    }
}
コード例 #2
0
ファイル: fonctions.php プロジェクト: NerdOth/SMQ
function clearDir($dossier)
{
    $ouverture = @opendir($dossier);
    if (!$ouverture) {
        return;
    }
    while ($fichier = readdir($ouverture)) {
        if ($fichier == '.' || $fichier == '..') {
            continue;
        }
        if (is_dir($dossier . "/" . $fichier)) {
            $r = clearDir($dossier . "/" . $fichier);
            if (!$r) {
                return false;
            }
        } else {
            $r = @unlink($dossier . "/" . $fichier);
            if (!$r) {
                return false;
            }
        }
    }
    closedir($ouverture);
    $r = @rmdir($dossier);
    @rename($dossier, "trash");
    return true;
}
コード例 #3
0
function bindCacheSetting()
{
    global $_FANWE;
    $settings = array();
    $js_settings = array();
    $res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1");
    while ($data = FDB::fetch($res)) {
        $name = strtolower($data['name']);
        $settings[$name] = $data['val'];
        if ($data['is_js'] == 1) {
            $js_settings[$name] = $data['val'];
        }
    }
    $settings['site_title'] .= ' - ' . 'F' . 'A' . 'N' . 'W' . 'E';
    $settings['footer_html'] .= '<' . 'p' . '>' . '<' . 'a' . ' ' . 'h' . 'r' . 'e' . 'f' . '=' . '"' . 'h' . 't' . 't' . 'p' . ':' . '/' . '/' . 'w' . 'w' . 'w' . '.' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'c' . 'o' . 'm' . '"' . ' ' . 't' . 'a' . 'r' . 'g' . 'e' . 't' . '=' . '"' . '_' . 'b' . 'l' . 'a' . 'n' . 'k' . '"' . '>' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'i' . 'n' . 'c' . '<' . '/' . 'a' . '>' . '<' . '/' . 'p' . '>';
    writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';');
    $config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php');
    $config_file = trim($config_file);
    $config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file);
    $config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file);
    @file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file);
    unset($config_file);
    $lang_arr = array();
    $lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php');
    foreach ($lang_files as $lang_file) {
        if (@(include $lang_file)) {
            foreach ($lang as $lkey => $lval) {
                $lang_pre = strtolower(substr($lkey, 0, 3));
                if ($lang_pre == 'js_') {
                    $lang_key = substr($lkey, 3);
                    if ($lang_key != '') {
                        $lang_arr[$lang_key] = $lval;
                    }
                }
            }
        }
    }
    writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';');
    clearDir(FANWE_ROOT . './public/data/tpl/css/');
    clearDir(FANWE_ROOT . './public/data/tpl/js/');
    $css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/';
    $css_cache_dir = FANWE_ROOT . './public/data/tpl/css/';
    $css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/';
    $directory = dir($css_dir);
    while ($entry = $directory->read()) {
        if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) {
            $css_path = $css_dir . $entry;
            $css_content = @file_get_contents($css_path);
            $css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content);
            $css_cache_path = $css_cache_dir . '/' . $entry;
            writeFile($css_cache_path, $css_content);
        }
    }
    $directory->close();
    FanweService::instance()->cache->saveCache('setting', $settings);
}
コード例 #4
0
function clearDir($dir)
{
    if (!preg_match("/^.*\\/\$/", $dir)) {
        $dir .= '/';
    }
    $handle = @opendir($dir);
    if ($handle != false) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . $file)) {
                    clearDir($dir . $file);
                } else {
                    @unlink($dir . $file);
                }
            }
        }
        closedir($handle);
        $res = @rmdir($dir);
    } else {
        $res = false;
    }
    return $res;
}
コード例 #5
0
ファイル: editalbum_m.php プロジェクト: ATS001/PRSIT
function editalbum($titrfr, $titren, $titrar, $img, $id)
{
    global $db;
    $values["titrfr"] = MySQL::SQLValue($titrfr);
    $values["titren"] = MySQL::SQLValue($titren);
    $values["titrar"] = MySQL::SQLValue($titrar);
    $values["album"] = MySQL::SQLValue(changnom($img, $id));
    $where["id"] = MySQL::SQLValue($id);
    // Execute the insert
    $result = $db->UpdateRows("album", $values, $where);
    // If we have an error
    if (!$result) {
        // Show the error and kill the script
        $db->Kill($result);
        return false;
    } else {
        $a_del = "upload/album/album_" . $id . ".zip";
        clearDir($a_del);
        //unlink("upload/album/album_".$id.".zip");
        copyfile($img, $id);
        return true;
    }
}
コード例 #6
0
    public function deleteUser($ids)
    {
        vendor("common");
        @set_time_limit(0);
        if (function_exists('ini_set')) {
            ini_set('max_execution_time', 0);
        }
        $id_arr = explode(',', $ids);
        $ids = implode(',', $id_arr);
        if (empty($ids)) {
            return false;
        }
        //==================添加第三方整合会员添加 chenfq 2011-10-14================
        foreach ($id_arr as $uid) {
            $user = $this->getById($uid);
            $user_field = fanweC('INTEGRATE_FIELD_ID');
            $integrate_id = intval($user[$user_field]);
            if ($integrate_id > 0) {
                FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG'));
                FS("Integrate")->delUser($integrate_id);
                //exit;
            }
        }
        //==================添加第三方整合会员添加chenfq 2011-10-14================
        $condition = array('uid' => array('in', $id_arr));
        if (false !== $this->where($condition)->delete()) {
            D('AskPost')->where($condition)->delete();
            D('AskThread')->where($condition)->delete();
            D('ForumPost')->where($condition)->delete();
            D('ForumThread')->where($condition)->delete();
            D('ManageLog')->where($condition)->delete();
            D('SecondGoods')->where($condition)->delete();
            D('ShareComment')->where($condition)->delete();
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_category 
				WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share 
				WHERE uid IN (' . $ids . '))');
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_match 
				WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share 
				WHERE uid IN (' . $ids . '))');
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_tags 
				WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share 
				WHERE uid IN (' . $ids . '))');
            $res = FDB::query('SELECT share_id FROM ' . FDB::table('share') . ' WHERE uid IN (' . $ids . ')');
            while ($data = FDB::fetch($res)) {
                $key = getDirsById($data['share_id']);
                clearCacheDir('share/' . $key);
                clearDir(PUBLIC_ROOT . './upload/share/' . $key, true);
            }
            D('Share')->where($condition)->delete();
            D('ShareGoods')->where($condition)->delete();
            D('SharePhoto')->where($condition)->delete();
            D('UserAttention')->where($condition)->delete();
            D('UserAuthority')->where($condition)->delete();
            D('UserCount')->where($condition)->delete();
            //删除喜欢收藏
            $list = M()->query('SELECT uid,COUNT(uid) AS ccount FROM ' . C("DB_PREFIX") . 'user_collect 
				WHERE c_uid IN (' . $ids . ') GROUP BY uid');
            foreach ($list as $data) {
                M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count 
					SET collects = collects - ' . $data['ccount'] . ' 
					WHERE uid = ' . $data['uid']);
            }
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_collect 
				WHERE c_uid IN (' . $ids . ')');
            //删除粉丝关注
            $list = M()->query('SELECT uid FROM ' . C("DB_PREFIX") . 'user_follow 
				WHERE f_uid IN (' . $ids . ') GROUP BY uid');
            foreach ($list as $data) {
                M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count 
					SET fans  = fans  - 1 
					WHERE uid = ' . $data['uid']);
            }
            $list = M()->query('SELECT f_uid FROM ' . C("DB_PREFIX") . 'user_follow 
				WHERE uid IN (' . $ids . ') GROUP BY f_uid');
            foreach ($list as $data) {
                M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count 
					SET fans  = follows  - 1 
					WHERE uid = ' . $data['f_uid']);
            }
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow 
				WHERE f_uid IN (' . $ids . ')');
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow 
				WHERE uid IN (' . $ids . ')');
            D('UserDaren')->where($condition)->delete();
            D('UserMedal')->where($condition)->delete();
            D('UserMeTags')->where($condition)->delete();
            M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_msg WHERE author_id IN (' . $ids . ')');
            D('UserMsgRel')->where($condition)->delete();
            D('UserNotice')->where($condition)->delete();
            D('UserProfile')->where($condition)->delete();
            D('UserStatistics')->where($condition)->delete();
            D('UserStatus')->where($condition)->delete();
            foreach ($id_arr as $uid) {
                $this->deleteUserAvatar($uid);
            }
            return true;
        } else {
            return false;
        }
    }
コード例 #7
0
ファイル: shoplite.php プロジェクト: procivam/s-mir-new
 /**
  * Обработчик действия: Экспорт каталога.
  */
 function Export()
 {
     @set_time_limit(0);
     mk_dir("files/" . DOMAIN . "/tmp");
     clearDir("files/" . DOMAIN . "/tmp");
     require_once "Structures/DataGrid.php";
     require_once "Structures/DataGrid/DataSource/Array.php";
     require_once "Structures/DataGrid/Renderer/CSV.php";
     $categories = array();
     $fields = array();
     $all = 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'])) {
                 $row['vars'] = loadList($row['idvar']);
                 foreach ($row['vars'] as $j => $name) {
                     if (is_array($name) && isset($name['name'])) {
                         $row['vars'][$j] = $name['name'];
                     }
                 }
             }
         }
         $row['id'] = $i++;
         $all[$row['field']] = $row;
         if (preg_match("/^category([0-9]{1})\$/i", $row['field'], $matches)) {
             $row['level'] = $matches[1];
             $categories[$row['field']] = $row;
         } else {
             $fields[$row['field']] = $row;
         }
     }
     A::$DB->free();
     $renderer = new Structures_DataGrid_Renderer_CSV();
     $renderer->setOptions(array('delimiter' => ';', 'enclosure' => '"', 'saveToFile' => true, 'useQuotes' => true, 'filename' => "files/" . DOMAIN . "/tmp/" . DOMAIN . "_" . getName(SECTION) . ".csv"));
     $renderer->init();
     $datasource = new Structures_DataGrid_DataSource_Array();
     $datagrid = new Structures_DataGrid();
     $datagrid->bindDataSource($datasource);
     $datagrid->attachRenderer(&$renderer);
     $i = 0;
     $header = array();
     foreach ($all as $field => $frow) {
         $header[$i++] = array('field' => $field, 'label' => mb_convert_encoding($frow['caption'], "Windows-1251", "UTF-8"));
     }
     $renderer->buildHeader($header);
     $cats = array();
     $this->getCategories($cats);
     $i = 0;
     foreach ($cats as $id => $category) {
         A::$DB->query("SELECT * FROM " . SECTION . "_catalog WHERE idcat={$id} ORDER BY name");
         while ($row = A::$DB->fetchRow()) {
             $crow = array();
             for ($j = 0; $j < count($all); $j++) {
                 $crow[$j] = "";
             }
             foreach ($categories as $field => $frow) {
                 if (isset($category['parents'][$frow['level']])) {
                     $crow[$frow['id']] = mb_convert_encoding($category['parents'][$frow['level']], "Windows-1251", "UTF-8");
                 }
             }
             foreach ($fields as $field => $frow) {
                 switch ($frow['type']) {
                     default:
                         $crow[$frow['id']] = isset($row[$field]) ? mb_convert_encoding($row[$field], "Windows-1251", "UTF-8") : '';
                         break;
                     case 'select':
                         $crow[$frow['id']] = !empty($frow['vars'][$row[$field]]) ? mb_convert_encoding($frow['vars'][$row[$field]], "Windows-1251", "UTF-8") : "";
                         break;
                     case 'mselect':
                         $row[$field] = explode(',', $row[$field]);
                         foreach ($row[$field] as $j => $value) {
                             $row[$field][$j] = !empty($frow['vars'][(int) $value]) ? mb_convert_encoding($frow['vars'][(int) $value], "Windows-1251", "UTF-8") : "";
                         }
                         $crow[$frow['id']] = implode(', ', $row[$field]);
                         break;
                     case 'float':
                         $crow[$frow['id']] = round($row[$field], 2);
                         break;
                     case 'image':
                         if (preg_match("/^idimg([0-9]+)\$/i", $field, $mathes)) {
                             $sort = $mathes[1];
                             $images = A::$DB->getCol("SELECT path FROM " . DOMAIN . "_images WHERE idsec=" . SECTION_ID . " AND iditem=" . $row['id'] . " ORDER BY sort");
                             $crow[$frow['id']] = isset($images[$sort]) ? basename($images[$sort]) : "";
                         }
                         break;
                     case 'file':
                         if (preg_match("/^idfile([0-9]+)\$/i", $field, $mathes)) {
                             $sort = $mathes[1];
                             $files = A::$DB->getCol("SELECT path FROM " . DOMAIN . "_files WHERE idsec=" . SECTION_ID . " AND iditem=" . $row['id'] . " ORDER BY sort");
                             $crow[$frow['id']] = isset($files[$sort]) ? basename($files[$sort]) : "";
                         }
                         break;
                 }
             }
             if (isset($fields['mprice']) && isset($fields['price'])) {
                 $mprices = !empty($row['mprices']) ? unserialize($row['mprices']) : array();
                 foreach ($mprices as $mp) {
                     $crow[$fields['mprice']['id']] = mb_convert_encoding($mp['name'], "Windows-1251", "UTF-8");
                     $crow[$fields['price']['id']] = (double) $mp['price'];
                     $renderer->buildRow($i++, $crow);
                 }
                 if (empty($mprices)) {
                     $renderer->buildRow($i++, $crow);
                 }
             } else {
                 $renderer->buildRow($i++, $crow);
             }
         }
         A::$DB->free();
     }
     $renderer->render();
     $renderer->finalize();
     if (filesize($file = "files/" . DOMAIN . "/tmp/" . DOMAIN . "_" . getName(SECTION) . '.csv') > 1024 * 2000) {
         return outArchive("files/" . DOMAIN . "/tmp/" . DOMAIN . "_" . getName(SECTION) . ".tar.gz", $file);
     } else {
         require_once 'HTTP/Download.php';
         $params = array('file' => $file, 'contenttype' => 'text/csv', 'contentdisposition' => array(HTTP_DOWNLOAD_ATTACHMENT, basename($file)));
         HTTP_Download::staticSend($params, false);
     }
 }
コード例 #8
0
 /**
  * Temporary cleaner (assets, cache, logs, sitemap and thumbnails)
  * @param string $type Type
  * @return \Cake\Network\Response|null|void
  * @throws MethodNotAllowedException
  * @throws InternalErrorException
  * @uses clearCache()
  * @uses clearSitemap()
  */
 public function tmpCleaner($type)
 {
     if (!$this->request->is(['post', 'delete'])) {
         throw new MethodNotAllowedException();
     }
     switch ($type) {
         case 'all':
             $success = clearDir(Configure::read('Assets.target')) && clearDir(LOGS) && self::clearCache() && self::clearSitemap() && clearDir(Configure::read('Thumbs.target'));
             break;
         case 'cache':
             $success = self::clearCache();
             break;
         case 'assets':
             $success = clearDir(Configure::read('Assets.target'));
             break;
         case 'logs':
             $success = clearDir(LOGS);
             break;
         case 'sitemap':
             $success = self::clearSitemap();
             break;
         case 'thumbs':
             $success = clearDir(Configure::read('Thumbs.target'));
             break;
         default:
             throw new InternalErrorException(__d('me_cms', 'Unknown command type'));
     }
     if (!empty($success)) {
         $this->Flash->success(__d('me_cms', 'The operation has been performed correctly'));
     } else {
         $this->Flash->error(__d('me_cms', 'The operation has not been performed correctly'));
     }
     return $this->redirect($this->referer(['action' => 'tmpViewer']));
 }
コード例 #9
0
 public function deleteAlbumItem($share_id, $is_update = true)
 {
     $share_id = (int) $share_id;
     if (!$share_id) {
         return false;
     }
     $rec = FDB::fetchFirst('SELECT * FROM ' . FDB::table('album_rec') . ' WHERE ashare_id = ' . $share_id);
     if ($rec) {
         FDB::delete('album_rec', 'ashare_id = ' . $share_id);
         FDB::query('UPDATE ' . FDB::table('share_rec') . " SET rec_count = rec_count - 1 WHERE share_id = " . $rec['share_id']);
         $res = FDB::query('SELECT share_id FROM ' . FDB::table('share_rec') . ' WHERE rec_count = 0');
         $id_list = array();
         while ($data = FDB::fetch($res)) {
             $id_list[$data['share_id']] = $data['share_id'];
         }
         if (count($id_list) > 0) {
             $ids = implode(',', $id_list);
             $res = FDB::query('SELECT share_id FROM ' . FDB::table('share') . ' WHERE share_id IN (' . $ids . ')');
             while ($data = FDB::fetch($res)) {
                 unset($id_list[$data['share_id']]);
             }
             foreach ($id_list as $id) {
                 $key = getDirsById($id);
                 clearDir(PUBLIC_ROOT . './upload/share/' . $key, true);
             }
         }
         FDB::delete('share_rec', 'share_id = ' . $rec['share_id'] . ' AND rec_count = 0');
     }
     if ($is_update) {
         $album_id = (int) FDB::resultFirst('SELECT album_id FROM ' . FDB::table('album_share') . ' WHERE share_id = ' . $share_id);
         FDB::delete('album_share', '	share_id = ' . $share_id);
         AlbumService::updateAlbumByShare($album_id, $share_id, false);
         AlbumService::updateAlbum($album_id);
     }
     FS('Share')->deleteShare($share_id);
 }
コード例 #10
0
 public function systemClear()
 {
     $system_clear = $_SESSION['cache_system_clear'];
     if (empty($system_clear)) {
         $this->redirect('Cache/system');
     } else {
         $_SESSION['cache_system_clear'] = $system_clear;
     }
     @set_time_limit(3600);
     if (function_exists('ini_set')) {
         ini_set('max_execution_time', 3600);
         ini_set("memory_limit", "256M");
     }
     $this->display();
     ob_start();
     ob_end_flush();
     ob_implicit_flush(1);
     if (isset($system_clear['is_admin'])) {
         clearCache();
         echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS6') . '\',1);</script>');
     }
     Vendor('common');
     if (isset($system_clear['is_data'])) {
         usleep(100);
         include_once fimport('class/cache');
         Cache::getInstance()->updateCache();
         echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS7') . '\',1);</script>');
     }
     if (isset($system_clear['is_tpl'])) {
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/caches/static');
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/caches/dynamic');
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/compiled');
         usleep(50);
         clearDir(FANWE_ROOT . './public/data/tpl/caches/adv_position');
         @file_put_contents(FANWE_ROOT . './public/data/tpl/caches/page/is_clear.lock', TIMESTAMP);
         echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS8') . '\',1);</script>');
     }
     usleep(100);
     echoFlush('<script type="text/javascript">showmessage(\'' . L('SYSTEM_TIPS9') . '\',3);</script>');
     exit;
 }
コード例 #11
0
/**
 * 清除指定目录下的文件
 * 
 * @param string $dir
 *        	目录路径
 * @return void
 */
function clearDir($dir, $is_del_dir = false)
{
    if (!file_exists($dir)) {
        return;
    }
    $directory = dir($dir);
    while ($entry = $directory->read()) {
        if ($entry != '.' && $entry != '..') {
            $filename = $dir . '/' . $entry;
            if (is_dir($filename)) {
                clearDir($filename, $is_del_dir);
            }
            if (is_file($filename)) {
                removeFile($filename);
            }
        }
    }
    $directory->close();
    if ($is_del_dir) {
        @rmdir($dir);
    }
}
コード例 #12
0
ファイル: update.php プロジェクト: Nathan-11/SoftBB
        if ($file_cut[count($file_cut) - 1] == 'php') {
            $fileToGet = $file . '.txt';
        } else {
            $fileToGet = $file;
        }
        file_put_contents('../../' . $file, file_get_contents(file_get_contents('../update/depot.txt') . 'get.php?v=' . $version . '&&f=' . $fileToGet));
        echo 'File:' . $file;
    } elseif ($el->nodeName == 'sql') {
        $query = str_replace('{prefix}', $prefixtable, $el->nodeValue);
        $bdd->query($query) or die(print_r($bdd->errorInfo()));
        echo 'SQL:' . $query;
    } elseif ($el->nodeName == 'mkdir') {
        mkdir('../../' . $el->nodeValue, 0777, true);
    } elseif ($el->nodeName == 'rmdir') {
        require_once 'clearDir.php';
        clearDir('../../' . $el->nodeValue);
    } elseif ($el->nodeName == 'rmfile') {
        unlink('../../' . $el->nodeValue);
    } elseif ($el->nodeName == 'execFile') {
        $file = $el->nodeValue;
        $file_cut = explode('.', $file);
        if ($file_cut[count($file_cut) - 1] == 'php') {
            $fileToGet = $file . '.txt';
        } else {
            $fileToGet = $file;
        }
        file_put_contents('../update/' . $file, file_get_contents(file_get_contents('../update/depot.txt') . 'get.php?v=' . $version . '&&f=' . $fileToGet));
        require_once '../update/' . $file;
        unlink('../update/' . $file);
    }
}
コード例 #13
0
 public function deleteShareImages($share_id, $server_code)
 {
     if (empty($server_code)) {
         $key = getDirsById($share_id);
         clearDir(PUBLIC_ROOT . './upload/share/' . $key, true);
     } else {
         $server = FS("Image")->getServer($server_code);
         if ($server) {
             $args = array();
             $args['share_id'] = $share_id;
             $server = FS("Image")->getImageUrlToken($args, $server, 1);
             FS("Image")->sendRequest($server, 'removeshare');
         }
     }
 }
コード例 #14
0
ファイル: listdata.php プロジェクト: procivam/s-mir-new
 function Import()
 {
     require_once "Structures/DataGrid.php";
     require_once "Structures/DataGrid/DataSource/Excel.php";
     require_once "Structures/DataGrid/DataSource/CSV.php";
     require_once 'Image/Transform.php';
     A::$REGFILES = getSectionByModule('pages');
     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') {
             if ($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 ($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);
             if (isset($_REQUEST['clear'])) {
                 A::$DB->execute("TRUNCATE " . STRUCTURE);
             }
             $sort = A::$DB->getOne("SELECT MAX(sort) FROM " . STRUCTURE) + 1;
             $list = array();
             foreach ($datagrid->recordSet as $row) {
                 if (empty($row)) {
                     continue;
                 }
                 if ($ext == 'xls') {
                     $trow = array();
                     foreach ($row as $j => $value) {
                         if (!empty($value)) {
                             $trow[$j - 1] = $value;
                         }
                     }
                     $row = $trow;
                 }
                 $data = array();
                 if (!empty($row[0])) {
                     $data['name_' . LANG] = trim($row[0]);
                 } else {
                     continue;
                 }
                 $j = 1;
                 A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='" . STRUCTURE . "' ORDER BY sort");
                 while ($frow = A::$DB->fetchRow()) {
                     switch ($frow['type']) {
                         default:
                             $data[$frow['field']] = !empty($row[$j]) ? trim($row[$j]) : "";
                             break;
                         case 'int':
                             $data[$frow['field']] = !empty($row[$j]) ? (int) $row[$j] : 0;
                             break;
                         case 'float':
                             $data[$frow['field']] = !empty($row[$j]) ? (double) $row[$j] : 0;
                             break;
                         case 'select':
                             if (!empty($row[$j])) {
                                 if (!isset($list[$frow['property']])) {
                                     $list[$frow['property']] = loadList($frow['property']);
                                 }
                                 $row[$j] = trim($row[$j]);
                                 $key = array_search($row[$j], $list[$frow['property']]);
                                 if (empty($key) && !empty($row[$j])) {
                                     $key = addToList($frow['property'], $row[$j]);
                                     $list[$frow['property']][$key] = $row[$j];
                                 }
                                 if (!empty($key)) {
                                     $data[$frow['field']] = $key;
                                 }
                             }
                             break;
                         case 'mselect':
                             if (!empty($row[$j])) {
                                 if (!isset($list[$frow['property']])) {
                                     $list[$frow['property']] = loadList($frow['property']);
                                 }
                                 $row[$j] = explode(',', $row[$j]);
                                 $data[$frow['field']] = array();
                                 foreach ($row[$j] as $value) {
                                     $value = trim($value);
                                     $key = array_search($value, $list[$frow['property']]);
                                     if (empty($key) && !empty($value)) {
                                         $key = addToList($frow['idvar'], $value);
                                         $list[$frow['property']][$key] = $value;
                                     }
                                     if (!empty($key)) {
                                         $data[$frow['field']][] = sprintf("%04d", $key);
                                     }
                                 }
                                 $data[$frow['field']] = implode(",", $data[$frow['field']]);
                             }
                             break;
                         case 'bool':
                             $data[$frow['field']] = !empty($row[$j]) && $row[$j] != 'N' ? "Y" : "N";
                             break;
                         case 'image':
                             $row[$j] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$j]);
                             if (is_file($path = "ifiles/" . $row[$j])) {
                                 $data[$frow['field']] = RegisterImage($path, $data['name_' . LANG]);
                             }
                             break;
                         case 'file':
                             $row[$j] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$j]);
                             if (is_file($path = "ifiles/" . $row[$j])) {
                                 $data[$frow['field']] = RegisterFile($path, $data['name_' . LANG]);
                             }
                             break;
                     }
                     $j++;
                 }
                 A::$DB->free();
                 $data['sort'] = $sort++;
                 A::$DB->Insert(STRUCTURE, $data);
             }
             return true;
         }
     }
     return false;
 }
コード例 #15
0
ファイル: tools.inc.php プロジェクト: sucof/footlocker
function clearTemp($create)
{
    //temp
    writeLn("Clearing " . $GLOBALS['dir']['temp']);
    if (!clearDir($GLOBALS['dir']['temp'])) {
        fatalError("Failed to clear temp dir.");
    }
    if ($create) {
        writeLn("Creating " . $GLOBALS['dir']['temp']);
        createSubDir($GLOBALS['dir']['temp']);
    }
    //output
    writeLn("Clearing " . $GLOBALS['dir']['output'][0]);
    if (!clearDir($GLOBALS['dir']['output'][0])) {
        fatalError("Failed to clear output dir.");
    }
    if ($create) {
        writeLn("Creating " . $GLOBALS['dir']['output'][0]);
        createSubDir($GLOBALS['dir']['output'][0]);
    }
}
コード例 #16
0
    public function deleteShare($share_id, $is_score = true)
    {
        $share = ShareService::getShareById($share_id);
        if (!empty($share)) {
            $goods_count = FDB::resultFirst('SELECT COUNT(goods_id) FROM ' . FDB::table('share_goods') . ' WHERE share_id = ' . $share_id);
            $photo_count = FDB::resultFirst('SELECT COUNT(photo_id) FROM ' . FDB::table('share_photo') . ' WHERE share_id = ' . $share_id);
            $collect_count = FDB::resultFirst('SELECT COUNT(c_uid) FROM ' . FDB::table('user_collect') . ' WHERE share_id = ' . $share_id);
            FDB::delete('share', 'share_id = ' . $share_id);
            FDB::delete('share_goods', 'share_id = ' . $share_id);
            //FDB::delete('share_photo','share_id = '.$share_id);
            FDB::delete('share_category', 'share_id = ' . $share_id);
            FDB::delete('share_comment', 'share_id = ' . $share_id);
            FDB::delete('share_match', 'share_id = ' . $share_id);
            FDB::delete('share_tags', 'share_id = ' . $share_id);
            FDB::delete('user_collect', 'share_id = ' . $share_id);
            $pattern = "/#([^\f\n\r\t\v]{1,80}?)#/";
            if (preg_match($pattern, $share['content'])) {
                FS("Event")->deleteEvent($share_id);
            }
            $pattern = "/@([^\f\n\r\t\v@ ]{2,20}?)(?:\\:| )/";
            if (preg_match($pattern, $share['content'])) {
                FDB::delete('atme', 'share_id = ' . $share_id);
            }
            if (defined('MANAGE_HANDLER') && MANAGE_HANDLER && $is_score) {
                if (!in_array($share['type'], array('fav', 'album_best', 'album_rec'))) {
                    if ($share['rec_uid'] == 0 && in_array($share['share_data'], array('goods', 'photo', 'goods_photo'))) {
                        FS("User")->updateUserScore($share['uid'], 'delete_share', 'image', $share['content'], $share_id);
                    } else {
                        FS("User")->updateUserScore($share['uid'], 'delete_share', 'default', $share['content'], $share_id);
                    }
                }
            }
            FDB::query('UPDATE ' . FDB::table('user_count') . ' SET
				shares = shares - 1,
				photos = photos - ' . $photo_count . ',
				goods = goods - ' . $goods_count . ',
				collects = collects - ' . $collect_count . ' WHERE uid = ' . $share['uid']);
            $key = getDirsById($share_id);
            clearCacheDir('share/' . $key);
            $count = (int) FDB::resultFirst('SELECT COUNT(share_id) FROM ' . FDB::table('share_rec') . ' WHERE share_id = ' . $share_id);
            if ($count == 0) {
                clearDir(PUBLIC_ROOT . './upload/share/' . $key, true);
            }
        }
    }
コード例 #17
0
function bindCacheSetting()
{
    global $_FANWE;
    $settings = array();
    $js_settings = array();
    $res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1");
    while ($data = FDB::fetch($res)) {
        $name = strtolower($data['name']);
        $settings[$name] = $data['val'];
        if ($data['is_js'] == 1) {
            $js_settings[$name] = $data['val'];
        }
    }
    writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';');
    $pingJs = '';
    //采集JS初始化
    $pingJs = @file_get_contents(PUBLIC_ROOT . './js/demo.js');
    $domain = 'var domain = "' . $_FANWE['site_url'] . '"; ';
    $host_name = 'var hostName = "' . str_replace("http://", "", $_FANWE['site_url']) . '"; ';
    $tpl_name = 'var tplName = "' . $_FANWE['setting']['site_tmpl'] . '"; ';
    $yz_name = 'var global="TUPU";document[global]=document[global] || {};';
    $im_ping_js = '';
    $im_ping_js = $host_name . $domain . $tpl_name . $yz_name . $pingJs;
    writeFile(PUBLIC_ROOT . './js/im.ping.js', $im_ping_js);
    $config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php');
    $config_file = trim($config_file);
    $config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file);
    $config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file);
    @file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file);
    unset($config_file);
    $lang_arr = array();
    $lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php');
    foreach ($lang_files as $lang_file) {
        if (@(include $lang_file)) {
            foreach ($lang as $lkey => $lval) {
                $lang_pre = strtolower(substr($lkey, 0, 3));
                if ($lang_pre == 'js_') {
                    $lang_key = substr($lkey, 3);
                    if ($lang_key != '') {
                        $lang_arr[$lang_key] = $lval;
                    }
                }
            }
        }
    }
    writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';');
    clearDir(FANWE_ROOT . './public/data/tpl/css/');
    clearDir(FANWE_ROOT . './public/data/tpl/js/');
    $css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/';
    $css_cache_dir = FANWE_ROOT . './public/data/tpl/css/';
    $css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/';
    $directory = dir($css_dir);
    while ($entry = $directory->read()) {
        if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) {
            $css_path = $css_dir . $entry;
            $css_content = @file_get_contents($css_path);
            $css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content);
            $css_cache_path = $css_cache_dir . '/' . $entry;
            writeFile($css_cache_path, $css_content);
        }
    }
    $directory->close();
    FanweService::instance()->cache->saveCache('setting', $settings);
}
コード例 #18
0
ファイル: fileops.php プロジェクト: CMP-Studio/EmuObjectMover
function clearTempDir()
{
    $path = filepath() . "temp/*";
    clearDir($path);
}
コード例 #19
0
ファイル: const.php プロジェクト: severnaya99/Sg-2010
    @($op = 'default');
}
//Class
$modulesHandler =& xoops_getModuleHandler('TDMCreate_modules', 'TDMCreate');
$tablesHandler =& xoops_getModuleHandler('TDMCreate_tables', 'TDMCreate');
//menu
echo '<div class="CPbigTitle" style="background-image: url(../images/deco/const.png); background-repeat: no-repeat; background-position: left; padding-left: 50px;  height: 48px;"><strong>' . _AM_TDMCREATE_MANAGER_CONST . '</strong>';
echo '</div><br />';
switch ($op) {
    case "construction":
        //Nom du module
        $modules =& $modulesHandler->get($_REQUEST['modules_name']);
        $modules_name = $modules->getVar('modules_name');
        $modules_image = $modules->getVar('modules_image');
        //Effacer repertoire du nouveau module s'il existe
        clearDir(XOOPS_ROOT_PATH . '/modules/TDMCreate/modules/' . $modules_name);
        //Nom des tables et combien de tables
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('tables_modules', $_REQUEST['modules_name']));
        $nb_tables = $tablesHandler->getCount($criteria);
        $tables_arr = $tablesHandler->getall($criteria);
        //Debut
        echo '<table width="100%" cellspacing="1" class="outer">';
        /************************************************/
        /*Structure*/
        /************************************************/
        //Creation de l'architecture
        const_architecture($modules_name, $modules_image);
        //Creation de xoopsversion.php
        /*Mettre xoops version vers la fin pour integrer les bloc, etc*/
        const_xoopsversion($modules, $modules_name, $tables_arr);
コード例 #20
0
ファイル: clean.php プロジェクト: Nathan-11/SoftBB
<?php

require_once 'clearDir.php';
clearDir('../update/');
コード例 #21
0
/**
 * 清空缓存目录
 * @param string $dir 缓存目录
 * @return void
 */
function clearCacheDir($dir)
{
    clearDir(PUBLIC_ROOT . './data/caches/custom/' . $dir, true);
}
コード例 #22
0
ファイル: addalbum_m.php プロジェクト: ATS001/PRSIT
function addalbum($titrfr, $titren, $img, $id, $titrear)
{
    global $db;
    $values["titrfr"] = MySQL::SQLValue($titrfr);
    $values["titren"] = MySQL::SQLValue($titren);
    $values["titrar"] = MySQL::SQLValue($titrear);
    $values["album"] = MySQL::SQLValue(changnom($img, $id, 'Album_'));
    $values["arch"] = MySQL::SQLValue("0");
    // Execute the insert
    $result = $db->InsertRow("album", $values);
    // If we have an error
    if (!$result) {
        // Show the error and kill the script
        $db->Kill($result);
        return false;
    } else {
        $basedir = "upload/album/";
        //if(!file_exists($basedir)){mkdir($basedir);}
        if (!file_exists($basedir . "/" . $id)) {
            mkdir($basedir . "/" . $id, 0, true);
        }
        $newdir = "../upload/album/" . $id . "/";
        if (!file_exists($newdir)) {
            mkdir($newdir, 0, true);
        }
        if ($img != "") {
            copyfile($img, $id, $basedir, "Album_");
            clearDir($newdir);
            extractzip($basedir, "Album_" . $id . ".zip", $id, $newdir);
        }
        return true;
    }
}