本文整理汇总了PHP中pwg_db_fetch_row函数的典型用法代码示例。如果您正苦于以下问题:PHP pwg_db_fetch_row函数的具体用法?PHP pwg_db_fetch_row怎么用?PHP pwg_db_fetch_row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwg_db_fetch_row函数的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: PhpBB_Linkuser
function PhpBB_Linkuser($pwg_id, $bb_id)
{
$query = "\nSELECT pwg.id as pwg_id, bb.user_id as bb_id\nFROM " . USERS_TABLE . " pwg, " . PhpBB_USERS_TABLE . " bb\nWHERE pwg.id = " . $pwg_id . "\nAND bb.user_id = " . $bb_id . "\nAND pwg.username = bb.username\n;";
$data = pwg_db_fetch_row(pwg_query($query));
if (!empty($data)) {
$subquery = "\nDELETE FROM " . Register_PhpBB_ID_TABLE . "\nWHERE id_user_pwg = '" . $pwg_id . "'\nOR id_user_PhpBB = '" . $bb_id . "'\n;";
$subresult = pwg_query($subquery);
$subquery = "\nINSERT INTO " . Register_PhpBB_ID_TABLE . "\n (id_user_pwg, id_user_PhpBB)\nVALUES (" . $pwg_id . ", " . $bb_id . ")\n;";
$subresult = pwg_query($subquery);
}
}
示例3: get_search_array
/**
* Returns search rules stored into a serialized array in "search"
* table. Each search rules set is numericaly identified.
*
* @param int $search_id
* @return array
*/
function get_search_array($search_id)
{
if (!is_numeric($search_id)) {
die('Search id must be an integer');
}
$query = '
SELECT rules
FROM ' . SEARCH_TABLE . '
WHERE id = ' . $search_id . '
;';
list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
return unserialize($serialized_rules);
}
示例4: process_password_request
/**
* checks the validity of input parameters, fills $page['errors'] and
* $page['infos'] and send an email with confirmation link
*
* @return bool (true if email was sent, false otherwise)
*/
function process_password_request()
{
global $page, $conf;
if (empty($_POST['username_or_email'])) {
$page['errors'][] = l10n('Invalid username or email');
return false;
}
$user_id = get_userid_by_email($_POST['username_or_email']);
if (!is_numeric($user_id)) {
$user_id = get_userid($_POST['username_or_email']);
}
if (!is_numeric($user_id)) {
$page['errors'][] = l10n('Invalid username or email');
return false;
}
$userdata = getuserdata($user_id, false);
// password request is not possible for guest/generic users
$status = $userdata['status'];
if (is_a_guest($status) or is_generic($status)) {
$page['errors'][] = l10n('Password reset is not allowed for this user');
return false;
}
if (empty($userdata['email'])) {
$page['errors'][] = l10n('User "%s" has no email address, password reset is not possible', $userdata['username']);
return false;
}
$activation_key = generate_key(20);
list($expire) = pwg_db_fetch_row(pwg_query('SELECT ADDDATE(NOW(), INTERVAL 1 HOUR)'));
single_update(USER_INFOS_TABLE, array('activation_key' => pwg_password_hash($activation_key), 'activation_key_expire' => $expire), array('user_id' => $user_id));
$userdata['activation_key'] = $activation_key;
set_make_full_url();
$message = l10n('Someone requested that the password be reset for the following user account:') . "\r\n\r\n";
$message .= l10n('Username "%s" on gallery %s', $userdata['username'], get_gallery_home_url());
$message .= "\r\n\r\n";
$message .= l10n('To reset your password, visit the following address:') . "\r\n";
$message .= get_gallery_home_url() . '/password.php?key=' . $activation_key . '-' . urlencode($userdata['email']);
$message .= "\r\n\r\n";
$message .= l10n('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n";
unset_make_full_url();
$message = trigger_change('render_lost_password_mail_content', $message);
$email_params = array('subject' => '[' . $conf['gallery_title'] . '] ' . l10n('Password Reset'), 'content' => $message, 'email_format' => 'text/plain');
if (pwg_mail($userdata['email'], $email_params)) {
$page['infos'][] = l10n('Check your email for the confirmation link');
return true;
} else {
$page['errors'][] = l10n('Error sending email');
return false;
}
}
示例5: ws_extref_categories_set
function ws_extref_categories_set($params, &$service)
{
// does the category really exist?
$query = '
SELECT COUNT(*)
FROM ' . CATEGORIES_TABLE . '
WHERE id = ' . $params['category_id'] . '
;';
list($count) = pwg_db_fetch_row(pwg_query($query));
if ($count == 0) {
return new PwgError(404, 'category_id not found');
}
single_update(CATEGORIES_TABLE, array('external_reference' => $params['external_reference']), array('id' => $params['category_id']));
return true;
}
示例6: get_columns_of
/**
* list all columns of each given table
*
* @return array of array
*/
function get_columns_of($tables)
{
$columns_of = array();
foreach ($tables as $table) {
$query = '
DESC ' . $table . '
;';
$result = pwg_query($query);
$columns_of[$table] = array();
while ($row = pwg_db_fetch_row($result)) {
$columns_of[$table][] = $row[0];
}
}
return $columns_of;
}
示例7: find_available_feed_id
/**
* search an available feed_id
*
* @return string feed identifier
*/
function find_available_feed_id()
{
while (true) {
$key = generate_key(50);
$query = '
SELECT COUNT(*)
FROM ' . USER_FEED_TABLE . '
WHERE id = \'' . $key . '\'
;';
list($count) = pwg_db_fetch_row(pwg_query($query));
if (0 == $count) {
return $key;
}
}
}
示例8: get_oauth_id
function get_oauth_id($user_id)
{
$query = '
SELECT oauth_id FROM ' . USER_INFOS_TABLE . '
WHERE user_id = ' . $user_id . '
AND oauth_id != ""
;';
$result = pwg_query($query);
if (!pwg_db_num_rows($result)) {
return null;
} else {
list($oauth_id) = pwg_db_fetch_row($result);
return $oauth_id;
}
}
示例9: delete_cat_permalink
/** deletes the permalink associated with a category
* returns true on success
* @param int cat_id the target category id
* @param boolean save if true, the current category-permalink association
* is saved in the old permalinks table in case external links hit it
*/
function delete_cat_permalink($cat_id, $save)
{
global $page, $cache;
$query = '
SELECT permalink
FROM ' . CATEGORIES_TABLE . '
WHERE id=\'' . $cat_id . '\'
;';
$result = pwg_query($query);
if (pwg_db_num_rows($result)) {
list($permalink) = pwg_db_fetch_row($result);
}
if (!isset($permalink)) {
// no permalink; nothing to do
return true;
}
if ($save) {
$old_cat_id = get_cat_id_from_old_permalink($permalink);
if (isset($old_cat_id) and $old_cat_id != $cat_id) {
$page['errors'][] = sprintf(l10n('Permalink %s has been previously used by album %s. Delete from the permalink history first'), $permalink, $old_cat_id);
return false;
}
}
$query = '
UPDATE ' . CATEGORIES_TABLE . '
SET permalink=NULL
WHERE id=' . $cat_id . '
LIMIT 1';
pwg_query($query);
unset($cache['cat_names']);
//force regeneration
if ($save) {
if (isset($old_cat_id)) {
$query = '
UPDATE ' . OLD_PERMALINKS_TABLE . '
SET date_deleted=NOW()
WHERE cat_id=' . $cat_id . ' AND permalink=\'' . $permalink . '\'';
} else {
$query = '
INSERT INTO ' . OLD_PERMALINKS_TABLE . '
(permalink, cat_id, date_deleted)
VALUES
( \'' . $permalink . '\',' . $cat_id . ',NOW() )';
}
pwg_query($query);
}
return true;
}
示例10: Register_PhpBB_InitPage
function Register_PhpBB_InitPage()
{
global $conf, $user;
include_once REGPHPBB_PATH . 'include/functions.inc.php';
if (isset($_POST['validate']) and !is_admin()) {
if (!empty($_POST['use_new_pwd'])) {
$query = '
SELECT ' . $conf['user_fields']['username'] . ' AS username
FROM ' . USERS_TABLE . '
WHERE ' . $conf['user_fields']['id'] . ' = \'' . $user['id'] . '\'
;';
list($username) = pwg_db_fetch_row(pwg_query($query));
PhpBB_Updateuser($user['id'], stripslashes($username), md5($_POST['use_new_pwd']), $_POST['mail_address']);
}
}
}
示例11: find_available_check_key
function find_available_check_key()
{
while (true) {
$key = generate_key(16);
$query = '
select
count(*)
from
' . USER_MAIL_NOTIFICATION_TABLE . '
where
check_key = \'' . $key . '\';';
list($count) = pwg_db_fetch_row(pwg_query($query));
if ($count == 0) {
return $key;
}
}
}
示例12: oauth_try_log_user
/**
* interrupt normal login if corresponding to an oauth user
*/
function oauth_try_log_user($success, $username)
{
global $conf, $redirect_to;
$query = '
SELECT oauth_id
FROM ' . USER_INFOS_TABLE . ' AS i
INNER JOIN ' . USERS_TABLE . ' AS u
ON i.user_id = u.' . $conf['user_fields']['id'] . '
WHERE ' . $conf['user_fields']['username'] . ' = "' . pwg_db_real_escape_string($username) . '"
AND oauth_id != ""
;';
$result = pwg_query($query);
if (pwg_db_num_rows($result)) {
list($oauth_id) = pwg_db_fetch_row($result);
list($provider) = explode('---', $oauth_id, 2);
$_SESSION['page_errors'][] = l10n('You registered with a %s account, please sign in with the same account.', $provider);
$redirect_to = get_root_url() . 'identification.php';
// variable used by identification.php
return true;
}
return false;
}
示例13: pfemail_admin_menu
function pfemail_admin_menu($menu)
{
global $page;
$query = '
SELECT
COUNT(*)
FROM ' . PFEMAIL_PENDINGS_TABLE . '
JOIN ' . IMAGES_TABLE . ' ON image_id = id
WHERE state = \'moderation_pending\'
;';
$result = pwg_query($query);
list($page['pfemail_nb_pendings']) = pwg_db_fetch_row($result);
$name = 'Photo from Email';
if ($page['pfemail_nb_pendings'] > 0) {
$style = 'background-color:#666;';
$style .= 'color:white;';
$style .= 'padding:1px 5px;';
$style .= 'border-radius:10px;';
$style .= 'margin-left:5px;';
$name .= '<span style="' . $style . '">' . $page['pfemail_nb_pendings'] . '</span>';
}
array_push($menu, array('NAME' => $name, 'URL' => get_root_url() . 'admin.php?page=plugin-photo_from_email'));
return $menu;
}
示例14: ws_session_getStatus
/**
* API method
* Returns info about the current user
* @param mixed[] $params
*/
function ws_session_getStatus($params, &$service)
{
global $user, $conf;
$res['username'] = is_a_guest() ? 'guest' : stripslashes($user['username']);
foreach (array('status', 'theme', 'language') as $k) {
$res[$k] = $user[$k];
}
$res['pwg_token'] = get_pwg_token();
$res['charset'] = get_pwg_charset();
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
$res['current_datetime'] = $dbnow;
$res['version'] = PHPWG_VERSION;
if (is_admin()) {
$res['upload_file_types'] = implode(',', array_unique(array_map('strtolower', $conf['upload_form_all_types'] ? $conf['file_ext'] : $conf['picture_ext'])));
$res['upload_form_chunk_size'] = $conf['upload_form_chunk_size'];
}
return $res;
}
示例15: mass_inserts
}
mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $usr_grp);
$page['infos'][] = l10n('group "%s" added', $_POST['duplicate_' . $group . '']);
}
}
// +
// | toggle_default
// +
if ($action == "toggle_default") {
foreach ($groups as $group) {
$query = '
SELECT name, is_default
FROM ' . GROUPS_TABLE . '
WHERE id = ' . $group . '
;';
list($groupname, $is_default) = pwg_db_fetch_row(pwg_query($query));
// update of the group
$query = '
UPDATE ' . GROUPS_TABLE . '
SET is_default = \'' . boolean_to_string(!get_boolean($is_default)) . '\'
WHERE id = ' . $group . '
;';
pwg_query($query);
$page['infos'][] = l10n('group "%s" updated', $groupname);
}
}
invalidate_user_cache();
}
// +-----------------------------------------------------------------------+
// | template init |
// +-----------------------------------------------------------------------+