Viewing file: admin.booklibrary.class.others.php (8.65 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
*
* @package Booklibrary
* @copyright 2009 Andrey Kvasnevskiy-OrdaSoft([email protected]);Rob de Cleen([email protected])
* Homepage: http://www.joomlawebserver.com
* @version: 1.5.2 Free $
*
**/
class mosBooklibraryOthers{
/**
* Sets the parametes for connecting to a webservice via a
* @param the array of parameters
* @deprecated $Revision: 1.0 $ - December 2007
*/
function setParams()
{
//echo '2222: ';exit;
global $booklibrary_configuration;
// Prepare settings
// Using single quotes is easier because you don't have to escape them. For every setting, add a line.
$settings = "<?php\n";
$settings .= "// Do not edit this file. Generated by admin script.\n";
$settings .= "// Booklibrary Configuration file\n";
$settings .= "// General Informations \n";
$settings .= "\$booklibrary_configuration['release']['version']='" . $booklibrary_configuration['release']['version'] ."';\n";
$settings .= "\$booklibrary_configuration['release']['date']='" . $booklibrary_configuration['release']['date'] ."';\n";
$settings .= "// edit book \n";
$settings .= "\$booklibrary_configuration['editbook']['check']['isbn']='" . $booklibrary_configuration['editbook']['check']['isbn'] . "';\n";
$settings .= "\$booklibrary_configuration['editbook']['default']['lang']='" . $booklibrary_configuration['editbook']['default']['lang'] . "';\n";
$settings .= "// price settings\n";
$settings .= "\$booklibrary_configuration['price']['show']='" . $booklibrary_configuration['price']['show'] ."';\n";
$settings .= "// amazon settings\n";
$settings .= "\$booklibrary_configuration['ws']['amazon']['tag']='" . $booklibrary_configuration['ws']['amazon']['tag'] ."';\n";
$settings .= "\$booklibrary_configuration['ws']['amazon']['devtag']= '" . $booklibrary_configuration['ws']['amazon']['devtag'] ."';\n";
$settings .= "// fetch images settings\n";
$settings .= "\$booklibrary_configuration['fetchImages']['boolean']='" . $booklibrary_configuration['fetchImages']['boolean'] ."';\n";
$settings .= "\$booklibrary_configuration['fetchImages']['location']='" . $booklibrary_configuration['fetchImages']['location'] ."';\n";
$settings .= "// review settings\n";
$settings .= "\$booklibrary_configuration['reviews']['show']='" . $booklibrary_configuration['reviews']['show'] ."';\n";
$settings .= "\$booklibrary_configuration['reviews']['registrationlevel']='" . $booklibrary_configuration['reviews']['registrationlevel'] ."';\n";
$settings .= "// lend settings\n";
$settings .= "\$booklibrary_configuration['lendstatus']['show']='" . $booklibrary_configuration['lendstatus']['show'] ."';\n";
$settings .= "\$booklibrary_configuration['lendrequest']['registrationlevel']='" . $booklibrary_configuration['lendrequest']['registrationlevel'] ."';\n";
$settings .= "// ebook settings\n";
$settings .= "\$booklibrary_configuration['ebooks']['allow']='" . $booklibrary_configuration['ebooks']['allow'] ."';\n";
$settings .= "\$booklibrary_configuration['ebooks']['show']='" . $booklibrary_configuration['ebooks']['show'] ."';\n";
$settings .= "\$booklibrary_configuration['ebooks']['registrationlevel']='" . $booklibrary_configuration['ebooks']['registrationlevel'] ."';\n";
$settings .= "\$booklibrary_configuration['ebooks']['location']='" . $booklibrary_configuration['ebooks']['location'] ."';\n";
$settings .= "// debuging\n";
$settings .= "\$booklibrary_configuration['debug']='" . $booklibrary_configuration['debug'] . "';\n";
$settings .= "\$booklibrary_configuration['page']['items']='" . $booklibrary_configuration['page']['items'] . "';\n";
$settings .= "// foto size\n";
$settings .= "\$booklibrary_configuration['foto']['high']= '" . $booklibrary_configuration['foto']['high'] ."';\n";
$settings .= "\$booklibrary_configuration['foto']['width']= '" . $booklibrary_configuration['foto']['width'] ."';\n";
//add for show in category picture
$settings .= "// show in category picture\n";
$settings .= "\$booklibrary_configuration['cat_pic']['show']='" . $booklibrary_configuration['cat_pic']['show'] ."';\n";
//add for show subcategory
$settings .= "// show subcategory\n";
$settings .= "\$booklibrary_configuration['subcategory']['show']='" . $booklibrary_configuration['subcategory']['show'] ."';\n";
$settings .= "?>\n";
// Write out new initialization file
$fd = fopen("./components/com_booklibrary/admin.booklibrary.class.conf.php", "w" )
or die ("Cannot create configuration file.");
fwrite( $fd, $settings );
fclose( $fd );
}
/**
* Rating Array
* @return array an Array containing the information of all Rating
* possibilities
*/
function getRatingArray(){
$i = 0;
$retVal = array();
while($i < 5){
//erster teil x,0
$tmp = $i * 2;
array_push($retVal, array($tmp, $i.",0"));
//zweiter teil x,5
$tmp ++;
array_push($retVal, array($tmp, $i.",5"));
$i ++;
}
array_push($retVal, array(10, "10,0"));
return $retVal;
}
/**
* Language Array - defined in the language files!
* @return array an Array containing the information of all Language
* possibilities
*/
function getLanguageArray(){
$retVal = array();
array_push($retVal, array("Not specified", _BOOKLIBRARY_LANGUAGE_NOT_USED));
array_push($retVal, array("English", _BOOKLIBRARY_LANGUAGE_ENG));
array_push($retVal, array("Dutch", _BOOKLIBRARY_LANGUAGE_DUT));
array_push($retVal, array("Italian", _BOOKLIBRARY_LANGUAGE_ITA));
array_push($retVal, array("French", _BOOKLIBRARY_LANGUAGE_FRE));
array_push($retVal, array("German", _BOOKLIBRARY_LANGUAGE_GER));
array_push($retVal, array("Spanish",_BOOKLIBRARY_LANGUAGE_SPA));
array_push($retVal, array("Russian", _BOOKLIBRARY_LANGUAGE_RUS));
return $retVal;
}
/**
* fetches the information from the imageURL field of the book and stores
* the book with the ISBN number in the defined folder - then overwrites
* the information in the imageURL field so that it points to the file
* downloaded
* @param mosBooklibrary store the book with all necessary information.
* @return null if everything is OK, else return error string
*/
function storeImageFile(& $book, $picture)
{
global $mosConfig_live_site, $mosConfig_absolute_path, $booklibrary_configuration;
$old_pic=$book->imageURL;
//set path for local host images files
$is_local_url = false ;
if(substr($old_pic,0,4) != "http")
{
$old_pic = $mosConfig_live_site . '/'. $old_pic;
$is_local_url = true;
}
if ($picture != null)
{
$new_pic = substr($book->isbn . strrchr($picture['name'], "."), 1);
if(!move_uploaded_file($picture['tmp_name'], $mosConfig_absolute_path.$booklibrary_configuration['fetchImages']['location'].$new_pic))
{
return "Error moving File!";
} else
{
$book->imageURL=$booklibrary_configuration['fetchImages']['location'].$new_pic;return null;
}
}
//echo '2222: '.$is_local_url;exit;
else if( $is_local_url)
{
//for local images - do only check
if( !($ch = curl_init($old_pic)) ) return "Bad path to image file: $old_pic";
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_exec($ch);
$intReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($intReturnCode != 200)
{
return "Bad path image file";
}
}else if( !$is_local_url && strlen(trim($old_pic)) > 0)
{
$new_pic = substr($book->isbn . strrchr($book->imageURL, "."), 1);
if( strrchr($new_pic, "/") ) return "Bad path to image file: $book->imageURL";
if( !($ch = curl_init($old_pic)) ) return "Bad path to image file: $old_pic";
if($fp = fopen($mosConfig_absolute_path.$booklibrary_configuration['fetchImages']['location'] . $new_pic, "w") )
{
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_exec($ch);
$intReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
fclose($fp);
if ($intReturnCode != 200)
{
unlink($mosConfig_absolute_path .$booklibrary_configuration['fetchImages']['location']
.$new_pic);
return "Bad path image file";
}
}
else
{
return "Folder".$booklibrary_configuration['fetchImages']['location']."dont exist";
}
}
else
{
return "Bad path or access deny to save image file";
}
}
}
?>
|