function check_user_info(&$error) { global $CONFIG, $cpg_udb; //, $PHP_SELF; global $lang_register_php, $lang_register_confirm_email, $lang_continue, $lang_register_approve_email, $lang_register_activated_email, $lang_register_user_login; //$CONFIG['admin_activation'] = FALSE; //$CONFIG['admin_activation'] = TRUE; $user_name = trim(get_post_var('username')); $password = trim(get_post_var('password')); $password_again = trim(get_post_var('password_verification')); $email = trim(get_post_var('email')); $profile1 = addslashes($_POST['user_profile1']); $profile2 = addslashes($_POST['user_profile2']); $profile3 = addslashes($_POST['user_profile3']); $profile4 = addslashes($_POST['user_profile4']); $profile5 = addslashes($_POST['user_profile5']); $profile6 = addslashes($_POST['user_profile6']); $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_name = '" . addslashes($user_name) . "'"; $result = cpg_db_query($sql); if (mysql_num_rows($result)) { $error = '<li>' . $lang_register_php['err_user_exists']; return false; } mysql_free_result($result); if (utf_strlen($user_name) < 2) { $error .= '<li>' . $lang_register_php['err_uname_short']; } if (utf_strlen($password) < 2) { $error .= '<li>' . $lang_register_php['err_password_short']; } if ($password == $user_name) { $error .= '<li>' . $lang_register_php['err_uname_pass_diff']; } if ($password != $password_again) { $error .= '<li>' . $lang_register_php['err_password_mismatch']; } if (!eregi("^[_\\.0-9a-z\\-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,6}\$", $email)) { $error .= '<li>' . $lang_register_php['err_invalid_email']; } if ($error != '') { return false; } if (!$CONFIG['allow_duplicate_emails_addr']) { $sql = "SELECT user_id " . "FROM {$CONFIG['TABLE_USERS']} " . "WHERE user_email = '" . addslashes($email) . "'"; $result = cpg_db_query($sql); if (mysql_num_rows($result)) { $error = '<li>' . $lang_register_php['err_duplicate_email']; return false; } mysql_free_result($result); } /* if ($CONFIG['reg_requires_valid_email'] || $CONFIG['admin_activation']) { $active = 'NO'; list($usec, $sec) = explode(' ', microtime()); $seed = (float) $sec + ((float) $usec * 100000); srand($seed); $act_key = md5(uniqid(rand(), 1)); } else { $active = 'YES'; $act_key = ''; } */ $active = 'YES'; if ($CONFIG['enable_encrypted_passwords']) { $encpassword = md5($password); } else { $encpassword = $password; } $sql = "INSERT INTO {$CONFIG['TABLE_USERS']} " . "(user_regdate, user_active, user_actkey, user_name, user_password, user_email, user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6) " . "VALUES (NOW(), '{$active}', '{$act_key}', '" . addslashes($user_name) . "', '" . addslashes($encpassword) . "', '" . addslashes($email) . "', '{$profile1}', '{$profile2}', '{$profile3}', '{$profile4}', '{$profile5}', '{$profile6}')"; if ($CONFIG['log_mode']) { log_write('New user "' . addslashes($user_name) . '" created on ' . date("F j, Y, g:i a"), CPG_ACCESS_LOG); } $result = cpg_db_query($sql); /* //we disable the email verification etc and all the messages... cause we try to auto logon and redir to checkout if ($CONFIG['reg_requires_valid_email']) { if (!$CONFIG['admin_activation']==1) { //user gets activation email $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key; $template_vars = array( '{SITE_NAME}' => $CONFIG['gallery_name'], '{USER_NAME}' => $user_name, '{ACT_LINK}' => $act_link ); if (!cpg_mail($email, sprintf($lang_register_php['confirm_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_confirm_email, $template_vars)))) { cpg_die(CRITICAL_ERROR, $lang_register_php['failed_sending_email'], __FILE__, __LINE__); } } if ($CONFIG['admin_activation']==1) { msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_continue, $CONFIG['photo_shop_paypal_ssl_adress'].'?file=photo_shop/photo_shop_checkout'); } else { msg_box($lang_register_php['information'], $lang_register_php['thank_you'], $lang_continue, $CONFIG['photo_shop_paypal_ssl_adress'].'?file=photo_shop/photo_shop_checkout'); } } else { msg_box($lang_register_php['information'], $lang_register_php['acct_active'], $lang_continue, $CONFIG['photo_shop_paypal_ssl_adress'].'?file=photo_shop/photo_shop_checkout'); } */ // email notification to admin if ($CONFIG['reg_notify_admin_email']) { // get default language in which to inform the admin $lang_register_php_def = cpg_get_default_lang_var('lang_register_php'); $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email'); if ($CONFIG['admin_activation'] == 1) { $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key; $template_vars = array('{SITE_NAME}' => $CONFIG['gallery_name'], '{USER_NAME}' => $user_name, '{ACT_LINK}' => $act_link); cpg_mail('admin', sprintf($lang_register_php_def['notify_admin_request_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_approve_email_def, $template_vars))); } else { cpg_mail('admin', sprintf($lang_register_php_def['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_register_php_def['notify_admin_email_body'], $user_name)); } } //additional we try to login the user and redirect to the checkout // if (defined('UDB_INTEGRATION')) { $cpg_udb->login_page(); } if ($USER_DATA = $cpg_udb->login($user_name, $password, true)) { //photoshop_refresh($CONFIG['photo_shop_paypal_ssl_adress'].'?file=photo_shop/photo_shop_checkout'); photoshop_refresh($CONFIG['ecards_more_pic_target'] . '?file=photo_shop/photo_shop_checkout'); exit; } echo "Please login"; return true; }
function photoshop_process_post_data() { global $CONFIG; $field_list = array('type', 'name', 'price', 'max_items', 'size', 'ship'); $item_id_array = photoshop_get_post_var('item_id'); foreach ($item_id_array as $key => $item_id) { $set_statment = ''; foreach ($field_list as $field) { if ($field == 'type' || $field == 'name') { $set_statment .= $field . "='" . addslashes($_POST[$field . '_' . $item_id]) . "',"; } else { $set_statment .= $field . "='" . $_POST[$field . '_' . $item_id] . "',"; } } $set_statment = substr($set_statment, 0, -1); cpg_db_query("UPDATE {$CONFIG['TABLE_SHOP_CONFIG']} SET {$set_statment} WHERE id = '{$item_id}' LIMIT 1"); } photoshop_refresh($_SERVER['PHP_SELF'] . '?file=photo_shop/photo_shop_config'); }
function photoshop_add_item($pic_data) { global $CONFIG, $SHOP_CONFIG, $lang_photoshop, $album; if (!$CONFIG['photo_shop_enabled']) { //shop disabled return $pic_data; } $html = ""; $added = ""; $event = isset($_POST['event']) ? $_POST['event'] : null; //price override //if the shop is disabled to show for that album we return $pic_data //also we check if an override price is set $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$pic_data['aid']}"); while ($temp_data = mysql_fetch_array($results)) { if ($temp_data['gid'] == '-1') { return $pic_data; } $SHOP_CONFIG[$temp_data['gid']]['price'] = $temp_data['price']; } mysql_free_result($results); switch ($event) { case 'add_item': if (isset($_POST['pid'])) { $added = 'yes'; } $duplicate = photoshop_deep_in_array($_POST['pid'], $_POST['item_id'], $_SESSION['photoshop']['cart']); //search array if item is already in cart.. then ++ amount of that item if (is_numeric($duplicate)) { // only add 1 item if it's for the CD if ($_SESSION['photoshop']['cart'][$duplicate]['id'] != "CD" && $SHOP_CONFIG[$_POST['item_id']]['size'] == 0) { ++$_SESSION['photoshop']['cart'][$duplicate]['amount']; } else { //break; } } else { $_SESSION['photoshop']['cart'][] = array('pid' => $_POST['pid'], 'id' => $_POST['item_id'], 'amount' => '1', 'aid' => $pic_data['aid']); } $cookie_data = base64_encode(serialize($_SESSION['photoshop']['cart'])); setcookie($CONFIG['cookie_name'] . '_cart', $cookie_data, time() + 86400 * 30, $CONFIG['cookie_path']); break; } //the max download size from the shop config //$max_down_size = max($SHOP_CONFIG[]['size']); //fullsized image width/ height $imagesize[0] = $pic_data['pheight']; $imagesize[1] = $pic_data['pwidth']; //if orig exists, use its dimensions if (isset($CONFIG['enable_watermark'])) { // modpack installed ? Then we check for an orig image $image = $CONFIG['fullpath'] . $pic_data['filepath'] . $CONFIG['orig_pfx'] . $pic_data['filename']; if (file_exists($image)) { $imagesize = getimagesize($image); } } //loop through the items and create forms $html .= "<select name=\"item_id\" class=\"listbox_lang\">"; $temp_html = ''; foreach ($SHOP_CONFIG as $key => $value) { if ($value['type'] == 'photo') { //echo $value['size']; if ($value['price'] > 0) { //is the image > than the shops download size or it's a to print image if (max($imagesize[0], $imagesize[1]) >= $value['size'] || $value['size'] == 0) { $temp_html .= "<option value=\"{$value['id']}\">{$value['name']} - {$value['price']} {$CONFIG['photo_shop_currency']}</option>"; } } elseif ($value['price'] == -1) { if (max($imagesize[0], $imagesize[1]) >= $value['size'] || $value['size'] == 0) { $temp_html .= "<option value=\"{$value['id']}\">{$value['name']} - {$lang_photoshop['free']}</option>"; } } } elseif ($value['type'] == 'cd') { $cd = true; } } //if we have no items to sell (maybe the download sizes in shop config are > than teh image size) return; if ($temp_html == '') { return $pic_data; } $html .= $temp_html; $html .= $cd ? "<option value=\"CD\">{$lang_photoshop['CD']}</option>" : ''; $html .= "</select>"; $album == 'search' ? $referer = "displayimage.php?pos=-{$pic_data['pid']}" : ($referer = null); $shop_data = <<<EOT \t<table class="shop_table"> \t\t<tr> \t\t\t<td> \t\t\t<form action="{$referer}" method="post"> \t\t\t \t{$added}{$lang_photoshop['buy']} {$html} \t\t\t\t<input type="hidden" value="{$pic_data['pid']}" name="pid" /> \t\t\t\t<input type="hidden" value="add_item" name="event" /> \t\t\t<input type="submit" value="{$lang_photoshop['send']}" class="comment_button" /> \t\t\t</form> \t\t\t</td> \t\t</tr> \t</table> EOT; $pic_data['html'] = $shop_data . $pic_data['html']; $referer = $_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''); if ($added) { //this is not nice.. but the menu updates before the content. So if you add an item, the basket count can't match // -> we have to refresh the page twice... can be removed but than the counter is wrong till the user manually reloads photoshop_refresh($referer, $lang_photoshop['added']); exit; } return $pic_data; }
if (!defined('IN_COPPERMINE')) { die('Not in Coppermine...'); } //cart empty?? $cd_counter = photoshop_count_items(); if ($cd_counter['cd'] + $cd_counter['photo'] == 0) { pageheader($lang_photoshop['checkout']); starttable('100%', $lang_photoshop['checkout'], 1); msg_box('', $lang_photoshop['cart_empty'], $lang_continue, $CONFIG['ecards_more_pic_target'] . 'index.php'); pagefooter(); ob_end_flush(); exit; } //if user isn't logged in redirect to shop register/ login page if (!USER_ID) { photoshop_refresh($_SERVER['PHP_SELF'] . '?file=photo_shop/photo_shop_register'); exit; } //start html output pageheader($lang_photoshop['checkout']); starttable('100%', $lang_photoshop['checkout'], 1); endtable(); //start all the if else $cd_price = item_price($cd_counter['cd']); if ($cd_price[3] == false) { // more CD items than max defined -> warn and show link to cart echo '<tr><td><br>' . $cd_price[2] . '<br>' . $lang_photoshop['goto_cart_cd'] . '</td></tr>'; } elseif ($_POST['order'] == "confirmed" && $cd_counter['cd'] + $cd_counter['photo'] > 0) { //add to mysql, show confirmation and send email (user+admin) photoshop_prep_data($shop_array_cd, $shop_array_photos); //order_id++
function photoshop_create_cart_form($box) { global $SHOP_CONFIG, $CONFIG, $THEME_DIR, $lang_photoshop; $error = ''; $tot_price = 0; $cd_counter = 0; $photo_counter = 0; $photo_price = 0; $cd_price = 0; $link = $_SERVER['PHP_SELF'] . '?file=photo_shop/photo_shop_cart'; foreach ($_SESSION['photoshop']['cart'] as $key => $temp) { //foreach //to make it better readable $item_id = isset($_SESSION['photoshop']['cart'][$key]['id']) ? $_SESSION['photoshop']['cart'][$key]['id'] : ''; $pid = isset($_SESSION['photoshop']['cart'][$key]['pid']) ? $_SESSION['photoshop']['cart'][$key]['pid'] : ''; $amount = isset($_SESSION['photoshop']['cart'][$key]['amount']) ? $_SESSION['photoshop']['cart'][$key]['amount'] : ''; //get the thumb URL $select_columns = 'filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, title, aid'; $result = cpg_db_query("SELECT {$select_columns} from {$CONFIG['TABLE_PICTURES']} WHERE pid='{$pid}' LIMIT 1"); $row = mysql_fetch_array($result); //get price and name $price = $SHOP_CONFIG[$item_id]['price']; $name = $SHOP_CONFIG[$item_id]['name']; //price override $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$row['aid']}"); while ($temp_data = mysql_fetch_array($results)) { if ($temp_data['gid'] == $SHOP_CONFIG[$item_id]['id']) { $price = $temp_data['price']; } } mysql_free_result($results); //html resize thumb if ($CONFIG['enable_mini_thumbs'] == '1') { // if you use the modpack and have enabled mini thumbs -> these get used instead of html resized thumbs $thumb_url = get_pic_url($row, 'mini'); $destWidth = $CONFIG['mini_thumb_width']; $destHeight = $CONFIG['mini_thumb_height']; } else { $thumb_url = get_pic_url($row, 'thumb'); $new_size = 60; $ratio = max($row['pwidth'], $row['pheight']) / $new_size; $ratio = max($ratio, 1.0); $destWidth = (int) ($row['pwidth'] / $ratio); $destHeight = (int) ($row['pheight'] / $ratio); } if ($box == "photo" and isset($name)) { // it's a photo //here we check if the price is set to -1 (that's a free item, and we set price for display reasons back to 0.00) //do the same in cart and calc total an in function item_price, pricelist, photoshop_add_data if ($price == -1) { $price = "0.00"; } $photo_price += $amount * $price; $photo_counter += $amount; echo <<<EOT \t\t\t<tr> \t\t\t\t<td width="13%"><a href="displayimage.php?pos=-{$pid}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a></td> \t\t\t\t<td align="left" valign="top" width="30%"> \t\t\t\t\t<table style="font-size:10px"> \t\t\t\t\t\t<tr><td>{$lang_photoshop['title']}</td><td>{$row['title']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['filename']}</td><td>{$row['filename']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['size']}</td><td>{$row['pwidth']} x {$row['pheight']}</td></tr> \t\t\t\t\t</table> \t\t\t\t</td> \t\t\t\t<td align="left" width="15%">{$name}</td> \t\t\t\t<td align="left" width="15%">{$lang_photoshop['amount']} \t\t\t\t\t\t<input type="hidden" name="item_id[]" value="{$key}" /> \t\t\t\t\t \t<input type="text" class="textinput" maxlength="5" style="width: 20px" name="count{$key}" value="{$amount}"/> \t\t\t\t</td> \t\t\t\t<td align="left" width="20%"><span style="float:right">{$price} {$CONFIG['photo_shop_currency']} {$lang_photoshop['each']}</span></td> \t\t\t\t<td width="7%" align="center"> <a href="{$link}&event=delete&item={$key}&box=photo"> <img src="{$THEME_DIR}images/delete_small.gif" border="0" alt="" /> </a> \t\t\t\t</td> \t\t\t</tr> EOT; } elseif ($box == "cd" and isset($name)) { //we're viewing the cd box, but there are also print photos, lets calculate its price too $photo_price += $amount * $price; $photo_counter += $amount; } elseif ($box == "cd" and !isset($name)) { ++$cd_counter; // += $amount; echo <<<EOT \t\t\t<tr> \t\t\t\t<td width="13%"><a href="displayimage.php?pos=-{$pid}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a></td> \t\t\t\t<td align="left" valign="top" width="30%"> \t\t\t\t\t<table style="font-size:10px"> \t\t\t\t\t\t<tr><td>{$lang_photoshop['title']}</td><td>{$row['title']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['filename']}</td><td>{$row['filename']}</td></tr> \t\t\t\t\t\t<tr><td>{$lang_photoshop['size']}</td><td>{$row['pwidth']} x {$row['pheight']}</td></tr> \t\t\t\t\t</table> \t\t\t\t</td> \t\t\t\t<td align="left" width="15%"> </td> \t\t\t\t<td align="left" width="15%"> </td> \t\t\t\t<td align="left" width="20%"> </td> \t\t\t\t<td width="7%" align="center"> <a href="{$link}&event=delete&item={$key}&box={$box}"> <img src="{$THEME_DIR}images/delete_small.gif" border="0" alt="" /> </a> \t\t\t\t</td> \t\t\t</tr> EOT; } elseif ($box == "photo" and !isset($name)) { //viewing print photos, but that's for cd ++$cd_counter; // += $amount; } } //foreach if ($cd_counter > 0) { //if we have an item added to cd $pricelist = array(); foreach ($SHOP_CONFIG as $key => $value) { //foreach if ($value['type'] == "cd") { $pricelist[$key] = $value['max_items']; } } arsort($pricelist); foreach ($pricelist as $key => $val) { if ($val >= $cd_counter) { $pointer = $key; $check = true; //echo "$key - $val<br />"; } } $error = ''; $cd_price = $SHOP_CONFIG[$pointer]['price']; if (!$check == true) { $error = "<font color=\"red\">" . $lang_photoshop['to_many_pics'] . "</font> <br />"; $cd_price = ''; } } else { $cd_price = ''; } //end if we have an item added to cd if ($box == "photo" and $photo_counter < 1) { //uncomment, then the cart print refreshes to cd if print is empty photoshop_refresh($_SERVER['PHP_SELF'] . '?file=photo_shop/photo_shop_cart&box=cd'); } //sort($pricelist); if ($box == "cd" and $cd_counter > 0) { $to_go = $SHOP_CONFIG[$pointer]['max_items'] - $cd_counter; if ($to_go > 0) { $to_go = sprintf($lang_photoshop['to_go'], $to_go); } elseif ($to_go == 0) { $to_go = sprintf($lang_photoshop['to_go_full'], $to_go); } elseif ($cd_counter - $pricelist[0]['max_items'] > 0) { $to_go = sprintf($lang_photoshop['to_go_remove'], $cd_counter - $pricelist[count($pricelist) - 1]['max_items']); } echo <<<EOT \t\t\t<tr> \t\t\t\t<td align="right" colspan="6"> \t\t\t\t\t<hr size="1" /> \t\t\t\t\t{$to_go} \t\t\t\t</td> \t\t\t</tr> EOT; } $counter['cd'] = $cd_counter; $counter['photo'] = $photo_counter; $price_t[0] = $photo_price; $price_t[1] = $cd_price; echo photoshop_format_price($price_t, $counter, $error, 'html'); }