|
Roctor posted:I don't know anything about your game, but I can share a train of thought that I've just run down if you want to avoid crons. This is actually a really good idea I hadn't thought of, thank you for sharing it. I might end up doing this if nothing else occurs to me.
|
# ? Feb 11, 2009 17:04 |
|
|
# ? May 16, 2024 12:57 |
|
are there any programs or websites out there that can scan large php application files such as cakephp or wordpress for lines that send third parties sensitive information? i know a fresh download of wordpress is fairly safe but other apps are harder to trust.
|
# ? Feb 11, 2009 23:27 |
|
KarmaticStylee posted:are there any programs or websites out there that can scan large php application files such as cakephp or wordpress for lines that send third parties sensitive information? That's a very complicated task. I recommend running a test environment and sniffing the packets that come from it. Or I could say something about reading the code yourself or using code that comes from a trustworthy source.
|
# ? Feb 11, 2009 23:33 |
|
royallthefourth posted:That's a very complicated task. I recommend running a test environment and sniffing the packets that come from it. Thanks for the idea royallthefourth posted:Or I could say something about reading the code yourself or using code that comes from a trustworthy source. Reading each and every file of open source php apps would take quite a bit of time
|
# ? Feb 12, 2009 00:27 |
|
I'm looking for a third party product (free or low cost) that provides basic blog functionality (posts, comments, Atom/RSS feeds, etc) without the presentation layer. Basically something that I can dump into my own framework and incorporate into a currently existing application. Any suggestions?
|
# ? Feb 12, 2009 00:31 |
|
supster posted:I'm looking for a third party product (free or low cost) that provides basic blog functionality (posts, comments, Atom/RSS feeds, etc) without the presentation layer. Basically something that I can dump into my own framework and incorporate into a currently existing application. Any suggestions? I would hope that one of the blogging apps out there had its models done well enough that you could lift them. Those are wheels that have been reinvented plenty of times.
|
# ? Feb 12, 2009 01:04 |
|
supster posted:I'm looking for a third party product (free or low cost) that provides basic blog functionality (posts, comments, Atom/RSS feeds, etc) without the presentation layer. Basically something that I can dump into my own framework and incorporate into a currently existing application. Any suggestions? Look at CodeIgniter, it's not a code base, it's a PHP framework, but the basic example is a full-fledged blog. You can start with that example, and add-on as you need.
|
# ? Feb 12, 2009 01:17 |
|
I am already using a framework (in-house). I'm just looking to avoid having to write the mundane stuff like feed generation, comment support, etc. I guess I might consider taking a look at picking apart an already-built blog system. Are there any widely used blog plugins for CodeIgniter that I don't know about?
|
# ? Feb 12, 2009 01:29 |
|
Well, most code example you'd get for codeigniter would use a lot of codeigniter features, so you'd probably end up doing more code by converting it rather than writing from scratch. Also, I haven't heard of any plugins, just a big tutorial and the end result is a full blog, without feeds tough.
|
# ? Feb 12, 2009 01:40 |
|
supster posted:I am already using a framework (in-house). I'm just looking to avoid having to write the mundane stuff like feed generation, comment support, etc. Isn't feed generation really a presentation layer thing?
|
# ? Feb 12, 2009 01:48 |
|
That's what I was going to say. Ideally all the xml markup should be made in the presentation layer.
|
# ? Feb 12, 2009 02:10 |
|
niralisse posted:Isn't feed generation really a presentation layer thing? My other requests still stand though.
|
# ? Feb 12, 2009 02:33 |
supster posted:Yeah....... good point. How robust of a blog system are you looking for? If it's just some basic functionality it seems like it would be less work/headache to just write your own. Do you foresee yourself updating the third party library as new versions become available? That could become a pain to merge into your concoction.
|
|
# ? Feb 12, 2009 03:10 |
|
I posted this question in the Web Design megathread but I was told this is more of a PHP/MySQL question, so I'll crosspost it here, too: I'm trying to learn how to create a search box on a web page that can search a databse and display results, for instance, searching through a product listing. I know how to make a search box that will search all the pages in a website, and the output looks like something you'd get from google. I don't want that, because if it doesn't look right and its confusing to a possible customer. I'm looking for something like the search box in the top right of this website: http://plasticpolybags.com/ The search box enables you to put in the Width and Height of one of these bags, and when you submit it, it will display all the possible product listings that fit those dimensions, it won't just start listing any page that has the word "height" or "width" or any random number in it. I don't know if this is a MySQL thing, an HTML thing, or a PHP thing, so I'm hoping you goons can point me in the right direction. It seems like designing a search box like this is a little time consuming and complicated, so if you can't provide an answer on how to create one of these, can you at least kind of explain the process behind what's going on when you click Submit on this search box? What are some websites or resources I could use to try to learn how to replicate this search box on my own? I'm pretty computer/internet savvy, just not programming/coding savvy...
|
# ? Feb 12, 2009 03:13 |
imonlyapuppet posted:The search box enables you to put in the Width and Height of one of these bags, and when you submit it, it will display all the possible product listings that fit those dimensions, it won't just start listing any page that has the word "height" or "width" or any random number in it. Basically you'd have a table in a database (think of a table as spreadsheet in excel). Let's call this table Bags. We'd have a few fields (or columns, in excel) called Name, Width, Length, (Id, Type, etc). Let's say we have some data like: code:
select Name from Bags where Width=10 and Length=20 and you basically replace 10 and 20 in that statement with variables containing the value of what the user entered. There's a whole slew of information you can read about how to do this using php. XAMPP is an easy way to get an environment running for writing a PHP/MySQL app for the first time.
|
|
# ? Feb 12, 2009 03:30 |
|
Is there a way to make the "substr" function act more dynamically so that it will only cut off at the end of a word (or before a space or end of string) as apposed to exact at XYZ charters? for example $str = "hey there!" If I say substr($str,0,5) It will produce "hey t" Is there a function that will work as an exception to this that will allow you to bleed over a word so things don't cut off unnaturally? Perhaps smartsubstr($str,0,5) will product either "hey" or fully "hey there" but it won't cut it off in the middle of a word?
|
# ? Feb 13, 2009 19:41 |
|
php:<? function substr_words($str, $limit) { if (strlen($str) <= $limit) { return $str; } preg_match('/^.{'.($limit - 1).'}\S*/us', $str, $matches); return $matches[0]; } ?>
|
# ? Feb 13, 2009 20:40 |
cannibustacap posted:smartsubstr($str,0,5) will product either "hey" or fully "hey there" but it won't cut it off in the middle of a word? You can write your own pretty easily by using explode with " " as your delimiter.
|
|
# ? Feb 13, 2009 20:42 |
|
cannibustacap posted:Is there a way to make the "substr" function act more dynamically so that it will only cut off at the end of a word (or before a space or end of string) as apposed to exact at XYZ charters? Okay I got off my lazy rear end and did it. Confirmed to work: php:<? if ($body && strlen($body) >= $limit) { $words = explode(' ', $body); for ($k = 0, $count = 0; $count <= $limit && $k < sizeof($words); $k++, $count += strlen($words[$k])) { $sent = $sent ? $sent . ' ' . $words[$k] : $words[$k] . ' '; } } ?>
|
# ? Feb 14, 2009 01:27 |
|
cannibustacap posted:Okay I got off my lazy rear end and did it. Confirmed to work: I can't even read what the gently caress that's supposed to do. Maybe it's because I'm drowsy as hell (very probable) but don't you find this far easier to read? php:<? $max = 15; $output = ''; $count = 0; $words = explode(' ', $body); foreach($words as $word) { if( strlen($output) >= $max) { $output = trim($output); break; } $output .= $word . ' '; } ?>
|
# ? Feb 14, 2009 02:25 |
|
Mercator posted:I can't even read what the gently caress that's supposed to do. Maybe it's because I'm drowsy as hell (very probable) but don't you find this far easier to read? But your's is almost 3x the lines......
|
# ? Feb 14, 2009 02:28 |
|
supster posted:But your's is almost 3x the lines...... You are clearly old enough to remember The Great Carriage-Return Shortage of Aught-Three. No, seriously. Go with the more readable code. Six months from now you won't remember what the gently caress this does and will need to figure it out just from reading it.
|
# ? Feb 14, 2009 03:01 |
|
savetheclocktower posted:No, seriously. Go with the more readable code. Six months from now you won't remember what the gently caress this does and will need to figure it out just from reading it. If only PHP had some feature where you could inject extra text into your code that the interpreter would ignore. You could use this, in a pinch, to annotate your program. At a stretch you could possibly even explain what you've done...
|
# ? Feb 14, 2009 11:28 |
|
Guys its very easy to readphp:<? if ($body && strlen($body) >= $limit) { $words = explode(' ', $body); for ($k = 0, $count = 0; $count <= $limit && $k < sizeof($words); $k++, $count += strlen($words[$k])) { $sent = $sent ? $sent . ' ' . $words[$k] : $words[$k] . ' '; } } ?> Line 2: Words is an array made of each separate "word" in the body. Line 3: create a for loop with two conditions: k, count. Both start at 0, but k increases incrementally to keep track of the keys, count just keeps track of the numbers of number of characters used so far. Once that limit is reached, you have $sent, your $sentence. Then again, sometimes I look at my co-workers code and have no clue what they say either. I really should comment more
|
# ? Feb 14, 2009 12:59 |
|
Might want to use something like this if you ever have to cut off extremely long strings.php:<? function cutoff($string, $limit) { if(strlen($string) <= $limit) return $string; $pos = $limit; while($pos > 0 && $string[$pos] != ' ' && $string[$pos] != "\t" && $string[$pos] != "\n") $pos--; return rtrim(substr($string, 0, $pos)); } ?>
|
# ? Feb 14, 2009 13:25 |
|
cannibustacap posted:Guys its very easy to read $sent will usually be a string of length $limit + $k + 1 AND have two spaces after the first word. Additionally, you are ignoring the length of the first word entirely! Try running this with the string "One two one two one two" and a limit of 6. You get one whole extra word. (This breaks on any strings that have the correct sequence of words and when it does your strlen goes through the roof) Use what supster wrote, or: php:<? if (strlen($body) <= $limit) $sent = $body; else { $sent = wordwrap($body, $limit, "SOMETHING_THAT_WILL_NEVER_APPEAR_IN_THE_TEXT"); $sent = substr($sent, 0, strpos($sent, "SOMETHING_THAT_WILL_NEVER_APPEAR_IN_THE_TEXT")); } ?> edit: gently caress comments. jasonbar fucked around with this message at 18:19 on Feb 14, 2009 |
# ? Feb 14, 2009 18:08 |
|
Every solution written so far is terrible since it doesn't add an ellipsis at the end of the chopped string.
|
# ? Feb 14, 2009 23:04 |
|
Well for the purpose of my web site, this actually does work good enough. Its all rough estimates anyway.
|
# ? Feb 14, 2009 23:49 |
|
I'm writing a PHP and MySQL based inventory system for all the beer I have around. I'm able to insert records into the database just fine, and I can display them in a table just fine. I'd like to have a button by each row with the label, "Remove this Beer," which will call another php page to confrim deletion of the beer from the database. When I insert records into the database, I create a UID for each row using uniqid(), and I need to make sure I'm passing that UID so I know I am deleting the right row. Here's what I have so far: code:
|
# ? Feb 14, 2009 23:59 |
|
Two methods: 1) Instead of a button, have a link that goes to "removebeer.php?id=$guid" or whatever. That way, no form is necessary at all. 2) Have a hidden input field. "<input type='hidden' name='beerid' value='555'>" and then it will be $_POST['beerid'], but the user will never see it. As an aside, why are you using uniqid() instead of having an autoincrement ID field in the database?
|
# ? Feb 15, 2009 00:12 |
|
Golbez posted:Two methods: Excellent, thank you. I'll be using the second method you suggested. As to uinqid(), it seemed like a good idea at the time and now I am kind of committed to it for now. You're right that autoincrement would do it, and I have no idea why I didn't think of that at the start.
|
# ? Feb 15, 2009 00:28 |
|
edit: I typed out this whole post, and then stumbled upon the way to do it myself...
Hammerite fucked around with this message at 01:46 on Feb 15, 2009 |
# ? Feb 15, 2009 01:42 |
|
I apologize if this has been asked before but it's hard to search for a question like this: Is there any way to make it so pages that you only want to be included (such as a header.php, or navigation.php) can't be viewed unless in an include? Guess it applies to just scripts too such as search.php, I don't want people just typing in search.php and seeing it. Wow, that was harder than I thought to describe.
|
# ? Feb 15, 2009 02:31 |
|
The smart way is to put any important source files outside of webroot, period. The dumb way is to do something like, if (!defined('MY_APP_BE_RUNNIN')) { return; } in your header fine, and define('MY_APP_BE_RUNNIN', true); in any files that include it.
|
# ? Feb 15, 2009 02:33 |
|
gibbed posted:The smart way is to put any important source files outside of webroot, period. How about I do both? I'm working on a clothing shop website with PHP and MySQL currently, and it's my first real project. I know nothing about security. Hopefully I won't learn the hard way
|
# ? Feb 15, 2009 02:39 |
|
Jo3sh posted:Clearly, then, this creates a series of buttons whose names are unique. How can I pass that unique string to removebeer.php? Rrraaagh echo statements for HTML! A pet peeve of mine. Any reason you're not doing this? php:<?php // snip the part where I connect to the database and retrieve the table ?> <form name="form1" method="post" action="removebeer.php"> <table border="1"> <tr> <th>Brewer or Brewery</th> <th>Name of Beer</th> <th>Size</th> <th>GUID</th> </tr> <?php while($row = mysql_fetch_array($result)) { ?> <tr> <td><?=$row['brewer']?></td> <td><?=$row['name']?></td> <td><?=$row['size']?></td> <td><input type="submit" name="<?=$row['guid']?>" value="Remove this Beer" /></td> </tr> <?php } // while ?> </table> </form> Zorilla fucked around with this message at 10:06 on Feb 15, 2009 |
# ? Feb 15, 2009 10:01 |
|
Zorilla posted:By the way, when fixing your code, I also noticed you're looping the form over and over again. That can't be good. Not necessarily. If he wanted a distinct submit button for each line, creating a new form for each line is the way to do it, and so far as I can tell has no deleterious effects. Now, sure, your method works too, since the value is included in the name of the submit button, but it doesn't work if each row had an editable field or what not. edit: It could work if each row had a unique name, so you could do "<input name='name<?=$row['guid']?>'", I suppose. Golbez fucked around with this message at 17:33 on Feb 15, 2009 |
# ? Feb 15, 2009 17:25 |
|
Golbez posted:Not necessarily. If he wanted a distinct submit button for each line, creating a new form for each line is the way to do it, and so far as I can tell has no deleterious effects. Now, sure, your method works too, since the value is included in the name of the submit button, but it doesn't work if each row had an editable field or what not. One of the things I meant that it was invalid HTML to put <form> tags inside <table>. You either have to start and stop them outside <table> or put them inside <td>. Besides, it's still bad practice to use multiple forms on a page where all the information looks like it belongs to one form. What happens when you edit information on one row, then hit Submit on another? You lose the other row. Not good. If he were to end up using text input fields later on like you brought up, that's when he should start considering using arrayed input names like description[somenumber] and checkboxes for deletion instead. Zorilla fucked around with this message at 20:28 on Feb 15, 2009 |
# ? Feb 15, 2009 19:48 |
|
Zorilla posted:Rrraaagh echo statements for HTML! A pet peeve of mine. Got any rational reason behind having that pet peeve? Since my preference runs the exact opposite to yours for most involved html rendering, I'd be interested if there was an actual reason to do things one way rather than the other; I'm not aware of a reason using echo is 'wrong'?
|
# ? Feb 15, 2009 19:55 |
|
|
# ? May 16, 2024 12:57 |
|
KuruMonkey posted:Got any rational reason behind having that pet peeve? Using echo statements:
Zorilla fucked around with this message at 20:31 on Feb 15, 2009 |
# ? Feb 15, 2009 20:02 |