📄 common.lib.php
字号:
break; case 'Function': echo '<a href="main.php?dbsel='.$GLOBALS['dbsel'].'&action=add_function" class="propItemTitle" target="main"> » '.$GLOBALS['traduct']->get(89).'</a>'; break; }}/*** Display query has been execute** @param string $query* @param bool $withLink if true some links will be display*/function displayQuery($query, $withLink=true, $changesLines=''){ global $SQLiteManagerAuth; if(empty($query) && isset($GLOBALS['DisplayQuery'])) $query = $GLOBALS['DisplayQuery']; $linkBase = 'main.php?dbsel='.$GLOBALS['dbsel'].'&table='.$GLOBALS['table']; if($posLim = strpos($query, 'LIMIT')) { $queryLink = substr($query, 0, ($posLim-1)); } else $queryLink = $query; if(isset($GLOBALS['DbGrid']) && is_object($GLOBALS['DbGrid'])){ if(!empty($GLOBALS['DbGrid']->infoNav['start']) || !empty($GLOBALS['DbGrid']->infoNav['end']) || !empty($GLOBALS['DbGrid']->infoNav['all'])){ $infoNav = '<span style="font-size: 12px">'.$GLOBALS['traduct']->get(136).' '.$GLOBALS['DbGrid']->infoNav['start'].'-'.$GLOBALS['DbGrid']->infoNav['end'].'/'.$GLOBALS['DbGrid']->infoNav['all'].' </span>'; } } if(!isset($infoNav)) $infoNav = ''; if(WITH_AUTH && isset($SQLiteManagerAuth) && !$SQLiteManagerAuth->getAccess('execSQL')) $withLink = false; $modifyLink = '[<a href="'.$linkBase.'&action=sql&sql_action=modify&displayResult=&DisplayQuery='.urlencode($queryLink).'" class="titleHeader" target="main">'.$GLOBALS['traduct']->get(14).'</a>]'; $explainLink = '[<a href="'.$linkBase.'&action=sql&sql_action=explain&displayResult=1&DisplayQuery='.urlencode($queryLink).'" class="titleHeader" target="main">'.$GLOBALS['traduct']->get(145).'</a>]'; $replayLink = '[<a href="'.$linkBase.'&action=sql&displayResult=1&DisplayQuery='.urlencode($queryLink).'" class="titleHeader" target="main">'.$GLOBALS['traduct']->get(223).'</a>]'; echo ' <table class="query" cellspacing="0" align="center">'; if($changesLines != '') echo '<tr><td bgcolor="#CCCCCC"><span class="sqlsyntaxe"> '.$changesLines.' '.$GLOBALS['traduct']->get(71).'</span></td></tr>'; echo ' <tr> <td class="queryTitle" bgcolor="'.$GLOBALS['displayQueryTitleColor'].'" style="white-space: nowrap"> '.$GLOBALS['traduct']->get(90).' : '.(($withLink)? ' '.$infoNav.$modifyLink.' '.$explainLink.' '.$replayLink : '' ).'</td></tr> <tr><td class="queryBody" bgcolor="'.$GLOBALS['displayQueryBgColor'].'" style="white-space: nowrap"><div class="sqlsyntaxe">'.highlight_query($query).'</div></td></tr> </table><br/> ';}/*** highlight query for a proch future!!** @param string $query SQL command string*/function highlight_query($query){ include_once INCLUDE_LIB.'ParsingQuery.class.php'; $Colorize =& new ParsingQuery($query, 1); $Colorize->explodeQuery(); $Colorize->colorWordList(); return $Colorize->highlightQuery();}/*** Display function list for the insert / modify form** @param string $champ name of the current champ*/function SQLiteFunctionList($champ, $userDefine=""){ $out = '<select name="funcs['.$champ.']">'."\n".' <option value="" />'."\n"; foreach($GLOBALS['SQLfunction'] as $funct) $out .= '<option value="'.$funct.'">'.$funct.'</option>'."\n"; $tabUDF = $GLOBALS["workDb"]->functInfo; $out .= '<option value="" />'."\n"; if(is_array($tabUDF)) foreach($tabUDF as $udfInfo) if($udfInfo['funct_type']==1) $out .= '<option value="'.$udfInfo['funct_name'].'">'.$udfInfo['funct_name'].'</option>'; $out .= '</select>'; return $out;}/*** Display operator list for the select form* @author Maur韈io M. Maia <mauricio.maia@gmail.com>** @param string $champ name of the current champ*/function SQLiteSelectList($champ, $userDefine=""){ $out = '<select name="operats['.$champ.']">'."\n".' <option value="" />'."\n"; foreach($GLOBALS['SQLselect'] as $operat) { if(($operat != "fulltextsearch") || ALLOW_FULLSEARCH) $out .= '<option value="'.$operat.'">'.$operat.'</option>'."\n"; } $out .= '</select>'; return $out;}/*** Display input TYPE for the insert / modify form** @param array $info data info for the current champ* @param mixed $data current value of the champ*/function SQLiteInputType($info, $data, $allowDefault=true, $allow_advanced=true){ static $tabIndex; $allowBigger=false; if(empty($tabIndex)) $tabIndex = 1; if (!$allowBigger) if(eregi('CHAR|TEXT|LOB', $info['type'])) { preg_match('/\((.*)\)/', $info['type'], $length); if(isset($length[1]) && $length[1]){ $maxlength = ' maxlength="'.$length[1].'"'; if($length[1]<=20) $maxlength = ' size="'.($length[1]+1).'" '.$maxlength; } else $maxlength = ' size="20"'; } else $maxlength = ' size="20"'; if($allowDefault && $info['notnull'] && ($data == '')){ if(strstr($info['type'], '(')) { $localType = trim(preg_replace('/\(.*\)/', '', $info['type'])); } else { $localType = $info['type']; } if($info['dflt_value']!= '') $data = $info['dflt_value']; elseif(isset($GLOBALS['SQLiteType'][$localType])) $data=$GLOBALS['SQLiteType'][$localType]; } if((strtoupper(substr($info['type'],0,4))!='TEXT') && (strtoupper(substr($info['type'],0,4))!='BLOB')) { if(JSCALENDAR_PATH && isset($GLOBALS['GlobalCalendar']) && (($info['type'] == 'DATE') || ($info['type'] == 'DATETIME'))) { $id = $GLOBALS['GlobalCalendar']->_gen_id(); $out = "<input size=\"15\" id=\"".$GLOBALS['GlobalCalendar']->_field_id($id)."\" type=\"text\" class=\"text\" name=\"valField[".$info['name']."]\" value=\"".htmlentities($data, ENT_NOQUOTES, $GLOBALS['charset'])."\"". $maxlength." tabindex=".($tabIndex++).((!$info['notnull'])? " onChange=\"if(this.value!='') setCheckBox('editElement', 'nullField[".$info['name']."]', false); else setCheckBox('editElement', 'nullField[".$info['name']."]', true);\"" : '' ).">"; $out .= '<a href="#" id="'. $GLOBALS['GlobalCalendar']->_trigger_id($id) . '">' . '<img align="middle" border="0" src="' . $GLOBALS['GlobalCalendar']->calendar_lib_path . 'img.gif" alt="" /></a>'; $options = array( 'inputField' => $GLOBALS['GlobalCalendar']->_field_id($id), 'button' => $GLOBALS['GlobalCalendar']->_trigger_id($id)); if($info['type'] == 'DATETIME') { $GLOBALS['GlobalCalendar']->calendar_options['ifFormat'] = '%Y-%m-%d %H:%M'; $GLOBALS['GlobalCalendar']->calendar_options['daFormat'] = '%Y-%m-%d %H:%M'; } else { $GLOBALS['GlobalCalendar']->calendar_options['ifFormat'] = '%Y-%m-%d'; $GLOBALS['GlobalCalendar']->calendar_options['daFormat'] = '%Y-%m-%d'; } $out .= $GLOBALS['GlobalCalendar']->_make_calendar($options); } else { $out = "<input type=\"text\" class=\"text\" name=\"valField[".$info['name']."]\" value=\"".htmlentities($data, ENT_NOQUOTES, $GLOBALS['charset'])."\"".$maxlength." tabindex=".($tabIndex++).((!$info['notnull'])? " onChange=\"if(this.value!='') setCheckBox('editElement', 'nullField[".$info['name']."]', false); else setCheckBox('editElement', 'nullField[".$info['name']."]', true);\"" : '' ).">"; } } else { if(ADVANCED_EDITOR && $allow_advanced && isset($GLOBALS['spaw_dir']) && (isset($_COOKIE["SQLiteManager_HTMLon"]) && !$_COOKIE["SQLiteManager_HTMLon"])){ $GLOBALS["spawEditorByName"][$info['name']] = new SPAW_Wysiwyg("valField[".$info['name']."]", $data, $GLOBALS["langSuffix"], SPAW_TOOLBAR_STYLE, '', (TEXTAREA_NB_COLS*6), (TEXAREA_NB_ROWS*16)); // Show SPAW Editor $out = $GLOBALS["spawEditorByName"][$info['name']]->show(); } else { $out = "<textarea name=\"valField[".$info['name']."]\" cols=".TEXTAREA_NB_COLS." rows=".TEXAREA_NB_ROWS." tabindex=".($tabIndex++).((!$info['notnull'])? " onChange=\"if(this.value!='') setCheckBox('editElement', 'nullField[".$info['name']."]', false); else setCheckBox('editElement', 'nullField[\'".$info['name']."\']', true);\"" : "" ).">". htmlentities($data, ENT_NOQUOTES, $GLOBALS['charset']). '</textarea>'; } } if(isset($out)) return $out;}/*** Return Available language*/function getAvailableLanguage(){ $out = ""; $listLangue = $GLOBALS['langueTranslated']; natsort($listLangue); while(list($lgId, $lgLib) = each($listLangue)){ $out .= '<option value="'.$lgId.'"'.(($GLOBALS['currentLangue']==$lgId)? ' selected="selected"' : '' ).'>'.(($GLOBALS['langueTranslated'][$lgId])? $GLOBALS['langueTranslated'][$lgId] : $lgLib).'</option>'."\n"; } return $out;}/*** Return available theme*/function getAvailableTheme(){ $out = ""; //natsort($GLOBALS['themeTranslated']); while(list($key,$themeId) = each($GLOBALS['availableTheme'])){ $themeLib = ($GLOBALS['themeTranslated'][$themeId])? $GLOBALS['themeTranslated'][$themeId] : $themeId; $out .= '<option value="'.$themeId.'"'.(($GLOBALS['localtheme']==$themeId)? ' selected="selected"' : '' ).'>'.$themeLib.'</option>'."\n"; } return $out;}/*** Apply a function from record form** @param string $function the function name* @param mixed $value paramaters to apply function*/function applyFunction($function, $value){ $newValue = $value; if(in_array($function, $GLOBALS['SQLfunction'])){ if($function == 'MD5') $newValue = "php('md5', $value)"; elseif($function == 'NOW') $newValue = "php('date', 'Y-m-d')"; else $newValue = strtolower($function)."($value)"; } else { foreach($GLOBALS['workDb']->functInfo as $functInfo) { if($function == $functInfo['funct_name']) $newValue = $function."('$value')"; } } return $newValue;}/*** Convert a hash table to GET url string** @param array $tab table of key=>value*/function arrayToGet($tab){ $strOut = array(); while(list($var, $value) = each($tab)) $strOut[] = $var."=".$value; return implode("&", $strOut); }/*** Cleaning field name, remove non authorized caractere** @param string string is the field name* @param string $allow PCRE representation of caract鑢e authorized*/function cleanFieldName($string, $allow = 'a-z_0-9[[:space:]]'){ return eregi_replace('[^'.$allow.']', '', trim($string));}/*** Return a tab with all position of a caractere** @param string $string haystack string* @param char $seperation needle string to find*/function strpos_all($string, $separator){ static $tabPos=array(); $pos = strpos($string, $separator); if((string)$pos!=""){ if(count($tabPos)>=1) $addPrec = ($tabPos[count($tabPos)-1] +1); else $addPrec = 0; array_push($tabPos, ($pos + $addPrec)); $substring = substr($string, ($pos + 1), (strlen($string) - ($pos+1)) ); strpos_all($substring, $separator); } return $tabPos;}/*** Function for error handling* return PHP error from SQLite error to enhancement error displaying*/function phpSQLiteErrorHandling($errno, $errstr, $errfile, $errline){ preg_match('/:(.*)/', $errstr, $errorResult); if(isset($errorResult[1])) $GLOBALS['phpSQLiteError'] = $errorResult[1];}/*** Create SELECT from array value** @param array $tabData array("ID"=>"VALUE", ...)* @param string form $varNamevar name* @param int $varValue value to selected* @return string HTML out*/function createSelect($tabData, $varName, $varValue){ $out = ''; if(isset($tabData) && !empty($tabData)){ $out .= '<SELECT name="'.$varName.'">'."\n".'<option value="" />'."\n"; foreach($tabData as $id=>$value) $out .= '<option value="'.$id.'"'.(($id==$varValue)? ' selected="selected"' : '' ).'>'.$value.'</option>'."\n"; $out .='</SELECT>'."\n"; } return $out;}/*** Send image HTML!* if exist img filename in theme, this is display also the './pics/'.$filename is display* * @param string $src filename* @param sring $alt string is display when mouse over* @param int $border image border size in px* @param int $width width size in px* @param int height heigh size in px* @return string img HTML tag */function displayPics($src, $alt="", $border=0, $width="", $height=""){ $filename = basename($src); if(file_exists('./theme/'.$GLOBALS['localtheme'].'/pics/'.$filename)){ $imgSrc = './theme/'.$GLOBALS['localtheme'].'/pics/'.$filename; } else { $imgSrc = './theme/default/pics/'.$filename; } return '<img src="'.$imgSrc.'" border="'.$border.'" alt="'.$alt.'" title="'.$alt.'"'.(($width)? ' width='.$width : '' ).(($height)? ' height='.$height : '' ).'>';}/*** Add brackets when spaces in objects, remove existing ones for concatenations [table].[col] > [table.col]** @param string $object object with or without bracket* @return string object with brackets*/function brackets($object,$type=''){ $object = ereg_replace('\[|\]','',$object); if (strstr($object,' ')) { $object = "[$object]"; } return $object;}/*** Add quotes on values, and support for Like '%text%'** @param string $text string value* @param string $like string add like %* @return escaped string with quotes*/function quotes($text,$like=''){ if (substr($like,0,1)=='%') $text = '%'+$text; if (substr($like,1,1)=='%') $text .= '%'; $out = "'".$GLOBALS['db']->escape($text)."'"; return $out;}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -