本文整理汇总了PHP中pwg_db_real_escape_string函数的典型用法代码示例。如果您正苦于以下问题:PHP pwg_db_real_escape_string函数的具体用法?PHP pwg_db_real_escape_string怎么用?PHP pwg_db_real_escape_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwg_db_real_escape_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ws_images_addFlickr
function ws_images_addFlickr($photo, &$service)
{
if (!is_admin()) {
return new PwgError(403, 'Forbidden');
}
global $conf;
if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key'])) {
return new PwgError(null, l10n('Please fill your API keys on the configuration tab'));
}
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php';
include_once FLICKR_PATH . 'include/functions.inc.php';
if (test_remote_download() === false) {
return new PwgError(null, l10n('No download method available'));
}
// init flickr API
include_once FLICKR_PATH . 'include/phpFlickr/phpFlickr.php';
$flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
$flickr->enableCache('fs', FLICKR_FS_CACHE);
// user
$u = $flickr->test_login();
if ($u === false or empty($_SESSION['phpFlickr_auth_token'])) {
return new PwgError(403, l10n('API not authenticated'));
}
// photos infos
$photo_f = $flickr->photos_getInfo($photo['id']);
$photo = array_merge($photo, $photo_f['photo']);
$photo['url'] = $flickr->get_biggest_size($photo['id'], 'original');
$photo['path'] = FLICKR_FS_CACHE . 'flickr-' . $u['username'] . '-' . $photo['id'] . '.' . get_extension($photo['url']);
// copy file
if (download_remote_file($photo['url'], $photo['path']) == false) {
return new PwgError(null, l10n('Can\'t download file'));
}
// category
if (!preg_match('#^[0-9]+$#', $photo['category'])) {
$categories_names = explode(',', $photo['category']);
$photo['category'] = array();
foreach ($categories_names as $category_name) {
$query = '
SELECT id FROM ' . CATEGORIES_TABLE . '
WHERE LOWER(name) = "' . strtolower($category_name) . '"
;';
$result = pwg_query($query);
if (pwg_db_num_rows($result)) {
list($cat_id) = pwg_db_fetch_row($result);
$photo['category'][] = $cat_id;
} else {
$cat = create_virtual_category($category_name);
$photo['category'][] = $cat['id'];
}
}
} else {
$photo['category'] = array($photo['category']);
}
// add photo
$photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']);
// do some updates
if (!empty($photo['fills'])) {
$photo['fills'] = rtrim($photo['fills'], ',');
$photo['fills'] = explode(',', $photo['fills']);
$updates = array();
if (in_array('fill_name', $photo['fills'])) {
$updates['name'] = pwg_db_real_escape_string($photo['title']);
}
if (in_array('fill_posted', $photo['fills'])) {
$updates['date_available'] = date('Y-m-d H:i:s', $photo['dates']['posted']);
}
if (in_array('fill_taken', $photo['fills'])) {
$updates['date_creation'] = $photo['dates']['taken'];
}
if (in_array('fill_author', $photo['fills'])) {
$updates['author'] = pwg_db_real_escape_string($photo['owner']['username']);
}
if (in_array('fill_description', $photo['fills'])) {
$updates['comment'] = pwg_db_real_escape_string(@$photo['description']);
}
if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location'])) {
$updates['latitude'] = pwg_db_real_escape_string($photo['location']['latitude']);
$updates['longitude'] = pwg_db_real_escape_string($photo['location']['longitude']);
}
if (in_array('level', $photo['fills']) && !$photo['visibility']['ispublic']) {
$updates['level'] = 8;
if ($photo['visibility']['isfamily']) {
$updates['level'] = 4;
}
if ($photo['visibility']['isfriend']) {
$updates['level'] = 2;
}
}
if (count($updates)) {
single_update(IMAGES_TABLE, $updates, array('id' => $photo['image_id']));
}
if (!empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills'])) {
$raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']);
$raw_tags = implode(',', $raw_tags);
set_tags(get_tag_ids($raw_tags), $photo['image_id']);
}
}
return l10n('Photo "%s" imported', $photo['title']);
}
示例2: pwg_login
/**
* Default method for user login, can be overwritten with 'try_log_user' trigger.
* @see try_log_user()
*
* @param string $username
* @param string $password
* @param bool $remember_me
* @return bool
*/
function pwg_login($success, $username, $password, $remember_me)
{
if ($success === true) {
return true;
}
// we force the session table to be clean
pwg_session_gc();
global $conf;
// retrieving the encrypted password of the login submitted
$query = '
SELECT ' . $conf['user_fields']['id'] . ' AS id,
' . $conf['user_fields']['password'] . ' AS password
FROM ' . USERS_TABLE . '
WHERE ' . $conf['user_fields']['username'] . ' = \'' . pwg_db_real_escape_string($username) . '\'
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
if (isset($row['id']) and $conf['password_verify']($password, $row['password'], $row['id'])) {
log_user($row['id'], $remember_me);
trigger_notify('login_success', stripslashes($username));
return true;
}
trigger_notify('login_failure', stripslashes($username));
return false;
}
示例3: plugin_install
function plugin_install($id, $version, &$errors)
{
global $conf;
/* ****************************************************************** */
/* **************** BEGIN - Data preparation in vars **************** */
/* ****************************************************************** */
$defaultPH = array();
// Set current plugin version in config table
$plugin = PHInfos(PH_PATH);
$version = $plugin['version'];
// Default global parameters for Prune History conf
// -------------------------------------------------
$defaultPH = array('PHVersion' => $version, 'AUTOPRUNE' => 'false', 'RANGEVALUE' => '0', 'RANGE' => '0');
// Create Prune History conf if not already exists
// ------------------------------------------------
$query = '
SELECT param
FROM ' . CONFIG_TABLE . '
WHERE param = "PruneHistory"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0) {
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param, value, comment)
VALUES ("PruneHistory","' . pwg_db_real_escape_string(serialize($defaultPH)) . '","Prune History parameters")
;';
pwg_query($q);
}
}
示例4: upgrade_210
function upgrade_210()
{
global $conf;
$default = array('Blacklist' => "0", 'Version' => "2.1.1");
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES ("HistoryIPConfig","' . pwg_db_real_escape_string(serialize($default)) . '","History IP Excluder options");
';
pwg_query($q);
upgrade_211();
}
示例5: plugin_install
function plugin_install()
{
$eml_conf = array('content' => '', 'enabled' => false);
$query = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES (
\'eml\',
\'' . pwg_db_real_escape_string(serialize($eml_conf)) . '\',
\'Parameters of Extend Notification Link plugin\'
)
;';
pwg_query($query);
}
示例6: activate
function activate($theme_version, &$errors = array())
{
global $conf, $prefixeTable;
if (empty($conf['smartpocket'])) {
$conf['smartpocket'] = serialize($this->default_conf);
$query = "\n INSERT INTO " . CONFIG_TABLE . " (param,value,comment)\n VALUES ('smartpocket' , '" . pwg_db_real_escape_string($conf['smartpocket']) . "' , 'loop#autohide');";
pwg_query($query);
} elseif (count(unserialize($conf['smartpocket'])) != 2) {
$conff = unserialize($conf['smartpocket']);
$config = array('loop' => !empty($conff['loop']) ? $conff['loop'] : true, 'autohide' => !empty($conff['autohide']) ? $conff['autohide'] : 5000);
conf_update_param('smartpocket', pwg_db_real_escape_string(serialize($config)));
load_conf_from_db();
}
$this->installed = true;
}
示例7: upgrade_100_110
function upgrade_100_110()
{
global $conf;
load_language('plugin.lang', PH_PATH);
// Upgrading options - Changing config variables to assoc array
// ------------------------------------------------------------
// Upgrade $conf_PH options
$conf_PH = unserialize($conf['PruneHistory']);
$Newconf_PH = array('PHVersion' => $conf_PH[0], 'AUTOPRUNE' => $conf_PH[1], 'RANGEVALUE' => $conf_PH[2], 'RANGE' => $conf_PH[3]);
// unset obsolete conf
// -------------------
for ($i = 0; $i <= 3; $i++) {
unset($conf_PH[$i]);
}
$update_conf = serialize($Newconf_PH);
conf_update_param('PruneHistory', pwg_db_real_escape_string($update_conf));
}
示例8: plugin_install
function plugin_install($id, $version, &$errors)
{
global $conf;
// Set current plugin version in config table
$plugin = CM_Infos(CM_PATH);
$version = $plugin['version'];
$default = array('CMVersion' => $version, 'CM_No_Comment_Anonymous' => 'false', 'CM_GROUPCOMM' => 'false', 'CM_ALLOWCOMM_GROUP' => -1, 'CM_GROUPVALID1' => 'false', 'CM_VALIDCOMM1_GROUP' => -1, 'CM_GROUPVALID2' => 'false', 'CM_VALIDCOMM2_GROUP' => -1);
$query = '
SELECT param
FROM ' . CONFIG_TABLE . '
WHERE param = "CommentsManager"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0) {
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param, value, comment)
VALUES ("CommentsManager","' . pwg_db_real_escape_string(serialize($default)) . '","Comments Access Manager parameters")
;';
pwg_query($q);
}
}
示例9: upgrade_240_250
function upgrade_240_250()
{
global $conf;
load_language('plugin.lang', REGFLUXBB_PATH);
$plugin = RegFluxBB_Infos(REGFLUXBB_PATH);
$version = $plugin['version'];
// Upgrading options - Changing config variables to assoc array
// ------------------------------------------------------------
$conf_RegFluxBB = isset($conf['Register_FluxBB']) ? explode(";", $conf['Register_FluxBB']) : array();
$Newconf_RegFluxBB = array('REGFLUXBB_VERSION' => $version, 'FLUXBB_PREFIX' => $conf_RegFluxBB[0], 'FLUXBB_ADMIN' => $conf_RegFluxBB[1], 'FLUXBB_GUEST' => $conf_RegFluxBB[2], 'FLUXBB_DEL_PT' => $conf_RegFluxBB[3], 'FLUXBB_CONFIRM' => $conf_RegFluxBB[4], 'FLUXBB_DETAIL' => $conf_RegFluxBB[5], 'FLUXBB_UAM_LINK' => $conf_RegFluxBB[6], 'FLUXBB_GROUP' => $conf_RegFluxBB[7]);
$update_conf = serialize($Newconf_RegFluxBB);
$q = '
DELETE FROM ' . CONFIG_TABLE . '
WHERE param="Register_FluxBB" LIMIT 1
;';
pwg_query($q);
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param, value, comment)
VALUES ("Register_FluxBB","' . pwg_db_real_escape_string($update_conf) . '","Register_FluxBB parameters")
;';
pwg_query($q);
}
示例10: plugin_install
function plugin_install($id, $version, &$errors)
{
global $prefixeTable, $conf;
// Set current plugin version in config table
$plugin = RegFluxBB_Infos(REGFLUXBB_PATH);
$version = $plugin['version'];
// Default global parameters for RegisterFluxBB conf
// -------------------------------------------------
$defaultRegFluxBB = array('REGFLUXBB_VERSION' => $version, 'FLUXBB_PREFIX' => '', 'FLUXBB_ADMIN' => '', 'FLUXBB_GUEST' => '', 'FLUXBB_DEL_PT' => 'false', 'FLUXBB_CONFIRM' => 'false', 'FLUXBB_DETAIL' => 'false', 'FLUXBB_UAM_LINK' => 'false', 'FLUXBB_GROUP' => '');
// Create RegisterFluxBB conf if not already exists
// ------------------------------------------------
$query = '
SELECT param
FROM ' . CONFIG_TABLE . '
WHERE param = "Register_FluxBB"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0) {
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param, value, comment)
VALUES ("Register_FluxBB","' . pwg_db_real_escape_string(serialize($defaultRegFluxBB)) . '","Register_FluxBB parameters")
;';
pwg_query($q);
}
// Create relation table between FluxBB and Piwigo
// -----------------------------------------------
$q = '
CREATE TABLE IF NOT EXISTS ' . Register_FluxBB_ID_TABLE . ' (
id_user_pwg smallint(5) NOT NULL default "0",
id_user_FluxBB int(10) NOT NULL default "0",
PwdSynch varchar(3) default NULL,
PRIMARY KEY (id_user_pwg),
KEY id_user_pwg (id_user_pwg, id_user_FluxBB, PwdSynch)
)
;';
pwg_query($q);
}
示例11: plugin_install
function plugin_install($id, $version, &$errors)
{
global $conf;
// Set plugin parameters
$default = array();
$query = '
SELECT param
FROM ' . CONFIG_TABLE . '
WHERE param = "HistoryIPExcluder"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0) {
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
';
pwg_query($q);
}
// Set plugin config
$plugin = HIPE_infos(HIPE_PATH);
$version = $plugin['version'];
$default = array('Blacklist' => "0", 'Version' => $version);
$query = '
SELECT param
FROM ' . CONFIG_TABLE . '
WHERE param = "HistoryIPConfig"
;';
$count = pwg_db_num_rows(pwg_query($query));
if ($count == 0) {
$q = '
INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
VALUES ("HistoryIPConfig","' . pwg_db_real_escape_string(serialize($default)) . '","History IP Excluder options");
';
pwg_query($q);
}
}
示例12: Audit_PWG_PhpBB
Audit_PWG_PhpBB();
} else {
if (isset($_GET['action']) and $_GET['action'] == 'new_link' and isset($_GET['pwg_id']) and isset($_GET['bb_id'])) {
PhpBB_Linkuser($_GET['pwg_id'], $_GET['bb_id']);
Audit_PWG_PhpBB();
} else {
if (isset($_GET['action']) and $_GET['action'] == 'sync_user' and isset($_GET['username'])) {
$query = "\nSELECT id AS id_pwg, username, password, mail_address\nFROM " . USERS_TABLE . "\nWHERE BINARY username = BINARY '" . pwg_db_real_escape_string($_GET['username']) . "'\nLIMIT 1\n;";
$data = pwg_db_fetch_assoc(pwg_query($query));
if (!empty($data)) {
PhpBB_Updateuser($data['id_pwg'], stripslashes($data['username']), $data['password'], $data['mail_address']);
}
Audit_PWG_PhpBB();
} else {
if (isset($_GET['action']) and $_GET['action'] == 'add_user' and isset($_GET['username'])) {
$query = "\nSELECT id, username, password, mail_address\nFROM " . USERS_TABLE . "\nWHERE BINARY username = BINARY '" . pwg_db_real_escape_string($_GET['username']) . "'\nLIMIT 1\n;";
$data = pwg_db_fetch_assoc(pwg_query($query));
if (!empty($data)) {
PhpBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']);
}
Audit_PWG_PhpBB();
} else {
if (isset($_GET['action']) and $_GET['action'] == 'del_user' and isset($_GET['id'])) {
PhpBB_Deluser($_GET['id'], true);
Audit_PWG_PhpBB();
}
}
}
}
}
}
示例13: upgradeCM_240_250
function upgradeCM_240_250()
{
global $conf;
// Upgrading options - Changing config variables to assoc array
// ------------------------------------------------------------
// Upgrade $conf_CM options
$conf_CM = unserialize($conf['CommentsManager']);
$Newconf_CM = array('CMVersion' => $conf_CM[0], 'CM_No_Comment_Anonymous' => $conf_CM[1], 'CM_GROUPCOMM' => $conf_CM[2], 'CM_ALLOWCOMM_GROUP' => $conf_CM[3], 'CM_GROUPVALID1' => $conf_CM[4], 'CM_VALIDCOMM1_GROUP' => $conf_CM[5], 'CM_GROUPVALID2' => $conf_CM[6], 'CM_VALIDCOMM2_GROUP' => $conf_CM[7]);
// unset obsolete conf
// -------------------
for ($i = 0; $i <= 7; $i++) {
unset($conf_CM[$i]);
}
$update_conf = serialize($Newconf_CM);
conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
}
示例14: oauth_begin_register
/**
* register page
*/
function oauth_begin_register()
{
global $conf, $template, $hybridauth_conf, $page, $user;
if ($hybridauth_conf['enabled'] == 0) {
return;
}
// coming from identification page
if (pwg_get_session_var('oauth_new_user') != null) {
list($provider, $user_identifier) = pwg_get_session_var('oauth_new_user');
try {
if ($provider == 'Persona') {
$template->assign('OAUTH_USER', array('provider' => 'Persona', 'username' => $user_identifier, 'u_profile' => null, 'avatar' => null));
oauth_assign_template_vars();
$template->append('OAUTH', array('persona_email' => $user_identifier), true);
$conf['oauth']['include_common_template'] = true;
} else {
require_once OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php';
$hybridauth = new Hybrid_Auth($hybridauth_conf);
$adapter = $hybridauth->authenticate($provider);
$remote_user = $adapter->getUserProfile();
// security, check remote identifier
if ($remote_user->identifier != $user_identifier) {
pwg_unset_session_var('oauth_new_user');
throw new Exception('Hacking attempt!', 403);
}
$template->assign('OAUTH_USER', array('provider' => $hybridauth_conf['providers'][$provider]['name'], 'username' => $remote_user->displayName, 'u_profile' => $remote_user->profileURL, 'avatar' => $remote_user->photoURL));
}
$oauth_id = pwg_db_real_escape_string($provider . '---' . $user_identifier);
$page['infos'][] = l10n('Your registration is almost done, please complete the registration form.');
// register form submited
if (isset($_POST['submit'])) {
$user_id = register_user($_POST['login'], hash('sha1', $oauth_id . $conf['secret_key']), $_POST['mail_address'], true, $page['errors'], false);
if ($user_id !== false) {
pwg_unset_session_var('oauth_new_user');
// update oauth field
single_update(USER_INFOS_TABLE, array('oauth_id' => $oauth_id), array('user_id' => $user_id));
// log_user and redirect
log_user($user_id, false);
redirect('profile.php');
}
unset($_POST['submit']);
} else {
if (isset($_POST['login']) && $conf['oauth']['allow_merge_accounts']) {
if ($conf['insensitive_case_logon'] == true) {
$_POST['username'] = search_case_username($_POST['username']);
}
$user_id = get_userid($_POST['username']);
if ($user_id === false) {
$page['errors'][] = l10n('Invalid username or email');
} else {
if ($user_id == $conf['webmaster_id']) {
$page['errors'][] = l10n('For security reason, the main webmaster account can\'t be merged with a remote account, but you can use another webmaster account.');
} else {
if (pwg_login(false, $_POST['username'], $_POST['password'], false)) {
// update oauth field
single_update(USER_INFOS_TABLE, array('oauth_id' => $oauth_id), array('user_id' => $user['id']));
pwg_unset_session_var('oauth_new_user');
redirect('profile.php');
} else {
$page['errors'][] = l10n('Invalid password!');
}
}
}
}
}
// overwrite fields with remote datas
if ($provider == 'Persona') {
$_POST['login'] = '';
$_POST['mail_address'] = $user_identifier;
} else {
$_POST['login'] = $remote_user->displayName;
$_POST['mail_address'] = $remote_user->email;
}
// template
$template->assign('OAUTH_PATH', OAUTH_PATH);
if ($conf['oauth']['allow_merge_accounts']) {
$template->assign('OAUTH_LOGIN_IN_REGISTER', true);
$template->set_prefilter('register', 'oauth_add_login_in_register');
} else {
$template->set_prefilter('register', 'oauth_add_profile_prefilter');
$template->set_prefilter('register', 'oauth_remove_password_fields_prefilter');
}
} catch (Exception $e) {
$page['errors'][] = l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>', $e->getCode());
}
} else {
if ($conf['oauth']['display_register']) {
oauth_assign_template_vars(get_gallery_home_url());
$template->set_prefilter('register', 'oauth_add_buttons_prefilter');
}
}
}
示例15: load_language
<?php
// Need upgrade?
global $conf;
include PHPWG_THEMES_PATH . 'elegant/admin/upgrade.inc.php';
load_language('theme.lang', PHPWG_THEMES_PATH . 'elegant/');
$config_send = array();
if (isset($_POST['submit_elegant'])) {
$config_send['p_main_menu'] = (isset($_POST['p_main_menu']) and !empty($_POST['p_main_menu'])) ? $_POST['p_main_menu'] : 'on';
$config_send['p_pict_descr'] = (isset($_POST['p_pict_descr']) and !empty($_POST['p_pict_descr'])) ? $_POST['p_pict_descr'] : 'on';
$config_send['p_pict_comment'] = (isset($_POST['p_pict_comment']) and !empty($_POST['p_pict_comment'])) ? $_POST['p_pict_comment'] : 'off';
$conf['elegant'] = serialize($config_send);
conf_update_param('elegant', pwg_db_real_escape_string($conf['elegant']));
array_push($page['infos'], l10n('Information data registered in database'));
}
$template->set_filenames(array('theme_admin_content' => dirname(__FILE__) . '/admin.tpl'));
$template->assign('options', unserialize($conf['elegant']));
$template->assign_var_from_handle('ADMIN_CONTENT', 'theme_admin_content');