function getNewID($rsn) { $rsnx = ""; $rs = RandomString(1, false); $rn = rand(1, 1001); $rsn = $rsn . "" . $rs . "" . $rn; if (chkDuplicateCode($rsn) == false) { $rsnx = $rsn; } else { $rsnx = getNewID($rsn); } return $rsnx; }
$row_user_id = mssql_fetch_assoc(mssql_query("SELECT id from mobile_user where number='" . $phone_num . "'", $dbhandle)); } else { $insert_user = mssql_query("INSERT INTO mobile_user VALUES('" . $phone_num . "')", $dbhandle); $row_user_id = mssql_fetch_assoc(mssql_query("SELECT id from mobile_user where number='" . $phone_num . "'", $dbhandle)); } ##Check id user is subscribed to content $queryIfSubs = "SELECT COUNT(*) as cnt_sub from user_subscription where type_id='" . $content_type_id . "' and user_id='" . $row_user_id['id'] . "' and state='1'"; //echo $queryIfSubs; $row_check_subscription = mssql_fetch_assoc(mssql_query($queryIfSubs, $dbhandle)); $query4TY = "select type from content_type where id = '" . $content_type_id . "'"; $getKey4TYPE = mssql_fetch_assoc(mssql_query($query4TY, $dbhandle)); $key4Type = $getKey4TYPE['type']; if ($row_check_subscription['cnt_sub'] > 0) { ##on demand content echo '<div class="container"><div class="news-paper"><div class="sign_up text-center">A download Link to ' . $content_name['cnt_name'] . ' will be sent to you shortly. Please hold on...'; $url_iid = getNewID('R'); //echo $url_iid; $query = "select substring(s.shortcode , 2 , len(s.shortcode ) - 1) as shortcd from shortcode s, contype_shortcode c where c.type_id = '" . $content_type_id . "' and s.id = c.short_id and s.state = 1 and c.stato = 1"; $get_SC = mssql_fetch_assoc(mssql_query($query, $dbhandle)); //echo $query; $sender = $get_SC['shortcd']; //Send message sendmsg2($phone_num, $sender, $url_iid, $content_type_id, $key4Type); echo '<p><a href="http://www.dosika.co.ke/waspplanet/0g/">««<b>Click here</b></a> to go back to content.</p></div></div></div>'; } else { //$pin_code = getPinCode(4); $date_ = date("Y-m-d H:i:s", time()); $insert_user = mssql_query("INSERT INTO subscription_code (user_id, pin_code, type_id, dateadded,source_id) VALUES(" . $row_user_id['id'] . ",'" . $key4Type . "','" . $content_type_id . "','" . $date_ . "','')", $dbhandle); if ($insert_user) { $query = "select substring(s.shortcode , 2 , len(s.shortcode ) - 1) as shortcd from shortcode s, contype_shortcode c where c.type_id = '" . $content_type_id . "' and s.id = c.short_id and s.state = 1 and c.stato = 1"; $get_SC = mssql_fetch_assoc(mssql_query($query, $dbhandle));