本文整理汇总了PHP中pwg_db_fetch_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP pwg_db_fetch_assoc函数的具体用法?PHP pwg_db_fetch_assoc怎么用?PHP pwg_db_fetch_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwg_db_fetch_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: vjs_begin_delete_elements
function vjs_begin_delete_elements($ids)
{
if (count($ids) == 0) {
return 0;
}
$vjs_extensions = array('ogg', 'ogv', 'mp4', 'm4v', 'webm', 'webmv');
$files_ext = array_merge(array(), $vjs_extensions, array_map('strtoupper', $vjs_extensions));
// Find details base on ID and if supported video files
$query = '
SELECT
id,
path,
representative_ext
FROM ' . IMAGES_TABLE . '
WHERE id IN (' . implode(',', $ids) . ') AND ' . SQL_VIDEOS . '
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
if (url_is_remote($row['path'])) {
continue;
}
$files = array();
$files[] = get_element_path($row);
$ok = true;
if (!isset($conf['never_delete_originals'])) {
foreach ($files as $path) {
// Don't delete the actual video or representative
// It is done by PWG core
// Delete any other video source format
$file_wo_ext = pathinfo($path);
$file_dir = dirname($path);
foreach ($files_ext as $file_ext) {
$path_ext = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "." . $file_ext;
if (is_file($path_ext) and !unlink($path_ext)) {
$ok = false;
trigger_error('"' . $path_ext . '" cannot be removed', E_USER_WARNING);
break;
}
}
// Delete video thumbnails
$filematch = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "-th_*";
$matches = glob($filematch);
if (is_array($matches)) {
foreach ($matches as $filename) {
if (is_file($filename) and !unlink($filename)) {
$ok = false;
trigger_error('"' . $filename . '" cannot be removed', E_USER_WARNING);
break;
}
}
}
// End videos thumbnails
}
// End for each files
}
// End IF
}
// End While
}
示例3: get_summary
function get_summary($year = null, $month = null, $day = null)
{
$query = '
SELECT
year,
month,
day,
hour,
nb_pages
FROM ' . HISTORY_SUMMARY_TABLE;
if (isset($day)) {
$query .= '
WHERE year = ' . $year . '
AND month = ' . $month . '
AND day = ' . $day . '
AND hour IS NOT NULL
ORDER BY
year ASC,
month ASC,
day ASC,
hour ASC
;';
} elseif (isset($month)) {
$query .= '
WHERE year = ' . $year . '
AND month = ' . $month . '
AND day IS NOT NULL
AND hour IS NULL
ORDER BY
year ASC,
month ASC,
day ASC
;';
} elseif (isset($year)) {
$query .= '
WHERE year = ' . $year . '
AND month IS NOT NULL
AND day IS NULL
ORDER BY
year ASC,
month ASC
;';
} else {
$query .= '
WHERE year IS NOT NULL
AND month IS NULL
ORDER BY
year ASC
;';
}
$result = pwg_query($query);
$output = array();
while ($row = pwg_db_fetch_assoc($result)) {
$output[] = $row;
}
return $output;
}
示例4: get_site_url
function get_site_url($category_id)
{
global $page;
$query = '
SELECT galleries_url
FROM ' . SITES_TABLE . ' AS s,' . CATEGORIES_TABLE . ' AS c
WHERE s.id = c.site_id
AND c.id = ' . $category_id . '
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
return $row['galleries_url'];
}
示例5: NBMS_Load_Profile
function NBMS_Load_Profile()
{
global $conf, $user, $template, $lang;
$query = '
SELECT enabled
FROM ' . USER_MAIL_NOTIFICATION_TABLE . '
WHERE user_id = \'' . $user['id'] . '\'
;';
$data = pwg_db_fetch_assoc(pwg_query($query));
$values = $data['enabled'];
if (is_null($values)) {
$values = 'false';
}
$template->assign('radio_options', array('true' => l10n('Yes'), 'false' => l10n('No')));
$template->assign(array('NBMS' => $values));
$template->set_prefilter('profile_content', 'NBMS_prefilter');
}
示例6: global_version_update
function global_version_update()
{
global $conf;
// Get current plugin version
$plugin = HIPE_infos(HIPE_PATH);
$version = $plugin['version'];
// Update plugin version
$query = '
SELECT value
FROM ' . CONFIG_TABLE . '
WHERE param = "HistoryIPConfig"
;';
$result = pwg_query($query);
$conf_HIPE = pwg_db_fetch_assoc($result);
$Newconf_HIPE = unserialize($conf_HIPE['value']);
$Newconf_HIPE['Version'] = $version;
conf_update_param('HistoryIPConfig', pwg_db_real_escape_string(serialize($Newconf_HIPE)));
}
示例7: query2array
/**
* Builds an data array from a SQL query.
* Depending on $key_name and $value_name it can return :
*
* - an array of arrays of all fields (key=null, value=null)
* array(
* array('id'=>1, 'name'=>'DSC8956', ...),
* array('id'=>2, 'name'=>'DSC8957', ...),
* ...
* )
*
* - an array of a single field (key=null, value='...')
* array('DSC8956', 'DSC8957', ...)
*
* - an associative array of array of all fields (key='...', value=null)
* array(
* 'DSC8956' => array('id'=>1, 'name'=>'DSC8956', ...),
* 'DSC8957' => array('id'=>2, 'name'=>'DSC8957', ...),
* ...
* )
*
* - an associative array of a single field (key='...', value='...')
* array(
* 'DSC8956' => 1,
* 'DSC8957' => 2,
* ...
* )
*
* @since 2.6
*
* @param string $query
* @param string $key_name
* @param string $value_name
* @return array
*/
function query2array($query, $key_name = null, $value_name = null)
{
$result = pwg_query($query);
$data = array();
if (isset($key_name)) {
if (isset($value_name)) {
while ($row = pwg_db_fetch_assoc($result)) {
$data[$row[$key_name]] = $row[$value_name];
}
} else {
while ($row = pwg_db_fetch_assoc($result)) {
$data[$row[$key_name]] = $row;
}
}
} else {
if (isset($value_name)) {
while ($row = pwg_db_fetch_assoc($result)) {
$data[] = $row[$value_name];
}
} else {
while ($row = pwg_db_fetch_assoc($result)) {
$data[] = $row;
}
}
}
return $data;
}
示例8: qsearch_get_tags
function qsearch_get_tags(QExpression $expr, QResults $qsr)
{
$token_tag_ids = $qsr->tag_iids = array_fill(0, count($expr->stokens), array());
$all_tags = array();
for ($i = 0; $i < count($expr->stokens); $i++) {
$token = $expr->stokens[$i];
if (isset($token->scope) && 'tag' != $token->scope->id) {
continue;
}
if (empty($token->term)) {
continue;
}
$clauses = qsearch_get_text_token_search_sql($token, array('name'));
$query = 'SELECT * FROM ' . TAGS_TABLE . '
WHERE (' . implode("\n OR ", $clauses) . ')';
$result = pwg_query($query);
while ($tag = pwg_db_fetch_assoc($result)) {
$token_tag_ids[$i][] = $tag['id'];
$all_tags[$tag['id']] = $tag;
}
}
// check adjacent short words
for ($i = 0; $i < count($expr->stokens) - 1; $i++) {
if ((strlen($expr->stokens[$i]->term) <= 3 || strlen($expr->stokens[$i + 1]->term) <= 3) && ($expr->stoken_modifiers[$i] & (QST_QUOTED | QST_WILDCARD)) == 0 && ($expr->stoken_modifiers[$i + 1] & (QST_BREAK | QST_QUOTED | QST_WILDCARD)) == 0) {
$common = array_intersect($token_tag_ids[$i], $token_tag_ids[$i + 1]);
if (count($common)) {
$token_tag_ids[$i] = $token_tag_ids[$i + 1] = $common;
}
}
}
// get images
$positive_ids = $not_ids = array();
for ($i = 0; $i < count($expr->stokens); $i++) {
$tag_ids = $token_tag_ids[$i];
$token = $expr->stokens[$i];
if (!empty($tag_ids)) {
$query = '
SELECT image_id FROM ' . IMAGE_TAG_TABLE . '
WHERE tag_id IN (' . implode(',', $tag_ids) . ')
GROUP BY image_id';
$qsr->tag_iids[$i] = query2array($query, null, 'image_id');
if ($expr->stoken_modifiers[$i] & QST_NOT) {
$not_ids = array_merge($not_ids, $tag_ids);
} else {
if (strlen($token->term) > 2 || count($expr->stokens) == 1 || isset($token->scope) || $token->modifier & (QST_WILDCARD | QST_QUOTED)) {
// add tag ids to list only if the word is not too short (such as de / la /les ...)
$positive_ids = array_merge($positive_ids, $tag_ids);
}
}
} elseif (isset($token->scope) && 'tag' == $token->scope->id && strlen($token->term) == 0) {
if ($token->modifier & QST_WILDCARD) {
// eg. 'tag:*' returns all tagged images
$qsr->tag_iids[$i] = query2array('SELECT DISTINCT image_id FROM ' . IMAGE_TAG_TABLE, null, 'image_id');
} else {
// eg. 'tag:' returns all untagged images
$qsr->tag_iids[$i] = query2array('SELECT id FROM ' . IMAGES_TABLE . ' LEFT JOIN ' . IMAGE_TAG_TABLE . ' ON id=image_id WHERE image_id IS NULL', null, 'id');
}
}
}
$all_tags = array_intersect_key($all_tags, array_flip(array_diff($positive_ids, $not_ids)));
usort($all_tags, 'tag_alpha_compare');
foreach ($all_tags as &$tag) {
$tag['name'] = trigger_change('render_tag_name', $tag['name'], $tag);
}
$qsr->all_tags = $all_tags;
$qsr->tag_ids = $token_tag_ids;
}
示例9: Stereo_tabsheet
function Stereo_tabsheet($tabs, $context)
{
global $prefixeTable;
if ($context != 'photo') {
return $tabs;
}
load_language('plugin.lang', STEREO_PATH);
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
$id = $_GET['image_id'];
$query = '
SELECT file from ' . $prefixeTable . 'images
WHERE id = ' . $id;
$result = pwg_db_fetch_assoc(pwg_query($query));
if ($result && preg_match('/.*mpo$/i', $result['file'])) {
$tabs['stereo'] = array('caption' => l10n('STEREO_ADJUSTMENT'), 'url' => Stereo_get_admin_url($id));
}
return $tabs;
}
示例10: ws_categories_move
/**
* API method
* Moves a category
* @param mixed[] $params
* @option string|int[] category_id
* @option int parent
* @option string pwg_token
*/
function ws_categories_move($params, &$service)
{
global $page;
if (get_pwg_token() != $params['pwg_token']) {
return new PwgError(403, 'Invalid security token');
}
if (!is_array($params['category_id'])) {
$params['category_id'] = preg_split('/[\\s,;\\|]/', $params['category_id'], -1, PREG_SPLIT_NO_EMPTY);
}
$params['category_id'] = array_map('intval', $params['category_id']);
$category_ids = array();
foreach ($params['category_id'] as $category_id) {
if ($category_id > 0) {
$category_ids[] = $category_id;
}
}
if (count($category_ids) == 0) {
return new PwgError(403, 'Invalid category_id input parameter, no category to move');
}
// we can't move physical categories
$categories_in_db = array();
$query = '
SELECT id, name, dir
FROM ' . CATEGORIES_TABLE . '
WHERE id IN (' . implode(',', $category_ids) . ')
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
$categories_in_db[$row['id']] = $row;
// we break on error at first physical category detected
if (!empty($row['dir'])) {
$row['name'] = strip_tags(trigger_change('render_category_name', $row['name'], 'ws_categories_move'));
return new PwgError(403, sprintf('Category %s (%u) is not a virtual category, you cannot move it', $row['name'], $row['id']));
}
}
if (count($categories_in_db) != count($category_ids)) {
$unknown_category_ids = array_diff($category_ids, array_keys($categories_in_db));
return new PwgError(403, sprintf('Category %u does not exist', $unknown_category_ids[0]));
}
// does this parent exists? This check should be made in the
// move_categories function, not here
// 0 as parent means "move categories at gallery root"
if (0 != $params['parent']) {
$subcat_ids = get_subcat_ids(array($params['parent']));
if (count($subcat_ids) == 0) {
return new PwgError(403, 'Unknown parent category id');
}
}
$page['infos'] = array();
$page['errors'] = array();
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
move_categories($category_ids, $params['parent']);
invalidate_user_cache();
if (count($page['errors']) != 0) {
return new PwgError(403, implode('; ', $page['errors']));
}
}
示例11: die
// FIXME: Duplicated boilerplate - could be avoided with a hook in the else
// clause at the bottom of admin/photo.php letting you set the right include file
if (!isset($_GET['image_id']) or !isset($_GET['section'])) {
die('Invalid data!');
}
global $template, $page, $prefixeTable;
load_language('plugin.lang', STEREO_PATH);
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
$id = $_GET['image_id'];
$query = '
SELECT *
FROM ' . $prefixeTable . 'images i
LEFT JOIN ' . $prefixeTable . 'stereo s
ON i.id = s.media_id
WHERE i.id = ' . $id;
$picture = pwg_db_fetch_assoc(pwg_query($query));
if (isset($_POST['submit'])) {
check_pwg_token();
$offsetX = trim($_POST['offsetX']);
$offsetY = trim($_POST['offsetY']);
if (strlen($offsetX) === 0 || strlen($offsetY) === 0 || !is_numeric($offsetX) || !is_numeric($offsetY)) {
$page['errors'][] = 'Invalid offset value';
}
if (count($page['errors']) === 0) {
$stereoTable = $prefixeTable . 'stereo';
if (isset($picture['x'])) {
$query = "UPDATE {$stereoTable}\n\t\t\t\tSET x={$offsetX}, y={$offsetY}\n\t\t\t\tWHERE media_id = {$id};";
} else {
$picture['x'] = $offsetX;
$picture['y'] = $offsetY;
$query = "INSERT INTO {$stereoTable} (media_id, x, y)\n\t\t\t\tVALUES ({$id}, {$offsetX}, {$offsetY})";
示例12: get_common_tags
/**
* Return a list of tags corresponding to given items.
*
* @param int[] $items
* @param int $max_tags
* @param int[] $excluded_tag_ids
* @return array [id, name, counter, url_name]
*/
function get_common_tags($items, $max_tags, $excluded_tag_ids = array())
{
if (empty($items)) {
return array();
}
$query = '
SELECT t.*, count(*) AS counter
FROM ' . IMAGE_TAG_TABLE . '
INNER JOIN ' . TAGS_TABLE . ' t ON tag_id = id
WHERE image_id IN (' . implode(',', $items) . ')';
if (!empty($excluded_tag_ids)) {
$query .= '
AND tag_id NOT IN (' . implode(',', $excluded_tag_ids) . ')';
}
$query .= '
GROUP BY t.id
ORDER BY ';
if ($max_tags > 0) {
// TODO : why ORDER field is in the if ?
$query .= 'counter DESC
LIMIT ' . $max_tags;
} else {
$query .= 'NULL';
}
$result = pwg_query($query);
$tags = array();
while ($row = pwg_db_fetch_assoc($result)) {
$row['name'] = trigger_change('render_tag_name', $row['name'], $row);
$tags[] = $row;
}
usort($tags, 'tag_alpha_compare');
return $tags;
}
示例13: ws_permissions_getList
/**
* API method
* Returns permissions
* @param mixed[] $params
* @option int[] cat_id (optional)
* @option int[] group_id (optional)
* @option int[] user_id (optional)
*/
function ws_permissions_getList($params, &$service)
{
$my_params = array_intersect(array_keys($params), array('cat_id', 'group_id', 'user_id'));
if (count($my_params) > 1) {
return new PwgError(WS_ERR_INVALID_PARAM, 'Too many parameters, provide cat_id OR user_id OR group_id');
}
$cat_filter = '';
if (!empty($params['cat_id'])) {
$cat_filter = 'WHERE cat_id IN(' . implode(',', $params['cat_id']) . ')';
}
$perms = array();
// direct users
$query = '
SELECT user_id, cat_id
FROM ' . USER_ACCESS_TABLE . '
' . $cat_filter . '
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
if (!isset($perms[$row['cat_id']])) {
$perms[$row['cat_id']]['id'] = intval($row['cat_id']);
}
$perms[$row['cat_id']]['users'][] = intval($row['user_id']);
}
// indirect users
$query = '
SELECT ug.user_id, ga.cat_id
FROM ' . USER_GROUP_TABLE . ' AS ug
INNER JOIN ' . GROUP_ACCESS_TABLE . ' AS ga
ON ug.group_id = ga.group_id
' . $cat_filter . '
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
if (!isset($perms[$row['cat_id']])) {
$perms[$row['cat_id']]['id'] = intval($row['cat_id']);
}
$perms[$row['cat_id']]['users_indirect'][] = intval($row['user_id']);
}
// groups
$query = '
SELECT group_id, cat_id
FROM ' . GROUP_ACCESS_TABLE . '
' . $cat_filter . '
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
if (!isset($perms[$row['cat_id']])) {
$perms[$row['cat_id']]['id'] = intval($row['cat_id']);
}
$perms[$row['cat_id']]['groups'][] = intval($row['group_id']);
}
// filter by group and user
foreach ($perms as $cat_id => &$cat) {
if (isset($filters['group_id'])) {
if (empty($cat['groups']) or count(array_intersect($cat['groups'], $params['group_id'])) == 0) {
unset($perms[$cat_id]);
continue;
}
}
if (isset($filters['user_id'])) {
if ((empty($cat['users_indirect']) or count(array_intersect($cat['users_indirect'], $params['user_id'])) == 0) and (empty($cat['users']) or count(array_intersect($cat['users'], $params['user_id'])) == 0)) {
unset($perms[$cat_id]);
continue;
}
}
$cat['groups'] = !empty($cat['groups']) ? array_values(array_unique($cat['groups'])) : array();
$cat['users'] = !empty($cat['users']) ? array_values(array_unique($cat['users'])) : array();
$cat['users_indirect'] = !empty($cat['users_indirect']) ? array_values(array_unique($cat['users_indirect'])) : array();
}
unset($cat);
return array('categories' => new PwgNamedArray(array_values($perms), 'category', array('id')));
}
示例14: get_computed_categories
/**
* Get computed array of categories, that means cache data of all categories
* available for the current user (count_categories, count_images, etc.).
*
* @param array &$userdata
* @param int $filter_days number of recent days to filter on or null
* @return array
*/
function get_computed_categories(&$userdata, $filter_days = null)
{
$query = 'SELECT c.id AS cat_id, id_uppercat';
$query .= ', global_rank';
// Count by date_available to avoid count null
$query .= ',
MAX(date_available) AS date_last, COUNT(date_available) AS nb_images
FROM ' . CATEGORIES_TABLE . ' as c
LEFT JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON ic.category_id = c.id
LEFT JOIN ' . IMAGES_TABLE . ' AS i
ON ic.image_id = i.id
AND i.level<=' . $userdata['level'];
if (isset($filter_days)) {
$query .= ' AND i.date_available > ' . pwg_db_get_recent_period_expression($filter_days);
}
if (!empty($userdata['forbidden_categories'])) {
$query .= '
WHERE c.id NOT IN (' . $userdata['forbidden_categories'] . ')';
}
$query .= '
GROUP BY c.id';
$result = pwg_query($query);
$userdata['last_photo_date'] = null;
$cats = array();
while ($row = pwg_db_fetch_assoc($result)) {
$row['user_id'] = $userdata['id'];
$row['nb_categories'] = 0;
$row['count_categories'] = 0;
$row['count_images'] = (int) $row['nb_images'];
$row['max_date_last'] = $row['date_last'];
if ($row['date_last'] > $userdata['last_photo_date']) {
$userdata['last_photo_date'] = $row['date_last'];
}
$cats[$row['cat_id']] = $row;
}
// it is important to logically sort the albums because some operations
// (like removal) rely on this logical order. Child album doesn't always
// have a bigger id than its parent (if it was moved afterwards).
uasort($cats, 'global_rank_compare');
foreach ($cats as $cat) {
if (!isset($cat['id_uppercat'])) {
continue;
}
// Piwigo before 2.5.3 may have generated inconsistent permissions, ie
// private album A1/A2 permitted to user U1 but private album A1 not
// permitted to U1.
//
// TODO 2.7: add an upgrade script to repair permissions and remove this
// test
if (!isset($cats[$cat['id_uppercat']])) {
continue;
}
$parent =& $cats[$cat['id_uppercat']];
$parent['nb_categories']++;
do {
$parent['count_images'] += $cat['nb_images'];
$parent['count_categories']++;
if (empty($parent['max_date_last']) or $parent['max_date_last'] < $cat['date_last']) {
$parent['max_date_last'] = $cat['date_last'];
}
if (!isset($parent['id_uppercat'])) {
break;
}
$parent =& $cats[$parent['id_uppercat']];
} while (true);
unset($parent);
}
if (isset($filter_days)) {
foreach ($cats as $category) {
if (empty($category['max_date_last'])) {
remove_computed_category($cats, $category);
}
}
}
return $cats;
}
示例15: die
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH")) {
die("Hacking attempt!");
}
// +-----------------------------------------------------------------------+
// | Basic checks |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
$admin_album_base_url = get_root_url() . 'admin.php?page=album-' . $_GET['cat_id'];
$query = '
SELECT *
FROM ' . CATEGORIES_TABLE . '
WHERE id = ' . $_GET['cat_id'] . '
;';
$category = pwg_db_fetch_assoc(pwg_query($query));
if (!isset($category['id'])) {
die("unknown album");
}
// +-----------------------------------------------------------------------+
// | Tabs |
// +-----------------------------------------------------------------------+
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$page['tab'] = 'properties';
if (isset($_GET['tab'])) {
$page['tab'] = $_GET['tab'];
}
$tabsheet = new tabsheet();
$tabsheet->set_id('album');
$tabsheet->select($page['tab']);
$tabsheet->assign();