本文整理汇总了PHP中COM_makeSid函数的典型用法代码示例。如果您正苦于以下问题:PHP COM_makeSid函数的具体用法?PHP COM_makeSid怎么用?PHP COM_makeSid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了COM_makeSid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: links_save_category
function links_save_category($cid, $old_cid, $pid, $category, $description, $tid, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
global $_CONF, $_TABLES, $_USER, $LANG_LINKS, $LANG_LINKS_ADMIN, $_LI_CONF, $PLG_links_MESSAGE17;
// Convert array values to numeric permission values
if (is_array($perm_owner) or is_array($perm_group) or is_array($perm_members) or is_array($perm_anon)) {
list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
}
// clean 'em up
$description = addslashes(COM_checkHTML(COM_checkWords($description), 'links.edit'));
$category = addslashes(COM_checkHTML(COM_checkWords($category), 'links.edit'));
$pid = addslashes(strip_tags($pid));
$cid = addslashes(strip_tags($cid));
$old_cid = addslashes(strip_tags($old_cid));
if (empty($category) || empty($description)) {
return 7;
}
// Check cid to make sure not illegal
if ($cid == addslashes($_LI_CONF['root']) || $cid == 'user') {
return 11;
}
if (!empty($cid) && $cid != $old_cid) {
// this is either a new category or an attempt to change the cid
// - check that cid doesn't exist yet
$ctrl = DB_getItem($_TABLES['linkcategories'], 'cid', "cid = '{$cid}'");
if (!empty($ctrl)) {
if (isset($PLG_links_MESSAGE17)) {
return 17;
} else {
return 11;
}
}
}
// Check that they didn't delete the cid. If so, get the hidden one
if (empty($cid) && !empty($old_cid)) {
$cid = $old_cid;
}
// Make sure they aren't making a parent category child of one of it's own
// children. This would create orphans
if ($cid == DB_getItem($_TABLES['linkcategories'], 'pid', "cid='{$pid}'")) {
return 12;
}
$access = 0;
if (DB_count($_TABLES['linkcategories'], 'cid', $old_cid) > 0) {
// update existing item, but new cid so get access from database with old cid
$result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$old_cid}'");
$A = DB_fetchArray($result);
$access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
// set flag
$update = "existing";
} else {
if (DB_count($_TABLES['linkcategories'], 'cid', $cid) > 0) {
// update existing item, same cid, so get access from database with existing cid
$result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group, perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'");
$A = DB_fetchArray($result);
$access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
// set flag
$update = "same";
} else {
// new item, so use passed values
$access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
// set flag
$update = 'new';
}
}
if ($access < 3) {
// no access rights: user should not be here
COM_accessLog(sprintf($LANG_LINKS_ADMIN[60], $_USER['username'], $cid));
return 6;
} else {
// save item
if ($update == 'existing') {
// update an existing item but new cid
$sql = "UPDATE {$_TABLES['linkcategories']}\n SET cid='{$cid}',\n pid='{$pid}',\n tid='{$tid}',category='{$category}',\n description='{$description}',\n modified=NOW(),\n owner_id='{$owner_id}',group_id='{$group_id}',\n perm_owner='{$perm_owner}',perm_group='{$perm_group}',\n perm_members='{$perm_members}',perm_anon='{$perm_anon}'\n WHERE cid = '{$old_cid}'";
$result = DB_query($sql);
// Also need to update links for this category
$sql = "UPDATE {$_TABLES['links']} SET cid='{$cid}' WHERE cid='{$old_cid}'";
$result = DB_query($sql);
} else {
if ($update == 'same') {
// update an existing item
$sql = "UPDATE {$_TABLES['linkcategories']}\n SET pid='{$pid}',\n tid='{$tid}',category='{$category}',\n description='{$description}',\n modified=NOW(),\n owner_id='{$owner_id}',group_id='{$group_id}',\n perm_owner='{$perm_owner}',perm_group='{$perm_group}',\n perm_members='{$perm_members}',perm_anon='{$perm_anon}'\n WHERE cid = '{$cid}'";
$result = DB_query($sql);
} else {
// insert a new item
if (empty($cid)) {
$cid = COM_makeSid();
}
$sql = "INSERT INTO {$_TABLES['linkcategories']}\n (cid, pid, category, description, tid,\n created,modified,\n owner_id, group_id, perm_owner, perm_group,\n perm_members, perm_anon)\n VALUES\n ('{$cid}','{$pid}','{$category}',\n '{$description}','{$tid}',\n NOW(),NOW(),\n '{$owner_id}','{$group_id}','{$perm_owner}',\n '{$perm_group}','{$perm_members}','{$perm_anon}')";
$result = DB_query($sql);
}
}
if ($update == 'existing' && $cid != $old_cid) {
PLG_itemSaved($cid, 'links.category', $old_cid);
} else {
PLG_itemSaved($cid, 'links.category');
}
}
return 10;
// success message
}
示例2: service_submit_staticpages
/**
* Submit static page. The page is updated if it exists, or a new one is created
*
* @param array args Contains all the data provided by the client
* @param string &output OUTPUT parameter containing the returned text
* @param string &svc_msg OUTPUT parameter containing any service messages
* @return int Response code as defined in lib-plugins.php
*/
function service_submit_staticpages($args, &$output, &$svc_msg)
{
global $_CONF, $_TABLES, $_USER, $LANG_ACCESS, $LANG12, $LANG_STATIC, $LANG_LOGIN, $_GROUPS, $_SP_CONF;
$output = '';
if (!SEC_hasRights('staticpages.edit')) {
$output = COM_siteHeader('menu', $LANG_STATIC['access_denied']);
$output .= COM_showMessageText($LANG_STATIC['access_denied_msg'], $LANG_STATIC['access_denied'], true);
$output .= COM_siteFooter();
return PLG_RET_AUTH_FAILED;
}
if (defined('DEMO_MODE')) {
$output = COM_siteHeader('menu');
$output .= COM_showMessageText('Option disabled in Demo Mode', 'Option disabled in Demo Mode', true);
$output .= COM_siteFooter();
return PLG_REG_AUTH_FAILED;
}
$gl_edit = false;
if (isset($args['gl_edit'])) {
$gl_edit = $args['gl_edit'];
}
if ($gl_edit) {
// This is EDIT mode, so there should be an sp_old_id
if (empty($args['sp_old_id'])) {
if (!empty($args['id'])) {
$args['sp_old_id'] = $args['id'];
} else {
return PLG_RET_ERROR;
}
if (empty($args['sp_id'])) {
$args['sp_id'] = $args['sp_old_id'];
}
}
} else {
if (empty($args['sp_id']) && !empty($args['id'])) {
$args['sp_id'] = $args['id'];
}
}
if (empty($args['sp_uid'])) {
$args['sp_uid'] = $_USER['uid'];
}
if (empty($args['sp_title']) && !empty($args['title'])) {
$args['sp_title'] = $args['title'];
}
if (empty($args['sp_content']) && !empty($args['content'])) {
$args['sp_content'] = $args['content'];
}
if (isset($args['category']) && is_array($args['category']) && !empty($args['category'][0])) {
$args['sp_tid'] = $args['category'][0];
}
if (!isset($args['owner_id'])) {
$args['owner_id'] = $_USER['uid'];
}
if (empty($args['group_id'])) {
$args['group_id'] = SEC_getFeatureGroup('staticpages.edit', $_USER['uid']);
}
$args['sp_id'] = COM_sanitizeID($args['sp_id']);
if (!$gl_edit) {
if (strlen($args['sp_id']) > STATICPAGE_MAX_ID_LENGTH) {
if (function_exists('WS_makeId')) {
$args['sp_id'] = WS_makeId($slug, STATICPAGE_MAX_ID_LENGTH);
} else {
$args['sp_id'] = COM_makeSid();
}
}
}
// Apply filters to the parameters passed by the webservice
if ($args['gl_svc']) {
$par_str = array('mode', 'sp_id', 'sp_old_id', 'sp_tid', 'sp_format', 'postmode');
$par_num = array('sp_uid', 'sp_hits', 'owner_id', 'group_id', 'sp_where', 'sp_php', 'commentcode', 'sp_search', 'sp_status');
foreach ($par_str as $str) {
if (isset($args[$str])) {
$args[$str] = COM_applyBasicFilter($args[$str]);
} else {
$args[$str] = '';
}
}
foreach ($par_num as $num) {
if (isset($args[$num])) {
$args[$num] = COM_applyBasicFilter($args[$num], true);
} else {
$args[$num] = 0;
}
}
}
// START: Staticpages defaults
if ($args['sp_status'] != 1) {
$args['sp_status'] = 0;
}
if (empty($args['sp_format'])) {
$args['sp_format'] = 'allblocks';
}
if (empty($args['sp_tid'])) {
//.........这里部分代码省略.........
示例3: editpoll
/**
* Shows poll editor
*
* Diplays the poll editor form
*
* @param string $pid ID of poll to edit
* @return string HTML for poll editor form
*
*/
function editpoll($pid = '')
{
global $_CONF, $_PO_CONF, $_GROUPS, $_TABLES, $_USER, $LANG25, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $LANG_POLLS;
$retval = '';
if (!empty($pid)) {
$topic = DB_query("SELECT * FROM {$_TABLES['polltopics']} WHERE pid='{$pid}'");
$T = DB_fetchArray($topic);
// Get permissions for poll
$access = SEC_hasAccess($T['owner_id'], $T['group_id'], $T['perm_owner'], $T['perm_group'], $T['perm_members'], $T['perm_anon']);
if ($access == 0 or $access == 2) {
// User doesn't have access...bail
$retval .= COM_startBlock($LANG25[21], '', COM_getBlockTemplate('_msg_block', 'header'));
$retval .= $LANG25[22];
$retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
COM_accessLog("User {$_USER['username']} tried to illegally submit or edit poll {$pid}.");
return $retval;
}
}
// writing the menu on top
require_once $_CONF['path_system'] . 'lib-admin.php';
$menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/polls/index.php', 'text' => $LANG_ADMIN['list_all']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
$token = SEC_createToken();
$retval .= COM_startBlock($LANG25[5], '', COM_getBlockTemplate('_admin_block', 'header'));
$retval .= ADMIN_createMenu($menu_arr, $LANG_POLLS['editinstructions'], plugin_geticon_polls());
$retval .= SEC_getTokenExpiryNotice($token);
$poll_templates = new Template($_CONF['path'] . 'plugins/polls/templates/admin/');
$poll_templates->set_file(array('editor' => 'polleditor.thtml', 'question' => 'pollquestions.thtml', 'answer' => 'pollansweroption.thtml'));
$poll_templates->set_var('xhtml', XHTML);
$poll_templates->set_var('site_url', $_CONF['site_url']);
$poll_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
$poll_templates->set_var('layout_url', $_CONF['layout_url']);
if (!empty($pid) and $access == 3 and !empty($T['owner_id'])) {
$delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
$jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
$poll_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
$poll_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
} else {
$T['pid'] = COM_makeSid();
$T['topic'] = '';
$T['meta_description'] = '';
$T['meta_keywords'] = '';
$T['voters'] = 0;
$T['display'] = 1;
$T['is_open'] = 1;
$T['hideresults'] = 0;
$T['owner_id'] = $_USER['uid'];
if (isset($_GROUPS['Polls Admin'])) {
$T['group_id'] = $_GROUPS['Polls Admin'];
} else {
$T['group_id'] = SEC_getFeatureGroup('polls.edit');
}
SEC_setDefaultPermissions($T, $_PO_CONF['default_permissions']);
$T['statuscode'] = 0;
$T['commentcode'] = $_CONF['comment_code'];
$access = 3;
}
$poll_templates->set_var('lang_pollid', $LANG25[6]);
$poll_templates->set_var('poll_id', $T['pid']);
$poll_templates->set_var('lang_donotusespaces', $LANG25[7]);
$poll_templates->set_var('lang_topic', $LANG25[9]);
$poll_templates->set_var('poll_topic', htmlspecialchars($T['topic']));
$poll_templates->set_var('lang_mode', $LANG25[1]);
$poll_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
$poll_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
if (!empty($T['meta_description'])) {
$poll_templates->set_var('meta_description', $T['meta_description']);
}
if (!empty($T['meta_keywords'])) {
$poll_templates->set_var('meta_keywords', $T['meta_keywords']);
}
$poll_templates->set_var('status_options', COM_optionList($_TABLES['statuscodes'], 'code,name', $T['statuscode']));
$poll_templates->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $T['commentcode']));
$poll_templates->set_var('lang_appearsonhomepage', $LANG25[8]);
$poll_templates->set_var('lang_openforvoting', $LANG25[33]);
$poll_templates->set_var('lang_hideresults', $LANG25[37]);
$poll_templates->set_var('poll_hideresults_explain', $LANG25[38]);
$poll_templates->set_var('poll_topic_info', $LANG25[39]);
if ($T['display'] == 1) {
$poll_templates->set_var('poll_display', 'checked="checked"');
}
if ($T['is_open'] == 1) {
$poll_templates->set_var('poll_open', 'checked="checked"');
}
if ($T['hideresults'] == 1) {
$poll_templates->set_var('poll_hideresults', 'checked="checked"');
}
// user access info
$poll_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
$poll_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
$ownername = COM_getDisplayName($T['owner_id']);
$poll_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$T['owner_id']}"));
//.........这里部分代码省略.........
示例4: service_submit_staticpages
/**
* Submit static page. The page is updated if it exists, or a new one is created
*
* @param array args Contains all the data provided by the client
* @param string &output OUTPUT parameter containing the returned text
* @param string &svc_msg OUTPUT parameter containing any service messages
* @return int Response code as defined in lib-plugins.php
*/
function service_submit_staticpages($args, &$output, &$svc_msg)
{
global $_CONF, $_TABLES, $_USER, $LANG_ACCESS, $LANG12, $LANG_STATIC, $_GROUPS, $_SP_CONF;
if (!$_CONF['disable_webservices']) {
require_once $_CONF['path_system'] . 'lib-webservices.php';
}
$output = '';
if (!SEC_hasRights('staticpages.edit')) {
$output = COM_siteHeader('menu', $LANG_STATIC['access_denied']);
$output .= COM_startBlock($LANG_STATIC['access_denied'], '', COM_getBlockTemplate('_msg_block', 'header'));
$output .= $LANG_STATIC['access_denied_msg'];
$output .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
$output .= COM_siteFooter();
return PLG_RET_AUTH_FAILED;
}
$gl_edit = false;
if (isset($args['gl_edit'])) {
$gl_edit = $args['gl_edit'];
}
if ($gl_edit) {
// This is EDIT mode, so there should be an sp_old_id
if (empty($args['sp_old_id'])) {
if (!empty($args['id'])) {
$args['sp_old_id'] = $args['id'];
} else {
return PLG_RET_ERROR;
}
if (empty($args['sp_id'])) {
$args['sp_id'] = $args['sp_old_id'];
}
}
} else {
if (empty($args['sp_id']) && !empty($args['id'])) {
$args['sp_id'] = $args['id'];
}
}
if (empty($args['sp_title']) && !empty($args['title'])) {
$args['sp_title'] = $args['title'];
}
if (empty($args['sp_content']) && !empty($args['content'])) {
$args['sp_content'] = $args['content'];
}
if (isset($args['category']) && is_array($args['category']) && !empty($args['category'][0])) {
$args['sp_tid'] = $args['category'][0];
}
if (!isset($args['owner_id'])) {
$args['owner_id'] = $_USER['uid'];
}
if (empty($args['group_id'])) {
$args['group_id'] = SEC_getFeatureGroup('staticpages.edit', $_USER['uid']);
}
$args['sp_id'] = COM_sanitizeID($args['sp_id']);
if (!$gl_edit) {
if (strlen($args['sp_id']) > STATICPAGE_MAX_ID_LENGTH) {
$slug = '';
if (isset($args['slug'])) {
$slug = $args['slug'];
}
if (function_exists('WS_makeId')) {
$args['sp_id'] = WS_makeId($slug, STATICPAGE_MAX_ID_LENGTH);
} else {
$args['sp_id'] = COM_makeSid();
}
}
}
// Apply filters to the parameters passed by the webservice
if ($args['gl_svc']) {
$par_str = array('mode', 'sp_id', 'sp_old_id', 'sp_tid', 'sp_format', 'postmode');
$par_num = array('sp_hits', 'owner_id', 'group_id', 'sp_where', 'sp_php', 'commentcode');
foreach ($par_str as $str) {
if (isset($args[$str])) {
$args[$str] = COM_applyBasicFilter($args[$str]);
} else {
$args[$str] = '';
}
}
foreach ($par_num as $num) {
if (isset($args[$num])) {
$args[$num] = COM_applyBasicFilter($args[$num], true);
} else {
$args[$num] = 0;
}
}
}
// START: Staticpages defaults
if (empty($args['sp_format'])) {
$args['sp_format'] = 'allblocks';
}
if (empty($args['sp_tid'])) {
$args['sp_tid'] = 'all';
}
if ($args['sp_where'] < 0 || $args['sp_where'] > 3) {
//.........这里部分代码省略.........
示例5: WS_makeId
/**
* Create a new ID, preferrably from a provided 'Slug:' header
*
* For more information on the 'Slug:' header, see RFC 5023, section 9.7
*
* @param string $slug Content of the 'Slug:' header
* @param int $max_length max. length of the created ID
* @return string new ID
* @link http://tools.ietf.org/html/rfc5023#section-9.7
*
*/
function WS_makeId($slug = '', $max_length = 40)
{
$sid = COM_makeSid();
if (strpos($slug, '%') !== false) {
// we'll end up removing most of the %-encoded characters anyway ...
$slug = '';
}
$slug = trim($slug);
if (!empty($slug)) {
// make it more ID-like
$slug = str_replace(' ', '-', $slug);
$slug = strtolower($slug);
$id = COM_sanitizeID($slug . '-' . $sid);
if (strlen($id) > $max_length) {
// 'slug-sid' would make for nicer IDs but if we have to shorten
// them, they're probably not unique any more. So swap order.
$id = $sid . '-' . $slug;
}
} else {
$id = $sid;
}
return substr(COM_sanitizeID($id), 0, $max_length);
}
示例6: service_submit_story
//.........这里部分代码省略.........
$args['frontpage'] = $_CONF['frontpage'];
}
if (empty($args['show_topic_icon'])) {
$args['show_topic_icon'] = $_CONF['show_topic_icon'];
}
}
// - END: Set all the defaults -
// TEST CODE
/* foreach ($args as $k => $v) {
if (!is_array($v)) {
echo "$k => $v\r\n";
} else {
echo "$k => $v\r\n";
foreach ($v as $k1 => $v1) {
echo " $k1 => $v1\r\n";
}
}
}*/
// exit ();
// END TEST CODE
if (!isset($args['sid'])) {
$args['sid'] = '';
}
$args['sid'] = COM_sanitizeID($args['sid']);
if (!$gl_edit) {
if (strlen($args['sid']) > STORY_MAX_ID_LENGTH) {
$slug = '';
if (isset($args['slug'])) {
$slug = $args['slug'];
}
if (function_exists('WS_makeId')) {
$args['sid'] = WS_makeId($slug, STORY_MAX_ID_LENGTH);
} else {
$args['sid'] = COM_makeSid();
}
}
}
$story = new Story();
$gl_edit = false;
if (isset($args['gl_edit'])) {
$gl_edit = $args['gl_edit'];
}
if ($gl_edit && !empty($args['gl_etag'])) {
// First load the original story to check if it has been modified
$result = $story->loadFromDatabase($args['sid']);
if ($result == STORY_LOADED_OK) {
if ($args['gl_etag'] != date('c', $story->_date)) {
$svc_msg['error_desc'] = 'A more recent version of the story is available';
return PLG_RET_PRECONDITION_FAILED;
}
} else {
$svc_msg['error_desc'] = 'Error loading story';
return PLG_RET_ERROR;
}
}
// This function is also doing the security checks
$result = $story->loadFromArgsArray($args);
$sid = $story->getSid();
// Check if topics selected if not prompt required field
if ($result == STORY_LOADED_OK) {
if (!TOPIC_checkTopicSelectionControl()) {
$result = STORY_EMPTY_REQUIRED_FIELDS;
}
}
switch ($result) {
case STORY_DUPLICATE_SID:
示例7: savelink
/**
* Saves link to the database
*
* @param string $lid ID for link
* @param string $old_lid old ID for link
* @param string $cid cid of category link belongs to
* @param string $categorydd Category links belong to
* @param string $url URL of link to save
* @param string $description Description of link
* @param string $title Title of link
* @param int $hits Number of hits for link
* @param int $owner_id ID of owner
* @param int $group_id ID of group link belongs to
* @param int $perm_owner Permissions the owner has
* @param int $perm_group Permissions the group has
* @param int $perm_members Permissions members have
* @param int $perm_anon Permissions anonymous users have
* @return string HTML redirect or error message
* @global array core config vars
* @global array core group data
* @global array core table data
* @global array core user data
* @global array core msg data
* @global array links plugin lang admin vars
*
*/
function savelink($lid, $old_lid, $cid, $categorydd, $url, $description, $title, $hits, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
global $_CONF, $_GROUPS, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN, $_LI_CONF;
$retval = '';
// Convert array values to numeric permission values
if (is_array($perm_owner) or is_array($perm_group) or is_array($perm_members) or is_array($perm_anon)) {
list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
}
// Remove any autotags the user doesn't have permission to use
$description = PLG_replaceTags($description, '', true);
// clean 'em up
$description = DB_escapeString(COM_checkHTML(COM_checkWords($description), 'links.edit'));
$title = DB_escapeString(strip_tags(COM_checkWords($title)));
$cid = DB_escapeString($cid);
if (empty($owner_id)) {
// this is new link from admin, set default values
$owner_id = $_USER['uid'];
if (isset($_GROUPS['Links Admin'])) {
$group_id = $_GROUPS['Links Admin'];
} else {
$group_id = SEC_getFeatureGroup('links.edit');
}
$perm_owner = 3;
$perm_group = 2;
$perm_members = 2;
$perm_anon = 2;
}
$lid = COM_sanitizeID($lid);
$old_lid = COM_sanitizeID($old_lid);
if (empty($lid)) {
if (empty($old_lid)) {
$lid = COM_makeSid();
} else {
$lid = $old_lid;
}
}
// check for link id change
if (!empty($old_lid) && $lid != $old_lid) {
// check if new lid is already in use
if (DB_count($_TABLES['links'], 'lid', $lid) > 0) {
// TBD: abort, display editor with all content intact again
$lid = $old_lid;
// for now ...
}
}
$access = 0;
$old_lid = DB_escapeString($old_lid);
if (DB_count($_TABLES['links'], 'lid', $old_lid) > 0) {
$result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE lid = '{$old_lid}'");
$A = DB_fetchArray($result);
$access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
} else {
$access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
}
if ($access < 3 || !SEC_inGroup($group_id)) {
$display .= COM_showMessageText($MESSAGE[29], $MESSAGE[30]);
$display = COM_createHTMLDocument($display, array('pagetitle' => $MESSAGE[30]));
COM_accessLog("User {$_USER['username']} tried to illegally submit or edit link {$lid}.");
COM_output($display);
exit;
} elseif (!empty($title) && !empty($description) && !empty($url)) {
if ($categorydd != $LANG_LINKS_ADMIN[7] && !empty($categorydd)) {
$cid = DB_escapeString($categorydd);
} else {
if ($categorydd != $LANG_LINKS_ADMIN[7]) {
echo COM_refresh($_CONF['site_admin_url'] . '/plugins/links/index.php');
}
}
DB_delete($_TABLES['linksubmission'], 'lid', $old_lid);
DB_delete($_TABLES['links'], 'lid', $old_lid);
DB_save($_TABLES['links'], 'lid,cid,url,description,title,date,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon', "'{$lid}','{$cid}','{$url}','{$description}','{$title}',NOW(),'{$hits}',{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon}");
if (empty($old_lid) || $old_lid == $lid) {
PLG_itemSaved($lid, 'links');
} else {
//.........这里部分代码省略.........
示例8: Save
/**
* Save the current order to the database
*/
public function Save()
{
global $_TABLES, $_PP_CONF;
if ($this->isNew) {
// Shouldn't have an empty order ID, but double-check
if ($this->order_id == '') {
$this->order_id = COM_makeSid();
}
if ($this->billto_name == '') {
$this->billto_name = COM_getDisplayName($this->uid);
}
$_SESSION[PP_CART_VAR]['order_id'] = $this->order_id;
$sql1 = "INSERT INTO {$_TABLES['paypal.orders']} SET \r\n order_id='{$this->order_id}', \r\n order_date = '{$this->order_date}', \r\n uid = '" . (int) $this->uid . "', ";
$sql2 = '';
$log_msg = 'Order Created';
} else {
$sql1 = "UPDATE {$_TABLES['paypal.orders']} SET ";
$sql2 = " WHERE order_id = '{$this->order_id}'";
$log_msg = 'Order Updated';
}
$fields = array("status = '{$this->status}'", "pmt_txn_id = '" . DB_escapeString($this->pmt_txn_id) . "'", "pmt_method = '" . DB_escapeString($this->pmt_method) . "'", "phone = '" . DB_escapeString($this->phone) . "'", "tax = '{$this->tax}'", "shipping = '{$this->shipping}'", "handling = '{$this->handling}'", "instructions = '" . DB_escapeString($this->instructions) . "'", "buyer_email = '" . DB_escapeString($this->buyer_email) . "'");
foreach ($this->_addr_fields as $fld) {
$fields[] = $fld . "='" . DB_escapeString($this->{$fld}) . "'";
}
$sql = $sql1 . implode(', ', $fields) . $sql2;
//echo $sql;die;
DB_query($sql);
if (!DB_error()) {
$this->Log($log_msg);
}
$this->isNew = false;
return $this->order_id;
}
示例9: adEdit
/**
* Provide a form to edit a new or existing ad.
* @param array $A Array of ad data for edit form
* @param string $mode Edit mode
* @param boolean $admin True for administrator edit, false for normal
* @return string HTML for ad edit form
*/
function adEdit($A, $mode = 'edit', $admin = false)
{
global $_TABLES, $LANG_ADVT, $_CONF, $_CONF_ADVT, $LANG_ADMIN, $_USER, $LANG_ACCESS, $_GROUPS, $LANG12, $LANG24, $MESSAGE, $LANG_postmodes;
USES_classifieds_class_adtype();
// Determine if this user is an admin. Deprecates the $admin parameter.
$admin = SEC_hasRights($_CONF_ADVT['pi_name'] . '.admin') ? 1 : 0;
// only valid users allowed
if (COM_isAnonUser() || $_CONF_ADVT['usercanedit'] == 0 && !$admin) {
return CLASSIFIEDS_errorMsg($LANG_ADVT['no_permission'], 'alert', $LANG_ADVT['access_denied']);
}
// We know that we need to have categories, so make sure some exist
// before even trying to display the form. The category dropdown is
// created later since it needs the existing cat_id, if any.
if (DB_count($_TABLES['ad_category']) < 1) {
return CLASSIFIEDS_errorMsg($LANG_ADVT['no_categories'], 'info');
}
$time = time();
// used to compare now with expiration date
if ($admin) {
$T = new Template(CLASSIFIEDS_PI_PATH . '/templates/admin');
$T->set_file('adedit', "adminedit.thtml");
$action_url = CLASSIFIEDS_ADMIN_URL . '/index.php';
} else {
$T = new Template(CLASSIFIEDS_PI_PATH . '/templates');
$T->set_file('adedit', "submitform.thtml");
$action_url = CLASSIFIEDS_URL . '/index.php';
}
// Set up the wysiwyg editor, if available
switch (PLG_getEditorType()) {
case 'ckeditor':
$T->set_var('show_htmleditor', true);
PLG_requestEditor('classifieds', 'classifieds_entry', 'ckeditor_classifieds.thtml');
PLG_templateSetVars('classifieds_entry', $T);
break;
case 'tinymce':
$T->set_var('show_htmleditor', true);
PLG_requestEditor('classifieds', 'classifieds_entry', 'tinymce_classifieds.thtml');
PLG_templateSetVars('classifieds_entry', $T);
break;
default:
// don't support others right now
$T->set_var('show_htmleditor', false);
break;
}
switch ($mode) {
case 'editsubmission':
case 'moderate':
$savemode = 'savesubmission';
$delete_img = 'delsubimg';
$delete_ad = 'deletesubmission';
$type = 'moderate';
$saveoption = $LANG_ADMIN['moderate'];
$cancel_url = $_CONF['site_admin_url'] . '/moderation.php';
break;
case 'edit':
$savemode = 'savesubmission';
$delete_img = 'delsubimg';
$delete_ad = 'deletesubmission';
$saveoption = $LANG_ADMIN['save'];
$type = 'submission';
$cancel_url = $action_url;
break;
case 'update_ad':
default:
$savemode = 'update_ad';
$delete_img = 'delete_img';
$delete_ad = 'delete_ad';
$saveoption = $LANG_ADMIN['save'];
$type = '';
$cancel_url = $action_url;
break;
}
// Admins (only) use this form for submissions as well as edits,
// so we need to expect an empty array.
if (empty($A['ad_id'])) {
if (!$admin) {
return CLASSIFIEDS_errorMsg($LANG_ADVT['no_permission'], 'alert', $LANG_ADVT['access_denied']);
}
$A['ad_id'] = COM_makeSid();
$A['subject'] = '';
$A['descript'] = '';
$A['price'] = '';
$A['url'] = '';
$A['exp_date'] = '';
$A['add_date'] = time();
$A['ad_type'] = 0;
$A['perm_owner'] = $_CONF_ADVT['default_permissions'][0];
$A['perm_group'] = $_CONF_ADVT['default_permissions'][1];
$A['perm_members'] = $_CONF_ADVT['default_permissions'][2];
$A['perm_anon'] = $_CONF_ADVT['default_permissions'][3];
$A['uid'] = $_USER['uid'];
if (isset($_REQUEST['cat'])) {
$A['cat_id'] = intval($_REQUEST['cat']);
//.........这里部分代码省略.........
示例10: _loadBasics
/**
* Loads the basic details of an article into the internal
* variables, cleaning them up nicely.
* @access Private
* @param $array Array of POST/GET data (by ref).
* @return Nothing.
*/
function _loadBasics(&$array)
{
/* For the really, really basic stuff, we can very easily load them
* based on an array that defines how to COM_applyFilter them.
*/
foreach ($this->_postFields as $key => $value) {
$vartype = $value[0];
$varname = $value[1];
// If we have a value
if (array_key_exists($key, $array)) {
// And it's alphanumeric or numeric, filter it and use it.
if ($vartype == STORY_AL_ALPHANUM || $vartype == STORY_AL_NUMERIC) {
$this->{$varname} = COM_applyFilter($array[$key], $vartype);
} elseif ($vartype == STORY_AL_ANYTHING) {
$this->{$varname} = $array[$key];
} elseif ($array[$key] === 'on' || $array[$key] === 1) {
// If it's a checkbox that is on
$this->{$varname} = 1;
} else {
// Otherwise, it must be a checkbox that is off:
$this->{$varname} = 0;
}
} elseif ($vartype == STORY_AL_NUMERIC || $vartype == STORY_AL_CHECKBOX) {
// If we don't have a value, and have a numeric or text box, default to 0
$this->{$varname} = 0;
}
}
// SID's are a special case:
$sid = COM_sanitizeID($array['sid']);
if (isset($array['old_sid'])) {
$oldsid = COM_sanitizeID($array['old_sid'], false);
} else {
$oldsid = '';
}
if (empty($sid)) {
$sid = $oldsid;
}
if (empty($sid)) {
$sid = COM_makeSid();
}
$this->_sid = $sid;
$this->_originalSid = $oldsid;
/* Need to deal with the postdate and expiry date stuff */
$publish_ampm = '';
if (isset($array['publish_ampm'])) {
$publish_ampm = COM_applyFilter($array['publish_ampm']);
}
$publish_hour = 0;
if (isset($array['publish_hour'])) {
$publish_hour = COM_applyFilter($array['publish_hour'], true);
}
$publish_minute = 0;
if (isset($array['publish_minute'])) {
$publish_minute = COM_applyFilter($array['publish_minute'], true);
}
$publish_second = 0;
if (isset($array['publish_second'])) {
$publish_second = COM_applyFilter($array['publish_second'], true);
}
if ($publish_ampm == 'pm') {
if ($publish_hour < 12) {
$publish_hour = $publish_hour + 12;
}
}
if ($publish_ampm == 'am' and $publish_hour == 12) {
$publish_hour = '00';
}
$publish_year = 0;
if (isset($array['publish_year'])) {
$publish_year = COM_applyFilter($array['publish_year'], true);
}
$publish_month = 0;
if (isset($array['publish_month'])) {
$publish_month = COM_applyFilter($array['publish_month'], true);
}
$publish_day = 0;
if (isset($array['publish_day'])) {
$publish_day = COM_applyFilter($array['publish_day'], true);
}
$this->_date = strtotime("{$publish_month}/{$publish_day}/{$publish_year} {$publish_hour}:{$publish_minute}:{$publish_second}");
$archiveflag = 0;
if (isset($array['archiveflag'])) {
$archiveflag = COM_applyFilter($array['archiveflag'], true);
}
/* Override status code if no archive flag is set: */
if ($archiveflag != 1) {
$this->_statuscode = 0;
}
if (array_key_exists('expire_ampm', $array)) {
$expire_ampm = COM_applyFilter($array['expire_ampm']);
$expire_hour = COM_applyFilter($array['expire_hour'], true);
$expire_minute = COM_applyFilter($array['expire_minute'], true);
$expire_second = COM_applyFilter($array['expire_second'], true);
//.........这里部分代码省略.........
示例11: PAYPAL_do_upgrade
//.........这里部分代码省略.........
$c->add('fs_addresses', NULL, 'fieldset', 0, 60, NULL, 0, true, $_PP_CONF['pi_name']);
$c->add('get_street', $_PP_DEFAULTS['get_street'], 'select', 0, 60, 14, 10, true, $_PP_CONF['pi_name']);
$c->add('get_city', $_PP_DEFAULTS['get_city'], 'select', 0, 60, 14, 20, true, $_PP_CONF['pi_name']);
$c->add('get_state', $_PP_DEFAULTS['get_state'], 'select', 0, 60, 14, 30, true, $_PP_CONF['pi_name']);
$c->add('get_country', $_PP_DEFAULTS['get_country'], 'select', 0, 60, 14, 40, true, $_PP_CONF['pi_name']);
$c->add('get_postal', $_PP_DEFAULTS['get_postal'], 'select', 0, 60, 14, 50, true, $_PP_CONF['pi_name']);
$c->add('weight_unit', $_PP_DEFAULTS['weight_unit'], 'select', 0, 0, 15, 230, true, $_PP_CONF['pi_name']);
$c->add('ena_cart', $PP_DEFAULTS['ena_cart'], 'select', 0, 0, 2, 220, true, $_PP_CONF['pi_name']);
DB_query("UPDATE {$_TABLES['conf_values']}\n SET sort_order=80\n WHERE name='tmpdir'\n AND group_name='paypal'");
DB_query($sql, 1);
if (DB_error()) {
COM_errorLog("Error Executing SQL: {$sql}", 1);
}
// Convert saved buttons in the product records to simple text strings
// indicating the type of button to use. Don't save the button in the
// new cache table; that will be done when the button is needed.
DB_query("UPDATE {$_TABLES['paypal.products']} SET buttons='buy_now'");
// Create order records and associate with the existing purchase table.
// We create our own sid to try and use the original purchase date.
// Since this function runs so fast, there could still be duplicate
// sid's so we check for an existing sid before trying to use it.
// If that happens, the order_id will just be a current sid.
$sql = "SELECT * FROM {$_TABLES['paypal.purchases']}";
$res = DB_query($sql);
if ($res && DB_numRows($res) > 0) {
USES_paypal_class_order();
while ($A = DB_fetchArray($res, false)) {
$dt_tm = explode(' ', $A['purchase_date']);
list($y, $m, $d) = explode('-', $dt_tm[0]);
list($h, $i, $s) = explode(':', $dt_tm[1]);
$sid = $y . $m . $d . $h . $i . $s;
$order_id = $sid . mt_rand(0, 999);
while (DB_count($_TABLES['paypal.orders'], 'order_id', $order_id) > 0) {
$order_id = COM_makeSid();
}
// Discovered that the "price" field isn't filled in for the
// purchase table. Read the IPN data and use mc_gross.
$IPN = DB_getItem($_TABLES['paypal.ipnlog'], 'ipn_data', "txn_id = '" . DB_escapeString($A['txn_id']) . "'");
$price = 0;
if (!empty($IPN)) {
$data = @unserialize($IPN);
if ($data && isset($data['mc_gross'])) {
$price = (double) $data['mc_gross'];
if (isset($data['tax'])) {
$tax = (double) $data['tax'];
$price -= $tax;
} else {
$tax = 0;
}
if (isset($data['shipping'])) {
$shipping = (double) $data['shipping'];
$price -= $shipping;
} else {
$shipping = 0;
}
if (isset($data['handling'])) {
$handling = (double) $data['handling'];
$price -= $handling;
} else {
$handling = 0;
}
}
}
$ord = new ppOrder($order_id);
$ord->uid = $A['user_id'];
$ord->order_date = DB_escapeString($A['purchase_date']);
示例12: addslashes
$_REQUEST['item_3'] = addslashes($_REQUEST['item_3']);
$_REQUEST['item_4'] = addslashes($_REQUEST['item_4']);
$_REQUEST['item_5'] = addslashes($_REQUEST['item_5']);
$_REQUEST['item_6'] = addslashes($_REQUEST['item_6']);
$_REQUEST['item_7'] = addslashes($_REQUEST['item_7']);
$_REQUEST['item_8'] = addslashes($_REQUEST['item_8']);
$_REQUEST['item_9'] = addslashes($_REQUEST['item_9']);
$_REQUEST['item_10'] = addslashes($_REQUEST['item_10']);
if (!empty($_REQUEST['mkid']) && $_REQUEST['submission'] != 1) {
//edit mode
$sql = "name = '{$_REQUEST['name']}', " . "description = '{$_REQUEST['description']}', " . "modified = '{$_REQUEST['modified']}', " . "payed = '{$_REQUEST['payed']}', " . "validity = '{$_REQUEST['validity']}', " . "validity_start = '{$_REQUEST['from']}', " . "validity_end = '{$_REQUEST['to']}', " . "active = '{$_REQUEST['active']}', " . "hidden = '{$_REQUEST['hidden']}', " . "address = '{$_REQUEST['address']}', " . "lat = '{$lat}', " . "lng = '{$lng}', " . "mk_default = '{$_REQUEST['mk_default']}', " . "mk_pcolor = '{$_REQUEST['primary_color']}', " . "mk_scolor = '{$_REQUEST['stroke_color']}', " . "mk_label = '{$_REQUEST['label']}', " . "mk_label_color = '{$_REQUEST['label_color']}', " . "mk_icon = '{$_REQUEST['mk_icon']}', " . "mid = '{$_REQUEST['mid']}', " . "remark = '{$_REQUEST['remark']}', " . "street = '{$_REQUEST['street']}', " . "city = '{$_REQUEST['city']}', " . "code = '{$_REQUEST['code']}', " . "state = '{$_REQUEST['state']}', " . "country = '{$_REQUEST['country']}', " . "tel = '{$_REQUEST['tel']}', " . "fax = '{$_REQUEST['fax']}', " . "web = '{$_REQUEST['web']}', " . "item_1 = '{$_REQUEST['item_1']}', " . "item_2 = '{$_REQUEST['item_2']}', " . "item_3 = '{$_REQUEST['item_3']}', " . "item_4 = '{$_REQUEST['item_4']}', " . "item_5 = '{$_REQUEST['item_5']}', " . "item_6 = '{$_REQUEST['item_6']}', " . "item_7 = '{$_REQUEST['item_7']}', " . "item_8 = '{$_REQUEST['item_8']}', " . "item_9 = '{$_REQUEST['item_9']}', " . "item_10 = '{$_REQUEST['item_10']}', " . "owner_id = '{$_REQUEST['owner_id']}', " . "group_id = '{$_REQUEST['group_id']}', " . "perm_owner = '{$_REQUEST['perm_owner']}', " . "perm_group = '{$_REQUEST['perm_group']}', " . "perm_members = '{$_REQUEST['perm_members']}', " . "perm_anon = '{$_REQUEST['perm_anon']}', " . "submission = '0'";
$sql = "UPDATE {$_TABLES['maps_markers']} SET {$sql} " . "WHERE mkid = {$mkid}";
} else {
// create mode
if ($_REQUEST['submission'] != 1) {
$newmkid = addslashes(COM_makeSid());
} else {
$newmkid = $mkid;
}
$sql = "mkid = '{$newmkid}', " . "name = '{$_REQUEST['name']}', " . "description = '{$_REQUEST['description']}', " . "created = '{$_REQUEST['created']}', " . "modified = '{$_REQUEST['modified']}', " . "payed = '{$_REQUEST['payed']}', " . "validity = '{$_REQUEST['validity']}', " . "validity_start = '{$_REQUEST['from']}', " . "validity_end = '{$_REQUEST['to']}', " . "active = '{$_REQUEST['active']}', " . "hidden = '{$_REQUEST['hidden']}', " . "address = '{$_REQUEST['address']}', " . "lat = '{$lat}', " . "lng = '{$lng}', " . "mk_default = '{$_REQUEST['mk_default']}', " . "mk_pcolor = '{$_REQUEST['primary_color']}', " . "mk_scolor = '{$_REQUEST['stroke_color']}', " . "mk_label = '{$_REQUEST['label']}', " . "mk_label_color = '{$_REQUEST['label_color']}', " . "mk_icon = '{$_REQUEST['mk_icon']}', " . "mid = '{$_REQUEST['mid']}', " . "remark = '{$_REQUEST['remark']}', " . "street = '{$_REQUEST['street']}', " . "city = '{$_REQUEST['city']}', " . "code = '{$_REQUEST['code']}', " . "state = '{$_REQUEST['state']}', " . "country = '{$_REQUEST['country']}', " . "tel = '{$_REQUEST['tel']}', " . "fax = '{$_REQUEST['fax']}', " . "web = '{$_REQUEST['web']}', " . "item_1 = '{$_REQUEST['item_1']}', " . "item_2 = '{$_REQUEST['item_2']}', " . "item_3 = '{$_REQUEST['item_3']}', " . "item_4 = '{$_REQUEST['item_4']}', " . "item_5 = '{$_REQUEST['item_5']}', " . "item_6 = '{$_REQUEST['item_6']}', " . "item_7 = '{$_REQUEST['item_7']}', " . "item_8 = '{$_REQUEST['item_8']}', " . "item_9 = '{$_REQUEST['item_9']}', " . "item_10 = '{$_REQUEST['item_10']}', " . "owner_id = '{$_REQUEST['owner_id']}', " . "group_id = '{$_REQUEST['group_id']}', " . "perm_owner = '{$_REQUEST['perm_owner']}', " . "perm_group = '{$_REQUEST['perm_group']}', " . "perm_members = '{$_REQUEST['perm_members']}', " . "perm_anon = '{$_REQUEST['perm_anon']}', " . "submission = 0";
$sql = "INSERT INTO {$_TABLES['maps_markers']} SET {$sql} ";
}
DB_query($sql);
updateMap($_REQUEST['mid']);
if ($_REQUEST['submission'] == 0) {
DB_delete($_TABLES['maps_submission'], 'mkid', $mkid);
}
if (DB_error()) {
$msg = $LANG_MAPS_1['save_fail'];
} else {
$msg = $LANG_MAPS_1['save_success'];
示例13: POLLS_save
/**
* Saves a poll
*
* Saves a poll topic and potential answers to the database
*
* @param string $pid Poll topic ID
* @param string $old_pid Previous poll topic ID
* @param array $Q Array of poll questions
* @param string $mainpage Checkbox: poll appears on homepage
* @param string $topic The text for the topic
* @param int $statuscode (unused)
* @param string $open Checkbox: poll open for voting
* @param string $hideresults Checkbox: hide results until closed
* @param int $commentcode Indicates if users can comment on poll
* @param array $A Array of possible answers
* @param array $V Array of vote per each answer
* @param array $R Array of remark per each answer
* @param int $owner_id ID of poll owner
* @param int $group_id ID of group poll belongs to
* @param int $perm_owner Permissions the owner has on poll
* @param int $perm_grup Permissions the group has on poll
* @param int $perm_members Permissions logged in members have on poll
* @param int $perm_anon Permissions anonymous users have on poll
* @return string HTML redirect or error message
*
*/
function POLLS_save($pid, $old_pid, $Q, $mainpage, $topic, $statuscode, $open, $hideresults, $commentcode, $A, $V, $R, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
global $_CONF, $_TABLES, $_USER, $LANG21, $LANG25, $MESSAGE, $_POLL_VERBOSE, $_PO_CONF;
$retval = '';
// Convert array values to numeric permission values
list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
$pid = COM_sanitizeID($pid);
$topic = $topic;
$old_pid = COM_sanitizeID($old_pid);
if (empty($pid)) {
if (empty($old_pid)) {
$pid = COM_makeSid();
} else {
$pid = $old_pid;
}
}
// check if any question was entered
if (empty($topic) or count($Q) == 0 or strlen($Q[0]) == 0 or strlen($A[0][0]) == 0) {
$retval .= COM_siteHeader('menu', $LANG25[5]);
$retval .= COM_startBlock($LANG21[32], '', COM_getBlockTemplate('_msg_block', 'header'));
$retval .= $LANG25[2];
$retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
$retval .= COM_siteFooter();
return $retval;
}
// check for poll id change
if (!empty($old_pid) && $pid != $old_pid) {
// check if new pid is already in use
if (DB_count($_TABLES['polltopics'], 'pid', $pid) > 0) {
// TBD: abort, display editor with all content intact again
$pid = $old_pid;
// for now ...
}
}
// start processing the poll topic
if ($_POLL_VERBOSE) {
COM_errorLog('**** Inside POLL_save() in ' . $_CONF['site_admin_url'] . '/plugins/polls/index.php ***');
}
$pid = str_replace(' ', '', $pid);
// strip spaces from poll id
$access = 0;
if (DB_count($_TABLES['polltopics'], 'pid', $pid) > 0) {
$result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['polltopics']} WHERE pid = '{$pid}'");
$P = DB_fetchArray($result);
$access = SEC_hasAccess($P['owner_id'], $P['group_id'], $P['perm_owner'], $P['perm_group'], $P['perm_members'], $P['perm_anon']);
} else {
$access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
}
if ($access < 3 || !SEC_inGroup($group_id)) {
$display .= COM_siteHeader('menu', $MESSAGE[30]);
$display .= COM_startBlock($MESSAGE[30], '', COM_getBlockTemplate('_msg_block', 'header'));
$display .= $MESSAGE[31];
$display .= COM_endBlock();
$display .= COM_siteFooter(COM_getBlockTemplate('_msg_block', 'footer'));
COM_accessLog("User {$_USER['username']} tried to illegally submit or edit poll {$pid}.");
echo $display;
exit;
}
if (empty($voters)) {
$voters = 0;
}
if ($_POLL_VERBOSE) {
COM_errorLog('owner permissions: ' . $perm_owner, 1);
COM_errorLog('group permissions: ' . $perm_group, 1);
COM_errorLog('member permissions: ' . $perm_members, 1);
COM_errorLog('anonymous permissions: ' . $perm_anon, 1);
}
// we delete everything and re-create it with the input from the form
$del_pid = $pid;
if (!empty($old_pid) && $pid != $old_pid) {
$del_pid = $old_pid;
// delete by old pid, create using new pid below
}
DB_delete($_TABLES['polltopics'], 'pid', $del_pid);
//.........这里部分代码省略.........
示例14: MakeTicketId
/**
* Create a unique ticket ID
*
* @param array $A Array of values, non-indexed
* @return string Ticket ID
*/
public static function MakeTicketId($A = array())
{
/*if (empty($A)) {
return NULL;
}
if (!is_array($A)) {
$A = array($A);
}*/
/* $str = 'EVT'; // some meaningless string to start
foreach ($A as $val) {
$str .= $val;
}
$str .= rand(0,100) . time();
return md5($str);
*/
// md5 makes a long value to put in a qrcode url.
// makeSid() should be sufficient since it includes some
// random characters.
return COM_makeSid();
}
示例15: savebanner
/**
* Saves banner to the database
*
* @param string $bid ID for banner
* @param string $old_bid old ID for banner
* @param string $cid cid of category banner belongs to
* @param string $categorydd Category banner belong to
* @param string $url URL of banner to save
* @param string $description Description of banner
* @param string $title Title of banner
* @param int $hits Number of hits for banner
* @param int $owner_id ID of owner
* @param int $group_id ID of group banner belongs to
* @param int $perm_owner Permissions the owner has
* @param int $perm_group Permissions the group has
* @param int $perm_members Permissions members have
* @param int $perm_anon Permissions anonymous users have
* @return string HTML redirect or error message
* @global array core config vars
* @global array core group data
* @global array core table data
* @global array core user data
* @global array core msg data
* @global array banner plugin lang admin vars
*
*/
function savebanner($bid, $old_bid, $cid, $categorydd, $url, $description, $title, $publishstart, $publishend, $hits, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon)
{
global $_CONF, $_GROUPS, $_TABLES, $_USER, $MESSAGE, $LANG_BANNER_ADMIN, $_BAN_CONF;
$retval = '';
// Convert array values to numeric permission values
if (is_array($perm_owner) or is_array($perm_group) or is_array($perm_members) or is_array($perm_anon)) {
list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
}
// clean 'em up
$description = addslashes(COM_checkHTML(COM_checkWords($description)));
$title = addslashes(COM_checkHTML(COM_checkWords($title)));
$cid = addslashes($cid);
//$description = str_replace('<p>','',$description);
//$description = str_replace('</p>','',$description);
if (empty($owner_id)) {
// this is new banner from admin, set default values
$owner_id = $_USER['uid'];
if (isset($_GROUPS['Banner Admin'])) {
$group_id = $_GROUPS['Banner Admin'];
} else {
$group_id = SEC_getFeatureGroup('banner.edit');
}
$perm_owner = 3;
$perm_group = 2;
$perm_members = 2;
$perm_anon = 2;
}
if (empty($publishstart)) {
$publishstart = 'NULL';
} else {
$publishstart = "'" . $publishstart . "'";
}
if (empty($publishend)) {
$publishend = 'NULL';
} else {
$publishend = "'" . $publishend . "'";
}
$bid = COM_sanitizeID($bid);
$old_bid = COM_sanitizeID($old_bid);
if (empty($bid)) {
if (empty($old_bid)) {
$bid = COM_makeSid();
} else {
$bid = $old_bid;
}
}
// check for banner id change
if (!empty($old_bid) && $bid != $old_bid) {
// check if new bid is already in use
if (DB_count($_TABLES['banner'], 'bid', $bid) > 0) {
// TBD: abort, display editor with all content intact again
$bid = $old_bid;
// for now ...
}
}
$access = 0;
$old_bid = addslashes($old_bid);
if (DB_count($_TABLES['banner'], 'bid', $old_bid) > 0) {
$result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['banner']} WHERE bid = '{$old_bid}'");
$A = DB_fetchArray($result);
$access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
} else {
$access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon);
}
if ($access < 3 || !SEC_inGroup($group_id)) {
$display .= COM_siteHeader('menu', $MESSAGE[30]) . COM_showMessageText($MESSAGE[31], $MESSAGE[30]) . COM_siteFooter();
COM_accessLog("User {$_USER['username']} tried to illegally submit or edit banner {$bid}.");
echo $display;
exit;
} elseif (!empty($title) && !empty($description)) {
if ($categorydd != $LANG_BANNER_ADMIN[7] && !empty($categorydd)) {
$cid = addslashes($categorydd);
} else {
if ($categorydd != $LANG_BANNER_ADMIN[7]) {
//.........这里部分代码省略.........