readOptions(); if ( !empty($option['lang']) ) { $locale = $option['lang']; } else { $locale = 'en_US'; } } //$locale = 'en_US'; $domain = 'ed2kls'; load_textdomain ($domain, dirname (__FILE__) . '/lang/' . $domain . '-' . $locale . '.mo'); } function addHead() { global $ed2klspage; $ed2klspage = 1; $cssUrl = constant('ED2KLS_URL') . '/ed2kls.css?v=' . constant('ED2KLS_VERSION'); if ( file_exists(TEMPLATEPATH . '/ed2kls.css') ) { $cssUrl = get_bloginfo('template_url') . '/ed2kls.css'; } echo ' '; } function addFooter() { global $ed2klsnumber; if ($ed2klsnumber >= 1) { echo '
' . __('You can use eMule or its mod (see Mod Page on emule-mods.de) (Windows), aMule(Win, Linux, Mac), etc. to download eD2k links. See eD2k Links Handling for help.
eMuleCollection files contain a set of links intended to be downloaded. They can be managed by eMule.
Click and hold down SHIFT key to toggle multiple checkboxes.
Use filters to select.
View eD2k Link Selector WordPress plugin HomePage to find this plugin or contact the author.', 'ed2kls') . '
' . __('Name Filter helps you select files by their names or extensions. Case insensitive.
Symbols Usage:
AND: space( ), +;
NOT: -;
OR: |;
Escape: two quote marks("");
Match at the start: ^;
Match at the end: $.
e.g.
emule|0.49c -exe to select names that contain "eMule" and "0.49c" but not contain "exe";
^emule 0.49c$ to select names started with "emule" and end with "0.49c";
"emule 0.49c" with quote marks to match exactly a "emule 0.49c", not a "eMule fake 0.49c".', 'ed2kls') . '
' . __('Size Filter helps you select files by their sizes.', 'ed2kls') . '
'; } } function shortcodeEd2k( $atts = array(), $content = NULL, $code = 'ed2k' ) { if ( $content === NULL ) { return ''; } global $eD2kLSOption, $ed2klspage; $option = $eD2kLSOption->readOptions(); $myatts = shortcode_atts( $option, $atts ); if ( !is_singular() && $myatts['forall'] == 'false' || $myatts['format'] == '2' || $ed2klspage === 0 ) { return $this->convert2anchor($content); } global $ed2klsnumber; $ed2klsnumber += 1; $myno = strval($ed2klsnumber); return $this->convert2table($content, $myatts, $myno); } function shortcodeEd2kCmt( $atts = array(), $content = NULL, $code = 'ed2k' ) { if ( $content === NULL ) { return ''; } return $this->convert2anchor($content); } function convert2anchor( $content ) { $newcontent = ''; $newcontent .= '

'; $content = preg_replace ( "/(?ed2k: ' . $name . '
'; } else { $myline = preg_replace ( "/

|<\/p>|||
/i", "", $myline ); $myline = trim($myline); if ($myline !== "") { $newcontent .= '' . $myline . '
'; } } } $newcontent .= '

'; return $newcontent; } function convert2table($content, $atts, $no) { global $elsConvert; return $elsConvert->convert($content, $no, $atts['head'], $atts['stat'], $atts['name'], $atts['size'], $atts['collection'], $atts['width'], $atts['fontsize'], $atts['buttonstyle']); } } } /* Get the php class "elsConvert" here: http://emulefans.com/php-class-ed2k-link-selector/ */ if(!class_exists('elsConvert')) { class elsConvert { function formatSize($val) { $sep = 100; $unit = __('Bytes', 'ed2kls'); if ($val >= 1099511627776) { $val = round($val / (1099511627776 / $sep)) / $sep; $unit = __('TB', 'ed2kls'); } else if ($val >= 1073741824) { $val = round($val / (1073741824 / $sep)) / $sep; $unit = __('GB', 'ed2kls'); } else if ($val >= 1048576) { $val = round($val / (1048576 / $sep)) / $sep; $unit = __('MB', 'ed2kls'); } else if ($val >= 1024) { $val = round($val / (1024 / $sep)) / $sep; $unit = __('KB', 'ed2kls'); } return $val . $unit; } function convert($content, $no = 1, $head = "eD2k链接", $stat = "http://ed2k.shortypower.org/?hash=", $name = "auto", $size = "auto", $collection = "true", $width = "100%", $fontsize = "13px", $buttonstyle = "0") { $sizetot = 0; $num = 0; $extarray = array(); $newcontent = ''; if ( strtolower($collection) != "false" ) { $newcontent .= '
'; } $newcontent .= ' '; $content = preg_replace ( "/(?formatSize($mysize); $hash = $pieces[2]; $newcontent .= ' '; } else { $myline = preg_replace ( "/

|<\/p>|||
/i", "", $myline ); $myline = trim($myline); if ($myline !== "") { $newcontent .= '

'; } } } $sizetot = $this->formatSize($sizetot); $newcontent .= '
' . $head . '
' . __('Help', 'ed2kls') . ' | ' . __('eMule Official', 'ed2kls') . ' | ' . __('eMuleFans.com', 'ed2kls') . ' | eMule-Mods.de | ' . __('Plugin Home', 'ed2kls') . '
' . $myname . ''; if (strtolower($stat) != "false") { $newcontent .= ' ' . __('Stat', 'ed2kls') . ''; } $newcontent .= ' ' . $mysize . '
'. $myline .'
'; if ( (strtolower($name) != 'false' && $num >= 2) || strtolower($name) == 'true') { $newcontent .= ' [?]:'; $extarray = array_unique($extarray); foreach ($extarray as $myext) { $newcontent .= ' '; } $newcontent .= ''; } if ( (strtolower($size) != 'false' && $num >= 2) || strtolower($size) == 'true') { $newcontent .= ' [?]:,'; } $newcontent .= ' ' . $sizetot .'
(' . $num . '' . __('Files', 'ed2kls') . ')
'; if ( strtolower($collection) != "false" ) { $newcontent .= ' '; } $newcontent .= '
'; if ( strtolower($collection) != "false" ) { $newcontent .= '
'; } return $newcontent; } } } if(!class_exists('eD2kLSButton')) { class eD2kLSButton { function eD2kLSButton() { add_action('init', array(&$this, 'addTinymce')); add_filter('admin_head', array(&$this, 'addQuicktag')); } function addQuicktag() { echo ' '; } function addTinymce() { if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ){ return; } if ( get_user_option('rich_editing') == 'true' ) { add_filter('admin_head', array(&$this, 'addTinymceJsVars')); add_filter('mce_external_plugins', array(&$this, 'addTinymcePlugin')); add_filter('mce_buttons', array(&$this, 'addTinymceButton')); } } function addTinymceJsVars() { echo ' '; } function addTinymcePlugin($plugin_array) { $plugin_array['ed2kls'] = constant('ED2KLS_URL') . '/tinymce/editor_plugin.js'; return $plugin_array; } function addTinymceButton($buttons) { array_push($buttons, 'separator', 'ed2kls'); return $buttons; } } } if(!class_exists('eD2kLSOption')) { class eD2kLSOption { function eD2kLSOption() { add_action('init', array(&$this, 'updateOptions'), 9); register_activation_hook(__FILE__, array(&$this, 'optionInit')); register_deactivation_hook(__FILE__, array(&$this, 'deactive')); add_action('admin_menu', array(&$this, 'addOptionPage')); add_filter('plugin_action_links', array(&$this, 'addLinks'), 10, 2); } function addOptionPage() { if (function_exists('add_options_page')) { add_options_page(__('eD2k Link Selector Options', 'ed2kls'), __('eD2k Link Selector', 'ed2kls'), 'manage_options', 'ed2k-link-selector/options.php'); } } function readOptions() { $options = get_option('ed2kls_options'); if (empty($options) || $options['dbversion'] != constant('ED2KLS_DBVERSION')) { $options = $this->defaultOptions(); } return $options; } function optionInit() { $options = get_option('ed2kls_options'); if (empty($options)) { $options = $this->setDefaultOptions(); } elseif ($options['dbversion'] != constant('ED2KLS_DBVERSION')) { $options = $this->mergeOptions(); } return $options; } function defaultOptions() { $defOptions = array(); $defOptions['dbversion'] = constant('ED2KLS_DBVERSION'); $defOptions['lang'] = get_locale(); $defOptions['head'] = __('eD2k Links', 'ed2kls'); $defOptions['stat'] = 'http://ed2k.shortypower.org/?hash='; $defOptions['name'] = 'auto'; $defOptions['size'] = 'auto'; $defOptions['collection'] = 'true'; $defOptions['width'] = '100%'; $defOptions['fontsize'] = '13px'; $defOptions['buttonstyle'] = '0'; $defOptions['format'] = '1'; $defOptions['forall'] = 'false'; return $defOptions; } function mergeOptions() { load_plugin_textdomain('ed2kls', false, 'ed2k-link-selector/lang'); $newOptions = $this->defaultOptions(); $oldOptions = get_option('ed2kls_options'); if (empty($oldOptions)) { add_option('ed2kls_options', $newOptions); } else { foreach ($newOptions as $name => $myNewOption) { $myOldOption = $oldOptions[$name]; if (!empty($myOldOption)) { $newOptions[$name] = $myOldOption; } } update_option('ed2kls_options', $newOptions); } return $newOptions; } function setDefaultOptions() { load_plugin_textdomain('ed2kls', false, 'ed2k-link-selector/lang'); $newOptions = $this->defaultOptions(); if (get_option('ed2kls_options') === false) { add_option('ed2kls_options', $newOptions); } else { update_option('ed2kls_options', $newOptions); } return $newOptions; } function updateOptions() { if ( isset($_POST['elsopt-save']) ) { $newOptions = array(); $defOptions = $this->defaultOptions(); $newOptions['dbversion'] = constant('ED2KLS_DBVERSION'); $newOptions['lang'] = $_POST['elsopt-lang']; $newOptions['head'] = trim($_POST['elsopt-head']) ? trim($_POST['elsopt-head']) : $defOptions['head']; if ( $_POST['elsopt-stat-if'] == 'true') { $newOptions['stat'] = trim($_POST['elsopt-stat']) ? trim($_POST['elsopt-stat']) : $defOptions['stat']; } else { $newOptions['stat'] = 'false'; } $newOptions['name'] = $_POST['elsopt-name']; $newOptions['size'] = $_POST['elsopt-size']; $newOptions['collection'] = $_POST['elsopt-collection']; $newOptions['width'] = $_POST['elsopt-width'] ? $_POST['elsopt-width'] : $defOptions['width']; $newOptions['fontsize'] = $_POST['elsopt-fontsize'] ? $_POST['elsopt-fontsize'] : $defOptions['fontsize']; $newOptions['format'] = $_POST['elsopt-format']; $newOptions['buttonstyle'] = $_POST['elsopt-buttonstyle']; $newOptions['forall'] = $_POST['elsopt-forall']; update_option('ed2kls_options', $newOptions); } if ( isset($_POST['elsopt-default']) ) { $this->setDefaultOptions(); } } function deactive() { if ( isset($_GET['elsdeldata']) && $_GET['elsdeldata'] = 'yes' ) { delete_option('ed2kls_options'); } } function addLinks($links, $file) { if ( $file == 'ed2k-link-selector/ed2k-link-selector.php' ) { $deactivateUrl = 'plugins.php?action=deactivate&plugin=ed2k-link-selector/ed2k-link-selector.php'; if (function_exists('wp_nonce_url')) { $deactivateUrl = wp_nonce_url($deactivateUrl, 'deactivate-plugin_ed2k-link-selector/ed2k-link-selector.php'); } $links[] = '' . __('Disable Cpltly', 'ed2kls') . ''; $links[] = '' . __('Settings', 'ed2kls') . ''; } return $links; } } } if(class_exists('elsConvert')) { $elsConvert = new elsConvert(); } if(class_exists('eD2kLinkSelector')) { $eD2kLinkSelector = new eD2kLinkSelector(); } if(class_exists('eD2kLSOption')) { $eD2kLSOption = new eD2kLSOption(); } if(class_exists('eD2kLSButton')) { $eD2kLSButton = new eD2kLSButton(); } ?>