• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pwg_db_fetch_assoc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中pwg_db_fetch_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP pwg_db_fetch_assoc函数的具体用法?PHP pwg_db_fetch_assoc怎么用?PHP pwg_db_fetch_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pwg_db_fetch_assoc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:33,代码来源:functions_user.inc.php


示例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
}
开发者ID:naryoss,项目名称:piwigo-videojs,代码行数:59,代码来源:admin_boot.php


示例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;
}
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:57,代码来源:stats.php


示例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'];
}
开发者ID:HassenLin,项目名称:piwigo_utf8filename,代码行数:12,代码来源:cat_modify.php


示例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');
}
开发者ID:Eric-Piwigo,项目名称:NBM_Subscriber,代码行数:17,代码来源:main.inc.php


示例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)));
}
开发者ID:Eric-Piwigo,项目名称:HistoryIPExcluder,代码行数:18,代码来源:dbupgrade.inc.php


示例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;
}
开发者ID:squidjam,项目名称:Piwigo,代码行数:62,代码来源:functions_mysql.inc.php


示例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;
}
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:67,代码来源:functions_search.inc.php


示例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;
}
开发者ID:ejegg,项目名称:piwigo-stereo,代码行数:18,代码来源:functions.php


示例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']));
    }
}
开发者ID:HassenLin,项目名称:piwigo_utf8filename,代码行数:65,代码来源:pwg.categories.php


示例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})";
开发者ID:ejegg,项目名称:piwigo-stereo,代码行数:31,代码来源:admin.php


示例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;
}
开发者ID:donseba,项目名称:Piwigo,代码行数:41,代码来源:functions_tag.inc.php


示例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')));
}
开发者ID:squidjam,项目名称:Piwigo,代码行数:81,代码来源:pwg.permissions.php


示例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;
}
开发者ID:donseba,项目名称:Piwigo,代码行数:84,代码来源:functions_category.inc.php


示例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();
开发者ID:donseba,项目名称:Piwigo,代码行数:31,代码来源:album.php


示例16: check_pwg_token

    if (!empty($_POST)) {
        check_pwg_token();
    }
    $userdata = $user;
    trigger_notify('loc_begin_profile');
    // Reset to default (Guest) custom settings
    if (isset($_POST['reset_to_default'])) {
        $fields = array('nb_image_page', 'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'show_nb_hits');
        // Get the Guest custom settings
        $query = '
SELECT ' . implode(',', $fields) . '
  FROM ' . USER_INFOS_TABLE . '
  WHERE user_id = ' . $conf['default_user_id'] . '
;';
        $result = pwg_query($query);
        $default_user = pwg_db_fetch_assoc($result);
        $userdata = array_merge($userdata, $default_user);
    }
    save_profile_from_post($userdata, $page['errors']);
    $title = l10n('Your Gallery Customization');
    $page['body_id'] = 'theProfilePage';
    $template->set_filename('profile', 'profile.tpl');
    $template->set_filename('profile_content', 'profile_content.tpl');
    load_profile_in_template(get_root_url() . 'profile.php', make_index_url(), $userdata);
    $template->assign_var_from_handle('PROFILE_CONTENT', 'profile_content');
    // include menubar
    $themeconf = $template->get_template_vars('themeconf');
    if (!isset($themeconf['hide_menu_on']) or !in_array('theProfilePage', $themeconf['hide_menu_on'])) {
        include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
    }
    include PHPWG_ROOT_PATH . 'include/page_header.php';
开发者ID:lcorbasson,项目名称:Piwigo,代码行数:31,代码来源:profile.php


示例17: ws_images_addRemote

function ws_images_addRemote($params, &$service)
{
    global $conf;
    if (!is_admin()) {
        return new PwgError(401, 'Access denied');
    }
    load_language('plugin.lang', URLUPLOADER_PATH);
    $params = array_map('trim', $params);
    $allowed_extensions = array('jpg', 'jpeg', 'png', 'gif');
    $allowed_mimes = array('image/jpeg', 'image/png', 'image/gif');
    // check empty url
    if (empty($params['file_url'])) {
        return new PwgError(WS_ERR_INVALID_PARAM, l10n('File URL is empty'));
    }
    // check remote url
    if (!url_is_remote($params['file_url'])) {
        return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file URL'));
    }
    // check file extension
    if (!in_array(strtolower(get_extension($params['file_url'])), $allowed_extensions)) {
        return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file type'));
    }
    // download file
    include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
    $temp_filename = $conf['data_location'] . basename($params['file_url']);
    $file = fopen($temp_filename, 'w+');
    $result = fetchRemote($params['file_url'], $file);
    fclose($file);
    // download failed ?
    if (!$result) {
        @unlink($temp_filename);
        return new PwgError(WS_ERR_INVALID_PARAM, l10n('Unable to download file'));
    }
    // check mime-type
    if (!in_array(get_mime($temp_filename, $allowed_mimes[0]), $allowed_mimes)) {
        @unlink($temp_filename);
        return new PwgError(WS_ERR_INVALID_PARAM, l10n('Invalid file type'));
    }
    // add photo
    include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php';
    $image_id = add_uploaded_file($temp_filename, basename($temp_filename), array($params['category']), $params['level']);
    $updates = array();
    if (!empty($params['name'])) {
        $updates['name'] = $params['name'];
    }
    if ($params['url_in_comment'] == 'true') {
        $url = parse_url($params['file_url']);
        $url = $url['scheme'] . '://' . $url['host'];
        $updates['comment'] = '<a href="' . $url . '">' . $url . '</a>';
    }
    single_update(IMAGES_TABLE, $updates, array('id' => $image_id));
    // return infos
    $query = '
SELECT id, name, permalink
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $params['category'] . '
;';
    $category = pwg_db_fetch_assoc(pwg_query($query));
    $url_params = array('image_id' => $image_id, 'section' => 'categories', 'category' => $category);
    $query = '
SELECT id, path, name
  FROM ' . IMAGES_TABLE . '
  WHERE id = ' . $image_id . '
;';
    $image_infos = pwg_db_fetch_assoc(pwg_query($query));
    $query = '
SELECT
    COUNT(*) AS nb_photos
  FROM ' . IMAGE_CATEGORY_TABLE . '
  WHERE category_id = ' . $params['category'] . '
;';
    $category_infos = pwg_db_fetch_assoc(pwg_query($query));
    $category_name = get_cat_display_name_from_id($params['category'], null);
    return array('image_id' => $image_id, 'url' => make_picture_url($url_params), 'src' => DerivativeImage::thumb_url($image_infos), 'name' => $image_infos['name'], 'category' => array('id' => $params['category'], 'nb_photos' => $category_infos['nb_photos'], 'label' => $category_name));
}
开发者ID:skylogic004,项目名称:Piwigo-URL-Uploader,代码行数:75,代码来源:ws_functions.inc.php


示例18: load_conf_from_db

/**
 * Add configuration parameters from database to global $conf array
 *
 * @param string $condition SQL condition
 * @return void
 */
function load_conf_from_db($condition = '')
{
    global $conf;
    $query = '
SELECT param, value
 FROM ' . CONFIG_TABLE . '
 ' . (!empty($condition) ? 'WHERE ' . $condition : '') . '
;';
    $result = pwg_query($query);
    if (pwg_db_num_rows($result) == 0 and !empty($condition)) {
        fatal_error('No configuration data');
    }
    while ($row = pwg_db_fetch_assoc($result)) {
        $val = isset($row['value']) ? $row['value'] : '';
        // If the field is true or false, the variable is transformed into a boolean value.
        if ($val == 'true') {
            $val = true;
        } elseif ($val == 'false') {
            $val = false;
        }
        $conf[$row['param']] = $val;
    }
    trigger_notify('load_conf', $condition);
}
开发者ID:squidjam,项目名称:Piwigo,代码行数:30,代码来源:functions.inc.php


示例19: ROUND

     , ROUND(AVG(rate),2) AS average
  FROM ' . RATE_TABLE . '
  WHERE element_id = ' . $picture['current']['id'] . '
;';
        list($rate_summary['count'], $rate_summary['average']) = pwg_db_fetch_row(pwg_query($query));
    }
    $template->assign('rate_summary', $rate_summary);
    $user_rate = null;
    if ($conf['rate_anonymous'] or is_autorize_status(ACCESS_CLASSIC)) {
        if ($rate_summary['count'] > 0) {
            $query = 'SELECT rate
      FROM ' . RATE_TABLE . '
      WHERE element_id = ' . $page['image_id'] . '
      AND user_id = ' . $user['id'];
            if (!is_autorize_status(ACCESS_CLASSIC)) {
                $ip_components = explode('.', $_SERVER['REMOTE_ADDR']);
                if (count($ip_components) > 3) {
                    array_pop($ip_components);
                }
                $anonymous_id = implode('.', $ip_components);
                $query .= ' AND anonymous_id = \'' . $anonymous_id . '\'';
            }
            $result = pwg_query($query);
            if (pwg_db_num_rows($result) > 0) {
                $row = pwg_db_fetch_assoc($result);
                $user_rate = $row['rate'];
            }
        }
        $template->assign('rating', array('F_ACTION' => add_url_params($url_self, array('action' => 'rate')), 'USER_RATE' => $user_rate, 'marks' => $conf['rate_items']));
    }
}
开发者ID:donseba,项目名称:Piwigo,代码行数:31,代码来源:picture_rate.inc.php


示例20: osm_loc_begin_element_set_unit

function osm_loc_begin_element_set_unit()
{
    global $page;
    if (!isset($_POST['submit'])) {
        return;
    }
    $collection = explode(',', $_POST['element_ids']);
    $query = "SELECT `id`, `latitude`, `longitude`\n\t\t\tFROM " . IMAGES_TABLE . "\n\t\t\tWHERE id IN (" . implode(',', $collection) . ")";
    $datas = array();
    $errors = array();
    $form_errors = 0;
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        if (!isset($_POST['osmlat-' . $row['id']])) {
            $form_errors++;
            continue;
        }
        $error = false;
        $data = array('id' => $row['id'], 'latitude' => trim($_POST['osmlat-' . $row['id']]), 'longitude' => trim($_POST['osmlon-' . $row['id']]));
        if (strlen($data['latitude']) > 0 and strlen($data['longitude']) > 0) {
            if (!is_numeric($data['latitude']) or !is_numeric($data['longitude']) or (double) $data['latitude'] > 90 or (double) $data['latitude'] < -90 or (double) $data['longitude'] > 180 or (double) $data['longitude'] < -180) {
                $error = true;
            }
        } elseif (strlen($data['latitude']) == 0 and strlen($data['longitude']) == 0) {
            // nothing
        } else {
            $error = true;
        }
        if ($error) {
            $errors[] = $row['name'];
        } else {
            $datas[] = $data;
        }
    }
    mass_updates(IMAGES_TABLE, array('primary' => array('id'), 'update' => array('latitude', 'longitude')), $datas);
    if (count($errors) > 0) {
        $page['errors'][] = 'Invalid latitude or longitude value for files: ' . implode(', ', $errors);
    }
    if ($form_errors) {
        $page['errors'][] = 'OpenStreetMap: Invalid form submission for ' . $form_errors . ' photos';
    }
}
开发者ID:joubu,项目名称:piwigo-openstreetmap,代码行数:42,代码来源:admin_batchmanager.php



注:本文中的pwg_db_fetch_assoc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pwg_db_fetch_row函数代码示例发布时间:2022-05-15
下一篇:
PHP pwdHash函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap