Jump to content

whare

Members
  • Posts

    75
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

whare's Achievements

Member

Member (2/5)

0

Reputation

  1. ok topic is a bit cryptic I am working on a small charity project for a friend he raises funds for a charity via online auctions and raffles of donated items but we want to expand it to start with affiliate schemes gaining the donation without our users dipping there hands in there own pocket anyway some of the affiliate links can be huge so I wanted to chop them down with out own redirect using an array so the user input www.yoursite.com/?afflink=thesiteyouwant and it auto redirects to the correct place here is the code I have so far <? if(isset($_GET['id'])) { $page = $_GET['id']; $link["g"] = www.google.co.uk; $link["b"] = www.bing.com; $link["f"] = www.facebook.com; $name["g"] = google; $name["b"] = bing; $name["f"] = facebook; ?> <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "<? $link[$page] ; ?>" } //--> </script> </head> <body onLoad="setTimeout('delayer()', 5000)"> <h2>Thankyou for your help</h2> <p>Your Awesome!!!!<br> You will be redirected to <? echo $name[$page] ; ?> in 5 Seconds<br><br> If the page does not redirect you please click <a href="<? $link[$page] ; ?>">Here</a></p> </body> </html> <? } else { ?> Main Site <? } ?> now this part (below) works correctly You will be redirected to <? echo $name[$page] ; ?> in 5 Seconds but the links will not load it just shows the link you entered to get there and yes I am a newb been a while since i had a play so playing catch up again now lol as soon as I can get the links to load correct I will be on my way again Thanx all
  2. I tried with the style=\"".(($x%2==1)?"":"float:left")."; the formatting just went mayhem all the boxes overlapped http://www.doveclix.com/index.php?view=click1& this is not the live page that is located @ http://www.doveclix.com/index.php?view=click& where style=\"float:".(($x%2==1)?"right":"left")."; is still in use and sorry for posting in the wrong section and thank you for moving it
  3. This is abit of both css and php Demo Link: http://www.doveclix.com/index.php?view=click1& what i am trying todo is get them to list AD1 AD2 AD3 AD4 but currently the just vertical list now it needs todo it within its relevant category i did try style=\"float:".(($x%2==1)?"right":"left")."; and worked ok when categories are not used however with the method i want to use it pushes the Opulentia link in cat C to the right here is the code guys <?php //########################################################################### //# AURORAGPT Script Copyright owned by Mike Pratt and John Terrell # //# ALL RIGHTS RESERVED 2007-2014 # //# # //# Any illegal use of this script is strictly prohibited unless # //# permission is given by the owner of this script. To sell # //# this script you must have a resellers license. Your site # //# must also use a unique encrypted license key for your # //# site. Your site must also have site_info module and # //# key.php file must be in the script unedited. Otherwise # //# it will be considered as unlicensed and can be shut down # //# legally by Illusive Web Services. By using AuroraGPT # //# script you agree not to copy infringe any of the coding # //# and or create a clone version is also copy infringement # //# and will be considered just that and legal action will be # //# taken if neccessary. # //#########################################################################// //**VS**//$setting[ptc]//**VE**// if($settings[ptcon] == 1) { //**S**// if($type == "") $type="DESC"; if($type == "DESC") $newtype="ASC"; if($type == "ASC") $newtype="DESC"; if($orderby == "") $orderby="pamount"; $order[$orderby]="<img src=\"images/"."$type".".gif\" border=0>"; $totalptc=0; $y=0; if(!$LOGGED_IN) { $sql = $Db1->query("SELECT * FROM ads WHERE credits>=1 and active=1 and (daily_limit>views_today or daily_limit=0) and (upgrade='' or upgrade='1') ORDER BY $orderby $type "); $totalptc = $Db1->num_rows(); } if($LOGGED_IN) { $clickHistory = loadClickHistory($username, "ptc"); if($thismemberinfo['type'] == 1) { $eb = intval($Db1->querySingle("SELECT eb_ptc as total FROM memberships WHERE id='{$thismemberinfo['membership']}' ","total")); } $sql = $Db1->query("SELECT * FROM ads WHERE credits>=1 and active=1 and (daily_limit>views_today or daily_limit=0) and (upgrade='0' ".($thismemberinfo[type]==1?" or upgrade='1'":"").") ORDER BY $orderby $type "); } $totalptc=0; if($Db1->num_rows() > 0) { for($x=0; $ad=$Db1->fetch_array($sql); $x++) { //$cont = $ad[country]; //$tstring = explode(',' , $cont); //if ((in_array("$thismemberinfo[country]",$tstring)) || ($ad[country]=="")) { $cont = $ad[country]; $tstring = explode(',' , $cont); if ((in_array("$thismemberinfo[country]",$tstring)) || ($ad[country]=="")) { if(findclick($clickHistory, $ad['id']) == 0) { $totalptc++; $tempcodep=" <div class=ptclink style=\"background-color: $ad[bgcolor] !important;\" id=\"col$x\"> <center> <a href=\"gpt.php?v=entry&type=ptc&id=$ad[id]&".$url_variables."\" target=\"_blank\" onclick=\"clicked1('col$x');\"><b>".parse_link(ucwords(strtolower(stripslashes($ad[title]))))."</b> ".iif($ad['targetban']!="","<br><img src=\"$ad[targetban]\"width=\"245\" border=\"0\">")."".iif($ad['targetban']==0 ,"")." ".iif($ad['subtitle_on'] && $ad['subtitle']!="","<br/><em>".strtolower(html_entity_decode($ad['subtitle']))."</em>")."</a><br> <div class=linktext><div class=textlink><i> $ad[timed] Sec.</i><br> ".iif($ad['class']=="P","$ad[pamount] Points","$settings[currency]$ad[pamount]")."</div></div> </center> </div>" ; $tempcodeb=" <div class=ptclink id=\"col$x\"> <center> <a href=\"gpt.php?v=entry&type=ptc&id=$ad[id]&".$url_variables."\" target=\"_blank\" onclick=\"clicked1('col$x');\"><b>".parse_link(ucwords(strtolower(stripslashes($ad[title]))))."</b> ".iif($ad['targetban']!="","<br><img src=\"$ad[targetban]\"width=\"245\" border=\"0\">")."".iif($ad['targetban']==0 ,"")." ".iif($ad['subtitle_on'] && $ad['subtitle']!="","<br/><em>".strtolower(html_entity_decode($ad['subtitle']))."</em>")."</a><br> <div class=linktext><div class=textlink><i> $ad[timed] Sec.</i><br> ".iif($ad['class']=="P","$ad[pamount] Points","$settings[currency]$ad[pamount]")."</div></div> </center> </div>" ; $tempcodec=" <div class=ptclink id=\"col$x\" style='height:100px;'> <center> <a href=\"gpt.php?v=entry&type=ptc&id=$ad[id]&".$url_variables."\" target=\"_blank\" onclick=\"clicked1('col$x');\"><b>".parse_link(ucwords(strtolower(stripslashes($ad[title]))))."</b> ".iif($ad['subtitle_on'] && $ad['subtitle']!="","<br/><em>".strtolower(html_entity_decode($ad['subtitle']))."</em>")."</a><br> <div class=linktext><div class=textlink><i> $ad[timed] Sec.</i><br> ".iif($ad['class']=="P","$ad[pamount] Points","$settings[currency]$ad[pamount]")."</div></div> </center> </div>" ;$tempcoded=" <div class=ptclink id=\"col$x\"> <center> <a href=\"gpt.php?v=entry&type=ptc&id=$ad[id]&".$url_variables."\" target=\"_blank\" onclick=\"clicked1('col$x');\"><b>".parse_link(ucwords(strtolower(stripslashes($ad[title]))))."</b> </a><br> <div class=linktext><div class=textlink><i> $ad[timed] Sec.</i><br> ".iif($ad['class']=="P","$ad[pamount] Points","$settings[currency]$ad[pamount]")."</div></div> </center> </div>" ; if($ad['class'] == "P") $classp= "<h2>Admin Ads</h2>"; if($ad['class'] == "A") $classa= "<h2>A</h2>"; if($ad['class'] == "B") $classb= "<h2>B</h2>"; if($ad['class'] == "C") $classc= "<h2>C</h2>"; if($ad['class'] == "D") $classd= "<h2>D</h2>"; if($ad['class'] == "P" && $ad[upgrade]==1) { $adsp1.=$tempcodep; } else { if($ad['class'] == "P") $adsp.=$tempcodep; } if($ad['class'] == "A" && $ad[upgrade]==1) { $adsa1.=$tempcodep; } else { if($ad['class'] == "A") $adsa.=$tempcodep; } if($ad['class'] == "B" && $ad[upgrade]==1) { $adsb1.=$tempcodeb; } else { if($ad['class'] == "B") $adsb.=$tempcodeb; } if($ad['class'] == "C" && $ad[upgrade]==1) { $adsc1.=$tempcodec; } else { if($ad['class'] == "C") $adsc.=$tempcodec; } if($ad['class'] == "D" && $ad[upgrade]==1) { $adsd1.=$tempcoded; } else { if($ad['class'] == "D") $adsd.=$tempcoded; } // if($ad['class'] == "A") $adsa2.=$tempcode; // if($ad['class'] == "B") $adsb2.=$tempcode; // if($ad['class'] == "C") $adsc2.=$tempcode; // if($ad['class'] == "D") $adsd2.=$tempcode; // if($ad[upgrade] == 1) $adsp1.=$adsp2; // else $adsp.=$adsp2; // if($ad[upgrade] == 1) $adsa1.=$adsa2; // else $adsa.=$adsa2; // if($ad[upgrade] == 1) $adsb1.=$adsb2; // else $adsb.=$adsb2; // if($ad[upgrade] == 1) $adsc1.=$adsc2; // else $adsc.=$adsc2; // if($ad[upgrade] == 1) $adsd1.=$adsd2; // else $adsd.=$adsd2; } } //} } } if($thismemberinfo[type] != 1 && $settings[showPremOnlyMsg]) { $sql = $Db1->query("SELECT COUNT(id)as total FROM ads WHERE credits>=1 and active='1' and (daily_limit>views_today or daily_limit=0) and upgrade='1' "); $upgradeOnly = $Db1->fetch_array($sql); if($upgradeOnly[total] > 0) { $showmsg="<div style=\"background-color: pink; border: 1px solid red; margin: 10px;\">Upgrade to a premium account to access more advertisements. There are currently ".$upgradeOnly[total]." premium-only ads available!</div>"; } } $includes[title]="Get Paid To Click"; $includes[content].=" <script> function clicked1(colid) { document.getElementById(colid).style.display='none'; document.getElementById('refwarn').style.display=''; } </script> ".iif($totalptc>0, " <table width=\"100%\" cellpadding=0 cellspacing=0> <tr> <td align=\"left\">$totalptc Links Available To Click</td><td align=\"right\"><div align=\"right\"> ".iif($settings[surfalllinks],"<a href=\"gpt.php?v=entry&type=ptc&s=1&".$url_variables."\" style=\"font-size: 15pt;\">Surf These Links</a>")." </div></td> </tr> </table> <table width=\"100%\"> ".iif($settings[min_clicks_required]>0," <tr> <td><center><font color=\"darkred\"><b>NOTE: Members must click at least $settings[min_clicks_required] PTC Ads today to earn from their refferals tomorrow!</b></font></center></td> </tr>")." ".iif($settings[premium_ref_earnings]>0," <tr> <td><center><font color=\"darkgreen\"><b>Upgraded Members do not have to click any ads to receive earnings from their referrals.</b></font></center></td> </tr>")." </table> ".iif($settings[ptc_list]," <div class=\"ptcWrapper\"> <table width=100% border=0><tr><td> $classp $adsp1 $adsp</td></tr><tr><td> $classa $adsa1 $adsa</td></tr><tr><td> $classb $adsb1 $adsb</td></tr><tr><td> $classc $adsc1 $adsc</td></tr><tr><td> $classd $adsd1 $adsd</td></tr><tr><td> </td></tr></table> </div> $showmsg ")." <p> <b>Rules</b><br /> <small>You Can Only Visit One Site At A Time<br /> <strong>You MUST Click The Correct Button After The Timer Runs Out</strong></small> </p> ","<p>There are no links available to click!</p>")." "; } else { $includes[content]="PTC is currently disabled by admin!"; } ?> CSS .ptclink { /*height: 5em;*/ width: 270px; -moz-border-radius: 1em 4em 1em 4em; border-radius: 1em 4em 1em 4em; background-color: #e8e8e8; border: 2px dashed #ab0224; margin:7px; } .linktext { width:70px; /*height:180px;*/ margin:5px 5px; -moz-border-radius: 1em 1em 1em 1em; border-radius: 1em 1em 1em 1em; background-color:#ab0224; border:1px solid #ab0224; /* for IE */ filter:alpha(opacity=60); /* CSS3 standard */ opacity:0.6; } .textlink { font-weight:bold; color:#ffffff; } PLEASE EXCUSE THE DEAD CODE IN THE PHP I HAVE NOT CLEANED IT UP YET Thanx all hope somebody can help with it
  4. index.php?page=1 that link style but there is not hard files it is all to be stored in the DB here is what i have got so far <? $result = mysql_query("SELECT * FROM page") or die(mysql_error()); $row = mysql_fetch_array( $result ); if(isset($_GET['page'])) { echo $row['text']; } else { $result = mysql_query("SELECT * FROM page WHERE id='1'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['text']; } ?> but always shows page ID 1 (home page) so i no i am missing something just not sure what hehe DB structure: menu ----id (auto increase) ----name (home, about etc) ----id2 (page weight) pages ----id (auto increase) ----name (page name home, about etc) ----text (page text) link structure from the menu <? $result = mysql_query("SELECT * FROM menu ORDER BY id2") or die(mysql_error()); ?> <table> <? while($row = mysql_fetch_array( $result )) { ?> <tr><td> <a href="index.php?page=<? echo $row['id'];?>"><? echo $row['name']; ?></a> </td></tr> <? } ?> </table> dont think i have missed any info that i have on file but not sure why it will not link so thought of you guys hehe Thanx in advance
  5. Drag up this old topic of mine its is related right still want the same sort of format but looking to use it to pull data from the DB so new pages can be created/edit from site admin area something like what a forum would do but only edited and created by site staff to eliminate the need for FTP access to the server for editing thanx
  6. god i forgot how many painkillers was needed for php get the error in my abouve post Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/a6950394/public_html/index.php on line 150 and to be honist being a noob still lol i dont really inderstand the glob command so unsure how best to troble shoot this one
  7. Thanx for the reply however i did look over your code and see if (!in_array($page, glob('pages/*.php'))) { used for stopping code from running and see it as a problem however i will try it but sill see it as a pitfall EDIT: Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/a6950394/public_html/index.php on line 150 used the code and that is the error going to have a bit of a play now
  8. Bad idea, just assume I crafted the URL: index.php?page=../your/secret/config you would get a 404 error hehe but no i see what you are saying so have you an better code example that i would work with that has ease of use but still the function i require?
  9. Thanx for the reply After abit of playing i cam up with this myself after looking at premiso's post <?php if(isset($_GET['page'})) { if(file_exists($_GET['page'].'.php')) { include($_GET['page'].'.php'); } else { include('main.php'); }} ?> now that works sort of if i type in index.php?page=main it will show as it should if i type in index.php?page=nofile again it all works However if i type in index.php i get no include it will not load the main.php so i must be missing something just can not remember what lol Thanx
  10. It is for my own site i want to use the index.php as a main template file and include the other page info into the main body are as requested so on the main page i would have header menu footer and the include for the body thankyou for the reply EDIT: How can i do it without the array ? i would like to just beable to place a file in the folder and URL link it without editing an array first
  11. Hi all not been playing with php over the past year and still a noob lol i did have some code to include files based on the URL link E.G: http://www.yoursite.com/index.php?page=about then i had some form of string that would access the URL so it would have checked if the url was just index.php or had ?page=somepage after it I can not seem to find any referance on the www or shift the headach i have got trying to remember the code so thought some of you wondaful people would no what i am on about and point me in the rught direction of a tutorial for the information or have the code tohand so i can referance from it thanx all
  12. I did not see that topic (I was not looking for it) White space was the problem Sorry for posting this and thanx Will
  13. Hi All Here we go with some session errors sessions.php <?php /** * Session.php * * The Session class is meant to simplify the task of keeping * track of logged in users and also guests. * * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC) * Last Updated: August 19, 2004 */ include("database.php"); include("mailer.php"); include("form.php"); class Session { var $username; //Username given on sign-up var $userid; //Random value generated on current login var $userlevel; //The level to which the user pertains var $time; //Time user was last active (page loaded) var $logged_in; //True if user is logged in, false otherwise var $userinfo = array(); //The array holding all user info var $url; //The page url current being viewed var $referrer; //Last recorded site page viewed /** * Note: referrer should really only be considered the actual * page referrer in process.php, any other time it may be * inaccurate. */ /* Class constructor */ function Session(){ $this->time = time(); $this->startSession(); } /** * startSession - Performs all the actions necessary to * initialize this session object. Tries to determine if the * the user has logged in already, and sets the variables * accordingly. Also takes advantage of this page load to * update the active visitors tables. */ function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /** * Set guest value to users not logged in, and update * active guests table accordingly. */ if(!$this->logged_in){ $this->username = $_SESSION['username'] = GUEST_NAME; $this->userlevel = GUEST_LEVEL; $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time); } /* Update users last active timestamp */ else{ $database->addActiveUser($this->username, $this->time); } /* Remove inactive visitors from database */ $database->removeInactiveUsers(); $database->removeInactiveGuests(); /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } /** * checkLogin - Checks if the user has already previously * logged in, and a session with the user has already been * established. Also checks to see if user has been remembered. * If so, the database is queried to make sure of the user's * authenticity. Returns true if the user has logged in. */ function checkLogin(){ global $database; //The database connection /* Check if user has been remembered */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){ $this->username = $_SESSION['username'] = $_COOKIE['cookname']; $this->userid = $_SESSION['userid'] = $_COOKIE['cookid']; } /* Username and userid have been set and not guest */ if(isset($_SESSION['username']) && isset($_SESSION['userid']) && $_SESSION['username'] != GUEST_NAME){ /* Confirm that username and userid are valid */ if($database->confirmUserID($_SESSION['username'], $_SESSION['userid']) != 0){ /* Variables are incorrect, user not logged in */ unset($_SESSION['username']); unset($_SESSION['userid']); return false; } /* User is logged in, set class variables */ $this->userinfo = $database->getUserInfo($_SESSION['username']); $this->username = $this->userinfo['username']; $this->userid = $this->userinfo['userid']; $this->userlevel = $this->userinfo['userlevel']; return true; } /* User not logged in */ else{ return false; } } /** * login - The user has submitted his username and password * through the login form, this function checks the authenticity * of that information in the database and creates the session. * Effectively logging in the user if all goes well. */ function login($subuser, $subpass, $subremember){ global $database, $form; //The database and form object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Check if username is not alphanumeric */ if(!eregi("^([0-9a-z])*$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } /* Checks that username is in database and password is correct */ $subuser = stripslashes($subuser); $result = $database->confirmUserPass($subuser, md5($subpass)); /* Check error codes */ if($result == 1){ $field = "user"; $form->setError($field, "* Username not found"); } else if($result == 2){ $field = "pass"; $form->setError($field, "* Invalid password"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } /* Username and password correct, register session variables */ $this->userinfo = $database->getUserInfo($subuser); $this->username = $_SESSION['username'] = $this->userinfo['username']; $this->userid = $_SESSION['userid'] = $this->generateRandID(); $this->userlevel = $this->userinfo['userlevel']; /* Insert userid into database and update active users table */ $database->updateUserField($this->username, "userid", $this->userid); $database->addActiveUser($this->username, $this->time); $database->removeActiveGuest($_SERVER['REMOTE_ADDR']); /** * This is the cool part: the user has requested that we remember that * he's logged in, so we set two cookies. One to hold his username, * and one to hold his random value userid. It expires by the time * specified in constants.php. Now, next time he comes to our site, we will * log him in automatically, but only if he didn't log out before he left. */ if($subremember){ setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH); setcookie("cookid", $this->userid, time()+COOKIE_EXPIRE, COOKIE_PATH); } /* Login completed successfully */ return true; } /** * logout - Gets called when the user wants to be logged out of the * website. It deletes any cookies that were stored on the users * computer as a result of him wanting to be remembered, and also * unsets session variables and demotes his user level to guest. */ function logout(){ global $database; //The database connection /** * Delete cookies - the time must be in the past, * so just negate what you added when creating the * cookie. */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){ setcookie("cookname", "", time()-COOKIE_EXPIRE, COOKIE_PATH); setcookie("cookid", "", time()-COOKIE_EXPIRE, COOKIE_PATH); } /* Unset PHP session variables */ unset($_SESSION['username']); unset($_SESSION['userid']); /* Reflect fact that user has logged out */ $this->logged_in = false; /** * Remove from active users table and add to * active guests tables. */ $database->removeActiveUser($this->username); $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time); /* Set user level to guest */ $this->username = GUEST_NAME; $this->userlevel = GUEST_LEVEL; } /** * register - Gets called when the user has just submitted the * registration form. Determines if there were any errors with * the entry fields, if so, it records the errors and returns * 1. If no errors were found, it registers the new user and * returns 0. Returns 2 if registration failed. */ function register($subuser, $subpass, $subemail){ global $database, $form, $mailer; //The database, form and mailer object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Spruce up username, check length */ $subuser = stripslashes($subuser); if(strlen($subuser) < 5){ $form->setError($field, "* Username below 5 characters"); } else if(strlen($subuser) > 30){ $form->setError($field, "* Username above 30 characters"); } /* Check if username is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } /* Check if username is reserved */ else if(strcasecmp($subuser, GUEST_NAME) == 0){ $form->setError($field, "* Username reserved word"); } /* Check if username is already in use */ else if($database->usernameTaken($subuser)){ $form->setError($field, "* Username already in use"); } /* Check if username is banned */ else if($database->usernameBanned($subuser)){ $form->setError($field, "* Username banned"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } else{ /* Spruce up password and check length*/ $subpass = stripslashes($subpass); if(strlen($subpass) < 4){ $form->setError($field, "* Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){ $form->setError($field, "* Password not alphanumeric"); } /** * Note: I trimmed the password only after I checked the length * because if you fill the password field up with spaces * it looks like a lot more characters than 4, so it looks * kind of stupid to report "password too short". */ } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the */ else{ if($database->addNewUser($subuser, md5($subpass), $subemail)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass); } return 0; //New user added succesfully }else{ return 2; //Registration attempt failed } } } /** * editAccount - Attempts to edit the user's account information * including the password, which it first makes sure is correct * if entered, if so and the new password is in the right * format, the change is made. All other fields are changed * automatically. */ function editAccount($subcurpass, $subnewpass, $subemail){ global $database, $form; //The database and form object /* New password entered */ if($subnewpass){ /* Current Password error checking */ $field = "curpass"; //Use field name for current password if(!$subcurpass){ $form->setError($field, "* Current Password not entered"); } else{ /* Check if password too short or is not alphanumeric */ $subcurpass = stripslashes($subcurpass); if(strlen($subcurpass) < 4 || !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){ $form->setError($field, "* Current Password incorrect"); } /* Password entered is incorrect */ if($database->confirmUserPass($this->username,md5($subcurpass)) != 0){ $form->setError($field, "* Current Password incorrect"); } } /* New Password error checking */ $field = "newpass"; //Use field name for new password /* Spruce up password and check length*/ $subpass = stripslashes($subnewpass); if(strlen($subnewpass) < 4){ $form->setError($field, "* New Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){ $form->setError($field, "* New Password not alphanumeric"); } } /* Change password attempted */ else if($subcurpass){ /* New Password error reporting */ $field = "newpass"; //Use field name for new password $form->setError($field, "* New Password not entered"); } /* Email error checking */ $field = "email"; //Use field name for email if($subemail && strlen($subemail = trim($subemail)) > 0){ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return false; //Errors with form } /* Update password since there were no errors */ if($subcurpass && $subnewpass){ $database->updateUserField($this->username,"password",md5($subnewpass)); } /* Change Email */ if($subemail){ $database->updateUserField($this->username,"email",$subemail); } /* Success! */ return true; } /** * isAdmin - Returns true if currently logged in user is * an administrator, false otherwise. */ function isAdmin(){ return ($this->userlevel == ADMIN_LEVEL || $this->username == ADMIN_NAME); } /** * generateRandID - Generates a string made up of randomized * letters (lower and upper case) and digits and returns * the md5 hash of it to be used as a userid. */ function generateRandID(){ return md5($this->generateRandStr(16)); } /** * generateRandStr - Generates a string made up of randomized * letters (lower and upper case) and digits, the length * is a specified parameter. */ function generateRandStr($length){ $randstr = ""; for($i=0; $i<$length; $i++){ $randnum = mt_rand(0,61); if($randnum < 10){ $randstr .= chr($randnum+48); }else if($randnum < 36){ $randstr .= chr($randnum+55); }else{ $randstr .= chr($randnum+61); } } return $randstr; } }; /** * Initialize session object - This must be initialized before * the form object because the form uses session variables, * which cannot be accessed unless the session has started. */ $session = new Session; /* Initialize form object */ $form = new Form; ?> main.php (now this works fine) <?php /** * Main.php * * This is an example of the main page of a website. Here * users will be able to login. However, like on most sites * the login form doesn't just have to be on the main page, * but re-appear on subsequent pages, depending on whether * the user has logged in or not. * * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC) * Last Updated: August 26, 2004 */ include("include/session.php"); ?> <html> <body> <table> <tr><td> <?php /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <h1>Login</h1> <?php /** * User not logged in, display the login form. * If user has already tried to login, but errors were * found, display the total number of errors. * If errors occurred, they will be displayed. */ if($form->num_errors > 0){ echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> <font size="2">Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> <?php } /** * Just a little page footer, tells how many registered members * there are, how many users currently logged in and viewing site, * and how many guests viewing site. Active users are displayed, * with link to their user information. */ echo "</td></tr><tr><td align=\"center\"><br><br>"; echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>"; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.<br><br>"; include("include/view_active.php"); ?> </td></tr> </table> </body> </html> My index.php I have taken snipplets from main.php to put this together there is some linking errors in there but nothing to worry about I will sort them when I sort the session problem <?php include("include/session.php"); include('config/img.php'); ?> <html> <head> <link rel="stylesheet" type="text/css" href="config/style.css" /> <title>Dash Airways</title> </head> <body> <table class="main" align="center"> <tr> <td colspan="3" class="head"><img src="img/header.png"></td> </tr> <tr> <td class="leftmenu" valign="top"><br /> <table class="menu"> <tr> <th class="mhead">Main Menu</th> </tr> <tr> <td class="min"><br /> <a href="?page=home">Home</a><br /> About<br /> Join<br /> Contact<br /> Forum<br /><br /></td> </tr> </table><br /><br /> <table class="menu"> <tr> <th class="mhead">Advertisment</th> </tr> <tr> <td class="min"><br />Check Back Later<br />There might be some then<br /><br /> </tr> </table><br /> </td> <td class="body" valign="top"> <?php $page = $_GET['page']; if (!empty($page)) { $page .= '.php'; include($page); } else { include('home.php'); } ?></td> <td class="rightmenu" valign="top"><br /> <table class="menu1"> <tr> <th class="mhead">Airline Info</th> </tr> <tr> <td class="min"><br /><?php echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>"; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.<br><br>"; include("include/view_active.php"); ?> </td> </tr> </table><br /><br /> <table class="menu1"> <tr> <th class="mhead">Login</th> </tr> <tr> <td class="min"><br /><?php /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <h1>Login</h1> <?php /** * User not logged in, display the login form. * If user has already tried to login, but errors were * found, display the total number of errors. * If errors occurred, they will be displayed. */ if($form->num_errors > 0){ echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; } ?> <table align="left" border="0" cellspacing="0" cellpadding="3"> <form action="process.php" method="POST"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> <font size="2">Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </form> </table> <? } ?> </td> </tr> </table><br /></td> </tr> <tr> <td colspan="3" class="foot">©Copyright 2002-2009 Dash Airways<br /> Website and Graphics created by William Evans<br /> This site is best viewed using Modzilla Firefox 3 with a minimum resolution of 800x600</td> </tr> </table> </body> </html> to view the error in action please goto http://temp.sc40.info/ (please ignore the formatting it is still WIP lol) Thanx Will
  14. Hi I have been looking into ways to dispay information on remote site not owned by myself and I understand it can be done something like <head> <title>My Website</title> <script LANGUAGE="JAVASCRIPT" type="text/javascript" src="http://www.somesite.com/somefile.js?id=TAGNAME"></script> </head> <body onLoad="somename()"> the main linking file <DIV ID="Tag1"></DIV> <DIV ID="Tag2"></DIV> <DIV ID="Tag3"></DIV> <DIV ID="Tag4"></DIV> each tag can dispay something differant all comming from one file So how is this done now I guess it would to much for somebody to write here so any information from tutorials or hints and tips etc I would be greatful I did do a google but I could not seem to fine what I was looking for unless i was searching for the wrong tags thanx Will
  15. Hi All Right I am having a play with cURL seeing if I can make it function how i would like anyway in the file I am inporting from an external site http://www.sitename.com/foldername/filename.php all the table values are set in % of the overall size making it normaly easy to resize according to your site style as normaly it is imported using Iframe now when I use cURL it seems to set the total size to around 800px but the max size of the table that it is going into is only 640px (starting to see the problem?) so I need to try and find a way to resize it to the correct size as it seem to be cURL making it to big Any Ideas? here is the code im using <?php /** * Initialize the cURL session */ $ch = curl_init(); /** * Set the URL of the page or file to download. */ curl_setopt($ch, CURLOPT_URL, 'http://www.sitename.com/foldername/filename.php'); /** * Ask cURL to return the contents in a variable * instead of simply echoing them to the browser. */ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); /** * Execute the cURL session */ $contents = curl_exec ($ch); /** * Close cURL session */ curl_close ($ch); ?> and to include it into my main pages I use <?php $page = $_GET['page']; if (!empty($page)) { $page .= '.php'; include($page); } else { include('404.php'); } ?> Thanx for reading hope sombody knows a way out of this problem
×
×
  • 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.