function pb_db($sql, $callback = '', $callbackNoResults = '', $return = 'array') { //SQL CONNECT $conn = pb_sql_connect(); //SQL QUERY $query = pb_sql_query($conn, $sql); //SQL CLOSE $conn->close(); //CHECK CALLBACKS if ($callback == '') { return $query; } else { if ($callback === true) { return pb_switch($query->fetch_assoc()); } else { if ($query->num_rows > 0) { if (pb_sql_is_callback($callback) == true) { return $callback; } else { while ($row = $query->fetch_assoc()) { if ($return == 'array') { $callback($row); } else { $callback(pb_switch($row)); } } } } else { if (pb_sql_is_callback($callbackNoResults) == true) { return $callbackNoResults; } else { $callbackNoResults(); } } } } }
function pb_time($action = '', $options = array(), $callback = null) { $options = pb_switch(array_merge(array("format" => "F j, Y, g:i:s a T", "start" => date("F j, Y, g:i:s a T"), "end" => date("F j, Y, g:i:s a T"), "expire" => 0, "key" => null, "token" => null), $options)); $output = false; if (empty($action)) { $output = date($options->format); } elseif ($action == 'diff') { if (!ctype_digit($options->start)) { $options->start = strtotime($options->start); } if (!ctype_digit($options->end)) { $options->end = strtotime($options->end); } $output = $options->end - $options->start; } elseif (strpos($action, 'token') !== false) { $token_parts = explode(':', $action); if (!empty($token_parts[1]) && $token_parts[1] == 'new') { $date = new DateTime($options->start); $date->modify($options->expire); $end_date = $date->format($options->format); $data = array("start" => $options->start, "end" => $end_date, "expire" => $options->expire); $output = pb_encrypt_decrypt('encrypt', json_encode($data), $options->key); $output = str_replace('=', '', $output); } elseif (!empty($token_parts[1]) && $token_parts[1] == 'check') { $decrypt = json_decode(pb_encrypt_decrypt('decrypt', $options->token . '==', $options->key)); if (strtotime(date($options->format)) < strtotime(date($options->format, strtotime($decrypt->end)))) { $output = true; } } else { $json = json_decode(pb_encrypt_decrypt('decrypt', $options->token . '==', $options->key)); $s_date = $json->start; $e_date = $json->end; $life = $json->expire; $die = dateDiff(date($options->format), $e_date); if (empty($die)) { $die = '0'; } else { $die = "in about " . $die; } $output = json_encode(array("start" => $json->start, "end" => $json->end, "life" => $json->expire, "die" => $die)); } } return $output; }
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++; } }
<!-- <span style="font-size: 14px;" class="pb-theme-black"><?php print $pb_user['registered']; ?> </span> --> </h3> <?php print '<strong><i class="zmdi zmdi-home"></i> ' . $home . '</strong><br />' . pb_user()->phone . '<br />' . pb_user()->email . ''; ?> <hr /> </div> <div class="pb-sidebar-overflow" style="padding-bottom: 20px;"> <?php $user_feed = pb_switch(json_decode(pb_og('feed', pb_user()->user_id))); if (!is_array($user_feed)) { foreach ($user_feed as $post) { if ($post->status == 'open' || $post->status == 1) { if ($post->type == 'product') { ?> <a href="/item?id=<?php print $post->id; ?> "> <div class="col-md-12 pb-post pb-rule-below-thick"> <div class="pb-post-block"> <div class="pb-post-content"> <?php if (!empty($post->images->featured) && pb_is_image($post->images->featured)) { print '<img src="' . $post->images->featured . '" class="pb-post-product lazy">';