Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-webclient
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-webclient
Commits
e477d179
Commit
e477d179
authored
Jun 04, 2012
by
Владислав Большаков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
barbass: удаляем лишние файлы
parent
33275c21
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
1569 deletions
+103
-1569
barbass_typos.sql
barbass_typos.sql
+5
-11
database.php
database.php
+0
-1118
default.php
default.php
+1
-1
etersoft_typos.js
etersoft_typos.js
+97
-61
etersoft_typos2.js
etersoft_typos2.js
+0
-211
minimambo.php
minimambo.php
+0
-167
No files found.
barbass_typos.sql
View file @
e477d179
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
-- http://www.phpmyadmin.net
--
--
-- Хост: localhost
-- Хост: localhost
-- Время создания: Май 1
0
2012 г., 17:20
-- Время создания: Май 1
6
2012 г., 17:20
-- Версия сервера: 5.1.56
-- Версия сервера: 5.1.56
-- Версия PHP: 5.3.10
-- Версия PHP: 5.3.10
...
@@ -25,12 +25,11 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
...
@@ -25,12 +25,11 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- Структура таблицы `admins`
-- Структура таблицы `admins`
--
--
DROP
TABLE
IF
EXISTS
`admins`
;
CREATE
TABLE
IF
NOT
EXISTS
`admins`
(
CREATE
TABLE
IF
NOT
EXISTS
`admins`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id_user`
int
(
11
)
NOT
NULL
,
`id_user`
int
(
11
)
NOT
NULL
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
2
0
;
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
2
1
;
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -38,18 +37,16 @@ CREATE TABLE IF NOT EXISTS `admins` (
...
@@ -38,18 +37,16 @@ CREATE TABLE IF NOT EXISTS `admins` (
-- Структура таблицы `messages`
-- Структура таблицы `messages`
--
--
DROP
TABLE
IF
EXISTS
`messages`
;
CREATE
TABLE
IF
NOT
EXISTS
`messages`
(
CREATE
TABLE
IF
NOT
EXISTS
`messages`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id_site`
int
(
11
)
NOT
NULL
,
`id_site`
int
(
11
)
NOT
NULL
,
`link`
text
NOT
NULL
COMMENT
'Ссылка на страницу'
,
`link`
text
NOT
NULL
COMMENT
'Ссылка на страницу'
,
`error_text`
varchar
(
100
)
NOT
NULL
COMMENT
'Выделенный текст '
,
`error_text`
varchar
(
100
)
NOT
NULL
COMMENT
'Выделенный текст '
,
`email`
varchar
(
150
)
DEFAULT
NULL
COMMENT
'email отправителя'
,
`comment`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'комментарий пользователя'
,
`comment`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'комментарий пользователя'
,
`datetime`
datetime
NOT
NULL
,
`datetime`
datetime
NOT
NULL
,
`status`
tinyint
(
1
)
NOT
NULL
COMMENT
'1: исправлена, 0: нет'
,
`status`
tinyint
(
1
)
NOT
NULL
COMMENT
'1: исправлена, 0: нет'
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Сообщения'
AUTO_INCREMENT
=
2
22
;
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Сообщения'
AUTO_INCREMENT
=
2
41
;
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -57,14 +54,13 @@ CREATE TABLE IF NOT EXISTS `messages` (
...
@@ -57,14 +54,13 @@ CREATE TABLE IF NOT EXISTS `messages` (
-- Структура таблицы `responsible`
-- Структура таблицы `responsible`
--
--
DROP
TABLE
IF
EXISTS
`responsible`
;
CREATE
TABLE
IF
NOT
EXISTS
`responsible`
(
CREATE
TABLE
IF
NOT
EXISTS
`responsible`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id_site`
int
(
11
)
NOT
NULL
,
`id_site`
int
(
11
)
NOT
NULL
,
`id_user`
int
(
11
)
NOT
NULL
,
`id_user`
int
(
11
)
NOT
NULL
,
`status`
tinyint
(
1
)
NOT
NULL
COMMENT
'Возможность отписать себя с рассылки'
,
`status`
tinyint
(
1
)
NOT
NULL
COMMENT
'Возможность отписать себя с рассылки'
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Зависимость сайтов и ответственных'
AUTO_INCREMENT
=
18
;
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Зависимость сайтов и ответственных'
AUTO_INCREMENT
=
22
;
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -72,7 +68,6 @@ CREATE TABLE IF NOT EXISTS `responsible` (
...
@@ -72,7 +68,6 @@ CREATE TABLE IF NOT EXISTS `responsible` (
-- Структура таблицы `sites`
-- Структура таблицы `sites`
--
--
DROP
TABLE
IF
EXISTS
`sites`
;
CREATE
TABLE
IF
NOT
EXISTS
`sites`
(
CREATE
TABLE
IF
NOT
EXISTS
`sites`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`site`
varchar
(
150
)
NOT
NULL
COMMENT
'Формат: mysite.ru'
,
`site`
varchar
(
150
)
NOT
NULL
COMMENT
'Формат: mysite.ru'
,
...
@@ -85,7 +80,6 @@ CREATE TABLE IF NOT EXISTS `sites` (
...
@@ -85,7 +80,6 @@ CREATE TABLE IF NOT EXISTS `sites` (
-- Структура таблицы `users`
-- Структура таблицы `users`
--
--
DROP
TABLE
IF
EXISTS
`users`
;
CREATE
TABLE
IF
NOT
EXISTS
`users`
(
CREATE
TABLE
IF
NOT
EXISTS
`users`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`email`
varchar
(
150
)
NOT
NULL
,
`email`
varchar
(
150
)
NOT
NULL
,
...
@@ -94,4 +88,4 @@ CREATE TABLE IF NOT EXISTS `users` (
...
@@ -94,4 +88,4 @@ CREATE TABLE IF NOT EXISTS `users` (
`lastname`
varchar
(
20
)
NOT
NULL
,
`lastname`
varchar
(
20
)
NOT
NULL
,
`datetime`
datetime
NOT
NULL
COMMENT
'Дата добавления'
,
`datetime`
datetime
NOT
NULL
COMMENT
'Дата добавления'
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Ответственные за сайты'
AUTO_INCREMENT
=
38
;
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Ответственные за сайты'
AUTO_INCREMENT
=
44
;
database.php
deleted
100644 → 0
View file @
33275c21
<?php
////////////////////////////////////////
// Файл из пакета дистрибутива:
// CMS "Mambo 4.5.2.3 Paranoia Light"
// Дата выпуска: 16.08.2005
// Исправленная и доработанная версия
// Локализация и сборка дистрибутива:
// - AndyR - mailto:andyr@mail.ru
//////////////////////////////////////
// Не удаляйте строку ниже:
$andyr_signature
=
'Mambo_4523_Paranoia_019'
;
?>
<?php
/**
* @version $Id: database.php,v 1.1 2007/03/29 18:21:57 pv Exp $
* @package Mambo
* @subpackage Database
* @copyright (C) 2000 - 2005 Miro International Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
*/
/** ensure this file is being included by a parent file */
defined
(
'_VALID_MOS'
)
or
die
(
'Direct Access to this location is not allowed.'
);
/**
* Database connector class
* @subpackage Database
* @package Mambo
*/
class
database
{
/** @var string Internal variable to hold the query sql */
var
$_sql
=
''
;
/** @var int Internal variable to hold the database error number */
var
$_errorNum
=
0
;
/** @var string Internal variable to hold the database error message */
var
$_errorMsg
=
''
;
/** @var string Internal variable to hold the prefix used on all database tables */
var
$_table_prefix
=
''
;
/** @var Internal variable to hold the connector resource */
var
$_resource
=
''
;
/** @var Internal variable to hold the last query cursor */
var
$_cursor
=
null
;
/** @var boolean Debug option */
var
$_debug
=
0
;
/** @var int A counter for the number of queries performed by the object instance */
var
$_ticker
=
0
;
/** @var array A log of queries */
var
$_log
=
null
;
/**
* Database object constructor
* @param string Database host
* @param string Database user name
* @param string Database user password
* @param string Database name
* @param string Common prefix for all tables
*/
function
database
(
$host
=
'localhost'
,
$user
,
$pass
,
$db
,
$table_prefix
)
{
// perform a number of fatality checks, then die gracefully
if
(
!
function_exists
(
'mysql_connect'
))
{
//or die( 'FATAL ERROR: MySQL support not available. Please check your configuration.' );
echo
'1'
;
$mosSystemError
=
1
;
$basePath
=
dirname
(
__FILE__
);
include
$basePath
.
'/../configuration.php'
;
include
$basePath
.
'/../offline.php'
;
exit
();
}
if
(
!
(
$this
->
_resource
=
@
mysql_connect
(
$host
,
$user
,
$pass
)))
{
//or die( 'FATAL ERROR: Connection to database server failed.' );
echo
'2'
;
$mosSystemError
=
2
;
$basePath
=
dirname
(
__FILE__
);
include
$basePath
.
'/../configuration.php'
;
include
$basePath
.
'/../offline.php'
;
exit
();
}
if
(
!
mysql_select_db
(
$db
))
{
//die( "FATAL ERROR: Database not found. Operation failed with error: ".mysql_error());
echo
'3'
;
$mosSystemError
=
3
;
$basePath
=
dirname
(
__FILE__
);
include
$basePath
.
'/../configuration.php'
;
include
$basePath
.
'/../offline.php'
;
exit
();
}
$this
->
_cursor
=
mysql_query
(
"set names 'utf8';"
,
$this
->
_resource
);
$this
->
_table_prefix
=
$table_prefix
;
$this
->
_ticker
=
0
;
$this
->
_log
=
array
();
}
/**
* @param int
*/
function
debug
(
$level
)
{
$this
->
_debug
=
intval
(
$level
);
}
/**
* @return int The error number for the most recent query
*/
function
getErrorNum
()
{
return
$this
->
_errorNum
;
}
/**
* @return string The error message for the most recent query
*/
function
getErrorMsg
()
{
return
str_replace
(
array
(
"
\n
"
,
"'"
),
array
(
'\n'
,
"\'"
),
$this
->
_errorMsg
);
}
/**
* Get a database escaped string
* @return string
*/
function
getEscaped
(
$text
)
{
return
mysql_escape_string
(
$text
);
}
/**
* Get a quoted database escaped string
* @return string
*/
function
Quote
(
$text
)
{
return
'\''
.
mysql_escape_string
(
$text
)
.
'\''
;
}
/**
* Sets the SQL query string for later execution.
*
* This function replaces a string identifier <var>$prefix</var> with the
* string held is the <var>_table_prefix</var> class variable.
*
* @param string The SQL query
* @param string The common table prefix
*/
function
setQuery
(
$sql
,
$prefix
=
'#__'
)
{
$this
->
_sql
=
$this
->
replacePrefix
(
$sql
,
$prefix
);
}
/**
* This function replaces a string identifier <var>$prefix</var> with the
* string held is the <var>_table_prefix</var> class variable.
*
* @param string The SQL query
* @param string The common table prefix
* @author thede, David McKinnis
*/
function
replacePrefix
(
$sql
,
$prefix
=
'#__'
)
{
$sql
=
trim
(
$sql
);
$escaped
=
false
;
$quoteChar
=
''
;
$n
=
strlen
(
$sql
);
$startPos
=
0
;
$literal
=
''
;
while
(
$startPos
<
$n
)
{
$ip
=
strpos
(
$sql
,
$prefix
,
$startPos
);
if
(
$ip
===
false
)
{
break
;
}
$j
=
strpos
(
$sql
,
"'"
,
$startPos
);
$k
=
strpos
(
$sql
,
'"'
,
$startPos
);
if
((
$k
!==
FALSE
)
&&
((
$k
<
$j
)
||
(
$j
===
FALSE
)))
{
$quoteChar
=
'"'
;
$j
=
$k
;
}
else
{
$quoteChar
=
"'"
;
}
if
(
$j
===
false
)
{
$j
=
$n
;
}
$literal
.=
str_replace
(
$prefix
,
$this
->
_table_prefix
,
substr
(
$sql
,
$startPos
,
$j
-
$startPos
)
);
$startPos
=
$j
;
$j
=
$startPos
+
1
;
if
(
$j
>=
$n
)
{
break
;
}
// quote comes first, find end of quote
while
(
TRUE
)
{
$k
=
strpos
(
$sql
,
$quoteChar
,
$j
);
$escaped
=
false
;
if
(
$k
===
false
)
{
break
;
}
$l
=
$k
-
1
;
while
(
$l
>=
0
&&
$sql
{
$l
}
==
'\\'
)
{
$l
--
;
$escaped
=
!
$escaped
;
}
if
(
$escaped
)
{
$j
=
$k
+
1
;
continue
;
}
break
;
}
if
(
$k
===
FALSE
)
{
// error in the query' - no end quote; ignore it
break
;
}
$literal
.=
substr
(
$sql
,
$startPos
,
$k
-
$startPos
+
1
);
$startPos
=
$k
+
1
;
}
if
(
$startPos
<
$n
)
{
$literal
.=
substr
(
$sql
,
$startPos
,
$n
-
$startPos
);
}
return
$literal
;
}
/**
* @return string The current value of the internal SQL vairable
*/
function
getQuery
()
{
return
"<pre>"
.
htmlspecialchars
(
$this
->
_sql
)
.
"</pre>"
;
}
/**
* Execute the query
* @return mixed A database resource if successful, FALSE if not.
*/
function
query
()
{
global
$mosConfig_debug
;
if
(
$this
->
_debug
)
{
$this
->
_ticker
++
;
$this
->
_log
[]
=
$this
->
_sql
;
}
$this
->
_errorNum
=
0
;
$this
->
_errorMsg
=
''
;
$this
->
_cursor
=
mysql_query
(
$this
->
_sql
,
$this
->
_resource
);
if
(
!
$this
->
_cursor
)
{
$this
->
_errorNum
=
mysql_errno
(
$this
->
_resource
);
$this
->
_errorMsg
=
mysql_error
(
$this
->
_resource
)
.
" SQL=
$this->_sql
"
;
if
(
$this
->
_debug
)
{
trigger_error
(
mysql_error
(
$this
->
_resource
),
E_USER_NOTICE
);
//echo "<pre>" . $this->_sql . "</pre>\n";
if
(
function_exists
(
'debug_backtrace'
))
{
foreach
(
debug_backtrace
()
as
$back
)
{
if
(
@
$back
[
'file'
])
{
echo
'<br />'
.
$back
[
'file'
]
.
':'
.
$back
[
'line'
];
}
}
}
}
return
false
;
}
return
$this
->
_cursor
;
}
function
query_batch
(
$abort_on_error
=
true
,
$p_transaction_safe
=
false
)
{
$this
->
_errorNum
=
0
;
$this
->
_errorMsg
=
''
;
if
(
$p_transaction_safe
)
{
$si
=
mysql_get_server_info
();
preg_match_all
(
"/(\d+)\.(\d+)\.(\d+)/i"
,
$si
,
$m
);
if
(
$m
[
1
]
>=
4
)
{
$this
->
_sql
=
'START TRANSACTION;'
.
$this
->
_sql
.
'; COMMIT;'
;
}
else
if
(
$m
[
2
]
>=
23
&&
$m
[
3
]
>=
19
)
{
$this
->
_sql
=
'BEGIN WORK;'
.
$this
->
_sql
.
'; COMMIT;'
;
}
else
if
(
$m
[
2
]
>=
23
&&
$m
[
3
]
>=
17
)
{
$this
->
_sql
=
'BEGIN;'
.
$this
->
_sql
.
'; COMMIT;'
;
}
}
$query_split
=
preg_split
(
"/[;]+/"
,
$this
->
_sql
);
$error
=
0
;
foreach
(
$query_split
as
$command_line
)
{
$command_line
=
trim
(
$command_line
);
if
(
$command_line
!=
''
)
{
$this
->
_cursor
=
mysql_query
(
$command_line
,
$this
->
_resource
);
if
(
!
$this
->
_cursor
)
{
$error
=
1
;
echo
'xxx '
;
$this
->
_errorNum
.=
mysql_errno
(
$this
->
_resource
)
.
' '
;
$this
->
_errorMsg
.=
mysql_error
(
$this
->
_resource
)
.
" SQL=
$command_line
<br />"
;
if
(
$abort_on_error
)
{
return
$this
->
_cursor
;
}
}
}
}
return
$error
?
false
:
true
;
}
/**
* Diagnostic function
*/
function
explain
()
{
$temp
=
$this
->
_sql
;
$this
->
_sql
=
"EXPLAIN
$this->_sql
"
;
$this
->
query
();
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$first
=
true
;
$buf
=
"<table cellspacing=
\"
1
\"
cellpadding=
\"
2
\"
border=
\"
0
\"
bgcolor=
\"
#000000
\"
align=
\"
center
\"
>"
;
$buf
.=
$this
->
getQuery
();
while
(
$row
=
mysql_fetch_assoc
(
$cur
))
{
if
(
$first
)
{
$buf
.=
"<tr>"
;
foreach
(
$row
as
$k
=>
$v
)
{
$buf
.=
"<th bgcolor=
\"
#ffffff
\"
>
$k
</th>"
;
}
$buf
.=
"</tr>"
;
$first
=
false
;
}
$buf
.=
"<tr>"
;
foreach
(
$row
as
$k
=>
$v
)
{
$buf
.=
"<td bgcolor=
\"
#ffffff
\"
>
$v
</td>"
;
}
$buf
.=
"</tr>"
;
}
$buf
.=
"</table><br /> "
;
mysql_free_result
(
$cur
);
$this
->
_sql
=
$temp
;
return
"<div style=
\"
background-color:#FFFFCC
\"
align=
\"
left
\"
>
$buf
</div>"
;
}
/**
* @return int The number of rows returned from the most recent query.
*/
function
getNumRows
(
$cur
=
null
)
{
return
mysql_num_rows
(
$cur
?
$cur
:
$this
->
_cursor
);
}
/**
* This method loads the first field of the first row returned by the query.
*
* @return The value returned in the query or null if the query failed.
*/
function
loadResult
()
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$ret
=
null
;
if
(
$row
=
mysql_fetch_row
(
$cur
))
{
$ret
=
$row
[
0
];
}
mysql_free_result
(
$cur
);
return
$ret
;
}
/**
* Load an array of single field results into an array
*/
function
loadResultArray
(
$numinarray
=
0
)
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$array
=
array
();
while
(
$row
=
mysql_fetch_row
(
$cur
))
{
$array
[]
=
$row
[
$numinarray
];
}
mysql_free_result
(
$cur
);
return
$array
;
}
/**
* Load a assoc list of database rows
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
*/
function
loadAssocList
(
$key
=
''
)
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$array
=
array
();
while
(
$row
=
mysql_fetch_assoc
(
$cur
))
{
if
(
$key
)
{
$array
[
$row
->
$key
]
=
$row
;
}
else
{
$array
[]
=
$row
;
}
}
mysql_free_result
(
$cur
);
return
$array
;
}
/**
* This global function loads the first row of a query into an object
*
* If an object is passed to this function, the returned row is bound to the existing elements of <var>object</var>.
* If <var>object</var> has a value of null, then all of the returned query fields returned in the object.
* @param string The SQL query
* @param object The address of variable
*/
function
loadObject
(
&
$object
)
{
if
(
$object
!=
null
)
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
false
;
}
if
(
$array
=
mysql_fetch_assoc
(
$cur
))
{
mysql_free_result
(
$cur
);
mosBindArrayToObject
(
$array
,
$object
,
null
,
null
,
false
);
return
true
;
}
else
{
return
false
;
}
}
else
{
if
(
$cur
=
$this
->
query
())
{
if
(
$object
=
mysql_fetch_object
(
$cur
))
{
mysql_free_result
(
$cur
);
return
true
;
}
else
{
$object
=
null
;
return
false
;
}
}
else
{
return
false
;
}
}
}
/**
* Load a list of database objects
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*/
function
loadObjectList
(
$key
=
''
)
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$array
=
array
();
while
(
$row
=
mysql_fetch_object
(
$cur
))
{
if
(
$key
)
{
$array
[
$row
->
$key
]
=
$row
;
}
else
{
$array
[]
=
$row
;
}
}
mysql_free_result
(
$cur
);
return
$array
;
}
/**
* @return The first row of the query.
*/
function
loadRow
()
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$ret
=
null
;
if
(
$row
=
mysql_fetch_row
(
$cur
))
{
$ret
=
$row
;
}
mysql_free_result
(
$cur
);
return
$ret
;
}
/**
* Load a list of database rows (numeric column indexing)
* @param string The field name of a primary key
* @return array If <var>key</var> is empty as sequential list of returned records.
* If <var>key</var> is not empty then the returned array is indexed by the value
* the database key. Returns <var>null</var> if the query fails.
*/
function
loadRowList
(
$key
=
''
)
{
if
(
!
(
$cur
=
$this
->
query
()))
{
return
null
;
}
$array
=
array
();
while
(
$row
=
mysql_fetch_array
(
$cur
))
{
if
(
$key
)
{
$array
[
$row
[
$key
]]
=
$row
;
}
else
{
$array
[]
=
$row
;
}
}
mysql_free_result
(
$cur
);
return
$array
;
}
/**
* Document::db_insertObject()
*
* { Description }
*
* @param [type] $keyName
* @param [type] $verbose
*/
function
insertObject
(
$table
,
&
$object
,
$keyName
=
NULL
,
$verbose
=
false
)
{
$fmtsql
=
"INSERT INTO
$table
( %s ) VALUES ( %s ) "
;
$fields
=
array
();
foreach
(
get_object_vars
(
$object
)
as
$k
=>
$v
)
{
if
(
is_array
(
$v
)
or
is_object
(
$v
)
or
$v
===
NULL
)
{
continue
;
}
if
(
$k
[
0
]
==
'_'
)
{
// internal field
continue
;
}
$fields
[]
=
"`
$k
`"
;
$values
[]
=
"'"
.
$this
->
getEscaped
(
$v
)
.
"'"
;
}
$this
->
setQuery
(
sprintf
(
$fmtsql
,
implode
(
","
,
$fields
)
,
implode
(
","
,
$values
)
)
);
(
$verbose
)
&&
print
"
$sql
<br />
\n
"
;
if
(
!
$this
->
query
())
{
return
false
;
}
$id
=
mysql_insert_id
();
(
$verbose
)
&&
print
"id=[
$id
]<br />
\n
"
;
if
(
$keyName
&&
$id
)
{
$object
->
$keyName
=
$id
;
}
return
true
;
}
/**
* Document::db_updateObject()
*
* { Description }
*
* @param [type] $updateNulls
*/
function
updateObject
(
$table
,
&
$object
,
$keyName
,
$updateNulls
=
true
)
{
$fmtsql
=
"UPDATE
$table
SET %s WHERE %s"
;
$tmp
=
array
();
foreach
(
get_object_vars
(
$object
)
as
$k
=>
$v
)
{
if
(
is_array
(
$v
)
or
is_object
(
$v
)
or
$k
[
0
]
==
'_'
)
{
// internal or NA field
continue
;
}
if
(
$k
==
$keyName
)
{
// PK not to be updated
$where
=
"
$keyName
='"
.
$this
->
getEscaped
(
$v
)
.
"'"
;
continue
;
}
if
(
$v
===
NULL
&&
!
$updateNulls
)
{
continue
;
}
if
(
$v
==
''
)
{
$val
=
"''"
;
}
else
{
$val
=
"'"
.
$this
->
getEscaped
(
$v
)
.
"'"
;
}
$tmp
[]
=
"`
$k
`=
$val
"
;
}
$this
->
setQuery
(
sprintf
(
$fmtsql
,
implode
(
","
,
$tmp
)
,
$where
)
);
return
$this
->
query
();
}
/**
* @param boolean If TRUE, displays the last SQL statement sent to the database
* @return string A standised error message
*/
function
stderr
(
$showSQL
=
false
)
{
return
"БД ошибка функции, код возврата:
$this->_errorNum
"
.
"<br /><font color=
\"
red
\"
>
$this->_errorMsg
</font>"
.
(
$showSQL
?
"<br />SQL = <pre>
$this->_sql
</pre>"
:
''
);
}
function
insertid
()
{
return
mysql_insert_id
();
}
function
getVersion
()
{
return
mysql_get_server_info
();
}
/**
* Fudge method for ADOdb compatibility
*/
function
GenID
(
$foo1
=
null
,
$foo2
=
null
)
{
return
'0'
;
}
/**
* @return array A list of all the tables in the database
*/
function
getTableList
()
{
$this
->
setQuery
(
'SHOW tables'
);
$this
->
query
();
return
$this
->
loadResultArray
();
}
/**
* @param array A list of table names
* @return array A list the create SQL for the tables
*/
function
getTableCreate
(
$tables
)
{
$result
=
array
();
foreach
(
$tables
as
$tblval
)
{
$this
->
setQuery
(
'SHOW CREATE table '
.
$tblval
);
$this
->
query
();
$result
[
$tblval
]
=
$this
->
loadResultArray
(
1
);
}
return
$result
;
}
/**
* @param array A list of table names
* @return array An array of fields by table
*/
function
getTableFields
(
$tables
)
{
$result
=
array
();
foreach
(
$tables
as
$tblval
)
{
$this
->
setQuery
(
'SHOW FIELDS FROM '
.
$tblval
);
$this
->
query
();
$fields
=
$this
->
loadObjectList
();
foreach
(
$fields
as
$field
)
{
$result
[
$tblval
][
$field
->
Field
]
=
preg_replace
(
"/[(0-9)]/"
,
''
,
$field
->
Type
);
}
}
return
$result
;
}
}
/**
* mosDBTable Abstract Class.
* @abstract
* @package Mambo
* @subpackage Database
*
* Parent classes to all database derived objects. Customisation will generally
* not involve tampering with this object.
* @package Mambo
* @author Andrew Eddie <eddieajau@users.sourceforge.net
*/
class
mosDBTable
{
/** @var string Name of the table in the db schema relating to child class */
var
$_tbl
=
''
;
/** @var string Name of the primary key field in the table */
var
$_tbl_key
=
''
;
/** @var string Error message */
var
$_error
=
''
;
/** @var mosDatabase Database connector */
var
$_db
=
null
;
/**
* Object constructor to set table and key field
*
* Can be overloaded/supplemented by the child class
* @param string $table name of the table in the db schema relating to child class
* @param string $key name of the primary key field in the table
*/
function
mosDBTable
(
$table
,
$key
,
&
$db
)
{
$this
->
_tbl
=
$table
;
$this
->
_tbl_key
=
$key
;
$this
->
_db
=&
$db
;
}
/**
* Filters public properties
* @access protected
* @param array List of fields to ignore
*/
function
filter
(
$ignoreList
=
null
)
{
$ignore
=
is_array
(
$ignoreList
);
$iFilter
=
new
InputFilter
();
foreach
(
$this
->
getPublicProperties
()
as
$k
)
{
if
(
$ignore
&&
in_array
(
$k
,
$ignoreList
)
)
{
continue
;
}
$this
->
$k
=
$iFilter
->
process
(
$this
->
$k
);
}
}
/**
* @return string Returns the error message
*/
function
getError
()
{
return
$this
->
_error
;
}
/**
* Gets the value of the class variable
* @param string The name of the class variable
* @return mixed The value of the class var (or null if no var of that name exists)
*/
function
get
(
$_property
)
{
if
(
isset
(
$this
->
$_property
))
{
return
$this
->
$_property
;
}
else
{
return
null
;
}
}
/**
* Returns an array of public properties
* @return array
*/
function
getPublicProperties
()
{
static
$cache
=
null
;
if
(
is_null
(
$cache
))
{
$cache
=
array
();
foreach
(
get_class_vars
(
get_class
(
$this
)
)
as
$key
=>
$val
)
{
if
(
substr
(
$key
,
0
,
1
)
!=
'_'
)
{
$cache
[]
=
$key
;
}
}
}
return
$cache
;
}
/**
* Set the value of the class variable
* @param string The name of the class variable
* @param mixed The value to assign to the variable
*/
function
set
(
$_property
,
$_value
)
{
$this
->
$_property
=
$_value
;
}
/**
* binds a named array/hash to this object
*
* can be overloaded/supplemented by the child class
* @param array $hash named array
* @return null|string null is operation was satisfactory, otherwise returns an error
*/
function
bind
(
$array
,
$ignore
=
""
)
{
if
(
!
is_array
(
$array
))
{
$this
->
_error
=
strtolower
(
get_class
(
$this
))
.
"::bind failed."
;
return
false
;
}
else
{
return
mosBindArrayToObject
(
$array
,
$this
,
$ignore
);
}
}
/**
* binds an array/hash to this object
* @param int $oid optional argument, if not specifed then the value of current key is used
* @return any result from the database operation
*/
function
load
(
$oid
=
null
)
{
$k
=
$this
->
_tbl_key
;
if
(
$oid
!==
null
)
{
$this
->
$k
=
$oid
;
}
$oid
=
$this
->
$k
;
if
(
$oid
===
null
)
{
return
false
;
}
$this
->
_db
->
setQuery
(
"SELECT * FROM
$this->_tbl
WHERE
$this->_tbl_key
='
$oid
'"
);
return
$this
->
_db
->
loadObject
(
$this
);
}
/**
* generic check method
*
* can be overloaded/supplemented by the child class
* @return boolean True if the object is ok
*/
function
check
()
{
return
true
;
}
/**
* Inserts a new row if id is zero or updates an existing row in the database table
*
* Can be overloaded/supplemented by the child class
* @param boolean If false, null object variables are not updated
* @return null|string null if successful otherwise returns and error message
*/
function
store
(
$updateNulls
=
false
)
{
$k
=
$this
->
_tbl_key
;
global
$migrate
;
if
(
$this
->
$k
&&
!
$migrate
)
{
$ret
=
$this
->
_db
->
updateObject
(
$this
->
_tbl
,
$this
,
$this
->
_tbl_key
,
$updateNulls
);
}
else
{
$ret
=
$this
->
_db
->
insertObject
(
$this
->
_tbl
,
$this
,
$this
->
_tbl_key
);
}
if
(
!
$ret
)
{
$this
->
_error
=
strtolower
(
get_class
(
$this
))
.
"::запись неудачна <br />"
.
$this
->
_db
->
getErrorMsg
();
return
false
;
}
else
{
return
true
;
}
}
/**
*/
function
move
(
$dirn
,
$where
=
''
)
{
$k
=
$this
->
_tbl_key
;
$sql
=
"SELECT
$this->_tbl_key
, ordering FROM
$this->_tbl
"
;
if
(
$dirn
<
0
)
{
$sql
.=
"
\n
WHERE ordering <
$this->ordering
"
;
$sql
.=
(
$where
?
"
\n
AND
$where
"
:
''
);
$sql
.=
"
\n
ORDER BY ordering DESC
\n
LIMIT 1"
;
}
else
if
(
$dirn
>
0
)
{
$sql
.=
"
\n
WHERE ordering >
$this->ordering
"
;
$sql
.=
(
$where
?
"
\n
AND
$where
"
:
''
);
$sql
.=
"
\n
ORDER BY ordering
\n
LIMIT 1"
;
}
else
{
$sql
.=
"
\n
WHERE ordering =
$this->ordering
"
;
$sql
.=
(
$where
?
"
\n
AND
$where
"
:
''
);
$sql
.=
"
\n
ORDER BY ordering
\n
LIMIT 1"
;
}
$this
->
_db
->
setQuery
(
$sql
);
//echo 'A: ' . $this->_db->getQuery();
$row
=
null
;
if
(
$this
->
_db
->
loadObject
(
$row
))
{
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
SET ordering='
$row->ordering
'"
.
"
\n
WHERE
$this->_tbl_key
='"
.
$this
->
$k
.
"'"
);
if
(
!
$this
->
_db
->
query
())
{
$err
=
$this
->
_db
->
getErrorMsg
();
die
(
$err
);
}
//echo 'B: ' . $this->_db->getQuery();
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
SET ordering='
$this->ordering
'"
.
"
\n
WHERE
$this->_tbl_key
='"
.
$row
->
$k
.
"'"
);
//echo 'C: ' . $this->_db->getQuery();
if
(
!
$this
->
_db
->
query
())
{
$err
=
$this
->
_db
->
getErrorMsg
();
die
(
$err
);
}
$this
->
ordering
=
$row
->
ordering
;
}
else
{
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
SET ordering='
$this->ordering
'"
.
"
\n
WHERE
$this->_tbl_key
='"
.
$this
->
$k
.
"'"
);
//echo 'D: ' . $this->_db->getQuery();
if
(
!
$this
->
_db
->
query
())
{
$err
=
$this
->
_db
->
getErrorMsg
();
die
(
$err
);
}
}
}
/**
* Compacts the ordering sequence of the selected records
* @param string Additional where query to limit ordering to a particular subset of records
*/
function
updateOrder
(
$where
=
''
)
{
$k
=
$this
->
_tbl_key
;
if
(
!
array_key_exists
(
'ordering'
,
get_class_vars
(
strtolower
(
get_class
(
$this
))
)
))
{
$this
->
_error
=
"ВНИМАНИЕ: "
.
strtolower
(
get_class
(
$this
))
.
" не поддержтвает сортировку."
;
return
false
;
}
if
(
$this
->
_tbl
==
"#__content_frontpage"
)
{
$order2
=
", content_id DESC"
;
}
else
{
$order2
=
""
;
}
$this
->
_db
->
setQuery
(
"SELECT
$this->_tbl_key
, ordering FROM
$this->_tbl
"
.
(
$where
?
"
\n
WHERE
$where
"
:
''
)
.
"
\n
ORDER BY ordering"
.
$order2
);
if
(
!
(
$orders
=
$this
->
_db
->
loadObjectList
()))
{
$this
->
_error
=
$this
->
_db
->
getErrorMsg
();
return
false
;
}
// first pass, compact the ordering numbers
for
(
$i
=
0
,
$n
=
count
(
$orders
);
$i
<
$n
;
$i
++
)
{
if
(
$orders
[
$i
]
->
ordering
>=
0
)
{
$orders
[
$i
]
->
ordering
=
$i
+
1
;
}
}
$shift
=
0
;
$n
=
count
(
$orders
);
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
{
//echo "i=$i id=".$orders[$i]->$k." order=".$orders[$i]->ordering;
if
(
$orders
[
$i
]
->
$k
==
$this
->
$k
)
{
// place 'this' record in the desired location
$orders
[
$i
]
->
ordering
=
min
(
$this
->
ordering
,
$n
);
$shift
=
1
;
}
else
if
(
$orders
[
$i
]
->
ordering
>=
$this
->
ordering
&&
$this
->
ordering
>
0
)
{
$orders
[
$i
]
->
ordering
++
;
}
}
//echo '<pre>';print_r($orders);echo '</pre>';
// compact once more until I can find a better algorithm
for
(
$i
=
0
,
$n
=
count
(
$orders
);
$i
<
$n
;
$i
++
)
{
if
(
$orders
[
$i
]
->
ordering
>=
0
)
{
$orders
[
$i
]
->
ordering
=
$i
+
1
;
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
"
.
"
\n
SET ordering='"
.
$orders
[
$i
]
->
ordering
.
"' WHERE
$k
='"
.
$orders
[
$i
]
->
$k
.
"'"
);
$this
->
_db
->
query
();
//echo '<br />'.$this->_db->getQuery();
}
}
// if we didn't reorder the current record, make it last
if
(
$shift
==
0
)
{
$order
=
$n
+
1
;
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
"
.
"
\n
SET ordering='
$order
' WHERE
$k
='"
.
$this
->
$k
.
"'"
);
$this
->
_db
->
query
();
//echo '<br />'.$this->_db->getQuery();
}
return
true
;
}
/**
* Generic check for whether dependancies exist for this object in the db schema
*
* can be overloaded/supplemented by the child class
* @param string $msg Error message returned
* @param int Optional key index
* @param array Optional array to compiles standard joins: format [label=>'Label',name=>'table name',idfield=>'field',joinfield=>'field']
* @return true|false
*/
function
canDelete
(
$oid
=
null
,
$joins
=
null
)
{
$k
=
$this
->
_tbl_key
;
if
(
$oid
)
{
$this
->
$k
=
intval
(
$oid
);
}
if
(
is_array
(
$joins
))
{
$select
=
"
$k
"
;
$join
=
""
;
foreach
(
$joins
as
$table
)
{
$select
.=
",
\n
COUNT(DISTINCT
{
$table
[
'idfield'
]
}
) AS
{
$table
[
'idfield'
]
}
"
;
$join
.=
"
\n
LEFT JOIN
{
$table
[
'name'
]
}
ON
{
$table
[
'joinfield'
]
}
=
$k
"
;
}
$this
->
_db
->
setQuery
(
"SELECT
$select
\n
FROM
$this->_tbl
\n
$join
\n
WHERE
$k
= "
.
$this
->
$k
.
" GROUP BY
$k
"
);
if
(
$obj
=
$this
->
_db
->
loadObject
())
{
$this
->
_error
=
$this
->
_db
->
getErrorMsg
();
return
false
;
}
$msg
=
array
();
foreach
(
$joins
as
$table
)
{
$k
=
$table
[
'idfield'
];
if
(
$obj
->
$k
)
{
$msg
[]
=
$AppUI
->
_
(
$table
[
'label'
]
);
}
}
if
(
count
(
$msg
))
{
$this
->
_error
=
"noDeleteRecord"
.
": "
.
implode
(
', '
,
$msg
);
return
false
;
}
else
{
return
true
;
}
}
return
true
;
}
/**
* Default delete method
*
* can be overloaded/supplemented by the child class
* @return true if successful otherwise returns and error message
*/
function
delete
(
$oid
=
null
)
{
//if (!$this->canDelete( $msg )) {
// return $msg;
//}
$k
=
$this
->
_tbl_key
;
if
(
$oid
)
{
$this
->
$k
=
intval
(
$oid
);
}
$this
->
_db
->
setQuery
(
"DELETE FROM
$this->_tbl
WHERE
$this->_tbl_key
= '"
.
$this
->
$k
.
"'"
);
if
(
$this
->
_db
->
query
())
{
return
true
;
}
else
{
$this
->
_error
=
$this
->
_db
->
getErrorMsg
();
return
false
;
}
}
function
checkout
(
$who
,
$oid
=
null
)
{
if
(
!
array_key_exists
(
'checked_out'
,
get_class_vars
(
strtolower
(
get_class
(
$this
))
)
))
{
$this
->
_error
=
"ВНИМАНИЕ: "
.
strtolower
(
get_class
(
$this
))
.
" не поддерживает checkouts."
;
return
false
;
}
$k
=
$this
->
_tbl_key
;
if
(
$oid
!==
null
)
{
$this
->
$k
=
$oid
;
}
$time
=
date
(
"%Y-%m-%d H:i:s"
);
if
(
intval
(
$who
))
{
// new way of storing editor, by id
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
"
.
"
\n
SET checked_out='
$who
', checked_out_time='
$time
'"
.
"
\n
WHERE
$this->_tbl_key
='"
.
$this
->
$k
.
"'"
);
}
else
{
// old way of storing editor, by name
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
"
.
"
\n
SET checked_out='1', checked_out_time='
$time
', editor='"
.
$who
.
"' "
.
"
\n
WHERE
$this->_tbl_key
='"
.
$this
->
$k
.
"'"
);
}
return
$this
->
_db
->
query
();
}
function
checkin
(
$oid
=
null
)
{
if
(
!
array_key_exists
(
'checked_out'
,
get_class_vars
(
strtolower
(
get_class
(
$this
))
)
))
{
$this
->
_error
=
"ВНИМАНИЕ: "
.
strtolower
(
get_class
(
$this
))
.
" не поддерживает checkin."
;
return
false
;
}
$k
=
$this
->
_tbl_key
;
if
(
$oid
!==
null
)
{
$this
->
$k
=
$oid
;
}
$time
=
date
(
"H:i:s"
);
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
"
.
"
\n
SET checked_out='0', checked_out_time='0000-00-00 00:00:00'"
.
"
\n
WHERE
$this->_tbl_key
='"
.
$this
->
$k
.
"'"
);
return
$this
->
_db
->
query
();
}
function
hit
(
$oid
=
null
)
{
global
$mosConfig_enable_log_items
;
$k
=
$this
->
_tbl_key
;
if
(
$oid
!==
null
)
{
$this
->
$k
=
intval
(
$oid
);
}
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
SET hits=(hits+1) WHERE
$this->_tbl_key
='
$this->id
'"
);
$this
->
_db
->
query
();
if
(
@
$mosConfig_enable_log_items
)
{
$now
=
date
(
"Y-m-d"
);
$this
->
_db
->
setQuery
(
"SELECT hits"
.
"
\n
FROM #__core_log_items"
.
"
\n
WHERE time_stamp='
$now
' AND item_table='
$this->_tbl
' AND item_id='"
.
$this
->
$k
.
"'"
);
$hits
=
intval
(
$this
->
_db
->
loadResult
()
);
if
(
$hits
)
{
$this
->
_db
->
setQuery
(
"UPDATE #__core_log_items SET hits=(hits+1)"
.
"
\n
WHERE time_stamp='
$now
' AND item_table='
$this->_tbl
' AND item_id='"
.
$this
->
$k
.
"'"
);
$this
->
_db
->
query
();
}
else
{
$this
->
_db
->
setQuery
(
"INSERT INTO #__core_log_items VALUES"
.
"
\n
('
$now
','
$this->_tbl
','"
.
$this
->
$k
.
"','1')"
);
$this
->
_db
->
query
();
}
}
}
/**
* Generic save function
* @param array Source array for binding to class vars
* @param string Filter for the order updating
* @returns TRUE if completely successful, FALSE if partially or not succesful.
*/
function
save
(
$source
,
$order_filter
)
{
if
(
!
$this
->
bind
(
$_POST
))
{
return
false
;
}
if
(
!
$this
->
check
())
{
return
false
;
}
if
(
!
$this
->
store
())
{
return
false
;
}
if
(
!
$this
->
checkin
())
{
return
false
;
}
$filter_value
=
$this
->
$order_filter
;
$this
->
updateOrder
(
$order_filter
?
"`
$order_filter
`='
$filter_value
'"
:
""
);
$this
->
_error
=
''
;
return
true
;
}
/**
* Generic Publish/Unpublish function
* @param array An array of id numbers
* @param integer 0 if unpublishing, 1 if publishing
* @param integer The id of the user performnig the operation
*/
function
publish_array
(
$cid
=
null
,
$publish
=
1
,
$myid
=
0
)
{
if
(
!
is_array
(
$cid
)
||
count
(
$cid
)
<
1
)
{
$this
->
_error
=
"Не выбран объект."
;
return
false
;
}
$cids
=
implode
(
','
,
$cid
);
$this
->
_db
->
setQuery
(
"UPDATE
$this->_tbl
SET published='
$publish
'"
.
"
\n
WHERE
$this->_tbl_key
IN (
$cids
) AND (checked_out=0 OR (checked_out='
$myid
'))"
);
if
(
!
$this
->
_db
->
query
())
{
$this
->
_error
=
$this
->
_db
->
getErrorMsg
();
return
false
;
}
if
(
count
(
$cid
)
==
1
)
{
$this
->
checkin
(
$cid
[
0
]
);
}
$this
->
_error
=
''
;
return
true
;
}
/**
* Export item list to xml
* @param boolean Map foreign keys to text values
*/
function
toXML
(
$mapKeysToText
=
false
)
{
$xml
=
'<record table="'
.
$this
->
_tbl
.
'"'
;
if
(
$mapKeysToText
)
{
$xml
.=
' mapkeystotext="true"'
;
}
$xml
.=
'>'
;
foreach
(
get_object_vars
(
$this
)
as
$k
=>
$v
)
{
if
(
is_array
(
$v
)
or
is_object
(
$v
)
or
$v
===
NULL
)
{
continue
;
}
if
(
$k
[
0
]
==
'_'
)
{
// internal field
continue
;
}
$xml
.=
'<'
.
$k
.
'><![CDATA['
.
$v
.
']]></'
.
$k
.
'>'
;
}
$xml
.=
'</record>'
;
return
$xml
;
}
}
?>
default.php
View file @
e477d179
...
@@ -372,5 +372,5 @@ hgfgjhfgm,hgfhnfghnlfghlgfhgflhfghklgfhkghkgfhkgfkhhjkgfhklfghjh
...
@@ -372,5 +372,5 @@ hgfgjhfgm,hgfhnfghnlfghlgfhgflhfghklgfhkghkgfhkgfkhhjkgfhklfghjh
h gjhfgm,hgfhnfghnlfghlgfhgflhfghklgfhkghkgfhkgfkhhjkgfhklfghjh
h gjhfgm,hgfhnfghnlfghlgfhgflhfghklgfhkghkgfhkgfkhhjkgfhklfghjh
fg
<br>
gjhfgm,hg
fg
<br>
gjhfgm,hg
</div>
</div>
<script
src=
"etersoft_typos
2
.js"
></script>
<script
src=
"etersoft_typos.js"
></script>
</body>
</body>
etersoft_typos.js
View file @
e477d179
...
@@ -5,23 +5,37 @@
...
@@ -5,23 +5,37 @@
*/
*/
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
var
ety_time
=
0
;
//время последнего запроса
window
.
document
.
onkeydown
=
function
(
e
)
{
window
.
document
.
onkeydown
=
function
(
e
)
{
if
(
e
.
ctrlKey
==
1
&&
e
.
keyCode
==
13
)
{
if
(
e
.
ctrlKey
==
1
&&
e
.
keyCode
==
13
)
{
ETY
_
control_panel
();
ETY
.
control_panel
();
}
}
}
}
function
ETY_control_panel
()
{
var
ETY
=
{
time
:
0
,
//время последнего запроса
server_url
:
"http://barbass.pubsandbox.eterhost.ru/typos/server.php"
,
select_text
:
""
,
//Выделенный текст
get_select_text
:
function
()
{
var
text
=
String
(
window
.
getSelection
()).
trim
().
substr
(
0
,
50
);
if
(
typeof
(
text
)
==
'undefined'
)
{
text
=
""
;
}
return
text
;
},
control_panel
:
function
()
{
if
(
document
.
getElementById
(
"e_typos_div"
).
style
.
display
==
"block"
)
{
if
(
document
.
getElementById
(
"e_typos_div"
).
style
.
display
==
"block"
)
{
ETY_
close
();
this
.
close
();
}
else
{
}
else
{
ETY_div
();
this
.
div
();
ETY
.
select_text
=
ETY
.
get_select_text
();
}
}
}
},
function
ETY_div
()
{
div
:
function
()
{
//Определяем на какой позиции X, Y всплывет элемент
//Определяем на какой позиции X, Y всплывет элемент
var
top
=
window
.
pageYOffset
+
window
.
innerHeight
/
3
;
var
top
=
window
.
pageYOffset
+
window
.
innerHeight
/
3
;
var
left
=
window
.
pageXOffset
+
window
.
innerWidth
/
3
;
var
left
=
window
.
pageXOffset
+
window
.
innerWidth
/
3
;
...
@@ -29,133 +43,152 @@ function ETY_div() {
...
@@ -29,133 +43,152 @@ function ETY_div() {
document
.
getElementById
(
"e_typos_div"
).
style
.
left
=
left
+
"px"
;
document
.
getElementById
(
"e_typos_div"
).
style
.
left
=
left
+
"px"
;
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"none"
;
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"none"
;
//document.getElementById("e_typos_user_text").style.display = "none";
document
.
getElementById
(
"e_typos_comment"
).
value
=
""
;
document
.
getElementById
(
"e_typos_comment"
).
value
=
""
;
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"block"
;
}
},
function
ETY_close
()
{
close
:
function
()
{
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"none"
;
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"none"
;
}
},
function
ETY_post_data
()
{
post_data
:
function
()
{
var
this_url
=
window
.
location
.
href
;
//Текущая страница
var
this_url
=
window
.
location
.
href
;
//Текущая страница
var
select_text
=
String
(
window
.
getSelection
()).
trim
();
//Выделенный текст
var
post_text
;
var
user_email
=
document
.
getElementById
(
"e_typos_email"
).
value
.
trim
().
substr
(
0
,
50
);
if
(
ETY
.
select_text
==
""
)
{
if
(
user_email
==
''
)
{
post_text
=
ETY
.
get_select_text
();
user_email
=
""
;
}
else
{
}
else
{
if
(
!
/^
([
a-z0-9_-
]
+
\.)
*
[
a-z0-9_-
]
+@
[
a-z0-9_-
]
+
(\.[
a-z0-9_-
]
+
)
*
\.[
a-z
]{2,4}
$/
.
test
(
user_email
))
{
post_text
=
ETY
.
select_text
;
ETY_error
(
"red"
,
"e-mail некорректен"
);
return
false
;
}
}
var
new_text
=
ETY
.
get_select_text
();
if
(
new_text
!=
ETY
.
select_text
&&
new_text
.
length
!=
0
)
{
post_text
=
new_text
;
}
}
//Выделенный текст
var
user_comment
=
document
.
getElementById
(
"e_typos_comment"
).
value
.
trim
().
substr
(
0
,
50
);
var
user_comment
=
document
.
getElementById
(
"e_typos_comment"
).
value
.
trim
().
substr
(
0
,
50
);
if
(
user_comment
==
''
)
{
if
(
user_comment
==
''
)
{
user_comment
=
""
;
user_comment
=
""
;
}
}
if
(
selec
t_text
.
length
==
0
)
{
if
(
pos
t_text
.
length
==
0
)
{
ETY_
error
(
"red"
,
"Вы ничего не выделили"
);
this
.
error
(
"red"
,
"Вы ничего не выделили"
);
}
else
if
(
selec
t_text
.
length
<
5
)
{
}
else
if
(
pos
t_text
.
length
<
5
)
{
ETY_
error
(
"red"
,
"Выделенный текст слишком короток"
);
this
.
error
(
"red"
,
"Выделенный текст слишком короток"
);
}
else
if
(
selec
t_text
.
length
>
30
)
{
}
else
if
(
pos
t_text
.
length
>
30
)
{
ETY_
error
(
"red"
,
"Выделенный текст слишком длинный"
);
this
.
error
(
"red"
,
"Выделенный текст слишком длинный"
);
}
else
{
}
else
{
ETY
.
select_text
=
post_text
;
//Ajax-запрос
//Ajax-запрос
ETY_ajax_query
(
"http://barbass.pubsandbox.eterhost.ru/typos/server.php"
+
"?url="
+
this_url
+
"&email="
+
user_email
+
"&comment="
+
user_comment
+
"&error_text="
+
selec
t_text
);
this
.
ajax_query
(
this
.
server_url
+
"?e_typos_url="
+
this_url
+
"&e_typos_comment="
+
user_comment
+
"&e_typos_error_text="
+
pos
t_text
);
}
}
},
}
//Отправка запроса
ajax_query
:
function
(
url
)
{
this
.
error
(
"black"
,
"Идет отправка данных..."
);
//Отправка запроса
function
ETY_ajax_query
(
url
)
{
ETY_error
(
"black"
,
"Идет отправка данных..."
);
var
XHR
=
window
.
XDomainRequest
||
window
.
XMLHttpRequest
;
var
XHR
=
window
.
XDomainRequest
||
window
.
XMLHttpRequest
;
request
=
new
XHR
;
request
=
new
XHR
;
//Если не поддерживаются кроссдоменные запросы
//Если не поддерживаются кроссдоменные запросы
if
(
request
.
withCredentials
==
undefined
)
{
if
(
request
.
withCredentials
==
undefined
)
{
ETY_error
(
"red"
,
"Ваш браузер не может отправить данные"
);
var
old_url
=
window
.
location
.
href
;
newWin
=
window
.
open
(
url
,
'_blank'
);
window
.
parent
.
focus
();
//setTimeout('newWin.close()', 1000);
this
.
error
(
"green"
,
"Спасибо за ваше внимание"
);
window
.
setTimeout
(
'ETY.close()'
,
2000
);
return
false
;
return
false
;
}
}
var
result
=
ETY_
timer
();
var
result
=
this
.
timer
();
if
(
result
==
0
)
{
if
(
result
==
0
)
{
ETY_
error
(
"red"
,
"Не отправляйте данные часто"
);
this
.
error
(
"red"
,
"Не отправляйте данные часто"
);
return
false
;
return
false
;
}
else
{
}
else
{
ety_time
=
ETY_this
_time
();
this
.
time
=
this
.
now
_time
();
ETY_set_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
,
ety_
time
);
this
.
set_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
,
this
.
time
);
}
}
request
.
open
(
"POST"
,
url
,
true
);
request
.
open
(
"POST"
,
url
,
true
);
request
.
onload
=
function
()
{
request
.
onload
=
function
()
{
var
data
=
request
.
responseText
;
var
data
=
request
.
responseText
.
split
(
' '
)
;
switch
(
data
)
{
switch
(
data
[
0
]
)
{
case
'10robot'
:
case
'10robot'
:
ETY_
error
(
"red"
,
"Есть подозрения что вы робот"
);
ETY
.
error
(
"red"
,
"Есть подозрения что вы робот"
);
break
;
break
;
case
'10dataerror'
:
case
'10dataerror'
:
ETY_
error
(
"red"
,
"Данные некорректны"
);
ETY
.
error
(
"red"
,
"Данные некорректны"
);
break
;
break
;
case
'10siteerror'
:
case
'10siteerror'
:
ETY_
error
(
"red"
,
"Данный сайт не поддерживается"
);
ETY
.
error
(
"red"
,
"Данный сайт не поддерживается"
);
break
;
break
;
case
'10emailerror'
:
case
'10emailerror'
:
ETY_
error
(
"red"
,
"Сервер не смог отправить письмо"
);
ETY
.
error
(
"red"
,
"Сервер не смог отправить письмо"
);
break
;
break
;
case
'10win'
:
case
'10win'
:
ETY_
error
(
"green"
,
"Спасибо за ваше внимание"
);
ETY
.
error
(
"green"
,
"Спасибо за ваше внимание"
);
window
.
setTimeout
(
'ETY_
close()'
,
2000
);
window
.
setTimeout
(
'ETY.
close()'
,
2000
);
break
;
break
;
case
'10inserterror'
:
case
'10inserterror'
:
ETY_
error
(
"red"
,
"Ошибка добавления данных"
);
ETY
.
error
(
"red"
,
"Ошибка добавления данных"
);
break
;
break
;
case
'10servererror'
:
case
'10servererror'
:
ETY_
error
(
"red"
,
"На сервере произошла ошибка"
);
ETY
.
error
(
"red"
,
"На сервере произошла ошибка"
);
break
;
break
;
default
:
default
:
ETY_
error
(
"red"
,
"На сервере произошла ошибка"
);
ETY
.
error
(
"red"
,
"На сервере произошла ошибка"
);
break
;
break
;
}
}
}
}
request
.
onerror
=
function
()
{
request
.
onerror
=
function
()
{
ETY_
error
(
"red"
,
"Ошибка отправки данных. Повторите позже"
);
ETY
.
error
(
"red"
,
"Ошибка отправки данных. Повторите позже"
);
ETY_
time
=
0
;
this
.
time
=
0
;
}
}
request
.
send
();
request
.
send
();
}
},
function
ETY_error
(
color
,
text
)
{
error
:
function
(
color
,
text
)
{
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_error"
).
innerHTML
=
text
;
document
.
getElementById
(
"e_typos_error"
).
innerHTML
=
text
;
document
.
getElementById
(
"e_typos_error"
).
style
.
color
=
color
;
document
.
getElementById
(
"e_typos_error"
).
style
.
color
=
color
;
document
.
getElementById
(
"e_typos_error"
).
style
.
borderColor
=
color
;
document
.
getElementById
(
"e_typos_error"
).
style
.
borderColor
=
color
;
}
},
text
:
function
(
text
)
{
document
.
getElementById
(
"e_typos_user_text"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_user_text"
).
innerHTML
=
"Ваш текст: "
+
text
;
},
function
ETY_timer
()
{
timer
:
function
()
{
var
sec
=
ETY_this
_time
();
var
sec
=
this
.
now
_time
();
var
time_s
=
ETY_
get_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
);
var
time_s
=
this
.
get_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
);
if
(
time_s
!=
0
)
{
if
(
time_s
!=
0
)
{
ety_
time
=
time_s
;
this
.
time
=
time_s
;
}
}
if
(
ETY_this_time
()
-
parseFloat
(
ety_
time
)
<
60000
)
{
if
(
this
.
now_time
()
-
parseFloat
(
this
.
time
)
<
60000
)
{
return
0
;
return
0
;
}
else
{
}
else
{
return
1
;
return
1
;
}
}
}
},
function
ETY_this_time
()
{
now_time
:
function
()
{
var
day
=
new
Date
();
var
day
=
new
Date
();
var
sec
=
day
.
getTime
();
var
sec
=
day
.
getTime
();
return
sec
;
return
sec
;
}
},
function
ETY_get_storage
(
key
)
{
get_storage
:
function
(
key
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
if
(
!
localStorage
.
getItem
(
key
+
""
))
{
if
(
!
localStorage
.
getItem
(
key
+
""
))
{
return
0
;
return
0
;
...
@@ -166,10 +199,13 @@ function ETY_get_storage(key) {
...
@@ -166,10 +199,13 @@ function ETY_get_storage(key) {
}
else
{
}
else
{
return
0
;
return
0
;
}
}
}
},
function
ETY_set_storage
(
key
,
data
)
{
set_storage
:
function
(
key
,
data
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
localStorage
.
setItem
(
key
+
""
,
data
);
localStorage
.
setItem
(
key
+
""
,
data
);
}
}
}
}
}
etersoft_typos2.js
deleted
100644 → 0
View file @
33275c21
/* Плагин: сервис опечаток от компании Etersoft
* email: info@etersoft.ru
* автор: barbass@etersoft.ru
* дата: 2012-04-18
*/
//////////////////////////////////////////////////////
window
.
document
.
onkeydown
=
function
(
e
)
{
if
(
e
.
ctrlKey
==
1
&&
e
.
keyCode
==
13
)
{
ETY
.
control_panel
();
}
}
var
ETY
=
{
time
:
0
,
//время последнего запроса
server_url
:
"http://barbass.pubsandbox.eterhost.ru/typos/server.php"
,
select_text
:
""
,
//Выделенный текст
get_select_text
:
function
()
{
var
text
=
String
(
window
.
getSelection
()).
trim
().
substr
(
0
,
50
);
if
(
typeof
(
text
)
==
'undefined'
)
{
text
=
""
;
}
return
text
;
},
control_panel
:
function
()
{
if
(
document
.
getElementById
(
"e_typos_div"
).
style
.
display
==
"block"
)
{
this
.
close
();
}
else
{
this
.
div
();
ETY
.
select_text
=
ETY
.
get_select_text
();
}
},
div
:
function
()
{
//Определяем на какой позиции X, Y всплывет элемент
var
top
=
window
.
pageYOffset
+
window
.
innerHeight
/
3
;
var
left
=
window
.
pageXOffset
+
window
.
innerWidth
/
3
;
document
.
getElementById
(
"e_typos_div"
).
style
.
top
=
top
+
"px"
;
document
.
getElementById
(
"e_typos_div"
).
style
.
left
=
left
+
"px"
;
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"none"
;
//document.getElementById("e_typos_user_text").style.display = "none";
document
.
getElementById
(
"e_typos_comment"
).
value
=
""
;
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"block"
;
},
close
:
function
()
{
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"none"
;
},
post_data
:
function
()
{
var
this_url
=
window
.
location
.
href
;
//Текущая страница
var
post_text
;
if
(
ETY
.
select_text
==
""
)
{
post_text
=
ETY
.
get_select_text
();
}
else
{
post_text
=
ETY
.
select_text
;
}
var
new_text
=
ETY
.
get_select_text
();
if
(
new_text
!=
ETY
.
select_text
&&
new_text
.
length
!=
0
)
{
post_text
=
new_text
;
}
//Выделенный текст
var
user_comment
=
document
.
getElementById
(
"e_typos_comment"
).
value
.
trim
().
substr
(
0
,
50
);
if
(
user_comment
==
''
)
{
user_comment
=
""
;
}
if
(
post_text
.
length
==
0
)
{
this
.
error
(
"red"
,
"Вы ничего не выделили"
);
}
else
if
(
post_text
.
length
<
5
)
{
this
.
error
(
"red"
,
"Выделенный текст слишком короток"
);
}
else
if
(
post_text
.
length
>
30
)
{
this
.
error
(
"red"
,
"Выделенный текст слишком длинный"
);
}
else
{
ETY
.
select_text
=
post_text
;
//Ajax-запрос
this
.
ajax_query
(
this
.
server_url
+
"?e_typos_url="
+
this_url
+
"&e_typos_comment="
+
user_comment
+
"&e_typos_error_text="
+
post_text
);
}
},
//Отправка запроса
ajax_query
:
function
(
url
)
{
this
.
error
(
"black"
,
"Идет отправка данных..."
);
var
XHR
=
window
.
XDomainRequest
||
window
.
XMLHttpRequest
;
request
=
new
XHR
;
//Если не поддерживаются кроссдоменные запросы
if
(
request
.
withCredentials
==
undefined
)
{
var
old_url
=
window
.
location
.
href
;
newWin
=
window
.
open
(
url
,
'_blank'
);
window
.
parent
.
focus
();
//setTimeout('newWin.close()', 1000);
this
.
error
(
"green"
,
"Спасибо за ваше внимание"
);
window
.
setTimeout
(
'ETY.close()'
,
2000
);
return
false
;
}
var
result
=
this
.
timer
();
if
(
result
==
0
)
{
this
.
error
(
"red"
,
"Не отправляйте данные часто"
);
return
false
;
}
else
{
this
.
time
=
this
.
now_time
();
this
.
set_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
,
this
.
time
);
}
request
.
open
(
"POST"
,
url
,
true
);
request
.
onload
=
function
()
{
var
data
=
request
.
responseText
.
split
(
' '
);
switch
(
data
[
0
])
{
case
'10robot'
:
ETY
.
error
(
"red"
,
"Есть подозрения что вы робот"
);
break
;
case
'10dataerror'
:
ETY
.
error
(
"red"
,
"Данные некорректны"
);
break
;
case
'10siteerror'
:
ETY
.
error
(
"red"
,
"Данный сайт не поддерживается"
);
break
;
case
'10emailerror'
:
ETY
.
error
(
"red"
,
"Сервер не смог отправить письмо"
);
break
;
case
'10win'
:
ETY
.
error
(
"green"
,
"Спасибо за ваше внимание"
);
window
.
setTimeout
(
'ETY.close()'
,
2000
);
break
;
case
'10inserterror'
:
ETY
.
error
(
"red"
,
"Ошибка добавления данных"
);
break
;
case
'10servererror'
:
ETY
.
error
(
"red"
,
"На сервере произошла ошибка"
);
break
;
default
:
ETY
.
error
(
"red"
,
"На сервере произошла ошибка"
);
break
;
}
}
request
.
onerror
=
function
()
{
ETY
.
error
(
"red"
,
"Ошибка отправки данных. Повторите позже"
);
this
.
time
=
0
;
}
request
.
send
();
},
error
:
function
(
color
,
text
)
{
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_error"
).
innerHTML
=
text
;
document
.
getElementById
(
"e_typos_error"
).
style
.
color
=
color
;
document
.
getElementById
(
"e_typos_error"
).
style
.
borderColor
=
color
;
},
text
:
function
(
text
)
{
document
.
getElementById
(
"e_typos_user_text"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_user_text"
).
innerHTML
=
"Ваш текст: "
+
text
;
},
timer
:
function
()
{
var
sec
=
this
.
now_time
();
var
time_s
=
this
.
get_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
);
if
(
time_s
!=
0
)
{
this
.
time
=
time_s
;
}
if
(
this
.
now_time
()
-
parseFloat
(
this
.
time
)
<
60000
)
{
return
0
;
}
else
{
return
1
;
}
},
now_time
:
function
()
{
var
day
=
new
Date
();
var
sec
=
day
.
getTime
();
return
sec
;
},
get_storage
:
function
(
key
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
if
(
!
localStorage
.
getItem
(
key
+
""
))
{
return
0
;
}
else
{
var
data
=
localStorage
.
getItem
(
key
+
""
);
return
data
;
}
}
else
{
return
0
;
}
},
set_storage
:
function
(
key
,
data
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
localStorage
.
setItem
(
key
+
""
,
data
);
}
}
}
minimambo.php
deleted
100644 → 0
View file @
33275c21
<?php
define
(
'_CMN_YES'
,
'Да'
);
define
(
'_CMN_NO'
,
'Нет'
);
define
(
'_PN_PAGE'
,
'Страница'
);
define
(
'_PN_OF'
,
'из'
);
define
(
'_PN_START'
,
'[В начало]'
);
define
(
'_PN_PREVIOUS'
,
'[Пред]'
);
define
(
'_PN_NEXT'
,
'[След]'
);
define
(
'_PN_END'
,
'[В конец]'
);
define
(
'_PN_DISPLAY_NR'
,
'На странице #'
);
define
(
'_PN_RESULTS'
,
'Результаты'
);
define
(
'_JAN'
,
'Январь'
);
define
(
'_FEB'
,
'Февраль'
);
define
(
'_MAR'
,
'Март'
);
define
(
'_APR'
,
'Апрель'
);
define
(
'_MAY'
,
'Май'
);
define
(
'_JUN'
,
'Июнь'
);
define
(
'_JUL'
,
'Июль'
);
define
(
'_AUG'
,
'Август'
);
define
(
'_SEP'
,
'Сентябрь'
);
define
(
'_OCT'
,
'Октябрь'
);
define
(
'_NOV'
,
'Ноябрь'
);
define
(
'_DEC'
,
'Декабрь'
);
global
$config_absolute_path
;
/**
* Copy the named array content into the object as properties
* only existing properties of object are filled. when undefined in hash, properties wont be deleted
* @param array the input array
* @param obj byref the object to fill of any class
* @param string
* @param boolean
*/
function
mosBindArrayToObject
(
$array
,
&
$obj
,
$prefix
=
NULL
,
$checkSlashes
=
true
)
{
if
(
!
is_array
(
$array
)
||
!
is_object
(
$obj
))
{
return
(
false
);
}
if
(
$prefix
)
{
foreach
(
get_object_vars
(
$obj
)
as
$k
=>
$v
)
{
if
(
isset
(
$array
[
$prefix
.
$k
]))
{
$obj
->
$k
=
(
$checkSlashes
&&
get_magic_quotes_gpc
())
?
stripslashes
(
$array
[
$k
]
)
:
$array
[
$k
];
}
}
}
else
{
foreach
(
get_object_vars
(
$obj
)
as
$k
=>
$v
)
{
if
(
isset
(
$array
[
$k
]))
{
$obj
->
$k
=
(
$checkSlashes
&&
get_magic_quotes_gpc
())
?
stripslashes
(
$array
[
$k
]
)
:
$array
[
$k
];
}
}
}
return
true
;
}
// ----------------------------------------------------------------------------------
class
mosHTML
{
function
makeOption
(
$value
,
$text
=
''
)
{
$obj
=
new
stdClass
;
$obj
->
value
=
$value
;
$obj
->
text
=
trim
(
$text
)
?
$text
:
$value
;
return
$obj
;
}
/**
* Generates an HTML select list
* @param array An array of objects
* @param string The value of the HTML name attribute
* @param string Additional HTML attributes for the <select> tag
* @param string The name of the object variable for the option value
* @param string The name of the object variable for the option text
* @param mixed The key that is selected
* @returns string HTML for the select list
*/
function
selectList
(
&
$arr
,
$tag_name
,
$tag_attribs
,
$key
,
$text
,
$selected
=
NULL
)
{
reset
(
$arr
);
$html
=
"
\n
<select name=
\"
$tag_name
\"
$tag_attribs
>"
;
for
(
$i
=
0
,
$n
=
count
(
$arr
);
$i
<
$n
;
$i
++
)
{
$k
=
$arr
[
$i
]
->
$key
;
$t
=
$arr
[
$i
]
->
$text
;
$id
=
@
$arr
[
$i
]
->
id
;
$extra
=
''
;
$extra
.=
$id
?
" id=
\"
"
.
$arr
[
$i
]
->
id
.
"
\"
"
:
''
;
if
(
is_array
(
$selected
))
{
foreach
(
$selected
as
$obj
)
{
$k2
=
$obj
->
$key
;
if
(
$k
==
$k2
)
{
$extra
.=
" selected=
\"
selected
\"
"
;
break
;
}
}
}
else
{
$extra
.=
(
$k
==
$selected
?
" selected=
\"
selected
\"
"
:
''
);
}
$html
.=
"
\n\t
<option value=
\"
"
.
$k
.
"
\"
$extra
>"
.
$t
.
"</option>"
;
}
$html
.=
"
\n
</select>
\n
"
;
return
$html
;
}
function
yesnoSelectList
(
$tag_name
,
$tag_attribs
,
$selected
,
$yes
=
_CMN_YES
,
$no
=
_CMN_NO
)
{
$arr
=
array
(
mosHTML
::
makeOption
(
'0'
,
$no
),
mosHTML
::
makeOption
(
'1'
,
$yes
),
);
return
mosHTML
::
selectList
(
$arr
,
$tag_name
,
$tag_attribs
,
'value'
,
'text'
,
$selected
);
}
}
function
mosRedirect
(
$url
,
$msg
=
''
)
{
// specific filters
$iFilter
=
new
InputFilter
();
$url
=
$iFilter
->
process
(
$url
);
$msg
=
$iFilter
->
process
(
$msg
);
if
(
$iFilter
->
badAttributeValue
(
array
(
'href'
,
$url
)))
{
$url
=
$GLOBALS
[
'mosConfig_live_site'
];
}
if
(
trim
(
$msg
))
{
if
(
strpos
(
$url
,
'?'
))
{
$url
.=
'&mosmsg='
.
urlencode
(
$msg
);
}
else
{
$url
.=
'?mosmsg='
.
urlencode
(
$msg
);
}
}
if
(
headers_sent
())
{
echo
"<script>document.location.href='
$url
';</script>
\n
"
;
}
else
{
@
ob_end_clean
();
// clear output buffer
header
(
"Location:
$url
"
);
}
exit
();
}
define
(
"_MOS_NOTRIM"
,
0x0001
);
define
(
"_MOS_ALLOWHTML"
,
0x0002
);
function
mosGetParam
(
&
$arr
,
$name
,
$def
=
null
,
$mask
=
0
)
{
$return
=
null
;
if
(
isset
(
$arr
[
$name
]
))
{
if
(
is_string
(
$arr
[
$name
]
))
{
if
(
!
(
$mask
&
_MOS_NOTRIM
))
{
$arr
[
$name
]
=
trim
(
$arr
[
$name
]
);
}
if
(
!
(
$mask
&
_MOS_ALLOWHTML
))
{
$arr
[
$name
]
=
strip_tags
(
$arr
[
$name
]
);
}
if
(
!
get_magic_quotes_gpc
())
{
$arr
[
$name
]
=
addslashes
(
$arr
[
$name
]
);
}
}
return
$arr
[
$name
];
}
else
{
return
$def
;
}
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment