📄 options.php
字号:
<?phpdefined('WikyBlog') or die("Not an entry point...");//// PAGE ACTION FUNCTIONS//if( !isOwner(true,false) ){ return;}wbLang::getFile('toolOptions');//returns true if visibility was changed, false otherwisefunction setNewFlags(){ // not much checking going on here // there's not really anything anyone could do by adding undefined flags global $dbObject; $empty = array(''); // We only want it to affect these values // 'admin', 'locked', 'hidden', 'restricted', 'nocomments', 'registered' // $changeThese = array('admin', 'locked', 'hidden', 'restricted', 'nocomments', 'registered'); //must be the owner to get this far.. // just check to make sure there's not an admin lock if( !$dbObject->editable ){ message('You must be the administrator.'); return; } // 0) Before $arrayBefore = explode(',',$dbObject->flags); $arrayBefore = array_diff($arrayBefore,$empty); sort($arrayBefore); if( strpos($dbObject->flags,'hidden') !== false){ $hiddenBefore = true; }else{ $hiddenBefore = false; } $arrayAfter = array_diff($arrayBefore,$changeThese); // 1) After $hiddenAfter = false; $_POST += array('permission'=>'','visibility'=>'','commenting'=>''); $arrayAfter['permission'] = $_POST['permission']; $arrayAfter['visibility'] = $_POST['visibility']; $arrayAfter['commenting'] = $_POST['commenting']; $arrayAfter = array_diff($arrayAfter,$empty); sort($arrayAfter); // 2) Update?? if( $arrayAfter === $arrayBefore){ message('OPTIONS_NOT_CHANGED'); return false; } $dbObject->flags = implode(',',$arrayAfter); // 4) Was "hidden" changed? if( strpos($dbObject->flags,'hidden') !== false){ $hiddenAfter = true; } if( $hiddenAfter === $hiddenBefore){ return array(true,false); }else{ return array(true,true); }}function saveFlags($do){ global $dbObject,$wbTables; if( !$do ){ return; } if( !$dbObject->exists ){ message('FILE_MUST_EXIST'); return; } $query = 'UPDATE '.$wbTables['all_files']; $query .= ' SET `flags` = "'. $dbObject->flags.'" '; $query .= ', `modified` = `modified` '; $query .= ' WHERE `file_id` = "'.$dbObject->file_id.'"'; $result = wbDB::runQuery($query); $num = mysql_affected_rows(); if($num == 0){ message('OPTIONS_NOT_UPDATED'); return; } //Success, doKeys? message('OPTIONS_UPDATED'); if( $do[1] ){ includeFile('tool/Tags.php'); if( strpos($dbObject->flags,'hidden') !== false){ //Now Hidden updateTags($dbObject->keywords,''); allSearch::remove($dbObject); }else{ //Now Visible updateTags('',$dbObject->keywords); allSearch::update($dbObject); } }}// Advanced File Optionsfunction getOptions(){ global $page,$dbObject,$pageOwner; global $lang,$jsNum; //this could happen if a user accesses the ?cmd=options page when they aren't authorised.. // this could happen to someone with Owner privileges on a Admin_only page // they still won't be able to do anything to the options but this way the links will be correct // if( empty($dbObject->links[$lang['options']]) ){ $dbObject->links[$lang['options']] = '/Edit'.$dbObject->uniqLink.'?cmd=options'; } $page->formAction = $dbObject->links[$lang['options']]; $optionsArray = array(); ob_start(); $flagsArray = explode(',',$dbObject->flags); $checked['global'] = false; $checked['restricted'] = false; $checked['registered'] = false; $checked['locked'] = false; $checked['admin'] = false; $checked['hidden'] = false; $checked['visible'] = false; $checked['nocomments'] = false; $checked['comments'] = false; foreach($flagsArray as $value){ $checked[$value] = ' checked="checked" '; } $size = 0; foreach($dbObject->userValues as $key =>$value){ $size += strlen($dbObject->$key); } //////// 0) Properties if( $dbObject->exists ){ $optionsArray[$lang['properties']] = ''; $optionsArray[$lang['properties']] .= '<table width="100%"><tr><td>'.$lang['file_name'].': </td><td> '.$dbObject->uniqLink; $optionsArray[$lang['properties']] .= '</td></tr><tr><td style="white-space:nowrap">'.$lang['last_modified'].': </td><td> '.dbFromDate($dbObject->modified,7); //nowrap because the uniqLink could potentially be long! $optionsArray[$lang['properties']] .= '</td></tr><tr><td>'.$lang['posted'].':</td><td> '.dbFromDate($dbObject->posted,7); $optionsArray[$lang['properties']] .= '</td></tr><tr><td>'.$lang['created'].':</td><td> '.dbFromDate($dbObject->created,7); $optionsArray[$lang['properties']] .= '</td></tr><tr><td>'.$lang['size'].':</td><td> '.$size.' '.$lang['bytes']; $optionsArray[$lang['properties']] .= '</td></tr></table>'; } //////// 0) Update Software pages if( method_exists($dbObject,'options')){ $temp = $dbObject->options(); if( is_array($temp) ){ $optionsArray += $temp; } } //////// (new) Redirect if( (strpos($dbObject->flags,'redirect') !== false) ){ $optionsArray[$lang['redirect']] = '<ul>'; $optionsArray[$lang['redirect']] .= '<li>'.$lang['REMOVE_REDIRECT'].'</li>'; $optionsArray[$lang['redirect']] .= '</ul>'; } //////// 1) Locking if( $dbObject->commands['lock'] ){ if( !$checked['restricted'] && !$checked['locked'] && !$checked ['registered'] && !$checked['admin']){ $checked['global'] = ' checked="checked" '; } $optionsArray[$lang['editing']] = ''; $optionsArray[$lang['editing']] .= '<span class="sm">'.$lang['EDITING_OPTIONS'].'</span>'; $optionsArray[$lang['editing']] .= '<p></p> <label><input type="radio" name="permission" value="" '.$checked['global'].'/> '.$lang['all_users'].'</label>'; $optionsArray[$lang['editing']] .= '<br /> <label><input type="radio" name="permission" value="registered" '.$checked['registered'].'/> '.$lang['registered_users'].'</label>'; $optionsArray[$lang['editing']] .= '<br /> <label><input type="radio" name="permission" value="restricted" '.$checked['restricted'].'/> '.$lang['restricted_to'].'</label>'; $optionsArray[$lang['editing']] .= wbLinks::special('WorkGroup','workgroup'); //special link looks in lang for label text! $optionsArray[$lang['editing']] .= '<br /> <label><input type="radio" name="permission" value="locked" '.$checked['locked'].'/> '.$lang['locked'].'</label>'; if( ($_SESSION['userlevel'] === 4) || $checked['admin']){ $optionsArray[$lang['editing']] .= '<br /> <label><input type="radio" name="permission" value="admin" '.$checked['admin'].'/> '.$lang['admin_only'].'</label>'; } } //////// 2) Hiding if( $dbObject->commands['hide'] ){ if( !$checked['hidden']){ $checked['visible']= ' checked="checked" '; } $optionsArray[$lang['visibility']] = ''; $optionsArray[$lang['visibility']] .= '<span class="sm">'.$lang['VISIBILITY_OPTIONS']; $optionsArray[$lang['visibility']] .= '</span>'; $optionsArray[$lang['visibility']] .= '<p></p> <label><input type="radio" name="visibility" value="" '.$checked['visible'].'/> '.$lang['visible'].'</label>'; $optionsArray[$lang['visibility']] .='<br /> <label><input type="radio" name="visibility" value="hidden" '.$checked['hidden'].'/> '.$lang['hidden'].'</label>'; $optionsArray[$lang['visibility']] .= ': '.wbLinks::special('Browse_Hidden','BROWSE_HIDDEN'); } //////// 3) Comments if( $dbObject->commands['comments'] ){ if( !$checked['nocomments']){ $checked['comments'] = ' checked="checked" '; } $optionsArray[$lang['comments']] = ''; $optionsArray[$lang['comments']] .= '<span class="sm">'.$lang['COMMENT_OPTIONS'] .'</span>'; $optionsArray[$lang['comments']] .= '<p></p> <label><input type="radio" name="commenting" value="" '.$checked['comments'].'/> '.$lang['enabled'].'</label>'; $optionsArray[$lang['comments']] .= '<br /> <label><input type="radio" name="commenting" value="nocomments" '.$checked['nocomments'].'/> '.$lang['disabled'].'</label>'; } $optionsArray[$lang['save']] = ''; //////// 4) Other if( $dbObject->exists ){ $optionsArray[$lang['other']] = '<ul>'; //Blog if( isset($pageOwner['sBlog']) && ($pageOwner['sBlog'] == 'On') && isset($pageOwner['isBlog']) && ($pageOwner['isBlog'] =='On') && (strpos($dbObject->flags,'hidden') === false) && ($dbObject->objectType == $pageOwner['blogT']) /*&& strtolower($dbObject->title) != 'home')*/ ){ if( strpos($dbObject->flags,'unchecked') === false){ $optionsArray[$lang['other']] .= '<li>'.wbLinks::local($dbObject->uniqLink.'?cmd=blogthis',$lang['blog_this']).'</li>'; }else{ $optionsArray[$lang['other']] .= '<li>'.wbLinks::local($dbObject->uniqLink.'?cmd=unblog',$lang['unblog']).'</li>'; } } //Repost $optionsArray[$lang['other']] .= '<li>'.wbLinks::local($dbObject->uniqLink.'?cmd=repost',$lang['repost']).'</li>'; if( $dbObject->commands['delete'] ){ $optionsArray[$lang['other']] .= '<li>'.wbLinks::local($dbObject->uniqLink.'?cmd=delete',$lang['delete'],' title="'.$lang['send_to_trash'].'"'); $optionsArray[$lang['other']] .= '<span class="sm"> '.wbLinks::special('Trash','trash').' </span></li>'; } //New Copy/Rename // do it with a form end($dbObject->dbInfo['keys']); $key = key($dbObject->dbInfo['keys']); $title = $dbObject->$key; $temp = ''; $temp .= '<input type="text" name="to" size="20" value="'.htmlspecialchars($title).'" /> '; $temp .= '<br/>'; $temp .= '<input type="submit" name="cmd" value="'.$lang['copy'].'" /> '; $temp .= '<input type="submit" name="cmd" value="'.$lang['rename'].'" /> '; $optionsArray[$lang['other']] .= '<li>'.$temp.'</li>'; //$optionsArray[$lang['other']] .= '<li>Set '.wbLinks::special('DefaultOptions','default options').' for this file type.</li>'; $optionsArray[$lang['other']] .= '<li>'.wbLang::text('SET_DEFAULT_OPTIONS',wbLinks::special('DefaultOptions','default_options')).'</li>'; $optionsArray[$lang['other']] .= '</ul>'; } //////// 5) Saving if(count($optionsArray)%2 == 0){ $optionsArray[' '] = ''; } $optionsArray[$lang['save']] = '<br /><input type="submit" name="cmd" value="'.$lang['save_options'].'" />'; //////// 6) Show Options echo '<table cellpadding="20" border="0" width="100%"><tr>'; $i=0; $amount = intval(count($optionsArray)/2); $amount = count($optionsArray) - $amount; foreach( $optionsArray as $key => $value){ if($i==2){ echo '</tr><tr>'; $i=0; } $i++; echo '<td width="50%">'; echo '<h3 class="heading">'.$key.'</h3>'; if( !empty($value) ){ echo '<div class="underline"></div>'; echo $value; } echo '</td>'; } echo '</tr></table>'; $page->contentA[$lang['options']] = wb::get_clean();}//////////////////////////////////////////////////////////////////////// Other Options//class options{ function repost(){ global $dbObject,$wbTables,$wbNow; $query = 'UPDATE '.$wbTables['all_files']; $query .= ' SET `modified` = `modified` '; $query .= ', `posted` = now()'; $query .= ' WHERE '; $query .= $wbTables['all_files'].'.`file_id` = "'.$dbObject->file_id.'" '; $result = wbDB::runQuery($query); $num = mysql_affected_rows(); if($num != 1){ message('NOT_REPOSTED'); if($num == -1){ trigger_error('File not reposted'); } return; } $dbObject->posted = $wbNow; message('REPOSTED'); // // Ping // options::ping(); } function blogThis(){ global $dbObject; if( isset($dbObject->userValues['keywords']) && empty($dbObject->keywords) && !isset($_GET['confirm']) ){ $link1 = wbLinks::local('/edit'.$dbObject->uniqLink.'?cmd=edit',false); $link2 = wbLinks::local($dbObject->uniqLink.'?cmd=blogthis&confirm=true',false); message('NO_KEYWORDS',$link1,$link2); return; } if( !empty($dbObject->flags) ){ $dbObject->flags .= ',unchecked'; }else{ $dbObject->flags = 'unchecked'; } options::update(); // // PING // options::ping(); } function unBlog(){ global $dbObject; $flagsArray = explode(',',$dbObject->flags); $remove = array('','unchecked'); $flagsArray = array_diff($flagsArray,$remove); $dbObject->flags = implode(',',$flagsArray); options::update(); } function update(){ global $wbTables, $dbObject; $query = 'UPDATE '.$wbTables['all_files']; $query .= ' SET `modified` = `modified` '; $query .= ' ,`flags` = "'.wbDB::escape($dbObject->flags).'" '; $query .= ' WHERE '; $query .= $wbTables['all_files'].'.`file_id` = "'.$dbObject->file_id.'" '; $result = wbDB::runQuery($query); $num = mysql_affected_rows(); if($num != 1){ message('OPTIONS_NOT_UPDATED'); if($num == -1){ trigger_error('File not reposted'); } return; } message('OPTIONS_UPDATED'); } // // PING // how does this work for files that are old.. and have an old posted value.. where are they shown? function ping(){ global $dbObject,$pageOwner; //is this page in the blog? if( strpos($dbObject->flags,'unchecked') === false){ return; } //is this page visible if( strpos($dbObject->flags,'hidden') !== false){ return; } if( empty($pageOwner['uServices']) ){ return; } includeFile('/tool/Ping.php'); RPC::pingAllUrls($pageOwner['uServices']); } }//////////////////////////////////////////////////////////////////////// Control//global $lang;switch( $page->userCmd ){ case 'save options': case wbStrtolower($lang['save_options']): $do = setNewFlags(); saveFlags($do); break; case 'repost': options::repost(); break; case 'blogthis': options::blogThis(); break; case 'unblog': options::unBlog(); break; case 'options': case 'get options': break;}getOptions();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -