";
ini_set("soap.wsdl_cache_enabled", 1);
ini_set("soap.wsdl_cache_ttl", 86400);
//error_reporting(E_ALL);
ini_set('display_errors','On');
//echo "";
// License
// Our plugin is compatible with the GNU General Public License v2, or any later version.
$myEpaperClass = new epaper();
add_action('init', array($myEpaperClass,'epaperTextDomain'), 1);
add_action('admin_menu', array($myEpaperClass,'epaperIntegrationMenu'));
add_shortcode('ePaper', array($myEpaperClass,'epaperShortcode'));
wp_register_sidebar_widget('1000grad-ePaper','1000°ePaper', array($myEpaperClass,'epaperWidget'),array( 'description' => 'Shows the first ePaper Channel' ));
wp_register_widget_control('1000grad-ePaper','1000grad-ePaper', array($myEpaperClass,'epaperWidgetControl') );
//wp_register_sidebar_widget('1000grad-ePaper-2','1000°ePaper #2', array($myEpaperClass,'epaperWidget2'),array( 'description' => 'Shows the second ePaper Channel' ));
//wp_register_widget_control('1000grad-ePaper-2','1000grad-ePaper #2', array($myEpaperClass,'epaperWidgetControl2'));
add_action( 'add_meta_boxes', array( $myEpaperClass, 'addEpaperMetaBox' ) );
add_filter('the_posts', array($myEpaperClass,'conditionally_add_scripts_and_styles'));
// doesnt work for the moment :-(
//add_action('wp_head', array($myEpaperClass,'colorboxinlineheader'));
add_action('wp_footer', array($myEpaperClass,'colorboxinline'));
class epaper {
function colorboxinlineheader() {
echo '';
}
function colorboxinline() {
echo '';
$code= '
';
// echo $code;
}
function addEpaperMetaBox() {
$epaper_options = get_option("plugin_epaper_options");
$apikey=$epaper_options['apikey'];
if($apikey>"") {
add_meta_box( 'epaper_editorbox', '1000°ePaper', array(&$this, 'epaperMetaBox'), 'post', 'side', 'high' );
add_meta_box( 'epaper_editorbox', '1000°ePaper', array(&$this, 'epaperMetaBox'), 'page', 'side', 'high' );
}
}
function conditionally_add_scripts_and_styles($posts) {
if (empty($posts))
return $posts;
$shortcode_found = false; // use this flag to see if styles and scripts need to be enqueued
foreach ($posts as $post) {
if (stripos($post->post_content, 'ePaper')) {
$shortcode_found = true; // bingo!
break;
}
}
// if ($shortcode_found)
{
// wp_enqueue_script('js_colorbox_min', plugins_url('1000grad-epaper/colorbox/jquery.colorbox-min.js'));
wp_enqueue_script('js_colorbox', plugins_url('1000grad-epaper/colorbox/jquery.colorbox.js'));
wp_enqueue_style('style_colorbox', plugins_url('1000grad-epaper/colorbox/colorbox.css'));
# wp_enqueue_script('yo', 'yo');
# wp_head('yo', 'yo');
}
return $posts;
}
function epaperWidget($args) {
extract($args);
$epaper_options = get_option("plugin_epaper_options");
$url=$epaper_options['channelurl1'];
if($url>"") {
$name=$epaper_options['widgetname1'];
if ($name=="") $name="ePaper";
echo $before_widget;
echo $before_title .$name;
echo $after_title;
$html="";
$html.='
';
// $html.='';
// $html.="
';
// $html.='';
echo $html;
echo $after_widget;
}
}
function epaperWidgetControl() {
$options = get_option("plugin_epaper_options");
if ($_POST['ePaperSubmit'])
{
$options['widgetname1'] = htmlspecialchars($_POST['ePaperWidgetTitle']);
update_option("plugin_epaper_options", $options);
}
?>
"", 'url' => "", 'id' => "", 'nr' => "", ), $atts)); if ($nr=="") $nr=1; $epaper_options = get_option("plugin_epaper_options"); if ($url=="") $url=$epaper_options['channelurl'.$nr]; $html="
';
//$html.='';
return $html;
}
function epaperEditPost($id,$test,$apiKey) {
e_('
',
'post_status' => 'publish',
);
$postid=wp_insert_post( $my_post );
echo __('";
print_r($clientlist);
echo "";
foreach ( $clientlist as $clientpaper ) {
try {
$clientabfrage = $test->ePaperGetInfos($apiKey,$clientpaper->id);
} catch (SoapFault $e) {echo 'Fehler beim Zugriff auf ePaper'.$e->getMessage(); return false;}
echo "";
print_r($clientabfrage);
echo "";
$clientinfo=json_decode($clientabfrage);
?>
API Key: '. $apiKey;
$clientinfo=($testchannel->__getFunctions());
echo __('
Number of API Commands:','1000grad-epaper').' '.count($clientinfo);
}
function epaperTestWordpress() {
global $wp_version;
$versionwordpress = $wp_version;
$versionphp = phpversion();
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$memory_limit = (int)(ini_get('memory_limit'));
$max_execution_time= (int)(ini_get('max_execution_time'));
$max_input_time= (int)(ini_get('max_input_time'));
$upload_mb = min($max_upload, $max_post, $memory_limit);
$uptime_mb = min($max_execution_time,$max_input_time);
echo "";
_e('max. PHP-Upload of this Wordpress:','1000grad-epaper');
echo ' '.$upload_mb.' MByte (upload: '.$max_upload.'MB, Post:'.$max_post.'MB, Speicher:'.$memory_limit.'MB)';
echo "
";
_e('Wordpress & PHP-Version:','1000grad-epaper');
echo ' '.$versionwordpress.' / '.$versionphp;
echo "
";
_e('max. PHP-Time for this Wordpress:','1000grad-epaper');
echo ' '.$uptime_mb.' sec. (execution: '.$max_execution_time.'s, Input:'.$max_input_time.'s)';
echo "
";
_e('curl for this Wordpress:','1000grad-epaper');
if (extension_loaded('curl')) echo " OK. ";
else _e("
Error, there is NO CURL installed at your wordpress system!",'1000grad-epaper');
//echo ' '.$uptime_mb.' sec. (execution: '.$max_execution_time.'s, Input:'.$max_input_time.'s)';
echo "
";
_e("local plugin settings:",'1000grad-epaper');
echo "
";
echo "
";
$epaper_options = get_option("plugin_epaper_options");
print_r($epaper_options);
echo "";
}
function epaperTestApi() {
global $test; global $apiKey; epaper::epaperConnect();
if ($apiKey>'') {
try {
$version=$test->getVersion();
} catch (SoapFault $e) {_e('Lampestr. 2
D-04107 Leipzig
Support: +49 341 96382-63
Fax: +49 341 96382-22
info@1000grad.de
http://www.1000grad.de
http://www.1000grad-epaper.de/loesungen/wp-plugin
'') {
try {
$clientinfos=$test->clientGetInfos($apiKey);
} catch (SoapFault $e) {echo '
Fehler bei API Key Athentifizierung'.$e->getMessage().''; return false;}
$clientinfo=json_decode($clientinfos);
echo 'Name: '.$clientinfo->name;
echo ' ('.$clientinfo->firstname.' '.$clientinfo->lastname.') ';
echo '
Kurzname: '.$clientinfo->short_name;
echo '
Kundennummer: '.$clientinfo->customer_id;
echo '
Email: '.$clientinfo->email;
echo '
vorhandene Kanäle: '.$clientinfo->channels_count.'';
echo '
verwendeter Speicher: '.round($clientinfo->disk_usage / 1024 / 1024 ).' MByte';
echo '
vorhandene ePapers: '.$clientinfo->count_created;
echo '
publizierte ePapers: '.$clientinfo->count_published;
// echo '
ePapers Limit: '.$clientinfo->count_limit;
try { $clientchannels=json_decode($channel->channelsGetList($apiKey));
} catch (SoapFault $e) {echo '
Fehler bei API Key Athentifizierung '.$e->getMessage().''; return false;}
echo '
ePapers Channels: '.$clientchannels->count;
foreach ( $clientchannels->channels as $channelt ) {
// $channelinfo=json_decode($testchannel->GetChannelInfo($apiKey,$channel->id));
echo "
ID: ".$channelt->id;
echo " - ".$channelt->time_created;
echo " - ".$channelt->time_modified;
echo " - ".$channelt->expiry_time;
echo " ";
if ($channelt->id_epaper>"") echo "- ePaper Nr. ".$channelt->id_epaper;
else _e('not used','1000grad-epaper');
}
return true;
}
}
function epaperSettings() {
$epaper_options = get_option("plugin_epaper_options");
if (!is_array( $epaper_options )) {
$epaper_options = array(
'url' => '',
'wordpressapi' => 'http://epaperplugin.1kcloud.com/api/v2/wordpress-wsdl/',
'apikey' => '',
);
}
if ($_GET['epaper-settings-save']) {
$epaper_options['url'] = htmlspecialchars($_GET['epaper_url']);
$epaper_options['wordpressapi'] = htmlspecialchars($_GET['epaper_wordpressapi']);
$epaper_options['apikey'] = htmlspecialchars($_GET['epaper_apikey']);
update_option("plugin_epaper_options", $epaper_options);
}
// epaper_more_channels
if ($_GET['epaper-more-channels']) { echo "upgrade not in settings - tbo"; }
// echo "
";
?>
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 200
php_value max_input_time 200
Error: '.$result['errors']['errorDesc'].'';
// echo '
Error-Code: '.$result['errors']['errorCode'].' ';
// print_r($result);
return false;
} else {
// echo '
PDF-ID: '.$result['pdfId'];
}
$uploadit=$result['pdfId'];
// print_r($result);
_e('
Upload was sucessful','1000grad-epaper');
}
else {
_e("
Error, there is NO CURL installed at your wordpress system!",'1000grad-epaper');
// return false;
echo "
";
$data = "";
$boundary = "---------------------".substr(md5(rand(0,32000)), 0, 10);
$fileContents = file_get_contents($upload['tmp_name']);
$data .= "--$boundary\n";
$data .= "Content-Disposition: form-data; name=\"apikey\"\n\n".$apiKey."\n";
$data .= "--$boundary\n";
$data .= "Content-Disposition: form-data; name=\"file\"; filename=\"".urlencode($upload['name'])."\"\n";
$data .= "Content-Type: application/octet-stream\n";
// $data .= "Content-Transfer-Encoding: binary\n\n";
$data .= $fileContents."\n";
$data .= "--$boundary\n";
$opts = array(
'http'=>array(
'method'=>"POST ".parse_url($uploadUrl, PHP_URL_PATH),
'user_agent'=>"Wordpress ePaper upload",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" .
"Content-Type: multipart/form-data; boundary=".$boundary,
'content'=>$data
)
);
print_r($opts);
$context = stream_context_create($opts);
$socket = stream_socket_client("tcp://".parse_url($uploadUrl, PHP_URL_HOST).":80", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
while (!feof($socket)) {
sleep(1);
echo fgets($socket, 1024);
}
fclose($socket);
echo "xx- upload ende des tests";
return false;
}
$uploadid = $test->epaperCreateFromPdf($apiKey,$uploadit);
// _e('
ePaper generation started','1000grad-epaper');
if ($test->epaperStartRenderprocess($apiKey,$uploadid)) _e('
ePaper Rendering was started.','1000grad-epaper');
else _e('
ePaper rendering couldnt start error.','1000grad-epaper');
require_once 'ProgressBar.class.php';
$bar = new ProgressBar();
$bar->setAutohide(true);
$bar->setSleepOnFinish(1);
$bar->setForegroundColor('#333333');
$elements = 10; //total number of elements to process
$bar->setBarLength(400);
for($j=5;$j>2;$j++){
$infoj=$test->epaperGetInfos($apiKey,$uploadid);
$info = json_decode($infoj, true);
// echo "".preg_replace("/(render)/", "", $info['status'])."";
echo "".$info['status']." ";
$status=$info['status'];
if ($status=="ready") $j=0;
echo $info['renderprocess']['current_page']."/".$info['pages'];
$bar->initialize($elements); //print the empty bar
$bar->setMessage($status);
for($i=0;$i<$elements;$i++){
sleep(1);
$bar->increase(); //calls the bar with every processed element
}
}
echo "
";
echo "";
epaper::epaperChannelDetailsForm($id,$uploadid,$upload['name']);
}
}
function epaperChannelEmpty() {
global $test; global $channel; global $apiKey; epaper::epaperConnect(); epaper::epaperChannelConnect();
$id=$_POST['id'];
$id_epaper=$_POST['id_epaper'];
if ($id_epaper>"") {
if ($channel->channelsRemoveEpaperFromChannel($apiKey,$id)) echo '
Kanal freigestelltOK' ; else echo "Fehler beim Kanal-freistellen!";
if ($test->epaperDelete($apiKey,$id_epaper)) echo '
voriges ePaper gelöschtOK' ; else echo "Fehler beim löschen des vorigen epapers!";
}
}
function epaperChannelDetails() {
global $test; global $channel; global $apiKey; epaper::epaperConnect(); epaper::epaperChannelConnect();
$uploadid=$_POST['id_epaper'];
$id=$_POST['id'];
$title=$_POST['title'];
$lang=$_POST['lang'];
_e('
Name:','1000grad-epaper');
echo ' '.($title);
if ($test->epaperSetVar($apiKey,$uploadid,'title',html_entity_decode($title))=='1') echo ' OK' ;
else echo "probleme beim titel-Setzen";
try { $fileup = $test->epaperSetVar($apiKey,$uploadid,'is_pdf_download','0');
} catch (SoapFault $e) {echo 'Fehler beim Editieren von ePaper (download)'.$e->getMessage(); return false;}
try { $fileup = $test->epaperSetVar($apiKey,$uploadid,'is_search','1');
} catch (SoapFault $e) {echo 'Fehler beim Editieren von ePaper (search)'.$e->getMessage(); return false;}
try { $fileup = $test->epaperSetVar($apiKey,$uploadid,'use_ipad','1');
} catch (SoapFault $e) {echo 'Fehler beim Editieren von ePaper (mobile)'.$e->getMessage(); return false;}
try { $fileup = $test->epaperMove($apiKey,$uploadid,html_entity_decode($title),'1');
} catch (SoapFault $e) {echo 'Fehler beim Umbenennen vom ePaper '.$e->getMessage(); return false;}
// channelsPublishEpaperTochannel
try { $fileup = $channel->channelsPublishEpaperToChannel($apiKey,$uploadid,$id);
} catch (SoapFault $e) {echo '
Fehler beim Kanalisieren von ePaper: '.$e->getMessage(); return false;}
if ($fileup=='1') _e('
Publishing started.','1000grad-epaper');
else _e('
Unable to start publishing.','1000grad-epaper');
echo "
";
require_once 'ProgressBar.class.php';
$bar = new ProgressBar();
$bar->setAutohide(true);
$bar->setSleepOnFinish(1);
$bar->setForegroundColor('#333333');
$elements = 10; //total number of elements to process
$bar->setBarLength(400);
for($j=5;$j>2;$j++){
$infoj=$test->epaperGetInfos($apiKey,$uploadid);
$info = json_decode($infoj, true);
$status=$info['status'];
if ($status=="ready") $j=0;
// echo $info['status']." ";
// echo $info['renderprocess']['current_page']."/".$info['pages'];
$bar->initialize($elements); //print the empty bar
$bar->setMessage($status);
for($i=0;$i<$elements;$i++){
sleep(1); // simulate a time consuming process
$bar->increase(); //calls the bar with every processed element
}
}
echo "
";
echo "
";
_e("Your ePaper is now ready to use.",'1000grad-epaper');
echo "
";
?>
weitere Angaben:';
// echo "