Jump to content

krillz

Advanced Member
  • Posts

    150
  • Joined

  • Last visited

Everything posted by krillz

  1. krillz

    php rand function

    php's rand() function is based on so called pseudo-random numbers. A pseudo-random number is based on on a formula that would look random to anyone that does not know the formula. And based on a quote from a book covering the topic of random functions, this formula should have the following characteristics: Good numeric distribution, let say you want to produce a random number between 0 and 5 then the formula should produce a equal ammounts of 0 - 1 - 2 - 3 - 4 - 5 over time. You should not be able to predict the numbers, unless you know the formula and the start value used in the formula. The process should not cycle, in other words produce the same set numbers over x number of intervalls. So it's not really random, but it seems random to the user. If you check major online casinos they generate random numbers using nature, most common is using materials that randomly discharges photons to trigger a number, or use radioactive isotops as radio active decay is random by nature you can never predict when a "burst" happens, using this you will achieve "true" randomness by measuring when this happens. *edit* check php's better random function called: mt_rand() as it's much faster than rand() and uses the Mersenne Twister method to generating numbers.
  2. It does seem like the $_POST is not filled on the first submit. What do I do to fix this? This code while (list($key, $val) = each($_POST)) { echo "$key => $val "; } prints out all the key-value pairs inside the $_POST. On the first run it doesn't print out anything, implying $_POST is empty. I can't see the reason why the $_POST is empty on the first go, but after I press back and Submit again it works as expected. For post to be filled you need to send something to the page using the POST method. So that's your problem you are trying to run the email stuff even though no one has filled out and submited the form . You can do something as check if $_POST is set or not, and control the script using that. if ( isset($_POST["from"])) { //first make sure from is sanitary $from = $_POST["from"]; $from=filter_var($from, FILTER_SANITIZE_EMAIL); //this first cleans it, so that it contains the right kind of characters if(filter_var($from, FILTER_VALIDATE_EMAIL)){ //this checks the resulting clean address for well-formedness $to = "myaddress@gmail.com"; $subject = "Feedback"; //$message = $_POST["msg"] + ; reset($_POST); while (list($key, $val) = each($_POST)) { $message .= "$key => $val \n"; } $headers = "CC: anotheraddress@gmail.com"; //mail($to,$subject,$message,$headers); echo "Thank you! We will get back to you shortly."; } else { echo 'The from address provided is invalid!'; echo ' '.$from.' '; reset($_POST); while (list($key, $val) = each($_POST)) { echo "$key => $val "; } } } this way the code will only be ran if $_POST["from"] has been sent.
  3. anything is possible, what you would need is api that re-streams the original stream, and streams your own sound files when you wishes. But it will take some work. You should contact someone that codes/offers online streaming solutions and work something out.
  4. One more question: Where can I find the style sheet. I can't seem to id it in the original site design folders. Well you got the path to your css file right in the source code: C:/Users/Sean Sullivan/Desktop/MSSM Web Files/Night Club/Original Site Files/style.css
  5. Hmm let's see if we can spot it, just a couple of quick observations: filter_var($from, FILTER_VALIDATE_EMAIL) Do not rely on FILTER_VALIDATE_EMAIL especially in online mail forms, I'll quote a very good phrase that indicates why you shouldn't rely on this filter option alone: Now let's continue: Most important first step, sounds like a stupid mistake, but people tend to miss this somehow. Are you running the code without checking if the form was sent, which basically means that first time you enter that page the whole validation code starts, but the problem is that nothing has been sent thus $_POST is not filled with what you are looking for. And based on the error code generated I got a feeling it might have something to do with this. if that wasn't the case try the below things: Have you tried printing out $message after the loop to see if you get the string builds up correctly? The filter options removes all characters except letters, digits and !#$%&'*+-/=?^_`{|}~@.[]. Are you using any symbol that is not allowed?
  6. Do you recommend a particular software? I use ClamXav on my mac laptop, it's more a virus scanner and not an antivirus software as there is no need for that. So you manually scan files/uploads/mails using it. It uses the same virus database as ClamWin, and basically just scans until it finds a signature and alerts you, so you can remove it and not risk spreading the virus further. http://www. clam xav.com/index.php?page=dl
  7. ineed it does, however there are millions of ways to bypass this, or take advantage of flaws in application using shared userbases expecially where one of them has root previleges. And I think it's a little like with linux, where we have virus scanners not directly to protect our system but more to make sure we do not spread viruses along to any windows machines on the network etc.
  8. Just upload one of your php5.ini files and put it in the root directory, if that works create a envirentment path to it as shown in the last example. Anyway talked to my friend that is using godaddy for a couple of years and here are the key phrases he told me: 1: Changes to the php.ini file won't show up until after 1200 MST, when they rehash or restart the server. 2. If you are running PHP 4, name your initialization file php.ini. If you are running PHP 5, name your initialization file php5.ini. Always upload the initialization file to the root directory of your site. 3. Depending on what linux distro you got along with admin panel; try checking in the directory /etc/ as most of the times the files path is /etc/php.ini 4. I also found out my friend has acess to a shell, so you can use linux commands to find the place where php.ini are located just type this into the shell/terminal: php -i | grep php.ini this will show you the location of the php.ini file used for php4. And just dump your php5.ini into the location.
  9. if you look better you will spot that in fact we got double quote symbols: $invite_tr = " "; at the beginning and at the end you got " ".
  10. ehm, check the top level directory of the user account or in /cgi-bin/ if they are running php as CGI, as I remember using that one a while back when we did something using godaddy's hosting. But I also remember there only being a php.ini for php4 and to change settings for php5 I had to manually upload a php5.ini to the same directory. Another thing with go daddy: * Windows IIS6 accounts do not support PHP. * Windows IIS7 accounts always run PHP 5. * Linux accounts support both PHP 4 and PHP 5. Also when they told you to add the php5.ini to the root folder although you don't have priveleges to edit anything in there, I still remember being able to add stuff to the folder so just put the file there and create a .htaccess file where you point to the php5.ini file with a line like: SetEnv PHPRC /path/to/root/folder and if you need to get your hands on a php.ini file check out php.net they got a few: http://cvs.php.net/viewvc.cgi/php-src/php.ini-recommended
  11. Actually if you want the variable to be parsed you need to use double quotes as otherwise the variable will not be parsed: $beta = 'test'; echo 'This is a $beta'; // this will show: This is a $beta echo "This is a $beta"; // this will show: This is a test Also when you need to print out a lot of html it can be good to either close the php write your html then open it up again. Although it's a minus in terms of optimization it's not noticeable in small scripts. Another way could be using a variation of the echo statement: $uno = 'one'; $dos = 'two'; $tres = 'three'; echo A lot of text goes here put a lot of text here over several lines something that is a pain in the ass to have in quotes and stuff I can even put in my variables here and they will be parsed $uno $dos , $tres most likely misspelled but hey I do not speak spaninsh anyway I think you got the picture by now so I'll stop. END;
  12. you should check your php syntax, as you had dots and stuff flying right and left. anyway here you got your code working > Complete the form to send invitations. </pre> <form action="<?php%20echo%20%24_SERVER%20%5B'PHP_SELF'%5D;%20?>" method="POST" accept-charset="utf-8"> Type an email address for each invitation to send. Email for ( $i=1; $i $invite_tr = " "; echo $invite_tr; } ?> </form> <br><br><br>/* === this is where I'm lost. I can not capture the email values from the form, whether to later.... echo or send mail. === */<br>if (isset($_POST['submit'])){<br> for ($n=1; $n echo $n.' '.$_POST["email$n"].'<br>'; <br> }<br> }<br>?><br><br><br
  13. Hmm yeah although you can get array_slice to work as you want with help of some nifty mathematical expression to get it to slice well even at the end of the array. I think you might be better using a different function to cut the array into pieces of 12 that requires a lot less effort. check out the array_chunk() function instead, this will spare you of some variables that you are using right now. example of splitting an array into chunks of 12: $input = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"); $new = array_chunk($input, 12); to get the amount of pages you have, perhaps save it in a variable pages simply do: $pages = count($new); $new is a multidimensional array: $new[rows][cols] where in your case rows = page and cols = images So in my example we got two 2 pages: 1st has 12 elements and 2nd has the rest. So if you don't have an ammount that devides evenly with 12 then your last chunk ( the last row ) will not have 12 elements in it, something you need to pay attention to when you loop through to not end up outside its bounderies causing a out of bounds error. but that is easily done with some control statements.
  14. krillz

    Post Time Issue

    you need to add the date in this format if you are using datetime: 'YYYY-MM-DD HH:MM:SS' the php code: date('Y-m-j G:i:s') will format the date into that layout and you can simply put that in. Or you can use the NOW() function within mysql to do that. Problem with the second is that it will go after server time, and if you are wanting to choose a special timezone you will need to go with formating in php and puting that in. so you would have to use a query like: INSERT INTO articles (date) VALUES (NOW());
  15. krillz

    Post Time Issue

    That doesnt tell us anything, show us your database and table settings. More specifically what type the row accepts where you are trying to add the date.
  16. krillz

    Post Time Issue

    But you need to put in the date manually using functions, otherwise you won't get shit. http://www.tizag.com/mysqlTutorial/mysql-date.php
  17. krillz

    Post Time Issue

    Do you actually try to put in a date and not a empty value? // set the default timezone to use. Available since PHP 5.1 date_default_timezone_set('GMT'); // prints something like: 2010-02-23 15:12:11 echo date('Y-m-j G:i:s'); ?>
  18. Don't tell me you are just puting in $_POST[] variables without checking them, as that is the biggest no-no you can do in terms of php security. Read up on SQL injections as your code has nothing that even tries to prevent them.
  19. krillz

    OOP Example

    well that example is a poor one, you should not use the var declaration, instead go with public/private/protected. Using var can give you a false feeling that the content is safe but var is publicly available. The above example would make sense if the variable $stefan was private or protected, as this would mean that the variable could only be used by functions with in the class with the exception of static ones. this means that the variable $name within that person class can be accessed and changed at will by anyone with access: $test = new person('jimmy'); echo $test->name; echo ' '; $test->name = 'wanker'; echo $test->name; now the above code should look something like this instead: final class person { private $name; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?> This follows good coding practises, it is coded in a better secure-code way. Here having functions that return the name makes sense as this is the only way we can access the data inside the name variable because it's private. So remember to ditch using var, as this is a quite shady way of doing it, use private/protected/public. This makes the code a lot easier to read and understand. Also we use the keyword final before our class, this is standard practise when coding OOP in PHP and if the class you are coding will not be inherited by other classes you are supposed to put final there, this is for several reasons: security, code performs better (optimization), code is easy to read. As you automatically see what is globaly available and what's not and so on. you can also use final on functions that still are available to be used by child classes but where you disable the possibility to override or change those functions.
  20. Well google has a very very good search API, the math is amazing behind it, all is linear algebra in awesome algoritms. But if your client wants a local site wise search engine, well I would suggest going with the ones already on the market, as coding one yourself that performs well on matching search queries is a damn pain in the ass. check out open source projects, they are completely free of charge with some exceptions when it comes to reselling for some, however read the open source licnsenses that come with the code to stay away from trouble. places you can check for projects: code.google.com sourceforge.net I bet the are already a bunch of solutions to your problem, the only thing left is finding them and implementing them on the site.
  21. Pagerank has gotten a very reduced role since google started fighting cheaters and private add selling on pages. but a good way on not jumping into the wrong boat and competeting in keyword niches where you don't have a chance against the big players. I would suggest you check more complex keywords, more preferably keywords that a person in your area would use. Computer Repairs in Area, Computer Reperairs in CityName etc spend some time @ http://www.google.com/trends and analyse and compare volumes of googlers searching these keywords. You might not have a chance in the Computer Repairs maybe but you might get good positions among longer keyword searches that have good amount of searches. Rank good on a couple of them and it might pay off better than for one single hard key word. And don't forget it's not the computer repairs you want to position well in, it's in the searches people in your area search for you need, to get clients. so in google trends let's do a study: Set Location USA, and search history of 30 days. We assume we live in Dallas TX. try these searches: computer repair,computer repairs,repair computer, computer service. Right of the bat you can see that computer repairs is not a good keyword to rank good for, as only a small fraction uses that search term when googling, we also see that computer service is a rarely used search term among Dallas users. Also we spot two good looking search terms that a frequently googled among Dallas users: computer repair, and repair computer. Interesting part here is that repair computer has slightly better results than repair computer. Now let's check the competition google them: As suspected we got quite the competition right here, after all google trends has been around for a while and is used so frequently it's almost abused by people in the affiliate landing pages business ( I made my living by it for 2 years at one point). So I can conclude we won't show up on the first page over night, it will take some time. But I still want to take a piece of that cake so I got three ways I can go: Keep investigating search terms in google trends until I find a couple with not ideal but still a good amount of searches made on that don't pose such a big competition to me. I start adding content that is rich on keywords for those specific keywords (don't spam but good use content), update frequently and it pays of, might take some time in a worst case scenario. Second alternative is getting on that map shown in computer repair dallas and repair computer dallas. It lists local businesses, so registering and getting listed there would indeed be a good idea. Sure it costs, but it seems as a good investment, as this targets the persons I really want to reach. Third would be targeted adsense ads, here you need to invest, but might be a good investement as after all I won't get anywhere near the first page for quite some time, and by buying I will show up, and when I reach the first time I stop the ad campain. Targeted ads are also nice way of stealing competition, some dirty trick I used to do back a few years, check your competitions hopepages and look for google ads running on their site. Now make a anlyse of the pages they are showing on, better yet check under what keywords they show up in google, and buy ads to show up when these keywords are present in the page. A fair bet is that the visitors will click on your ad while on the competitions site is if we present a cheaper price than theirs, that will make them click. And if you are lucky the competition is not filtering out any keywords that might be used by their competitors, And you can actually pull it off.
  22. I tried to change the line : Zend_Loader::registerAutoload(); With : include_once('Zend/Loader/Autoloader.php'); $loader = Zend_Loader_Autoloader::getInstance(); $loader->setFallbackAutoloader(true); $loader->suppressNotFoundWarnings(false); But it's the same problem Then I tried with the ZF 1.10 and it's exactly the same ... Do someone has any idea to start the tutorial on Windows with ZF 1.10 please ? Note : the tutorial is given in a MAMP environment and yes it worked on my Macbook yesterday, but not at all on Windows .... I wonder why :/ Download an earlier version, it seems the project files uses deprecated function, in other words functions that are no longer in use by the framework. So you need to downgrade the zend framework until you find a version where the functions were still in use.
  23. yeah I just checked opera 8's headers and they are like: Mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; Nokia 6600/4.09.1; 6329) Opera 8.00 [en] And we are checking it for MSIE 6.0 so it's a positive match, a way around this could be to check whether the header does not have Opera in it: if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE $i.0") && !strpos($_SERVER["HTTP_USER_AGENT"], "Opera"))
  24. well if you read about the get_browser function you will se this text: So personally I would not use that method as it is not available for php coders right out of the box, so the say. And the solution would only add code, as you would first have to check the return array return['browser'] == 'Internet explorer' and return['version'] Also if someone got an old setup of the browscap.ini in worst case scenario they won't be able to find a match with anything newer than IE 6. As I said I would not use a solution like that unless specifically instructed to do so, so if it's a more reliable way, when it comes to IE it got pretty standard headers and are easily matched using preg_match() or strpos() so I see no factor on how using get_browser would be a more reliable way, as it's reliability hangs on the users themselves making sure the config is correctly setup and up-to-date. Also if you need a bunch more info, more than what browser the user has, let say compatibility with stuff you are using in your code, I'd choose phpSniff over get_browser any day.
×
×
  • Create New...