function theme_switch_page_start() { global $CONFIG, $USER, $REFERER; $superCage = Inspekt::makeSuperCage(); $mobile_browser = '0'; if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($superCage->server->getRaw('HTTP_USER_AGENT')))) { $mobile_browser++; } if (strpos(strtolower($superCage->server->getRaw('HTTP_ACCEPT')), 'application/vnd.wap.xhtml+xml') > 0 or ($superCage->server->keyExists('HTTP_X_WAP_PROFILE') or $superCage->server->keyExists('HTTP_PROFILE'))) { $mobile_browser++; } $mobile_ua = strtolower(substr($superCage->server->getRaw('HTTP_USER_AGENT'), 0, 4)); $mobile_agents = array('w3c ', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno', 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'oper', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-'); if (in_array($mobile_ua, $mobile_agents)) { $mobile_browser++; } if (strpos(strtolower($superCage->server->getRaw('ALL_HTTP'), 'operamini') > 0)) { $mobile_browser++; } if (strpos(strtolower($superCage->server->getRaw('HTTP_USER_AGENT')), ' ppc;') > 0) { $mobile_browser++; } if (strpos(strtolower($superCage->server->getRaw('HTTP_USER_AGENT')), 'windows ce') > 0) { $mobile_browser++; } elseif (strpos(strtolower($superCage->server->getRaw('HTTP_USER_AGENT')), 'windows') > 0) { $mobile_browser = 0; } if (strpos(strtolower($superCage->server->getRaw('HTTP_USER_AGENT')), 'iemobile') > 0) { $mobile_browser++; } if ($mobile_browser > 0) { define('MOBILE_BROWSER', TRUE); if (!$superCage->cookie->keyExists($CONFIG['cookie_name'] . '_mobile_theme')) { define('MOBILE_VIEW', TRUE); if ($CONFIG['theme'] != $CONFIG['theme_switch_mobile_theme'] && !$superCage->get->keyExists('theme')) { $USER['theme'] = $CONFIG['theme_switch_mobile_theme']; user_save_profile(); header('Location: ' . urldecode($REFERER)); } } } }
function pageheader($section, $meta = '') { global $CONFIG, $THEME_DIR; global $template_header, $lang_charset, $lang_text_dir; $custom_header = ''; if (defined('CMS_INTEGRATION')) { $custom_header = cms_pageheader($section, $meta); } header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"'); if (defined('CMS_INTEGRATION')) { cms_user_save_profile(); } else { user_save_profile(); } $template_vars = array('{LANG_DIR}' => $lang_text_dir, '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section, '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'], '{META}' => $meta, '{GAL_NAME}' => $CONFIG['gallery_name'], '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'], '{MAIN_MENU}' => theme_main_menu(), '{ADMIN_MENU}' => theme_admin_mode_menu(), '{CUSTOM_HEADER}' => $custom_header); echo template_eval($template_header, $template_vars); }
function process_login() { global $CONFIG, $HTTP_POST_VARS, $PHP_SELF, $USER; global $ONNEXT_SCRIPT, $ONBACK_SCRIPT, $WIZARD_BUTTONS; global $template_login_success, $template_login_failure; global $lang_login_php; $results = db_query("SELECT user_id, user_name, user_password FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '" . addslashes($HTTP_POST_VARS['username']) . "' AND BINARY user_password = '******'password']) . "' AND user_active = 'YES'"); if (mysql_num_rows($results)) { $USER_DATA = mysql_fetch_array($results); $cookie_life_time = 86400; setcookie($CONFIG['cookie_name'] . '_uid', $USER_DATA['user_id'], time() + $cookie_life_time, $CONFIG['cookie_path']); setcookie($CONFIG['cookie_name'] . '_pass', md5($HTTP_POST_VARS['password']), time() + $cookie_life_time, $CONFIG['cookie_path']); $USER['am'] = 1; user_save_profile(); $params = array('{WELCOME}' => sprintf($lang_login_php['welcome'], USER_NAME), '{POST_ACTION}' => $PHP_SELF . '?cmd=publish'); echo template_eval($template_login_success, $params); } else { $params = array('{ERROR}' => $lang_login_php['err_login'], '{POST_ACTION}' => $PHP_SELF . '?cmd=publish'); echo template_eval($template_login_failure, $params); } $ONNEXT_SCRIPT = 'dummy.submit();'; $ONBACK_SCRIPT = 'dummy.submit();'; $WIZARD_BUTTONS = 'true,true,false'; }
$login_failed = ''; $cookie_warning = ''; if ($superCage->post->keyExists('submitted')) { if ($USER_DATA = $cpg_udb->login($superCage->post->getEscaped('username'), $superCage->post->getEscaped('password'), $superCage->post->getInt('remember_me'))) { //$referer=preg_replace("'&'","&",$referer); // Write the log entry if ($CONFIG['log_mode'] == CPG_LOG_ALL) { log_write('The user ' . $USER_DATA['user_name'] . ' (user ID ' . $USER_DATA['user_id'] . ") logged in.", CPG_ACCESS_LOG); } // Set the language preference $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_language = '{$USER['lang']}' WHERE user_id = {$USER_DATA['user_id']}"; $result = cpg_db_query($sql); $cpg_udb->authenticate(); if (!$USER_DATA['has_admin_access']) { unset($USER['am']); user_save_profile(); } $redirect = $CPG_REFERER && strpos($CPG_REFERER, 'login.php') === false ? $CPG_REFERER : 'index.php'; $pending_approvals = $USER_DATA['has_admin_access'] && cpg_get_pending_approvals() > 0 ? '<br />' . $lang_gallery_admin_menu['upl_app_title'] : ''; cpgRedirectPage($redirect, $lang_login_php['login'], sprintf($lang_login_php['welcome'], $USER_DATA['user_name']) . $pending_approvals, 3, 'success'); exit; } else { // Write the log entry log_write("Failed login attempt at IP {$hdr_ip} with Username: "******"2" class="tableh2"> <div id="cpgMessage" class="cpg_user_message cpg_message_validation"> {$lang_login_php['err_login']} </div> </td>
function pageheader($section, $meta = '') { global $CONFIG, $THEME_DIR; global $template_header, $lang_charset, $lang_text_dir; $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']); $charset = $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset']; header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"'); header("Content-Type: text/html; charset={$charset}"); user_save_profile(); $template_vars = array('{LANG_DIR}' => $lang_text_dir, '{TITLE}' => theme_page_title($section), '{CHARSET}' => $charset, '{META}' => $meta, '{GAL_NAME}' => $CONFIG['gallery_name'], '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'], '{SYS_MENU}' => theme_main_menu('sys_menu'), '{SUB_MENU}' => theme_main_menu('sub_menu'), '{ADMIN_MENU}' => theme_admin_mode_menu(), '{CUSTOM_HEADER}' => $custom_header, '{JAVASCRIPT}' => theme_javascript_head(), '{MESSAGE_BLOCK}' => theme_display_message_block()); echo template_eval($template_header, $template_vars); }
/** * display_thumbnails() * * Generates data to display thumbnails of pictures in an album * * @param mixed $album Either the album ID or the meta album name * @param integer $cat Either the category ID or album ID if negative * @param integer $page Page number to display * @param integer $thumbcols * @param integer $thumbrows * @param boolean $display_tabs **/ function display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs) { global $CONFIG, $AUTHORIZED, $USER; global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units, $lang_common; $thumb_per_page = $thumbcols * $thumbrows; $lower_limit = ($page - 1) * $thumb_per_page; $pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page); $total_pages = ceil($thumb_count / $thumb_per_page); $i = 0; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . "\n" . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . "\n" . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . "\n" . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $album_date_fmt); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } //thumb cropping - if we display a system thumb we calculate the dimension by any and not ex if ($row['system_icon'] == 'true') { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); } $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit; $thumb_list[$i]['pid'] = $row['pid']; $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\"/>"; $thumb_list[$i]['caption'] = bb_decode($row['caption_text']); $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['aid'] = $row['aid']; $thumb_list[$i]['pwidth'] = $row['pwidth']; $thumb_list[$i]['pheight'] = $row['pheight']; } // Add a hit to album counter if it is a numeric album if (is_numeric($album)) { // Create an array to hold the album id for hits (if not created) if (!isset($USER['liv_a']) || !is_array($USER['liv_a'])) { $USER['liv_a'] = array(); } // Add 1 to album hit counter if (!USER_IS_ADMIN && !in_array($album, $USER['liv_a']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) { add_album_hit($album); if (count($USER['liv_a']) > 4) { array_shift($USER['liv_a']); } array_push($USER['liv_a'], $album); user_save_profile(); } } $date = isset($_GET['date']) ? cpgValidateDate($_GET['date']) : null; theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs, 'thumb', $date); } else { theme_no_img_to_display($album_name); } }
function pageheader_mini($section, $javascript = false) { global $CONFIG; global $lang_charset, $lang_text_dir; $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']); $charset = $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset']; header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"'); header("Content-Type: text/html; charset={$charset}"); user_save_profile(); if ($javascript) { $js = theme_javascript_head(); } else { $js = ''; } echo <<<EOT <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="{$lang_text_dir}"> <head> <meta http-equiv="Content-Type" content="text/html; charset={$charset}" /> <meta http-equiv="Pragma" content="no-cache" /> <title>{$section}</title> <link rel="stylesheet" href="css/coppermine.css" type="text/css" /> <link rel="stylesheet" href="themes/{$CONFIG['theme']}/style.css" type="text/css" /> <link rel="shortcut icon" href="favicon.ico" /> {$js} </head> <body> EOT; }
function send_ecard($recipient_email, $recipient_name, $greetings, $msg_content, $sender_name, $sender_email, $image, $n_picname, $redirect_link) { global $_SERVER, $xoopsUser, $xoopsModuleConfig, $USER, $xoopsDB; global $xoopsModule, $xoopsConfig, $myts; if (is_object($xoopsUser)) { $s_uid = "|| sender_uid = " . $xoopsUser->uid(); } else { $s_uid = ""; } $s_time = time() - 3600; $result = $xoopsDB->query("SELECT * from " . $xoopsDB->prefix("xcgal_ecard") . " WHERE (sess_id ='" . session_id() . "' || sender_email = '" . $myts->makeTboxData4Save($sender_email) . "' || sender_ip ='" . $_SERVER['REMOTE_ADDR'] . "' " . $s_uid . ") AND s_time > " . $s_time . ""); if ($xoopsDB->getRowsNum($result) >= $xoopsModuleConfig['ecards_per_hour']) { redirect_header('index.php', 2, sprintf(_MD_CARD_PERHOUR, $xoopsModuleConfig['ecards_per_hour'])); return; } if (is_array($USER['ecard']) && count($USER['ecard']) >= $xoopsModuleConfig['ecards_per_hour']) { $s_count = 0; foreach ($USER['ecard'] as $sent) { if ($sent > $s_time) { $s_count++; } } if ($s_count >= $xoopsModuleConfig['ecards_per_hour']) { redirect_header('index.php', 2, sprintf(_MD_CARD_PERHOUR, $xoopsModuleConfig['ecards_per_hour'])); return; } } if (count($USER['ecard']) >= $xoopsModuleConfig['ecards_per_hour'] + 2) { array_shift($USER['ecard']); } $delete_time = time() - $xoopsModuleConfig['ecards_saved_db'] * 86400; $xoopsDB->query("DELETE from " . $xoopsDB->prefix("xcgal_ecard") . " WHERE s_time < " . $delete_time . ""); if (is_object($xoopsUser)) { $sender_uid = $xoopsUser->uid(); } else { $sender_uid = 0; } $e_id = get_message_id(); $sql = "INSERT INTO " . $xoopsDB->prefix("xcgal_ecard") . " (e_id, sess_id, sender_ip, sender_uid, sender_name, sender_email, recipient_name, recipient_email, greetings, message, s_time, pid, picked) VALUES ('" . $e_id . "', '" . session_id() . "', '" . $_SERVER['REMOTE_ADDR'] . "', {$sender_uid}, '" . $myts->makeTboxData4Save($sender_name) . "', '" . $myts->makeTboxData4Save($sender_email) . "', '" . $myts->makeTboxData4Save($recipient_name) . "', '" . $myts->makeTboxData4Save($recipient_email) . "', '" . $myts->makeTboxData4Save($greetings) . "', '" . $myts->makeTareaData4Save($msg_content) . "', " . time() . ", {$image}, 0)"; if (!$xoopsDB->queryF($sql)) { redirect_header('index.php', 2, _MD_CARD_NOTINDB); } $xoopsDB->queryF("UPDATE " . $xoopsDB->prefix("xcgal_pictures") . " SET sent_card=sent_card+1 WHERE pid='" . $image . "'"); $USER['ecard'][] = time(); user_save_profile(); $myts =& MyTextSanitizer::getInstance(); $xoopsMailer =& getMailer(); $xoopsMailer->setFromEmail($sender_email); $xoopsMailer->setFromName($sender_name); $ecardText = $xoopsModuleConfig['ecards_text']; $ecardText = str_replace("{R_NAME}", $recipient_name, $ecardText); $ecardText = str_replace("{R_MAIL}", $recipient_email, $ecardText); $ecardText = str_replace("{S_NAME}", $sender_name, $ecardText); $ecardText = str_replace("{S_MAIL}", $sender_email, $ecardText); $ecardText = str_replace("{SAVE_DAYS}", $xoopsModuleConfig['ecards_saved_db'], $ecardText); $ecardText = str_replace("{X_SITEURL}", XOOPS_URL, $ecardText); $ecardText = str_replace("{X_SITENAME}", $xoopsConfig['sitename'], $ecardText); $ecardText = str_replace("{CARD_LINK}", XOOPS_URL . "/modules/xcgal/displayecard.php?data=" . $e_id, $ecardText); $xoopsMailer->setToEmails($recipient_email); $xoopsMailer->setSubject(sprintf(_MD_CARD_ECARD_TITLE, $sender_name)); $xoopsMailer->setBody($ecardText); if ($xoopsModuleConfig['ecards_type'] != 1) { $htmlCard = build_html_card($sender_name, $sender_email, $n_picname, $msg_content, $greetings, $e_id); $xoopsMailer->multimailer->IsHTML(true); $xoopsMailer->setBody($htmlCard); } $xoopsMailer->useMail(); $xoopsMailer->send(true); $ev_success = $xoopsMailer->getSuccess(); //$ev_errors = $xoopsMailer->getErrors(); #enable to show detailed errors if (!empty($ev_success)) { redirect_header($redirect_link, 2, _MD_CARD_SEND_SUCCESS); exit; } else { redirect_header($redirect_link, 2, _MD_CARD_SEND_FAILED . "<br />" . $ev_errors); exit; } }
/** * display_slideshow() * * gets data for thumbnails in an album for the film stript using Ajax call * * this added by Nuwan Sameera Hettiarachchi * * @param integer $album * @param integer $cat * @param integer $pos **/ function &display_slideshow($pos, $ajax_show = 0) { global $CONFIG, $album, $pid, $slideshow, $USER; $superCage = Inspekt::makeSuperCage(); $Pic = array(); $Pid = array(); $Title = array(); $i = 0; $j = 0; /** get the pic details by querying database*/ $pic_data = get_pic_data($album, $pic_count, $album_name, $pos, 1, false); /** calculate total amount of pic a perticular album */ if ($ajax_show == 0) { set_js_var('Pic_count', $pic_count); } foreach ($pic_data as $picture) { if (is_image($picture['filename'])) { if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($picture['pwidth'], $picture['pheight'])) { $picture_url = get_pic_url($picture, 'normal'); } else { $picture_url = get_pic_url($picture, 'fullsize'); } $Pic[$i] = htmlspecialchars($picture_url, ENT_QUOTES); /*if ($picture['pid'] == $pid) { $j = $i; $start_img = $picture_url; }*/ //$j and $start_img are never used } else { $pic_url = get_pic_url($picture, 'thumb'); $Pic[$i] = htmlspecialchars($pic_url); } $Pid[$i] = $picture['pid']; $Title[$i] = $picture['title'] ? $picture['title'] : $picture['filename']; $i++; } /** set variables to jquery.slideshow.js */ set_js_var('Time', $slideshow); set_js_var('Pid', $pid); /*if (!$i) { $Pic[0] = 'images/thumb_document.jpg'; }*/ // Add the hit if slideshow hits are enabled in config if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && $CONFIG['slideshow_hits'] != 0) { // Add 1 to hit counter if (!in_array($Pid['0'], $USER['liv']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) { add_hit($Pid['0']); if (count($USER['liv']) > 4) { array_shift($USER['liv']); } array_push($USER['liv'], $Pid['0']); user_save_profile(); } } /** show slide show on first time*/ if ($ajax_show == 0) { theme_slideshow($Pic['0'], $Title['0']); } /** now we make a array to encode*/ $dataArray = array('url' => $Pic['0'], 'title' => $Title['0'], 'pid' => $Pid['0']); $dataJson = json_encode($dataArray); /** send variable to javascript script*/ if ($ajax_show == 1) { header("Content-Type: text/plain"); echo $dataJson; } }
function process_login() { global $CONFIG, $USER, $CPG_PHP_SELF; global $ONNEXT_SCRIPT, $ONBACK_SCRIPT, $WIZARD_BUTTONS; global $template_login_success, $template_login_failure, $template_login; global $lang_login_php, $cpg_udb; $superCage = Inspekt::makeSuperCage(); $tt = 'worked'; if ($USER_DATA = $cpg_udb->login($superCage->post->getEscaped('username'), $superCage->post->getEscaped('password'))) { $USER['am'] = 1; user_save_profile(); $params = array('{WELCOME}' => sprintf($lang_login_php['welcome'], USER_NAME), '{POST_ACTION}' => trim($CONFIG['site_url'], '/') . '/' . $CPG_PHP_SELF . '?cmd=publish'); echo template_eval($template_login_success, $params); } else { $params = array('{ERROR}' => $lang_login_php['err_login'], '{POST_ACTION}' => trim($CONFIG['site_url'], '/') . '/' . $CPG_PHP_SELF . '?cmd=publish'); echo template_eval($template_login_failure, $params); } $ONNEXT_SCRIPT = 'dummy.submit();'; $ONBACK_SCRIPT = 'dummy.submit();'; $WIZARD_BUTTONS = 'true,true,false'; }
function process_login() { global $CONFIG, $USER, $CPG_PHP_SELF; //$PHP_SELF, global $ONNEXT_SCRIPT, $ONBACK_SCRIPT, $WIZARD_BUTTONS; global $template_login_success, $template_login_failure, $template_login; global $lang_login_php, $cpg_udb; $superCage = Inspekt::makeSuperCage(); $tt = 'worked'; //sanitizing the login/pass $username = $superCage->post->getMatched('username', '/^[0-9A-Za-z\\/_]+$/'); $username = $username[1]; $password = $superCage->post->getMatched('password', '/^[0-9A-Za-z\\/_]+$/'); $password = $password[1]; // if ( $USER_DATA = $cpg_udb->login(addslashes($_POST['username']), addslashes($_POST['password'])) ) { if ($USER_DATA = $cpg_udb->login(addslashes($username), addslashes($password))) { $USER['am'] = 1; user_save_profile(); $params = array('{WELCOME}' => sprintf($lang_login_php['welcome'], USER_NAME), '{POST_ACTION}' => trim($CONFIG['site_url'], '/') . '/' . $CPG_PHP_SELF . '?cmd=publish'); echo template_eval($template_login_success, $params); } else { $params = array('{ERROR}' => $lang_login_php['err_login'], '{POST_ACTION}' => trim($CONFIG['site_url'], '/') . '/' . $CPG_PHP_SELF . '?cmd=publish'); echo template_eval($template_login_failure, $params); } $ONNEXT_SCRIPT = 'dummy.submit();'; $ONBACK_SCRIPT = 'dummy.submit();'; $WIZARD_BUTTONS = 'true,true,false'; }
/** * display_thumbnails() * * Generates data to display thumbnails of pictures in an album * * @param mixed $album Either the album ID or the meta album name * @param integer $cat Either the category ID or album ID if negative * @param integer $page Page number to display * @param integer $thumbcols * @param integer $thumbrows * @param boolean $display_tabs **/ function fetchcontent_display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs) { global $CONFIG, $USER, $LINEBREAK; global $lang_date, $lang_display_thumbnails, $lang_byte_units, $lang_common; $superCage = Inspekt::makeSuperCage(); $thumb_per_page = $thumbcols * $thumbrows; $lower_limit = ($page - 1) * $thumb_per_page; $pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page); $total_pages = ceil($thumb_count / $thumb_per_page); $i = 0; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . $LINEBREAK . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . $LINEBREAK . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . $LINEBREAK . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $lang_date['album']); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } // thumb cropping - if we display a system thumb we calculate the dimension by any and not ex if (array_key_exists('system_icon', $row) && $row['system_icon'] == true) { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); } $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit; $thumb_list[$i]['pid'] = $row['pid']; // $thumb_list[$i]['image'] = '<img src="' . $pic_url . '" class="image" ' . $image_size['geom'] . ' border="0" alt="' . $row['filename'] . '" title="' . $pic_title . '" />'; // commented out for fetchcontent $thumb_list[$i]['thumbpath'] = $pic_url; // Added for fetchcontent $thumb_list[$i]['thumbsize'] = $image_size['geom']; // Added for fetchcontent $thumb_list[$i]['caption'] = bb_decode($row['caption_text']); $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['aid'] = $row['aid']; $thumb_list[$i]['pwidth'] = $row['pwidth']; $thumb_list[$i]['pheight'] = $row['pheight']; // cpg1.5: new thumb fields below $thumb_list[$i]['title'] = $row['title']; $thumb_list[$i]['description'] = $row['caption']; $thumb_list[$i]['filepath'] = $row['filepath']; $thumb_list[$i]['filename'] = $row['filename']; $thumb_list[$i]['filesize'] = $row['filesize']; $thumb_list[$i]['msg_id'] = isset($row['msg_id']) ? $row['msg_id'] : ''; // needed for get_pic_pos() } // Add a hit to album counter if it is a numeric album if (is_numeric($album)) { // Create an array to hold the album id for hits (if not created) if (!isset($USER['liv_a']) || !is_array($USER['liv_a'])) { $USER['liv_a'] = array(); } // Add 1 to album hit counter if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && !in_array($album, $USER['liv_a']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) { add_album_hit($album); if (count($USER['liv_a']) > 4) { array_shift($USER['liv_a']); } array_push($USER['liv_a'], $album); user_save_profile(); } } //Using getRaw(). The date is sanitized in the called function. $date = $superCage->get->keyExists('date') ? cpgValidateDate($superCage->get->getRaw('date')) : null; // This is the difference to the original function taken from Coppermine's core: we don't process the data further, but put it into an array and return it $return = array('thumb_list' => $thumb_list, 'thumb_count' => $thumb_count, 'album_name' => $album_name, 'aid' => $album, 'cat' => $cat, 'page' => $page, 'total_pages' => $total_pages, 'sort_options' => is_numeric($album), 'display_tabs' => $display_tabs, 'mode' => 'thumb', 'date' => $date); } elseif (is_numeric($album)) { $return = array('album_name' => $album_name); } return $return; }
function process_login() { global $CONFIG, $USER; //$PHP_SELF, global $ONNEXT_SCRIPT, $ONBACK_SCRIPT, $WIZARD_BUTTONS; global $template_login_success, $template_login_failure, $template_login; global $lang_login_php, $cpg_udb; $tt = 'worked'; if ($USER_DATA = $cpg_udb->login(addslashes($_POST['username']), addslashes($_POST['password']))) { $USER['am'] = 1; user_save_profile(); $params = array('{WELCOME}' => sprintf($lang_login_php['welcome'], USER_NAME), '{POST_ACTION}' => trim($CONFIG['site_url'], '/') . '/' . $_SERVER['PHP_SELF'] . '?cmd=publish'); echo template_eval($template_login_success, $params); } else { $params = array('{ERROR}' => $lang_login_php['err_login'], '{POST_ACTION}' => trim($CONFIG['site_url'], '/') . '/' . $_SERVER['PHP_SELF'] . '?cmd=publish'); echo template_eval($template_login_failure, $params); } $ONNEXT_SCRIPT = 'dummy.submit();'; $ONBACK_SCRIPT = 'dummy.submit();'; $WIZARD_BUTTONS = 'true,true,false'; }
/** * display_thumbnails() * * Generates data to display thumbnails of pictures in an album * * @param mixed $album Either the album ID or the meta album name * @param integer $cat Either the category ID or album ID if negative * @param integer $page Page number to display * @param integer $thumbcols * @param integer $thumbrows * @param boolean $display_tabs **/ function display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs) { global $CONFIG, $AUTHORIZED, $USER; global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units, $lang_common; $superCage = Inspekt::makeSuperCage(); $thumb_per_page = $thumbcols * $thumbrows; $lower_limit = ($page - 1) * $thumb_per_page; $pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page); $total_pages = ceil($thumb_count / $thumb_per_page); $i = 0; if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . "\n" . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . "\n" . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . "\n" . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $album_date_fmt); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } //thumb cropping - if we display a system thumb we calculate the dimension by any and not ex if ($row['system_icon'] == 'true') { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); } $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit; $thumb_list[$i]['pid'] = $row['pid']; $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\"/>"; $thumb_list[$i]['caption'] = bb_decode($row['caption_text']); $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['aid'] = $row['aid']; $thumb_list[$i]['pwidth'] = $row['pwidth']; $thumb_list[$i]['pheight'] = $row['pheight']; if (defined('API_CALL')) { $thumb_list[$i]['title'] = $row['title']; $thumb_list[$i]['filename'] = get_pic_url($row); } } // Print out XML photo list and exit if (defined('API_CALL')) { echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; echo $superCage->post->getAlpha('album') ? "<" . $superCage->post->getAlpha('album') . ">\n" : "<api_search>\n"; foreach ($thumb_list as $pic) { $file = preg_replace('/%7E/', '~', $pic['filename']); echo " <picture id=\"{$pic['pid']}\">\n"; echo " <title>{$pic['title']}</title>\n"; echo " <file>{$file}</file>\n"; echo " <width>{$pic['pwidth']}</width>\n"; echo " <height>{$pic['pheight']}</height>\n"; echo " </picture>\n"; } echo $superCage->post->getAlpha('album') ? "</" . $superCage->post->getAlpha('album') . ">" : "</api_search>"; exit; } // Add a hit to album counter if it is a numeric album if (is_numeric($album)) { // Create an array to hold the album id for hits (if not created) if (!isset($USER['liv_a']) || !is_array($USER['liv_a'])) { $USER['liv_a'] = array(); } // Add 1 to album hit counter if (!USER_IS_ADMIN && !in_array($album, $USER['liv_a']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) { add_album_hit($album); if (count($USER['liv_a']) > 4) { array_shift($USER['liv_a']); } array_push($USER['liv_a'], $album); user_save_profile(); } } //Using getRaw(). The date is sanitized in the called function. $date = $superCage->get->keyExists('date') ? cpgValidateDate($superCage->get->getRaw('date')) : null; theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs, 'thumb', $date); } else { if (defined('API_CALL')) { new OAuthException('No pictures found'); } else { theme_no_img_to_display($album_name); } } }