Запись [f:_dev/main/area.php] < dev.sky.1.001
Версия 1.001
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | <?php defined('START') or die; //if (!class_exists('Area')) { class Area { static function main(&$syn, &$set) { $syn = true; $set = $area = []; $post = $_POST && isset($_POST['inc_p']); foreach (['inc', 'exc'] as $k) foreach (['p', 't', 'r'] as $v) { if ($post) { # write $v = preg_replace("/([ \n]){2,}/s", "$1", unl(trim($_POST[$kv = "{$k}_$v"]))); unset($_POST[$kv]); $set["u_$kv"] = escape($v, true); } else { # read $kv = "{$k}_$v"; $v = $GLOBALS["u_$kv"] = unescape($GLOBALS["u_$kv"], true); } $area[$kv] = $v = preg_replace("/\s+/s", ' ', $v); if (0 /* 2do: check syntax */) $area[$kv] = $syn = false; } if ($set) set($set, 0, defined('ID') ? ID : 2); return (object)$area; } static function init() { $area = @self::main($syn); // $me = new Area(); list($dir_list, $skip, $nused, $files2) = self::filter_path($area->inc_p, $area->exc_p); set([ 'dirs' => implode(' ', $dir_list), 'skip' => implode(' ', $skip), 'files2' => implode(' ', $files2), 'i_dir=i_file=cells=cell' => 0, 'rows' => implode(' ', self::filter_rows($area->inc_r, $area->exc_r)), ]); } static function lst($dir, $what = false, $up = false, $skip = []) { if ($dir === '/' || $dir === '') $dir = '.'; $list = $up ? ['..'] : []; if ($dh = @opendir($dir)) { global $u_svn_skips; is_array($skip) or $skip = str2ary($skip); while ($name = readdir($dh)) { if ($name == '.' || $name == '..' || in_array($name, $u_svn_skips)) continue; $path = $dir == '.' ? $name : "$dir/$name"; foreach ($skip as $s) if (preg_match("|^$s$|", $path)) continue 2; if (!$what) $list[$path] = is_file($path); # unix link ? elseif ($what($path)) $list[] = $path; } closedir($dh); } return $list; } function file($text_only = false, $utf8_check = false) { global $dirs, $files, $skip, $i_dir, $i_file; if ($i_dir < count($dirs = str2ary($dirs))) { if ($i_file) $files = str2ary($files); else { $files = is_file($dirs[$i_dir]) ? [$dirs[$i_dir]] : self::lst($dirs[$i_dir], 'is_file', false, $skip); set('files', implode(' ', $files)); } if ($i_file >= count($files)) { set(['i_file' => 0, 'i_dir' => ++$i_dir]); } else { $this->ft = rectype($this->fn = $files[$i_file]); set('i_file', ++$i_file); if (!$text_only || 1 == $this->ft) return getfile($this->fn, $this->ft, $utf8_check); } return false; } set(['cells' => 1, 'i_dir=i_file=dirs' => 0]); return true; # end } function row() { global $rows, $table, $struc, $i_dir, $i_file, $dirs; if ($i_dir < count($rows = str2ary($rows))) { list ($table, $cn, $cp, $where) = explode('.', $rows[$i_dir], 4); if ($dirs !== $table) { for ($q = sql("explain $table"), $struc = []; $r = fetch($q, true); $struc[$r[0]] = $r[1]); set(['struc' => serialize($struc), 'dirs' => $table]); } if (eval(sqlf("^select * from $table $where %s limit $i_file, 1", $cn ? "order by $cn" : ''))) { $this->fn = $cn ? "$table.$cn=$r[$cn]" : "^$table.$i_file"; set('i_file', ++$i_file); return $r; } else { set(['i_file' => 0, 'i_dir' => ++$i_dir]); return false; } } return true; # end } static function filter_path($u_inc_p, $u_exc_p) { $dir_list = $skip = $files2 = []; if ($used = $u_inc_p !== '' && $u_exc_p !== '*') { global $u_svn_skips; $u_inc_p = str2ary($u_inc_p); $skip = str2ary(trim($u_exc_p)); array_walk($skip, create_function('&$_', '$_ = str_replace("*", ".*?", str_replace(".", "\\\\.", $_));')); foreach ($u_inc_p as $dir) { if (in_array(basename($dir), $u_svn_skips)) continue; foreach ($skip as $s) if (preg_match("|^$s$|", $dir)) continue 2; $dir_list = array_merge($dir_list, $d = walk_dirs($dir, $skip)); if (1 === count($d) && is_file($dir)) $files2[] = $dir; } } return [array_unique($dir_list), $skip, !$used, array_unique($files2)]; } static function filter_rows($u_inc_r, $u_exc_r) { $list = []; if ($u_inc_r && $u_exc_r !== '/') { $ary = $u_inc_r === '/' ? array_map(create_function('$_','return "$_.*";'), fetch(sql('show tables'), 0)) : explode(' ', $u_inc_r); foreach ($ary as $row) { $exc = ''; list($id_pos, $id_name, $table, $inc) = table_id_test($row); foreach (str2ary($u_exc_r) as $val) if ("$table." == substr($val, 0, strlen("$table."))) { list(, $exc) = explode('.', $val); if ($exc === '*') continue 2; break; } if ($inc == "*" && !$exc) $sql = ''; else { $sql = $inc === '*' ? 'where' : 'where ' . parse_where($id_name, $inc, $exc); if ($exc) $sql .= ($inc === '*' ? ' ' : ' and ') . 'not ' . parse_where($id_name, $exc, $inc != '*'); } if ($id_pos === '!') $sql = sprintf(span_r, ' - table not exists, skipped'); if ($id_pos === '?') $sql = sprintf(span_r, ' - table do not have auto_increment column, skipped'); $list[] = "$table.$id_name.$id_pos." . str_replace(' ', "\t", $sql); } } return $list; } function filter_tables($inc, $exc, $mand = [], $test = '') { if ($inc === '' || $exc === '/') return $mand; $list = '' === $test ? fetch(sql("show tables"), 0) : [$test]; if ($inc === '/' && $exc === '') return $list; $inc = $inc == '/' ? false : preg_split("/\s+/sm", $inc); $exc = $exc == '' ? false : preg_split("/\s+/sm", $exc); $ret = []; foreach ($list as $table) if (item_match_list($table, $inc, $exc)) array_push($ret, $table); $diff = $mand ? array_diff($mand, $ret) : []; return array_merge($ret, $diff); } function ta_3($ie) { return ; } function html() { echo $this->ta_3('inc') . $this->ta_3('exc'); echo tag("$explane Definitions can be listed via space or new line.", 'style="background:#dfd;padding: 10px;margin-bottom:5px"'); if (!$area) { } } } if (!isset($sky)) global $sky; if (!$sky->area): # HTML PAGE $sky->area = true; $str = !$WVAL && $PVAL == 'scripts' ? 'is the standard for new applications' : "inherited from this Snapshot ID=$WVAL"; $area = 'area' == $PVAL; $copyto = 'copyto' == $PVAL; if ($sar = 'sar' == $PVAL) { $dis_tar = ' disabled class="dis_tar"'; } else $dis_tar = ''; $undev = in_array($PVAL, ['snapshots', 'scripts']); eval(cell(99, 'm')); $areas = eval('return ' . unescape($areas, true) . ';'); $areas_opt = [-2 => 'DEV.SKY.', -1 => 'Others'] + array_map(create_function('$v', 'return $v[6];'), $areas); if ('snapshots' == $PVAL) $explane = '<u>Please define area - what you want to save in snapshot:</u><br><hr>'; elseif ('scripts' == $PVAL) $explane = "This Area definition $str<br>You should leave it `AS IS` in most cases. However you can correct it.<hr>"; else $explane = ''; $_POST or @Area::main($syn); $title = 'compare' == $PVAL ? 'This instance' : 'Area definition'; $edit = $WVAL && $PVAL == 'scripts' ? '' : ' - <a href="?settings=dev&edit">edit</a>'; ?> <fieldset id="area_list"><legend><?=$title?></legend> <?if(!$area):?><div style="float:right; margin:-5px 0 5px 0">Presets: <select onchange="area(this.value)" style="font-size:10px"><?=option(-3, [-3 => '--'] + $areas_opt)?></select> <a href="?utility=area">edit</a></div> <?endif?> <?if ($undev):?>Application under development: <b><?=strtoupper($u_my_app)?></b> - <a href="?settings=dev&edit">edit</a><?endif?> <br> <div style="float:left;width:30%;"> <label>include paths: <span class="pop" id="pop_ip">?</span></label> <textarea name="inc_p" style="width:100%" rows="3"><?=$u_inc_p?></textarea> </div> <div style="float:left;width:27%;margin-left:10px"> <label>include tables structure: <span class="pop" id="pop_it">?</span></label> <textarea name="inc_t" style="width:100%"<?=$dis_tar?> rows="3"><?=$u_inc_t?></textarea> </div> <div style="float:left;width:39%;margin-left:10px"> <label>include tables rows: <span class="pop" id="pop_ir">?</span></label> <textarea name="inc_r" style="width:100%" rows="3"><?=$u_inc_r?></textarea> </div> <div style="clear:both"></div><br> <div style="float:left;width:30%;"> <label>exclude paths: <span class="pop" id="pop_ep">?</span></label> <textarea name="exc_p" style="width:100%" rows="3"><?=$u_exc_p?></textarea> </div> <div style="float:left;width:27%;margin-left:10px"> <label>exclude tables structure: <span class="pop" id="pop_et">?</span></label> <textarea name="exc_t" style="width:100%"<?=$dis_tar?> rows="3"><?=$u_exc_t?></textarea> </div> <div style="float:left;width:39%;margin-left:10px"> <label>exclude tables rows: <span class="pop" id="pop_er">?</span></label> <textarea name="exc_r" style="width:100%" rows="3"><?=$u_exc_r?></textarea> </div> <div style="clear:both"></div> <div style="background:#dfd;padding: 10px;margin-bottom:5px"><?=$explane?> Definitions can be listed via space or new line.</div> <?if(!$area):?> Will skipped in all subdirs <u>SVN skips:</u> "<span style="background:white"><?=implode(' ', $u_svn_skips)?></span>"<?=$edit?><br> <?if (!$copyto):?><div id="text-files"><u>Text files:</u> "<?=implode(' ', $u_text_files) . '"' . $edit?></div><?endif?> <div id="php-files" style="display:none"><u>PHP files:</u> "<?=$u_php_files . '"' . $edit?></div> <?endif?> </fieldset> <script type="text/javascript"> var f1 = $('f1'); function area(v) { var i, tas = $$('textarea', 'area_list'); if (-2 == v) v = ['_dev dev.php', '_dev_', '_dev_codebase.-10000 _dev_help.* _dev_memory.-1000 _dev_packages.1', '_dev/temp', '', '']; else if (-1 == v) v = ['/', '/', '', '_arch _dev dev.php', '_dev_', '']; else if (-3 == v) return; else return ajax('area' + v + '&l=_' + qs_area(), function(r, err) { r = callback(r, err); for (i in tas) tas[i].value = r[i]; }); for (i in tas) tas[i].value = v[i]; } <?if(!$WVAL && $PVAL=='scripts'):?>area(-1)<?endif?> </script> <?endif?> |
Записи Codebase (89)
Статус SKY.
Current version: 1.001
Coresky records: 22
Local (DEV) records: 89
Web (all) records: 105
Download: dev.php
Coresky records: 22
Local (DEV) records: 89
Web (all) records: 105
Download: dev.php