Пример #1
0
function notify_artist($id)
{
    global $wpdb;
    // this is to notify artist about download of the $id image
    $max_downloads = get_option('max_downloads');
    // how many download attempts left?
    //$sql = "select downloads from wp_download_status where $id=".$id." and active=1 LIMIT 1";
    $sql = "SELECT c.price, st.purchid as zakaz, st.downloads, p.id as imageid, p.image as filename, p.name as cartoonname, p.description as description, \r\n\t\t\t\t\tu.user_email as email, b.name as artist\r\n\t\t\tFROM wp_download_status AS st, wp_product_list AS p, wp_users AS u, wp_product_brands AS b, wp_cart_contents as c\r\n\t\t\tWHERE st.fileid = p.file\r\n\t\t\tAND b.id = p.brand\r\n\t\t\tAND b.user_id = u.id\r\n\t\t\tAND c.purchaseid = st.purchid\r\n\t\t\tAND st.id =" . $id;
    $downloads_left = $wpdb->get_results($sql, ARRAY_A);
    // actual downloads_left
    $downloads = $downloads_left[0]['downloads'];
    // actual downloads_left
    if ($downloads == $max_downloads - 1) {
        // if this is a first download of the file
        send_email_to_artist($downloads_left[0]['price'], $downloads_left[0]['imageid'], $downloads_left[0]['filename'], $downloads_left[0]['cartoonname'], $downloads_left[0]['description'], $downloads_left[0]['artist'], $downloads_left[0]['email']);
        //rise clear flag
        $sql = "UPDATE wp_options SET `option_value`=1 WHERE `option_name` = 'clearmycache'";
        $result = mysql_query($sql);
    }
    return;
}
Пример #2
0
function notify_artist($id)
{
    global $wpdb;
    // this is to notify artist about download of the $id image
    $max_downloads = 5;
    // how many download attempts left?
    //$sql = "select downloads from wp_download_status where $id=".$id." and active=1 LIMIT 1";
    $sql = "SELECT c.price, st.purchid as zakaz, st.downloads, p.id as imageid, p.image as filename, p.name as cartoonname, p.description as description, \r\nu.user_email as email, b.name as artist\r\nFROM \r\nwp_purchase_logs as plog,\r\nwp_download_status AS st, \r\nwp_product_list AS p, \r\nwp_users AS u, \r\nwp_product_brands AS b, \r\nwp_cart_contents as c\r\nWHERE \r\nplog.id = " . $id . " AND\r\nplog.id = st.purchid AND\r\nplog.id = c.purchaseid AND\r\np.id = st.fileid AND\r\np.brand = b.id AND\r\nu.id = b.user_id\r\nlimit 1";
    //pokazh($sql);
    $result = mysql_query("{$sql}");
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    //pokazh($result,"111");
    while ($row = mysql_fetch_array($result)) {
        //pokazh($row,"row");
        $downloads = $row['downloads'];
        $price = $row['price'];
        $imageid = $row['imageid'];
        $filename = $row['filename'];
        $cartoonname = $row['cartoonname'];
        $description = $row['description'];
        $artist = $row['artist'];
        $email = $row['email'];
    }
    send_email_to_artist($price, $imageid, $filename, $cartoonname, $description, $artist, $email);
    return;
}