epaperOptions = get_option("plugin_epaper_options");
$this->apikey = $this->epaperOptions['apikey'];
$this->_isRegistered();
}
/**
* Shall validate if plugin is registered
*/
private function _isRegistered ()
{
if (isset($this->apikey) && ($this->apikey != "")) {
$this->isRegistered = true;
} else {
$this->isRegistered = false;
if (isset($_GET["page"])) if ($_GET["page"]=="epaper_apikey") return;
echo '
',
'post_status' => 'publish',
);
$postid = wp_insert_post($my_post);
echo __('"; // print_r($clientinfo); // echo ""; echo __('
API Key: '. $apiKey;
$clientinfo=($testchannel->__getFunctions());
echo __('
Number of API Commands:','1000grad-epaper').' '.count($clientinfo);
}
/**
* Test von einigen Wordpress Einstellungen
*/
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 "
";
_e("local plugin settings:",'1000grad-epaper');
echo "
";
echo "
";
$epaper_options = get_option("plugin_epaper_options");
print_r($epaper_options);
echo "";
}
/**
* Anzeige der einzelnen Funktionen
*/
function epaperTestDebug($functions)
{
// echo ""; // print_r($functions); // echo ""; } /** * API Test */ function epaperTestEpaperApi() { if ($this->isRegistered === true) { $epaperApi = new EpaperApi(); $version = $epaperApi->getEpaperApiVersion(); $functions = $epaperApi->getEpaperApiFunctions(); $clientinfos = $epaperApi->getEpaperApiClientInfos($this->apikey); echo 'API Version: ' . $version; echo __('
apt-get install php5-curl",'1000grad-epaper');
exit();
}
$html->epaperApiSettingsForm($this->epaperOptions);
$html->close3Div();
$expr5 = 'Infos';
$html->associatedDivs($expr5);
$this->epaperTestWordpress();
$html->close3Div();
$expr6 = 'ePaper Wordpress API';
$html->associatedDivs($expr6);
$this->epaperTestApikeyApi();
$html->close3Div();
$expr7 = 'ePaper User API';
$html->associatedDivs($expr7);
$this->epaperTestEpaperApi();
$html->close3Div();
$html->associatedDivs('ePaper Channel API');
$this->epaperTestChannelApi();
$html->close3Div();
$html->associatedDivs('ePaper API License');
$this->epaperLicense();
$html->close3Div();
$html->closeDiv();
$html->closeDiv();
$html->br();
$html->closeDiv();
}
/**
* Registrierungsprozess fuer neue User
*/
function epaperApikey()
{
if (!is_array($this->epaperOptions)) {
$this->epaperOptions = array(
'url' => '',
'email' => '',
'wordpressapi' => 'http://epaperplugin.1kcloud.com/api/v2/wordpress-wsdl/',
'text' => '',
'urlapikey' => '',
'apikey' => '',
'code' => '',
'newsletter' => '',
);
}
// # schritt 2: email adresse wird übermittelt
if (isset($_POST['on'])) {
$email = trim(htmlspecialchars($_POST['apikey_email']));
if (isset ($_POST['agb'])) $agb="yes"; else $agb="";
if (isset ($_POST['newsletter'])) $newsletter="yes"; else $newsletter="";
$language = __("en",'1000grad-epaper');
// wordpress infos
global $wp_version;
$version_wordpress = $wp_version;
$version_php = 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);
$wordpress = admin_url();
$text = "wordpress";
$wordpresscode="";
_e("Acquiring data.",'1000grad-epaper');
$this->epaperOptions['email'] = $email;
$this->epaperOptions['text'] = $text;
$this->epaperOptions['agb'] = $agb;
$this->epaperOptions['newsletter'] = $newsletter;
update_option("plugin_epaper_options", $this->epaperOptions);
$apikeyApi = new EpaperApikeyApi();
$res = json_decode($apikeyApi->getRegistrationCodeByEmail($email, $text, $wordpress, $upload_mb,
$uptime_mb, $wordpresscode, $agb, $newsletter, $version_wordpress ,$version_php, $language));
}
// # schritt 1: formular wird angezeigt
$html = new EpaperHtml();
$html->divClassWrap();
$out = __("1000°ePaper Registration",'1000grad-epaper');
$html->h1($out);
$html->divPostboxContainer();
$html->divMetaboxHolder();
if (!extension_loaded('curl')) {
_e("apt-get install php5-curl",'1000grad-epaper');
exit();
}
// 3
// --
$out = __("Request 1000°ePaper Key",'1000grad-epaper');
$html->associatedDivs($out);
$html->renderEpaperForm ($this->epaperOptions);
$html->close3Div();
// --
$expr = __("Registration Code",'1000grad-epaper');
$html->associatedDivs($expr);
// # schritt 3: code aus der email wird angeklickt.
if (isset($_GET['email'])) {
$this->epaperApikeyGetByCode();
} else {
// # schritt 3b: code aus der email kann eingetippt werden
if ($this->epaperOptions['email'] != "") {
$html->divEpaperform();
$html->divMetaboxPrefs();
$html->renderConfirmEmailRegisterForm($this->epaperOptions);
$html->closeDiv();
$html->closeDiv();
$html->br();
} else {
_e('Info: Your Information will be transmitted to the 1000Grad Company. You will receive an email for confirmation.','1000grad-epaper');
$html->close3Div();
$expr = 'Kontakt';
$html->associatedDivs($expr);
$html->printEpaperContact();
}
}
$html->close3Div();
$html->close3Div();
}
/**
* Test Funktion zum Erhalten des Apikeys
* @return boolean
*/
public function epaperApikeyGetByCode()
{
// $email = $this->epaperOptions['email'];
$email = trim(htmlspecialchars($_GET['email']));
$code = trim(htmlspecialchars($_GET['code']));
$echo = __("Confirmation code was entered:",'1000grad-epaper');
echo $echo . " " . $code;
$apikeyApi = new EpaperApikeyApi();
$result = ($apikeyApi->sendCodeGetApikey($email, $code));
if ($result==false) {
echo "Your new settings are: ",'1000grad-epaper');
print_r($result);
echo "";
$this->epaperOptions['url']= $result->apiurl;
$this->epaperOptions['apikey']= $result->apikey;
update_option("plugin_epaper_options", $this->epaperOptions);
_e("
Now you can use this ePaper Plugin!
",'1000grad-epaper'); $html = new EpaperHtml(); $html->registerDoneBtn(); } /** * wird ausgefuerht, wenn jemand ein PDF hochlaedt * @return boolean */ public function epaperChannelUpload() { // echo "ss"; $html = new EpaperHtml(); $upload = $_FILES['uploadfile']; $id = $_POST['id']; $id_epaper = $_POST['id_epaper']; $epaperApi = new EpaperApi(); if ($id_epaper!="") { $channelApi = new EpaperChannelApi(); if ($channelApi->removeEpaperFromChannel($this->apikey, $id)) { _e("
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 200
php_value max_input_time 200
";
print_r($response);
echo "";
return false;
} elseif (!$result['success']) {
echo '';
_e('Error message from 1000°ePaper server:','1000grad-epaper');
echo ' '.$result['errors']['errorDesc'].'';
return false;
} else {
echo " OK";
}
$pdfId = $result['pdfId'];
_e('
Upload was sucessful','1000grad-epaper');
} else {
_e("
Error, there is NO CURL installed at your wordpress system!",'1000grad-epaper');
return false;
}
$uploadId = $epaperApi->epaperCreateFromPdf($this->apikey, $pdfId);
if ($epaperApi->epaperStartRenderprocess($this->apikey,$uploadId)) {
echo ", ";
_e('ePaper Rendering was started.','1000grad-epaper');
} else {
_e('
ePaper rendering couldnt start error.','1000grad-epaper');
}
echo "
";
$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 = $epaperApi->returnEpaperInfos($this->apikey, $uploadId);
$info = json_decode($infoj, true);
// echo "
"; // print_r($info); // echo ""; 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 } } $html->brClearAll(); echo "
"; $this->epaperChannelDetailsForm($id,$uploadId,$upload['name']); echo "
"; } /** * leert den ePaper Kanal, inkl. Löschen des zugehoerigen ePapers */ public function epaperChannelEmpty() { $id = $_POST['id']; $epaperId = $_POST['id_epaper']; if ($epaperId != "") { $channelApi = new EpaperChannelApi(); _e(""; _e("Your ePaper is now ready to use.",'1000grad-epaper'); echo "
"; $html->br(); $html->epaperPublishedButtonForm(); } /** * Formular waehrend des Hochladens */ public function epaperChannelDetailsForm($id, $epaperId, $name) { $name = preg_replace("/^(.+)\.pdf$/i","\\1", $name); $html = new EpaperHtml; $html->divEpaperform(); $html->divMetaboxPrefs(); $html->channelDetailsForm($id, $epaperId, $name); $html->closeDiv(); $html->closeDiv(); } /** * Formular zum Hochladen der pdfs in der Gesamtuebersicht */ public function epaperChannelUploadForm($id, $epaperId) { $html = new EpaperHtml; $html->divEpaperform(); $html->divMetaboxPrefs(); $html->pdfUploadForm($id, $epaperId); if ($epaperId != "") { $html->pdfDeleteForm($id, $epaperId); } $html->closeDiv(); $html->closeDiv(); } /** * einen neuen Beitrag posten, in dem das ePaper verlinkt ist */ public function epaperChannelPostPost() { $html = new EpaperHtml(); $h3=__("Post ePaper Channel",'1000grad-epaper'); $html->h3($h3); // $channelid = $_POST["channelid"]; // if ($channelid == "") $channelid = $_GET["channelid"]; // $channelApi = new EpaperChannelApi(); // if (!$channelinfo = $channelApi->getChannelInfo($this->apikey, $channelid)) { // _e("ePaper channel read fault.",'1000grad-epaper'); // return false; // } // $info=json_decode($channelinfo); if (isset($channelurl)) { $channelurl = $_GET["url"]; $textout = "[ePaper url=".$channelurl."]" . " "; } else $textout = "[ePaper]" . " "; // please mention the class alignment possibility $textout .= __( "This is my new ePaper, brought to you by the 1000°ePaper service.\n". "Even you can share your ePapers\n". "with this wordpress plugin! Get your first ePaper Channel FOR FREE during beta stage." ,'1000grad-epaper'); echo "".$textout.""; $my_post = array( 'post_title' => 'ePaper ', // 'post_title' => 'ePaper '.$info->title, 'post_content' => $textout, 'post_status' => 'publish', ); $postid = wp_insert_post($my_post); _e("
";
echo '';
_e('Further edit this post','1000grad-epaper');
echo '';
}
/**
* Zentralfunktion des Plugins mit Verteilung in Unterfunktionen
*/
public function epaperChannels()
{
if (isset($_REQUEST['modus'])) $modus = $_REQUEST['modus'];
else $modus="";
$html = new EpaperHtml();
switch ($modus) {
case 'upload':
$this->epaperChannelUpload();
break;
case 'postpost':
$this->epaperChannelPostPost();
break;
case 'channeldetails':
$this->epaperChannelDetails();
break;
case 'channelupgrade':
$this->epaperChannelUpgrade();
break;
case 'empty':
$this->epaperChannelEmpty();
break;
case 'list':
$this->epaperEditList();
break;
}
if ($modus=="" || $modus=="channelupgrade" || $modus=="empty") {
$html->divClassWrap();
$html->h1('1000°ePaper');
$html->divPostboxContainer95pc();
$html->divMetaboxHolder();
$html->divUiSortable();
$html->divPostbox();
$html->divClassInside();
$html->logo1000Grad();
$html->introText();
if (!extension_loaded('curl')) {
_e("
Error, there is NO CURL installed at your wordpress system!",'1000grad-epaper');
}
if ($this->isRegistered) {
$channelApi = new EpaperChannelApi();
$channels = json_decode($channelApi->getChannelsList($this->apikey));
//print_r($channels);
//$channelcount = count($channels->channels);
$channelnr = 0;
$html->close3Div();
foreach ( $channels->channels as $channelz ) {
$channelnr = $channelnr + 1;
$channelinfo = json_decode($channelApi->getChannelInfo($this->apikey, $channelz->id));
$this->epaperChannelShow($channelinfo, $channelnr);
}
$channelnr = $channelnr + 1;
$expr = __("add another ePaper Channel",'1000grad-epaper');
$html->associatedDivs($expr);
echo "
| ";
echo " | "; $html->epaperChannelUpgradeForm(); echo " | ";
_e("You can get more 1000°ePaper channels for your account for instance via PayPal. Coming soon.",'1000grad-epaper');
_e(" Please give us feedback about this plugin",'1000grad-epaper'); echo " |
| "; if (!isset($channelinfo->id_epaper)) { echo __("no ePaper given",'1000grad-epaper'); } else { $htmlf = "url . '/epaper/epaper-ani.gif?rnd=' . rand(1000, 9999) . '" alt="epaper preview gif" border="0" hspace=20 /> '; echo $htmlf; } echo " | "; $this->epaperChannelUploadForm($channelinfo->id, $channelinfo->id_epaper); echo " | ";
if (!isset($channelinfo->id_epaper))
{
_e("According to your wordpress settings the maximum upload size is limited to",'1000grad-epaper');
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$memory_limit = (int)(ini_get('memory_limit'));
$upload_mb = min($max_upload, $max_post, $memory_limit);
echo " " . $upload_mb . " MB";
} else {
_e("Embed this ePaper:",'1000grad-epaper');
echo "
|