NoRespect |
02-17-2006 03:15 AM |
Tried to install this tonite, uploaded everything, and get the following...no idea....
Quote:
Importing Product, Please Wait...
[:]
db->query_read(" SELECT items.*, category.name AS categoryname, category.allowedgroups AS categoryallowedgroups, category.deniedgroups AS categorydeniedgroups FROM " . TABLE_PREFIX . "estoreitems AS items LEFT JOIN " . TABLE_PREFIX . "estorecategory AS category ON (category.categoryid = items.category) WHERE items.active = 1 " . $wherestr . " ORDER BY displayorder ")) { // start caching the items while ($item = $vbulletin->db->fetch_array($items)) { // cache this item $founditems[$item[itemid]] = $item; } } // return the found items return $founditems; } // function to check if the user has enough points to cover the cost of the item // $xfertype = 0 means that the user is trying to remove an option // $xfertype = 1 means that the user is trying to purchase an option function estore_calculate_total_cost($action) { global $vbulletin; // force cost to be 0 if its empty if (empty($action['cost'])) { $action['cost'] = 0; } // set the current userpoints $action['finalpoints'] = $vbulletin->userinfo[$vbulletin->options['ebux_pointsfield']]; $action['userpoints'] = vb_number_format($action['finalpoints'], $vbulletin->options['estore_decimalplaces']); // set the current bankpoints $action['finalbankpoints'] = $vbulletin->userinfo[$vbulletin->options['ebux_bankfield']]; $action['bankpoints'] = vb_number_format($action['finalbankpoints'], $vbulletin->options['estore_decimalplaces']); // check if the items quantity needs to be updated if ($action['defquantity'] && (!$action['refilldateline'] || ($action['refilldateline'] < TIMENOW))) { // refill the item stock $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "estoreitems SET quantity = defquantity, refilldateline = " . (TIMENOW + $vbulletin->options['estore_defaultrefillrate']) . " WHERE itemid = '" . $action['itemid'] . "' "); // update the item quantity $action['quantity'] = $action['defquantity']; } // check if this usergroup gets a discount (discount is on the base price, not the taxed price) if ($vbulletin->userinfo['permissions']['estorediscountrate'] > 0) { // verify the discountrate is < 100 if ($vbulletin->userinfo['permissions']['estorediscountrate'] <= 100) { // generate the overall discount rate $action['discountrate'] = ((100 - $vbulletin->userinfo['permissions']['estorediscountrate']) / 100); // calculate the item cost with the discounted rate $action['cost'] = $action['cost'] * $action['discountrate']; } } // check if this user gets a senior member discount if (($vbulletin->options['estore_seniordiscountrate'] != 0) && !empty($vbulletin->userinfo['birthday'])) { // get the current variables properly $curyear = date('Y'); $curmonth = date('m'); $curday = date('d'); // get the birthday variables properly list($usermonth, $userday, $useryear) = explode("-", $vbulletin->userinfo['birthday']); // verify that the $useryear is valid if (($useryear >= 1900) && ($useryear < $curyear)) { // verify that the $useryear is < $curyear found $userage = 0; if ($useryear < $curyear) { // start calculating the $userage $userage = $curyear - $useryear; // check if the $curmonth is <= $usermonth if ($curmonth < $usermonth) { // user has not had a birthday this year yet $userage--; } else if ($curmonth == $usermonth) { // check if the $userday is < $curday if ($curday < $userday) { // user has not had a birthday this year yet $userage--; } } } // check if the user gets a senior discount or not if ($userage && ($userage >= $vbulletin->options['estore_seniordiscountage'])) { // generate the overall discount rate $action['discountrate'] = ((100 - $vbulletin->options['estore_seniordiscountrate']) / 100); // calculate the item cost with the discounted rate $action['cost'] = $action['cost'] * $action['discountrate']; } } } // check if this user gets a loyal member discount if ($vbulletin->options['estore_loyalmemberdiscountrate'] != 0) { // check if this user has been registered for more than x days if ((TIMENOW - $vbulletin->userinfo['joindate']) > ($vbulletin->options['estore_loyalmembertimeframe'] * 86400)) { // generate the overall discount rate $action['discountrate'] = ((100 - $vbulletin->options['estore_loyalmemberdiscountrate']) / 100); // calculate the item cost with the discounted rate $action['cost'] = $action['cost'] * $action['discountrate']; } } // generate the item cost with the item tax percentage $action['itemcost'] = $action['cost']; if ($action['tax'] > 0) { // generate the item taxes $action['itemtax'] = (($action['tax'] / 100) + 1.00); // calculate the itemcost with the item tax too $action['itemcost'] = $action['itemcost'] * $action['itemtax']; } // now generate the final item cost with the overall tax percentage $action['finalcost'] = $action['itemcost']; if ($vbulletin->options['estore_federaltaxpercent'] > 0) { // generate the federal taxes $action['federaltax'] = (($vbulletin->options['estore_federaltaxpercent'] / 100) + 1.00); // calculate the finalcost with the federal tax too $action['finalcost'] = $action['finalcost'] * $action['federaltax']; } // round off the 'finalcost' $action['finalcost'] = round($action['finalcost'], 5); // format all of the numbers properly $action['cost'] = vb_number_format($action['cost'], $vbulletin->options['estore_decimalplaces']); $action['totalcost'] = vb_number_format($action['finalcost'], $vbulletin->options['estore_decimalplaces']); $action['tax'] = vb_number_format($action['tax'], $vbulletin->options['estore_decimalplaces']); // check if the user has enough points if ($action['finalpoints'] >= $action['finalcost']) { // set that this action should not be allowed $action['isallowed'] = 0; return $action; } // check if there are some items left if (($action['cost'] != 0) && ($action['quantity'] == 0)) { // set that this action should not be allowed $action['isallowed'] = 0; return $action; } // set that this action seems to be allowable $action['isallowed'] = 1; return $action; } // function to validate the costs function estore_validate_cost($action) { // check if the user has enough points if ($action['finalpoints'] < $action['finalcost']) { // display error, not enough points eval(standard_error(fetch_error('estore_not_enough _points'))); } // check if there are some items left if (($action['defquantity'] != 0) && ($action['quantity'] == 0)) { // display error, no items left eval(standard_error(fetch_error('estore_item_out_o f_stock'))); } } // build the proper $allowedusergroups & $deniedusergroups function estore_build_proper_usergroups($action, $estorecategories) { // get the category's allowedgroups $categoryallowedgroups = $estorecategories[$action['category']]['allowedgroups']; // check if the categoryallowedgroups is empty $allowedgroups = array(); if (!$action['overridepermissions'] && !empty($categoryallowedgroups)) { // explode these into an array $usergroups = explode(",", $categoryallowedgroups); // process each usergroup foreach($usergroups AS $usergroupid) { // add this to the allowedgroups $allowedgroups[$usergroupid] = $usergroupid; } } // now check if it has any addition option allowedgroups to merge in if (!empty($action['allowedgroups'])) { // explode these into an array $usergroups = explode(",", $action['allowedgroups']); // process each usergroup foreach($usergroups AS $usergroupid) { // add this to the allowedgroups $allowedgroups[$usergroupid] = $usergroupid; } } // get the category's denied usergroups$categorydeniedgroups = $estorecategories[$action['category']]['deniedgroups']; // check if the categorydeniedgroups is empty $deniedgroups = array(); if (!$action['overridepermissions'] && !empty($categorydeniedgroups)) { // explode these into an array $usergroups = explode(",", $categorydeniedgroups); // process each usergroup foreach($usergroups AS $usergroupid) { // add this to the deniedgroups $deniedgroups[$usergroupid] = $usergroupid; } } // now check if it has any addition option deniedgroups to merge in if (!empty($action['deniedgroups'])) { // explode these into an array $usergroups = explode(",", $action['deniedgroups']); // process each usergroup foreach($usergroups AS $usergroupid) { // add this to the deniedgroups $deniedgroups[$usergroupid] = $usergroupid; } } // rebuild the final allowedgroups $action['allowedgroups'] = ''; foreach($allowedgroups AS $usergroupid) { // check if it needs a comma separation if (!empty($action['allowedgroups'])) { $action['allowedgroups'] .= ","; } $action['allowedgroups'] .= $usergroupid; } // rebuild the final deniedgroups $action['deniedgroups'] = ''; foreach($deniedgroups AS $usergroupid) { // check if it needs a comma separation if (!empty($action['deniedgroups'])) { $action['deniedgroups'] .= ","; } $action['deniedgroups'] .= $usergroupid; } // return the new action fields return $action; } // function to check if the user is in the allowed usergroups function estore_check_allowed($userinfo, $allowedgroups, $deniedgroups) { // set it to return disabled by default $isallowed = 0; // convert the groups to an array $allowed = explode(",", $allowedgroups); $denied = explode(",", $deniedgroups); // check if the user is in the allowedgroups if (is_member_of($userinfo, $allowed)) { $isallowed = 1; } // check if the user is in the deniedgroups if (is_member_of($userinfo, $denied)) { $isallowed = 0; } // return if they are allowed or not return $isallowed; } // function to add an action to the history function estore_add_history($userinfo, $action) { // calculate the expired time if ($action['expirydate']) { // calculate the $expirydate $expirydate = TIMENOW + ($action['expirydate'] * 86400); } else { // set the $expirydate to 0 $expirydate = '0'; } // clear out the $newhistory array $newhistory = array(); // always add some things into the array $newhistory['itemid'] = $action['itemid']; $newhistory['finalcost'] = $action['finalcost']; $newhistory['dateline'] = TIMENOW; $newhistory['expires'] = $expirydate; if (!empty($action['threadid'])) { $newhistory['threadid'] = $action['threadid']; } if (!empty($action['forumid'])) { $newhistory['forumid'] = $action['forumid']; } if (!empty($action['usergroupid'])) { $newhistory['usergroupid'] = $action['usergroupid']; } if (!empty($action['touserid'])) { $newhistory['touserid'] = $action['touserid']; } if (!empty($action['tousername'])) { $newhistory['tousername'] = $action['tousername']; } if (!empty($action['fromuserid'])) { $newhistory['fromuserid'] = $action['fromuserid']; } if (!empty($action['fromusername'])) { $newhistory['fromusername'] = $action['fromusername']; } if (!empty($action['reason'])) { $newhistory['reason'] = $action['reason']; } // keep the old history $userhistory = $userinfo['estore_history']; if (!empty($userhistory)) { // try to unserialize it $userhistory = unserialize($userhistory); } // add this current history to the finalhistory $userhistory[] = $newhistory; // try to serialize it $userhistory = serialize($userhistory); // return the $userhistory return $userhistory; } // function to remove an action from the history function estore_remove_history($userinfo, $action) { // get the old history $userhistory = $userinfo['estore_history']; if (!empty($userhistory)) { // try to unserialize it $userhistory = unserialize($userhistory); // process each user history foreach($userhistory AS $key => $history) { // check if this option is expired if ($histor y['itemid'] == $action['itemid']) { // attempt to unset this from the userhistory unset($userhistory[$key]); } } } // try to serialize it $userhistory = serialize($userhistory); // return the $userhistory return $userhistory; } // function to handle specific cases for expired options function estore_expire_special_options($userinfo, $history, $tablename, $fieldname, $fieldvalue) { // check if this is an option we have to expire in a different way switch($history['itemid']) { // change others user title back case(15): { // check if this is for the user if ($userinfo['userid'] == $history['userid']) { // return the string to remove this option return "usertitle = '" . addslashes($userinfo['displayusertitle']) . "'"; } else { // return '1' to mean skip processing return '1'; } break; } } // return '0' to mean keep processing return '0'; } // function to verify the set name function estore_verify_set_name($action, $setname) { // verify that the $action['setname'] is valid if (empty($setname) || !is_string($setname)) { // display error, option set name is invalid eval(standard_error(fetch_error('estore_option_set _name_invalid'))); } // return the setname return $setname; } // function to verify the set value function estore_verify_set_value($action, $setvalue) { global $vbulletin; // verify that the $setvalue is valid if (empty($setvalue)) { // display error, option set value is invalid eval(standard_error(fetch_error('estore_option_set _value_invalid'))); } // it needs to be evalulated if (!eval('$setvalue = ' . $setvalue . '; return true;')) { // display error, option set value is invalid eval(standard_error(fetch_error('estore_option_set _value_invalid'))); } // check if $setvalue is a string if (is_string($setvalue)) { // add the slashes to $setvalue $setvalue = $vbulletin->db->escape_string($setvalue); } // return the setvalue return $setvalue; } // function to verify the where name function estore_verify_where_name($action, $wherename) { // verify that the wherename is valid if its set if (empty($wherename)) { // we are going to assume where name should be userid $wherename = 'userid'; } else if (!is_string($wherename)) { // display error, option where name is invalid eval(standard_error(fetch_error('estore_option_whe re_name_invalid'))); } // return the wherename return $wherename; } // function to verify the where value function estore_verify_where_value($action, $wherevalue) { global $vbulletin; // verify that the where value is valid if its set if (empty($wherevalue)) { // we are going to assume it wants the purchasers userid $wherevalue = $vbulletin->userinfo['userid']; } else { // try to evalute it as php if (!eval('$wherevalue = ' . $wherevalue . '; return true;')) { // display error, option where value is invalid eval(standard_error(fetch_error('estore_option_whe re_value_invalid'))); } // check if $wherevalue is a string if (is_string($wherevalue)) { // add the slashes to the $wherevalue $wherevalue = $vbulletin->db->escape_string($wherevalue); } } // return the wherevalue return $wherevalue; } // function to update this purchase to the user function estore_user_purchase_update($userinfo, $action, $extrafields = '') { global $vbulletin; // clear out the queryfields $queryfields = array(); // check if this item is one that can changealways if (!$action['changealways']) { // check if its doing a purchase or a refund if ($action['removal'] == true) { // add to the query field to increase this user's points $queryfields[] = $vbulletin->options['ebux_pointsfield'] . " = " . $vbulletin->options['ebux_pointsfield'] . " + " . $action['finalcost']; } else { // add to the query field to decrease this user's points $queryfields[] = $vbulletin->options['ebux_pointsfield'] . " = " . $vbulletin->options['ebux_pointsfield'] . " - " . $action['finalcost']; } } else { // check if this user has any changealways features $changealways = explode(",", $userinfo['changealwaysitems']); // check if this is an array if (empty($changealways) || !in_array($action['itemid'], $changealways)) { // add this to the $changealways array $changealways[] = $action['itemid']; } // check if it should be removed from the array else if ($action['removal'] == true) { // check if it should give the user the points back if ($vbulletin->options['estore_removeablerefunds']) { // add to the query field to increase this user's points $queryfields[] = $vbulletin->options['ebux_pointsfield'] . " = " . $vbulletin->options['ebux_pointsfield'] . " + " . $action['finalcost']; } // process each part of the array to remove the proper one foreach($changealways AS $key => $itemid) { // check if this is the one we want to remove if ($itemid == $action['itemid']) { // remove this item from the $changealways unset($changealways[$key]); } } } // now rebuild the changealways field $changestr = ''; foreach($changealways AS $itemid) { // add this to the $changestr if (!empty($changestr)) { $changestr .= ","; } $changestr .= $itemid; } // add this to the queryfields $queryfields[] = "changealwaysitems = '" . $changestr . "'"; } // check if it should log this transaction if ($action['loghistory']) { // check if it is removing the history or not if ($action['removal'] == true) { // remove this purchase from the user's history $userhistory = estore_remove_history($userinfo, $action); } else { // add this purchase to the user's history $userhistory = estore_add_history($userinfo, $action); } // add this to the query fields $queryfields[] = "estore_history = '" . $vbulletin->db->escape_string($userhistory) . "'"; } // check if it has any $extrafields to add to the query if (!empty($extrafields) && is_array($extrafields)) { // process each $extrafields foreach($extrafields AS $field) { // verify that the field is not empty as well if (!empty($field)) { // add this to the queryfields $queryfields[] = $field; } } } // build the querystr from the queryfields $querystr = ''; foreach($queryfields AS $field) { // verify that $field is not empty as well if (!empty($field)) { // check if it needs to add a comma if (!empty($querystr)) { $querystr .= ", "; } // add this field to the querystr $querystr .= $field; } } // lastly, verify that $querystr is not empty and it should send the query if (!empty($querystr)) { // send off the query to update this user $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . $vbulletin->options['ebux_pointstable'] . " SET " . $querystr . " WHERE userid = '" . $userinfo['userid'] . "' "); } } // function to handle updating the quantity sold function estore_update_quantity_sold($action) { global $vbulletin; // check if it should update the quantity too $updatequantity = ''; if ($action['defquantity'] > 0) { // update the quantity $updatequantity = ", quantity = quantity - 1"; } // send the query to update the estoreitem $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "estoreitems SET sold = sold + 1 " . $updatequantity . " WHERE itemid = '" . $action['itemid'] . "' "); // verify that the finalcost is set if (!is_numeric($action['finalcost'])) { $action['finalcost'] = 0; } // add this this purchase into the history $vbulletin->db->query_write(" INSERT INTO " . TABLE_PREFIX . "estoreitemhistory (historyid, itemid, itemname, userid, username, dateline, finalcost, extrainfo) VALUES ( 0, '" . $action['itemid'] . "', '" . $vbulletin->db->escape_string($action['name']) . "', '" . $vbulletin->userinfo['userid'] . "', '" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "', '" . TIMENOW . "', '" . $action['finalcost'] . "', '" . $vbulletin->db->escape_string($action['extrainfo']) . "' ) "); } // function to handle updating the category / option cache function estore_update_datastore($forceupdate = false, $estorecategory, $estoreoptions) { global $vbulletin; // check if it should query the data first if ($forceupdate) { // build the estorecategorycache $estorecategory = array(); $categories = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "estorecategory WHERE active = 1"); while ($category = $vbulletin->db->fetch_array($categories)) { // cache this category $estorecategory[$category['categoryid']] = $category; } // build the estoreoptioncache $estoreoptions = array(); $items = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "estoreitems WHERE active = 1"); while ($item = $vbulletin->db->fetch_array($items)) { // cache this item $estoreoptions[$item['itemid']] = $item; } } // reserialize the data $estorecategory = serialize($estorecategory); $estoreoptions = serialize($estoreoptions); // dump the data into the database $vbulletin->db->query_write(" REPLACE INTO " . TABLE_PREFIX . "datastore (title, data) VALUES ('estorecategory', '" . $vbulletin->db->escape_string($estorecategory) . "'), ('estoreoptions', '" . $vbulletin->db->escape_string($estoreoptions) . "') "); } // function to quickly add points function estore_quick_add_points($userinfo, $givepoints, $extrafields) { global $vbulletin; // add these points into the user's info $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . $vbulletin->options['ebux_pointstable'] . " SET " . $vbulletin->options['ebux_pointsfield'] . " = " . $vbulletin->options['ebux_pointsfield'] . " + " . $givepoints . " " . $extrafields . " WHERE userid = '" . $vbulletin->userinfo['userid'] . "' "); } // function to quickly subtract points function estore_quick_subtract_points($userinfo, $givepoints, $extrafields) { global $vbulletin; // add these points into the user's info $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . $vbulletin->options['ebux_pointstable'] . " SET " . $vbulletin->options['ebux_pointsfield'] . " = " . $vbulletin->options['ebux_pointsfield'] . " - " . $givepoints . " " . $extrafields . " WHERE userid = '" . $vbulletin->userinfo['userid'] . "' "); } // function to sort an array by fieldname function estore_sort_internal($array1, $array2) { // return the result return strnatcmp($array1['displayorder'], $array2['displayorder']); } // function that will sort by display order function estore_sort_by_display_order($data) { // call the usort function usort($data, 'estore_sort_internal'); // return the data return $data; } // function to construct the breadcrumbs function estore_construct_navbits($navitems) { global $vbphrase; // add the default $navbits first $navbits = array('estore.php?' . $vbulletin->session->vars['sessionurl'] => $vbphrase['estore_title']); // add the rest of the navitems if (is_array($navitems)) { // process each navitem foreach($navitems AS $key => $item) { // verify its not empty if (!empty($item)) { // insert this into $navbits $navbits[$key] = $item; } } } // return the $navbits return $navbits; } ?>
|
|