Пример #1
0
function jb_update_subscription_quota($employer_id)
{
    $status = JB_get_employer_subscription_status($employer_id);
    if ($status != 'Active') {
        // reset all quota variables
        $sql = "UPDATE employers SET views_quota=0, posts_quota=0, p_posts_quota=0, views_quota_tally=0, posts_quota_tally=0, p_posts_quota_tally=0 , quota_timestamp='0' WHERE ID='" . jb_escape_sql($employer_id) . "' ";
        JB_mysql_query($sql);
        return;
        // the employer must have an active subscription
    }
    $sql = "SELECT * FROM employers where ID='" . jb_escape_sql($employer_id) . "'";
    $result = JB_mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    $t = $row['quota_timestamp'];
    // calculate timestamp for 1 month in the future
    $t_next_month = mktime(date('H', $t), date('i', $t), date('s', $t), date('n', $t) + 1, date('j', $t), date('Y', $t));
    $now = time();
    // $time_diff is the amount of seconds remaining in the subscription
    $time_diff = $t_next_month - $now;
    if ($time_diff < 0) {
        // update timestamp & reset quotas
        // get the subscription // , t2.views_quota as VQ, t2.posts_quota AS PQ, t2.p_posts_quota AS PPQ
        $sql = "SELECT * FROM subscription_invoices as t1, subscriptions as t2 WHERE t1.subscription_id = t2.subscription_id AND t1.employer_id='" . jb_escape_sql($employer_id) . "' AND  ((t1.status='Completed' ) OR ((t1.status='Pending') AND t1.reason='jb_credit_advanced')) ORDER BY t1.invoice_date DESC LIMIT 1";
        $result = JB_mysql_query($sql) or die(mysql_error());
        $sub_row = mysql_fetch_array($result, MYSQL_ASSOC);
        //Update the employer's quota and tally
        $sql = "UPDATE employers SET views_quota='" . jb_escape_sql($sub_row['views_quota']) . "', posts_quota='" . jb_escape_sql($sub_row['posts_quota']) . "', p_posts_quota='" . jb_escape_sql($sub_row['p_posts_quota']) . "', views_quota_tally='0', posts_quota_tally='0', p_posts_quota_tally='0', quota_timestamp='" . $now . "' WHERE ID='" . jb_escape_sql($employer_id) . "' ";
        JB_mysql_query($sql);
    }
}
Пример #2
0
function JB_insert_post_data($insert_mode = 'EMPLOYER')
{
    if ($_REQUEST['user_id'] != '' && $insert_mode == 'ADMIN') {
        $user_id = (int) $_REQUEST['user_id'];
    } else {
        $user_id = (int) $_SESSION['JB_ID'];
    }
    // determine what kind of posting it is
    $post_mode = "free";
    if ($_REQUEST['type'] != 'premium') {
        if (JB_POSTING_FEE_ENABLED == 'YES') {
            $post_mode = "normal";
            if ($insert_mode != 'ADMIN') {
                $credits = JB_get_num_posts_remaining($user_id);
            }
        }
    } else {
        if (JB_PREMIUM_POSTING_FEE_ENABLED == 'YES') {
            $post_mode = "premium";
            if ($insert_mode != 'ADMIN') {
                $credits = JB_get_num_premium_posts_remaining($user_id);
            }
        }
    }
    $_PRIVILEGED_USER = false;
    if ($insert_mode != 'ADMIN') {
        // check if the user is priveleged
        $_PRIVILEGED_USER = JB_is_privileged_user($user_id, $post_mode);
    } elseif ($insert_mode == 'ADMIN') {
        // Admin mode is always _PRIVILEGED_USER
        $_PRIVILEGED_USER = true;
    }
    $approved = 'N';
    if (JB_POSTS_NEED_APPROVAL == 'NO') {
        $approved = 'Y';
    } elseif ($_PRIVILEGED_USER) {
        $approved = 'Y';
    } elseif (JB_POSTS_NEED_APPROVAL == 'NOT_SUBSCRIBERS' && $insert_mode == 'EMPLOYER') {
        // no approval needed for subscibers..
        if (JB_SUBSCRIPTION_FEE_ENABLED == 'YES') {
            // check subscription
            if (JB_get_employer_subscription_status($user_id) == 'Active') {
                $approved = 'Y';
            }
        }
        if ($post_mode != 'free') {
            $approved = 'Y';
        }
    }
    if ($_REQUEST['app_type'] == false) {
        $_REQUEST['app_type'] = "O";
    }
    $new = false;
    if ($_REQUEST['post_id'] == false) {
        $new = true;
        $now = gmdate("Y-m-d H:i:s");
        $assign = array('post_date' => gmdate("Y-m-d H:i:s"), 'post_mode' => $post_mode, 'user_id' => $user_id, 'pin_x' => (int) $_REQUEST['pin_x'], 'pin_y' => (int) $_REQUEST['pin_y'], 'approved' => $approved, 'app_type' => $_REQUEST['app_type'], 'app_url' => $_REQUEST['app_url'], 'cached_summary' => '', 'expired' => 'N');
        $sql = "REPLACE INTO `posts_table` (" . JB_get_sql_insert_fields(1, $assign) . ") VALUES (" . JB_get_sql_insert_values(1, "posts_table", "post_id", $post_id, $user_id, $assign) . " )";
        // DEDUCT CREDITS (For new posts)
        if ($post_mode == 'normal' && !$_PRIVILEGED_USER) {
            JB_deduct_posting_credit($user_id);
        }
        if ($post_mode == 'premium' && !$_PRIVILEGED_USER) {
            JB_deduct_p_posting_credit($user_id);
        }
    } else {
        $post_id = (int) $_REQUEST['post_id'];
        if ($insert_mode != 'ADMIN') {
            // verify that the post is owned by this user in case of hacking
            $sql = "SELECT * from posts_table where post_id='" . jb_escape_sql($_REQUEST['post_id']) . "'";
            //echo $sql.'<br>'.$user_id;
            $result = JB_mysql_query($sql) or die(mysql_error());
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
            if ($row['user_id'] != $user_id) {
                die('hacking attempt');
            }
        }
        $old_data = JB_load_post_data($post_id);
        // these old_values will be used to update the category counters & keep the current approved status
        $approved = $old_data['approved'];
        $assign = array('pin_x' => (int) $_REQUEST['pin_x'], 'pin_y' => (int) $_REQUEST['pin_y'], 'approved' => $approved, 'app_type' => $_REQUEST['app_type'], 'app_url' => $_REQUEST['app_url']);
        $sql = "UPDATE `posts_table` SET " . JB_get_sql_update_values(1, "posts_table", "post_id", $_REQUEST['post_id'], $user_id, $assign) . " WHERE post_id='" . jb_escape_sql($post_id) . "'";
    }
    $result = JB_mysql_query($sql) or die(mysql_error() . $sql);
    if ($new) {
        $post_id = jb_mysql_insert_id();
    }
    JBPLUG_do_callback('insert_post_data', $post_id);
    // for the plugin if you want your plugin to do something after a post is saved. Note that if the post is edited then $_REQUEST['post_id'] will be set or else this is a new post.
    if (JB_PREMIUM_AUTO_UPGRADE == 'YES') {
        // auto upgrade to premium!
        $post_mode = "premium";
        $sql = "UPDATE `posts_table` SET `post_mode`='" . jb_escape_sql($post_mode) . "' WHERE post_id='" . jb_escape_sql($post_id) . "' ";
        JB_mysql_query($sql) or die(mysql_error() . $sql);
    }
    // rebuild categories count...
    JB_update_post_category_count($old_data, $_REQUEST);
    // This will update the category counters only for the affected categories
    // build categories cache / update counters / update rss, etc.
    JB_finalize_post_updates();
    if (JB_EMAIL_NEW_POST_SWITCH == 'YES' && $new) {
        $Form = JB_get_DynamicFormObject(1);
        $Form->load($post_id);
        $TITLE = $Form->get_raw_template_value("TITLE");
        $POSTED_BY = $Form->get_raw_template_value("POSTED_BY");
        $POSTED_BY_ID = $Form->get_raw_template_value("USER_ID");
        $DATE = JB_get_formatted_date($Form->get_template_value("DATE"));
        $FORMATTED_DATE = $DATE;
        $DESCRIPTION = $Form->get_raw_template_value("DESCRIPTION");
        // get the email template
        $template_result = JB_get_email_template(310, $_SESSION['LANG']);
        $t_row = mysql_fetch_array($template_result);
        $to_address = JB_SITE_CONTACT_EMAIL;
        $to_name = JB_SITE_NAME;
        $subject = $t_row['EmailSubject'];
        $message = $t_row['EmailText'];
        $from_name = $t_row['EmailFromName'];
        $from_address = $t_row['EmailFromAddress'];
        $subject = str_replace("%SITE_NAME%", JB_SITE_NAME, $subject);
        $message = str_replace("%SITE_NAME%", JB_SITE_NAME, $message);
        $message = str_replace("%SITE_URL%", JB_BASE_HTTP_PATH, $message);
        $message = str_replace("%SITE_CONTACT_EMAIL%", JB_SITE_CONTACT_EMAIL, $message);
        $message = str_replace("%POST_TITLE%", $TITLE, $message);
        $message = str_replace("%DATE%", $FORMATTED_DATE, $message);
        $message = str_replace("%POST_DESCRIPTION%", $DESCRIPTION, $message);
        $message = str_replace("%POSTED_BY%", $POSTED_BY, $message);
        $message = str_replace("%ADMIN_LINK%", JB_BASE_HTTP_PATH . "admin/ra.php?post_id=" . $Form->get_value('post_id') . "&key=" . md5($Form->get_value('post_id') . JB_ADMIN_PASSWORD), $message);
        $message = str_replace('<BR>', "\n", $message);
        $message = str_replace('<P>', "\n\n", $message);
        $message = html_entity_decode($message);
        $message = strip_tags($message);
        $email_id = JB_queue_mail($to_address, $to_name, $from_address, $from_name, $subject, $message, '', 310);
        JB_process_mail_queue(1, $email_id);
    }
    return $post_id;
}
Пример #3
0
         $subscr_block_status = JB_get_employer_view_block_status($_SESSION['JB_ID']);
         if ($subscr_block_status == 'N' && JB_SUBSCRIPTION_FEE_ENABLED == 'YES' && !$key_test_passed) {
             echo "<p>" . $label["resume_some_fields_blocked"] . "</p>";
             echo JBEmployer::JB_get_special_offer_msg();
             $is_blocked = 'Y';
         }
         break;
     case 'NO':
         break;
 }
 $REQUEST_FEATURE == false;
 switch (JB_RESUME_REQUEST_SWITCH) {
     case 'YES':
         //
         if (JB_NEED_SUBSCR_FOR_REQUEST == 'YES') {
             $subscr_status = JB_get_employer_subscription_status($_SESSION['JB_ID']);
             if ($subscr_status == 'Active') {
                 $REQUEST_FEATURE = true;
             } else {
                 $REQUEST_FEATURE = false;
             }
         } else {
             $REQUEST_FEATURE = true;
         }
         break;
     case 'NO':
         $REQUEST_FEATURE = false;
         break;
 }
 if ($key_test_passed) {
     // viewing form an special that came form an application.