function str_replace_action() { chkpw('func_data_replace'); if(front::post('submit') &&front::post('sfield') &&front::post('replace1')) { $field=front::post('sfield'); $table=front::post('stable'); $table=new $table(); $replace1=front::post('replace1'); $replace2=front::post('replace2'); $where=front::post('where'); if(!$where) { $table->getFields(); $where=$table->primary_key.'>0'; } $table->rec_update( " `$field` = REPLACE($field,'$replace1','$replace2')",$where); front::flash("成功替换!"); } $_tables=tdatabase::getInstance()->getTables(); $this->view->tables=array(0=>'请选则项目...'); if(config::get('test_data')) $prefix='test_'; else $prefix=config::get('database','prefix'); foreach($_tables as $table) { if(!eregi($prefix,$table['name'])) continue; $name=str_replace($prefix,'',$table['name']); $name=str_replace('a_','',$name); $_name=lang($name); if($_name<>$name) $this->view->tables[$name]=$_name; } }
private function get_my_tables() { $tables=array(); $forms=tdatabase::getInstance()->getTables(); foreach($forms as $form) { if(preg_match('/^'.config::get('database','prefix').'(my_\w+)/xi',$form['name'],$res)) $tables[]=$res[1]; } return $tables; }
public function res2items($res) { if (!$res) { return array(); } $result = array(); $db = litepublisher::$db; while ($item = $db->fetchassoc($res)) { $id = (int) $item['id']; $item['idgroups'] = tdatabase::str2array($item['idgroups']); $result[] = $id; $this->items[$id] = $item; } return $result; }
require_once litepublisher::$paths->lib . 'options.class.php'; require_once litepublisher::$paths->lib . 'site.class.php'; } else { require_once litepublisher::$paths->lib . 'kernel.php'; } define('dbversion', true); /* if (class_exists('Memcache')) { tfilestorage::$memcache = new Memcache; tfilestorage::$memcache->connect('127.0.0.1', 11211); } */ if (!tstorage::loaddata()) { if (file_exists(litepublisher::$paths->data . 'storage.php') && filesize(litepublisher::$paths->data . 'storage.php')) { die('Storage not loaded'); } require_once litepublisher::$paths->lib . 'install' . DIRECTORY_SEPARATOR . 'install.php'; } litepublisher::$classes = tclasses::i(); litepublisher::$options = toptions::i(); litepublisher::$db = tdatabase::i(); litepublisher::$site = tsite::i(); litepublisher::$urlmap = turlmap::i(); if (!defined('litepublisher_mode')) { litepublisher::$urlmap->request(strtolower($_SERVER['HTTP_HOST']), $_SERVER['REQUEST_URI']); } } catch (Exception $e) { litepublisher::$options->handexception($e); } litepublisher::$options->savemodified(); litepublisher::$options->showerrors();
function restoreTables($file) { set_time_limit(0); $database=new tdatabase(); $sqlquery=file_get_contents($file); if (!$sqlquery) return; $sqlquery=str_replace("\r","",$sqlquery); $sqls=split(";[ \t]{0,}\n",$sqlquery); $nerrCode=""; $i=0; foreach ($sqls as $q) { $q=trim($q); if ($q == "") { continue; } if ($database->query($q)) $i++; else $nerrCode .= "执行: <font color='blue'>$q</font> 出错!</font><br>"; } }
public function __set($name, $value) { if (method_exists($this, $set = "set{$name}")) { return $this->{$set}($value); } if (in_array($name, self::$arrayprops)) { $this->post->data[$name] = tdatabase::str2array($value); } elseif (in_array($name, self::$intprops)) { $this->post->{$name} = (int) $value; } elseif (in_array($name, self::$boolprops)) { $this->post->data[$name] = $value == '1'; } else { $this->post->{$name} = $value; } }
protected function set_post(tpost $post) { extract($_POST, EXTR_SKIP); $post->title = $title; $cats = self::processcategories(); $cats = array_unique($cats); array_delete_value($cats, 0); array_delete_value($cats, ''); array_delete_value($cats, false); array_delete_value($cats, null); $post->categories = $cats; if ($post->id == 0 && litepublisher::$options->user > 1) { $post->author = litepublisher::$options->user; } if (isset($tags)) { $post->tagnames = $tags; } if (isset($icon)) { $post->icon = (int) $icon; } if (isset($idview)) { $post->idview = $idview; } if (isset($files)) { $files = trim($files, ', '); $post->files = tdatabase::str2array($files); } if (isset($date) && $date) { $post->posted = tadminhtml::getdatetime('date'); } if (isset($status)) { $post->status = $status == 'draft' ? 'draft' : 'published'; $post->comstatus = $comstatus; $post->pingenabled = isset($pingenabled); $post->idperm = (int) $idperm; if ($password != '') { $post->password = $password; } } if (isset($url)) { $post->url = $url; $post->title2 = $title2; $post->keywords = $keywords; $post->description = $description; $post->rawhead = $head; } $post->content = $raw; if (isset($excerpt)) { $post->excerpt = $excerpt; } if (isset($rss)) { $post->rss = $rss; } if (isset($more)) { $post->moretitle = $more; } if (isset($filtered)) { $post->filtered = $filtered; } if (isset($upd)) { $update = sprintf($this->lang->updateformat, tlocal::date(time()), $upd); $post->content = $post->rawcontent . "\n\n" . $update; } }
function get_my_tables_list() { $tables = array('继承', '不绑定'); $forms = tdatabase::getInstance()->getTables(); foreach ($forms as $form) { if (preg_match('/^' . config::get('database', 'prefix') . '(my_\w+)/xi', $form['name'], $res)) $tables[$res[1]] = setting::$var[$res[1]]['myform']['cname']; } return $tables; }
echo uri(); ?> " method="post"> <div id="tagscontent" class="right_box"> <table border="0" cellspacing="0" cellpadding="0" name="table1" id="table1" width="100%"> <thead> <tr class="th"> <th style="width:60px;"><input title="点击可全选本页的所有项目" onclick="CheckAll(this.form)" type="checkbox" name="chkall" class="checkbox" /></th> <th>表名</th> <th>记录数</th> <th>大小</th> </tr> </thead> <tbody> <?php foreach (tdatabase::getInstance()->getTables() as $table) { ?> <tr class="s_out"> <td style="width:60px;" align="center"><input onclick="c_chang(this)" type="checkbox" value="<?php echo $table['name']; ?> " name="select[]" class="checkbox" /></td> <td align="left" style="padding-left:10px;"><?php echo $table['name']; ?> </td> <td align="left" style="padding-left:10px;"><?php echo $table['count']; ?> </td> <td align="left" style="padding-left:10px;"><?php