Jump to content

rondog

Members
  • Posts

    753
  • Joined

  • Last visited

    Never

Everything posted by rondog

  1. got it..since my htaccess was in the sub directory, I didn't need the first /sub RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L] here is the full thread. It shows using htaccess in webroot as well as using htaccess in sub directory. The example above is for in the directory http://stackoverflow.com/questions/6668423/mod-rewrite-for-sub-directory
  2. I also tried: RewriteRule ^/sub/([^/\.]+)/?$ /sub/index.php?page=$1 [L] and same result
  3. I have a domain and a sub folder, called "sub"..inside "sub" is index.php which has this: <?php $page = $_GET['page']; switch ($page) { case "main": echo "main"; break; case "task_orders": echo "task_orders"; break; case "team_members": echo "team_members"; break; case "team_experience": echo "team_experience"; break; case "quality_assurance": echo "quality_assurance"; break; case "geographical_support": echo "geographical_support"; break; case "contact": echo "contact"; break; default: echo "main"; } my htaccess in "sub" is: Options +FollowSymLinks RewriteEngine On RewriteRule ^sub/([^/\.]+)/?$ index.php?page=$1 [L] when I click a link which looks like: <li><a href="/sub/main" title="Main" class="current">Main</a></li> <li><a href="/sub/task_orders" title="Task Orders">Task Orders</a></li> <li><a href="/sub/team_members" title="Team Members">Team Members</a></li> <li><a href="/sub/team_experience" title="Team Experience">Team Experience</a></li> <li><a href="/sub/quality_assurance" title="Quality Assurance Program">Quality Assurance</a></li> <li><a href="/sub/geographical_support" title="Geographical Support">Geographical Support</a></li> <li><a href="/sub/contact" title="Points of Contact">Points of Contact</a></li> I get a page not found rather than echoing out what page I am on
  4. you my friend are a genius...that totally worked!
  5. So a PHP script is creating the folder through a form and is setting the owner/group to "apache/apache" whereas the script is "mc1967/psacIn" Can I do anything in the PHP to set its owner/group?
  6. I'm installing an app on a clients server and when I try and upload through the form, I get this error: <b>Warning</b>: move_uploaded_file() [<a href='0function.move-uploaded-file0'>function.move-uploaded-file0</a>]: SAFE MODE Restriction in effect. The script whose uid is 10053 is not allowed to access /var/www/vhosts/xxxxxxx.ca/httpdocs/clients/project_data/test owned by uid 48 in <b>/var/www/vhosts/xxxxxxx.ca/httpdocs/clients/upload.php</b> on line <b>50</b><br /> I've installed this same app on other servers and haven't ran into this problem before. The client is on a shared host so I do not have php.ini access. Any ideas? thanks
  7. alright..im just tryin to figure out why this particular server I am working with is giving me a 500 internal server error after the upload reaches 100%. It uploaded a 5mb file fine, but a 40mb file produced a 500 internal server error. The max post size is 100m and the upload max filesize is 100m
  8. Not sure if this solves the issues, but before concatenating a var you need to first define it. This wont work: $message1 .= 'Email: '.$email."\n\n"; $message1 .= 'Name: '.$name."\n\n"; It has to be: Not sure if this solves the issues, but before concatenating a var you need to first define it. This wont work: $message1 = 'Email: '.$email."\n\n"; $message1 .= 'Name: '.$name."\n\n";
  9. the username and password you are using to connect to your mysql server are incorrect
  10. If I have an upload script and it takes 10 minutes to upload a file, will having max_execution_time set to 60 not work since it is only a minute?
  11. I like yours, nice. Yeah, not really sure why mine if coloring properly. I am kinda just bored with dreamweaver. It is still one of the best syntax highlighters I've came across. I spent a good deal of time modifying the CodeHints.xml file for dreamweaver. I added a ton of functions for hints
  12. I am trying out Zend Studio. I've used dreamweaver for years. The color highlighting isn't very good right off the bat. Simple php methods like 'readfile' or 'substr' aren't colored. Most everything is black text. I am seeing screen shots where this is actually colored properly. Am I doing something wrong? [attachment deleted by admin]
  13. You almost got it <?php $end_date = strtotime('29 March 2011'); if (time() < $end_date) { //show your form } else { //registration is over } ?>
  14. I have a mobile app. They visit a web site where they login. The videos live above web root, thus making it impossible for anyone to directly link to the video file. On iOS, I made a PHP script that checks if they are logged in first and if they are I use a range download method that acts like streaming. Works great! On android however, the script isn't working..lame. So I was trying to think of other methods to deliver the video, but first checking if they are logged in. My idea was to check if they are logged in, if they are, copy the video from above web root to a temp directory in web root and give it a uniqid name and insert it into the DB. That ID will then expire after two hours and I would delete the video. Ok that sounds like it would work for both phones, except with high traffic, that could be problematic. My next idea was symlinks, but I don't know much about them other than they are a shortcut. Could I potentially use a symlink to give the logged in user a video file that lives above web root?
  15. Hey guys, I am trying to create an ajax pagination class. Right now I have it displaying all the pages. I want to make it so I can display something like 1...8 9 10 11 12 13...28 (when you're in the middle) 1 2 3 4 5 6...28 (when you're in the beginning) 1... 23 24 25 26 27 28 (when you're at the end) Just like its setup on these forums. The number of numbers in the middle, in this case 6, would be defined as well. Can someone point me in the right direction? Here is how I instantiate the class: paginate.php - get's called via ajax <?php if (is_numeric($_REQUEST['page'])) { require_once("paginator.class.php"); $p = new Paginator(); $p->currentPage = $_REQUEST['page']; $p->itemsTotal = 168; // mysql_num_rows value eventually $p->itemsPerPage = 10; // Static number $p->paginate(); ?> <div class="pagination"><?php echo $p->displayPages(); ?></div> <?php } ?> paginator.class.php <?php class Paginator { var $itemsPerPage; var $itemsTotal; var $numPages; var $currentPage; var $output; function Paginator() { } function paginate() { $this->numPages = ceil($this->itemsTotal / $this->itemsPerPage); for ($i = 1; $i <= $this->numPages; $i++) { if ($i == $this->currentPage) { $this->output .= "<span class=\"paginate current\" onclick=\"goPage(this)\" data-page=\"" . $i . "\">" . $i . "</span> "; } else { $this->output .= "<span class=\"paginate\" onclick=\"goPage(this)\" data-page=\"" . $i . "\">" . $i . "</span> "; } } } function displayPages() { return $this->output; } } ?> Any help would be appreciated, thanks!
  16. It may shut down the entire internet so be careful. lol I'm pretty sure that loop will never stop, but I may be wrong... if $i >= 1..it will always be greater than 1 if you keep increasing it
  17. Ah..well that explains why I couldn't find the syntax error lol..thank you
  18. I just need another pair of eyes as I am not seeing the syntax error. I'm sure I'll figure it out right after I post this as that has happened many times before. query: <?php $sql = " INSERT INTO views (user_id,show,show_id,episode,episode_id) VALUES ( '" . $_SESSION['user']['id'] . "', '" . $showTitle . "', '" . $showID . "', '" . $episodeTitle . "', '" . $episodeID . "')"; ?> output: <?php $output = " INSERT INTO views (user_id,show,show_id,episode,episode_id) VALUES ('1','Criminal Minds','9','Episode Title','1')"; ?> error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'show,show_id,episode,episode_id) VALUES ( '1', 'Criminal Minds', '9',' at line 2
  19. I've never done salting before. Usually just use md5, but the rainbow tables kinda scare me. Anyway, I read up a little on salting and does this look right?..right meaning effective Also, my salt string, is it case sensitive when I crypt it? <?php if (isset($_POST['submit'])) { $salt = "someStringThatonlYYiWillKnow!"; $username = stripslashes(mysql_real_escape_string(strtolower($_POST['username']))); $password = stripslashes(mysql_real_escape_string(md5($_POST['password']))); $ePass = crypt($password,$salt); $query = mysql_query("SELECT active,username,password FROM usernames WHERE username = '" . $username . "' AND password = '" . $ePass . "'") or die(mysql_error()); $num = mysql_num_rows($query); if ($num == 1) { $result = mysql_fetch_array($query); if ($result['active'] == 'yes') { $_SESSION['user']['username'] = $result['username']; $_SESSION['user']['authed'] = true; header("Location: main.php"); } else { $error = " <div class=\"notification information\"> <div>We located your account, however, it has not been activated by an admin yet.</div> </div>"; } } else { $error = " <div class=\"notification error\"> <div>Invalid Username / Password.</div> </div>"; } } ?>
  20. Ok after 3 days I finally figured this monster out! This script will play videos that live above web root on the iOS devices. You can take this script and add your authentication to it like I did. I am checking if a user is logged in that way a member cant copy a link and send it to a non member. They would have to give them their login info which is impossible to guard against anyway. <?php $file = "../../media/v_360.m4v"; if (is_file($file)) { $mime = "video/x-m4v"; header("Content-type: " . $mime); header("Accept-Ranges: bytes"); if (isset($_SERVER['HTTP_RANGE']))// do it for any device that supports byte-ranges not only iPhone { rangeDownload($file); } else { header("Content-Length: ".filesize($file)); readfile($file); } } else { // some error... } function rangeDownload($file) { $fp = @fopen($file, 'rb'); $size = filesize($file); // File size $length = $size; // Content length $start = 0; // Start byte $end = $size - 1; // End byte // Now that we've gotten so far without errors we send the accept range header /* At the moment we only support single ranges. * Multiple ranges requires some more work to ensure it works correctly * and comply with the spesifications: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2 * * Multirange support annouces itself with: * header('Accept-Ranges: bytes'); * * Multirange content must be sent with multipart/byteranges mediatype, * (mediatype = mimetype) * as well as a boundry header to indicate the various chunks of data. */ header("Accept-Ranges: 0-$length"); // header('Accept-Ranges: bytes'); // multipart/byteranges // http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2 if (isset($_SERVER['HTTP_RANGE'])) { $c_start = $start; $c_end = $end; // Extract the range string list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); // Make sure the client hasn't sent us a multibyte range if (strpos($range, ',') !== false) { // (?) Shoud this be issued here, or should the first // range be used? Or should the header be ignored and // we output the whole content? header('HTTP/1.1 416 Requested Range Not Satisfiable'); header("Content-Range: bytes $start-$end/$size"); // (?) Echo some info to the client? exit; } // If the range starts with an '-' we start from the beginning // If not, we forward the file pointer // And make sure to get the end byte if spesified if ($range == '-') { // The n-number of the last bytes is requested $c_start = $size - substr($range, 1); } else { $range = explode('-', $range); $c_start = $range[0]; $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; } /* Check the range and make sure it's treated according to the specs. * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html */ // End bytes can not be larger than $end. $c_end = ($c_end > $end) ? $end : $c_end; // Validate the requested range and return an error if it's not correct. if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { header('HTTP/1.1 416 Requested Range Not Satisfiable'); header("Content-Range: bytes $start-$end/$size"); // (?) Echo some info to the client? exit; } $start = $c_start; $end = $c_end; $length = $end - $start + 1; // Calculate new content length fseek($fp, $start); header('HTTP/1.1 206 Partial Content'); } // Notify the client the byte range we'll be outputting header("Content-Range: bytes $start-$end/$size"); header("Content-Length: $length"); // Start buffered download $buffer = 1024 * 8; while(!feof($fp) && ($p = ftell($fp)) <= $end) { if ($p + $buffer > $end) { // In case we're only outputtin a chunk, make sure we don't // read past the length $buffer = $end - $p + 1; } set_time_limit(0); // Reset time limit for big files echo fread($fp, $buffer); flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit. } fclose($fp); } ?> I got my source from here => http://mobiforge.com/developing/story/content-delivery-mobile-devices (Appendix - A). The script had a couple errors, nor did it set the: header("Accept-Ranges: bytes"); header.
  21. yep thats exactly what is was. I added php_value memory_limit 64M to an htaccess file and that worked
  22. I found a script online that I am trying to get working. It was giving a 500 error from the get go and I've pinpointed it to the $data = fread() line. Does anyone know why? <?php $file = "../../media/v_360.m4v"; $filesize = filesize($file); $offset = 0; $length = $filesize; if (isset($_SERVER['HTTP_RANGE'])) { // if the HTTP_RANGE header is set we're dealing with partial content $partialContent = true; // find the requested range // this might be too simplistic, apparently the client can request // multiple ranges, which can become pretty complex, so ignore it for now preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches); $offset = intval($matches[1]); $length = intval($matches[2]) - $offset; } else { $partialContent = false; } $file = fopen($file, 'r'); // seek to the requested offset, this is 0 if it's not a partial content request fseek($file, $offset); $data = fread($file, $length); /* fclose($file); if ($partialContent) { // output the right headers for partial content header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $filesize); } // output the regular HTTP headers header('Content-Type: ' . $ctype); header('Content-Length: ' . $filesize); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Accept-Ranges: bytes'); // don't forget to send the data too print($data); */ ?> Its trying to read a 60mb file. Do you think it is timing out and that is causing the error?
×
×
  • 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.