public function restore($filename) { if (!file_exists($filename)) { $this->pushError(sprintf(langBup::_('Filesystem backup %s does not exists'), basename($filename))); return false; } if (!class_exists('PclZip', false)) { /** @var backupBup $backup */ $backup = $this->getModule(); $backup->loadLibrary('pcl'); } $pcl = new PclZip($filename); if ($files = $pcl->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER) === 0) { $this->pushError(langBup::_('An error has occurred while unpacking the archive')); return false; } unset($pcl); // Unpack stacks $stacks = glob(realpath(ABSPATH) . '/BUP*'); if (empty($stacks)) { return true; } foreach ($stacks as $stack) { if (file_exists($stack)) { $pcl = new PclZip($stack); $pcl->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER); unlink($stack); unset($pcl); } } return true; }
public function __construct() { $this->_table = '@__files'; $this->_id = 'id'; $this->_alias = 'toe_f'; $this->_addField('pid', 'hidden', 'int', '', langBup::_('Product ID'))->_addField('name', 'text', 'varchar', '255', langBup::_('File name'))->_addField('path', 'hidden', 'text', '', langBup::_('Real Path To File'))->_addField('mime_type', 'text', 'varchar', '32', langBup::_('Mime Type'))->_addField('size', 'text', 'int', 0, langBup::_('File Size'))->_addField('active', 'checkbox', 'tinyint', 0, langBup::_('Active Download'))->_addField('date', 'text', 'datetime', '', langBup::_('Upload Date'))->_addField('download_limit', 'text', 'int', '', langBup::_('Download Limit'))->_addField('period_limit', 'text', 'int', '', langBup::_('Period Limit'))->_addField('description', 'textarea', 'text', 0, langBup::_('Descritpion'))->_addField('type_id', 'text', 'int', '', langBup::_('Type ID')); }
public function __construct() { $this->_table = '@__htmltype'; $this->_id = 'id'; $this->_alias = 'toe_htmlt'; $this->_addField('id', 'hidden', 'int', 0, langBup::_('ID'))->_addField('label', 'text', 'varchar', 0, langBup::_('Method'), 32)->_addField('description', 'text', 'varchar', 0, langBup::_('Description'), 255); }
public function __construct() { $this->_table = '@__options_categories'; $this->_id = 'id'; $this->_alias = 'toe_opt_cats'; $this->_addField('id', 'hidden', 'int', 0, langBup::_('ID'))->_addField('label', 'text', 'varchar', 0, langBup::_('Method'), 128); }
public function __construct() { $this->_table = '@__log'; $this->_id = 'id'; /*Let's associate it with posts*/ $this->_alias = 'toe_log'; $this->_addField('id', 'text', 'int', 0, langBup::_('ID'), 11)->_addField('type', 'text', 'varchar', '', langBup::_('Type'), 64)->_addField('data', 'text', 'text', '', langBup::_('Data'))->_addField('date_created', 'text', 'int', '', langBup::_('Date created'))->_addField('uid', 'text', 'int', 0, langBup::_('User ID'))->_addField('oid', 'text', 'int', 0, langBup::_('Order ID')); }
public function __construct() { $this->_table = '@__modules_type'; $this->_id = 'id'; /*Let's associate it with posts*/ $this->_alias = 'toe_m_t'; $this->_addField($this->_id, 'text', 'int', '', langBup::_('ID'))->_addField('label', 'text', 'varchar', '', langBup::_('Label'), 128); }
public function __construct() { $this->_table = '@__modules'; $this->_id = 'id'; /*Let's associate it with posts*/ $this->_alias = 'toe_m'; $this->_addField('label', 'text', 'varchar', 0, langBup::_('Label'), 128)->_addField('type_id', 'selectbox', 'smallint', 0, langBup::_('Type'))->_addField('active', 'checkbox', 'tinyint', 0, langBup::_('Active'))->_addField('params', 'textarea', 'text', 0, langBup::_('Params'))->_addField('has_tab', 'checkbox', 'tinyint', 0, langBup::_('Has Tab'))->_addField('description', 'textarea', 'text', 0, langBup::_('Description'), 128)->_addField('code', 'hidden', 'varchar', '', langBup::_('Code'), 64)->_addField('ex_plug_dir', 'hidden', 'varchar', '', langBup::_('External plugin directory'), 255); }
public function __construct() { $this->_table = '@__options'; $this->_id = 'id'; /*Let's associate it with posts*/ $this->_alias = 'toe_opt'; $this->_addField('id', 'text', 'int', 0, langBup::_('ID'))->_addField('code', 'text', 'varchar', '', langBup::_('Code'), 64)->_addField('value', 'text', 'varchar', '', langBup::_('Value'), 134217728)->_addField('label', 'text', 'varchar', '', langBup::_('Label'), 255)->_addField('description', 'text', 'text', '', langBup::_('Description'))->_addField('htmltype_id', 'selectbox', 'text', '', langBup::_('Type'))->_addField('cat_id', 'hidden', 'int', '', langBup::_('Category ID'))->_addField('sort_order', 'hidden', 'int', '', langBup::_('Sort Order'))->_addField('value_type', 'hidden', 'varchar', '', langBup::_('Value Type')); }
public function getTabs() { $tabs = array(); $tab = new tabBup(langBup::_('Templates'), $this->getCode()); $tab->setView('templatesTab'); $tab->setSortOrder(1); $tabs[] = $tab; return $tabs; }
/** * Returns the available tabs * * @return array of tab */ public function getTabs() { $tabs = array(); $tab = new tabBup(langBup::_('General'), $this->getCode()); $tab->setView('optionTab'); $tab->setSortOrder(-99); $tabs[] = $tab; return $tabs; }
public function saveGroupEvery() { $res = new responseBup(); if ($data = $this->getModel()->saveGroupEvery(reqBup::get('post'))) { $res->addMessage(langBup::_('Save complete')); //$res->addData($data); } else { $res->pushError($this->getModel()->getErrors()); } return $res->ajaxExec(); }
public function saveMainFromDestGroup() { $res = new responseBup(); $post = reqBup::get('post'); if ($result = $this->getModel()->saveMainFromDestGroup($post)) { $res->addMessage(langBup::_('Save Complete')); $res->addData($result); } else { $res->pushError($this->getModel('options')->getErrors()); } return $res->ajaxExec(); }
public function bupSendInfo() { $res = new responseBup(); if ($this->getModel()->welcomePageSaveInfo(reqBup::get('post'))) { $res->addMessage(langBup::_('Information was saved. Thank you!')); $originalPage = reqBup::getVar('original_page'); $return = $this->getModule()->decodeSlug(str_replace('return=', '', $originalPage)); $return = admin_url(strpos($return, '?') ? $return : 'admin.php?page=' . $return); $res->addData('redirect', $return); installerBup::setUsed(); } else { $res->pushError($this->getModel()->getErrors()); } return $res->ajaxExec(); }
public function initMenu() { $firstTimeLookedToPlugin = installerBup::isUsed(); //$firstTimeLookedToPlugin = false; if ($firstTimeLookedToPlugin) { add_menu_page(langBup::_('Ready! Backup'), langBup::_('Ready! Backup'), 10, $this->_file, array(frameBup::_()->getModule('options')->getView(), 'getAdminPage')); } else { if (frameBup::_()->getModule('promo_ready')) { add_menu_page(langBup::_('Ready! Backup'), langBup::_('Ready! Backup'), 10, $this->_file, array(frameBup::_()->getModule('promo_ready')->getView(), 'showWelcomePage')); } else { // if not install module "promo_ready" installerBup::setUsed(); add_menu_page(langBup::_('Ready! Backup'), langBup::_('Ready! Backup'), 10, $this->_file, array(frameBup::_()->getModule('options')->getView(), 'getAdminPage')); } } /*if(!empty($this->_options)) { foreach($this->_options as $opt) { add_submenu_page($this->_file, langBup::_($opt['title']), langBup::_($opt['title']), $opt['capability'], $opt['menu_slug'], $opt['function']); } }*/ }
public function sendMailToDevelopers() { $res = new responseBup(); $data = reqBup::get('post'); $fields = array('name' => new fieldBupBup('name', langBup::_('Your name field is required.'), '', '', 'Your name', 0, array(), 'notEmpty'), 'website' => new fieldBupBup('website', langBup::_('Your website field is required.'), '', '', 'Your website', 0, array(), 'notEmpty'), 'email' => new fieldBupBup('email', langBup::_('Your e-mail field is required.'), '', '', 'Your e-mail', 0, array(), 'notEmpty, email'), 'subject' => new fieldBupBup('subject', langBup::_('Subject field is required.'), '', '', 'Subject', 0, array(), 'notEmpty'), 'category' => new fieldBupBup('category', langBup::_('You must select a valid category.'), '', '', 'Category', 0, array(), 'notEmpty'), 'message' => new fieldBupBup('message', langBup::_('Message field is required.'), '', '', 'Message', 0, array(), 'notEmpty')); foreach ($fields as $f) { $f->setValue($data[$f->name]); $errors = validatorBup::validate($f); if (!empty($errors)) { $res->addError($errors); } } if (!$res->error) { $msg = 'Message from: ' . get_bloginfo('name') . ', Host: ' . $_SERVER['HTTP_HOST'] . '<br />'; foreach ($fields as $f) { $msg .= '<b>' . $f->label . '</b>: ' . nl2br($f->value) . '<br />'; } $headers[] = 'From: ' . $fields['name']->value . ' <' . $fields['email']->value . '>'; wp_mail('ukrainecmk@ukr.net, simon@readyshoppingcart.com, support@readyecommerce.zendesk.com', 'Ready Ecommerce Contact Dev', $msg, $headers); $res->addMessage(langBup::_('Done')); } $res->ajaxExec(); }
</td> </tr> </table> <div class="excludeOpt"> <?php echo langBup::_('Exclude:'); echo htmlBup::text('opt_values[exclude]', array('attrs' => 'class="excludeInput" title="If entering multiple files/directories, then separate them with commas."', 'value' => frameBup::_()->getModule('options')->get('exclude'))); ?> </div> <div class="emailOpt"> <table> <tr> <td width="120"><?php echo langBup::_('Email notification:'); ?> </td> <td><?php echo htmlBup::checkbox('opt_values[email_ch]', array('attrs' => 'class="bupCheckboxNotUnCheck"', 'value' => 1, 'checked' => frameBup::_()->getModule('options')->getValueType('email') ? 'checked' : '')); ?> </td> </tr> </table> <div class="emailAddress" <?php echo frameBup::_()->getModule('options')->getValueType('email') ? '' : 'style="display:none"'; ?> > <?php echo htmlBup::text('opt_values[email]', array('attrs' => 'class="excludeInput" placeholder="*****@*****.**" title=""', 'value' => frameBup::_()->getModule('options')->get('email'))); ?>
/** * Function to get field params * * @param object $params */ public static function getFieldAttributes($params) { $output = ''; if (!empty($params->attr)) { foreach ($params->attr as $key => $value) { $output .= langBup::_($key) . ':<br />'; $output .= htmlBup::text('params[attr][' . $key . ']', array('value' => $value)) . '<br />'; } } else { $output .= langBup::_('class') . ':<br />'; $output .= htmlBup::text('params[attr][class]', array('value' => '')) . '<br />'; $output .= langBup::_('id') . ':<br />'; $output .= htmlBup::text('params[attr][id]', array('value' => '')) . '<br />'; } return $output; }
public function activateUpdate($d = array()) { $plugName = isset($d['plugName']) ? $d['plugName'] : ''; if (!empty($plugName)) { $activationKey = isset($d['activation_key']) ? $d['activation_key'] : ''; if (!empty($activationKey)) { $result = modInstallerBup::activateUpdate($plugName, $activationKey); if ($result === true) { return true; } elseif (is_array($result)) { // Array with errors $this->pushError($result); } else { $this->pushError(langBup::_('Can not contact authorization server for now.')); $this->pushError(langBup::_('Please try again latter.')); $this->pushError(langBup::_('If problem will not stop - please contact us using this form <a href="http://readyshoppingcart.com/contacts/" target="_blank">http://readyshoppingcart.com/contacts/</a>.')); } } else { $this->pushError(langBup::_('Please enter activation key')); } } else { $this->pushError(langBup::_('Empty plugin name')); } }
/** * Remove Action */ public function removeAction() { $request = reqBup::get('post'); $response = new responseBup(); $model = $this->getModel(); if ($model->remove($request['filename']) === true) { $response->addMessage(langBup::_('Backup successfully removed')); } else { $response->addError(langBup::_('Unable to delete backup')); } $response->ajaxExec(); }
<div class="bupMargDest"> <?php echo htmlBup::radiobutton('dest_opt', array('attrs' => 'class="' . $not_piad . '"', 'value' => 'amazon', 'checked' => frameBup::_()->getModule('options')->get('glb_dest') == 'amazon' ? 'checked' : '')); ?> Amazon S3 </div> <div class="bupMargDest"> <?php echo htmlBup::radiobutton('dest_opt', array('attrs' => 'class="' . $not_piad . '"', 'value' => 'onedrive', 'checked' => frameBup::_()->getModule('options')->get('glb_dest') == 'onedrive' ? 'checked' : '')); ?> Microsoft OneDrive </div> <div> <?php echo htmlBup::hidden('reqType', array('value' => 'ajax')); ?> <?php echo htmlBup::hidden('page', array('value' => 'options')); ?> <?php echo htmlBup::hidden('action', array('value' => 'saveMainFromDestGroup')); ?> <?php echo htmlBup::submit('saveAll', array('value' => langBup::_('Save'), 'attrs' => 'class="button button-primary button-large"')); ?> </div> <div id="bupMainFormOptionsMsg"></div> </form> </div>
<img id="cspOptLogoImgPrev" src="<?php echo $this->optModel->isEmpty('logo_image') ? '' : frameBup::_()->getModule('options')->getLogoImgFullPath(); ?> " style="max-width: 200px;" /> </div> <div class="cspRightCol"> <div class="cspTip cspTipArrowLeft nomargin"> <?php langBup::_e('Choose your logo, you can use png, jpg or gif image file.'); ?> <span class="cspTipCorner"></span> </div> <br /> <div class="cspTip cspTipArrowDown nomargin"> <?php langBup::_e('You can use default logo, your own or disable it. To disable logo on Coming Soon page click "Remove image" button bellow.'); ?> <span class="cspTipCorner"></span> </div> <br /> <?php echo htmlBup::button(array('value' => langBup::_('Remove image'), 'attrs' => 'id="cspLogoRemove" class="button button-large" style="width:100%;"')); ?> <?php echo htmlBup::button(array('value' => langBup::_('Set default'), 'attrs' => 'id="cspLogoSetDefault" class="button button-large" style="width:100%;"')); ?> <div id="cspAdminOptLogoDefaultMsg"></div> </div> <div class="clearfix"></div>
foreach ($formData as $key => $val) { if (is_array($val)) { foreach ($val as $subKey => $subVal) { echo htmlBup::hidden($key . '[' . $subKey . ']', array('value' => $subVal)); } } else { echo htmlBup::hidden($key, array('value' => $val)); } } ?> <table width="100%"> <tr> <td><?php langBup::_e('Delete Plugin Data (options, setup data, database tables, etc.)'); ?> :</td> <td><?php echo htmlBup::radiobuttons('deleteOptions', array('options' => array('No', 'Yes'))); ?> </td> </tr> </table> <?php echo htmlBup::submit('toeGo', array('value' => langBup::_('Done'))); ?> <?php echo htmlBup::formEnd(); ?> </div> </body> </html>
/** * Show messages at the top of the page. This is kinda weird way to do this, * but WP gives me no other way to do this - no action or hook right after body tag opening or somwere around this place */ public function checkSysMessages() { $messages = array(); if (is_404() && frameBup::_()->getModule('user')->isAdmin()) { $messages['adminAlerts'][] = langBup::_(array('If you are trying to view your product and see this message - maybe you have some troubles with permalinks settings.', 'Try to go to <a href="' . get_admin_url() . 'options-permalink.php' . '">Admin panel -> Settings -> Permalinks</a> and re-saive this settings (just click on "Save Changes").<br />', '<a href="http://readyshoppingcart.com/faq/ecommerce-plugin-alerts">', 'Please check FAQ.', '</a>')); } if (!empty($messages)) { $this->getView()->assign('forAdminOnly', langBup::_('This message will be visible for admin only.')); $this->getView()->assign('messages', $messages); $this->getView()->display('pagesSystemMessages'); } }
/** * Return last error * @return string error message */ public function getError() { return langBup::_($this->_error); }
/** * Run parsed queries from SQL file * @global \wpdb $wpdb * @param array $queries * @return boolean */ protected function runQueries($queries = array()) { /** @var wpdb $wpdb */ global $wpdb; $config = $this->getConfig(); $transaction = $this->getTransactionSupport(); if (empty($queries) or $queries === null) { return false; } // Start transaction if safe update enabled or set error if transaction is unsupported if ($config['safe_update'] === true) { if ($transaction === true) { $this->query('SET AUTOCOMMIT=0'); $this->query('START TRANSACTION'); } else { $this->pushError(langBup::_('Your MySQL server does not support transactions, "safe update" unavailable')); return false; } } $this->query('SET FOREIGN_KEY_CHECKS=0'); foreach ($queries as $query) { if ($wpdb->query($query) === false) { // Rollback transaction if safe update enabled if ($config['safe_update'] === true && $transaction === true) { $this->query('ROLLBACK'); } $this->query('SET FOREIGN_KEY_CHECKS=1'); return false; } } // Commit transaction if safe update enabled if ($config['safe_update'] === true && $transaction === true) { $this->query('COMMIT'); } $this->query('SET FOREIGN_KEY_CHECKS=1', $wpdb->dbh); return true; }
public static function activate($modDataArr) { $locations = self::_getPluginLocations(); if ($modules = self::_getModulesFromXml($locations['xmlPath'])) { foreach ($modules as $m) { $modDataArr = utilsBup::xmlNodeAttrsToArr($m); if (!frameBup::_()->moduleActive($modDataArr['code'])) { //If module is not active - then acivate it if (frameBup::_()->getModule('options')->getModel('modules')->put(array('code' => $modDataArr['code'], 'active' => 1))->error) { errorsBup::push(langBup::_('Error Activating module'), errorsBup::MOD_INSTALL); } } } } }
<script type="text/javascript"> // <!-- jQuery(document).ready(function(){ jQuery('#toePagesRecreate').click(function(){ jQuery(this).sendForm({ msgElID: 'toePagesOptionsMsg', data: {page: 'pagesBup', action: 'recreatePages', reqType: 'ajax'} }); return false; }); }); // --> </script> <h1><?php langBup::_e('Pages Options'); ?> </h1> <table> <tr> <td><?php echo htmlBup::inputButton(array('value' => langBup::_('Recreate Pages'), 'attrs' => 'id="toePagesRecreate"')); ?> </td> <td><a href="#" class="toeOptTip" tip="<?php langBup::_e('If you accidently deleted one of plugin page - Login, or Checkout, or Shopping cart for example, just click on this button - and pages, that you deleted, will be created again. Do not use it without emergency.'); ?> "></a></td> </tr> </table> <div id="toePagesOptionsMsg"></div>
/** * Displays the config options for given module * * @param string $module * @param array $addDefaultOptions - if you want to add some additionsl options - specify it here */ public function drawConfig($module, $additionalOptions = array()) { if (!frameBup::_()->getModule($module)) { return false; } // check for xml file with params structure if (frameBup::_()->getModule($module)->isExternal()) { $config_xml = frameBup::_()->getModule($module)->getModDir() . 'mod.xml'; } else { $config_xml = BUP_MODULES_DIR . $module . DS . 'mod.xml'; } if (!file_exists($config_xml)) { // if there is no configuration file for this $module return langBup::_('There are no configuration options for this module'); } $output = ''; // reading params structure $configOptions = $this->prepareConfigOptions($config_xml); // reading params from database //bugodel2nia.............. if (is_string($this->value)) { $params = Utils::jsonDecode($this->value); } elseif (is_object($this->value) || is_array($this->value)) { $params = toeObjectToArray($this->value); } //if (!empty($params)) { if (!empty($configOptions)) { $i = 0; if (empty($params)) { $params = array('0' => array()); } if (is_array($additionalOptions) && !empty($additionalOptions)) { $configOptions = array_merge($configOptions, $additionalOptions); } foreach ($params as $param) { $output .= '<div class="module_options">'; foreach ($configOptions as $key => $value) { $fieldValue = ''; $output .= '<div class="module_option">'; $method = $configOptions[$key]['type']; $name = 'params[' . $i . '][' . $key . ']'; $options = array(); // if the values attribute is set if ($configOptions[$key]['values'] != '') { $extract_options = explode(',', $configOptions[$key]['values']); if (count($extract_options) > 1) { foreach ($extract_options as $item => $string) { if (strpos($string, '=>')) { $keyVal = array_map('trim', explode('=>', $string)); $options[$keyVal[0]] = $keyVal[1]; } else { $options[$string] = $string; } } } else { $fieldValue = $configOptions[$key]['default']; } // if helper is needed to render the object } elseif ($configOptions[$key]['helper'] != '') { $helper_name = $configOptions[$key]['helper']; // is helper from current module or other? if ($configOptions[$key]['module'] != '') { $hmodule = $configOptions[$key]['module']; } else { $hmodule = $module; } // calling the helper class $helper = frameBup::_()->getModule($hmodule)->getHelper(); if ($helper) { // calling the helper method for current option if (method_exists($helper, $helper_name)) { $options = $helper->{$helper_name}(); } } } if (isset($param[$key])) { $fieldValue = $param[$key]; } else { if ($fieldValue == '') { $fieldValue = $configOptions[$key]['default']; } } // filling the parameters to build html element $htmlParams = array('value' => $fieldValue, 'optionsBup' => $options); if ($method == 'checkbox') { $htmlParams['value'] = 1; $htmlParams['checked'] = (bool) $fieldValue; } if (!empty($configOptions[$key]['htmlParams']) && is_array($configOptions[$key]['htmlParams'])) { $htmlParams = array_merge($htmlParams, $configOptions[$key]['htmlParams']); } // output label and html element $output .= '<label>' . langBup::_($configOptions[$key]['label']); if ($configOptions[$key]['description'] != '') { $output .= '<a class="toeOptTip" tip="' . langBup::_($configOptions[$key]['description']) . '"></a>'; } $output .= '</label><br />'; $output .= htmlBup::$method($name, $htmlParams) . '<br />'; $output .= '</div>'; } $i++; $output .= '</div>'; } } return $output; }
<?php foreach ($this->storageData[2] as $el) { ?> <?php $name = frameBup::_()->getModule('backup')->getModel()->fileNameFormat($el, 'prefix'); $name = $name == 'full' && preg_match('~\\.sql~', $el) ? 'database' : $name; //if ($name == 'full' && preg_match('~\.sql~', $el)) continue; ?> <tr class="tabStr"> <td align="right" style="height:20px !important; margin:0px !important; padding:0px !important; " ><?php echo ucfirst($name); ?> </td> <td width="162"> <?php echo htmlBup::submit($el, array('value' => langBup::_('Restore'), 'attrs' => 'class="button button-primary button-small restoreBup" id="' . $this->storageData[0] . '"')); ?> <a class="button button-primary button-small bupButDownload" href="<?php echo substr(BUP_URL, 0, strlen(BUP_URL) - 1) . frameBup::_()->getModule('options')->get('warehouse') . $el; ?> " title="download">Download</a> <a class="delBackup" id="del|<?php echo $this->storageData[0] . '|' . $el, '|' . $name; ?> " href="javascript:void (0)" title="delete"></a> </td> </tr> <?php } ?> </table> </fieldset>
?> :</h4> <?php echo htmlBup::textarea('opt_values[msg_text]', array('value' => $this->optModel->get('msg_text'))); ?> <div class="cspLeftCol"> <?php langBup::_e('Select color'); ?> : <?php echo htmlBup::colorpicker('opt_values[msg_text_color]', array('value' => $this->optModel->get('msg_text_color'))); ?> </div> <div class="cspRightCol"> <?php langBup::_e('Select font'); ?> : <?php echo htmlBup::fontsList('opt_values[msg_text_font]', array('value' => $this->optModel->get('msg_text_font'))); ?> </div> <div class="clearfix"></div> <div class="clearfix"> <?php echo htmlBup::button(array('value' => langBup::_('Set default'), 'attrs' => 'id="cspMsgTextSetDefault"')); ?> <div id="cspAdminOptMsgTextDefaultMsg"></div> </div> <div class="clearfix"></div>