Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rich_traff's Achievements


Member (2/5)



  1. i dont have access to the php.ini file and currently am unable to contact the host admin. phpinfo() gives the following; SMTP - localhost - localhost smtp_port - 25 - 25 if that helps?
  2. I tried setting error reporting by placing it in with the mail part of the script <?php $email_from = "Example"; ini_set("sendmail_from", $email_from); ini_set('error_reporting', E_ALL); $headers = "From: $email_from"; No errors showed though, would it make a difference where i placed it? Also i looked in the error_log file from the site root but found nothing there. the last entry was from a few days ago and detailed some missing css files, there's nothing recent that suggests anything to do with mail or the script i have written. Am still to try the mail log script you suggested
  3. Hi, i've written a script that use's mail() in it to send some information. I've tested this on my own server and it works fine, however when i put it onto a clients server the email does not come through. Here is the email part of the script <?php $to = "me@example.com"; $subject = "subject"; $body = "Body of email"; $email_from = "Example"; ini_set("sendmail_from", $email_from); $headers = "From: $email_from"; if (mail($to, $subject, $body, $headers)) { echo("<p>Your email has been sent</p>"); } else { echo("<p>An error has occured</p>"); } So on my own server, the script runs, the message "Your email has been sent" shows and i receive the email. On my clients server, the script runs, the message "Your email has been sent" still shows, i do not get an error message, but the email never gets received. So im assuming it must be a config issue with their server… A problem though is that i only have ftp details for it and currently no way of contacting the web host, i don't even know where its hosted, all i have is a host ip, username and password. So, i am looking for some advice on A) what i should be looking for to figure out why the email is not getting through B) how to go about finding that info? C) options for improving the script that will ensure the email is sent/received.. Can anyone offer any advice?
  4. Yeah i see you point, thanks for tip, il rethink the approach...
  5. I have 2 websites, a companies main website written in PHP and a web application they have purchased written in aspx (main site) www.example.com (web app) www.webapp.com/login.aspx?CompanyName=example The client wants people to be able to login from their main website which then redirect to the webapp (which will be styled like their branding) without the customer realising they have left the main site. I thought i may be able to achieve this with a simple include from a page within the main site such as; <?php // www.example.com/software include"http://www.webapp.com/login.aspx?CompanyName=example"; ?> This pulls in the login page fine, however when you try to login it does not redirect, it gives a 404 error as it trys to open this URL http://www.example.com/software/login.aspx?CompanyName=example Is there a way of pulling in the necessary html from the aspx site to provide a login box in my clients main site but then have it redirect to the correct aspx page (on the aspx site)? I have thought about using an iframe, but that wont redirect to the webapp upon login, but just keep everything withing the iframe thanks for any advice...
  6. I have this function that does 3 things; 1) determines how many modules are published to a certain row in a joomla template layout. 2) sets the module width accordingly 3) outputs the html The modules are labeled A through H, what i want returned is the html for every module position to be published, at the moment it only returns the last pass of the foreach loop - so it outputs the html for module H, if i unpublished module H it will only show module G etc… I know it makes sense for that to be happening from looking at the code as it is now but i don't know how to change it so it does what i need… So, i want $result, to return all the html from each pass of the second foreach loop, can anyone help? <?php function modWidth3($row, $siteWidth, $mod) { $published = 0; $array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'); // Calculates how many modules are published to row foreach($array as $position) { if($mod->countModules('topRow' . $row . '_' . $position)) { $published = $published+1; } } // Sets module width according to number published $pixelsUsed = $published * 15; $pixelsLeft = $siteWidth - $pixelsUsed; $modWidth = $pixelsLeft / $published; $result =''; // Outputs published modules foreach ($array as $position) { if($mod->countModules('topRow' . $row . '_' . $position)) { $result =' <div id="topRow' . $row . '_' . $position.'" class="modRow" style="width:'.$modWidth.'px;"> <jdoc:include type="modules" name="topRow' . $row . '_' . $position.'" style="xhtml" /> </div>'; } } return $result; }
  7. As a side point, you may notice that im running a foreach loop twice, once to find out how many of the modules are published then again to output the html, on the second loop the module width is inserted (which depends on how many modules are published - ascertained from the first loop) I don't know if its possible to streamline this and only have to run 1 foreach loop but would appreciate any ideas...
  8. Hi, can anyone tell me how to turn this code into a function so i can reuse it again and again… It is for a joomla template file and calculates the widths of modules depending on how many are published to a certain row and what the site width is set at in the template parameters. So there is a row of module positions (rows increment in numbers 1, 2, 3 etc) each specific module has a letter (A, B, C etc) The code checks to see how many modules are published to that row and sets the width of each module accordingly, then outputs the div html. I am using an include at the moment like so <div id="topRow1_wrap"> <?php $row = 1; include 'includes/moduleWidths.php' ?> <div class="clear"></div> </div> with the code <?php $published = 0; $array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'); // Calculates how many modules are published to row foreach($array as $position) { if($this->countModules('topRow' . $row . '_' . $position)) { $published = $published+1; } } // Sets module width according to number published $pixelsUsed = $published * 15; $pixelsLeft = $siteWidth - $pixelsUsed; $percentageLeft = ($pixelsLeft / $siteWidth) * 100; $modWidth = $percentageLeft / $published; // Outputs published modules foreach ($array as $position) { if($this->countModules('topRow' . $row . '_' . $position)) {?> <div id="<?php echo'topRow' . $row . '_' . $position?>" class="modRow" style="width:<?php echo $modWidth;?>%;"> <jdoc:include type="modules" name="<?php echo'topRow' . $row . '_' . $position?>" style="xhtml" /> </div> <?php } } The values currently being used from the index.php are $siteWidth $row I want to turn this into a function and call it from the index.php file, but im unsure how… i tried this, but it didn't work, can anyone help? <?php require_once 'includes/moduleWidths.php'; ?> <div id="topRow1_wrap"> <?php $row = 1; modWidth($row, $siteWidth) ?> <div class="clear"></div> </div> <?php function modWidth($row, $siteWidth) { $published = 0; $array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'); // Calculates how many modules are published to row foreach($array as $position) { if($this->countModules('topRow' . $row . '_' . $position)) { $published = $published+1; } } // Sets module width according to number published $pixelsUsed = $published * 15; $pixelsLeft = $siteWidth - $pixelsUsed; $percentageLeft = ($pixelsLeft / $siteWidth) * 100; $modWidth = $percentageLeft / $published; // Outputs published modules $data = foreach($array as $position) { if($this->countModules('topRow' . $row . '_' . $position)) {?> <div id="<?php echo'topRow' . $row . '_' . $position?>" class="modRow" style="width:<?php echo $modWidth;?>%;"> <jdoc:include type="modules" name="<?php echo'topRow' . $row . '_' . $position?>" style="xhtml" /> </div> <?php } } return $data; }
  9. Tell me about it... At least its only one parameter thats changed, i've had a lot worse before. Your rewrite works perfectly, thanks again for your time
  10. Hi, i realise this is an old thread now but i have to make a change to the solution and am not sure how to do it so thought id repost here rather than start a new topic I am using this function supplied earlier in this thread by mjdamato <?php function getDateParts($startDate, $endDate) { //Normalize dates for 12noon to ensure full days calulation $startDate = strtotime(date("d F Y", $startDate) . " 12:00pm"); $endDate = strtotime(date("d F Y", $endDate) . " 12:00pm"); //Initialize array for return variable $return['totalWeeks'] = 0; $return['singeWeekendDays'] = 0; $return['singleWeekdays'] = 0; //Calculate total days, weeks, and remaining days $totalDays = round(($endDate-$startDate) / (60*60*24)) + 1; $return['totalWeeks'] = floor($totalDays/7); $remianingDays = $totalDays - ($return['totalWeeks']*7); //Determine types of remaining days while($remianingDays>0) { if(date("N", $endDate)>5) { $return['singeWeekendDays']++; } else { $return['singleWeekdays']++; } //Change end date to prev date, and reduce remaining days $endDate = strtotime(date("d F Y", $endDate) . " -1 day"); $remianingDays--; } return $return; } which takes a start date and end date and returns the number of full weeks (any 7 days), the remaining weekend days and week days. It currently counts any 7 day period as a week, so tues - mon is a valid week. The parameters have now changed though and i need to only count mon - sun as a full week. So if someone booked from wed to the following following fri, it should return 2 weekend days and 8 week days Where as if someone books from sun to the following tues, returned should be 1 week, 1 weekend day and 2 week days So, i need to input any start and end date and return; The number of full weeks (mon - sun) The number of remaining weekend days (sat, sun) The number of remaining week days (mon - fri) Now, i assume a way to adapt the function to give the full weeks would have something to do with counting any 7 day periods from the first date("N") to =1, then work out the remainders before and after this, but am not sure if this would be correct and even less sure how to implement it… can anyone help?
  11. Apologies… i didn't think that through before making my last post. I had in my head it would just be the query that would change, but the function would remain, clearly not so… You've given me more than enough help on this though and i really do appreciate it!
  12. @mjdamato, thanks so much for your help on this setting the if statement to this corrected the problem if ( datesAvailable($car_id, $start_date_unixTime, $end_date_unixTime)) Now, theres just one other thing, if you would be so kind... You mentioned the most efficient solution would be to check for a conflict in the db with the query itself, how would i go about that?
  13. ok, i think this is nearly there but have another issue which i think is just due to my inexperience using functions and not really knowing how to use them together properly… this code needs to be part of a larger function that checks a few things before returning a final output. I've taken the last rewritten function you provided and tested it on its own and it works no problems (the debugging helped me understand more so thanks for that) Im not really sure how to include functions within other functions though (and got errors whilst trying) so used an include. When i remove the redirects (from the controller file) your code echo's out everything you expect it to, correct date, returns true or false correctly etc. When i try to take the return value and base an if statement on it though (in the controller) it is always set to true… This is the controller file function <?php function points_spend() { // does stuff here $car_id = JRequest::getInt('id', ''); include 'bookings_overlap.php'; if ( $datesAvailable = true) { $this->setRedirect(JRoute::_('index.php?option=com_carbooking&id=' . $row->id . '&view=single'), 'The dates are true' . $datesAvailable); } elseif ( $datesAvailable = false) { $this->setRedirect(JRoute::_('index.php?option=com_carbooking&id=' . $row->id . '&view=single'), 'The dates are false' . $datesAvailable); } // does more stuff here } ?> and the included file <?php //Returns true/false based upon whether the requested dates conflict //with the already booked dates in the DB for the requested car id function datesAvailable($car_id, $start_date_unixTime, $end_date_unixTime) { /* $query = "SELECT start_date, end_date FROM #__carbooking_bookings WHERE car_id = '$car_id'"; $db->setQuery($query); $bookedDates = $db->loadRowList(); */ //Hard coded test array $bookedDates = array( array ('07/20/2011', '07/21/2011'), array ('08/16/2011', '08/17/2011') ); foreach($bookedDates as $key => $dates) { list($bookedStart, $bookedEnd) = $dates; if ($start_date_unixTime < strtotime($bookedEnd) && $end_date_unixTime > strtotime($bookedStart)) { //Conflicts detected, return false return false; } } //No conflicts detected, return true return true; } $datesAvailable = datesAvailable($car_id, $start_date_unixTime, $end_date_unixTime); ?> Can you tell me where im still going wrong with this? btw - i fully appreciate your time spent on this, i know i've already asked a lot...
  14. Yes, you were correct in your assumption... at least you were correct in assuming that i assumed the array would be formatted that way... turns out i should have checked more thoroughly...
  • 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.