-
Posts
187 -
Joined
-
Last visited
Everything posted by Lukeidiot
-
Very nice work! I have just one last question though, lets say a users subscription has been expired for 45 days and he buys another 30 days subscription, how can I make it "know" to add 30 days and not 30 - 45 days? P.S. I am using Seconds instead of Days, is it possible to use Seconds directly in the mysql query? Thanks so much
-
Thanks, but I am still having trouble with this if you guys want to contribute.
-
Heres the script <?php include("connect.php"); include("datediff.php"); $id = $_GET['id']; $sub = mysql_query("SELECT * FROM rsp_subscriptions WHERE username = '$id' ORDER BY date DESC"); $sub_row = mysql_fetch_assoc($sub); $sum = mysql_query("SELECT SUM(length) as total_length FROM rsp_subscriptions WHERE username = '$id'"); $subSum = mysql_fetch_assoc($sum); $sql = "SELECT * FROM rsp_users WHERE username = '$id'"; $e = mysql_query($sql); $row = mysql_fetch_assoc($e); //calculates subscription details $today = date("F j, Y, g:i a"); $startDate = $sub_row['date']; $endDate = strtotime($row['sub_end']); $sub_endit = $subSum['total_length'] + strtotime($startDate); $sub_endit2 = date("F j, Y, g:i a", $sub_endit); $end_sub_length = strtotime($subSum['total_length']) + strtotime(date("F j, Y, g:i a")); $sub_left = dateDiff($today, $sub_endit2); $formatStartDate = strtotime($startDate); $displayStartDate = date("F j, Y, g:i a", $formatStartDate); mysql_query("UPDATE rsp_users SET sub_left = '$sub_left' WHERE username = '$id'"); echo "sub_left: " . $row['sub_left']; ?> <br /> <b>Subscription Start: </b><?php if($sub_row['date'] < '0'){ echo "N/A<br>"; }else{ echo "$displayStartDate<br>";} ?> <b>Subscription End: </b><?php if(strtotime($sub_endit2) < strtotime('December 31, 1969, 5:00 pm')){ echo "N/A<br>"; }else{ echo "$sub_endit2<br>";} ?> <b>Subscription Left: </b><?php if($sub_left < '0'){ echo "N/A<br>"; }else{ echo "$sub_left days<br>";} ?> <b>Status: </b><?php if($row['activated'] == 0){ echo " Unactivated";} else { echo " Activated";} ?> <br /> <?php $sub = mysql_query("SELECT * FROM rsp_subscriptions WHERE username = '$id' ORDER BY date DESC"); if (mysql_num_rows($sub) > 0) { for ($i = '0'; $i < mysql_num_rows($sub); $i++) { $data = mysql_fetch_array($sub, MYSQL_ASSOC); if ($i == '0') { $first_date = $data['date']; echo $first_date; } else { // Some code here? } } } ?> datediff.php <?php /** * Finds the difference in days between two calendar dates. * * @param Date $startDate * @param Date $endDate * @return Int */ function dateDiff($startDate, $endDate) { // Parse dates for conversion $startArry = date_parse($startDate); $endArry = date_parse($endDate); // Convert dates to Julian Days $start_date = gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]); $end_date = gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]); // Return difference return round(($end_date - $start_date), 0); } ?> I tried your script, but it still calculates 60 days even though the first Subscription was bought in "Jan-1-2010"
-
I think I tried this, it kept giving me negative subscription time when I was testing it out. For example I set one sub_start to Jan-1-2010, and the other to Jan-1-2011, and it was negative one year.
-
Yes correct, but I am adding a new row for each subscription, then using this to calculate: $sub = mysql_query("SELECT * FROM rsp_subscriptions WHERE username = '$id' ORDER BY date DESC"); $sub_row = mysql_fetch_assoc($sub); $sum = mysql_query("SELECT SUM(length) as total_length FROM rsp_subscriptions WHERE username = '$id'"); $subSum = mysql_fetch_assoc($sum); $sql = "SELECT * FROM rsp_users WHERE username = '$id'"; $e = mysql_query($sql); $row = mysql_fetch_assoc($e); Its hard to explain but it seems to "reset" once a new month is added, I need to make it aware of the old dates with the new dates.
-
Okay guys, I figured out how to calculate monthly subscriptions into days, but I am stuck on calculating multiple monthly subscriptions.. for example Heres my mysql table: How would I calculate this: Subscription Start: February 21, 2011, 12:00 am Subscription End: April 22, 2011, 12:00 am Subscription Left: 60 days My trouble is that when the user buys another month, it calculates the end time based on the new "Subscription Start Date". Or vice versa. Any ideas guys? Thanks.
-
Okay guys, I figured out how to calculate monthly subscriptions into days, but I am stuck on calculating multiple monthly subscriptions.. for example Heres my mysql table: How would I calculate this: Subscription Start: February 21, 2011, 12:00 am Subscription End: April 22, 2011, 12:00 am Subscription Left: 60 days My trouble is that when the user buys another month, it calculates the end time based on the new "Subscription Start Date". Or vice versa. Any ideas guys? Thanks.
-
I have a layout (heres the code) that includes .php files into the index.php file. <?php // PHP Navigation ----------------------- $go = $_GET['go'];// Gets the ?go $fd = $_GET['fd'];// Gets the ?fd if(empty($go))// If go is empty { $go = 'main.php';// Includes the default page } // Cleaning the gets -------------------- $go = str_replace('http://','',$go); $go = str_replace('www.','',$go); $go = str_replace('.php','',$go); $go = str_replace('.txt','',$go); $fd = str_replace('http://','',$fd); $fd = str_replace('www.','',$fd); $fd = str_replace('.php','',$fd); // End of Cleaning the gets --------------- if(isset($fd) && isset($go) && file_exists($fd."/".$go.".php")){ include ($fd."/".$go.".php"); }else if(isset($go) && file_exists($go.".php")){ include ($go.".php"); }else{ echo "<p><b>Sorry, that page does not exist.</b></p>"; } // End of PHP Navigation ----------------- ?> I am trying to make it where I can navigate through my blog by visiting this url: http://www.lukeidiot.com/blog/29 by actually redirects to this url: http://www.lukeidiot.com/?go=blog&id=29 I was using this for my .htaccess ReWriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?go=$1 [QSA,L] I was exploding the $_GET['go'] by "/" and using it as such, but it didn't include correctly. I tried for hours but couldn't get it to work. (NOTE MY MOD_REWRITE DOESNT WORK) Thanks !!!
-
Hello. If you notice at this link: http://atomos.tumblr.com/post/1583437551 At the bottom there is a link labeled, "Show more notes.". I am trying to devise a way to make this automated using PHP. Heres the link, or javascript for "Show more users"... <a class="more_notes_link" href="#" onclick="this.style.display='none';document.getElementById('notes_loading_1598703430').style.display = 'inline';if(window.ActiveXObject)var tumblrReq=new ActiveXObject('Microsoft.XMLHTTP');else if(window.XMLHttpRequest)var tumblrReq=new XMLHttpRequest();else return false;tumblrReq.onreadystatechange=function(){if(tumblrReq.readyState==4){var notes_html=tumblrReq.responseText.split('<!-- START '+'NOTES -->')[1].split('<!-- END '+'NOTES -->')[0]; if(window.tumblrNotesLoaded)if(tumblrNotesLoaded(notes_html)==false)return;var more_notes_link=document.getElementById('more_notes_1598703430');var notes=more_notes_link.parentNode;notes.removeChild(more_notes_link);notes.innerHTML+=notes_html;if(window.tumblrNotesInserted)tumblrNotesInserted(notes_html);}};tumblrReq.open('GET','/notes/1598703430/WpyI5vO1W?from_c=1289946513',true);tumblrReq.send();return false;">Show more notes</a>
-
So like this? <?php $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_COOKIEFILE, "c:/xampp/htdocs/tumcookie.txt"); curl_setopt($curl, CURLOPT_COOKIEJAR, "c:/xampp/htdocs/tumcookie.txt"); curl_setopt($curl, CURLOPT_URL, "www.tumblr.com/dashboard"); $login = curl_exec ($curl); preg_match_all('~name="form_key" value="([^"]+)"~', $login, $matches); echo $matches[0]; curl_close ($curl); ?>
-
Thanks so much!
-
That just loads the site though, I dont see any HTML
-
Yeah the file_get_contents doesnt work for this server. Does anyone know how I can use cURL to get the HTML Source?
-
file_get_contents() will get the HTML of many URLs. file_get_contents() will get the HTML of many URLs. Not sure if that was a mispell, but "file_get_content()" is not a php function. It also doesnt get <form> html for some reason. I just dont know how to use cURL's returntransfer to read html. If anyone can tell me how to use cURL to get html, I would love you. Thanks!
-
I am using cURL, but can you show me an example on how to use it to get the html?
-
I am trying to find this form field "form_key" on tumblr.com If you view source on: http://www.tumblr.com/dashboard On firefox it shows this: <form style="width:0px; height:0px; overflow:hidden; position:absolute;" method="post" action="/set_avatar" id="set_avatar_form" enctype="multipart/form-data"> <input type="hidden" name="form_key" value="jg351pzpvzMSkyJIZZhkT7AfcQ"/> <input type="file" name="set_avatar" id="set_avatar" onchange="$('set_avatar_form').submit();"/> <input type="hidden" name="redirect_to" value="/dashboard"/> </form> But when I use php's file_get_content("http://www.tumblr.com/dashboard"); That data is no where to be found. Any idea how I can get that form data in my php file? For example I am trying to use regex preg_match_all to extract the form_key, but get_file_contents doesnt show the <form></form>
-
I am trying to use regex to find the following string: <input type="hidden" name="form_key" value="jg351pzpvzMSkyJIZZhkT7AfcQ"> How would I go about getting just the value "jg351pzpvzMSkyJIZZhkT7AfcQ" ? Thanks!
-
Thanks! Much Love.
-
I am trying to use preg_match_all to find some information on a webpage. Here is what I am currently using <?php $homepage = "http://www.example.com"; $page_contents1 = file_get_contents($homepage); $names1 = preg_match_all('/<span class="video_date">(.*)</span> - <a class="b" href="/(.*)/">(.*)</a><br/>\/', $page_contents1, $matches1); echo implode(", ", $matches1[1]); ?> I am trying to match this piece of html: <span class="video_date">Oct 21</span> - <a class="b" href="/meanwhilezealand/"> Meanwhile in New Zealand...</a><br/> Thanks for looking!
-
Nice site! For those who don't know this is a classic game, the design is supposed to look as it does i'm pretty sure. As for the ddos attacks, I can say that he gets them very regularly due to the nature of the game/niche.
-
rename connection.inc to php or people will be able to read your database connection info
-
If you want that to work try this... <?php if(isset($_POST['submit'])) { mysql_query("INSERT INTO users ('class') VALUES ('1')"); } ?> <form method="post" action=""> <input type="Submit" name="submit" value="Choose"> </form> Even though I have no idea why you have a form when you are inserting data directly "1" into class.
-
Make sure you CHMOD the dir. CHMOD: 777
-
I'ved add the "title" attribute to the img tag.
-
http://www.phpfreaks.com/forums/index.php/topic,37442.0.html