sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
I'm using RegexBuddy, and trying to create a match. I have this regular expression: ^/(~brians6)/(.*) and it matches /~brians6/ but not /~brians6/about.php and I'm wondering why, and how to fix it.
-
Can you show us an example of what they send you in your email? I'm not going to give them my email address, because I am paranoid about spam. If you could share more details about what they do, then perhaps we could come up with a solution that meets your needs. For my business, when we have a new product or something to advertise, we simple send out an email to our email database, letting them know what is going on. We currently use getresponse.com, but may be changing to constantcontact.com soon. These services make it fairly painless for you to send out emails to people.
-
So, I guess whatever works, right?
-
Until a couple months ago, I had not even used a framework with MVC. My code was always procedural, and I'm learning more about the benefits of MVC and OOP in general. I practiced by converting my website to the Kohana framework, and about a week ago converted it to CodeIgniter. My question is, while I had not done so, I had assumed that a database driven website meant that views were essentially replaced by plain HTML that is stored in a database, but after thinking more about it, my assumption must be wrong. I can see where product content might be pulled in, through a model , and passed to the view by the controller. Is there ever an instance where a whole view would be stored in the database? Doing so would prohibit the ability to embed php into the views, so I'm guessing this isn't a proper thing to do, but I'm trying to figure out other uses for database driven content (just because I've got nothing better to do on a Friday night). Is it generally slower to have a lot of content coming from the database vs. a file? I got started thinking about this because I have a search on my website, and it is actually using file_get_contents() to look through all of my pages, and due to my website getting a little bigger, this is now starting to be quite a slow search. I thought that perhaps all of my content should belong in the database, and use MySQL to search through for matches. What is the best way to handle searching a website like mine?
-
I'd like a query OR the ability to set a column's properties in the database, so that as I insert a new record, the value of the field in this column would be a unique AND random 10 digit number. I'm using phpMyAdmin, as I'm not a MySQL guru. Can I set the column in the database to generate this type of number, instead of auto-increment? Currently the column is just set as INT w/ auto-increment. I know I could probably do this with multiple queries to the database to confirm that a php generated random number isn't currently in use, but I'm looking for a cleaner way. Is what I want to do possible?
-
[SOLVED] PHP Exam - Design Patterns - What's the answer?
sKunKbad replied to phpcat's topic in PHP Coding Help
ArrayAccess http://www.php.net/manual/en/class.arrayaccess.php -
It's not just sun.com; many servers will reject requests if user-agent isn't set.
-
MadTechie, thanks for the explanation. I understand now.
-
OK, I have no sites using php4 anyway, but what was the reason to use =& anyways? I saw the docs on "return by reference", but I don't understand.
-
I've been using php for about 3 years, and have never come across a script that used =& like the following example: $foo =& new StdClass() What does this do? How is it different than just plain =
-
you ought to try removing segments of the code from various places, and determine where the error is coming from. It says line 1 ... but line 1 is obviously not the problem.
-
Cookies are generally easy to forge. What i am setting up wont be that complex, so i am not so sure on the security of using cookies but can you give me a link or something to point me in the right direction in making something relatively secure? Cookies might be easy to forge, but you can use session cookies and regenerate them on every page request. If youre really paranoid, use SSL, or maybe Apache's .htpasswd would suit your needs?
-
you can create a stream context within file_get_contents, and add a user-agent string. That might be your easy answer. See the file_get_contents page in the docs if you haven't done this before.
-
I figured out my own problem. It was with the theme_choice.php script. I'm just guessing, but other than trying to set the session variable, there was no output to "give back" to the javascript, and it may have been tripping up the javascript. I added a 200 OK header, and some text to the output, and all is well.
-
I've got a theme changer script, and it works good in any browser on Windows. I've tried Chrome, FF3, IE6, Opera, and Safari. When I go to my Mac, it works fine in Opera, but Safari and FF3 don't work, and on my Ubuntu laptop, using FF3, it doesn't work. The odd thing is, in all of these browsers, it works on the next page load. I thought maybe somebody in here would spot what was buggy. FORM: <form action="http://localhost/CodeIgniter/theme_choice.php" method="post"> <div id="themeBox"> <h3 style="margin-bottom:0px;"><label for="theme_choice">Pick a theme:</label></h3> <p style="font-size:80%; padding-top:0px; margin-top:0px;">current theme is "Blue Seashore"</p> <select id="theme_choice" name="theme_choice" onchange="goto_URL(this.form.theme_choice)" onkeyup="goto_URL(this.form.theme_choice)"> <option value="NA" selected="selected"> -- Select One --</option> <option value="blue_theme"> Blue Seashore </option> <option value="green_theme"> Green Army </option> <option value="mocha_theme"> Java Addiction </option> <option value="yellow_theme"> Ketchup & Mustard </option> <option value="dark_theme"> Midnight Mardi Gras </option> <option value="rose_theme"> Rose Garden </option> </select> </div> <noscript> <div id="themeButton"> <input type="hidden" name="referer" value="index.php" /> <input class="inputbutton" type="submit" value="Change Theme" /> </div> </noscript> </form> SCRIPT: function goto_URL(object) { if(object.options[object.selectedIndex].value != 'NA'){ var key = 'theme_choice='; var value = object.options[object.selectedIndex].value; var url = 'http://localhost/CodeIgniter/theme_choice.php'; var params = key + value; function createRequestObject() { var req; if(window.XMLHttpRequest){ req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject('Microsoft.XMLHTTP'); } else { alert('There was a problem creating the XMLHttpRequest object'); } return req; } var http = createRequestObject(); http.open('POST', url, true); http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', params.length); http.setRequestHeader('Connection', 'close'); http.onreadystatechange = function(){ if(http.readyState == 4 && http.status == 200){ window.location.href = 'http://localhost/CodeIgniter/'; } } http.send(params); } } THEME_CHOICE.PHP: <?php class Theme_choice extends Controller { function Theme_choice(){ parent::Controller(); } public function index(){ if ($this->input->post('theme_choice')){ $theme_choice = filter_input(INPUT_POST, 'theme_choice' , FILTER_SANITIZE_STRING ); if($theme_choice != 'NA'){ $_SESSION['stylesheet'] = $theme_choice; } } if($this->input->post('referer') && $this->input->post('referer') != 'index.php'){ $samePage = base_url() . filter_input(INPUT_POST, 'referer' , FILTER_SANITIZE_URL ); header("Location: " . $samePage ); }else{ $samePage = base_url(); header("Location: " . $samePage ); } } } ?> Javascript is not my strength, so I'm hoping one of you Javascript gurus can teach me something here. Thanks.
-
you could use strtotime('now') over a preset time of completion, and then convert that fraction to a decimal (percentage).
-
checking IP is never advised, because people on AOL get a new IP everytime they load a page. You might want to check user-agent instead, or use flash tokens (a session token, with random and unique value, that changes for every page load, and is only good for one page load).
-
slideshow.html <html> <head> <title>slide&fade</title> <script type="text/javascript" src="slide.js"></script> </head> <body bgcolor=#eeeeee> </body> </html> slide.js /*************************************************************************************** Copyright (C) 2008 Andreas Berger This script is made by and copyrighted to Andreas Berger - andreas_berger@bretteleben.de It may be used for free as long as this msg is intact! **************************************************************************************** Version 20080502 ***************************************************************************************/ //*****parameters to set***** //into this array insert the paths of your pics. //if there are only 2 images, set them two times i.e. 1/2/1/2 imges=new Array ('pic01.jpg', 'pic02.jpg', 'pic03.jpg', 'pic04.jpg', 'pic05.jpg'); picleft=0; //set this to the left position of your pics to be shown on the page pictop=0; //set thid to the top position of your pics to be shown on the page picwid=551; //set this to the width of your widest pic pichei=354; //... and this to the height of your highest pic backgr="#ffffff"; //set this to the background color you want to use for the slide-area //(for example the body-background-color) if your pics are of different size sdur=4; //time to show a pic between fades in seconds fdur=1; //duration of the complete fade in seconds steps=20; //steps to fade from on pic to the next startwhen=1; // "startwhen" leave it at "null" to start the function by calling it from your page by link //(sample: <a href="javascript:myfade();">slide</a>) // or set it to 1 to start the slide automatically as soon as the page is loaded //*****nothing more to do, have fun //************************************************************************************** ftim=fdur*1000/steps;stim=sdur*1000;emax=imges.length; for(e = 1; e <= emax; e++) { theid="img"+e;thesrc=imges[e-1]; document.write("<div id='"+theid+"'><img src='"+thesrc+"' border='0'></img></div>"); } document.write("<style type='text/css'>"); for(b = 1; b <= emax; b++) { thestylid="img"+b;thez=1;thevis='hidden'; if(b<=1) {thez=2; thevis='visible';} document.write("#"+thestylid+" {position:absolute; left:"+picleft+"px; top:"+pictop+"px; width:"+picwid+"px; height:"+pichei+"px; background-color:"+backgr+"; layer-background-color:"+backgr+"; visibility:"+thevis+"; z-index:"+thez+";}"); } document.write("</style>"); function myfade() { parr = new Array(); for(a = 1; a <= emax; a++) { idakt="img"+a;paktidakt=document.getElementById(idakt); ie5exep=new Array(paktidakt);parr=parr.concat(ie5exep);} i=1;u=0;slide (i); } function slide(numa){ ptofade = parr[numa-1]; if(numa<=emax){pnext=parr[numa];} if(numa==emax){pnext=parr[0];} pnext.style.visibility = "visible"; pnext.style.filter = "Alpha(Opacity=100)"; pnext.style.MozOpacity = 1; pnext.style.opacity = 1; ptofade.style.filter = "Alpha(Opacity=100)"; ptofade.style.MozOpacity = 1; ptofade.style.opacity = 1; factor = 100/steps; slidenow(); } function slidenow(){ check1=ptofade.style.MozOpacity; maxalpha = (100 - factor*u)/100*105; if(check1<=maxalpha/100){u=u+1;} curralpha = 100 - factor*u; ptofade.style.filter = "Alpha(Opacity="+curralpha+")"; ptofade.style.MozOpacity = curralpha/100; ptofade.style.opacity = curralpha/100; if(u<steps){window.setTimeout("slidenow()",ftim);} if(u>=steps && i<emax){ ptofade.style.visibility = "hidden"; ptofade.style.zIndex = 1; pnext.style.zIndex = 2; i=i+1;u=0; window.setTimeout("slide(i)",stim);} if(u>=steps && i>=emax){ ptofade.style.visibility = "hidden"; ptofade.style.zIndex = 1; pnext.style.zIndex = 2; i=1;u=0; window.setTimeout("slide(i)",stim);} } function dostart(){window.setTimeout("myfade()",stim);} if(startwhen){onload=dostart;}
-
Not to throw a wrench in the cogs, but you could save yourself a lot of time by using a good framework like CodeIgniter or Kohana. They have the MVC all set up for you, and since you know a little about MVC, you should be able to start working immediately. You don't have to use the rest of their framework if you don't want, but I think once you see how they work you will start using them, and it will save you a lot of time. http://codeigniter.com http://kohanaphp.com
-
If you can modify or create an .htaccess file, you can put the following in it, and people will not be able to browse your directories: Options -Indexes And to keep people from accessing a file directly, you can you mod_rewrite with a rewrite rule such as: RewriteRule ^functions.php - [F,L] or use something like this: <Files functions.php> order deny,allow deny from all allow from yourwebsite.com </Files>
-
After days searching for an answer, I found out that when PHP is compiled --with-curlwrappers the header must be in the form of an array, and not just a string. This isn't documented, but I found this answer by browsing the bug reports for the stream_context_create() function. I am relieved that I finally found the answer I was looking for, but I spent countless hours searching for the answer, and even though it is in the bug reports, apparently nobody ever took the time to add it to the documentation. I wish I could add it, but it is not allowed according to "the rules".