function logbee_header() { $location = Rewrite::newInstance()->get_location(); $section = Rewrite::newInstance()->get_section(); if ($location == 'item' && $section == '') { echo ' <style type="text/css"> .logbee ul { margin: 10px 0; list-style: none; } .logbee ul li { float: left; } .logbee .clear { clear:both; } </style>'; // meta-tags $address_array = array(); if (osc_item_address() != "") { $address_array[] = osc_item_address(); } if (osc_item_city_area() != "") { $address_array[] = osc_item_city_area(); } if (osc_item_zip() != "") { $address_array[] = osc_item_zip(); } if (osc_item_city() != "") { $address_array[] = osc_item_city(); } if (osc_item_region() != "") { $address_array[] = osc_item_region(); } if (osc_item_country() != "") { $address_array[] = osc_item_country(); } $address = implode(", ", $address_array); $price = ''; if (osc_item_formated_price() != "") { $price = osc_item_formated_price(); } $email = ''; if (osc_item_show_email()) { $email = osc_item_contact_email(); } echo ' <meta property="logbee:title" content="' . osc_esc_html(osc_item_title()) . '"/> <meta property="logbee:url" content="' . osc_esc_html(osc_item_url()) . '"/> <meta property="logbee:desc" content="' . osc_esc_html(osc_item_description()) . '"/> <meta property="logbee:addr" content="' . osc_esc_html($address) . '"/> <meta property="logbee:email" content="' . osc_esc_html($email) . '"/> <meta property="logbee:price" content="' . osc_esc_html($price) . '"/>'; // do we have the cars_plugin enabled? if (osc_plugin_is_enabled('cars_attributes/index.php')) { require_once osc_plugin_path('') . '/cars_attributes/ModelCars.php'; if (osc_is_this_category('cars_plugin', osc_item_category_id())) { $detail = ModelCars::newInstance()->getCarAttr(osc_item_id()); echo ' <meta property="logbee:type" content="car"/> <meta property="logbee:mileage" content="' . osc_esc_html(@$detail['i_mileage']) . '"/> <meta property="logbee:firstreg" content="' . osc_esc_html(@$detail['i_year']) . '"/>'; } } // do we have the realestate_plugin enabled? if (osc_plugin_is_enabled('realestate_attributes/index.php')) { require_once osc_plugin_path('') . '/realestate_attributes/ModelRealEstate.php'; if (osc_is_this_category('realestate_plugin', osc_item_category_id())) { $detail = ModelRealEstate::newInstance()->getAttributes(osc_item_id()); echo ' <meta property="logbee:type" content="realty"/> <meta property="logbee:rooms" content="' . osc_esc_html(@$detail['i_num_rooms']) . '"/> <meta property="logbee:size" content="' . osc_esc_html(@$detail['s_square_meters']) . ' sqm"/>'; } } // images osc_reset_resources(); $images_array = array(); for ($i = 0; osc_has_item_resources(); $i++) { $images_array[] = osc_esc_html(osc_resource_url()); } $images = implode("|", $images_array); echo ' <meta property="logbee:imgurl" content="' . $images . '"/> '; osc_reset_resources(); echo "\n"; } }
/** * Show form to vote an item. (itemDetail) */ function voting_item_detail() { if (osc_is_this_category('voting', osc_item_category_id()) && osc_get_preference('item_voting', 'voting') == '1') { $aux_vote = ModelVoting::newInstance()->getItemAvgRating(osc_item_id()); $aux_count = ModelVoting::newInstance()->getItemNumberOfVotes(osc_item_id()); $vote['vote'] = $aux_vote['vote']; $vote['total'] = $aux_count['total']; $hash = ''; if (osc_logged_user_id() == 0) { $hash = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']; $hash = sha1($hash); } else { $hash = null; } $vote['can_vote'] = true; if (osc_get_preference('user', 'voting') == 1) { if (!osc_is_web_user_logged_in()) { $vote['can_vote'] = false; } } if (!can_vote(osc_item_id(), osc_logged_user_id(), $hash)) { $vote['can_vote'] = false; } require 'item_detail.php'; } }
function digitalgoods_upload_files($item) { if ($item['fk_i_category_id'] != null) { if (osc_is_this_category('digitalgoods', $item['fk_i_category_id'])) { $files = Params::getFiles('dg_files'); if (count($files) > 0) { require LIB_PATH . 'osclass/mimes.php'; $aMimesAllowed = array(); $aExt = explode(',', osc_get_preference('allowed_ext', 'digitalgoods')); foreach ($aExt as $ext) { $mime = $mimes[$ext]; if (is_array($mime)) { foreach ($mime as $aux) { if (!in_array($aux, $aMimesAllowed)) { array_push($aMimesAllowed, $aux); } } } else { if (!in_array($mime, $aMimesAllowed)) { array_push($aMimesAllowed, $mime); } } } $failed = false; $maxSize = osc_max_size_kb() * 1024; foreach ($files['error'] as $key => $error) { $bool_img = false; if ($error == UPLOAD_ERR_OK) { $size = $files['size'][$key]; if ($size <= $maxSize) { $fileMime = $files['type'][$key]; if (in_array($fileMime, $aMimesAllowed)) { $date = date('YmdHis'); $file_name = $date . '_' . $item['pk_i_id'] . '_' . $files['name'][$key]; $path = osc_get_preference('upload_path', 'digitalgoods') . $file_name; if (move_uploaded_file($files['tmp_name'][$key], $path)) { DGModel::newInstance()->insertFile($item['pk_i_id'], $files['name'][$key], $date); } else { $failed = true; } } else { $failed = true; } } else { $failed = true; } } } if ($failed) { osc_add_flash_error_message(__('Some of the files were not uploaded because they have incorrect extension', 'digitalgoods'), 'admin'); } } } } }
if ($open == 1) { if (can_vote($itemId, $userId, $hash)) { ModelVoting::newInstance()->insertItemVote($itemId, $userId, $iVote, $hash); } } else { if ($user == 1 && is_null($hash)) { if (can_vote($itemId, $userId, $hash)) { ModelVoting::newInstance()->insertItemVote($itemId, $userId, $iVote, $hash); } } } } // return updated voting $item = Item::newInstance()->findByPrimaryKey($itemId); View::newInstance()->_exportVariableToView('item', $item); if (osc_is_this_category('voting', osc_item_category_id())) { $aux_vote = ModelVoting::newInstance()->getItemAvgRating(osc_item_id()); $aux_count = ModelVoting::newInstance()->getItemNumberOfVotes(osc_item_id()); $vote['vote'] = $aux_vote['vote']; $vote['total'] = $aux_count['total']; $vote['can_vote'] = true; if (osc_get_preference('user', 'voting') == 1) { if (!osc_is_web_user_logged_in()) { $vote['can_vote'] = false; } } if (!can_vote(osc_item_id(), osc_logged_user_id(), $hash)) { $vote['can_vote'] = false; } require 'view_votes.php'; }