Close Panel
Hello Guest! | Log In


lheader.gif rheader.gif
tgcontentlogo.gif
tgcontentlogob.gif
Posted by err0r on June 23rd, 2008

I use the database to present some pages because it’s just easier to deal with. At one time I was using a Mod for Invision Power Boards to add simple pages to present info on various IRC information. I really wasn’t happy with how it worked and rather than edit something that could break again in future forum updates I decided to make my own system.

Each page has a link that only the admin can see that allows you to pop up a window in which you can edit the page’s html coding. I only use this method for a few information pages that do not require extra php coding.

Features:

  1. Quick launch link directly from the page you want to edit.
  2. Auto insertion of links to menu on creation
  3. Alert popup to ensure you really meant to update the page.
  4. Ability to delete the page
  5. On submit the window refreshes the information and the page refreshes as well.

Here is what the process looks like

TG Page Editor


Posted by err0r on June 19th, 2008

TG Tooltip

Curious about TG’s popup tool tip info? This is how we do it. This is a JS code from one of our favorite sites Dynamic Drive. Of course we have edited to better suit our look and needs. Here is the breakdown.

Put this in the <head> section or in your css file

<!–
#dhtmltooltip{
position: absolute;
width: 150px;
border: 2px solid black;
padding: 2px;
background-color: lightyellow;
visibility: hidden;
z-index: 100;
/*Remove below line to remove shadow. Below line should always appear last within this CSS*/
filter: progid :D XImageTransform.Microsoft.Shadow(color=gray,direction=135);
}>;

Now for the Javascript and related coding. Place this somewhere in the body outside of any relative or absolute tags.

<script type="text/javascript"><!–
/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}
function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
//if the horizontal distance isn’t enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it’s width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"
//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}
function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=
tipobj.style.width=
}
}
document.onmousemove=positiontip
// –></script>

Now just edit your link with the following information.

onMouseover="ddrivetip(‘JavaScriptKit.com JavaScript tutorials’,'yellow’, 300)";
onMouseout="hideddrivetip()"

This is the breakdown of how the code works

ddrivetip(‘TEXT TO DISPLAY’, ‘OPTIONAL BACKGROUND COLOR’, OPTIONAL TIP WIDTH)

Here are some examples of using the code in the links

<a onmouseover="ddrivetip(‘Visit Yahoo.com’)" href="http://www.yahoo.com">
</a> onMouseout="hideddrivetip()"&gt;Search Engine
<div onmouseover="ddrivetip(‘This DIV has a tip!’, ‘#EFEFEF’)">
onMouseout="hideddrivetip()"&gt;Some text here. Some text here.</div>
<a onmouseover="ddrivetip(‘Yahoo\’s Site’, ‘yellow’, 250)" href="http://yahoo.com">
</a> onMouseout="hideddrivetip()"&gt;Yahoo

This is a very helpful and attractive addon for your site. Be sure to leave in the credit for dynamic drive and check out the actual full page devoted to the addon HERE.


Posted by err0r on June 9th, 2008

I ran across this function to delete a file from the server if it exists some time ago. It has been very useful to me.

<?php
$DelFilePath = "/home/path/to/file";
if (file_exists($DelFilePath))  {
unlink($DelFilePath);
}
?>

Posted by err0r on June 9th, 2008

There are many ways to get the file extension of a file. Here is an example of a php function I found to do just that.

<?php
function file_extension($fname)
{
$path_info = pathinfo($fname);
return $path_info[‘extension’];
}
?>

Another way would be to check the actual string and use what’s after the last slash. I picked this up on a forum I visit.

<?php
$filetype = substr($file, strrpos($file, ‘.’) + 1);
?>




lhfooter.gif
Valid XHTML 1.0 | Valid CSS | Load Time: 0.460189 sec(s)
rfooter.gif