PDA

Просмотр полной версии : Help plz!


BADWOLF
27.01.2008, 01:30
http://www.xakep.ru/post/41519/
Кому не трудно помогите плз
Застрял на моменте создания lib.php :confused:
Напишите как его создать =)))
Заранее благодарен!

cash$$$
27.01.2008, 16:52
<?php
/* $Id: common.lib.php 211 2003-11-11 12:26:47Z kukutz $ */
// vim: expandtab sw=4 ts=4 sts=4:

/**
* Misc stuff and functions used by almost all the scripts.
* Among other things, it contains the advanced authentification work.
*/

if (!defined('PMA_COMMON_LIB_INCLUDED')) {
define('PMA_COMMON_LIB_INCLUDED', 1);

/**
* Avoids undefined variables in PHP3
*/
if (!isset($use_backquotes)) {
$use_backquotes = 0;
}
if (!isset($pos)) {
$pos = 0;
}

include('./config.inc.php');
include('./mysql_wrappers.lib.php');
include('./defines.lib.php');

/**
* Add slashes before "'" and "\" characters so a value containing them can
* be used in a sql comparison.
*
* @param string the string to slash
* @param boolean whether the string will be used in a 'LIKE' clause
* (it then requires two more escaped sequences) or not
* @param boolean whether to treat cr/lfs as escape-worthy entities
* (converts \n to \\n, \r to \\r)
*
* @return string the slashed string
*
* @access public
*/
function PMA_sqlAddslashes($a_string = '', $is_like = FALSE, $crlf = FALSE)
{
if ($is_like) {
$a_string = str_replace('\\', '\\\\\\\\', $a_string);
} else {
$a_string = str_replace('\\', '\\\\', $a_string);
}

if ($crlf) {
$a_string = str_replace("\n", '\n', $a_string);
$a_string = str_replace("\r", '\r', $a_string);
$a_string = str_replace("\t", '\t', $a_string);
}

$a_string = str_replace('\'', '\\\'', $a_string);

return $a_string;
} // end of the 'PMA_sqlAddslashes()' function


$dblink = mysql_connect($cfg['host'], $cfg['user'], $cfg['password']) or die("can't connect");
mysql_select_db($cfg['db']) or die("no database");
$dblist = array();


/* ----------------------- Set of misc functions ----------------------- */


/**
* Adds backquotes on both sides of a database, table or field name.
* Since MySQL 3.23.6 this allows to use non-alphanumeric characters in
* these names.
*
* @param mixed the database, table or field name to "backquote" or
* array of it
* @param boolean a flag to bypass this function (used by dump
* functions)
*
* @return mixed the "backquoted" database, table or field name if the
* current MySQL release is >= 3.23.6, the original one
* else
*
* @access public
*/
function PMA_backquote($a_name, $do_it = TRUE)
{
if ($do_it
&& PMA_MYSQL_INT_VERSION >= 32306
&& !empty($a_name) && $a_name != '*') {

if (is_array($a_name)) {
$result = array();
reset($a_name);
while(list($key, $val) = each($a_name)) {
$result[$key] = '`' . $val . '`';
}
return $result;
} else {
return '`' . $a_name . '`';
}
} else {
return $a_name;
}
} // end of the 'PMA_backquote()' function


/**
* Defines the <CR><LF> value depending on the user OS.
*
* @return string the <CR><LF> value to use
*
* @access public
*/
function PMA_whichCrlf()
{
$the_crlf = "\n";

return $the_crlf;
} // end of the 'PMA_whichCrlf()' function


/**
* Writes localised date
*
* @param string the current timestamp
*
* @return string the formatted date
*
* @access public
*/
function PMA_localisedDate($timestamp = -1, $format = '')
{
global $datefmt, $month, $day_of_week;

if ($format == '') {
$format = $datefmt;
}

if ($timestamp == -1) {
$timestamp = time();
}

$date = ereg_replace('%[aA]', $day_of_week[(int)strftime('%w', $timestamp)], $format);
$date = ereg_replace('%[bB]', $month[(int)strftime('%m', $timestamp)-1], $date);

return strftime($date, $timestamp);
} // end of the 'PMA_localisedDate()' function


// stub
function PMA_convert_string($src_charset, $dest_charset, $what) {
return $what;
} // end of the "PMA_convert_string()" function

} // $__PMA_COMMON_LIB__
?>

Оно?

BADWOLF
27.01.2008, 22:42
Неа :(

cash$$$
28.01.2008, 01:10
Может зто поможет

$text = 'Переменная с текстом BBCode: Hello world!';
// Подключаем библиотеку с классом
require_once 'ваш/путь/bbcode.lib.php';
// Создаем объект и распарсиваем $text
$bb = new bbcode($text);
// Конвертируем BBCode в HTML и выводим его
echo $bb -> get_html();

этот код демонстрирует, как можно обработать последовательность текстов BBCode:
$list = array(
'Первый текст с ББКодом',
'Второй текст с ББКодом'
);
// Подключаем библиотеку с классом
require_once 'ваш/путь/bbcode.lib.php';
// Создаем объект
$bb = new bbcode;
// В цикле парсим ББКод и выводим HTML
foreach ($list as $val) {
$bb -> parse($val);
echo $bb -> get_html() . '<br />';
}

код, устанавливающий набор смайликов

$text = 'Переменная BBCode со смайликами: :) :D';
// Формируем список смайликов:
$smiles = array(
':)' => '<img src="images/smilies/2.gif" alt="Well" />',
':D' => '<img src="images/smilies/1.gif" alt="Very we!" />'
);
// Подключаем библиотеку с классом
require_once 'ваш/путь/bbcode.lib.php';
// Создаем объект и парсим $text
$bb = new bbcode($text);
// Задаем набор смайликов
$bb -> mnemonics = $smiles;
// Конвертируем BBCode в HTML и выводим его
echo $bb -> get_html();

Смайлики не будут вставляться в содержимое тегов [bbcode], [code], [nobb], [php] и т.п..