Jump to content

Vermillion

Members
  • Posts

    118
  • Joined

  • Last visited

    Never

Everything posted by Vermillion

  1. It would be helpful to see the code you are using for echoing your countries. We will figure something out from there.
  2. Hi guys, I decided to write to my own DateTime class mainly because the one PHP comes with doesn't do anything I want it to do. I need to implement a way of using DST for countries that use it, but I myself live in a place where DST is never used, so it's hard for me, so I have a few questions, first some questions related to DST itself and then the ones in PHP so I can implement it. * When does the DST enter in effect? * When does it end? * Is it the same for every year? * Do all the countries that use DST move their clocks one hour ahead or the time that needs to be changed varies from place to place? * How exactly can I get "The second Sunday of every march" with PHP?
  3. Suppose I have the following DateTime string. 20100312122636 How can I determine what day is it based on it? I want to know what day (Sunday, Monday, Tuesday...) is based on that string, but I can't figure a way to do it.
  4. Alright, I swear I am close on solving my whole problems for once and for all. Please bear with me till then. I have never been good with htaccess. I am trying to find a way to use the auto_prepend_file with it with no luck. Also, is there a way to include all the files from the API with that statement at once, or can I just include one? It would be very nice to be able to include all my API in just one htaccess so I can use it without creating a require hell once again.
  5. Is there a way to do it without modifying the php.ini file? My host will not be dedicated unfortunately .
  6. Alright, I get it for the most part. But where exactly do I put that __autoload() function? Also, here is a hierarchy of my work so far, I hope this can help you help me (file names are in blue, normal folders in black): www - projectfreedom -- FreedomAPI.php -- FreedomAPI --- class.DateTime.inc.php --- Connection ---- Communication ----- class.Message.inc.php ----- class.PrivateMessage.inc.php I test everything in the FreedomAPI.php file. Eventually, I will make more directories inside www and inside projectfreedom, so the __autoload function will become very handy, once I know how to use it lol.
  7. Hey there! First of all, thanks a bunch for the reply. I really appreciate it. I have been into PHP for 4 years and into OOP for 3 years and I never heard about __autoload() haha. Can you give me more info about it? I will really appreciate it.
  8. Hi guys, it has been a while since the last time I came here... I am now working on my website in the most "professional" way for me. I am using OOP, Namespaces, and all that, and here is where I have a question: The root namespace is called "FreedomAPI", and in that namespace I will put all the functions that are too general to fit in another subnamespace. I have no problem with that, the thing is that I don't know where to create those general functions. would it be a good solution to put them in a "functions.php", and then just include that file with the rest of my classes? My framework is sorta complex, and I have had a horrible experience trying to include all the files in different levels of directories in the servers, so I don't know what to do about where to write those functions.
  9. I really appreciate it but I have checked your code and I came to the conclusion that I can't adapt it to mine, so can you just help me to get mine right? Your code scared me when I saw it had references, and I already suck with pointers in C++, so I may just check them another day . I just really need to see why when I echo the $_SESSION['captcha'] variable it is different than the captcha in the picture. I mean, both strings are the same variable, and I don't modify it in any other line after I create it.
  10. I have been coding my site for months now, and weeks on just the registration script. Today, I had planned to finally finish my registration script, but I noticed that there's a problem with my captcha scripts thanks to the fact that my Ajax wouldn't deliver the correct Captcha. So trying to hunt the bug down, I started to make the script, and surprisingly, I found the bug very quickly, but unfortunately I still can't find a solution for it. This is the script that outputs the Captcha image: <?php session_start(); // Everything related to the Captcha. $captchamd5 = md5(microtime() * mktime()); $string = substr($captchamd5, 0, 7); //The Captcha string will only have 7 characters. $captcha = imagecreatefrompng("../graphics/captcha_bg.png"); $white = imagecolorallocate($captcha, 255, 255, 255); $line = imagecolorallocate($captcha, 233, 239, 239); imageline($captcha, 0, 0, 39, 29, $line); imageline($captcha, 40, 0, 64, 29, $line); imagestring($captcha, 5, 20, 10, $string, $white); $_SESSION['captcha'] = $string; header("Content-type: image/png"); imagepng($captcha); ?> And the test page I made to test it just has this code: <?php session_start(); ?> <?php echo '<img src="AwingsCLF/register/captcha.php"/>'; echo $_SESSION['captcha']; ?> Like you can see, the first script assigns the value to my $_SESSION['captcha'] array value, and the second script echoes that output, but first including the captcha as an image. The problem is that the values on the Captcha are different; what I echo is different than what I see in the image, like you can see on the pic below: Any help with this will be really appreciated. I don't want to change the way the whole thing works because I have a complex PHP class that handles registrations that comes from both browsers with JS enabled and for browsers without it. So I really need to get that session variable working right.
  11. Are you sure you want to encrypt passwords? Because the best move is usually to hash the passwords (hashing passwords and encrypting them are different things). There are 2 PHP functions that can hash passwords: sha1() and md5(). If I remember correctly, sha1() uses a 64bits (or less?) hashing algorithm, whereas md5() uses 128bits, if I remember correctly. I always heard that md5() was safer, so I always use that one.
  12. I was told it wasn't recommended as well... But I don't want to use a variable for that. I think I will see about using relative paths and that stuff.
  13. Thanks both. I tried theonlydrayk's solution and that one worked wonderfully .
  14. OOP is a painful concept to understand at first, but once you get it, you love it. You really do. I know I felt in love of it... Anyways, you can really do everything with it in a safe, quick, and to-the-point way. Consider what Daniel0 said: Imagine you, the person, are the object. You have a function to take your (my apologies for this example, lol) clothes off. You wouldn't want other people to take your clothes off, would you? .
  15. I made a thread about this a while ago, same topic, same everything lol. I believe the answer to the "do you need to be x years old to take it" was no, you can take it any time you are ready. I wish I could take it after I turn 17, hope I have the knowledge by then .
  16. I remember the days when I was like "what's a hello world? Why Hello world?"... Good, good times, Wikipedia has a rocket-science explanation about it. I think it should be used just to help people set their environments for programming, but they are more used as examples now...
  17. Hi guys. I am having a weird problem here: Can someone tell me why when I do this: '<a href="'.$_SERVER['HTTP_HOST'].'/login/">Login</a>' The link becomes this?: http://www.projectawings.com/www.projectawings.com/login/ That really shouldn't be happening, I should only see: www.projectawings.com/login/ or http://www.projectawings.com/login/ It happens on my localhost as well. it does: http://localhost/localhost/login/ I really want to find a solution to this one . Any help will be appreciated!
  18. Yep, it works very well. Just making sure if it is safe to just use that. The only thing I don't like is that it does something like this: This will be<br /> a new line When I want it to do this: This will be<br />a new line
  19. Okay, I killed my laziness and tested everything with a database. Now is all this really safe? It looks quite lazy and I don't think I trust this at all: To insert the data: <?php $content = mysql_real_escape_string($_POST['content']); mysql_query("INSERT INTO bans (ban_id, user_id, forum_id, ban_date, ban_expires, ban_note) VALUES ('1', '1', '1', '20000505231111', '20000505231111', '".$content."')"); ?> To retrieve the data: <?php $string = htmlentities($string); $string = nl2br($string); ?>
  20. Ah okay, this is starting to make me sick. Can't find a way to fix it, and it is hurtful ):. Anyone knows about a PHP script that scripts characters just fine, and that makes sure the content is safe to use?
  21. Lets assume I am inserting data and then retrieving it: <?php $content = $_POST['content']; $content = mysql_real_escape_string($content); //inputting $content = awingsMarkup($content); //Extracting echo $content;?> With that, I get: This\r\nis a cool\r\nstring So it's still not working .
  22. I use this function for my markup: function awingsMarkup($string){ /** * * The function that will convert Awings Markup Tags (AMTs) to HTML. * Awings Markup Tags are the "BBCodes" that generate the HTML for awings. This function does just that. * * @PACKAGE AwingsCLF * @AUTHOR Andrés Ibañez * @PARAM string - string that will be transformed into HTML. * @RETURN string * */ //Conversion: Markup to HTML. $string = preg_replace(BOLD, '<strong>$1</strong>', $string); $string = preg_replace(ITALICS, '<span style="font-style:italic;">$1</span>', $string); $string = preg_replace(UNDERLINE, '<span style="text-decoration: underline;">$1</span>', $string); $string = preg_replace(HEADER1, '<h1>$1</h1>', $string); $string = preg_replace(HEADER2, '<h2>$1</h2>', $string); $string = preg_replace(HEADER3, '<h3>$1</h3>', $string); $string = preg_replace(SIZE, '<span style="font-size: $1em;">$2</span>', $string); $string = preg_replace(COLOR, '<span style="color: $1;">$2</span>', $string); $string = preg_replace(IMG, '<img src="$1" />', $string); $string = preg_replace(LINK, '<a href="$1" target="_blank">$2</a>', $string); $string = preg_replace(QUOTE, '<blockquote class="quote">$1</blockquote>', $string); $string = preg_replace(QUOTE_ORIGINATOR, '<blockquote><span style="font-size:12px;"><strong>Quote</strong> $1</span><br /><blockquote class="quote">$2</blockquote></blockquote>', $string); $string = preg_replace(SUP, '<span style="font-size:xx-small; vertical-align:top;">$1</span>', $string); $string = preg_replace(SUB, '<span style="font-size:xx-small; vertical-align:bottom;">$1</span>', $string); $string = preg_replace(STRIKE, '<span style="text-decoration:line-through;">$1</span>', $string); $string = preg_replace(OVERLINE, '<span style="text-decoration:overline;">$1</span>', $string); $string = preg_replace(SPOILER, '<script type="text/javascript">document.write(\'<div class="codeContainer"><div class="codeBox"><span style="font-weight: bold;">Spoiler:</span> <span style="color: #808080;">$1 -</span> <input type="button" class="codeToggleButton" value="Show" /><div class="codeContent">--------------------<br />$2</div></div></div>\')</script><noscript><div class="spoilerCont_noJS"><div class="spoilerNoJSTitle"><strong>$1</strong><br />Highlight The box below to read the spoiler.<hr /><div class="spoilerNoJSBody">$2</div></div></div></noscript>', $string); $string = preg_replace(CODE, '<script type="text/javascript">document.write(\'<div class="codeContainer"><div class="codeBox"><span style="font-weight: bold;">Code:</span> <span style="color: #808080;">$1 -</span> <input type="button" class="codeToggleButton" value="Show" /><div class="codeContent">--------------------<br />$2</div></div></div>\')</script><noscript><div class="codeCont_noJS"><div class="codeNoJSTitle"><strong>$1</strong><br />See the code below:<hr /><div class="codeNoJSBody">$2</div></div></div></noscript>', $string); $string = nl2br($string); return $string; } Testing if I could escape the string correctly for MySQL input, I tried this: <?php $content = $_POST['content']; $content = mysql_real_escape_string($content); echo awingsMarkup($content);?> And with that, if I input: This is a cool string I get this: This\r\nis a cool\r\nstring If I remove the mysql_real_escape_string(), it works well. But I really don't think I should remove it if that's what people will use to send the data to the database of the forum. Any help?
  23. Haha yeah, I managed to get it though =P! I swear this is my last question >.<: I can't seem to echo the content in 'data' properly. I don't mind if it echoes the [c0de] tags, I will let my markup post to deal with that. I have tried many things, including this (I have renamed the countLines function to codeAmt): $result = codeAmt($string); echo "<pre>"; print_r($result); echo "</pre>"; echo "<br /><br />"; echo $result[0]['num']; echo "<br />"; foreach($result[0]['data'] as $key => $current){ echo $result[0][$current]; } but that is not working, I get this: I have even tried everything that even a newbie would do >.>, with no avail.
  24. How can I actually do that? I am already returning the $string, I don't know how I can return or call the $Matchs afterwards .
  25. Okay, thanks a lot for the help so far. Now, I need to do a small improvement to this code. I need to store the whole blocks with PHP tags, but only the blocks, so if people put this: So in the function I would store "[code]lol [/code]" and "[code]fixed lol [/code]" in array elements, so I can do something like this: $codes = array(); //The array would have something like: $codes[0] = "[c0de]lol[/c0de]"; $codes[1] = "[c0de]fixed lol[/c0de]"; //so I could eco something like: echo "the first code block (".$codes[0].") has " .$lines[0];
×
×
  • 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.