Jump to content

rtadams89

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by rtadams89

  1. Ahh, interesting. That does seem to help. Thanks for the help.
  2. I got a bit further using this code: <?php // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, "https://membership.usarugby.org/PublicRosterRpt.aspx?ReportID=27343&PrinterFriendly=1"); //return the transfer as a string $userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"; curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); echo $output; ?> I at least get some of the page, but a major chunk (with the info I need) in the middle is missing. I think this is due to the use of JavaScript on the page, but I'm not sure what the javascript is doing, so I don't know where to go from here...
  3. Ultimately, I'm trying to get a list of all the "Individual names" that show up on this page: https://membership.usarugby.org/PublicRosterRpt.aspx?ReportID=27343&PrinterFriendly=1 To get the contents of that page (for later parsing with regex), I first tried to use file_get_contents(), but it seems to return the contents of a "Object Moved" error page. Looking at the source code of the page I am trying to scrap, it looks like it uses JavaScript to submit a form post before the data is shown, I image this is why an error page is returned when I attempt to use file_get_contents(). For my second attempt, I used this function which I found on the PHP.net comments page for file_get_contents(). function http_post ($url, $data) { $data_url = http_build_query ($data); $data_len = strlen ($data_url); return array ('content'=>file_get_contents ($url, false, stream_context_create (array ('http'=>array ('method'=>'POST' , 'header'=>"Connection: close\r\nContent-Length: $data_len\r\n" , 'content'=>$data_url )))) , 'headers'=>$http_response_header ); } It too returned the same error page. I would appreciate some help in getting the page data of the URL above into a PHP variable so that I can process it further.
  4. I have a frameset page, on which I use the following code to dynamically resize the iframe based on the size on the content page in the iframe: <script type="text/javascript"> /*********************************************** * IFrame SSI script II- � Dynamic Drive DHTML code library (http://www.dynamicdrive.com) * Visit DynamicDrive.com for hundreds of original DHTML scripts * This notice must stay intact for legal use ***********************************************/ //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: var iframeids=["forumframe"] //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): var iframehide="no" var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeCaller() { var dyniframe=new Array() for (i=0; i<iframeids.length; i++){ if (document.getElementById) resizeIframe(iframeids[i]) //reveal iframe for lower end browsers? (see var above): if ((document.all || document.getElementById) && iframehide=="no"){ var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) tempobj.style.display="block" } } } function resizeIframe(frameid){ var currentfr=document.getElementById(frameid) if (currentfr && !window.opera){ currentfr.style.display="block" if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax currentfr.height = currentfr.Document.body.scrollHeight; if (currentfr.addEventListener) currentfr.addEventListener("load", readjustIframe, false) else if (currentfr.attachEvent){ currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.attachEvent("onload", readjustIframe) } } } function readjustIframe(loadevt) { var crossevt=(window.event)? event : loadevt var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement if (iframeroot) resizeIframe(iframeroot.id); } function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url } if (window.addEventListener) window.addEventListener("load", resizeCaller, false) else if (window.attachEvent) window.attachEvent("onload", resizeCaller) else window.onload=resizeCaller </script> When I try to load a page from outside my domain (say http://google.com), the script throws an error. Why is this, and is there any work around?
  5. The exact code would depend on the format of the image tags in your blog content, but couldn't you just load the blog post into a php variable, and use something like str_replace("<img width = 500", "<img width = 200", $blog_content_var) ? If the imgage tags are not consistant, you could use a regex to find and replace them.
  6. I finally got it working. Very simple once I managed to get the numbers straight in my head.
  7. As part of my web gallery, I have a script which generates thumbnails from uploaded pictures. The uploaded pictures vary in dimensions from portrait to landscape. I want all the thumbnails to be exactly 100 x 66 pixels, and contain no white space or "filler." Additionally, I want to maintain the aspect ratio of the original image. Obviously, this means some cropping will occur with images that don't have a 100/66 aspect ratio. I'm familiar with PHP, but not with the GD library, so I've been looking at example scripts to do this. I've found plenty that will create 100 x 66 thumbnails, but they all seem to either distort the aspect ratio to make the picture fit or include white space to pad the image. I have yet to find one that will properly crop and re size any image I throw at it to produce a thumbnail with as much of the original image as possible, while maintaining the aspect ratio. Can anyone point me to such a script?
  8. I'm trying to create a PHP website that will analyze Windows minidump files. I am using the Microsoft Debugger Tools, and specifically kd.exe, to analyze minidumps. If I'm interacting with the computer PHP/Apache is running on, I can open a command prompt and type: "c:\program files\debugging tools for windows (x86)\kd.exe" -y srv*c:\symbols*http://msdl.microsoft.com/download/symbols -i c:\windows\i386 -z c:\test.dmp This will tell me what file caused the crash recorded in the test.dmp minidump file. I'm trying to run this same command in a PHP web page using: passthru("\"c:\program files\debugging tools for windows (x86)\kd.exe\" -y srv*c:\symbols*http://msdl.microsoft.com/download/symbols -i c:\windows\i386 -z c:\test.dmp") Unfortunately, this causes PHP and the web server to hang. I suspect this happens because kd.exe doesn't automatically quit after running. Instead, it goes to a kd.exe debugger prompt. Any ideas about how to go about getting the output of kd.exe using PHP?
  9. A bunch of my relatives got web cams for Christmas and now ant to be able to sue them to chat with one another. I've tried to instruct them on how to do this using a IM application, but since some use Skype, some use MSN, some user AIM, etc. there is not a convenient way to get them all connected. I have been looking into a website based solution. Basically, I want my family members to go to a web page I host, log in, and be able to view (literally) the other family members who are also logged in. I have found a few Flash based solutions (such as http://www.flashpioneer.com/chat/demo/fpchat2.htm), but they are all expensive. Does anyone know of a free, video chat system I can install on my webspace?
  10. I have the following javascript in the HEAD section of one of my pages <script language="JavaScript"> function emailWindow() { eval( "page = window.open('email.php?id=<?php echo $id; ?>', '<?php rand(); ?>', 'toolbar=0,scrollbars=1," + "location=0,statusbar=0,menubar=0,resizable=0,width=250,height=200');" ); } opener.location = "index.php?month=<?php echo $month ?>&year=<?php echo $year ?>"; window.setTimeout('window.close()', 1000); </script> I then have a body onload event set to call the emailWindow() function. Basically what happens is the original page loads, pops up a new page (using the emailWindow function), then closes the original page. Some pop-up blockers prevent the pop-up page from opening. When this happens, I would like the original page to stay open so the user can click a link to manually open the pop-up page. How would I go about doing this?
  11. When you say reduce what you are sending, do you mean you want to cut down on the actual size (bytes) or the # of variables that have to be passed? If you just want to reduce the number of variables, try putting all the md5 sums in an array. Then you can reference the array and pull out any m5d sum or all of them. I don't think md5($ck1+$ck2+$ck3+$ck4+$ck5); is a very good idea. Manly because this will return a different md5 if the same files are sent, but in a different order. md5($ck1+$ck2+$ck3+$ck4+$ck5) != md5($ck5+$ck4+$ck3+$ck2+$ck1); You could always do something like md5($ck1) + md5($ck2) and have it work for your application, but it's not truly a checksum if you do that.
  12. You could always use <a href="http://yourwebsite.com/images/image.jpg" />
  13. How about phpStylist: http://sourceforge.net/projects/phpstylist/ You can use it from the command line if you have PHP installed on your local machine, or upload the single PHP file to your web server and do everything from a web front end.
  14. Right, but how would I get that to run? If I trigger it with the body onLoad event handler, it will run prematurely, and close the page before the email script runs.
  15. I have the following code: <?php $gzip_off = 1; require($_SERVER['DOCUMENT_ROOT'].'/includes/config.php'); require($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php'); if (($auth_lvl >= 2) && (isset($_GET['id']))) { //Email members on addition of new event. $id = $_GET['id']; mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); $sql = "SELECT d, m, y, title, text FROM calendar WHERE id=" . $id; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); $d = $row["d"]; $m = $row["m"]; $y = $row["y"]; $title = $row["title"]; $text = $row["text"]; ob_start(); ?> <html> <head> <title>DO NOT CLOSE</title> </head> <body> <center><b>DO NOT CLOSE THIS WINDOW!</b> <br>E-Mails are being sent to members.</center> <? //Output buffering fix echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; ob_flush(); flush(); $recipients = calendar_mail(); $subject = 'New Event'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: *** <no-reply@***.com>' . "\r\n"; $message = ' <html> <head> <title>New *** Event</title> </head> <body> <p>A new event has been posted on the <a href="http://www.***.com/schedule.php">***.com calendar</a>.</p> <br>Event Title: '.$title.' <br>Event Date: '.$m . "/" . $d . "/" . $y.' <br>Added by: '.$name.' <br>Event Details: '.$text.' <br><br>If you want to stop receiving notices when new events are added, you can change your notification preferences here: <a href="http://www.***.com/user_cp.php">http://www.asurfc.com/user_cp.php</a>. </body> </html> '; mail($recipients, $subject, $message, $headers); echo "<br><center><font color='RED'><b>You may now close this window.</b></font></center></body></html>"; } else { echo "ERROR"; } ?> As you can see, it uses output buffering to alert users that a PHP script is still running (sending emails in this case) and then notifies the user when the script finishes. Is there anyway to cause the window to close automatically when the script finishes?
  16. There was a slight syntax error in your code, but I got it to work with if (!isset($gzip_off)) { ob_start("ob_gzhandler"); } Thanks for the help.
  17. I start all of my PHP pages off with this code: <? require_once($_SERVER['DOCUMENT_ROOT'].'/includes/config.php'); ?> The "config.php" file contains (among other things) this: ob_start("ob_gzhandler"); which enables gzip compression for all my pages. I have one page on my site for which I need gzip compression OFF. I tried surrounding the gzip code in the "config.php" with an IF statement as follows: if (!isset($GET_['gzipoff'])) { ob_start("ob_gzhandler"); } then one the file for which I want gzip off, I changed the require_once line to: <? require_once($_SERVER['DOCUMENT_ROOT'].'/includes/config.php?gzipoff=1'); ?> Unfortunately this results in an error about not being able to include the file. Is it not possible to pass a variable to the included file this way? If not, is there a simple way to disable the gzip compression on just this one page?
  18. Is there a nice way to allow who ever is submitting the new calendar event to know what is going on. Otherwise I'm afraid they will think the browser windows is frozen and close it.
  19. So will breaking it into multiple mail() commands that are run in series make it faster?
  20. I'm not to worried about everyone seeing the other user's emails. We are a small organization, and all the members already have access to each other's emails. Unfortunately I do not have shell access. This is one of 1&1's $4/month linux hosting packages. My concern is not with how long it takes for the emails to be sent, but with the delay it introduces in loading the page. Would it be faster to have 5 mail() commands, watch with only 1/5 the recipients? Could I somehow have the mail() command happen in the background so as to not hold up the rest of the script?
  21. I'm hosting my site on a shared Linux hosting package at 1&1. I'm using the following code as part of a larger project to email all my users when a new event gets added to my site's calendar. The $recipients variable is a comma separated string of about 90 email addresses. //Email members on addition of new event. $sql2 = "SELECT * FROM phpbb_users WHERE user_id = ".$uid.""; $result2 = mysql_query($sql2) or die(mysql_error()); $row2 = mysql_fetch_assoc($result2); $name = preg_replace('/(\w+)([A-Z])/U', '\\1.\\2', $row2['username'], 1); $name = explode(".", $name, 2); $name = $name[0] . " " . $name[1]; $recipients = calendar_mail(); $subject = 'New ASURFC Event'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ASURFC <no-reply@asurfc.com>' . "\r\n"; $message = ' <html> <head> <title>New ASURFC Event</title> </head> <body> <p>A new event has been posted on the <a href="http://www.asurfc.com/schedule.php">ASURFC.com calendar</a>.</p> <br>Event Title: '.$title.' <br>Event Date: '.$month . "/" . $day . "/" . $year.' <br>Added by: '.$name.' <br>Event Details: '.$text.' <br><br>If you want to stop receiving notices when new events are added, you can change your notification preferences here: <a href="http://www.asurfc.com/user_cp.php">http://www.asurfc.com/user_cp.php</a>. </body> </html> '; mail($recipients, $subject, $message, $headers); When this code is run, it takes about a minute to complete. It does work, it just takes sooooooooooooo long. I'm worried that as I add more recipients, I will begin to experience errors dues to PHP's max execution time. Should the mail() function be this slow? Is there any way to make it faster?
  22. The "$users" variable needs to be a comma separate list of email addresses. Such as "a@a.com, b@b.com, c@c.com". Here is the function I use to retrieve email addresses from my database and turn them into a coma separated list: function calendar_mail() { //Database connection $conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Error connecting to mysql'); mysql_select_db(DB_NAME); $sql = 'SELECT user_email FROM phpbb_users WHERE user_notify_calendar="1" AND user_email!=""'; $result = mysql_query($sql); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $recepients = $recepients.$row['user_email'] . ", "; } $recepients = rtrim($recepients, " ,"); return $recepients; } The examples on the php website are also very helpful: http://us.php.net/function.mail
  23. I have phpBB 3.0.3 installed and working great. I am trying to use the phpBB user data on other pages of my site (not phpBB related). For example, I have one page which I only want displayed to currently logged in forum members, who belong to the phpBB group #7 or #8. Here is the current code of that page: <?require($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');?> <? define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $_SERVER['DOCUMENT_ROOT'].'/forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); $username = $user->data["username"]; $uid = $user->data["user_id"]; if (($user->data["is_registered"]) && (($user->data['group_id'] == || ($user->data['group_id'] == 7))){ $auth = 2; //Logged in as Coach/Officer } elseif (($user->data["is_registered"]) && ($user->data['group_id'] != && ($user->data['group_id'] != 7)){ $auth = 1; //Logged in as player } else{ $auth = 0; //Not logged in } if ($auth == 2) { //Display "secret" content here } ?> This works fine. However, I will be using the $auth variable on multiple pages. I would therefor like to place all of the above code in a function inside "functions.php" (included at the top of each page). I though I could just create a function like that: function phpbb_auth() { define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $_SERVER['DOCUMENT_ROOT'].'/forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); $username = $user->data["username"]; $uid = $user->data["user_id"]; if (($user->data["is_registered"]) && (($user->data['group_id'] == || ($user->data['group_id'] == 7))){ $auth = 2; //Logged in as Coach/Officer } elseif (($user->data["is_registered"]) && ($user->data['group_id'] != && ($user->data['group_id'] != 7)){ $auth = 1; //Logged in as player } else{ $auth = 0; //Not logged in } return $auth; } and then place "phpbb_auth();" at the top of my content page. This always results in a 500 error when viewing the page. I don't know if the problem is in the way I Construct and call the function, or if it is a limitation of phpBB. Any help?
  24. Awesome. At point should I worry about using separate include files? @redarrow: What would be the advantage of using the "include_once()" or "require_once()"? Since I am including the file at the top of the page, there doesn't seem to be a way for it to ever be accidentally loaded again...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.