Jump to content

education

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

education's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi i have a CAPTCHA script that stores images in a folder, i need to delete these files periodically say every 6 Hours. I need a simple php script that will do this that i can run from my cron task. How do i go about doing this??
  2. Any ideas guys, i have to leave work in 15mins and hope i can resolve this before i go.
  3. Gonna give up with that one as it wont work no matter what i do. However i have another way of doing it with one small problem. I have a file styleswitch.js the code is:- [code] //Style Sheet Switcher version 1.0 Nov 9th, 2005 //Author: Dynamic Drive: http://www.dynamicdrive.com //Usage terms: http://www.dynamicdrive.com/notice.htm function getCookie(Name) { var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null } function setCookie(name, value, days) { var expireDate = new Date() //set "expstring" to either future or past date, to set or delete cookie, respectively var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5) document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/"; } function deleteCookie(name){ setCookie(name, "moot") } function setStylesheet(title) { var i, cacheobj for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) { if(cacheobj.getAttribute("rel").indexOf("style") != -1 && cacheobj.getAttribute("title")) { cacheobj.disabled = true if(cacheobj.getAttribute("title") == title) cacheobj.disabled = false //enable chosen style sheet } } } function chooseStyle(styletitle, days){ if (document.getElementById){ setStylesheet(styletitle) setCookie("mysheet", styletitle, days) } } function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu var i if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu var element=(element.type=="select-one") ? element.options : element for (i=0; i<element.length; i++){ if (element[i].value==selectedtitle){ //if match found between form element value and cookie value if (element[i].tagName=="OPTION") //if this is a select menu element[i].selected=true else //else if it's a radio button element[i].checked=true break } } } } var selectedtitle=getCookie("mysheet") if (document.getElementById && selectedtitle!=null) //load user chosen style sheet if there is one stored setStylesheet(selectedtitle) [/code] at the top of every page i have the following:- [code] <link rel="alternate stylesheet" type="text/css" media="screen" title="default-theme" href="http://www.mydomain.com/style/style.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="green-theme" href="http://www.mydomain.com/style/green.css" /> <link rel="alternate stylesheet" type="text/css" media="screen" title="red-theme" href="http://www.mydomain.com/style/red.css" /> <script type="text/JavaScript" src="http://www.www.mydomain.com/scripts/styleswitch.js"> </script> [/code] and to change the style all i do is have [code] <a href="javascript:chooseStyle('default-theme', 60)"><img src="http://www.mydomain.com/images/blue_cube.gif" href="javascript:chooseStyle('default', 60)" width="12" height="12" class="cube_color"></a> <a href="javascript:chooseStyle('green-theme', 60)"><img src="http://www.mydomain.com/images/green_cube.gif" href="javascript:chooseStyle('green', 60)" width="12" height="12" class="cube_color"></a> <a href="javascript:chooseStyle('red-theme', 60)"><img src="http://www.mydomain.com/images/red_cube.gif" href="javascript:chooseStyle('red', 60)" width="12" height="12" class="cube_color"></a> [/code] on the page as well, the problem is when a user changes style on the first page the switch is perfect and when you go to another subdomain the style is remembered, however if the user changes style on this page then returns to the homepage the style is not remembered any ideas you have been a great help.
  4. right replaced it with that bit of code but it generates. [quote] Warning: Invalid argument supplied for foreach() in index.php on line 46 [/quote] ?
  5. Errm. Im lost right my form [code]         <form action="s3.php" method="get">             <p><label for="style">Style:</label>                 <select id="style" name="style">                 <?php                     foreach ($available_styles as $_style) {                         printf('<option value="%s"%s>%s</option>',                                $_style,                                ($_style == $style)                                    ? ' selected="selected"'                                    : '',                                ucfirst($_style));                     }                 ?>                 </select>                 <input type="submit" value="switch" />             </p>         </form> [/code] when you said try [code] <?php                     foreach ($available_styles as $_style) { echo "<a href='s3.php?style=$_style'><img src='$_style.jpg' /></a>"; } ?> [/code] where do i insert that in the form and how do i get the individual coloured cubes to pass that color to the switcher. ie do i write the following:-- [code] <?php                     foreach ($available_styles as $_style) { echo "<a href='s3.php?style=$_style'><img src='$_style.jpg' /><img src="red.jpg></a>"; } ?> ??? Im sorry im learning more about php each week but im stumped, i really do apreciate your patience with my newbie ness [/code]
  6. Gonna give it ago, if it works im gonna kiss ya!
  7. s3.cfg.php and s3.php are too seperate files, the actual code works great no problems what so ever but the script generates a drop down box ie blue, red, green etc when you select a colour you have to click submit to get the script to change. What i want to do is have a image of a red square that when the user clicks it changes to red style i.e <a href="#" img src="redsquare.jpg"> I really need to do this as am designing a site for work its done apart from this, it the style switch gives user accessibility features this is why its important.
  8. Hi im new to php and got a style changing script One file s3.cfg.php has this code [code]<?php // vim:et ts=4 sw=4 cindent:     $style_path = '';     $available_styles = array(         'red',         'green',         'blue'     );     $default_referrer = '/'; ?>[/code] The other file is called s3.php this has the following code: [code]<?php // vim:et ts=4 sw=4 cindent: if (!@include('s3.cfg.php'))     die("Unable to include config file!"); $set_cookie = true; if (isset($_GET['style'])) {     $style = $_GET['style']; } elseif (isset($_POST['style'])) {     $style = $_POST['style']; } elseif (isset($_COOKIE['style'])) {     $style = $_COOKIE['style'];     $set_cookie = false; } // if no style supplied, or invalid supplied... if (!isset($style)     || !in_array($style, $available_styles)) {     // set style to default (first available)     $style = $available_styles[0]; } // our cookie will last 2 years... modify // the last argument if this isn't sufficient if ($set_cookie)     setcookie('style', $style,               mktime() + 2 * 356 * 24 * 60 * 60,               '/', '.alterior.net'); $referrer = (!empty($_SERVER['HTTP_REFERER']))     ? $_SERVER['HTTP_REFERER']     : $default_referrer; header('Location: ' . $referrer); ?>[/code] Finally this code is included in my pages in the head section    [code]<?php     $path = substr($_SERVER['PATH_TRANSLATED'], 0,                    -strlen($_SERVER['SCRIPT_NAME']));     if (@include($path . '/s3.cfg.php')) {         $style = (isset($_COOKIE['style']))             ? $_COOKIE['style']             : $available_styles[0];         printf('<style type="text/css" media="screen">@import url(%s%s.css);</style>',                $style_path, $style);     } ?> [/code] and the styles are changed with a form [code]   <form action="s3.php" method="get">             <p><label for="style">Style:</label>                 <select id="style" name="style">                 <?php                     foreach ($available_styles as $_style) {                         printf('<option value="%s"%s>%s</option>',                                $_style,                                ($_style == $style)                                    ? ' selected="selected"'                                    : '',                                ucfirst($_style));                     }                 ?>                 </select>                 <input type="submit" value="switch" />             </p>         </form> [/code] all i want to do is change selecting the styles from a drop down box to a hyperlink i.e click a red square image for a red style. PLEASE PLEASE help this is driving me nuts i've tried every little bit of code to no availe.
  9. Hi guys, wondering if you can help. I have a site that currently uses resources obtained from an FTP site. the url on the page links direclty to this ftp site such as an image of a cloud might be obtained from ftp://someaddress.com/clouds. Now this takes up the ftp servers bandwith whenever someone access MY page. What i want to do is say every hour get my server to gather the information from the ftp site just a few pictures say and store them on my server where i can link to them there. i am totally new to php ish and am not sure how to do this, i have to as the ftp servers bandwidth has been cut and it will be catastrophic if my site losses these certain resources. Thanks for your help.
×
×
  • 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.