
BlueDevil23
Members-
Posts
328 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by BlueDevil23
-
Re: [REVIEW] Crime-Network.com - Please review! GRPG? just a question. I havent heard good things about that engine, but it could all be talk, its only what ive heard, and have no experience with it. But good luck with your game :)
-
Re: [mccode v2] User Search To be honest, I'm not sure. Its possible, but I googled it for a bit, and found nothing relative. Possibly not though, as it may require a page refresh, with PHP.
-
Re: [mccode v2] User Search Thank you all, glad you like it :) Very very small update to the script, to allow the money column to be searched with mathematical operators ( >, <, >= ... etc.) (Only removed the /$ in the money column rows, if you wanna just update your scripts, instead of uploading the new one) updated usersearch.php <?php /*-------------------------------------------------------------- - Made by BlueDevil23 - Free to the Criminal Existence Community -- Not to be sold. - Table filter JS, made possible by Max Guglielmi - mguglielmi.free.fr/scripts/TableFilter/?l=en --------------------------------------------------------------*/ include "globals.php"; $_GET['st'] = abs((int) $_GET['st']); $by=($_GET['by']) ? $_GET['by'] : 'userid'; $ord=($_GET['ord']) ? $_GET['ord'] : 'ASC'; print <<<EOF1 <html> <head> <title>{$set['game_name']};</title> <script src="tablefilter.js" type="text/javascript" language="javascript"></script> <link rel="stylesheet" type="text/css" href="filtergrid.css"> </head> <body> EOF1; print "<h3>User Search</h3>"; $cnt=mysql_query("SELECT userid FROM users",$c); $membs=mysql_num_rows($cnt); $q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON u.gang=g.gangID ORDER BY $by $ord"); print " <table width='75%' cellspacing='1' id='userlist' class='search'> <tr> <th>ID</th> <th>Name</th> <th>Money</th> <th>Level</th> <th>Gender</th> <th>Online</th> </tr>"; while($r=$db->fetch_row($q)) { $d=""; if ($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>"; $d="[img=donator.gif]"; } print " <tr> <td>{$r['userid']}</td> <td>[url='viewuser.php?u={$r[']{$r['gangPREF']} {$r['username']} $d[/url]</td> <td>{$r['money']}</td> <td>{$r['level']}</td> <td>{$r['gender']}</td> <td>"; if($r['laston'] >= time()-15*60) { print "<font color=green>[b]Online[/b]</font>"; } else { print "<font color=red>[b]Offline[/b]</font>"; } print " </td> </tr>"; } print "</table>"; print <<<EOF2 <script language="javascript" type="text/javascript"> var userlistFilters = { enter_key: true, btn_reset: true, // If you dont want your users to be able to search the list for money, un-comment the following line. /* col_2: "none", */ col_4: "select", col_5: "select", display_all_text: " ... ", //Un-comment the following lines to enable paging. /* paging: true, paging_length: 24, */ loader: true, loader_text: "Filtering...", } setFilterGrid("userlist", userlistFilters); </script> </body> </html> EOF2; $h->endpage(); ?>
-
Re: Basic Ajax is easy Nah, I completely with ya lol...but I'm attempting to learn. But if you dont know JS, your not going to understand AJAX, because that is what it essentially is.
-
Re: [mccode v2] User Search Thank you Savager and parelem :)
-
Re: [mccode v2] User Search Add this last bit on to the last file we were making tablefilter.js { var r = false, t = grabEBI(id); if(t != null && t.nodeName.toLowerCase() == "table") { for(i in TblId) { if(id == TblId[i]) r = true; }// for i }//if return r; } function getCellsNb(id,nrow) /*==================================================== - returns number of cells in a row - if nrow param is passed returns number of cells of that specific row =====================================================*/ { var t = grabEBI(id); var tr; if(nrow == undefined) tr = grabTag(t,"tr")[0]; else tr = grabTag(t,"tr")[nrow]; var n = getChildElms(tr); return n.childNodes.length; } function getRowsNb(id) /*==================================================== - returns total nb of filterable rows starting from reference row if defined =====================================================*/ { var t = grabEBI(id); var s = t.tf_ref_row; var ntrs = grabTag(t,"tr").length; return parseInt(ntrs-s); } function getFilters(id) /*==================================================== - returns an array containing filters ids - Note that hidden filters are also returned =====================================================*/ { var SearchFltId = new Array(); var t = grabEBI(id); var tr = grabTag(t,"tr")[0]; var enfants = tr.childNodes; if(t.tf_fltGrid) { for(var i=0; i<enfants.length; i++) SearchFltId.push(enfants[i].firstChild.getAttribute("id")); } return SearchFltId; } function clearFilters(id) /*==================================================== - clears grid filters =====================================================*/ { SearchFlt = getFilters(id); for(i in SearchFlt) grabEBI(SearchFlt[i]).value = ""; } function showLoader(id,p) /*==================================================== - displays/hides loader div =====================================================*/ { var loader = grabEBI("load_"+id); if(loader != null && p=="none") setTimeout("grabEBI('load_"+id+"').style.display = '"+p+"'",150); else if(loader != null && p!="none") loader.style.display = p; } function showRowsCounter(id,p) /*==================================================== - Shows total number of filtered rows =====================================================*/ { var totrows = grabEBI("totrows_span_"+id); if(totrows != null && totrows.nodeName.toLowerCase() == "span" ) totrows.innerHTML = p; } function getChildElms(n) /*==================================================== - checks passed node is a ELEMENT_NODE nodeType=1 - removes TEXT_NODE nodeType=3 =====================================================*/ { if(n.nodeType == 1) { var enfants = n.childNodes; for(var i=0; i<enfants.length; i++) { var child = enfants[i]; if(child.nodeType == 3) n.removeChild(child); } return n; } } function getCellText(n) /*==================================================== - returns text + text of child nodes of a cell =====================================================*/ { var s = ""; var enfants = n.childNodes; for(var i=0; i<enfants.length; i++) { var child = enfants[i]; if(child.nodeType == 3) s+= child.data; else s+= getCellText(child); } return s; } function getColValues(id,colindex,num) /*==================================================== - returns an array containing cell values of a column - needs following args: - filter id (string) - column index (number) - a boolean set to true if we want only numbers to be returned =====================================================*/ { var t = grabEBI(id); var row = grabTag(t,"tr"); var nrows = row.length; var start_row = parseInt( t.tf_ref_row );//filter start row var ncells = getCellsNb( id,start_row ); var colValues = new Array(); for(var i=start_row; i<nrows; i++)//iterates rows { var cell = getChildElms(row[i]).childNodes; var nchilds = cell.length; if(nchilds == ncells)// checks if row has exact cell # { for(var j=0; j<nchilds; j++)// this loop retrieves cell data { if(j==colindex && row[i].style.display=="" ) { var cell_data = getCellText( cell[j] ).toLowerCase(); (num) ? colValues.push( parseFloat(cell_data) ) : colValues.push( cell_data ); }//if j==k }//for j }//if nchilds == ncells }//for i return colValues; } function setColWidths(id) /*==================================================== - sets widths of columns =====================================================*/ { if( hasGrid(id) ) { var t = grabEBI(id); t.style.tableLayout = "fixed"; var colWidth = t.tf_colWidth; var start_row = parseInt( t.tf_ref_row );//filter start row var row = grabTag(t,"tr")[0]; var ncells = getCellsNb(id,start_row); for(var i=0; i<colWidth.length; i++) { for(var k=0; k<ncells; k++) { cell = row.childNodes[k]; if(k==i) cell.style.width = colWidth[i]; }//var k }//for i }//if hasGrid } function setVisibleRows(id) /*==================================================== - makes a row always visible =====================================================*/ { if( hasGrid(id) ) { var t = grabEBI(id); var row = grabTag(t,"tr"); var nrows = row.length; var showPaging = t.tf_displayPaging; var visibleRows = t.tf_rowVisibility; for(var i=0; i<visibleRows.length; i++) { if(visibleRows[i]<=nrows)//row index cannot be > nrows { if(showPaging) row[ visibleRows[i] ].setAttribute("validRow","true"); row[ visibleRows[i] ].style.display = ""; }//if }//for i }//if hasGrid } function setAlternateRows(id) /*==================================================== - alternates row colors for better readability =====================================================*/ { if( hasGrid(id) ) { var t = grabEBI(id); var row = grabTag(t,"tr"); var nrows = row.length; var start_row = parseInt( t.tf_ref_row );//filter start row var visiblerows = new Array(); for(var i=start_row; i<nrows; i++)//visible rows are stored in visiblerows array if( row[i].style.display=="" ) visiblerows.push(i); for(var j=0; j<visiblerows.length; j++)//alternates bg color (j % 2 == 0) ? row[ visiblerows[j] ].className = "even" : row[ visiblerows[j] ].className = "odd"; }//if hasGrid } function setColOperation(id) /*==================================================== - Calculates values of a column - params are stored in 'colOperation' table's attribute - colOperation["id"] contains ids of elements showing result (array) - colOperation["col"] contains index of columns (array) - colOperation["operation"] contains operation type (array, values: sum, mean) - colOperation["write_method"] array defines which method to use for displaying the result (innerHTML, setValue, createTextNode). Note that innerHTML is the default value. !!! to be optimised =====================================================*/ { if( hasGrid(id) ) { var t = grabEBI(id); var labelId = t.tf_colOperation["id"]; var colIndex = t.tf_colOperation["col"]; var operation = t.tf_colOperation["operation"]; var outputType = t.tf_colOperation["write_method"]; var precision = 2;//decimal precision if( (typeof labelId).toLowerCase()=="object" && (typeof colIndex).toLowerCase()=="object" && (typeof operation).toLowerCase()=="object" ) { var row = grabTag(t,"tr"); var nrows = row.length; var start_row = parseInt( t.tf_ref_row );//filter start row var ncells = getCellsNb( id,start_row ); var colvalues = new Array(); for(var k=0; k<colIndex.length; k++)//this retrieves col values { colvalues.push( getColValues(id,colIndex[k],true) ); }//for k for(var i=0; i<colvalues.length; i++) { var result=0, nbvalues=0; for(var j=0; j<colvalues[i].length; j++ ) { var cvalue = colvalues[i][j]; if( !isNaN(cvalue) ) { switch( operation[i].toLowerCase() ) { case "sum": result += parseFloat( cvalue ); break; case "mean": nbvalues++; result += parseFloat( cvalue ); break; //add cases for other operations }//switch } }//for j switch( operation[i].toLowerCase() ) { case "mean": result = result/nbvalues; break; } if(outputType != undefined && (typeof outputType).toLowerCase()=="object") //if outputType is defined { result = result.toFixed( precision ); if( grabEBI( labelId[i] )!=undefined ) { switch( outputType[i].toLowerCase() ) { case "innerhtml": grabEBI( labelId[i] ).innerHTML = result; break; case "setvalue": grabEBI( labelId[i] ).value = result; break; case "createtextnode": var oldnode = grabEBI( labelId[i] ).firstChild; var txtnode = createText( result ); grabEBI( labelId[i] ).replaceChild( txtnode,oldnode ); break; //other cases could be added }//switch } } else { try { grabEBI( labelId[i] ).innerHTML = result.toFixed( precision ); } catch(e){ }//catch }//else }//for i }//if typeof }//if hasGrid } function grabEBI(id) /*==================================================== - this is just a getElementById shortcut =====================================================*/ { return document.getElementById( id ); } function grabTag(obj,tagname) /*==================================================== - this is just a getElementsByTagName shortcut =====================================================*/ { return obj.getElementsByTagName( tagname ); } function regexpEscape(s) /*==================================================== - escapes special characters [\^$.|?*+() for regexp - Many thanks to Cedric Wartel for this fn =====================================================*/ { // traite les caract?res sp?ciaux [\^$.|?*+() //remplace le carct?re c par \c function escape(e) { a = new RegExp('\\'+e,'g'); s = s.replace(a,'\\'+e); } chars = new Array('\\','[','^','$','.','|','?','*','+','(',')'); //chars.each(escape); // no prototype framework here... for(e in chars) escape(chars[e]); return s; } function createElm(elm) /*==================================================== - returns an html element with its attributes - accepts the following params: - a string defining the html element to create - an undetermined # of arrays containing the couple "attribute name","value" ["id","myId"] =====================================================*/ { var el = document.createElement( elm ); if(arguments.length>1) { for(var i=0; i<arguments.length; i++) { var argtype = typeof arguments[i]; switch( argtype.toLowerCase() ) { case "object": if( arguments[i].length==2 ) { el.setAttribute( arguments[i][0],arguments[i][1] ); }//if array length==2 break; }//switch }//for i }//if args return el; } function createText(node) /*==================================================== - this is just a document.createTextNode shortcut =====================================================*/ { return document.createTextNode( node ); } function DetectKey(e) /*==================================================== - common fn that detects return key for a given element (onkeypress attribute on input) =====================================================*/ { var evt=(e)?e:(window.event)?window.event:null; if(evt) { var key=(evt.charCode)?evt.charCode: ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0)); if(key=="13") { var cid, leftstr, tblid, CallFn, Match; cid = this.getAttribute("id"); leftstr = this.getAttribute("id").split("_")[0]; tblid = cid.substring(leftstr.length+1,cid.length); t = grabEBI(tblid); (t.tf_isModfilter_fn) ? t.tf_modfilter_fn.call() : Filter(tblid); }//if key }//if evt } function importScript(scriptName,scriptPath) { var isImported = false; var scripts = grabTag(document,"script"); for (var i=0; i<scripts.length; i++) { if(scripts[i].src.match(scriptPath)) { isImported = true; break; } } if( !isImported )//imports script if not available { var head = grabTag(document,"head")[0]; var extScript = createElm( "script", ["id",scriptName], ["type","text/javascript"], ["src",scriptPath] ); head.appendChild(extScript); } }//fn importScript /*==================================================== - Below a collection of public functions for developement purposes - all public methods start with prefix 'TF_' - These methods can be removed safely if not needed =====================================================*/ function TF_GetFilterIds() /*==================================================== - returns an array containing filter grids ids =====================================================*/ { try{ return TblId } catch(e){ alert('TF_GetFilterIds() fn: could not retrieve any ids'); } } function TF_HasGrid(id) /*==================================================== - checks if table has a filter grid - returns a boolean =====================================================*/ { return hasGrid(id); } function TF_GetFilters(id) /*==================================================== - returns an array containing filters ids of a specified grid =====================================================*/ { try { var flts = getFilters(id); return flts; } catch(e) { alert('TF_GetFilters() fn: table id not found'); } } function TF_GetStartRow(id) /*==================================================== - returns starting row index for filtering process =====================================================*/ { try { var t = grabEBI(id); return t.tf_ref_row; } catch(e) { alert('TF_GetStartRow() fn: table id not found'); } } function TF_GetColValues(id,colindex,num) /*==================================================== - returns an array containing cell values of a column - needs following args: - filter id (string) - column index (number) - a boolean set to true if we want only numbers to be returned =====================================================*/ { if( hasGrid(id) ) { return getColValues(id,colindex,num); }//if TF_HasGrid else alert('TF_GetColValues() fn: table id not found'); } function TF_Filter(id) /*==================================================== - filters a table =====================================================*/ { var t = grabEBI(id); if( TF_HasGrid(id) ) Filter(id); else alert('TF_Filter() fn: table id not found'); } function TF_RemoveFilterGrid(id) /*==================================================== - removes a filter grid =====================================================*/ { if( TF_HasGrid(id) ) { var t = grabEBI(id); clearFilters(id); if(grabEBI("inf_"+id)!=null) { t.parentNode.removeChild(t.previousSibling); } // remove paging here var row = grabTag(t,"tr"); for(var j=0; j<row.length; j++) //this loop shows all rows and removes validRow attribute { row[j].style.display = ""; try { if( row[j].hasAttribute("validRow") ) row[j].removeAttribute("validRow"); } //ie<=6 doesn't support hasAttribute method catch(e){ for( var x = 0; x < row[j].attributes.length; x++ ) { if( row[j].attributes[x].nodeName.toLowerCase()=="validrow" ) row[j].removeAttribute("validRow"); }//for x }//catch(e) }//for j if( t.tf_alternateBgs )//removes alterning row colors { for(var k=0; k<row.length; k++) //this loop removes bg className { row[k].className = ""; } } if(t.tf_fltGrid) t.deleteRow(0); for(i in TblId)//removes grid id value from array if(id == TblId[i]) TblId.splice(i,1); }//if TF_HasGrid else alert('TF_RemoveFilterGrid() fn: table id not found'); } function TF_ClearFilters(id) /*==================================================== - clears grid filters only, table is not filtered =====================================================*/ { if( TF_HasGrid(id) ) clearFilters(id); else alert('TF_ClearFilters() fn: table id not found'); } function TF_SetFilterValue(id,index,searcharg) /*==================================================== - Inserts value in a specified filter - Params: - id: table id (string) - index: filter column index (numeric value) - searcharg: search string =====================================================*/ { if( TF_HasGrid(id) ) { var flts = getFilters(id); for(i in flts) { if( i==index ) grabEBI(flts[i]).value = searcharg; } } else { alert('TF_SetFilterValue() fn: table id not found'); } } /*==================================================== - bind an external script fns - fns below do not belong to filter grid script and are used to interface with external autocomplete script found at the following URL: [url]http://www.codeproject.com/jscript/jsactb.asp[/url] (credit to zichun) - fns used to merge filter grid with external scripts =====================================================*/ var colValues = new Array(); function setAutoComplete(id) { var t = grabEBI(id); var bindScript = t.tf_bindScript; var scriptName = bindScript["name"]; var scriptPath = bindScript["path"]; initAutoComplete(); function initAutoComplete() { var filters = TF_GetFilters(id); for(var i=0; i<filters.length; i++) { if( grabEBI(filters[i]).nodeName.toLowerCase()=="input") { colValues.push( getColValues(id,i) ); } else colValues.push( '' ); }//for i try{ actb( grabEBI(filters[0]), colValues[0] ); } catch(e){ alert(scriptPath + " script may not be loaded"); } }//fn } Thats it... lol Many thanks to parelem, for uploading to her game, and allowing me to take screenshots from there, since my game is on WAMP, and with only me and a Bot, it wouldnt of shown much lol... Screenshots: http://i33.tinypic.com/2ztim2w.jpg http://i37.tinypic.com/16hvls3.jpg http://i35.tinypic.com/mn1de9.jpg http://i36.tinypic.com/nva5qq.jpg http://i38.tinypic.com/50mtsj.jpg http://i37.tinypic.com/kb8dl.jpg http://i38.tinypic.com/2yuhhnd.jpg Enjoy :)
-
Re: [mccode v2] User Search [Continued...] Save as tablefilter.js /*==================================================== - HTML Table Filter Generator v1.6 - By Max Guglielmi - mguglielmi.free.fr/scripts/TableFilter/?l=en - please do not change this comment - don't forget to give some credit... it's always good for the author - Special credit to Cedric Wartel and [email][email protected][/email] for contribution and inspiration =====================================================*/ // global vars var TblId, SearchFlt, SlcArgs; TblId = new Array(), SlcArgs = new Array(); function setFilterGrid(id) /*==================================================== - Checks if id exists and is a table - Then looks for additional params - Calls fn that generates the grid =====================================================*/ { var tbl = grabEBI(id); var ref_row, fObj; if(tbl != null && tbl.nodeName.toLowerCase() == "table") { if(arguments.length>1) { for(var i=0; i<arguments.length; i++) { var argtype = typeof arguments[i]; switch(argtype.toLowerCase()) { case "number": ref_row = arguments[i]; break; case "object": fObj = arguments[i]; break; }//switch }//for }//if ref_row == undefined ? ref_row=2 : ref_row=(ref_row+2); var ncells = getCellsNb(id,ref_row); tbl.tf_ncells = ncells; if(tbl.tf_ref_row==undefined) tbl.tf_ref_row = ref_row; tbl.tf_Obj = fObj; if( !hasGrid(id) ) AddGrid(id); }//if tbl!=null } function AddGrid(id) /*==================================================== - adds a row containing the filtering grid =====================================================*/ { TblId.push(id); var t = grabEBI(id); var f = t.tf_Obj, n = t.tf_ncells; var inpclass, fltgrid, displayBtn, btntext, enterkey; var modfilter_fn, display_allText, on_slcChange; var displaynrows, totrows_text, btnreset, btnreset_text; var sort_slc, displayPaging, pagingLength, displayLoader; var load_text, exactMatch, alternateBgs, colOperation; var rowVisibility, colWidth, bindScript; f!=undefined && f["grid"]==false ? fltgrid=false : fltgrid=true;//enables/disables filter grid f!=undefined && f["btn"]==true ? displayBtn=true : displayBtn=false;//show/hides filter's validation button f!=undefined && f["btn_text"]!=undefined ? btntext=f["btn_text"] : btntext="go";//defines button text f!=undefined && f["enter_key"]==false ? enterkey=false : enterkey=true;//enables/disables enter key f!=undefined && f["mod_filter_fn"] ? modfilter_fn=true : modfilter_fn=false;//defines alternative fn f!=undefined && f["display_all_text"]!=undefined ? display_allText=f["display_all_text"] : display_allText="";//defines 1st option text f!=undefined && f["on_change"]==false ? on_slcChange=false : on_slcChange=true;//enables/disables onChange event on combo-box f!=undefined && f["rows_counter"]==true ? displaynrows=true : displaynrows=false;//show/hides rows counter f!=undefined && f["rows_counter_text"]!=undefined ? totrows_text=f["rows_counter_text"] : totrows_text="Displayed rows: ";//defines rows counter text f!=undefined && f["btn_reset"]==true ? btnreset=true : btnreset=false;//show/hides reset link f!=undefined && f["btn_reset_text"]!=undefined ? btnreset_text=f["btn_reset_text"] : btnreset_text="Reset";//defines reset text f!=undefined && f["sort_select"]==true ? sort_slc=true : sort_slc=false;//enables/disables select options sorting f!=undefined && f["paging"]==true ? displayPaging=true : displayPaging=false;//enables/disables table paging f!=undefined && f["paging_length"]!=undefined ? pagingLength=f["paging_length"] : pagingLength=10;//defines table paging length f!=undefined && f["loader"]==true ? displayLoader=true : displayLoader=false;//enables/disables loader f!=undefined && f["loader_text"]!=undefined ? load_text=f["loader_text"] : load_text="Loading...";//defines loader text f!=undefined && f["exact_match"]==true ? exactMatch=true : exactMatch=false;//enables/disbles exact match for search f!=undefined && f["alternate_rows"]==true ? alternateBgs=true : alternateBgs=false;//enables/disbles rows alternating bg colors f!=undefined && f["col_operation"] ? colOperation=true : colOperation=false;//enables/disbles column operation(sum,mean) f!=undefined && f["rows_always_visible"] ? rowVisibility=true : rowVisibility=false;//makes a row always visible f!=undefined && f["col_width"] ? colWidth=true : colWidth=false;//defines widths of columns f!=undefined && f["bind_script"] ? bindScript=true : bindScript=false; // props are added to table in order to be easily accessible from other fns t.tf_fltGrid = fltgrid; t.tf_displayBtn = displayBtn; t.tf_btnText = btntext; t.tf_enterKey = enterkey; t.tf_isModfilter_fn = modfilter_fn; t.tf_display_allText = display_allText; t.tf_on_slcChange = on_slcChange; t.tf_rowsCounter = displaynrows; t.tf_rowsCounter_text = totrows_text; t.tf_btnReset = btnreset; t.tf_btnReset_text = btnreset_text; t.tf_sortSlc = sort_slc; t.tf_displayPaging = displayPaging; t.tf_pagingLength = pagingLength; t.tf_displayLoader = displayLoader; t.tf_loadText = load_text; t.tf_exactMatch = exactMatch; t.tf_alternateBgs = alternateBgs; t.tf_startPagingRow = 0; if(modfilter_fn) t.tf_modfilter_fn = f["mod_filter_fn"];// used by DetectKey fn if(fltgrid) { var fltrow = t.insertRow(0); //adds filter row fltrow.className = "fltrow"; for(var i=0; i<n; i++)// this loop adds filters { var fltcell = fltrow.insertCell(i); //fltcell.noWrap = true; i==n-1 && displayBtn==true ? inpclass = "flt_s" : inpclass = "flt"; if(f==undefined || f["col_"+i]==undefined || f["col_"+i]=="none") { var inptype; (f==undefined || f["col_"+i]==undefined) ? inptype="text" : inptype="hidden";//show/hide input var inp = createElm( "input",["id","flt"+i+"_"+id],["type",inptype],["class",inpclass] ); inp.className = inpclass;// for ie<=6 fltcell.appendChild(inp); if(enterkey) inp.onkeypress = DetectKey; } else if(f["col_"+i]=="select") { var slc = createElm( "select",["id","flt"+i+"_"+id],["class",inpclass] ); slc.className = inpclass;// for ie<=6 fltcell.appendChild(slc); PopulateOptions(id,i); if(displayPaging)//stores arguments for GroupByPage() fn { var args = new Array(); args.push(id); args.push(i); args.push(n); args.push(display_allText); args.push(sort_slc); args.push(displayPaging); SlcArgs.push(args); } if(enterkey) slc.onkeypress = DetectKey; if(on_slcChange) { (!modfilter_fn) ? slc.onchange = function(){ Filter(id); } : slc.onchange = f["mod_filter_fn"]; } } if(i==n-1 && displayBtn==true)// this adds button { var btn = createElm( "input", ["id","btn"+i+"_"+id],["type","button"], ["value",btntext],["class","btnflt"] ); btn.className = "btnflt"; fltcell.appendChild(btn); (!modfilter_fn) ? btn.onclick = function(){ Filter(id); } : btn.onclick = f["mod_filter_fn"]; }//if }// for i }//if fltgrid if(displaynrows || btnreset || displayPaging || displayLoader) { /*** div containing rows # displayer + reset btn ***/ var infdiv = createElm( "div",["id","inf_"+id],["class","inf"] ); infdiv.className = "inf";// setAttribute method for class attribute doesn't seem to work on ie<=6 t.parentNode.insertBefore(infdiv, t); if(displaynrows) { /*** left div containing rows # displayer ***/ var totrows; var ldiv = createElm( "div",["id","ldiv_"+id] ); displaynrows ? ldiv.className = "ldiv" : ldiv.style.display = "none"; displayPaging ? totrows = pagingLength : totrows = getRowsNb(id); var totrows_span = createElm( "span",["id","totrows_span_"+id],["class","tot"] ); // tot # of rows displayer totrows_span.className = "tot";//for ie<=6 totrows_span.appendChild( createText(totrows) ); var totrows_txt = createText(totrows_text); ldiv.appendChild(totrows_txt); ldiv.appendChild(totrows_span); infdiv.appendChild(ldiv); } if(displayLoader) { /*** div containing loader ***/ var loaddiv = createElm( "div",["id","load_"+id],["class","loader"] ); loaddiv.className = "loader";// for ie<=6 loaddiv.style.display = "none"; loaddiv.appendChild( createText(load_text) ); infdiv.appendChild(loaddiv); } if(displayPaging) { /*** mid div containing paging displayer ***/ var mdiv = createElm( "div",["id","mdiv_"+id] ); displayPaging ? mdiv.className = "mdiv" : mdiv.style.display = "none"; infdiv.appendChild(mdiv); var start_row = t.tf_ref_row; var row = grabTag(t,"tr"); var nrows = row.length; var npages = Math.ceil( (nrows - start_row)/pagingLength );//calculates page nb var slcPages = createElm( "select",["id","slcPages_"+id] ); slcPages.onchange = function(){ if(displayLoader) showLoader(id,""); t.tf_startPagingRow = this.value; GroupByPage(id); if(displayLoader) showLoader(id,"none"); } var pgspan = createElm( "span",["id","pgspan_"+id] ); grabEBI("mdiv_"+id).appendChild( createText(" Page ") ); grabEBI("mdiv_"+id).appendChild(slcPages); grabEBI("mdiv_"+id).appendChild( createText(" of ") ); pgspan.appendChild( createText(npages+" ") ); grabEBI("mdiv_"+id).appendChild(pgspan); for(var j=start_row; j<nrows; j++)//this sets rows to validRow=true { row[j].setAttribute("validRow","true"); }//for j setPagingInfo(id); if(displayLoader) showLoader(id,"none"); } if(btnreset && fltgrid) { /*** right div containing reset button **/ var rdiv = createElm( "div",["id","reset_"+id] ); btnreset ? rdiv.className = "rdiv" : rdiv.style.display = "none"; var fltreset = createElm( "a", ["href","javascript:clearFilters('"+id+"');Filter('"+id+"');"] ); fltreset.appendChild(createText(btnreset_text)); rdiv.appendChild(fltreset); infdiv.appendChild(rdiv); } }//if displaynrows etc. if(colWidth) { t.tf_colWidth = f["col_width"]; setColWidths(id); } if(alternateBgs && !displayPaging) setAlternateRows(id); if(colOperation) { t.tf_colOperation = f["col_operation"]; setColOperation(id); } if(rowVisibility) { t.tf_rowVisibility = f["rows_always_visible"]; if(displayPaging) setVisibleRows(id); } if(bindScript) { t.tf_bindScript = f["bind_script"]; if( t.tf_bindScript!=undefined && t.tf_bindScript["target_fn"]!=undefined ) {//calls a fn if defined t.tf_bindScript["target_fn"].call(null,id); } }//if bindScript } function PopulateOptions(id,cellIndex) /*==================================================== - populates select - adds only 1 occurence of a value =====================================================*/ { var t = grabEBI(id); var ncells = t.tf_ncells, opt0txt = t.tf_display_allText; var sort_opts = t.tf_sortSlc, paging = t.tf_displayPaging; var start_row = t.tf_ref_row; var row = grabTag(t,"tr"); var OptArray = new Array(); var optIndex = 0; // option index var currOpt = new Option(opt0txt,"",false,false); //1st option grabEBI("flt"+cellIndex+"_"+id).options[optIndex] = currOpt; for(var k=start_row; k<row.length; k++) { var cell = getChildElms(row[k]).childNodes; var nchilds = cell.length; var isPaged = row[k].getAttribute("paging"); if(nchilds == ncells){// checks if row has exact cell # for(var j=0; j<nchilds; j++)// this loop retrieves cell data { if(cellIndex==j) { var cell_data = getCellText(cell[j]); // checks if celldata is already in array var isMatched = false; for(w in OptArray) { if( cell_data == OptArray[w] ) isMatched = true; } if(!isMatched) OptArray.push(cell_data); }//if cellIndex==j }//for j }//if }//for k if(sort_opts) OptArray.sort(); for(y in OptArray) { optIndex++; var currOpt = new Option(OptArray[y],OptArray[y],false,false); grabEBI("flt"+cellIndex+"_"+id).options[optIndex] = currOpt; } } function Filter(id) /*==================================================== - Filtering fn - gets search strings from SearchFlt array - retrieves data from each td in every single tr and compares to search string for current column - tr is hidden if all search strings are not found =====================================================*/ { showLoader(id,""); SearchFlt = getFilters(id); var t = grabEBI(id); t.tf_Obj!=undefined ? fprops = t.tf_Obj : fprops = new Array(); var SearchArgs = new Array(); var ncells = getCellsNb(id); var totrows = getRowsNb(id), hiddenrows = 0; var ematch = t.tf_exactMatch; var showPaging = t.tf_displayPaging; for(var i=0; i<SearchFlt.length; i++) SearchArgs.push( (grabEBI(SearchFlt[i]).value).toLowerCase() ); var start_row = t.tf_ref_row; var row = grabTag(t,"tr"); for(var k=start_row; k<row.length; k++) { /*** if table already filtered some rows are not visible ***/ if(row[k].style.display == "none") row[k].style.display = ""; var cell = getChildElms(row[k]).childNodes; var nchilds = cell.length; if(nchilds == ncells)// checks if row has exact cell # { var cell_value = new Array(); var occurence = new Array(); var isRowValid = true; for(var j=0; j<nchilds; j++)// this loop retrieves cell data { var cell_data = getCellText(cell[j]).toLowerCase(); cell_value.push(cell_data); if(SearchArgs[j]!="") { var num_cell_data = parseFloat(cell_data); if(/<=/.test(SearchArgs[j]) && !isNaN(num_cell_data)) // first checks if there is an operator (<,>,<=,>=) { num_cell_data <= parseFloat(SearchArgs[j].replace(/<=/,"")) ? occurence[j] = true : occurence[j] = false; } else if(/>=/.test(SearchArgs[j]) && !isNaN(num_cell_data)) { num_cell_data >= parseFloat(SearchArgs[j].replace(/>=/,"")) ? occurence[j] = true : occurence[j] = false; } else if(/</.test(SearchArgs[j]) && !isNaN(num_cell_data)) { num_cell_data < parseFloat(SearchArgs[j].replace(/</,"")) ? occurence[j] = true : occurence[j] = false; } else if(/>/.test(SearchArgs[j]) && !isNaN(num_cell_data)) { num_cell_data > parseFloat(SearchArgs[j].replace(/>/,"")) ? occurence[j] = true : occurence[j] = false; } else { // Improved by Cedric Wartel (cwl) // automatic exact match for selects and special characters are now filtered // modif cwl : exact match automatique sur les select var regexp; if(ematch || fprops["col_"+j]=="select") regexp = new RegExp('(^)'+regexpEscape(SearchArgs[j])+'($)',"gi"); else regexp = new RegExp(regexpEscape(SearchArgs[j]),"gi"); occurence[j] = regexp.test(cell_data); } }//if SearchArgs }//for j for(var z=0; z<ncells; z++) { if(SearchArgs[z]!="" && !occurence[z]) isRowValid = false; }//for t }//if if(!isRowValid) { row[k].style.display = "none"; hiddenrows++; if( showPaging ) row[k].setAttribute("validRow","false"); } else { row[k].style.display = ""; if( showPaging ) row[k].setAttribute("validRow","true"); } }// for k t.tf_nRows = parseInt( getRowsNb(id) )-hiddenrows; if( !showPaging ) applyFilterProps(id);//applies filter props after filtering process if( showPaging ){ t.tf_startPagingRow=0; setPagingInfo(id); }//starts paging process } function setPagingInfo(id) /*==================================================== - Paging fn - calculates page # according to valid rows - refreshes paging select according to page # - Calls GroupByPage fn =====================================================*/ { var t = grabEBI(id); var start_row = parseInt( t.tf_ref_row );//filter start row var pagelength = t.tf_pagingLength; var row = grabTag(t,"tr"); var mdiv = grabEBI("mdiv_"+id); var slcPages = grabEBI("slcPages_"+id); var pgspan = grabEBI("pgspan_"+id); var nrows = 0; for(var j=start_row; j<row.length; j++)//counts rows to be grouped { if(row[j].getAttribute("validRow") == "true") nrows++; }//for j var npg = Math.ceil( nrows/pagelength );//calculates page nb pgspan.innerHTML = npg; //refresh page nb span slcPages.innerHTML = "";//select clearing shortcut if( npg>0 ) { mdiv.style.visibility = "visible"; for(var z=0; z<npg; z++) { var currOpt = new Option((z+1),z*pagelength,false,false); slcPages.options[z] = currOpt; } } else {/*** if no results paging select is hidden ***/ mdiv.style.visibility = "hidden"; } GroupByPage(id); } function GroupByPage(id) /*==================================================== - Paging fn - Displays current page rows =====================================================*/ { showLoader(id,""); var t = grabEBI(id); var start_row = parseInt( t.tf_ref_row );//filter start row var pagelength = parseInt( t.tf_pagingLength ); var paging_start_row = parseInt( t.tf_startPagingRow );//paging start row var paging_end_row = paging_start_row + pagelength; var row = grabTag(t,"tr"); var nrows = 0; var validRows = new Array();//stores valid rows index for(var j=start_row; j<row.length; j++) //this loop stores valid rows index in validRows Array { var isRowValid = row[j].getAttribute("validRow"); if(isRowValid=="true") validRows.push(j); }//for j for(h=0; h<validRows.length; h++) //this loop shows valid rows of current page { if( h>=paging_start_row && h<paging_end_row ) { nrows++; row[ validRows[h] ].style.display = ""; } else row[ validRows[h] ].style.display = "none"; }//for h t.tf_nRows = parseInt(nrows); applyFilterProps(id);//applies filter props after filtering process } function applyFilterProps(id) /*==================================================== - checks fns that should be called after filtering and/or paging process =====================================================*/ { t = grabEBI(id); var rowsCounter = t.tf_rowsCounter; var nRows = t.tf_nRows; var rowVisibility = t.tf_rowVisibility; var alternateRows = t.tf_alternateBgs; var colOperation = t.tf_colOperation; if( rowsCounter ) showRowsCounter( id,parseInt(nRows) );//refreshes rows counter if( rowVisibility ) setVisibleRows(id);//shows rows always visible if( alternateRows ) setAlternateRows(id);//alterning row colors if( colOperation ) setColOperation(id);//makes operation on a col showLoader(id,"none"); } function hasGrid(id) /*==================================================== - checks if table has a filter grid - returns a boolean =====================================================*/ Same file continued in next post....
-
Hey all, I've been slowly putting this together, working on it the last few days. :) It basically voids the need for any search feature (search.php) or a Userlist (userlist.php), as it is both, combined in one. Getting late, so I'll get right to it. 3 Files you'll need.... One PHP file, One CSS file, and One JS file. First, the CSS.... save as filtergrid.css /*==================================================== - HTML Table Filter v1.6 elements and classes - edit classes below to change filter grid style =====================================================*/ .fltrow{ /* filter grid row appearance */ height:20px; background-color:#f4f4f4; } .btnflt{ /* button appearance */ font-size:11px; margin:0 2px 0 2px; padding:0 1px 0 1px; text-decoration:none; color: #fff; background-color:#666; } .flt{ /* filter (input) appearance */ background-color:#f4f4f4; border:1px inset #ccc; margin:0; width:100%; color: black; } .flt_s{ /* small filter (input) appearance */ background-color:#f4f4f4; border:1px inset #ccc; margin:0; width:80%; } .inf{ /* div containing left, middle and right divs */ clear:both; width:auto; height:20px; background:#f4f4f4; font-size:11px; margin:0; padding:1px 3px 1px 3px; border:1px solid #ccc; } .ldiv{ /* left div */ float:left; width:30%; position:inherit; } .mdiv{ /* middle div */ float:left; width:30%; position:inherit; text-align:center; } .rdiv{ /* right div */ float:right; width:30%; position:inherit; text-align:right; } .loader{ /* loader appearance */ position:absolute; padding: 15px 0 15px 0; margin-top:7%; width:200px; left:40%; z-index:1000; font-size:14px; font-weight:bold; border:1px solid #666; background:#f4f4f4; text-align:center; vertical-align:middle; } div.mdiv select{ height:20px; }/*paging drop-down list*/ div.inf a{ color:#CC0000; }/*link appearence in .inf div*/ div.inf a:hover{ text-decoration:none; }/*link appearence in .inf div*/ .tot{ font-weight:bold; }/*rows counter*/ .even{ background-color:#fff; }/*row bg alternating color*/ .odd{ background-color:#f4f4f4; }/*row bg alternating color*/ .search { width:100%; font-size:12px; border:1px solid #ccc; } .search th { background-color:#003366; color:#FFF; padding:2px; border:1px solid #ccc; } .search td { padding:2px; border-bottom:1px solid #ccc; border-right:1px solid #ccc; } Second the PHP file.... save as usersearch.php -- technically can be whatever you choose, but thats what I used. <?php /*-------------------------------------------------------------- - Made by BlueDevil23 - Free to the Criminal Existence Community -- Not to be sold. - Table filter JS, made possible by Max Guglielmi - mguglielmi.free.fr/scripts/TableFilter/?l=en --------------------------------------------------------------*/ include "globals.php"; $_GET['st'] = abs((int) $_GET['st']); $by=($_GET['by']) ? $_GET['by'] : 'userid'; $ord=($_GET['ord']) ? $_GET['ord'] : 'ASC'; print <<<EOF1 <html> <head> <title>{$set['game_name']};</title> <script src="tablefilter.js" type="text/javascript" language="javascript"></script> <link rel="stylesheet" type="text/css" href="filtergrid.css"> </head> <body> EOF1; print "<h3>User Search</h3>"; $cnt=mysql_query("SELECT userid FROM users",$c); $membs=mysql_num_rows($cnt); $q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON u.gang=g.gangID ORDER BY $by $ord"); print " <table width='75%' cellspacing='1' id='userlist' class='search'> <tr> <th>ID</th> <th>Name</th> <th>Money</th> <th>Level</th> <th>Gender</th> <th>Online</th> </tr>"; while($r=$db->fetch_row($q)) { $d=""; if ($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>"; $d="[img=donator.gif]"; } print " <tr> <td>{$r['userid']}</td> <td>[url='viewuser.php?u={$r[']{$r['gangPREF']} {$r['username']} $d[/url]</td> <td>\${$r['money']}</td> <td>{$r['level']}</td> <td>{$r['gender']}</td> <td>"; if($r['laston'] >= time()-15*60) { print "<font color=green>[b]Online[/b]</font>"; } else { print "<font color=red>[b]Offline[/b]</font>"; } print " </td> </tr>"; } print "</table>"; print <<<EOF2 <script language="javascript" type="text/javascript"> var userlistFilters = { enter_key: true, btn_reset: true, // If you dont want your users to be able to search the list for money, un-comment the following line. /* col_2: "none", */ col_4: "select", col_5: "select", display_all_text: " ... ", //Un-comment the following lines to enable paging. /* paging: true, paging_length: 24, */ loader: true, loader_text: "Filtering...", } setFilterGrid("userlist", userlistFilters); </script> </body> </html> EOF2; $h->endpage(); ?> Sine the JS file has so many characters I'll put it in two posts of its own, instead of splitting it up into three, to avoid confusion.
-
Re: {REQUEST}Mccode Duping... And what exactly is duping? :-)
-
Re: [V2] View Donators I happen to like your style, its the same way I write code. No need to mix (X)HTML with PHP...unless its excessive opening and closing, then I'll just print the (X)HTML. Also very neat. Good job on the mod, +1 :)
-
Re: mod_rewrite Check out these two sites. Rewrite Guide Tips and Tricks
-
Re: [mccode v2] Login and Register Pages Thank you all :) and thanks Tezza` for clearing that up :)
-
Re: [mccode v2] Login and Register Pages Thanks :) Lol, which one ?
-
Re: [mccode v2] Login and Register Pages Thank you both :)
-
Re: [V2] crystal Temple Good idea Sniko`, I always thought the original Crystal Template was quite boring, and could use a revamp :) +1
-
Re: [mccode v2] Login and Register Pages Thanks, Sniko` and Tezza` :)
-
Re: [mccode v2] Login and Register Pages Now for the main pages. I took my time to validate the XHTML and CSS on both pages. I've added the badges to the bottom. Here is login.php <?php /*----------------------------------------------------- -- Made By BlueDevil23 -- Free Mod for the CE Community - Not to be sold -- Template by Arcsin Web Templates - Do not remove their link! -----------------------------------------------------*/ session_start(); include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } print <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="description" content=""/> <meta name="keywords" content="" /> <meta name="author" content="" /> <link rel="stylesheet" type="text/css" href="reset.css" media="screen" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> <title>{$set['game_name']}</title> </head> <body> EOF; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; if(file_exists('ipbans/'.$IP)) { die("[b]<font color=red size=+1>Your IP has been banned, there is no way around this.</font>[/b]</body></html>"); } $year=date('Y'); print <<<EOF <div id="paper_left"> <div id="paper_right"> <div id="layout_wrapper"> <div id="layout_container"> <div id="layout_content"> <div id="site_title"> <h1>[url="#"]{$set['game_name']}[/url]</h1> <h2>Site motto here...</h2> </div> <div id="header_image"></div> <div class="navigation"> <ul> [*][url="login.php"]Login[/url] [*][url="register.php"]Register[/url] [/list] <div class="clearer"> </div> </div> EOF; /* Note: Uncomment this section to display subnavigation <div class="clearer"> </div> <div class="navigation" id="subnav"> <ul> [*][url="#"]Subnav item 1[/url] [*][url="#"]Subnav item 2[/url] [*][url="#"]Subnav item 3[/url] [/list] */ print <<<EOF <div class="clearer"> </div> </div> <div id="main"> <div class="post"> <div class="post_top"> <div class="post_title"><h2>Login</h2></div> </div> <div class="post_body"> <table width="80%"> <tr> <td width="50%"> <fieldset> <legend>About {$set['game_name']}</legend> {$set['game_description']} </fieldset> </td> <td> <fieldset> <legend>Login</legend> <form action="authenticate.php" method="post" name="login"> <dl> <dt>Username</dt> <dd><input type="text" name="username" /></dd> <dt>Password</dt> <dd><input type="password" name="password" /></dd> <dt> </dt> <dd><input type="submit" value="Submit" /></dd> </dl> </form> </fieldset> </td> </tr> </table> <h3>[url='register.php']REGISTER NOW![/url]</h3> </div> </div> </div> <div id="bottom"> <div class="tcenter2">Powered by codes made by Dabomstew (© {$year}). Game Copyright ©{$year} {$set['game_owner']}.</div> <div class="clearer"> </div> </div> <div id="footer"> <div class="left">© 2008 {$set['game_name']}</div> <div class="right">Design by [url="http://templates.arcsin.se/"]Arcsin Web Templates[/url] [url='http://validator.w3.org/check?uri=referer'][img=http://www.w3.org/Icons/valid-xhtml10][/url]. <a href='http://jigsaw.w3.org/css-validator/'> [img=http://jigsaw.w3.org/css-validator/images/vcss] </a> </div> <div class="clearer"> </div> </div> </div> </div> </div> </div> </body> </html> EOF; ?> And for register.php <?php /*----------------------------------------------------- -- Made By BlueDevil23 -- Free Mod for the CE Community - Not to be sold -- Template by Arcsin Web Templates - Do not remove their link! -----------------------------------------------------*/ session_start(); include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } //thx to [url]http://www.phpit.net/code/valid-email/[/url] for valid_email function valid_email($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } session_start(); print <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="description" content=""/> <meta name="keywords" content="" /> <meta name="author" content="" /> <link rel="stylesheet" type="text/css" href="reset.css" media="screen" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> <title>{$set['game_name']}</title> <script type="text/javascript"> var xmlHttp // xmlHttp variable function GetXmlHttpObject(){ // This function we will use to call our xmlhttpobject. var objXMLHttp=null // Sets objXMLHttp to null as default. if (window.XMLHttpRequest){ // If we are using Netscape or any other browser than IE lets use xmlhttp. objXMLHttp=new XMLHttpRequest() // Creates a xmlhttp request. }else if (window.ActiveXObject){ // ElseIf we are using IE lets use Active X. objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") // Creates a new Active X Object. } // End ElseIf. return objXMLHttp // Returns the xhttp object. } // Close Function function CheckPasswords(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="check.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("passwordresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function CheckUsername(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="checkun.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("usernameresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function CheckEmail(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="checkem.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("emailresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function PasswordMatch() { pwt1=document.getElementById('pw1').value; pwt2=document.getElementById('pw2').value; if(pwt1 == pwt2) { document.getElementById('cpasswordresult').innerHTML="OK"; } else { document.getElementById('cpasswordresult').innerHTML="Not Matching"; } } </script> </head> <body> EOF; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; if(file_exists('ipbans/'.$IP)) { die("[b]<font color=red size=+1>Your IP has been banned, there is no way around this.</font>[/b]"); } if($_POST['username']) { if($set['regcap_on']) { if(!$_SESSION['captcha'] or $_SESSION['captcha'] != $_POST['captcha']) { unset($_SESSION['captcha']); die("Captcha Test Failed >[url='register.php']Back[/url]"); } unset($_SESSION['captcha']); } if(!valid_email($_POST['email'])) { die("Sorry, the email is invalid. >[url='register.php']Back[/url]"); } if(strlen($_POST['username']) < 4) { die("Sorry, the username is too short. >[url='register.php']Back[/url]"); } $sm=100; if($_POST['promo'] == "Your Promo Code Here") { $sm+=100; } $username=$_POST['username']; $username=str_replace(array("<", ">"), array("<", ">"), $username); $q=$db->query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'"); $q2=$db->query("SELECT * FROM users WHERE email='{$_POST['email']}'"); if($db->num_rows($q)) { print "Username already in use. Choose another. >[url='register.php']Back[/url]"; } else if($db->num_rows($q2)) { print "E-Mail already in use. Choose another. >[url='register.php']Back[/url]"; } else if($_POST['password'] != $_POST['cpassword']) { print "The passwords did not match, go back and try again. >[url='register.php']Back[/url]"; } else { $_POST['ref'] = abs((int) $_POST['ref']); $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $q=$db->query("SELECT * FROM users WHERE lastip='$IP' AND userid={$_POST['ref']}"); if($db->num_rows($q)) { die("No creating referral multies. Bad dog. >[url='register.php']Back[/url]"); } if($_POST['ref']) { $q=$db->query("SELECT * FROM users WHERE userid={$_POST['ref']}"); $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)"); if($_POST['ref']) { require "global_func.php"; $db->query("UPDATE users SET crystals=crystals+2 WHERE userid={$_POST['ref']}"); event_add($_POST['ref'],"For refering $username to the game, you have earnt 2 valuable crystals!",$c); $db->query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$IP')"); } print "You have signed up, enjoy the game. > [url='login.php']Login[/url]"; } } else { if($set['regcap_on']) { $chars="123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?\\/%^"; $len=strlen($chars); $_SESSION['captcha']=""; for($i=0;$i<6;$i++) $_SESSION['captcha'].=$chars[rand(0, $len - 1)]; } print <<<EOF <div id="paper_left"> <div id="paper_right"> <div id="layout_wrapper"> <div id="layout_container"> <div id="layout_content"> <div id="site_title"> <h1>[url="#"]{$set['game_name']}[/url]</h1> <h2>Site motto here...</h2> </div> <div id="header_image"></div> <div class="navigation"> <ul> [*][url="login.php"]Login[/url] [*][url="register.php"]Register[/url] [/list] <div class="clearer"> </div> </div> EOF; /* Note: Uncomment this section to display subnavigation <div class="clearer"> </div> <div class="navigation" id="subnav"> <ul> [*][url="#"]Subnav item 1[/url] [*][url="#"]Subnav item 2[/url] [*][url="#"]Subnav item 3[/url] [/list] */ print <<<EOF <div class="clearer"> </div> </div> <div id="main"> <div class="post"> <div class="post_top"> <div class="post_title"><h2>Register</h2></div> </div> <div class="post_body"> <form action="register.php" method="post"> <table> <tr> <td width='30%'>Username</td><td> </td> <td width='40%'><input type="text" name="username" onkeyup='CheckUsername(this.value);' /></td> <td width='30%'><div id='usernameresult'></div></td> </tr> <tr> <td>Password</td><td> </td> <td><input type="password" id='pw1' name="password" onkeyup='CheckPasswords(this.value);PasswordMatch();' /></td> <td><div id='passwordresult'></div></td> </tr> <tr> <td>Confirm Password </td><td> </td> <td><input type="password" name="cpassword" id='pw2' onkeyup='PasswordMatch();' /></td> <td><div id='cpasswordresult'></div></td> </tr> <tr> <td>Email </td><td> </td> <td><input type="text" name="email" onkeyup='CheckEmail(this.value);' /></td> <td><div id='emailresult'></div></td> </tr> <tr> <td>Gender</td><td> </td> <td colspan='2'><select name='gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select></td> </tr> <tr> <td>Promo Code </td><td> </td> <td colspan="2"><input type="text" name="promo" /></td> </tr> <tr> <td> <input type="hidden" name="ref" value=' EOF; if($_GET['REF']) { print $_GET['REF']; } print "' /> </td> </tr>"; if($set['regcap_on']) { print " <tr> <td colspan=3>[img=captcha_verify.php?bgcolor=C3C3C3] <input type='text' name='captcha' /></td> </tr>"; } print " <tr> <td colspan='3' align='center'><input type='submit' value='Submit' /></td> </tr> </table> </form> </div> <div id='bottom'> </div>"; } print " </div> </div> <div class='clearer'></div> </div> <div id='footer'> <div class='left'>© 2008 {$set['game_name']} </div> <div class='right'> Design by [url='http://templates.arcsin.se/']Arcsin Web Templates[/url] [url='http://validator.w3.org/check?uri=referer'][img=http://www.w3.org/Icons/valid-xhtml10][/url]. <a href='http://jigsaw.w3.org/css-validator/'> [img=http://jigsaw.w3.org/css-validator/images/vcss] </a> </div> <div class='clearer'> </div> </div> </div> </div> </div> </body> </html>"; ?> Here is the images you will need to make it work. Save as body.jpg http://i37.tinypic.com/71igd3.jpg Save as grain_dark.gif http://i33.tinypic.com/291239z.gif Save as header.gif http://i33.tinypic.com/2582r8p.gif Save as paper_left.gif http://i36.tinypic.com/w85m2v.jpg Save as paper_right.gif http://i35.tinypic.com/23gzg1w.jpg Save as post_body.jpg http://i33.tinypic.com/riswv5.jpg Save as post_top.gif http://i35.tinypic.com/2nqr3na.gif Save as wrapper.gif http://i36.tinypic.com/2ev96jq.gif Screenshots: Login: Register: Enjoy! :)
-
Hey all i made this login and register setup from a free template awhile back for someone. They no longer own/code for a game, so it is no longer being used. So i got bored, and thought i would fully validate it, and fix it up. And then put it out there for anyone of the CE community, so its not just sitting around. Might as well get some use out of it. Thanks to Tezza` for making a filler banner for it. :) Now, there are three CSS files you'll need. 1 to reset the browser settings. Another to fix Internet Explorer's rendering differences. And a last one, that the pages get their styles from. So first save this as reset.css /* [url]http://meyerweb.com/eric/tools/css/reset/[/url] */ /* v1.0 | 20080212 */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } /* remember to define focus styles! */ :focus { outline: 0; } /* remember to highlight inserts somehow! */ ins { text-decoration: none; } del { text-decoration: line-through; } /* tables still need 'cellspacing="0"' in the markup */ table { border-collapse: collapse; border-spacing: 0; } Second, save this as ie_fixes.css #bottom,#footer,.post_body,.post_top {height: 0.01%;} And last, for the main CSS, save this as style.css /* Template name: Grunge Superstar Template URI: [url]http://templates.arcsin.se/grunge-superstar-website-template/[/url] Release date: 2008-06-15 Description: A dirty, monochrome single-column template. Author: Viktor Persson Author URI: [url]http://arcsin.se/[/url] This template is licensed under a Creative Commons Attribution 2.5 License: [url]http://templates.arcsin.se/license/[/url] */ /* -------------------------------- General ----------------------------------- */ html { font-size: 62.5%; /* reset 1em to 10px */ height: 100%; } body { background: #444 url('img/body.jpg'); color: #444; font: normal 1.2em Verdana,Arial,sans-serif; height: 100%; padding-bottom: 1px; /* force scrollbars */ padding-top: 64px; } small,.small {font-size: 0.9em;} a { color: #EEC; text-decoration: none; } a:hover { color: #FFA; text-decoration: underline; } p {padding: 0.2em 0 1.2em;} legend {font-weight: bold;} /* -------------------------------- Headings, titles ----------------------------------- */ h1 {font: normal 2em Georgia,sans-serif;} h2 {font: normal 1.6em Georgia,sans-serif;} h3 {font: normal 1.4em Georgia,sans-serif;} h4 {font: bold 1em Georgia,sans-serif;} h1, h2, h3, h4 {margin-bottom: 5px;} /* -------------------------------- Main layout ----------------------------------- */ #paper_left { background: url('img/paper_left.gif') no-repeat left top; margin: 0 auto; padding-bottom: 34px; width: 778px; } #paper_right { background: url('img/paper_right.gif') no-repeat right bottom; } #layout_wrapper { background: #50504A url('img/grain_dark.gif'); margin: 0 auto; width: 736px; } #layout_container {padding: 8px;} #layout_content {border: 1px solid #333;} #header_image { height: 160px; background: #222 url('img/header.gif') no-repeat; border-bottom: 1px solid #222; border-top: 1px solid #111; } /* -------------------------------- Site title ----------------------------------- */ #site_title { background: #222; padding: 12px 20px; } #site_title h1 { color: #EED; font: normal 2em Georgia,sans-serif; margin: 0 0 5px; } #site_title h2 { color: #BFBFB6; font: normal 1.1em sans-serif; margin: 0; } /* -------------------------------- Navigation ----------------------------------- */ .navigation { background: #353535 url('img/navigation.jpg') repeat-x; border-bottom: 1px solid #222; border-top: 1px solid #555; } .navigation ul {display: inline; margin: 0;} .navigation ul li { border-right: 1px solid #303030; float: left; list-style: none; } .navigation a { color: #AAA; display: block; font: bold 1em Verdana,sans-serif; padding: 12px 14px; text-decoration: none; } .navigation a:hover { background: #444; color: #E5E5D5; text-decoration: none; } .navigation li.current_page_item a { background: none; color: #EEE; } /* Sub navigation */ #subnav a { padding: 10px; font-size: 0.9em; } /* -------------------------------- Main ----------------------------------- */ #main { background: #4A4A4A; color: #CCC; } /* -------------------------------- Bottom ----------------------------------- */ #bottom { background: #222; border-bottom: 1px solid #1A1A1A; border-top: 1px solid #2A2A2A; color: #AAA; padding: 16px; } #bottom ul li { border-bottom: 1px solid #303030; } #bottom ul li a { color: #777; display: block; padding: 4px 6px; } #bottom ul li a:hover { background: #2A2A2A; color: #FFC; text-decoration: none; } /* -------------------------------- Footer ----------------------------------- */ #footer { background: #2A2A2A; border-bottom: 1px solid #1A1A1A; border-top: 1px solid #333; color: #888; font-size: 0.9em; padding: 10px 12px; } #footer a {color: #AAA;} #footer .right,#footer .right a {color: #555;} #footer a:hover {color: #BBB;} /* -------------------------------- Floats ----------------------------------- */ .left {float: left;} .right {float: right;} .clear,.clearer {clear: both;} .clearer,.block { display: block; line-height: 0; font-size: 0; } .clearer {height: 0;} /* -------------------------------- Misc ----------------------------------- */ /* Images */ img.bordered {padding: 3px; background: #666;} /* Text */ .tleft {text-align: left;} .tcenter {text-align: center;} .tcenter2 {text-align: center; font-style: italic;} .tright {text-align: right;} .vtop {vertical-align: top;} /* Label */ .label { background: #222 url('img/post_top.gif') repeat-x left top; border-bottom: 2px solid #555; color: #BBB; margin: 0; padding: 0.5em 0.8em 0.6em; } /* Margin, padding, width, height */ .ptb10 {padding: 10px 0;} /* -------------------------------- Posts ----------------------------------- */ .post { background: #363636; border-bottom: 1px solid #111; } .post_top { background: #222 url('img/post_top.gif') repeat-x left top; border-bottom: 4px solid #777; border-top: 1px solid #3A3A3A; padding: 10px 16px 13px; } .post_title h2 { font-size: 2em; margin: 0; padding: 0; } .post_body { background: url('img/post_body.jpg') no-repeat left top; border-top: 1px solid #333; padding: 16px 16px 0; } .post_metadata {padding: 10px;} .post_metadata .content { background: #424242; color: #999; font-size: 0.9em; padding: 10px 12px; } .post_metadata a {color: #BBB;} .post_metadata a:hover {color: #DDD;} .post_body ul, .post_body ol {margin: 0 0 1em 1.5em;} .post_body ul {list-style: disc;} .post_body ol {list-style: decimal;} /* ---------------------------------------- Forms ------------------------------------------- */ form {margin: 0; padding: 0;} /* Inputs */ input { background-color: #484848; color: #FFA; } select { background-color: #484848; color: #FFA; } input#s, textarea, input.styled { background: #DDD; border: 3px solid #555; font: normal 1em Verdana,sans-serif; padding: 3px; width: 160px; } textarea {width: 440px;}
-
Re: [V2] Upgraded Brothel few small little errors MrGi <?php include "globals.php"; $price = 50; //The price of the hoes $cashfh = $price * 100; //The total cash your hoes earn a day and give to you print "<h3>Brothel</h3> [i]Sign up to the brothel with your bought hoes and gain some money each day.[/i] [b]You currenltly have {$ir['totalhoes']} meaning you earn {$cashfh} a day! "; switch($_GET['action']) { case "joinconfirm": joinconfirm(); break; case "leave": leave(); break; case "buy": buy(); break; case "buyhoes": buyhoes(); break; case "buyconfirm": buyconfirm(); break; case "joinb": joinb(); break; default: index(); break; } function index() { global $db, $ir,$c,$userid,$h; print "[url='{$_SERVER[']Join brothel And Buy Hoes[/url] [url='{$_SERVER[']Buy Extra Hoes[/url] [url='{$_SERVER[']Leave and loose all your hoes[/url] "; } function joinb() { global $db, $ir,$c,$userid,$h; print "So, you would like to join the brothel and buy some hoes? It costs [b]FREE[/b] to sign up and \$5000 for each hoe. From each hoe you gain \$100 a day [b]How many hoes would you like to buy? You need 1 To Join![/b] <form action='{$_SERVER['PHP_SELF']}?action=joinconfirm' method='post'> <input type=text name=hoes> <input type=submit value=submit> </form>"; } function joinconfirm() { global $db, $ir,$c,$userid,$h; print "We have now taken your cash and you have now joined"; $db->query('UPDATE `users` SET money = money - $price WHERE userid = $userid'); $db->query('UPDATE `users` SET brotheljoin = 1 WHERE userid = $userid'); } function buy() { global $db, $ir,$c,$userid,$h; print "You can only buy one hoe a day, So would you like to buy a hoe today? [url='{$_SERVER[']Buy your hoe ($5000)[/url] "; } function buyhoes() { global $db, $ir,$c,$userid,$h; print "Buying A Hoe "; if($ir['money'] < '2000') { print "<font color=red>Error!</font> You dont have enough for the hoe you need 2000 dollars [url='index.php']Back Home[/url] "; } if($ir['money'] > '1999') { print "<font color=green>Success!</font> You buy a hoe for 2000 Dollars"; $db->query('UPDATE users SET money = money - 2000 WHERE userid = $userid'); $db->query('UPDATE users SET hoesbuy = 1 WHERE userid = $userid'); $db->query('UPDATE `users` SET money = money + totalhoes * 100 WHERE userid = $userid'); } if($ir['hoesbuy'] == 1) { print "<font color=red>Error!</font> You have already bought a hoe today!"; } } function leave() { global $db, $ir,$c,$userid,$h; print "Leaving Brothel "; if($ir['brotheljoin'] == '0') { print "<font color=red>Error!</font> You are not joined in the brothel [url='index.php']Back Home[/url] "; } if($ir['brotheljoin'] == '1') { print "<font color=green>Success!</font> You leave the brothel and you get rid of all your hoes"; $db->query('UPDATE users SET totalhoes = 0 WHERE userid = $userid'); $db->query('UPDATE users SET brotheljoin = 0 WHERE userid = $userid'); } } $h->endpage(); ?>
-
Re: [V2] Upgraded Brothel Yeah its got all the print/echo errors again. Try the one I posted, its at least got rid of that... :)
-
Re: [V2] Upgraded Brothel Well i got this much done.... <?php include "globals.php"; $price = 50; //The price of the hoes $cashfh = $price * 100; //The total cash your hoes earn a day and give to you switch($_GET['action']) { case "join": join(); break; case "joinconfirm": joinconfirm(); break; case "leave": leave(); break; case "buy": buy(); break; case "buyhoes": buyhoes(); break; case "buyconfirm": buyconfirm(); break; default: index(); break; } print "<h3>Brothel</h3> [i]Sign up to the brothel with your bought hoes and gain some money each day.[/i] [b]You currenltly have {$ir['hoes']} Meaning you earn {$cashfh} a day!"; function index() { global $db, $ir,$c,$userid,$h; print <<<EOF <a href={$_SERVER['PHP_SELF']}?action=join'>Join brothel And Buy Hoes</a> <a href={$_SERVER['PHP_SELF']}?action=buy'>Buy Extra Hoes</a> <a href={$_SERVER['PHP_SELF']}?action=leave'>Leave and loose all your hoes</a> EOF; } function join() { global $db, $ir,$c,$userid,$h; print "So, you would like to join the brothel and buy some hoes? It costs [b]FREE[/b] to sign up and $5000 for each hoe. From each hoe you gain $100 a day [b]How many hoes would you like to buy? You need 1 To Join![/b] <form action={$_SERVER['PHP_SELF']}?action=buyconfirm' method='post'> <input type=text name=hoes> <input type=submit value=submit> </form> "; } function joinconfirm() { global $db, $ir,$c,$userid,$h; echo "We have now taken your cash and you have now joined"; $db->query('UPDATE `users` SET money = money - $price WHERE userid = $userid'); $db->query('UPDATE `users` SET brotheljoin = 1 WHERE userd = $userid'); } function buy() { global $db, $ir,$c,$userid,$h; print "You can only buy one hoe a day, So would you like to buy a hoe today? <a href={$_SERVER['PHP_SELF']}?action=buyhoes'>Buy your hoe ($5000)</a> "; } function buyhoes() { global $db, $ir,$c,$userid,$h; print "Buying A Hoe "; if($ir['money'] < '2000') { print "<font color=red>Error!</font> You dont have enough for the hoe you need 2000 dollars [url='index.php']Back Home[/url] "; } if($ir['money'] > '1999') { print "<font color=green>Success!</font> You buy a hoe for 2000 Dollars"; $db->query('UPDATE users SET money = money - 2000 WHERE userid = $userid'); $db->query('UPDATE users SET hoesbuy = 1 WHERE userid = $userid'); $db->query('UPDATE `users` SET money = money + totalhoes * 100 WHERE userid = $userid'); } if($ir['hoesbuy'] == 1) { echo '<font color=red>Error!</font> You have already bought a hoe today!'; } } function leave() { global $db, $ir,$c,$userid,$h; echo "Leaving Brothel "; if($ir['brotheljoin'] == '0') { print "<font color=red>Error!</font> You are not joined in the brothel [url='index.php']Back Home[/url] "; } if($ir['brotheljoin'] == '1') { echo "<font color=green>Success!</font> You leave the brothel and you get rid of all your hoes"; $db->query('UPDATE users SET totalhoes = 0 WHERE userid = $userid'); $db->query('UPDATE users SET brotheljoin = 0 WHERE userid = $userid'); } } $h->endpage(); ?> its printing now, just getting Fatal error: Cannot redeclare join() in C:\wamp\www\SportMCC\upbrothel.php on line 51 ... now
-
Re: [V2] Upgraded Brothel Try this. <?php include "globals.php"; $price = 50; //The price of the hoes $cashfh = $price * 100; //The total cash your hoes earn a day and give to you switch($_GET['action']) { case "join": join(); break; case "joinconfirm": joinconfirm(); break; case "leave": leave(); break; case "buy": buy(); break; case "buyhoes": buyhoes(); break; case "buyconfirm": buyconfirm(); break; default: index(); break; } print "<h3>Brothel</h3> [i]Sign up to the brothel with your bought hoes and gain some money each day.[/i] [b]You currenltly have {$ir['hoes']} Meaning you earn {$cashfh} a day!"; function index() { global $db, $ir,$c,$userid,$h; echo "[url='.$_SERVER[']Join brothel And Buy Hoes[/url] [url='.$_SERVER[']Buy Extra Hoes[/url] [url='.$_SERVER[']Leave and loose all your hoes[/url] "; } function join() { global $db, $ir,$c,$userid,$h; echo "So, you would like to join the brothel and buy some hoes? It costs [b]FREE[/b] to sign up and $5000 for each hoe. From each hoe you gain $100 a day [b]How many hoes would you like to buy? You need 1 To Join![/b] <form action='.$_SERVER['PHP_SELF'].'?action=buyconfirm' method='post'> <input type=text name=hoes> <input type=submit value=submit> </form> "; } function joinconfirm() { global $db, $ir,$c,$userid,$h; echo "We have now taken your cash and you have now joined"; $db->query('UPDATE `users` SET money = money - $price WHERE userid = $userid'); $db->query('UPDATE `users` SET brotheljoin = 1 WHERE userd = $userid')"; } function buy() { global $db, $ir,$c,$userid,$h; echo 'You can only buy one hoe a day, So would you like to buy a hoe today? [url='.$_SERVER[']Buy your hoe ($5000)[/url] '; } function buyhoes() { global $db, $ir,$c,$userid,$h; echo 'Buying A Hoe "; if($ir['money'] < '2000') { echo "<font color=red>Error!</font> You dont have enough for the hoe you need 2000 dollars [url='index.php']Back Home[/url] "; } if($ir['money'] > '1999') { echo "<font color=green>Success!</font> You buy a hoe for 2000 Dollars"; $db->query('UPDATE users SET money = money - 2000 WHERE userid = $userid'); $db->query('UPDATE users SET hoesbuy = 1 WHERE userid = $userid'); $db->query('UPDATE `users` SET money = money + totalhoes * 100 WHERE userid = $userid')"; } if($ir['hoesbuy'] == 1) { echo '<font color=red>Error!</font> You have already bought a hoe today!'; } function leave() { global $db, $ir,$c,$userid,$h; echo 'Leaving Brothel "; if($ir['brotheljoin'] == '0') { echo "<font color=red>Error!</font> You are not joined in the brothel [url='index.php']Back Home[/url] "; } if($ir['brotheljoin'] == '1') { echo "<font color=green>Success!</font> You leave the brothel and you get rid of all your hoes"; $db->query('UPDATE users SET totalhoes = 0 WHERE userid = $userid'); $db->query('UPDATE users SET brotheljoin = 0 WHERE userid = $userid')"; } $h->endpage(); ?> Good job Sniko, just be careful with the echos Edited: Found more errors.
-
Re: BACKGROUND COLOR Open header.php find body { their will most likely be a background: #xxxxxx or background: url(background.gif) to change the color change that line to background: #xxxxxx ; .... -- replacing the x's with your desired color code. for a background image change that line to background: url(backgroundimageurl);
-
[mccodes v2] ingame 3 colum template modified
BlueDevil23 replied to MDK666's topic in Free Modifications
Re: [mccodes v2] ingame 3 colum template modified The same thing happened to another game, and i ended up fixing it by, going into mainmenu.php and changing the three table widths in there to 118 -
Re: [mccodesV2]main menu help No problem :)