http://www.burg.rauchfusz.de < > icedogg211@aol.com # # Joss Sanglier http://www.ancingbear.co.uk joss@dancingbear.co.uk # # Bot Support in Recipe Contents # # # # License : @license http://www.gnu.org/copyleft/gpl.html GNU/GPL # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # ################################################################################# # Don't allow direct linking defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); # Variables - Don't change anything here!!! require($mosConfig_absolute_path."/administrator/components/com_garyscookbook/config.garyscookbook.php"); require_once( "$mosConfig_absolute_path/administrator/includes/pcl/pclzip.lib.php" ); $temppath = $mosConfig_live_site."/media/"; $picturepath = $mosConfig_live_site.$ag_pathimages."/"; $thumbnailpath = $mosConfig_live_site.$ag_paththumbs."/"; $cookbookversion = "Gary´s Cookbook 2.3.2 by Gerald Berger"; # Check for Editor rights if($my->usertype == 'Editor' || $my->usertype == 'Administrator' || $my->usertype == 'Super Administrator' ) { $is_editor = true; $is_registered = true; $is_author = true; } else { if($my->usertype == 'Author' || $my->usertype == 'Editor' || $my->usertype == 'Administrator' || $my->usertype == 'Super Administrator' ) { $is_registered = true; $is_author = true; $is_editor = false; } else { if($my->usertype == 'Author' || $my->usertype == 'Registered' || $my->usertype == 'Editor' || $my->usertype == 'Administrator' || $my->usertype == 'Super Administrator' ) { $is_registered = true; $is_author = false; $is_editor = false; }else{ $is_author = false; $is_editor = false; $is_registered = false; } } } $is_user = (strtolower($my->usertype) <> ''); // CHECK LANGUAGE if (!defined( '_garyscookbook_LANG_INCLUDED' )) { if (file_exists($mosConfig_absolute_path."/administrator/components/com_garyscookbook/language/".$mosConfig_lang.".php") ) { include_once($mosConfig_absolute_path."/administrator/components/com_garyscookbook/language/".$mosConfig_lang.".php"); } else { include_once($mosConfig_absolute_path."/administrator/components/com_garyscookbook/language/english.php"); } } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function editcookbook( $option, &$row, &$clist, &$imagelist, &$thumblist, $ag_pathimages, $ag_paththumbs, $ag_upload ) { global $mosConfig_live_site,$cookbookversion; ?> "; echo ""; echo ""; } ?>
:
" ._garyscookbook_PICUPLOAD.":"; echo "
"; echo "
:
: imgtext , 'imgtext', 500, 200, '50', '100' ); ?>
: grapes , 'grapes', 500, 200, '50', '100' ); ?>
: properties , 'properties', 500, 300, '50', '100' ); ?>
: notes , 'notes', 500, 150, '50', '100' ); ?>
:
: portion ); echo $selist_ag_showportion; ?>
: aging ); echo $selist_ag_showdifficul; ?>
: years ); echo $selist_ag_showtime; ?>
:
:
: doc ); echo $yn_ag_showdetail; ?>
   
 
setQuery("SELECT * FROM #__categories WHERE id = '".$id." ORDER BY name'"); $rows2 = $database->loadObjectList(); $row2 = $rows2[0]; echo "
"; if ($row2->image <> "") { if ($ag_catTumb) { echo ""; }else{ echo ""; } } echo "

$row2->title

"; echo $row2->description; echo "
"; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function cookbookHeader($addOnOff) { global $func, $database, $id, $Itemid, $catid, $is_editor, $is_author, $is_registered, $ag_showrating, $ag_regonly, $ag_offlinecookbook, $ag_offlinemsg , $ag_showcomment,$ag_postnewcookbook, $ag_editorpostnewcookbook, $mosConfig_live_site, $ag_pic_path, $ag_introtext; echo ""; if ($ag_pic_path) { echo ""; }else { echo ""; } # ""; if ($addOnOff) { echo ""; } echo "
"._garyscookbook_TITLE."
"; echo ""; echo ""; echo ""; echo "
"; if ($func <> 'detail') { echo ShowCategoryPathLink($id); } else if ($id) { $database->setQuery( "SELECT a.*, cc.title AS category" . "\nFROM #__garyscookbook AS a, #__categories AS cc" . "\nWHERE a.catid=cc.id AND a.id=$id" ); $rows = $database->loadObjectList(); $row = &$rows[0]; echo ShowCategoryPathLink($row->catid); } echo ""; echo "
"; echo ""; echo ""; echo "
"; echo "
"; echo "

".stripslashes($ag_introtext)."

"; echo "
"; echo ""._garyscookbook_MOST_VIEWED.""; if ($ag_showrating) echo " - "._garyscookbook_TOP_RATED.""; echo " - "._garyscookbook_LAST_ADDED.""; if ($ag_showcomment) echo " - "._garyscookbook_LAST_COMMENTED.""; echo "
"; echo "
"; if ($ag_postnewcookbook == '1') { #Editor if (($ag_editorpostnewcookbook == '3' && $is_editor)) { echo " "._garyscookbook_ADD_cookbook.""._garyscookbook_ADD_cookbook.""; }else{ if (($ag_editorpostnewcookbook == '2' && $is_registered)) { echo " "._garyscookbook_ADD_cookbook.""._garyscookbook_ADD_cookbook.""; }else{ if (($ag_editorpostnewcookbook == '1' && $is_author)) { echo " "._garyscookbook_ADD_cookbook.""._garyscookbook_ADD_cookbook.""; }else{ if (($ag_editorpostnewcookbook == '0')) { echo " "._garyscookbook_ADD_cookbook.""._garyscookbook_ADD_cookbook.""; } } } } } echo "
"; echo "
"; return; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function functionheader() { global $func, $database, $id, $Itemid, $catid, $is_editor, $ag_showrating, $ag_regonly, $ag_offlinecookbook, $ag_offlinemsg , $ag_showcomment,$ag_postnewcookbook, $ag_editorpostnewcookbook, $mosConfig_live_site, $ag_pic_path; echo ""; echo ""; #echo "
"._garyscookbook_TITLE."
"; echo ""; echo ""; echo ""; echo "
"; echo ""; #echo "
"; echo "
"; return; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function savePost() { global $database, $my, $fromUser, $is_editor, $screenshot_name; include('administrator/components/com_garyscookbook/class.garyscookbook.php'); include('administrator/components/com_garyscookbook/config.garyscookbook.php'); $newcookbook = new mosgaryscookbook($database); $newcookbook->price = mosGetParam( $_POST, "price", $newcookbook->price ); $newcookbook->imgtitle = mosGetParam( $_POST, "imgtitle", $newcookbook->imgtitle ); $newcookbook->catid = mosGetParam( $_POST, "catid", $newcookbook->catid ); $newcookbook->imgtext = mosGetParam( $_POST, "imgtext", $newcookbook->imgtext, 0x0003 ); $newcookbook->grapes = mosGetParam( $_POST, "grapes", $newcookbook->grapes, 0x0003 ); $newcookbook->properties = mosGetParam( $_POST, "properties", $newcookbook->properties, 0x0003 ); $newcookbook->notes = mosGetParam( $_POST, "notes", $newcookbook->notes ); $newcookbook->imgauthor = mosGetParam( $_POST, "imgauthor", $newcookbook->imgauthor ); $newcookbook->imgdate = mktime(); $newcookbook->imgfilename = $screenshot_name; $newcookbook->imgthumbname = tn_.$screenshot_name; $newcookbook->portion = mosGetParam( $_POST, "portion", $newcookbook->portion ); $newcookbook->aging = mosGetParam( $_POST, "aging", $newcookbook->aging ); $newcookbook->years = mosGetParam( $_POST, "years", $newcookbook->years ); $newcookbook->country = mosGetParam( $_POST, "country", $newcookbook->country ); $newcookbook->doc = mosGetParam( $_POST, "doc", $newcookbook->doc ); $newcookbook->published = 0; if($is_editor) { $newcookbook->published = 1; } #DATA VALIDATION if ($newcookbook->imgtitle==null || $newcookbook->imgtitle=="" || $newcookbook->catid <=0) { echo "\n"; exit(); } if (!$newcookbook->store()) { echo "\n"; exit(); } if($is_editor) { echo "

"._garyscookbook_ADD_SUCCESS_EDITOR."
"; echo ""._garyscookbook_Back."
"; } else { echo "

"._garyscookbook_ADD_SUCCESS."

"; echo ""._garyscookbook_Back."
"; } // messaging for new items to administrators require_once( "components/com_messages/messages.class.php" ); $msg = new mosMessage( $database ); $database->setQuery( "SELECT id FROM #__users WHERE sendEmail='1'" ); $users = $database->loadResultArray(); foreach ($users as $user_id) { if($my->id>0) { $msg->send( $my->id, $user_id, "New recipe in cookbook FROM ".$my->username, sprintf( "New recipe:".$newcookbook->imgtitle." FROM ". $my->username, $my->username, $newcookbook->imgtitle ) ); } else //messaggio da anonimo (utente non registrato) { $msg->send( $user_id, $user_id, "New recipe in cookbook FROM Anonymous", sprintf( "New recipe:".$newcookbook->imgtitle." FROM Anonymous", $my->username, $newcookbook->imgtitle ) ); } } if($ag_sendEmail>0 && $ag_sendEmailAddress<>"" && $ag_sendEmailAddress<>null) { if($my->id>0) { $fromUser=$my->username; } else //messaggio da anonimo (utente non registrato) { $fromUser="Anonymous"; } $subject = _garyscookbook_ADD_SUBJECT . $fromUser; $message = _garyscookbook_ADD_MESSAGE. $newcookbook->imgtitle ."\r \n"; $message .= _garyscookbook_ADD_MESSAGE2; $headers = "From: $ag_sendEmailAddress\r\n"; $headers .= "Reply-To: $ag_sendEmailAddress\r\n"; $headers .= "X-Priority: 3\r\n"; $headers .= "X-MSMail-Priority: Low\r\n"; $headers .= "X-Mailer: Mambo Open Source 4.5\r\n"; mail( $ag_sendEmailAddress, $subject, $message, $headers ); } } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function cookbookFooter() { global $cookbookversion,$is_editor,$id,$cookbook_showlogo,$showedit, $Itemid; echo " "; if ($is_editor) { if ($id) { if ($showedit) { echo ""; } } } echo " "; #show/hide cookbook logo if($cookbook_showlogo) { echo ""; echo " "; echo ""; } else { echo "
"; } echo " "; echo " "; echo " "; echo " "; echo ""; echo "
"._garyscookbook_EDIT_RECIPE."

 

 

 

"; return; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function bb_decode($text) { $text = nl2br($text); static $bbcode_tpl = array(); static $patterns = array(); static $replacements = array(); // First: If there isn't a "[" and a "]" in the message, don't bother. if ((strpos($text, "[") === false || strpos($text, "]") === false)) { return $text; } // [b] and [/b] for bolding text. $text = str_replace("[b]", '', $text); $text = str_replace("[/b]", '', $text); // [u] and [/u] for underlining text. $text = str_replace("[u]", '', $text); $text = str_replace("[/u]", '', $text); // [i] and [/i] for italicizing text. $text = str_replace("[i]", '', $text); $text = str_replace("[/i]", '', $text); if (!count($bbcode_tpl)) { // We do URLs in several different ways.. $bbcode_tpl['url'] = '{DESCRIPTION}'; $bbcode_tpl['email']= '{EMAIL}'; $bbcode_tpl['url1'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']); $bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1\\2', $bbcode_tpl['url1']); $bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); $bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']); $bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']); $bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']); $bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']); $bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); // [url]xxxx://www.phpbb.com[/url] code.. $patterns[1] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si"; $replacements[1] = $bbcode_tpl['url1']; // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix). $patterns[2] = "#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si"; $replacements[2] = $bbcode_tpl['url2']; // [url=xxxx://www.phpbb.com]phpBB[/url] code.. $patterns[3] = "#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si"; $replacements[3] = $bbcode_tpl['url3']; // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix). $patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si"; $replacements[4] = $bbcode_tpl['url4']; // [email]user@domain.tld[/email] code.. $patterns[5] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si"; $replacements[5] = $bbcode_tpl['email']; } $text = preg_replace($patterns, $replacements, $text); return $text; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### /** * Mailfunktionen * Shows the email form for a given content item. */ function emailContentForm( $uid ) { global $database, $mainframe, $my; # Database Query $imgtitle=''; $database->setQuery( "SELECT imgtitle FROM #__garyscookbook WHERE id = '" .$uid. "'" ); $imgtitle = $database->loadResult(); if ( id === null ) { mosNotAuth(); return; } else { $template=''; $database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id = '0' AND menuid = '0'" ); $template = $database->loadResult(); emailForm( $uid, $imgtitle, $template ); } } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### /** * Writes Email form for filling in the send destination */ function emailForm( $uid, $title, $template='' ) { global $mosConfig_sitename; ?> <?php echo $title; ?>
 
 
  
getItemid( $uid, 0, 0 ); $email = trim( mosGetParam( $_POST, 'email', '' ) ); $yourname = trim( mosGetParam( $_POST, 'yourname', '' ) ); $youremail = trim( mosGetParam( $_POST, 'youremail', '' ) ); $subject_default = _EMAIL_INFO ." $yourname"; $subject = trim( mosGetParam( $_POST, 'subject', $subject_default ) ); if ( !$email || !$youremail || ( is_email( $email ) == false ) || ( is_email( $youremail ) == false ) ) { echo ""; exit(0); } $template=''; $database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'" ); $template = $database->loadResult(); // link sent in email $link = sefRelToAbs( $mosConfig_live_site .'/index.php?option=com_garyscookbook&Itemid='. $_Itemid.'&func=detail&id='.$uid ); // message text $msg = sprintf( _garyscookbook_EMAIL_MSG, $mosConfig_sitename, $yourname, $youremail, $link ); // mail function mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $subject, $msg ); emailSent( $email, $template ); } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### #emailcheck function is_email( $email ){ $rBool = false; if ( preg_match( "/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email ) ) { $rBool = true; } return $rBool; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function emailSent( $to, $template='' ) { global $mosConfig_sitename; ?> <?php echo $mosConfig_sitename; ?>


setQuery($query); $result = $database->query(); $total = mysql_num_rows($result); // put them in queue $j = 0; while ( $j < $total ) { $val = mysql_fetch_row( $result ); $queue[] = $val[0]; $j++; } } reset( $queue ); $query="SELECT count(id) as count FROM #__garyscookbook WHERE (0 != 0"; while ( list( $key, $cat )=each( $queue ) ) { $query .= " OR catid = $cat"; } $query .= ") AND published=1"; $database->setQuery( $query ); $result = $database->query(); $val = mysql_fetch_row($result); return $val[0]; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function ShowCategoryPathLink($cat) { global $database, $mosConfig_lang, $gid, $Itemid; $cat=intval( $cat ); $par_id=1000; while ( $par_id ) { $query="SELECT * FROM #__categories WHERE id=$cat AND published = 1 AND access <= '$gid'"; $database->setQuery( $query ); $result=$database->query(); $par_id = @mysql_result( $result, 0, 'parent_id' ); $cid = @mysql_result( $result, 0, 'id' ); $name="" . @mysql_result( $result,0,'name' ) . ""; // write path if ( empty( $path ) ) { $path = $name; } else { $path = $name . '' . $path; } // next looping $cat=$par_id; } $home="". _garyscookbook_CATEGORIES. ""; $pathName=$home . ' ' . $path . " "; return $pathName; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function ShowCategoryPath ( $cat ) { global $database, $mosConfig_lang, $gid; $cat=intval($cat); $parent_id = 1000; while ($parent_id) { // read name and parent_id $query = "SELECT * FROM #__categories WHERE id=$cat AND access <= '$gid'"; $database->setQuery( $query ); $result=$database->query(); $parent_id = @mysql_result($result, 0, 'parent'); $name = @mysql_result($result, 0, 'name'); // write path if (empty($path)) { $path = $name; } else { $path = $name . ' » ' . $path; } // next looping $cat = $parent_id; } return $path . ' '; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function parentcat($id, $Itemid) { global $database, $func, $gid, $ag_rmsm, $ag_collist, $output; $database->setQuery("SELECT d.* FROM #__categories AS d WHERE d.parent_id=$id and d.published=1 ORDER BY d.ordering"); $rows = $database->loadObjectList(); $num_rows = ceil(count($rows ) / $ag_collist ); $index=0; #Subcategories are only shows if exists if ($num_rows > 0) { $output.=''; $output.=''; $output .=''; for ( $row_count=0; $row_count < $num_rows; $row_count++ ) { $output .= ''; for ($col_count = 0; $col_count < $ag_collist; $col_count++) { $output.=''; } $output .= '
'; $output.= "" . _gkb_Down_Cat; $output.= '
'; $cur_name=$rows[$index]; if ( $cur_name == '' ) { $output .= ' '; } else { if (GetNumberOfLinks($rows->id)==1) { $insertbez = _garyscookbook_ADMIN_PICTURE; } else { $insertbez = _gkb_Cat_Recipes ; } $output.= 'id" ) . '">' . $cur_name->name . ' (' . GetNumberOfLinks( $cur_name->id ) . " " . $insertbez . ')'; $output.= substr($cur_name->description, 0, $ag_catlength); if ( $ag_rmsm > 0) { if ( $cur_name->access > 1 ) { $output .=' [SM]'; } else if ($cur_name->access > 0) { $output .= ' [RM]'; } } } $index++; $output .= '
'; } $output .= '
'; return $output; } } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function showOfflineMsg(){ global $ag_offlinemsg; echo ""; echo ""; echo "
"._garyscookbook_TITLE."
"; echo ""; echo ""; echo "
"; echo ""; echo ""; echo "
 

".$ag_offlinemsg."

"; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function showNoAccess(){ echo ""; echo ""; echo "
"._garyscookbook_TITLE."
"; echo ""; echo ""; echo "
"; echo ""; echo ""; echo ""; echo "
 

"._garyscookbook_UNAUTHORIZIED."

"._garyscookbook_UNAUTHORIZIED2."
"; } ### NEW Function #### NEW Function ### NEW Function ### NEW Function ### NEW Function ### NEW Function ### function resize_image($src_file, $dest_file, $new_size, $method, $dest_qual) { $imagetype = array( 1 => 'GIF', 2 => 'JPG', 3 => 'PNG', 4 => 'SWF', 5 => 'PSD', 6 => 'BMP', 7 => 'TIFF', 8 => 'TIFF', 9 => 'JPC', 10 => 'JP2', 11 => 'JPX', 12 => 'JB2', 13 => 'SWC', 14 => 'IFF'); $imginfo = getimagesize($src_file); # echo "\n"; if ($imginfo == null) { #falsche Datei löschen unlink($src_file); echo "\n"; die("ERROR: Source file not found or no Picture!"); } $imginfo[2] = $imagetype[$imginfo[2]]; // GD can only handle JPG & PNG images if ($imginfo[2] != 'JPG' && $imginfo[2] != 'PNG' && $imginfo[2] != 'GIF' && ($method == 'gd1' || $method == 'gd2')) die("ERROR: GD can only handle JPG and PNG files!"); // height/width $srcWidth = $imginfo[0]; $srcHeight = $imginfo[1]; echo "Creating thumbnail from $imginfo[2], $imginfo[0] x $imginfo[1]...
"; $ratio = max($srcWidth, $srcHeight) / $new_size; $ratio = max($ratio, 1.0); $destWidth = (int)($srcWidth / $ratio); $destHeight = (int)($srcHeight / $ratio); // Method for thumbnails creation switch ($method) { case "gd1" : if (!function_exists('imagecreatefromjpeg')) { die('GD image library not installed!'); } if ($imginfo[2] == 'JPG') $src_img = imagecreatefromjpeg($src_file); else if ($imginfo[2] == 'PNG') $src_img = imagecreatefrompng($src_file); else $src_img = imagecreatefromgif($src_file); if (!$src_img){ $ERROR = $lang_errors['invalid_image']; return false; } $dst_img = imagecreate($destWidth, $destHeight); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight); imagejpeg($dst_img, $dest_file, $dest_qual); imagedestroy($src_img); imagedestroy($dst_img); break; case "gd2" : if (!function_exists('imagecreatefromjpeg')) { die('GD image library not installed!'); } if (!function_exists('imagecreatetruecolor')) { die('GD2 image library does not support truecolor thumbnailing!'); } if ($imginfo[2] == 'JPG'){ $src_img = imagecreatefromjpeg($src_file);} else if ($imginfo[2] == 'PNG'){ $src_img = imagecreatefrompng($src_file);} else { $src_img = imagecreatefromgif($src_file);} if (!$src_img){ $ERROR = $lang_errors['invalid_image']; return false; } $dst_img = imagecreatetruecolor($destWidth, $destHeight); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight); imagejpeg($dst_img, $dest_file, $dest_qual); imagedestroy($src_img); imagedestroy($dst_img); break; } // Set mode of uploaded picture chmod($dest_file, octdec('755')); // We check that the image is valid $imginfo = getimagesize($dest_file); if ($imginfo == null){ return false; } else { return true; } } ### END Functions #### END Functions ### END Functions ### END Functions ### END Functions ### END Functions ### function exportRecipe($uid){ global $database; global $mosConfig_db, $mosConfig_sitename, $version,$option,$task,$mosConfig_dbprefix,$id, $thumbnailpath, $picturepath, $temppath,$mosConfig_absolute_path, $ag_pathimages, $ag_makeMM_pic; $query1="SELECT id, catid, imgtitle, imgauthor, imgtext, imgdate, imgcounter, imgvotes, imgvotesum, published, imgfilename, imgthumbname, doc, price, country, portion, aging, years, grapes, properties, notes FROM ".$mosConfig_dbprefix."garyscookbook WHERE id = '$uid'"; $result1=mysql_query($query1); list($id, $catid, $imgtitle, $imgauthor, $imgtext, $imgdate, $imgcounter, $imgvotes, $imgvotesum, $published, $imgfilename, $imgthumbname, $doc, $price, $country, $portion, $aging, $years, $grapes, $properties, $notes)=mysql_fetch_row($result1); //feststellen welcher Browser verwendet wird if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $UserAgent)) { $UserBrowser = "Opera"; } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $UserAgent)) { $UserBrowser = "IE"; } else { $UserBrowser = ''; } $filename = ereg_replace("[[:punct:]]","" ,$imgtitle ); $filename .= "_" . date("jmYHis") . ".gkb"; $filename = str_replace(" ","_" ,$filename ); $filename = str_replace("Ä","Ae" ,$filename ); $filename = str_replace("ä","ae" ,$filename ); $filename = str_replace("Ö","Oe" ,$filename ); $filename = str_replace("ö","oe" ,$filename ); $filename = str_replace("Ü","Ue" ,$filename ); $filename = str_replace("ü","ue" ,$filename ); $filename = str_replace("ß","ss" ,$filename ); $mime_type = 'application/x-zip'; /* Store the "Create Tables" SQL in variable $CreateTable[$tblval] */ $tblval = $mosConfig_dbprefix; $tblval .= "garyscookbook"; $database->setQuery("SHOW CREATE table $tblval"); $database->query(); $CreateTable[$tblval] = $database->loadResultArray(1); $opFile = $mosConfig_absolute_path. $ag_pathimages ."/". $imgfilename; if ($ag_makeMM_pic) { #'Hier muß noch das Bild eingefügt werden wenn vorhanden' if (file_exists($opFile)) { $fp = fopen($opFile , "r"); $bindata = fread($fp,filesize ($opFile)); $PictureImportname = "GKB_".date("jmYHis").$imgfilename; fclose($fp); } } #Kopf erzeugen $OutBuffer = ""; $OutBuffer .= "#\n"; $OutBuffer .= "# Garyscookbook Recipe Export\n"; $OutBuffer .= "# http://www.vb-dozent.net\n"; $OutBuffer .= "#\n"; $OutBuffer .= "# Host: $mosConfig_sitename\n"; $OutBuffer .= "# Generation Time: " . date("M j, Y \a\\t H:i") . "\n"; $OutBuffer .= "# Server version: " . $database->getVersion() . "\n"; $OutBuffer .= "# PHP Version: " . phpversion() . "\n"; $OutBuffer .= "# Included Files: " . $PictureImportname . "\n"; $OutBuffer .= "# Database : `" . $mosConfig_db . "`\n# --------------------------------------------------------\n"; $pictime = mktime(); if ($ag_makeMM_pic) { #Benötigte Felder festlegen $myfields = "`catid`, `imgdate`, `imgfilename`, `imgthumbname`, `imgtitle`, `imgauthor`, `imgtext`, `doc`, `price`, `country`,`portion`,`aging`,`years`,`grapes`,`properties`,`notes`"; $database->setQuery("SELECT `imgtitle`, `imgauthor`, `imgtext`, `doc`, `price`, `country`,`portion`,`aging`,`years`,`grapes`,`properties`,`notes` FROM ".$mosConfig_dbprefix."garyscookbook WHERE id='$uid'"); }else{ #Benötigte Felder festlegen $myfields = "`catid`, `imgdate`, `imgtitle`, `imgauthor`, `imgtext`, `doc`, `price`, `country`,`portion`,`aging`,`years`,`grapes`,`properties`,`notes`"; $database->setQuery("SELECT `imgtitle`, `imgauthor`, `imgtext`, `doc`, `price`, `country`,`portion`,`aging`,`years`,`grapes`,`properties`,`notes` FROM ".$mosConfig_dbprefix."garyscookbook WHERE id='$uid'"); } $rows = $database->loadObjectList(); if ($ag_makeMM_pic) { $InsertDump = "INSERT INTO $tblval ( $myfields ) VALUES ( '****' , '" .$pictime. "'," . "'" . $PictureImportname . "', 'tn_" . $PictureImportname . "',"; }else{ $InsertDump = "INSERT INTO $tblval ( $myfields ) VALUES ( '****' , '" .$pictime. "',"; } foreach($rows as $row) { $arr = mosObjectToArray($row); foreach($arr as $key => $value) { $value = addslashes( $value ); $value = str_replace( "\n", '\r\n', $value ); $value = str_replace( "\r", '', $value ); if (preg_match ("/\b" . $FieldType[$tblval][$key] . "\b/i", "DATE TIME DATETIME CHAR VARCHAR TEXT TINYTEXT MEDIUMTEXT LONGTEXT BLOB TINYBLOB MEDIUMBLOB LONGBLOB ENUM SET")) { $InsertDump .= "'$value',"; } else { $InsertDump .= "$value,"; } } } $OutBuffer .= rtrim($InsertDump,',') . ");\n"; // dump anything in the buffer @ob_end_clean(); ob_start(); header('Content-Type: ' . $mime_type); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); if ($UserBrowser == 'IE') { header('Content-Disposition: inline; filename="' . $filename . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Pragma: no-cache'); } if (function_exists('gzcompress')) { include "administrator/includes/pcl/zip.lib.php"; $zipfile = new zipfile(); $zipfile -> addFile($OutBuffer, $filename . ".sql"); if ($ag_makeMM_pic) { #'Hier muß noch das Bild eingefügt werden wenn vorhanden' $zipfile -> addFile($bindata, $PictureImportname); } echo $zipfile->file(); ob_end_flush(); ob_start(); } // do no more exit(); break; } ### END Functions #### END Functions ### END Functions ### END Functions ### END Functions ### END Functions ### function showGKBAdminMessage($message,$title,$option,$task) { global $PHP_SELF; ?>
setQuery( "SELECT id AS value, title AS text FROM #__categories" . "\nWHERE section='com_garyscookbook' ORDER BY ordering" ); $categories = array_merge( $categories, $database->loadObjectList() ); $clist = mosHTML::selectList( $categories, 'catid', 'class="inputbox" size="1"', 'value', 'text', $id ); editcookbook($option,$row, $clist, $imagelist, $thumblist,$ag_pathimages, $ag_paththumbs, $ag_upload); } else { echo ""; echo ""; echo "
"._garyscookbook_CANNOT_ADD."
"; } break; case 'save': $screenshot = (isset($_FILES['screenshot']['tmp_name']) ? $_FILES['screenshot']['tmp_name'] : ""); $screenshot_name = (isset($_FILES['screenshot']['name']) ? $_FILES['screenshot']['name'] : ""); cookbookHeader(0); if (strlen($screenshot) > 0 and $screenshot != "none"){ #echo "\n"; if (move_uploaded_file($screenshot, $mosConfig_absolute_path.$ag_pathimages."/$screenshot_name")) { resize_image($mosConfig_absolute_path.$ag_pathimages."/$screenshot_name", $mosConfig_absolute_path.$ag_pathimages."/$screenshot_name", "$ag_picturewidth", "$ag_thumbcreation", "$ag_picturequality"); #echo "\n"; resize_image($mosConfig_absolute_path.$ag_pathimages."/$screenshot_name", $mosConfig_absolute_path.$ag_paththumbs."/tn_$screenshot_name", "$ag_thumbwidth", "$ag_thumbcreation", "$ag_thumbquality"); } } savePost(); break; case 'viewcategory': if ($ag_regonly && !$my->id) { showNoAccess(); break; } else if ($ag_offlinecookbook && !$is_admin) { showOfflineMsg(); break; } cookbookHeader(0); if ($ag_subcatleft) { echo ""; echo ""; echo ""; echo "
"; echo catdescription( $id ); echo ""; echo parentcat( $id, $Itemid ); echo "
"; }else { echo parentcat( $id, $Itemid ); } $database->setQuery("SELECT count(id) FROM #__categories WHERE id = '$id' AND access <= '$gid'"); $is_allowed = $database->loadResult(); # Feststellen der Anzahl der verfügbaren Datensätze $database->setQuery("SELECT count(id) FROM #__garyscookbook WHERE published = '1' AND catid = '".$id."'"); $count = $database->loadResult(); # Berechnen der Gesamtseiten $gesamtseiten = floor($count / $ag_perpage); $seitenrest = $count % $ag_perpage; if ($seitenrest>0) { $gesamtseiten++; } # Feststellen der aktuellen Seite if (isset($startpage)) { if ($startpage>$gesamtseiten) { $startpage = $gesamtseiten; } else if ($startpage<1) { $startpage = 1; } } else { $startpage = 1; } if ($count=="") { $count = 0; } $text = str_replace("#count", $count, _garyscookbook_NUMBER_garyscookbook); echo "

".$text."
"; echo _garyscookbook_PAGES.": "; # Ausgeben der Seite zurueck Funktion $seiterueck = $startpage - 1; if ($seiterueck>0) { echo "« "; } #Ausgeben der einzelnen Seiten for ($i=1; $i <= $gesamtseiten; $i++) { if ($i==$startpage) { echo "$i "; } else { echo "$i "; } } # Ausgeben der Seite vorwärts Funktion $seitevor = $startpage + 1; if ($seitevor<=$gesamtseiten) { echo "» "; } # Limit und Seite Vor- & Rueckfunktionen $start = ( $startpage - 1 ) * $ag_perpage; echo "

"; $database->setQuery("SELECT name FROM #__categories WHERE id = '".$id." ORDER BY name'"); $catname = $database->loadResult(); echo ""; echo ""; $query1="SELECT * FROM #__garyscookbook WHERE published = '1' AND catid = '".$id."' ORDER BY imgtitle ASC LIMIT ".$start.",".$ag_perpage; $database->setQuery($query1); $rows = $database->loadObjectList(); echo ""; $rowcounter = 0; foreach($rows as $row1) { if (($rowcounter%3==0) AND ($rowcounter<>0)) echo ""; echo ""; $rowcounter++; } if ($rowcounter%3<>0) { for ($i = 1; $i <= (3-($rowcounter%3)); $i++) { echo ""; } } echo "
"._gkb_CatTabheader." $catname
"; if ($row1->imgfilename <> "") { echo""; echo ""; echo "

"; } else{ echo ""; echo "

"; } echo "$row1->imgtitle"; if ($ag_showdetail) echo "
"._garyscookbook_ADMIN_HITS.": $row1->imgcounter"; if ($ag_showrating) { if ($row1->imgvotes>0) { $filename = "point_kl"; $fimgvotesum = number_format($row1->imgvotesum/$row1->imgvotes,0,",","."); #$frating = "$fimgvotesum ($row1->imgvotes "._garyscookbook_VOTES.")"; $frating = " /($row1->imgvotes" ._garyscookbook_VOTES.")"; } else { $frating = _garyscookbook_NO_VOTES; } echo "
"._garyscookbook_RATING.": $frating"; } if ($ag_showcomment) { # Check how many comments exist $comments_query = "SELECT cmtid FROM ".$mosConfig_dbprefix."garyscookbook_comments WHERE cmtpic='$row1->id'"; $comments_result= mysql_query($comments_query); #$comments_result = $database->openConnectionWithReturn($comments_query); $comments = mysql_num_rows($comments_result); echo "
"._garyscookbook_DEL_COMMENT.": $comments"; } echo "
"; break; ######################################################################################### default: global $ag_regonly, $ag_offlinecookbook, $rowcounter, $is_admin, $rowcounter, $mosConfig_absolute_path; require($mosConfig_absolute_path."/administrator/components/com_garyscookbook/config.garyscookbook.php"); if ($ag_regonly && !$my->id) { showNoAccess(); break; } else if ($ag_offlinecookbook && !$is_admin) { showOfflineMsg(); break; } cookbookHeader(1); echo ""; echo ""; $query1="SELECT * FROM #__categories WHERE section = 'com_garyscookbook' AND published = '1' AND Parent_id = 0 ORDER BY ordering ASC"; $database->setQuery($query1); $rows = $database->loadObjectList(); $line=1; $linecolor=2; foreach($rows as $row1) { if (($rowcounter%$ag_collist==0) AND ($rowcounter<>0)) { echo ""; if ($linecolor==1){ $linecolor=2; }else{ $linecolor=1; } } echo ""; $line++; $rowcounter++; } if ($rowcounter%$ag_collist<>0) { for ($i = 1; $i <= ($ag_collist-($rowcounter%$ag_collist)); $i++) { echo ""; } } echo "
"._garyscookbook_CATEGORIES."
"; if ($row1->image <> "") { echo "id>"; if ($ag_catTumb) { echo "image' ' align='$row1->image_position' hspace='4' border='0' width='$ag_catpicturewidth/>"; } } if (GetNumberOfLinks($row1->id)==1) { $insertbez = _garyscookbook_ADMIN_PICTURE; } else { $insertbez = _gkb_Cat_Recipes ; } echo ""; echo "id>"; echo "$row1->title (" . GetNumberOfLinks($row1->id) . " $insertbez)"; #echo "$mosConfig_absolute_path$ag_paththumbs/$row1->image"; if ($row1->description <> "") { if (strlen($row1->description)> $ag_catlength_fp ) { $thisdescription = substr($row1->description, 0, $ag_catlength_fp); echo "
$thisdescription id>"._READ_MORE.""; }else{ echo "
$row1->description"; } } #echo "
"; break; } cookbookFooter(); ?>