PHP - Help With My Open Source Script (.htaccess Is The Only Broke Part)
I have an open source project (https://github.com/j.../patchdashboard)
Here's my .htaccess for this:
RewriteEngine On RewriteBase "/pm/" RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /patches/server/(.*)$ patch_list?server= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /packages/server/(.*)$ packages?server= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /search/exact/(.*)$ search?package=&exact=true [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /search/(.*)$ search?package= [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /rewrite_check/(.*)$ rewrite_check.php [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ index.php?page= [QSA,L]Basically, I want it so that no matter where they drop this script ("/", "/patch_dashboard/", "/pb/", etc.) it will redirect as intended. In the example I provided, the document root is "/pm/". When I try to hit a page ("http://dev2.curltool...es/server/demo1" for example), it gives a 404. If I hard code in each rule the base path, it just redirects everything to the main page. Any help would be greatly appreciated. Similar TutorialsHey folks,
I'm looking for an open-source php project to contribute to. I'm not looking for a really well-known project (ex: Wordpress, Zencart)
Something small would be greatly appreciated!
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=355719.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342675.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=331038.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347431.0 This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=329796.0 This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=318011.0 Hi I have a script below which I have put together from a couple of other scripts which simply adds an email address to a database for a newsletter and sends an email to the owner and to the user it then shows a success page. The script checks that the email is valid and there is also a captcha. The script works in that it only send out the emails if the captcha etc is entered correctly but the email is being added to the database regardless of whether the capture is correct or not. I was proud of myself for getting this far but would love some instruction on what I have missed and how to stop the email adding to the database unless it has passed the captcha. Below you will see the script. The commented out sections are parts of the old script I don't use. <?php require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TESTING); $error = false; if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) { //$name = tep_db_prepare_input($HTTP_POST_VARS['name']); $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']); //$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']); if (tep_validate_email($email_address) == false) { $error = true; $messageStack->add('testing', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); } //CAPTHCA CODE start require(DIR_WS_FUNCTIONS . 'capcha_code.php'); $code_query = tep_db_query("select code from capcha_code where oscsid = '" . tep_session_id($HTTP_GET_VARS[tep_session_name()]) . "'"); $code_array = tep_db_fetch_array($code_query); $code = $code_array['code']; tep_db_query("DELETE FROM " . TABLE_CAPCTHA_CODE . " WHERE oscsid='" . $vvcode_oscsid . "'"); //remove the visual verify code associated with this session to clean database and ensure new results $user_entered_code = $HTTP_POST_VARS['capcha_code']; if (!(strcasecmp($user_entered_code, $code) == 0)) { //make the check case insensitive $error = true; $messageStack->add('testing', CAPCTHA_CODE_ENTRY_ERROR); } //CAPTHCA CODE stop /* testing sign up start */ if (isset($HTTP_POST_VARS['testing_sign_up'])) { $testing_query = tep_db_query("select testing_id_number from " . TABLE_TESTING_SIGN_UP . " where testing_email_address = '" . tep_db_input($email_address) . "'"); if(tep_db_num_rows($testing_query) == 0) { $sql_data_array = array('testing_email_address' => $email_address, 'testing_firstname' => "", 'testing_lastname' => ""); tep_db_perform(TABLE_TESTING_SIGN_UP, $sql_data_array); } } /* testing sign up end */ if ($error == false) { tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $email_address,STORE_OWNER_EMAIL_ADDRESS); tep_mail(MESSAGE_TEXT, $email_address, CUSTOMER_SUBJECT, NUMBER_ONE, STORE_OWNER_EMAIL_ADDRESS); tep_redirect(tep_href_link(FILENAME_TESTING, 'action=success')); } } $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_TESTING)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td><!-- body_text //--> <td width="100%" valign="top"><?php echo tep_draw_form('testing', tep_href_link(FILENAME_TESTING, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td><td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td></tr> </table> </td></tr><td class="main"><?php echo INFORMATION_TEXT; ?></td> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr> <?php if ($messageStack->size('testing') > 0) { ?> <tr> <td><?php echo $messageStack->output('testing'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) { ?> <tr> <td class="main" align="left"><?php echo tep_image(DIR_WS_IMAGES . 'clever.gif', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_COMPLETE; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } else { ?> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2" > <!--<tr> <td class="main"><?php echo ENTRY_NAME; ?></td> </tr> <tr> <td class="main"><?php echo tep_draw_input_field('name'); ?></td> </tr>//--> <tr><td class="main"><?php echo INSTRUCTIONS_TEXT; ?></td></tr> <tr> <td class="main"><?php echo ENTRY_EMAIL; ?> <?php echo tep_draw_input_field('email'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <!--<tr> <td class="main"><?php echo ENTRY_ENQUIRY; ?></td> </tr> <tr> <td><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15, $infotext); ?></td> </tr>//--> <!-- CAPTHCA CODE-- START--> <tr> <td class="main"><?php echo CAPCTHA_CODE_CATEGORY; ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" cellspacing="2" cellpadding="2"> <tr> <td class="main"><?php echo CAPCTHA_CODE_TEXT_INSTRUCTIONS; ?></td> <td class="main"> <?php // ----- begin garbage collection -------- tep_db_query("DELETE FROM " . TABLE_CAPCTHA_CODE . " WHERE dt < DATE_SUB(NOW(), INTERVAL 5 HOUR)"); // ----- end garbage collection -------- //can replace the following loop with $capcha_code = substr(str_shuffle (CAPCTHA_CODE_CHARACTER_POOL), 0, rand(3,4)); if you have PHP 4.3 $capcha_code = ""; for ($i = 1; $i <= rand(3,4); $i++){ $capcha_code = $capcha_code . substr(CAPCTHA_CODE_CHARACTER_POOL, rand(0, strlen(CAPCTHA_CODE_CHARACTER_POOL)-1), 1); } $vvcode_oscsid = tep_session_id($HTTP_GET_VARS[tep_session_name()]); tep_db_query("DELETE FROM " . TABLE_CAPCTHA_CODE . " WHERE oscsid='" . $vvcode_oscsid . "'"); $sql_data_array = array('oscsid' => $vvcode_oscsid, 'code' => $capcha_code); tep_db_perform(TABLE_CAPCTHA_CODE, $sql_data_array); $capcha_code = ""; echo('<img src="' . FILENAME_CAPCTHA_CODE_DISPLAY . '?vvc=' . $vvcode_oscsid . '"'); ?> </td> <td class="main"><?php echo CAPCTHA_CODE_BOX_IDENTIFIER; ?></td> <td class="main"><?php echo tep_draw_input_field('capcha_code'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <!-- testing sign up start//--> <TD WIDTH="100%"> <tr> <td class="main" align="right"><?php echo ENTRY_TESTING_SIGN_UP; ?> <?php echo tep_draw_checkbox_field('testing_sign_up', '1', true); ?> </td></tr> <!--testing sign up end //--> <!-- CAPTHCA CODE-- STOP --> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </table></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } ?> </table></form></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Hi I have previously posted this in the Jquery section but im not so sure its a Jquery issue now, so apoligies for the double post. I am having an issue with a rating system that works if i access the gamecards.php file through its absolute path (www..../...../gamecards.php) but will not work if i access it through a file that it is an include of (www..../reviews.php) Basicaly, when i click on the link through the include, the data is not sent to the DB and the data does not refresh. gamecards.php all works fine when its not as an include. Any ideas why? Gamecards.php is posted below Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var dataString = 'id='+ id ; var parent = $(this); if(name=='up') { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "up_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } else { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "down_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } return false; }); }); </script> </head> <body> <?php include('config.php'); //get results from db if (isset($_GET['gameid']) && is_numeric($_GET['gameid'])) { $gameid = mysql_real_escape_string($_GET['gameid']); $sql = "SELECT * FROM Games WHERE gameid = $gameid"; $res = mysql_query($sql); $data = mysql_fetch_assoc($res); // However you'd like to format the html to output $title=$data['gametitle']; $cover=$data['cover']; $gameid=$data['gameid']; $info=$data['info']; $genre=$data['genre']; $rdate=$data['releasedate']; $format=$data['format']; $dir1="coverart"; $reviews="Enter Reviews Here"; date("d/m/y",$rdate); echo "<div id='cardcontainer_full'> <div id='coverart'><img src='$dir1/{$cover}' width='100' height='140'><br></div> <div id='gametitle'>$title</div> <div id='features'>Gen $genre<br><br> Release Date: $rdate<br><br> Available for: $format<br><br> </div> <div id='gameinfo'><div style='font-weight:bold'>Summary</div><br>$info <p><div style='font-weight:bold'>Reviews</div><p>$reviews </div> </div>"; } else { $data = ''; if(isset($_GET['filter']) && $_GET['filter'] != ''){ $filter = $_GET['filter']."%"; }else{ // set A as default $filter = "a%"; } $sql = "SELECT * FROM Games WHERE gametitle LIKE '$filter' ORDER BY gametitle"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("No records found"); // loop through the results returned by your query while($row = mysql_fetch_assoc($res)) { $title=$row['gametitle']; $cover=$row['cover']; $gameid=$row['gameid']; $up=$row['up']; $down=$row['down']; // directory for images $dir="coverart"; ?> <div id="cardcontainer"> <div id="coverart"> <?php echo "<img src='$dir/{$cover}' width='100' height='140'><br>"; ?> </div> <div id="gametitle"> <a href="Reviews.php?gameid=<?php echo $gameid ?>"><?php echo $title ?></a> </div> <div id="friendrating">Rate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="up"><?php echo $up; ?></a></div> <div id="globalrating">Hate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="down"><?php echo $down; ?></a></div> </div> <br /> <?php } } ?> </body> </html> My query gets the results and orders by one of the fields. Once I get the MySQL results I would like to find the first entry that has a letter as the first character of the same field that the list was ordered by, then split the results in to two parts and swap them. So that the results that have a letter at the start of the same sorted field are as the begining and the results that have the numbers as the start at the end of the array. But also so that the array works the same way as the original results string, so i can use say $results['mysqlfield'] Code: [Select] <? $out = preg_replace('/^(.{701}[^.]*).*/i','$1.',$detrsltnewsrow[news_desc]); echo $out; ?> </td></tr><tr><td colspan="2" class="para" style="padding-left:10px;"> <?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701) ?> </td></tr> I have the above snippet.. The first php statement, basically grasp the first 701 characters with the closet next stop "." character and out puts it. then out puts the HTML tags I have a problem with the second statement. I want to output anything after what has been outputted by: Code: [Select] <? $out = preg_replace('/^(.{701}[^.]*).*/i','$1.',$detrsltnewsrow[news_desc]); echo $out; ?> So need the correct syntax for Code: [Select] <?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701) ?> Currently it breaks at exactly the 701 character, want it to continue from the sentence the first code ended in. Hello all! I've been searching for sometimes without result on how to write a PHP script to open video streams in a website. When I open a website where there are links to several video streams and what I would like to do is to view them all in a consecutive manner (kind of a playlist). Could any one help me with this? Many thanks in advance! BR, Tomi Well I am using easy php and I need to make a script that will open up a script in easy php in the web browser.. so like a script to open http://127.0.0.1:8888/script.php then sleep for x amount of time then open another script in the browser http://127.0.0.1:8888/script2.php Any help is appreciated Hi Guys! I'm new here at PHPFreaks, I have this problem using simplexml_load_file function. I am retrieving an XML from another sub-domain of my project, it's working fine on my local server (win xp, php 5.2.14) but when I try to execute it on our testing server (linux, php 5.2.14) it returns an error something like this.. Warning: simplexml_load_file([url of the script]) [function.simplexml-load-file]: failed to open stream: Connection timed out in [absolute path of the script] on line 3 i have tried cURL and file_get_contents, still get no luck. please note that the XML is validated via w3c.org and works really fine on my local server.. Thanks in advanced! I'm starting to learn the image related functions with PHP. And I can't seem to get this image to work properly: <?php //set our page to display an image header ('Content-Type: image/png'); //create our image $img = @imagecreatetruecolor(450, 120); //create our white color $white = imagecolorallocate($img, 255, 255, 255); //create our string imgagestring($img, 1, 150, 60, 'Test', $white); imagepng($img); imagedestroy($img); ?> All I get is the img doesn't exist icon: http://osremake.org/test/index.php I've even looked up in the PHP manual to see if I'm doing anything wrong. :/ Code: [Select] $birthday = implode(",",$_POST['BirthDay']); $bday = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" ); echo $birthday['0']; exit; //var_dump($colorarrays); if (!in_array($birthday['0'], $bday)) { message("Please select a Correct Birthday, or u trying to hack"); } Okay, if I enter "55325" for my first birthday POST, it only shows "5" and thus making the in_array not work correctly how can i implode my data correctly ty Code: [Select] $colorarray = isset($_POST['form']['color']) ? intval($_POST['form']['color']) : 0; $color = array( "1", "2", "3", "4", "5", "6", "7", "8", "8", "9", "10", "11", "12", "13", "14", "15", "16" ); if (in_array($color, $colorarray)) { echo "search found"; exit; }else{ echo "hacker"; exit; } i submit my $_POST['form']['color'] as 1 through 16 and it always says hacker? Code: [Select] $ids = implode (",", $ibforums->input['checkbox']); $time = time(); $ids2 = implode (",", $ibforums->input['pendingusers']); $DB->query("UPDATE friends_pending SET pending='0',date=$time WHERE id IN ($ids) AND toid IN ($ids2)"); weird thing is, it's not bring up any error's or nothing $ids2 spits out 2,30 and $ids spits out 9,7 for this particular project doesn't give me mysql error or nothing, script runs fine. I have mysql error enabling under $dbquery class so nn to worry, how to get this to work? Can i even use 2 IN's in 1 query or??? The following code works fine when using chrome or firefox, but fails with IE. Error: Requested site is either unavailable or cannot be found. Question: Does anyone see anything here that is a known bug with IE that I don't know about? Code: [Select] public function download(){ if($this->validateFile()){ if(!headers_sent()){ header('Content-type: '.$this->getType()); header('Content-Disposition: attachment; filename="'.$this->name.'"'); readfile($this->file); } else{ echo 'Headers have already been sent and are preventing the file download from taking place.'; } return true; } return false; } //I felt this function might be relevant to the issue. I know, it's kind of a ghetto function, I'll improve on it some other time though. private function getType(){ $types=array( 'txt' => 'text/plain', 'mp3' => 'audio/x-mp3', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'doc' => 'application/msword', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/flv', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'avi' => 'video/x-msvideo', 'rtf' => 'application/rtf', 'pdf' => 'application/pdf', 'zip' => 'application/zip', 'exe' => 'application/octet-stream', 'xls' => 'application/msexcel', 'xlsxl' => 'application/msexcel'); if(!$types[$this->getExt()]==''){ return $types[$this->getExt()]; } return 'application/octet-stream'; } |