name); $seoname = str_replace("/", "-", $seoname); $seoname = str_replace("\\", "-", $seoname); $str = TUTORIALS_SEO_DIR . $id . "/" . $seoname; return $str; } // catList([tutorial id], [category tree seperator], [drop down menu name], [selected category id]) // -------------------- // This function has 2 parts. // 1) tutorial id & category tree seperators are both set. // 2) drop down menu & selected category id are both set. // // ----- // 1) Returns a category tree list of where the tutorial belongs // with category tree seperator seperating category levels. // e.g. Photoshop [category tree seperator] Web Graphics // // 2) Returns a select drop down menu with [selected category id] // selected and on top. The name of the select is [drop down menu name]. // Each of the options' values are their respective ids. // -------------------- // Usage: // Fetches either the category tree list of a tutorial or a select form of // all the categories. // function catList($id = '', $seperator = '', $select = '', $selectid = '') { if(!$select) { $obj = sql_fetch_object("SELECT * FROM " . CATEGORIES_TABLE . " WHERE id='$id'"); if($obj->main_cat > 0) { $str = $id . "|"; $lfid = $obj->main_cat; for($i=0;$i<1;$i++) { $mobj = sql_fetch_object("SELECT * FROM " . CATEGORIES_TABLE . " WHERE id='$lfid'"); $str .= $mobj->id . "|"; if($mobj->main_cat > 0) { $i--; $lfid = $mobj->main_cat; } } $ex = explode("|", $str); $result = array_reverse($ex); for($x=1;$x" . htmlspecialchars($cobj->name) . ""; if($x+1 < count($result)) { $string .= $seperator; } } } else { $string = "" . htmlspecialchars($obj->name) . ""; } return $string; } else { $string = ""; return $string; } } //********************************************************************************* // listTutorials($perpage, $limit, $orderby, $sort, $catid) // ========================================= // OVERVIEW: // This is the main function of the site. This parses tutorials from the database // in a simple list form. // ========================================= // if $perpage is set, $limit must be bool FALSE. // if $limit is set, $perpage must be bool FALSE. // // if this function is called with conflicting arguments, // this function will PARSE an error message and return FALSE // --------------------- // if $perpage is an INTEGER greater than 0, the function // uses the result_set class to fetch tutorials and PARSES // tutorials (directly from function) 10 per page, with // a pagination navigation as well (all from class result_set) // ---------------------- // if $limit is an INTEGER greater than 0, the function will // simply PARSE $limit number of tutorials ordered by $orderby. // There will only be one page, and no pagination. // // if $catid (OPTIONAL INT) is set, this function will ONLY display tutorials // for that certain category and NOT THE TUTORIALS IN THAT CATEGORY'S // SUBCATEGORIES. // ========================================= // In either case ($perpage OR $limit), a text will be parsed // stating the amount of tutorials displayed using $sort; // unless $sort is a bool FALSE. // // It is worth noting that this function also starts with //
// as a padding to keep the tutorial list seperated from other content. //********************************************************************************* function listTutorials($perpage, $limit, $orderby, $sort='', $catid='') { global $HTTP_GET_VARS; if( (is_numeric($perpage) && is_numeric($limit)) || (!is_numeric($perpage) && !is_numeric($limit)) ) { ?> listTutorials() error [functions.php]: $limit and $perpage cannot be set together, nor can they both not be set. $limit must be numeric while $perpage is bool FALSE, or vice versa. listTutorials() error [functions.php]: $orderby is a REQUIRED argument for listTutorials()
Displaying results per page sorted .
fetch_array() : mysql_fetch_array($result))) { $i++; $num = numcode($i); ?>
" . $result->pagination($HTTP_GET_VARS) . "
"; } ?>
563) { $string = "\"\""; return $string; } else { $string = "\"\""; return $string; } } // tut_manipulate() // manipulates the tutorial and returns the tutorial in html form. function tut_manipulate($tutorial) { // get rid of slashes $tutorial = stripslashes($tutorial); // replace STEP x with XHTML $tutorial = preg_replace("/===STEP (.*?)===/", "
Step $1
", $tutorial); // replace COMPLETED with XHTML $tutorial = str_replace("===COMPLETED===", "
Completed
", $tutorial); // CODES ---------------------------------------------------- // image code $tutorial = preg_replace("#\[\[\[IMG:(.*?)\]\]\]#e", "fetchImg($_GET[id], '\$1')", $tutorial); // code .. code $tutorial = preg_replace("#\[code\](.*?)\[\/code\]#sie", "'
' . highlight_string(trim(stripslashes('$1')), true) . '
'", $tutorial); // php.net link $tutorial = preg_replace("#\[=\[(.*?)\]=\]#", "$1", $tutorial); $tutorial = nl2br($tutorial); return $tutorial; } // ddate() // manipulates the date // --- // NOTE: at the moment, there is no real need for this function. However, // in the case that the server time differs from the preferred time, or if // in the future, specific date preferences are added, this function would be // extremely useful as every date format in the site uses this function as // opposed to PHP's default date(); function ddate($date_format, $unix_timestamp) { $date = date($date_format, $unix_timestamp+3600); return $date; } // email() // sends an email with certain preferences function email($to, $name, $from, $subject, $message, $header='', $footer='') { if(!isset($header)) { $header = str_replace("[n]", $name, DEFAULT_MAIL_HEADER); } if(!isset($footer)) { $footer = str_replace("[n]", $name, DEFAULT_MAIL_FOOTER); } $str = $header . $message . $footer; mail($to, $subject, $str, "From: " . $from); } // getContent() // function getContent($path, $field='') { if(sql_num_rows("SELECT * FROM " . PAGES_TABLE . " WHERE file='$path'") > 0) { $obj = sql_fetch_object("SELECT * FROM " . PAGES_TABLE . " WHERE file='$path'"); if($field == "") { $head = (!empty($obj->title) ? "" . $obj->title . "

" : ""); return $head . nl2br($obj->content); } elseif($field == "obj") { return $obj; } else { return nl2br($obj->$field); } } else { return false; } } ?>