Example #1
0
                }
            }
            echo '</div>

<div class="right" style="text-align:center;">
  <a href="' . tlink('user/owner_actions', 'action=add_store') . '" class="btn">Add new store</a>
</div>';
            break;
            /*
            ADD STORE
            */
        /*
        ADD STORE
        */
        case 'add_store':
            $prices = prices('object');
            $my_credits = $GLOBALS['me']->Credits;
            echo '<div class="left">
<div class="title">Add New Store</div>';
            if ($my_credits < $prices->store) {
                echo '<div class="mask-form"></div>';
            }
            echo submit_store_form();
            echo '</div>

<div class="right">';
            if ($my_credits < $prices->store) {
                echo '<div class="error">You don\'t have enough credits to add new stores.</div>
  <div style="margin-top: 20px; text-align: center;"><a href="' . tlink('user/plans') . '" class="btn">Add Credits</a></div>';
            } else {
                echo '<section class="cost-sect">
Example #2
0
    $result = $conn->query($sql);
    $ct = mysqli_num_rows($result);
} else {
    $ct = 0;
    $tot = 0;
    $cartid = 0;
}
$cc = 0;
$sql = "SELECT `or_id` FROM `us_or` WHERE `u_name`='{$uname}'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while ($row = $result->fetch_assoc()) {
        $orid[$cc] = $row['or_id'];
        $ship[$cc] = ships($orid[$cc]);
        $price[$cc] = prices($orid[$cc]);
        $cc++;
    }
}
function ships($id)
{
    $servername = "localhost";
    $username = "******";
    $password = "******";
    $dbname = "bookstore";
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    $s = 0;
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
Example #3
0
 public static function edit_product($id, $user, $post)
 {
     global $db, $LANG;
     $post = array_map('trim', $post);
     if (!isset($post['store']) || !\query\main::have_store($post['store'], $user)) {
         throw new \Exception($LANG['msg_error']);
         // this error can appear only when user try to modify post data
     } else {
         if (!isset($post['name']) || trim($post['name']) == '') {
             throw new \Exception($LANG['edit_prod_writename']);
         } else {
             if (!isset($post['url']) || !empty($post['url']) && !preg_match('/(^http(s)?:\\/\\/)([a-zA-Z0-9-]{3,100}).([a-zA-Z]{2,12})/', $post['url'])) {
                 throw new \Exception($LANG['edit_prod_writeurl']);
             } else {
                 if (!isset($post['description']) || strlen($post['description']) < 10) {
                     throw new \Exception($LANG['edit_prod_writedesc']);
                 } else {
                     $end = $post['end'] . ', ' . $post['end_hour'];
                     $info = \query\main::product_infos($id);
                     if (($end_unix = strtotime($post['end'])) > ($paid_until = strtotime($info->paid_until))) {
                         $prices = prices('object');
                         $now_unix = strtotime('today 00:00');
                         // cost for this product
                         $cost = (int) $prices->product * ceil(max(ceil(($end_unix - ($paid_until > $now_unix ? $paid_until : $now_unix)) / 86400), 1) / (int) $prices->product_max_days);
                         // save cost until
                         $paid_until = $end_unix;
                     } else {
                         // cost for this product
                         $cost = 0;
                     }
                     if ($GLOBALS['me']->Credits < $cost) {
                         throw new \Exception(sprintf($LANG['msg_notenoughpoints'], $cost, $GLOBALS['me']->Credits));
                     }
                     $image = \site\images::upload($_FILES['edit_product_form_image'], 'product_', array('path' => '', 'max_size' => 1024, 'max_width' => 800, 'max_height' => 800, 'current' => $info->image));
                     $stmt = $db->stmt_init();
                     $stmt->prepare("UPDATE " . DB_TABLE_PREFIX . "products SET store = ?, title = ?, link = ?, description = ?, tags = ?, image = ?, price = ?, old_price = ?, currency = ?, start = ?, expiration = ?, lastupdate_by = ?, lastupdate = NOW(), paid_until = FROM_UNIXTIME(?) WHERE id = ?");
                     $start = $post['start'] . ', ' . $post['start_hour'];
                     if ($cost <= 0) {
                         $paid_until = strtotime($info->paid_until);
                     }
                     $stmt->bind_param("isssssddsssisi", $post['store'], $post['name'], $post['url'], $post['description'], $post['tags'], $image, $post['price'], $post['old_price'], $post['currency'], $start, $end, $user, $paid_until, $id);
                     $execute = $stmt->execute();
                     $stmt->close();
                     if ($execute) {
                         // deduct credits
                         \user\update::add_credits($GLOBALS['me']->ID, -$cost);
                         return (object) array('image' => $image);
                     }
                     throw new \Exception($LANG['msg_error']);
                 }
             }
         }
     }
 }