<?php //pb_product if ($slq_table == 'pb_post') { $pData = json_decode($val['product_info']); $saveImag = array(); $saveImag_size = array(); foreach ($pData as $pd) { $images = explode(',', $pd->images); $timeAgo = time_ago(strtotime($pd->timestamp)); $date = $pd->timestamp; foreach ($images as $img) { array_push($saveImag, pb_safe_image_structure(pb_table_data('pb_safe_image', 'string', "uid='{$img}'"))); array_push($saveImag_size, pb_safe_image_structure(pb_table_data('pb_safe_image', 'size', "uid='{$img}'"))); } $title = $pd->title; $desc = $pd->desc; $tags = $pd->tags; $price = $pd->price; $condition = $pd->condition; } $user_data = json_decode(pb_user_data($val['user_id'], 'user_data'), true); foreach ($user_data as $data) { $author = $data['name']; $user = $data['username']; $avatar = $data['avatar']; } $comment = json_decode(get_comments($val['product_id'])); $imgSize = explode(':', $saveImag_size[0]); $entity = array('id' => $val['product_id'], 'type' => $val['type'], 'timestamp' => array('date' => $date, 'laps' => $timeAgo), 'user' => array('id' => $val['user_id'], 'name' => $author, 'username' => $user, 'avatar' => $avatar), 'images' => array('featured' => $saveImag[0], 'featured_width' => $imgSize[0], 'featured_height' => $imgSize[1], 'list' => $saveImag), 'product_info' => array('title' => $title, 'desc' => $desc, 'tags' => $tags, 'price' => $price, 'condition' => $condition), 'trans_info' => json_decode($val['trans_info']), 'comments' => array('count' => count($comment), 'comments' => $comment), 'status' => $val['status']); array_push($mainJson, $entity);
function pb_ad($defaults, $loop = 1, $location = '') { $defaults = pb_switch($defaults); $location = clean($location); $ad_id = pb_obj($defaults, 'id'); $width = pb_obj($defaults, 'style'); $keywords = pb_obj($defaults, 'tags'); $caption = pb_obj($defaults, 'caption', true); $type = pb_obj($defaults, 'type', 'long'); $_SESSION['pb_ad_style'] = $width; $_SESSION['pb_ad_cap'] = $caption; $code_previx = "pb_ad" . $location; pb_page_code($code_previx); $adCount = 1; while ($adCount <= $loop) { if (empty($ad_id) || $ad_id == 'paid') { $result = pb_db("SELECT * FROM pb_doubleclick WHERE status=1 order by RAND() LIMIT 1"); if ($result->num_rows > 0) { $ad_id = $result->fetch_assoc(); $ad_id = $ad_id['id']; } } if ($ad_id == 'free') { $ran = pb_db("SELECT product_id, user_id, product_info FROM pb_post WHERE type='product' AND status='open' order by RAND() LIMIT 1", true); $data = json_decode($ran->product_info); $data = $data[0]; $img_id = explode(',', $data->images); $img_id = $img_id[0]; $img_cta = $data->title; $img_user = $ran->user_id; $pid = $ran->product_id; $pb_safe_image = pb_db("SELECT string FROM pb_safe_image WHERE uid='{$img_id}'", true); if (!in_array('free_ads_' . $pid, pb_page_code($code_previx, true))) { if (isset($pb_safe_image->string)) { $img_url = $pb_safe_image->string; array_push($_SESSION[$code_previx . PAGE_LOAD_CODE], 'free_ads_' . $pid); print '<a class="pb_ad transition-300" href="/pb_doubleclick?path=/item?id=' . $pid . '&marketplace=free_user_ads&pg=' . PAGE_LOAD_CODE . '&source=' . $location . '&session=' . $code_previx . '&user_id=' . $img_user . '"'; print 'style="background:no-repeat center url(' . pb_safe_image_structure($img_url) . ');background-size:cover;' . $_SESSION['pb_ad_style'] . '">'; if (!empty($img_cta) && e($_SESSION['pb_ad_cap'])) { print '<div class="transition-300">' . $img_cta . '</div>'; } print '</a>'; } } } else { $ad = pb_db("SELECT * FROM pb_doubleclick WHERE id='{$ad_id}' AND status=1 LIMIT 1", true); if ($type == 'long') { $img = $ad->cover; } if ($type == 'square') { $img = $ad->cover_square; } if (empty($img)) { $img = $ad->cover; } if (!in_str('/', $img)) { $img = pb_db("SELECT string FROM pb_safe_image WHERE uid='{$img}'", true)->string; } if (!in_array($ad->id, pb_page_code($code_previx, true))) { array_push($_SESSION[$code_previx . PAGE_LOAD_CODE], $ad->id); print '<a class="pb_ad transition-300" href="/pb_doubleclick?path=' . $ad->link . '&pg=' . PAGE_LOAD_CODE . '&source=' . $location . '&session=' . $code_previx . '&marketplace=user_ad&id=' . $ad->id . '"'; print 'style="background:no-repeat center url(' . $img . ');background-size:cover;' . $_SESSION['pb_ad_style'] . '">'; if (!empty($ad->cta) && e($_SESSION['pb_ad_cap'])) { print '<div class="transition-300">' . $ad->cta . '</div>'; } print '</a>'; } } $adCount++; } }