📄 directories.php
字号:
$this->types['int'] = array('Whole Value'); $this->types['tinyint'] =& $this->types['int']; $this->types['smallint'] =& $this->types['int']; $this->types['mediumint'] =& $this->types['int']; $this->types['bigint'] =& $this->types['int']; // // Get detailed information from the table // $this->variables= array(); $avoid = array( 'file_id'=>1,'owner'=>1,'title'=>1, 'content'=>1,'ip'=>1,'username'=>1, 'hitcounter'=>1,'summary'=>1); $table = $tempObject->dbInfo['dbTable']; $query = 'SHOW FULL COLUMNS FROM '.$table; $result = wbDB::runQuery($query); while($row = mysql_fetch_assoc($result)){ if(isset($avoid[$row['Field']])){ continue; } $field =& $row['Field']; if( $pos = strpos($row['Type'],'(')){ $type = substr($row['Type'],0,$pos); }else{ $type =& $row['Type']; } if( !isset($this->types[$type]) ){ continue; } $this->variables[$field] = $type; } $this->variables['keywords'] = 'varchar'; $this->variables['modified'] = 'timestamp'; $this->variables['posted'] = 'timestamp'; $this->variables['created'] = 'timestamp'; } function selectVariables($name,$i){ echo '<select name="'.$name.'[]">'; echo '<option value="">-ignore-</option>'; foreach($this->variables as $field => $type){ echo '<option value=""></option>'; echo '<optgroup label="'.$field.'" title="'.$field.'">'; $this->selectVariables2($name,$i,$field,$type); echo '</optgroup>'; } echo '</select>'; } function selectVariables2($name,$i,$field,$type){ $temp = array(); $temp = $this->types[$type]; foreach($temp as $how){ $value = $field.':'.$how; if( isset($_POST[$name][$i]) && ($_POST[$name][$i] == $value) ){ echo '<option value="'.$value.'" selected="selected">'.$how.'</option>'; }else{ echo '<option value="'.$value.'">'.$how.'</option>'; } } } function create(){ global $dbInfo,$page; $page->displayTitle = 'Create New Directory'; $_POST += array( 'limit'=>'20', 'where'=>'', 'pre'=>'', 'post'=>'', ); // // Check // if( !$this->checkName() ){ return false; } $this->setVariables(); // // Get Object // echo '<table>'; echo '<tr>'; echo '<td>'; echo '<fieldset style="padding:1em;">'; echo '<legend>Structure</legend>'; echo '<table cellpadding="3" border="0">'; echo '<tr>'; echo '<td colspan="2">'; echo '<h4 class="heading">Name</h4>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td></td><td>'; echo $_POST['name']; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2">'; echo '<h4 class="heading">Levels*</h4>'; echo '</td>'; echo '<td colspan="2">'; echo '<h4 class="heading">Where</h4>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td style="white-space:nowrap;"> </td>'; echo '<td style="width:25em">'; echo '<table cellpadding="0" cellspacing="0">'; $i = 0; foreach($this->variables as $null){ echo '<tr>'; echo '<td>'; $this->selectVariables('columns',$i); echo '</td>'; echo '</tr>'; $i++; } echo '</table>'; echo '</td>'; // // Where // echo '<td></td>'; echo '<td>'; echo '<textarea name="where" rows="5" cols="30">'; echo htmlspecialchars($_POST['where']); echo '</textarea>'; echo '</td>'; echo '</tr>'; // // Finish // echo '</table>'; echo '</fieldset>'; echo '</td>'; echo '</tr><tr>'; echo '<td>'; echo '<fieldset style="padding:1em;height:100%;">'; echo '<legend>Display</legend>'; echo '<table cellpadding="3" border="0">'; echo '<tr>'; echo '<td colspan="2">'; echo '<h4 class="heading">Order By</h4>'; echo '</td>'; echo '<td colspan="2">'; echo '<h4 class="heading">Limit</h4>'; echo '</td>'; echo '</tr>'; echo '<tr>'; // // Order By // $order2['ASC'] = 'Ascending'; $order2['DESC'] = 'Descending'; echo '<td style="white-space:nowrap;"> </td>'; echo '<td style="width:25em">'; echo '<table cellpadding="0" cellspacing="0">'; $i = 0; foreach($this->variables as $null){ echo '<tr>'; echo '<td>'; $this->selectVariables('order',$i); echo '</td>'; echo '<td>'; echo '<select name="order2[]">'; foreach($order2 as $value => $disp){ if( isset($_POST['order2'][$i]) && ($_POST['order2'][$i] == $value)){ echo '<option value="'.$value.'" selected="selected">'.$disp.'</option>'; }else{ echo '<option value="'.$value.'">'.$disp.'</option>'; } } echo '</select>'; echo '</td>'; echo '</tr>'; $i++; } echo '</table>'; echo '</td>'; // // Limit // echo '<td></td>'; echo '<td>'; echo '<input name="limit" type="text" size="4" value="'.htmlspecialchars($_POST['limit']).'" />'; echo '</td>'; echo '</tr>'; // // Headings // echo '<tr>'; echo '<td colspan="2">'; echo '<h4 class="heading">Top of Page</h4>'; echo '</td>'; echo '<td colspan="2">'; echo '<h4 class="heading">Bottom of Page</h4>'; echo '</td></tr>'; echo '<tr>'; echo '<td style="white-space:nowrap;"> </td>'; echo '<td style="width:25em">'; echo '<textarea name="pre" rows="5" cols="30">'; echo htmlspecialchars($_POST['pre']); echo '</textarea>'; echo '</td>'; echo '<td style="white-space:nowrap;"> </td>'; echo '<td style="width:25em">'; echo '<textarea name="post" rows="5" cols="30">'; echo htmlspecialchars($_POST['post']); echo '</textarea>'; echo '</td></tr>'; echo '</table>'; echo '</fieldset>'; echo '</td>'; echo '</tr><tr>'; echo '<td style="text-align:center;">'; echo '<input type="submit" name="cmd" value="Finish" />'; echo ' <input type="submit" name="cmd" value="Start Over" />'; echo '<input type="hidden" name="name" value="'.htmlspecialchars($_POST['name']).'" />'; echo '<input type="hidden" name="space" value="'.htmlspecialchars($_POST['space']).'" />'; echo '<br/><span class="sm">* Levels is the only required setting.</span>'; echo '</td></tr>'; echo '</table>'; return true; } function setCurrent(){ global $dbInfo; foreach($dbInfo as $space => $info){ if( isset($info['dirs']) ){ $this->current[$space] = $info['useInfo']; } } } function showCurrent(){ global $dbInfo,$lang; if( count($this->current) < 1 ){ return; } echo '<tr>'; echo '<td>'; echo '<fieldset style="padding:1em;">'; echo '<legend>Current Directories</legend>'; echo '<table class="tableRows">'; echo '<tr>'; echo '<th>'; echo 'Name'; echo '</th>'; echo '<th>'; echo 'Built On Data Type'; echo '</th>'; // echo '<th>'; // echo 'Structure'; // echo '</th>'; echo '<th>'; echo 'Similar To'; echo '</th>'; echo '<th>'; echo 'Options'; echo '</th>'; echo '</tr>'; $i = 0; $classes[] = ' class="tableRowEven" '; $classes[] = ' class="tableRowOdd" '; foreach($this->current as $name => $useInfo){ $i++; echo '<tr>'; echo '<tr'.$classes[($i%2)].'>'; echo '<td>'; $temp = $name; if( isset($lang[$name]) ){ $temp = $lang[$name]; } echo wbLinks::local('/'.$name,$temp); echo '</td>'; echo '<td>'; echo $useInfo; echo '</td>'; // echo '<td>'; // $indent = ''; // foreach($dbInfo[$name]['dirs'] as $level => $null){ // echo $indent.'<span class="sm">'.$level.'</span>'; // echo '<br/>'; // $indent = '>'.$indent.' '; // } // echo '</td>'; echo '<td>'; if( isset($dbInfo[$name]['similar']) ){ $tempA = array(); foreach($dbInfo[$name]['similar'] as $simSpace){ $temp = $simSpace; if( isset($lang[$simSpace]) ){ $temp = $lang[$simSpace]; } $tempA[] = $temp; } echo implode(', ',$tempA); }else{ echo ' - '; } echo '</td>'; echo '<td>'; echo wbLinks::admin('Directories?cmd=edit&name='.$name,'edit'); echo ' '; echo wbLinks::admin('Directories?cmd=removeDir&name='.$name,'Remove'); echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</fieldset>'; echo '</td>'; echo '</tr>'; } function removeDirCheck(){ echo '<div style="text-align:center;padding:3em;">'; echo 'Are you sure you want to remove <tt>'.$_GET['name'].'</tt>?<br/>'; echo '<input type="submit" value="Cancel" /> '; echo ' <input type="submit" name="cmd['.$_GET['name'].']" value="Confirm Removal" /> '; echo '</div>'; } function removeDir(){ global $dbInfo,$dbObject,$page; $name =& $page->cmdArg[0]; if( !isset($dbInfo[$name]) ){ message($name.' was an invalid argument.'); return; } if( !isset($dbInfo[$name]['dirs']) ){ message($name.' was an invalid argument.'); return; } $data = $dbObject->getConfiguration(); if(isset($data['dbInfo'][$name]['dbPlugin'])){ includeFile('admin/PluginAdd.php'); pluginAdd::removeObject('class:'.$data['dbInfo'][$name]['class']); } unset($data['dbInfo'][$name]); $this->removeSimilar($data,$name); if( !$dbObject->updateConfig($data) ){ echo 'Oops, the directory wasn\'t deleted successfully, please try again.'; } message('The selected directory was removed.'); unset($this->current[$name]); } function removeSimilar(&$data,$name){ foreach($data['dbInfo'] as $space => $info){ if( !isset($info['dirs']) ){ continue; } if( !isset($info['similar']) ){ continue; } $key = array_search($name,$info['similar']); if( $key !== false){ unset($info['similar'][$key]); unset($data['dbInfo'][$space]['similar'][$key]); } if( !is_array($info['similar']) || (count($info['similar']) < 1) ){ unset($info['similar']); unset($data['dbInfo'][$space]['similar']); } } } function form(){ global $lang; $_POST += array('name'=>''); echo '<tr>'; echo '<td>'; echo '<fieldset style="padding:1em;">'; echo '<legend>Create New Directory</legend>'; echo '<table>'; echo '<tr>'; echo '<td>'; echo 'Name: '; echo '</td>'; echo '<td>'; echo '<input type="text" size="20" name="name" value="'.htmlspecialchars($_POST['name']).'" />'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo 'Over Space: '; echo '</td>'; echo '<td>'; echo '<select name="space">'; foreach($this->spaces as $space => $null){ echo '<option value="'.$space.'">'.$lang[$space].'</option>'; } echo '</select>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo '</td>'; echo '<td>'; echo '<input type="submit" name="cmd" value="Create" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</fieldset>'; echo '</td>'; echo '</tr>'; } ////////////////////////////////////////////////// // // editing // // see class toolDbObjects }new createDirectory();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -