oni-kun
Members-
Posts
1,984 -
Joined
-
Last visited
-
Days Won
1
Everything posted by oni-kun
-
Shared hosting usually does not allow access to anything outside the document root, especially cheaper hosts. Just make sure you bloody use .htaccess to disallow public access to your flatfile db. Your idea of recording the IP and using it as a session variable is an intelligent idea, it's funny nearly no site in existence does this, on gmail, hotmail, if you revert your IP mid-browsing you can still be in.. I'd look into securing that.
-
Why not just replace the whole thing.. $keyword = foo; $rssFeeds[0] = 'http://blogsearch.google.com/blogsearch_feeds?hl=en&q='.urencode($keyword).'&ie=utf-8&num=10&output=rss'; If the $rssFeeds variable does not require any extreme changes, place that after or in place of your old code.. and it'll change the keyword to what you set it as. $keyword could be set through $_GET if you wanted etc.
-
processing form on same page and then clearing the POST values
oni-kun replied to jeff5656's topic in PHP Coding Help
<?php if(isset($_POST['myusername'])) { echo "Your username has been added."; include ("connectdb.php"); $username = mysql_real_escape_string($_POST['myusername']); $password = mysql_real_escape_string($_POST['mypassword']); $query = "INSERT INTO members (id, username, password) VALUES('','$username', '$password')"; mysql_query($query) or die(mysql_error()); unset($_POST['myusername']); unset($username); unset($password); } ?> I assume that will work.. refreshing the page would not have a POST. -
Your regex does not match against an expression, only a simple pattern, you can use either of these: function br2nl($text) { return preg_replace('/<br\\s*?\/??>/i', '', $text); } br2nl($sub); //Using a function echo preg_replace('/<br\\s*?\/??>/i', '', $sub); //Directly
-
This is a shorter example, but he is learning and it's best to understand how the method works before working on shorthand logic for this.. It will not be as easy to understand for a beginner.
-
You can look at this example code here.. http://forums.tizag.com/showthread.php?t=4167 It's for a page hit counter, but you can just modify it to be a counter for the support causes.. <form action="counter.php" method="post"> ... </form> Is what you can create for the button, in counter.php write the code to place them in the database, creating a table alongside to see if anyone already with the same IP joined..
-
<?php function addX() { $rand = rand(1,5); if ($rand == 1) { return true; } else { return false; } } ?> Is that what you meant? This will generate a random number, giving it a probability of 0.2(20%) to be true, 80% chance to be false.
-
\b is the word boundry or matches white space at the beginning or end of a match, \s matching white space before just the term, which you should use if you were to match multiple spaces in some case... No problem.
-
Your navigation is very confusing. You may want to set up index.php to use GET for navigation. Menu.php could be separate but included. index.php?page=about index.php?page=bio index.php?page=DeathValley That's what most sites do. In menu.php or your page if you want.. <?php <ul> <li> if($_GET['page']=="DeathValley") { echo '<a id="uberlink2" href="?page=DeathValley">DeathValley</a>'; }elseif($_GET['page']=='About'){ echo '<a href="?page=About">About</a>'; </li> </ul> ?> Seems like a much more viable option.. but I have no clue what you're doing, your navi is very obscure, your links aren't making any sense to me..
-
If you're wanting to match a space before search term.. $match = preg_grep("/^\s$search_var/i", $my_array);
-
You can't, but you can do it in a method such as this: <?php $serv = "serv1"; $data = get_file_contents(uptime.php?server=$serv); // which'll return uptime $uptime = explode(' up ', $data); $uptime = explode(',', $uptime[1]); $uptime = $uptime[0].', '.$uptime[1]; echo "Server Name: " . $serv . "<br>"; echo "Server Uptime: " . $uptime . "<br>"; ?>
-
This code is rough but should work.. $result = @mysql_query("SELECT * FROM whatever"); while ($record=mysql_fetch_array($result)) { echo $record["adminonline"]; flush(); //Prevent output buffer from sleeping sleep(60*2); //Two minutes } You'd need to rewrite the while loop a bit to suit it to your own needs to finding if the admin/tutor is online, but sleep() will stop it from running the script continuously, flush() will prevent the script from sleeping, and make it just the while loop.
-
Your code is 1 hour * 24 hours, which is one day. $next_draw=$last_draw+($plot['draw_days']*(3600*24)); It should be this to be an hour: $next_draw=$last_draw+($plot['draw_days']*(60*60)); Why are you doing draw_days when you want hours? or is it supposed to be one hour->day for your program?
-
Try this. Some servers are mashy about shorthand tags.. <a href="<?php echo urlencode($download_link); ?>" class="download_link"> Urlencode should safely encode all HTML entities for you, that is what this feature is for. If you'd like to encode every possibly HTML entity then use htmlentities() on it instead.. but it shouldn't be needed for an url encoding. Edit: I get this, I tried it myself. http%3A%2F%2Fwww.mysite.com%2Ffx%2Findex.php%3Ffile%3D1%26sort%3D1
-
Maybe my DNS was scratched. Anyway, Yes, you should link every resource relatively or using https://, especially the base url.
-
The site doesn't exist, I don't know if this is spam or not.. but wrong forum.. If you link to 'http://yourdomain.com/images/3.gif' it'll show as unencrypted, you have to use relative linking.. ../images/4.gif etc.
-
You can use PHP's urlencode(), But I believe the browser should already do that by default, nonetheless there it is.
-
Place ob_start() at the beginning of your php code.. <?php ob_start() {your code} header(...) ?>
-
You can use $_POST or $_GET to send hidden variables to another page, $_GET will be visible in the url though.. For example these two pages. <?php //form.php $var = "Hey!"; header('Location: ./test.php?variable=$var'); ?> <?php //test.php $passedvar = $_GET['variable']; echo $passedvar; ?>
-
You'll need to use your .htaccess like this.. RewriteEngine On RewriteCond %{HTTP_HOST} ^subdomain\.example\.com RewriteRule ^(.*)$ http://example.com/show.php?url=test [R] If you want... test4.example.com to = show.php?url=test4.. RewriteEngine On RewriteCond %{HTTP_HOST} ^subdomain\.example\.com RewriteRule ^(.*)$ http://example.com/subdomain$1 [R]
-
You can't. Is 85.13.214.87 your server? If it is than on port.. 9998 you must define a gateway that writes the user to a temporary file that'll expire after X amount of minutes.. which will display the current online users in a more or less accurate method, that's what sites do to list online users..
-
Well first design your database adding tables for your repository and user profiles, once you're done that, i'm sorry to say, but the easiest way is to look in google "PHP upload file script", use a tutorial or look at some existing code and it should be very simple. Check for MIME etc to make sure they're the extentions you want.. ( not exe, but zip allowed etc. ) Once you're done that and are able to upload files to a temporary directory.. you now how to write a script that can grab all the files and place them on the page, and in your database write permissions to mods to be able to view..say.. moderate.php, and be able to remove, delete, rename etc. those submissions. All in all it doens't seem too complex..
-
Unique filename upload, and filename extract...
oni-kun replied to Mostly Ghostly's topic in PHP Coding Help
You can use this in your PHP code to randomize the file name.. $suffix = substr (md5(uniqid(rand(),1)), 3, 10); $filename = $file."_".$suffix; As for e-mailing yourself the file, you cannot. You have to link it with HTML.. such as something roughly like.. <a href="__FILE__$filename">$filename</a> PHP's mail() does not support attachments.. Edit: What's with your code? Create a form so that it can upload the file, lol. <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> -
Yeah, You can't use it as a function.. private $one, $two, $three Meaning you cannot use private as a function name, you'll have to change it.
-
If you mean to stop if from going offscreen, then use PHP's wordwrap() function, it'll automatically place a newline after every xx characters.. <?php $url = "http://www.domain.com/editaccount.php?notifications&md=ZmVlZF9jb21tZW50O2Zyb209NTA5MTM2MzA2O3VpZD03MTcxNTI4Mjk7b3duZXI9NzE3MTUyODI5O29pZD0xMzYzMTcxNTE1MTQ7dG89NzE3MTUyODI5&mid=edf630G2abee23dG2677304G36 "; $wrappedurl = wordwrap($url, 20, "\n"); echo $wrappedurl; ?>