<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); //if valid then do save if ($_POST['p_description'] != "") { include "./modules/preferences/save.php"; } #get the invoice id $preference_id = $_GET['id']; $preference = getPreference($preference_id); $index_group = getPreference($preference['index_group']); $preferences = getActivePreferences(); $defaults = getSystemDefaults(); $status = array(array('id' => '0', 'status' => $LANG['draft']), array('id' => '1', 'status' => $LANG['real'])); $smarty->assign('preference', $preference); $smarty->assign('defaults', $defaults); $smarty->assign('index_group', $index_group); $smarty->assign('preferences', $preferences); $smarty->assign('status', $status); $smarty->assign('pageActive', 'preference'); $subPageActive = $_GET['action'] == "view" ? "preferences_view" : "preferences_edit"; $smarty->assign('subPageActive', $subPageActive); $smarty->assign('active_tab', '#setting');
function updateTwitterFeed($lastupdate) { // Twitter! global $preferences; global $twit; require_once 'oauth/twitteroauth.php'; $twit = new TwitterOAuth($preferences->CONSUMER_KEY, $preferences->CONSUMER_SECRET_KEY, $preferences->OAUTH_TOKEN, $preferences->OAUTH_SECRET_TOKEN); // Update the following/followed balance updateTwitterFollowing(); // Update user information for those who require it updateTwitterUsers(); // Get mentions since the last update $args = array(); $lastreadid = getPreference("last_twitter_id"); if ($lastreadid) { $args['since_id'] = $lastreadid; } $tweets = $twit->get('statuses/mentions_timeline', $args); // if we have no tweets, stop here if (!is_array($tweets)) { loginfo("No tweets to read!"); return false; } // process tweets individually uasort($tweets, 'cmpTweetId'); foreach ($tweets as $tweet) { $lastreadid = processTweet($tweet); } // Save the last updated tweet id setPreference("last_twitter_id", $lastreadid); return true; }
public function insert() { //insert in si_invoice global $db_server; $sql = "INSERT \n\t\t\t\tINTO\n\t\t\t" . TB_PREFIX . "invoices (\n\t\t\t\tid, \n\t\t \t\tindex_id,\n\t\t\t\tdomain_id,\n\t\t\t\tbiller_id, \n\t\t\t\tcustomer_id, \n\t\t\t\ttype_id,\n\t\t\t\tpreference_id, \n\t\t\t\tdate, \n\t\t\t\tnote,\n\t\t\t\tcustom_field1,\n\t\t\t\tcustom_field2,\n\t\t\t\tcustom_field3,\n\t\t\t\tcustom_field4\n\t\t\t)\n\t\t\tVALUES\n\t\t\t(\n\t\t\t\tNULL,\n\t\t\t\t:index_id,\n\t\t\t\t:domain_id,\n\t\t\t\t:biller_id,\n\t\t\t\t:customer_id,\n\t\t\t\t:type_id,\n\t\t\t\t:preference_id,\n\t\t\t\t:date,\n\t\t\t\t:note,\n\t\t\t\t:custom_field1,\n\t\t\t\t:custom_field2,\n\t\t\t\t:custom_field3,\n\t\t\t\t:custom_field4\n\t\t\t\t)"; $pref_group = getPreference($this->preference_id, $this->domain_id); $sth = dbQuery($sql, ':index_id', index::next('invoice', $pref_group['index_group'], $this->domain_id), ':domain_id', $this->domain_id, ':biller_id', $this->biller_id, ':customer_id', $this->customer_id, ':type_id', $this->type_id, ':preference_id', $this->preference_id, ':date', $this->date, ':note', trim($this->note), ':custom_field1', $this->custom_field1, ':custom_field2', $this->custom_field2, ':custom_field3', $this->custom_field3, ':custom_field4', $this->custom_field4); #index::increment('invoice',$pref_group['index_group'], $domain_id,$this->biller_id); index::increment('invoice', $pref_group['index_group'], $this->domain_id); return lastInsertID(); }
dots = ''; if(description.length > 80){ dots = '...'; } var plugins_downloaded = <?php $plugins_downloaded = getPreference('plugins_downloaded'); if ($plugins_downloaded != '') { echo $plugins_downloaded; } else { echo 'new Array()'; } ?> ; var plugin_to_update = <?php echo getPreference('plugins_to_update'); ?> ; var button = ''; if(jQuery.inArray(data.plugins[i].s_update_url, plugins_downloaded) >= 0 ) { if( jQuery.inArray(data.plugins[i].s_update_url, plugin_to_update) >= 0 ) { button = '<a href="#'+data.plugins[i].s_update_url+'" class="btn btn-mini btn-orange market-popup market_update"><?php echo osc_esc_js(__('Update')); ?> </a>'; } else { button = '<a href="#" class="btn btn-mini btn-blue btn-disabled" ><?php echo osc_esc_js(__('Already downloaded')); ?> </a>';
/** * Return subdomain host * * @return string */ function osc_subdomain_host() { return getPreference('subdomain_host'); }
function bender_default_show_as() { return getPreference('defaultShowAs@all', 'bender'); }
function getUpdateNames($count = 100) { // where did we start off? $lastindex = getPreference("last_userupdate_index"); // return those rows global $link; /* echo "SELECT UserName FROM Participants LIMIT ".$lastindex." ".$count ; */ /* $namesresult = mysqli_query($link, "SELECT UserName FROM Participants */ /* LIMIT ".$lastindex.", ".$count) */ /* or die(__FILE__.__LINE__.mysqli_error($link)); */ // echo "SELECT UserName FROM Participants LIMIT ".$lastindex." ".$count . "\n" ; $namesresult = mysqli_query($link, "SELECT UserName FROM Participants \n LIMIT " . $lastindex . ", " . $count) or die(__FILE__ . __LINE__ . mysqli_error($link)); $namearray = array(); while ($namerow = mysqli_fetch_assoc($namesresult)) { $namearray[] = $namerow['UserName']; } // how many rows, if we need to wrap $countresult = mysqli_query($link, "SELECT COUNT(*) FROM Participants") or die(__FILE__ . __LINE__ . mysqli_error($link)); $totalcount = mysqli_fetch_array($countresult); $lastindex += $count; if ($lastindex >= $totalcount[0]) { $lastindex = 0; } // Save the last updated index (wrapping if necessary) setPreference("last_userupdate_index", $lastindex); return $namearray; }
var description = $(data.themes[i].s_description).text(); dots = ''; if(description.length > 80){ dots = '...'; } var themes_downloaded = <?php $themes_downloaded = getPreference('themes_downloaded'); if ($themes_downloaded != '') { echo $themes_downloaded; } else { echo 'new Array()'; } ?> ; var themes_to_update = <?php echo getPreference('themes_to_update'); ?> ; var button = ''; if(jQuery.inArray(data.themes[i].s_update_url, themes_downloaded) >= 0 ) { if( jQuery.inArray(data.themes[i].s_update_url, themes_to_update) >= 0 ) { button = '<a href="#'+data.themes[i].s_update_url+'" class="btn btn-mini btn-orange market-popup market_update"><?php echo osc_esc_js(__('Update')); ?> </a>'; } else { button = '<a href="#" class="btn btn-mini btn-disabled" ><?php echo osc_esc_js(__('Already downloaded')); ?> </a>';
<option value='0'> </option> EOD; foreach ($taxes as $tax) { $selected = $tax['tax_id'] == $defaults['tax'] ? "selected style='font-weight: bold'" : ""; $escaped = htmlsafe($tax['tax_description']); $display_block_tax .= <<<EOD \t\t\t<option {$selected} value="{$tax['tax_id']}">{$escaped}</option> EOD; } } $description = "{$LANG['tax']}"; $value = $display_block_tax; } else { if ($_GET["submit"] == "preference_id") { $pref = getPreference($defaults['preference']); $preferences = getActivePreferences(); if ($preferences == null) { //no records $display_block_preferences = "<p><em>{$LANG['no_preferences']}</em></p>"; } else { $default = "preference"; //has records, so display them $display_block_preferences = <<<EOD \t <select name="value"> <option value='0'> </option> EOD; foreach ($preferences as $preference) { $selected = $preference['pref_id'] == $defaults['preference'] ? "selected style='font-weight: bold'" : ""; $escaped = htmlsafe($preference['pref_description']);
function doModel() { parent::doModel(); //specific things for this class switch ($this->action) { case 'add': $this->doView("plugins/add.php"); break; case 'add_post': if (defined('DEMO')) { osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); } osc_csrf_check(); $package = Params::getFiles("package"); if (isset($package['size']) && $package['size'] != 0) { $path = osc_plugins_path(); (int) ($status = osc_unzip_file($package['tmp_name'], $path)); } else { $status = 3; } switch ($status) { case 0: $msg = _m('The plugin folder is not writable'); osc_add_flash_error_message($msg, 'admin'); break; case 1: $msg = _m('The plugin has been uploaded correctly'); osc_add_flash_ok_message($msg, 'admin'); break; case 2: $msg = _m('The zip file is not valid'); osc_add_flash_error_message($msg, 'admin'); break; case 3: $msg = _m('No file was uploaded'); osc_add_flash_error_message($msg, 'admin'); $this->redirectTo(osc_admin_base_url(true) . "?page=plugins&action=add"); break; case -1: default: $msg = _m('There was a problem adding the plugin'); osc_add_flash_error_message($msg, 'admin'); break; } $this->redirectTo(osc_admin_base_url(true) . "?page=plugins"); break; case 'install': if (defined('DEMO')) { osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); } osc_csrf_check(); $pn = Params::getParam('plugin'); // set header just in case it's triggered some fatal error header("Location: " . osc_admin_base_url(true) . "?page=plugins&error=" . $pn, true, '302'); $installed = Plugins::install($pn); if (is_array($installed)) { switch ($installed['error_code']) { case 'error_output': osc_add_flash_error_message(sprintf(_m('The plugin generated %d characters of <strong>unexpected output</strong> during the installation'), strlen($installed['output'])), 'admin'); break; case 'error_installed': osc_add_flash_error_message(_m('Plugin is already installed'), 'admin'); break; case 'error_file': osc_add_flash_error_message(_m("Plugin couldn't be installed because their files are missing"), 'admin'); break; case 'custom_error': osc_add_flash_error_message(sprintf(_m("Plugin couldn't be installed because of: %s"), $installed['msg']), 'admin'); break; default: osc_add_flash_error_message(_m("Plugin couldn't be installed"), 'admin'); break; } } else { osc_add_flash_ok_message(_m('Plugin installed'), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); break; case 'uninstall': if (defined('DEMO')) { osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); } osc_csrf_check(); if (Plugins::uninstall(Params::getParam("plugin"))) { osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin'); } else { osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); break; case 'enable': if (defined('DEMO')) { osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); } osc_csrf_check(); if (Plugins::activate(Params::getParam('plugin'))) { osc_add_flash_ok_message(_m('Plugin enabled'), 'admin'); } else { osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); break; case 'disable': if (defined('DEMO')) { osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); } osc_csrf_check(); if (Plugins::deactivate(Params::getParam('plugin'))) { osc_add_flash_ok_message(_m('Plugin disabled'), 'admin'); } else { osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=plugins'); break; case 'admin': $plugin = Params::getParam("plugin"); if ($plugin != "") { Plugins::runHook($plugin . '_configure'); } break; case 'admin_post': Plugins::runHook('admin_post'); break; case 'renderplugin': $file = Params::getParam("file"); if ($file != "") { // We pass the GET variables (in case we have somes) if (preg_match('|(.+?)\\?(.*)|', $file, $match)) { $file = $match[1]; if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) { for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) { //$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k]; //$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k]; Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]); } } } else { $file = $_REQUEST['file']; } $this->_exportVariableToView("file", osc_plugins_path() . $file); //osc_renderPluginView($file); $this->doView("plugins/view.php"); } break; case 'configure': $plugin = Params::getParam("plugin"); if ($plugin != '') { $plugin_data = Plugins::getInfo($plugin); $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll()); $this->_exportVariableToView("selected", PluginCategory::newInstance()->listSelected($plugin_data['short_name'])); $this->_exportVariableToView("plugin_data", $plugin_data); $this->doView("plugins/configuration.php"); } else { $this->redirectTo(osc_admin_base_url(true) . "?page=plugins"); } break; case 'configure_post': osc_csrf_check(); $plugin_short_name = Params::getParam("plugin_short_name"); $categories = Params::getParam("categories"); if ($plugin_short_name != "") { Plugins::cleanCategoryFromPlugin($plugin_short_name); if (isset($categories)) { Plugins::addToCategoryPlugin($categories, $plugin_short_name); } osc_add_flash_ok_message(_m('Configuration was saved'), 'admin'); $this->redirectTo(osc_get_http_referer()); } osc_add_flash_error_message(_m('No plugin selected'), 'admin'); $this->doView('plugins/index.php'); break; case 'error_plugin': // force php errors and simulate plugin installation to show the errors in the iframe if (!OSC_DEBUG) { error_reporting(E_ALL | E_STRICT); } @ini_set('display_errors', 1); include osc_plugins_path() . Params::getParam('plugin'); Plugins::install(Params::getParam('plugin')); exit; break; default: // $marketError = Params::getParam('marketError'); // $slug = Params::getParam('slug'); // if($marketError!='') { // if($marketError == '0') { // no error installed ok // $extra = '<br/><br/><b>' . __('You only need to install and configure the plugin.') . '</b>'; // osc_add_flash_ok_message( __('Everything was OK!') . ' ( ' . $slug . ' ) ' . $extra , 'admin'); // } else { // osc_add_flash_error_message( __('Error occurred') . ' ' . $slug , 'admin'); // } // } if (Params::getParam('checkUpdated') != '') { osc_admin_toolbar_update_plugins(true); } if (Params::getParam('iDisplayLength') == '') { Params::setParam('iDisplayLength', 10); } // ? $this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength')); $p_iPage = 1; if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') >= 1) { $p_iPage = Params::getParam('iPage'); } Params::setParam('iPage', $p_iPage); $aPlugin = Plugins::listAll(); $active_plugins = osc_get_plugins(); // pagination $start = ($p_iPage - 1) * Params::getParam('iDisplayLength'); $limit = Params::getParam('iDisplayLength'); $count = count($aPlugin); $displayRecords = $limit; if ($start + $limit > $count) { $displayRecords = $start + $limit - $count; } // -------------------------------------------------------- $aData = array(); $aInfo = array(); $max = $start + $limit; if ($max > $count) { $max = $count; } $aPluginsToUpdate = json_decode(getPreference('plugins_to_update')); $bPluginsToUpdate = is_array($aPluginsToUpdate) ? true : false; for ($i = $start; $i < $max; $i++) { $plugin = $aPlugin[$i]; $row = array(); $pInfo = osc_plugin_get_info($plugin); // prepare row 1 $installed = 0; if (osc_plugin_is_installed($plugin)) { $installed = 1; } $enabled = 0; if (osc_plugin_is_enabled($plugin)) { $enabled = 1; } // prepare row 2 $sUpdate = ''; // get plugins to update from t_preference if ($bPluginsToUpdate) { if (in_array(@$pInfo['plugin_update_uri'], $aPluginsToUpdate)) { $sUpdate = '<a class="market_update market-popup" href="#' . htmlentities($pInfo['plugin_update_uri']) . '">' . __("There's a new update available") . '</a>'; } } // prepare row 4 $sConfigure = ''; if (isset($active_plugins[$plugin . '_configure'])) { $sConfigure = '<a href="' . osc_admin_base_url(true) . '?page=plugins&action=admin&plugin=' . $pInfo['filename'] . "&" . osc_csrf_token_url() . '">' . __('Configure') . '</a>'; } // prepare row 5 $sEnable = ''; if ($installed) { if ($enabled) { $sEnable = '<a href="' . osc_admin_base_url(true) . '?page=plugins&action=disable&plugin=' . $pInfo['filename'] . "&" . osc_csrf_token_url() . '">' . __('Disable') . '</a>'; } else { $sEnable = '<a href="' . osc_admin_base_url(true) . '?page=plugins& action=enable&plugin=' . $pInfo['filename'] . "&" . osc_csrf_token_url() . '">' . __('Enable') . '</a>'; } } // prepare row 6 $sInstall = ''; if ($installed) { $sInstall = '<a onclick="javascript:return uninstall_dialog(\'' . $pInfo['filename'] . '\');" href="' . osc_admin_base_url(true) . '?page=plugins&action=uninstall& plugin=' . $pInfo['filename'] . "&" . osc_csrf_token_url() . '">' . __('Uninstall') . '</a>'; } else { $sInstall = '<a href="' . osc_admin_base_url(true) . '?page=plugins& action=install&plugin=' . $pInfo['filename'] . "&" . osc_csrf_token_url() . '">' . __('Install') . '</a>'; } $row[] = '<input type="hidden" name="installed" value="' . $installed . '" enabled="' . $enabled . '" />' . $pInfo['plugin_name'] . '<div>' . $sUpdate . '</div>'; $row[] = $pInfo['description']; $row[] = $sUpdate != '' ? $sUpdate : ' '; $row[] = $sConfigure != '' ? $sConfigure : ' '; $row[] = $sEnable != '' ? $sEnable : ' '; $row[] = $sInstall != '' ? $sInstall : ' '; $aData[] = $row; if (@$pInfo['plugin_update_uri'] != '') { $aInfo[@$pInfo['plugin_update_uri']] = $pInfo; } else { $aInfo[$i] = $pInfo; } } $array['iTotalRecords'] = $displayRecords; $array['iTotalDisplayRecords'] = count($aPlugin); $array['iDisplayLength'] = $limit; $array['aaData'] = $aData; $array['aaInfo'] = $aInfo; // -------------------------------------------------------- $page = (int) Params::getParam('iPage'); if (count($array['aaData']) == 0 && $page != 1) { $total = (int) $array['iTotalDisplayRecords']; $maxPage = ceil($total / (int) $array['iDisplayLength']); $url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING']; if ($maxPage == 0) { $url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url); $this->redirectTo($url); } if ($page > 1) { $url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url); $this->redirectTo($url); } } $this->_exportVariableToView('aPlugins', $array); $this->doView("plugins/index.php"); break; } }
function osc_check_themes_update($force = false) { $total = 0; $array = array(); $array_downloaded = array(); // check if exist a new version each day if (time() - osc_themes_last_version_check() > 24 * 3600 || $force) { $themes = WebThemes::newInstance()->getListThemes(); foreach ($themes as $theme) { $info = WebThemes::newInstance()->loadThemeInfo($theme); if (osc_check_theme_update(@$info['theme_update_uri'], @$info['version'])) { $array[] = $theme; $total++; } $array_downloaded[] = @$info['theme_update_uri']; } osc_set_preference('themes_to_update', json_encode($array)); osc_set_preference('themes_downloaded', json_encode($array_downloaded)); osc_set_preference('themes_update_count', $total); osc_set_preference('themes_last_version_check', time()); osc_reset_preferences(); } else { $total = getPreference('themes_update_count'); } return $total; }
function osc_get_preference($key, $section = 'osclass') { return getPreference($key, $section); }
function doModel() { switch ($this->action) { case 'add': // caliing add view $this->doView('languages/add.php'); break; case 'add_post': // adding a new language if (defined('DEMO')) { osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } osc_csrf_check(); $filePackage = Params::getFiles('package'); if (isset($filePackage['size']) && $filePackage['size'] != 0) { $path = osc_translations_path(); (int) ($status = osc_unzip_file($filePackage['tmp_name'], $path)); } else { $status = 3; } switch ($status) { case 0: $msg = _m('The translation folder is not writable'); osc_add_flash_error_message($msg, 'admin'); break; case 1: if (osc_checkLocales()) { $msg = _m('The language has been installed correctly'); osc_add_flash_ok_message($msg, 'admin'); } else { $msg = _m('There was a problem adding the language'); osc_add_flash_error_message($msg, 'admin'); } break; case 2: $msg = _m('The zip file is not valid'); osc_add_flash_error_message($msg, 'admin'); break; case 3: $msg = _m('No file was uploaded'); osc_add_flash_warning_message($msg, 'admin'); $this->redirectTo(osc_admin_base_url(true) . "?page=languages&action=add"); break; case -1: default: $msg = _m('There was a problem adding the language'); osc_add_flash_error_message($msg, 'admin'); break; } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; case 'edit': // editing a language $sLocale = Params::getParam('id'); if (!preg_match('/.{2}_.{2}/', $sLocale)) { osc_add_flash_error_message(_m('Language id isn\'t in the correct format'), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } $aLocale = $this->localeManager->findByPrimaryKey($sLocale); if (count($aLocale) == 0) { osc_add_flash_error_message(_m('Language id doesn\'t exist'), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } $this->_exportVariableToView("aLocale", $aLocale); $this->doView('languages/frm.php'); break; case 'edit_post': // edit language post osc_csrf_check(); $iUpdated = 0; $languageCode = Params::getParam('pk_c_code'); $enabledWebstie = Params::getParam('b_enabled'); $enabledBackoffice = Params::getParam('b_enabled_bo'); $languageName = Params::getParam('s_name'); $languageShortName = Params::getParam('s_short_name'); $languageDescription = Params::getParam('s_description'); $languageCurrencyFormat = Params::getParam('s_currency_format'); $languageDecPoint = Params::getParam('s_dec_point'); $languageNumDec = Params::getParam('i_num_dec'); $languageThousandsSep = Params::getParam('s_thousands_sep'); $languageDateFormat = Params::getParam('s_date_format'); $languageStopWords = Params::getParam('s_stop_words'); // formatting variables if (!preg_match('/.{2}_.{2}/', $languageCode)) { osc_add_flash_error_message(_m('Language id isn\'t in the correct format'), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } $enabledWebstie = $enabledWebstie != '' ? true : false; $enabledBackoffice = $enabledBackoffice != '' ? true : false; $languageName = strip_tags($languageName); $languageName = trim($languageName); $languageShortName = strip_tags($languageShortName); $languageShortName = trim($languageShortName); $languageDescription = strip_tags($languageDescription); $languageDescription = trim($languageDescription); $languageCurrencyFormat = strip_tags($languageCurrencyFormat); $languageCurrencyFormat = trim($languageCurrencyFormat); $languageDateFormat = strip_tags($languageDateFormat); $languageDateFormat = trim($languageDateFormat); $languageStopWords = strip_tags($languageStopWords); $languageStopWords = trim($languageStopWords); $msg = ''; if (!osc_validate_text($languageName)) { $msg .= _m("Language name field is required") . "<br/>"; } if (!osc_validate_text($languageShortName)) { $msg .= _m("Language short name field is required") . "<br/>"; } if (!osc_validate_text($languageDescription)) { $msg .= _m("Language description field is required") . "<br/>"; } if (!osc_validate_text($languageCurrencyFormat)) { $msg .= _m("Currency format field is required") . "<br/>"; } if (!osc_validate_int($languageNumDec)) { $msg .= _m("Number of decimals must only contain numeric characters") . "<br/>"; } if ($msg != '') { osc_add_flash_error_message($msg, 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages&action=edit&id=' . $languageCode); } $array = array('b_enabled' => $enabledWebstie, 'b_enabled_bo' => $enabledBackoffice, 's_name' => $languageName, 's_short_name' => $languageShortName, 's_description' => $languageDescription, 's_currency_format' => $languageCurrencyFormat, 's_dec_point' => $languageDecPoint, 'i_num_dec' => $languageNumDec, 's_thousands_sep' => $languageThousandsSep, 's_date_format' => $languageDateFormat, 's_stop_words' => $languageStopWords); $iUpdated = $this->localeManager->update($array, array('pk_c_code' => $languageCode)); if ($iUpdated > 0) { osc_add_flash_ok_message(sprintf(_m('%s has been updated'), $languageShortName), 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; case 'enable_selected': osc_csrf_check(); $msg = _m('Selected languages have been enabled for the website'); $iUpdated = 0; $aValues = array('b_enabled' => 1); $id = Params::getParam('id'); if (!is_array($id)) { osc_add_flash_warning_message(_m("The language ids aren't in the correct format"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } foreach ($id as $i) { $iUpdated += $this->localeManager->update($aValues, array('pk_c_code' => $i)); } if ($iUpdated > 0) { osc_add_flash_ok_message($msg, 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; case 'disable_selected': osc_csrf_check(); $msg = _m('Selected languages have been disabled for the website'); $msg_warning = ''; $iUpdated = 0; $aValues = array('b_enabled' => 0); $id = Params::getParam('id'); if (!is_array($id)) { osc_add_flash_warning_message(_m("The language ids aren't in the correct format"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } foreach ($id as $i) { if (osc_language() == $i) { $msg_warning = sprintf(_m("%s can't be disabled because it's the default language"), osc_language()); continue; } $iUpdated += $this->localeManager->update($aValues, array('pk_c_code' => $i)); } if ($msg_warning != '') { if ($iUpdated > 0) { osc_add_flash_warning_message($msg . '</p><p>' . $msg_warning, 'admin'); } else { osc_add_flash_warning_message($msg_warning, 'admin'); } } else { osc_add_flash_ok_message($msg, 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; case 'enable_bo_selected': osc_csrf_check(); $msg = _m('Selected languages have been enabled for the backoffice (oc-admin)'); $iUpdated = 0; $aValues = array('b_enabled_bo' => 1); $id = Params::getParam('id'); if (!is_array($id)) { osc_add_flash_warning_message(_m("The language ids aren't in the correct format"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } foreach ($id as $i) { $iUpdated += $this->localeManager->update($aValues, array('pk_c_code' => $i)); } if ($iUpdated > 0) { osc_add_flash_ok_message($msg, 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; case 'disable_bo_selected': osc_csrf_check(); $msg = _m('Selected languages have been disabled for the backoffice (oc-admin)'); $msg_warning = ''; $iUpdated = 0; $aValues = array('b_enabled_bo' => 0); $id = Params::getParam('id'); if (!is_array($id)) { osc_add_flash_warning_message(_m("The language ids aren't in the correct format"), 'admin'); $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); } foreach ($id as $i) { if (osc_language() == $i) { $msg_warning = sprintf(_m("%s can't be disabled because it's the default language"), osc_language()); continue; } $iUpdated += $this->localeManager->update($aValues, array('pk_c_code' => $i)); } if ($msg_warning != '') { if ($iUpdated > 0) { osc_add_flash_warning_message($msg . '</p><p>' . $msg_warning, 'admin'); } else { osc_add_flash_warning_message($msg_warning, 'admin'); } } else { osc_add_flash_ok_message($msg, 'admin'); } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; case 'delete': osc_csrf_check(); if (is_array(Params::getParam('id'))) { $default_lang = osc_language(); foreach (Params::getParam('id') as $code) { if ($default_lang != $code) { if ($this->localeManager->deleteLocale($code)) { if (!osc_deleteDir(osc_translations_path() . $code)) { osc_add_flash_error_message(sprintf(_m("Directory '%s' couldn't be removed"), $code), 'admin'); } else { osc_add_flash_ok_message(sprintf(_m('Directory "%s" has been successfully removed'), $code), 'admin'); } } else { osc_add_flash_error_message(sprintf(_m("Directory '%s' couldn't be removed;)"), $code), 'admin'); } } else { osc_add_flash_error_message(sprintf(_m("Directory '%s' couldn't be removed because it's the default language. Set another language as default first and try again"), $code), 'admin'); } } } $this->redirectTo(osc_admin_base_url(true) . '?page=languages'); break; default: if (Params::getParam('checkUpdated') != '') { osc_admin_toolbar_update_languages(true); } if (Params::getParam("action") != "") { osc_run_hook("language_bulk_" . Params::getParam("action"), Params::getParam('id')); } // ----- if (Params::getParam('iDisplayLength') == '') { Params::setParam('iDisplayLength', 10); } // ? $this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength')); $p_iPage = 1; if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') >= 1) { $p_iPage = Params::getParam('iPage'); } Params::setParam('iPage', $p_iPage); $aLanguages = OSCLocale::newInstance()->listAll(); // pagination $start = ($p_iPage - 1) * Params::getParam('iDisplayLength'); $limit = Params::getParam('iDisplayLength'); $count = count($aLanguages); $displayRecords = $limit; if ($start + $limit > $count) { $displayRecords = $start + $limit - $count; } // ---- $aLanguagesToUpdate = json_decode(getPreference('languages_to_update')); $bLanguagesToUpdate = is_array($aLanguagesToUpdate) ? true : false; // ---- $aData = array(); $max = $start + $limit; if ($max > $count) { $max = $count; } for ($i = $start; $i < $max; $i++) { $l = $aLanguages[$i]; $row = array(); $row[] = '<input type="checkbox" name="id[]" value="' . $l['pk_c_code'] . '" />'; $options = array(); $options[] = '<a href="' . osc_admin_base_url(true) . '?page=languages&action=edit&id=' . $l['pk_c_code'] . '">' . __('Edit') . '</a>'; $options[] = '<a href="' . osc_admin_base_url(true) . '?page=languages&action=' . ($l['b_enabled'] == 1 ? 'disable_selected' : 'enable_selected') . '&id[]=' . $l['pk_c_code'] . '&' . osc_csrf_token_url() . '">' . ($l['b_enabled'] == 1 ? __('Disable (website)') : __('Enable (website)')) . '</a> '; $options[] = '<a href="' . osc_admin_base_url(true) . '?page=languages&action=' . ($l['b_enabled_bo'] == 1 ? 'disable_bo_selected' : 'enable_bo_selected') . '&id[]=' . $l['pk_c_code'] . '&' . osc_csrf_token_url() . '">' . ($l['b_enabled_bo'] == 1 ? __('Disable (oc-admin)') : __('Enable (oc-admin)')) . '</a>'; $options[] = '<a onclick="return delete_dialog(\'' . $l['pk_c_code'] . '\');" href="' . osc_admin_base_url(true) . '?page=languages&action=delete&id[]=' . $l['pk_c_code'] . '&' . osc_csrf_token_url() . '">' . __('Delete') . '</a>'; $auxOptions = '<ul>' . PHP_EOL; foreach ($options as $actual) { $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL; } $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL; $sUpdate = ''; // get languages to update from t_preference if ($bLanguagesToUpdate) { if (in_array($l['pk_c_code'], $aLanguagesToUpdate)) { $sUpdate = '<a class="btn-market-update btn-market-popup" href="#' . htmlentities($l['pk_c_code']) . '">' . __("Update here") . '</a>'; } } $row[] = $l['s_name'] . $sUpdate . $actions; $row[] = $l['s_short_name']; $row[] = $l['s_description']; $row[] = $l['b_enabled'] ? __('Yes') : __('No'); $row[] = $l['b_enabled_bo'] ? __('Yes') : __('No'); $aData[] = $row; } // ---- $array['iTotalRecords'] = $displayRecords; $array['iTotalDisplayRecords'] = count($aLanguages); $array['iDisplayLength'] = $limit; $array['aaData'] = $aData; $page = (int) Params::getParam('iPage'); if (count($array['aaData']) == 0 && $page != 1) { $total = (int) $array['iTotalDisplayRecords']; $maxPage = ceil($total / (int) $array['iDisplayLength']); $url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING']; if ($maxPage == 0) { $url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url); $this->redirectTo($url); } if ($page > 1) { $url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url); $this->redirectTo($url); } } $this->_exportVariableToView('aLanguages', $array); $bulk_options = array(array('value' => '', 'data-dialog-content' => '', 'label' => __('Bulk actions')), array('value' => 'enable_selected', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected languages?'), strtolower(__('Enable (Website)'))), 'label' => __('Enable (Website)')), array('value' => 'disable_selected', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected languages?'), strtolower(__('Disable (Website)'))), 'label' => __('Disable (Website)')), array('value' => 'enable_bo_selected', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected languages?'), strtolower(__('Enable (oc-admin)'))), 'label' => __('Enable (oc-admin)')), array('value' => 'disable_bo_selected', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected languages?'), strtolower(__('Disable (oc-admin)'))), 'label' => __('Disable (oc-admin)')), array('value' => 'delete', 'data-dialog-content' => sprintf(__('Are you sure you want to %s the selected languages?'), strtolower(__('Delete'))), 'label' => __('Delete'))); $bulk_options = osc_apply_filter("language_bulk_filter", $bulk_options); $this->_exportVariableToView('bulk_options', $bulk_options); $this->doView('languages/index.php'); break; } }
function flatter_def_color() { return getPreference('defaultColor@all', 'flatter_theme'); }
function drawMarketItem($item, $color = false) { //constants $updateClass = ''; $updateData = ''; $thumbnail = false; $featuredClass = ''; $style = ''; $letterDraw = ''; $compatible = ''; $type = strtolower($item['e_type']); $items_to_update = json_decode(getPreference($type . 's_to_update'), true); $items_downloaded = json_decode(getPreference($type . 's_downloaded'), true); if ($item['s_thumbnail']) { $thumbnail = $item['s_thumbnail']; } if ($item['s_banner']) { if (@$item['s_banner_path'] != '') { $thumbnail = $item['s_banner_path'] . $item['s_banner']; } else { $thumbnail = 'http://market.osclass.org/oc-content/uploads/market/' . $item['s_banner']; } } $downloaded = false; if (in_array($item['s_update_url'], $items_downloaded)) { if (in_array($item['s_update_url'], $items_to_update)) { $updateClass = 'has-update'; $updateData = ' data-update="true"'; } else { // market item downloaded ! $downloaded = true; } } //Check if is compatibleosc_version() if ($type == 'language') { if (!check_market_language_compatibility($item['s_update_url'], $item['s_version'])) { $compatible = ' not-compatible'; } } else { if (!check_market_compatibility($item['s_compatible'], $type)) { $compatible = ' not-compatible'; } } if (!$thumbnail && $color) { $thumbnail = osc_current_admin_theme_url('images/gr-' . $color . '.png'); $letterDraw = $item['s_update_url'][0]; if ($type == 'language') { $letterDraw = $item['s_update_url']; } } if ($item['b_featured']) { $featuredClass = ' is-featured'; if ($downloaded || $updateClass) { $featuredClass .= '-'; } } if ($downloaded) { $featuredClass .= 'is-downloaded'; } $style = 'background-image:url(' . $thumbnail . ');'; echo '<a href="#' . $item['s_update_url'] . '" class="mk-item-parent ' . $featuredClass . $updateClass . $compatible . '" data-type="' . $type . '"' . $updateData . ' data-gr="' . $color . '" data-letter="' . $item['s_update_url'][0] . '">'; echo '<div class="mk-item mk-item-' . $type . '">'; echo ' <div class="banner" style="' . $style . '">' . $letterDraw . '</div>'; echo ' <div class="mk-info"><i class="flag"></i>'; echo ' <h3>' . $item['s_title'] . '</h3>'; echo ' <span class="downloads"><strong>' . $item['i_total_downloads'] . '</strong> ' . __('downloads') . '</span>'; echo ' <i>by ' . $item['s_contact_name'] . '</i>'; echo ' <div class="market-actions">'; echo ' <span class="more">' . __('View more') . '</span>'; echo ' <span class="download-btn' . $compatible . '" data-code="' . $item['s_update_url'] . '" data-type="' . $type . '"' . '>' . __('Download') . '</span>'; echo ' </div>'; echo ' </div>'; echo '</div>'; echo '</a>'; }
public function run() { global $db; $today = date('Y-m-d'); $cron = new cron(); $data = $cron->select_crons_to_run(); $return['cron_message'] = "Cron started"; $number_of_crons_run = "0"; $cron_log = new cronlog(); $cron_log->run_date = $today; foreach ($data as $key => $value) { $cron->domain_id = $value['domain_id']; $cron_log->cron_id = $value['id']; $cron_log->domain_id = $domain_id = $value['domain_id']; $check_cron_log = $cron_log->check(); $i = "0"; if ($check_cron_log == 0) { //only proceed if cron has not been run for today $run_cron = false; $start_date = date('Y-m-d', strtotime($value['start_date'])); $end_date = $value['end_date']; // Seconds in a day = 60 * 60 * 24 = 86400 $diff = number_format((strtotime($today) - strtotime($start_date)) / 86400, 0); //only check if diff is positive if ($diff >= 0 and ($end_date == "" or $end_date >= $today)) { if ($value['recurrence_type'] == 'day') { $modulus = $diff % $value['recurrence']; if ($modulus == 0) { $run_cron = true; } else { #$return .= "cron does not runs TODAY-days"; } } if ($value['recurrence_type'] == 'week') { $period = 7 * $value['recurrence']; $modulus = $diff % $period; if ($modulus == 0) { $run_cron = true; } else { #$return .= "cron is not runs TODAY-week"; } } if ($value['recurrence_type'] == 'month') { $start_day = date('d', strtotime($value['start_date'])); $start_month = date('m', strtotime($value['start_date'])); $start_year = date('Y', strtotime($value['start_date'])); $today_day = date('d'); $today_month = date('m'); $today_year = date('Y'); $months = $today_month - $start_month + 12 * ($today_year - $start_year); $modulus = $months % $value['recurrence']; if ($modulus == 0 and $start_day == $today_day) { $run_cron = true; } else { #$return .= "cron is not runs TODAY-month"; } } if ($value['recurrence_type'] == 'year') { $start_day = date('d', strtotime($value['start_date'])); $start_month = date('m', strtotime($value['start_date'])); $start_year = date('Y', strtotime($value['start_date'])); $today_day = date('d'); $today_month = date('m'); $today_year = date('Y'); $years = $today_year - $start_year; $modulus = $years % $value['recurrence']; if ($modulus == 0 and $start_day == $today_day and $start_month == $today_month) { $run_cron = true; } else { #$return .= "cron is not runs TODAY-year"; } } //run the recurrence for this invoice if ($run_cron) { $number_of_crons_run++; $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " was run today :: Info diff=" . $diff; $i++; $ni = new invoice(); $ni->id = $value['invoice_id']; $ni->domain_id = $domain_id; // $domain_id gets propagated from invoice to be copied from $new_invoice_id = $ni->recur(); //insert into cron_log date of run //$cron_log = new cronlog(); //$cron_log->run_date = $today; //$cron_log->domain_id = $domain_id; //$cron_log->cron_id = $value['cron_id']; $cron_log->insert(); ## email the people $invoiceobj = new invoice(); $invoice = $invoiceobj->select($new_invoice_id, $domain_id); $preference = getPreference($invoice['preference_id'], $domain_id); $biller = getBiller($invoice['biller_id'], $domain_id); $customer = getCustomer($invoice['customer_id'], $domain_id); #print_r($customer); #create PDF nameVj $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name_invoice = $spc2us_pref . ".pdf"; // email invoice if ($value['email_biller'] == "1" or $value['email_customer'] == "1") { $export = new export(); $export->domain_id = $domain_id; $export->format = "pdf"; $export->file_location = 'file'; $export->module = 'invoice'; $export->id = $invoice['id']; $export->execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email = new email(); $email->domain_id = $domain_id; $email->format = 'cron_invoice'; $email_body = new email_body(); $email_body->email_type = 'cron_invoice'; $email_body->customer_name = $customer['name']; $email_body->invoice_name = $invoice['index_name']; $email_body->biller_name = $biller['name']; $email->notes = $email_body->create(); $email->from = $biller['email']; $email->from_friendly = $biller['name']; $email->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']); $email->invoice_name = $invoice['index_name']; $email->subject = $email->set_subject(); $email->attachment = $pdf_file_name_invoice; $return['email_message'] = $email->send(); } //Check that all details are OK before doing the eway payment $eway_check = new eway(); $eway_check->domain_id = $domain_id; $eway_check->invoice = $invoice; $eway_check->customer = $customer; $eway_check->biller = $biller; $eway_check->preference = $preference; $eway_pre_check = $eway_check->pre_check(); //do eway payment if ($eway_pre_check == 'true') { // input customerID, method (REAL_TIME, REAL_TIME_CVN, GEO_IP_ANTI_FRAUD) and liveGateway or not $eway = new eway(); $eway->domain_id = $domain_id; $eway->invoice = $invoice; $eway->biller = $biller; $eway->customer = $customer; $payment_done = $eway->payment(); $payment_id = $db->lastInsertID(); $pdf_file_name_receipt = 'payment' . $payment_id . '.pdf'; if ($payment_done == 'true') { //do email of receipt to biller and customer if ($value['email_biller'] == "1" or $value['email_customer'] == "1") { /* * If you want a new copy of the invoice being emailed to the customer * use this code */ $export_rec = new export(); $export_rec->domain_id = $domain_id; $export_rec->format = "pdf"; $export_rec->file_location = 'file'; $export_rec->module = 'invoice'; $export_rec->id = $invoice['id']; $export_rec->execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email_rec = new email(); $email_rec->domain_id = $domain_id; $email_rec->format = 'cron_invoice'; $email_body_rec = new email_body(); $email_body_rec->email_type = 'cron_invoice_receipt'; $email_body_rec->customer_name = $customer['name']; $email_body_rec->invoice_name = $invoice['index_name']; $email_body_rec->biller_name = $biller['name']; $email_rec->notes = $email_body_rec->create(); $email_rec->from = $biller['email']; $email_rec->from_friendly = $biller['name']; $email_rec->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']); $email_rec->invoice_name = $invoice['index_name']; $email_rec->attachment = $pdf_file_name_invoice; $email_rec->subject = $email_rec->set_subject('invoice_eway_receipt'); $return['email_message'] = $email_rec->send(); /* * If you want a receipt as PDF being emailed to the customer * uncomment the code below */ /* $export = new export(); $export -> format = "pdf"; $export -> file_location = 'file'; $export -> module = 'payment'; $export -> id = $payment_id; $export -> execute(); $email = new email(); $email -> format = 'cron_payment'; $email_body = new email_body(); $email_body->email_type = 'cron_payment'; $email_body->customer_name = $customer['name']; $email_body->invoice_name = 'payment'.$payment_id; $email_body->biller_name = $biller['name']; $email -> notes = $email_body->create(); $email -> from = $biller['email']; $email -> from_friendly = $biller['name']; if($value['email_customer'] == "1") { $email -> to = $customer['email']; } if($value['email_biller'] == "1" AND $value['email_customer'] == "1") { $email -> to = $customer['email'].";".$biller['email']; } if($value['email_biller'] == "1" AND $value['email_customer'] == "0") { $email -> to = $customer['email']; } $email -> subject = $pdf_file_name_receipt." from ".$biller['name']; $email -> attachment = $pdf_file_name_receipt; $return['email_message'] = $email->send(); */ } } else { //do email to biller/admin - say error $email = new email(); $email->domain_id = $domain_id; $email->format = 'cron_payment'; $email->from = $biller['email']; $email->from_friendly = $biller['name']; $email->to = $biller['email']; $email->subject = "Payment failed for " . $invoice['index_name']; $error_message = "Invoice: " . $invoice['index_name'] . "<br /> Amount: " . $invoice['total'] . " <br />"; foreach ($eway->get_message() as $key => $value) { $error_message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}"; } $email->notes = $error_message; $return['email_message'] = $email->send(); } } } else { //cron not run for this cron_id $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff; } } else { //days diff is negative - whats going on $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: - Not cheduled for today - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff; } } else { // cron has already been run for that cron_id today $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron has already been run for domain: " . $domain_id . " for the date: " . $today . " for invoice " . $value['invoice_id']; $return['email_message'] = ""; } } // no crons scheduled for today if ($number_of_crons_run == '0') { $return['id'] = $i; $return['cron_message'] = "No invoices recurred for this cron run for domain: " . $domain_id . " for the date: " . $today; $return['email_message'] = ""; } //insert into cron_log date of run /* $cron_log = new cronlog(); $cron_log->run_date = $today; $cron_log->domain_id = $domain_id; $cron_log->insert(); */ /* * If you want to get an email once cron has been run edit the below details * */ /* $email = new email(); $email -> format = 'cron'; #$email -> notes = $return; $email -> from = "simpleinvoices@localhost"; $email -> from_friendly = "Simple Invoices - Cron"; $email -> to = "simpleinvoices@localhost"; #$email -> bcc = $_POST['email_bcc']; $email -> subject = "Cron for Simple Invoices has been run for today:"; $email -> send (); */ return $return; }
function osclassclsx_default_show_as() { return getPreference('defaultShowAs@all', 'osclassclsx'); }
$("#dialog-uninstall").dialog('open'); return false; } </script> <?php } osc_add_hook('admin_header', 'customHead'); $iDisplayLength = __get('iDisplayLength'); $aData = __get('aPlugins'); $tab_index = 1; osc_current_admin_theme_path('parts/header.php'); ?> <div id="tabs" class="ui-osc-tabs ui-tabs-right"> <ul> <?php $aPluginsToUpdate = json_decode(getPreference('plugins_to_update')); $bPluginsToUpdate = is_array($aPluginsToUpdate) ? true : false; if ($bPluginsToUpdate && count($aPluginsToUpdate) > 0) { $tab_index = 2; ?> <li><a href="#update-plugins"><?php _e('Updates'); ?> </a></li> <?php } ?> <li><a href="#market" onclick="window.location = '<?php echo osc_admin_base_url(true) . '?page=market&action=plugins'; ?> '; return false; "><?php
* Script: email.php * Email invoice page * * License: * GPL v3 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $invoice_id = $_GET['id']; $invoiceobj = new invoice(); $invoice = $invoiceobj->select($invoice_id); $preference = getPreference($invoice['preference_id']); $biller = getBiller($invoice['biller_id']); $customer = getCustomer($invoice['customer_id']); $invoiceType = getInvoiceType($invoice['type_id']); #create PDF name $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name = $spc2us_pref . '.pdf'; if ($_GET['stage'] == 2) { #echo $block_stage2; // Create invoice $export = new export(); $export->format = "pdf"; $export->file_location = 'file'; $export->module = 'invoice'; $export->id = $invoice_id; $export->execute();
function pop_default_show_as() { return getPreference('defaultShowAs@all', 'pop_theme'); }
/** * Return watermark place * * @return string */ function osc_watermark_place() { return getPreference('watermark_place'); }
function doModel() { //specific things for this class switch ($this->action) { case 'bulk_actions': break; case 'regions': //Return regions given a countryId $regions = Region::newInstance()->findByCountry(Params::getParam("countryId")); echo json_encode($regions); break; case 'cities': //Returns cities given a regionId $cities = City::newInstance()->findByRegion(Params::getParam("regionId")); echo json_encode($cities); break; case 'location': // This is the autocomplete AJAX $cities = City::newInstance()->ajax(Params::getParam("term")); echo json_encode($cities); break; case 'userajax': // This is the autocomplete AJAX $users = User::newInstance()->ajax(Params::getParam("term")); if (count($users) == 0) { echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results')))); } else { echo json_encode($users); } break; case 'date_format': echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date('Y-m-d H:i:s'), Params::getParam('format')))); break; case 'runhook': // run hooks $hook = Params::getParam('hook'); if ($hook == '') { echo json_encode(array('error' => 'hook parameter not defined')); break; } switch ($hook) { case 'item_form': osc_run_hook('item_form', Params::getParam('catId')); break; case 'item_edit': $catId = Params::getParam("catId"); $itemId = Params::getParam("itemId"); osc_run_hook("item_edit", $catId, $itemId); break; default: osc_run_hook('ajax_admin_' . $hook); break; } break; case 'categories_order': // Save the order of the categories osc_csrf_check(false); $aIds = Params::getParam('list'); $orderParent = 0; $orderSub = 0; $catParent = 0; $error = 0; $catManager = Category::newInstance(); $aRecountCat = array(); foreach ($aIds as $id => $parent) { if ($parent == 'root') { $res = $catManager->updateOrder($id, $orderParent); if (is_bool($res) && !$res) { $error = 1; } // find category $auxCategory = Category::newInstance()->findByPrimaryKey($id); // set parent category $conditions = array('pk_i_id' => $id); $array['fk_i_parent_id'] = NULL; $res = $catManager->update($array, $conditions); if (is_bool($res) && !$res) { $error = 1; } else { if ($res == 1) { // updated ok $parentId = $auxCategory['fk_i_parent_id']; if ($parentId) { // update parent category stats array_push($aRecountCat, $id); array_push($aRecountCat, $parentId); } } } $orderParent++; } else { if ($parent != $catParent) { $catParent = $parent; $orderSub = 0; } $res = $catManager->updateOrder($id, $orderSub); if (is_bool($res) && !$res) { $error = 1; } // set parent category $auxCategory = Category::newInstance()->findByPrimaryKey($id); $auxCategoryP = Category::newInstance()->findByPrimaryKey($catParent); $conditions = array('pk_i_id' => $id); $array['fk_i_parent_id'] = $catParent; $res = $catManager->update($array, $conditions); if (is_bool($res) && !$res) { $error = 1; } else { if ($res == 1) { // updated ok // update category parent $prevParentId = $auxCategory['fk_i_parent_id']; $parentId = $auxCategoryP['pk_i_id']; array_push($aRecountCat, $prevParentId); array_push($aRecountCat, $parentId); } } $orderSub++; } } // update category stats foreach ($aRecountCat as $rId) { osc_update_cat_stats_id($rId); } if ($error) { $result = array('error' => __("An error occurred")); } else { $result = array('ok' => __("Order saved")); } echo json_encode($result); break; case 'category_edit_iframe': $this->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey(Params::getParam("id"))); $this->_exportVariableToView('languages', OSCLocale::newInstance()->listAllEnabled()); $this->doView("categories/iframe.php"); break; case 'field_categories_iframe': $selected = Field::newInstance()->categories(Params::getParam("id")); if ($selected == null) { $selected = array(); } $this->_exportVariableToView("selected", $selected); $this->_exportVariableToView("field", Field::newInstance()->findByPrimaryKey(Params::getParam("id"))); $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll()); $this->doView("fields/iframe.php"); break; case 'field_categories_post': osc_csrf_check(false); $error = 0; $field = Field::newInstance()->findByName(Params::getParam("s_name")); if (!isset($field['pk_i_id']) || isset($field['pk_i_id']) && $field['pk_i_id'] == Params::getParam("id")) { // remove categories from a field Field::newInstance()->cleanCategoriesFromField(Params::getParam("id")); // no error... continue updating fields if ($error == 0) { $slug = Params::getParam("field_slug") != '' ? Params::getParam("field_slug") : Params::getParam("s_name"); $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($slug))); $slug_k = 0; while (true) { $field = Field::newInstance()->findBySlug($slug); if (!$field || $field['pk_i_id'] == Params::getParam("id")) { break; } else { $slug_k++; $slug = $slug_tmp . "_" . $slug_k; } } // trim options $s_options = ''; $aux = Params::getParam('s_options'); $aAux = explode(',', $aux); foreach ($aAux as &$option) { $option = trim($option); } $s_options = implode(',', $aAux); $res = Field::newInstance()->update(array('s_name' => Params::getParam("s_name"), 'e_type' => Params::getParam("field_type"), 's_slug' => $slug, 'b_required' => Params::getParam("field_required") == "1" ? 1 : 0, 's_options' => $s_options), array('pk_i_id' => Params::getParam("id"))); if (is_bool($res) && !$res) { $error = 1; } } // no error... continue inserting categories-field if ($error == 0) { $aCategories = Params::getParam("categories"); if (is_array($aCategories) && count($aCategories) > 0) { $res = Field::newInstance()->insertCategories(Params::getParam("id"), $aCategories); if (!$res) { $error = 1; } } } // error while updating? if ($error == 1) { $message = __("An error occurred while updating."); } } else { $error = 1; $message = __("Sorry, you already have a field with that name"); } if ($error) { $result = array('error' => $message); } else { $result = array('ok' => __("Saved"), 'text' => Params::getParam("s_name"), 'field_id' => Params::getParam("id")); } echo json_encode($result); break; case 'delete_field': osc_csrf_check(false); $res = Field::newInstance()->deleteByPrimaryKey(Params::getParam('id')); if ($res > 0) { $result = array('ok' => __('The custom field has been deleted')); } else { $result = array('error' => __('An error occurred while deleting')); } echo json_encode($result); break; case 'add_field': osc_csrf_check(false); $s_name = __('NEW custom field'); $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($s_name))); $slug_k = 0; while (true) { $field = Field::newInstance()->findBySlug($slug); if (!$field || $field['pk_i_id'] == Params::getParam("id")) { break; } else { $slug_k++; $slug = $slug_tmp . "_" . $slug_k; } } $fieldManager = Field::newInstance(); $result = $fieldManager->insertField($s_name, 'TEXT', $slug, 0, '', array()); if ($result) { echo json_encode(array('error' => 0, 'field_id' => $fieldManager->dao->insertedId(), 'field_name' => $s_name)); } else { echo json_encode(array('error' => 1)); } break; case 'enable_category': osc_csrf_check(false); $id = strip_tags(Params::getParam('id')); $enabled = Params::getParam('enabled') != '' ? Params::getParam('enabled') : 0; $error = 0; $result = array(); $aUpdated = array(); $mCategory = Category::newInstance(); $aCategory = $mCategory->findByPrimaryKey($id); if ($aCategory == false) { $result = array('error' => sprintf(__("No category with id %d exists"), $id)); echo json_encode($result); break; } // root category if ($aCategory['fk_i_parent_id'] == '') { $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id)); $mCategory->update(array('b_enabled' => $enabled), array('fk_i_parent_id' => $id)); $subCategories = $mCategory->findSubcategories($id); $aIds = array($id); $aUpdated[] = array('id' => $id); foreach ($subCategories as $subcategory) { $aIds[] = $subcategory['pk_i_id']; $aUpdated[] = array('id' => $subcategory['pk_i_id']); } Item::newInstance()->enableByCategory($enabled, $aIds); if ($enabled) { $result = array('ok' => __('The category as well as its subcategories have been enabled')); } else { $result = array('ok' => __('The category as well as its subcategories have been disabled')); } $result['affectedIds'] = $aUpdated; echo json_encode($result); break; } // subcategory $parentCategory = $mCategory->findRootCategory($id); if (!$parentCategory['b_enabled']) { $result = array('error' => __('Parent category is disabled, you can not enable that category')); echo json_encode($result); break; } $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id)); if ($enabled) { $result = array('ok' => __('The subcategory has been enabled')); } else { $result = array('ok' => __('The subcategory has been disabled')); } $result['affectedIds'] = array(array('id' => $id)); echo json_encode($result); break; case 'delete_category': osc_csrf_check(false); $id = Params::getParam("id"); $error = 0; $categoryManager = Category::newInstance(); $res = $categoryManager->deleteByPrimaryKey($id); if ($res > 0) { $message = __('The categories have been deleted'); } else { $error = 1; $message = __('An error occurred while deleting'); } if ($error) { $result = array('error' => $message); } else { $result = array('ok' => __("Saved")); } echo json_encode($result); break; case 'edit_category_post': osc_csrf_check(false); $id = Params::getParam("id"); $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0; $error = 0; $has_one_title = 0; $postParams = Params::getParamsAsArray(); foreach ($postParams as $k => $v) { if (preg_match('|(.+?)#(.+)|', $k, $m)) { if ($m[2] == 's_name') { if ($v != "") { $has_one_title = 1; $aFieldsDescription[$m[1]][$m[2]] = $v; $s_text = $v; } else { $aFieldsDescription[$m[1]][$m[2]] = NULL; $error = 1; } } else { $aFieldsDescription[$m[1]][$m[2]] = $v; } } } $l = osc_language(); if ($error == 0 || $error == 1 && $has_one_title == 1) { $categoryManager = Category::newInstance(); $res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id); $categoryManager->updateExpiration($id, $fields['i_expiration_days']); if (is_bool($res)) { $error = 2; } } if (Params::getParam('apply_changes_to_subcategories') == 1) { $subcategories = $categoryManager->findSubcategories($id); foreach ($subcategories as $subc) { $categoryManager->updateExpiration($subc['pk_i_id'], $fields['i_expiration_days']); } } if ($error == 0) { $msg = __("Category updated correctly"); } else { if ($error == 1) { if ($has_one_title == 1) { $error = 4; $msg = __('Category updated correctly, but some titles are empty'); } else { $msg = __('Sorry, including at least a title is mandatory'); } } else { if ($error == 2) { $msg = __('An error occurred while updating'); } } } echo json_encode(array('error' => $error, 'msg' => $msg, 'text' => $aFieldsDescription[$l]['s_name'])); break; case 'custom': // Execute via AJAX custom file $ajaxFile = Params::getParam("ajaxfile"); if ($ajaxFile == '') { echo json_encode(array('error' => 'no action defined')); break; } // valid file? if (stripos($ajaxFile, '../') !== false) { echo json_encode(array('error' => 'no valid ajaxFile')); break; } if (!file_exists(osc_plugins_path() . $ajaxFile)) { echo json_encode(array('error' => "ajaxFile doesn't exist")); break; } require_once osc_plugins_path() . $ajaxFile; break; case 'test_mail': $title = sprintf(__('Test email, %s'), osc_page_title()); $body = __("Test email") . "<br><br>" . osc_page_title(); $emailParams = array('subject' => $title, 'to' => osc_contact_email(), 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body); $array = array(); if (osc_sendMail($emailParams)) { $array = array('status' => '1', 'html' => __('Email sent successfully')); } else { $array = array('status' => '0', 'html' => __('An error occurred while sending email')); } echo json_encode($array); break; case 'test_mail_template': // replace por valores por defecto $email = Params::getParam("email"); $title = Params::getParam("title"); $body = urldecode(Params::getParam("body")); $emailParams = array('subject' => $title, 'to' => $email, 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body); $array = array(); if (osc_sendMail($emailParams)) { $array = array('status' => '1', 'html' => __('Email sent successfully')); } else { $array = array('status' => '0', 'html' => __('An error occurred while sending email')); } echo json_encode($array); break; case 'order_pages': osc_csrf_check(false); $order = Params::getParam("order"); $id = Params::getParam("id"); if ($order != '' && $id != '') { $mPages = Page::newInstance(); $actual_page = $mPages->findByPrimaryKey($id); $actual_order = $actual_page['i_order']; $array = array(); $condition = array(); $new_order = $actual_order; if ($order == 'up') { $page = $mPages->findPrevPage($actual_order); } else { if ($order == 'down') { $page = $mPages->findNextPage($actual_order); } } if (isset($page['i_order'])) { $mPages->update(array('i_order' => $page['i_order']), array('pk_i_id' => $id)); $mPages->update(array('i_order' => $actual_order), array('pk_i_id' => $page['pk_i_id'])); } } break; /****************************** ** COMPLETE UPGRADE PROCESS ** ******************************/ /****************************** ** COMPLETE UPGRADE PROCESS ** ******************************/ case 'upgrade': // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT osc_csrf_check(false); $message = ""; $error = 0; $sql_error_msg = ""; $rm_errors = 0; $perms = osc_save_permissions(); osc_change_permissions(); $maintenance_file = ABS_PATH . '.maintenance'; $fileHandler = @fopen($maintenance_file, 'w'); fclose($fileHandler); /*********************** **** DOWNLOAD FILE **** ***********************/ $data = osc_file_get_contents("http://osclass.org/latest_version.php"); $data = json_decode(substr($data, 1, strlen($data) - 3), true); $source_file = $data['url']; if ($source_file != '') { $tmp = explode("/", $source_file); $filename = end($tmp); $result = osc_downloadFile($source_file, $filename); if ($result) { // Everything is OK, continue /********************** ***** UNZIP FILE ***** **********************/ @mkdir(ABS_PATH . 'oc-temp', 0777); $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, ABS_PATH . 'oc-temp/'); if ($res == 1) { // Everything is OK, continue /********************** ***** COPY FILES ***** **********************/ $fail = -1; if ($handle = opendir(ABS_PATH . 'oc-temp')) { $fail = 0; while (false !== ($_file = readdir($handle))) { if ($_file != '.' && $_file != '..' && $_file != 'remove.list' && $_file != 'upgrade.sql' && $_file != 'customs.actions') { $data = osc_copy(ABS_PATH . "oc-temp/" . $_file, ABS_PATH . $_file); if ($data == false) { $fail = 1; } } } closedir($handle); //TRY TO REMOVE THE ZIP PACKAGE @unlink(osc_content_path() . 'downloads/' . $filename); if ($fail == 0) { // Everything is OK, continue /************************ *** UPGRADE DATABASE *** ************************/ $error_queries = array(); if (file_exists(osc_lib_path() . 'osclass/installer/struct.sql')) { $sql = file_get_contents(osc_lib_path() . 'osclass/installer/struct.sql'); $conn = DBConnectionClass::newInstance(); $c_db = $conn->getOsclassDb(); $comm = new DBCommandClass($c_db); $error_queries = $comm->updateDB(str_replace('/*TABLE_PREFIX*/', DB_TABLE_PREFIX, $sql)); } if ($error_queries[0]) { // Everything is OK, continue /********************************** ** EXECUTING ADDITIONAL ACTIONS ** **********************************/ if (file_exists(osc_lib_path() . 'osclass/upgrade-funcs.php')) { // There should be no errors here define('AUTO_UPGRADE', true); require_once osc_lib_path() . 'osclass/upgrade-funcs.php'; } // Additional actions is not important for the rest of the proccess // We will inform the user of the problems but the upgrade could continue /**************************** ** REMOVE TEMPORARY FILES ** ****************************/ $path = ABS_PATH . 'oc-temp'; $rm_errors = 0; $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST); for ($dir->rewind(); $dir->valid(); $dir->next()) { if ($dir->isDir()) { if ($dir->getFilename() != '.' && $dir->getFilename() != '..') { if (!rmdir($dir->getPathname())) { $rm_errors++; } } } else { if (!unlink($dir->getPathname())) { $rm_errors++; } } } if (!rmdir($path)) { $rm_errors++; } $deleted = @unlink(ABS_PATH . '.maintenance'); if ($rm_errors == 0) { $message = __('Everything looks good! Your Osclass installation is up-to-date'); } else { $message = __('Nearly everything looks good! Your Osclass installation is up-to-date, but there were some errors removing temporary files. Please manually remove the "oc-temp" folder'); $error = 6; // Some errors removing files } } else { $sql_error_msg = $error_queries[2]; $message = __('Problems when upgrading the database'); $error = 5; // Problems upgrading the database } } else { $message = __('Problems when copying files. Please check your permissions. '); $error = 4; // Problems copying files. Maybe permissions are not correct } } else { $message = __('Nothing to copy'); $error = 99; // Nothing to copy. THIS SHOULD NEVER HAPPEN, means we don't update any file! } } else { $message = __('Unzip failed'); $error = 3; // Unzip failed } } else { $message = __('Download failed'); $error = 2; // Download failed } } else { $message = __('Missing download URL'); $error = 1; // Missing download URL } if ($error == 5) { $message .= "<br /><br />" . __('We had some errors upgrading your database. The follwing queries failed:') . implode("<br />", $sql_error_msg); } echo $message; foreach ($perms as $k => $v) { @chmod($k, $v); } break; /******************************* ** COMPLETE MARKET PROCESS ** *******************************/ /******************************* ** COMPLETE MARKET PROCESS ** *******************************/ case 'market': // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT osc_csrf_check(false); $section = Params::getParam('section'); $code = Params::getParam('code'); $plugin = false; $re_enable = false; $message = ""; $error = 0; $data = array(); /************************ *** CHECK VALID CODE *** ************************/ if ($code != '' && $section != '') { if (stripos($code, "http://") === FALSE) { // OSCLASS OFFICIAL REPOSITORY $url = osc_market_url($section, $code); $data = json_decode(osc_file_get_contents($url), true); } else { // THIRD PARTY REPOSITORY if (osc_market_external_sources()) { $data = json_decode(osc_file_get_contents($code), true); } else { echo json_encode(array('error' => 8, 'error_msg' => __('No external sources are allowed'))); break; } } /*********************** **** DOWNLOAD FILE **** ***********************/ if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) { if ($data['e_type'] == 'THEME') { $folder = 'themes/'; } else { if ($data['e_type'] == 'LANGUAGE') { $folder = 'languages/'; } else { // PLUGINS $folder = 'plugins/'; $plugin = Plugins::findByUpdateURI($data['s_update_url']); if ($plugin != false) { if (Plugins::isEnabled($plugin)) { Plugins::runHook($plugin . '_disable'); Plugins::deactivate($plugin); $re_enable = true; } } } } $filename = $data['s_update_url'] . "_" . $data['s_version'] . ".zip"; $url_source_file = $data['s_source_file']; // error_log('Source file: ' . $url_source_file); // error_log('Filename: ' . $filename); $result = osc_downloadFile($url_source_file, $filename); if ($result) { // Everything is OK, continue /********************** ***** UNZIP FILE ***** **********************/ @mkdir(ABS_PATH . 'oc-temp', 0777); $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/'); if ($res == 1) { // Everything is OK, continue /********************** ***** COPY FILES ***** **********************/ $fail = -1; if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) { $folder_dest = ABS_PATH . "oc-content/" . $folder; if (function_exists('posix_getpwuid')) { $current_user = posix_getpwuid(posix_geteuid()); $ownerFolder = posix_getpwuid(fileowner($folder_dest)); } $fail = 0; while (false !== ($_file = readdir($handle))) { if ($_file != '.' && $_file != '..') { $copyprocess = osc_copy(osc_content_path() . "downloads/oc-temp/" . $_file, $folder_dest . $_file); if ($copyprocess == false) { $fail = 1; } } } closedir($handle); // Additional actions is not important for the rest of the proccess // We will inform the user of the problems but the upgrade could continue // Also remove the zip package /**************************** ** REMOVE TEMPORARY FILES ** ****************************/ @unlink(osc_content_path() . 'downloads/' . $filename); $path = osc_content_path() . 'downloads/oc-temp'; $rm_errors = 0; $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST); for ($dir->rewind(); $dir->valid(); $dir->next()) { if ($dir->isDir()) { if ($dir->getFilename() != '.' && $dir->getFilename() != '..') { if (!rmdir($dir->getPathname())) { $rm_errors++; } } } else { if (!unlink($dir->getPathname())) { $rm_errors++; } } } if (!rmdir($path)) { $rm_errors++; } if ($fail == 0) { // Everything is OK, continue if ($data['e_type'] != 'THEME' && $data['e_type'] != 'LANGUAGE') { if ($plugin != false && $re_enable) { $enabled = Plugins::activate($plugin); if ($enabled) { Plugins::runHook($plugin . '_enable'); } } } // recount plugins&themes for update if ($section == 'plugins') { osc_check_plugins_update(true); } else { if ($section == 'themes') { osc_check_themes_update(true); } else { if ($section == 'languages') { // load oc-content/ if (osc_checkLocales()) { $message .= __('The language has been installed correctly'); } else { $message .= __('There was a problem adding the language'); $error = 8; } osc_check_languages_update(true); } } } if ($rm_errors == 0) { $message = __('Everything looks good!'); $error = 0; } else { $message = __('Nearly everything looks good! but there were some errors removing temporary files. Please manually remove the \\"oc-temp\\" folder'); $error = 6; // Some errors removing files } } else { $message = __('Problems when copying files. Please check your permissions. '); if ($current_user['uid'] != $ownerFolder['uid']) { if (function_exists('posix_getgrgid')) { $current_group = posix_getgrgid($current_user['gid']); $message .= '<p><strong>' . sprintf(__('NOTE: Web user and destination folder user is not the same, you might have an issue there. <br/>Do this in your console:<br/>chown -R %s:%s %s'), $current_user['name'], $current_group['name'], $folder_dest) . '</strong></p>'; } } $error = 4; // Problems copying files. Maybe permissions are not correct } } else { $message = __('Nothing to copy'); $error = 99; // Nothing to copy. THIS SHOULD NEVER HAPPEN, means we don't update any file! } } else { $message = __('Unzip failed'); $error = 3; // Unzip failed } } else { $message = __('Download failed'); $error = 2; // Download failed } } else { $message = __('Input code not valid'); $error = 7; // Input code not valid } } else { $message = __('Missing download URL'); $error = 1; // Missing download URL } echo json_encode(array('error' => $error, 'message' => $message, 'data' => $data)); break; case 'check_market': // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT $section = Params::getParam('section'); $code = Params::getParam('code'); $data = array(); /************************ *** CHECK VALID CODE *** ************************/ if ($code != '' && $section != '') { if (stripos($code, "http://") === FALSE) { // OSCLASS OFFICIAL REPOSITORY $data = json_decode(osc_file_get_contents(osc_market_url($section, $code)), true); } else { // THIRD PARTY REPOSITORY if (osc_market_external_sources()) { $data = json_decode(osc_file_get_contents($code), true); } else { echo json_encode(array('error' => 3, 'error_msg' => __('No external sources are allowed'))); break; } } if (!isset($data['s_source_file']) || !isset($data['s_update_url'])) { $data = array('error' => 2, 'error_msg' => __('Invalid code')); } } else { $data = array('error' => 1, 'error_msg' => __('No code was submitted')); } echo json_encode($data); break; case 'market_data': $section = Params::getParam('section'); $page = Params::getParam("mPage"); $featured = Params::getParam("featured"); $sort = Params::getParam("sort"); $order = Params::getParam("order"); // for the moment this value is static $length = 9; if ($page >= 1) { $page--; } $url = osc_market_url($section) . "page/" . $page . '/'; if ($length != '' && is_numeric($length)) { $url .= 'length/' . $length . '/'; } if ($sort != '') { $url .= 'order/' . $sort; if ($order != '') { $url .= '/' . $order; } } if ($featured != '') { $url = osc_market_featured_url($section); } $data = array(); $data = json_decode(osc_file_get_contents($url), true); if (!isset($data[$section])) { $data = array('error' => 1, 'error_msg' => __('No market data')); } echo 'var market_data = window.market_data || {}; market_data.' . $section . ' = ' . json_encode($data) . ';'; break; case 'local_market': // AVOID CROSS DOMAIN PROBLEMS OF AJAX REQUEST $marketPage = Params::getParam("mPage"); if ($marketPage >= 1) { $marketPage--; } $out = osc_file_get_contents(osc_market_url(Params::getParam("section")) . "page/" . $marketPage); $array = json_decode($out, true); // do pagination $pageActual = $array['page']; $totalPages = ceil($array['total'] / $array['sizePage']); $params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => '#{PAGE}', 'sides' => 5); // set pagination $pagination = new Pagination($params); $aux = $pagination->doPagination(); $array['pagination_content'] = $aux; // encode to json echo json_encode($array); break; case 'dashboardbox_market': $error = 0; // make market call $url = getPreference('marketURL') . 'dashboardbox/'; $content = ''; if (false === ($json = @osc_file_get_contents($url))) { $error = 1; } else { $content = $json; } if ($error == 1) { echo json_encode(array('error' => 1)); } else { // replace content with correct urls $content = str_replace('{URL_MARKET_THEMES}', osc_admin_base_url(true) . '?page=market&action=themes', $content); $content = str_replace('{URL_MARKET_PLUGINS}', osc_admin_base_url(true) . '?page=market&action=plugins', $content); echo json_encode(array('html' => $content)); } break; case 'location_stats': osc_csrf_check(false); $workToDo = osc_update_location_stats(); if ($workToDo > 0) { $array['status'] = 'more'; $array['pending'] = $workToDo; echo json_encode($array); } else { $array['status'] = 'done'; echo json_encode($array); } break; case 'error_permissions': echo json_encode(array('error' => __("You don't have the necessary permissions"))); break; default: echo json_encode(array('error' => __('no action defined'))); break; } // clear all keep variables into session Session::newInstance()->_dropKeepForm(); Session::newInstance()->_clearVariables(); }
public function payment() { global $config; global $logger; //set customer,biller and preference if not defined if (empty($this->customer)) { $this->customer = getCustomer($this->invoice['customer_id'], $this->domain_id); } if (empty($this->biller)) { $this->biller = getBiller($this->invoice['biller_id'], $this->domain_id); } if (empty($this->preference)) { $this->preference = getPreference($this->invoice['preference_id'], $this->domain_id); } $eway = new ewaylib($this->biller['eway_customer_id'], 'REAL_TIME', false); //Eway only accepts amount in cents - so times 100 $value = $this->invoice['total'] * 100; $eway_invoice_total = htmlsafe(trim($value)); $logger->log("eway total: " . $eway_invoice_total, Zend_Log::INFO); $enc = new encryption(); $key = $config->encryption->default->key; $credit_card_number = $enc->decrypt($key, $this->customer['credit_card_number']); $eway->setTransactionData("TotalAmount", $eway_invoice_total); //mandatory field $eway->setTransactionData("CustomerFirstName", $this->customer['name']); $eway->setTransactionData("CustomerLastName", ""); $eway->setTransactionData("CustomerAddress", ""); $eway->setTransactionData("CustomerPostcode", ""); $eway->setTransactionData("CustomerInvoiceDescription", ""); $eway->setTransactionData("CustomerEmail", $this->customer['email']); $eway->setTransactionData("CustomerInvoiceRef", $this->invoice['index_name']); $eway->setTransactionData("CardHoldersName", $this->customer['credit_card_holder_name']); //mandatory field $eway->setTransactionData("CardNumber", $credit_card_number); //mandatory field $eway->setTransactionData("CardExpiryMonth", $this->customer['credit_card_expiry_month']); //mandatory field $eway->setTransactionData("CardExpiryYear", $this->customer['credit_card_expiry_year']); //mandatory field $eway->setTransactionData("Option1", ""); $eway->setTransactionData("Option2", ""); $eway->setTransactionData("Option3", ""); $eway->setTransactionData("TrxnNumber", $this->invoice['id']); //special preferences for php Curl //pass a long set to zero value stops curl from verifying peer's certificate $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0); $ewayResponseFields = $eway->doPayment(); $this->message = $ewayResponseFields; $message = ""; if ($ewayResponseFields["EWAYTRXNSTATUS"] == "False") { $logger->log("Transaction Error: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO); foreach ($ewayResponseFields as $key => $value) { $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}"; } $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO); //header("Location: trasnactionerrorpage.php"); //exit(); $return = 'false'; } else { if ($ewayResponseFields["EWAYTRXNSTATUS"] == "True") { $logger->log("Transaction Success: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO); foreach ($ewayResponseFields as $key => $value) { $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}"; } $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO); //header("Location: trasnactionsuccess.php"); //exit(); $payment = new payment(); $payment->ac_inv_id = $this->invoice['id']; #$payment->ac_inv_id = $_POST['invoice']; $payment->ac_amount = $this->invoice['total']; #$payment->ac_amount = $ewayResponseFields['EWAYRETURNAMOUNT']/100; #$payment->ac_amount = $_POST['mc_gross']; $payment->ac_notes = $message; $payment->ac_date = date('Y-m-d'); $payment->online_payment_id = $ewayResponseFields['EWAYTRXNNUMBER']; $payment->domain_id = $this->domain_id; $payment_type = new payment_type(); $payment_type->type = "Eway"; $payment_type->domain_id = $this->domain_id; $payment->ac_payment_type = $payment_type->select_or_insert_where(); $logger->log('Paypal - payment_type=' . $payment->ac_payment_type, Zend_Log::INFO); $payment->insert(); #echo $db->lastInsertID(); $return = 'true'; } } return $return; }
function osc_check_languages_update( $force = false ) { $total = 0; $array = array(); $array_downloaded = array(); // check if exist a new version each day if( (time() - osc_languages_last_version_check()) > (24 * 3600) || $force ) { $languages = OSCLocale::newInstance()->listAll(); foreach($languages as $lang) { if(osc_check_language_update($lang['pk_c_code'], $lang['s_version'] )) { $array[] = $lang['pk_c_code']; $total++; } $array_downloaded[] = $lang['pk_c_code']; } osc_set_preference( 'languages_to_update' , json_encode($array) ); osc_set_preference( 'languages_downloaded', json_encode($array_downloaded) ); osc_set_preference( 'languages_update_count', $total ); osc_set_preference( 'languages_last_version_check', time() ); osc_reset_preferences(); } else { $total = getPreference('languages_update_count'); } return $total; }
function osc_check_languages_update($force = false) { $total = getPreference('languages_update_count'); if ($force) { return _osc_check_languages_update(); } else { if (time() - osc_languages_last_version_check() > 24 * 3600) { osc_add_hook('admin_footer', 'check_languages_admin_footer'); } } return $total; }
function osclasswizards_default_show_as() { return getPreference('defaultShowAs@all', 'osclasswizards_theme'); }
function updateInvoice($invoice_id, $domain_id = '') { // global $logger; global $db_server; $domain_id = domain_id::get($domain_id); $invoiceobj = new invoice(); $current_invoice = $invoiceobj->select($_POST['id']); $current_pref_group = getPreference($current_invoice['preference_id']); $new_pref_group = getPreference($_POST['preference_id']); $index_id = $current_invoice['index_id']; // $logger->log('Curent Index Group: '.$description, Zend_Log::INFO); // $logger->log('Description: '.$description, Zend_Log::INFO); if ($current_pref_group['index_group'] != $new_pref_group['index_group']) { $index_id = index::increment('invoice', $new_pref_group['index_group']); } if ($db_server == 'mysql' && !_invoice_check_fk($_POST['biller_id'], $_POST['customer_id'], $type, $_POST['preference_id'])) { return null; } $sql = "UPDATE\n\t\t\t" . TB_PREFIX . "invoices\n\t\tSET\n\t\t\tindex_id = :index_id,\n\t\t\tbiller_id = :biller_id,\n\t\t\tcustomer_id = :customer_id,\n\t\t\tpreference_id = :preference_id,\n\t\t\tdate = :date,\n\t\t\tnote = :note,\n\t\t\tcustom_field1 = :customField1,\n\t\t\tcustom_field2 = :customField2,\n\t\t\tcustom_field3 = :customField3,\n\t\t\tcustom_field4 = :customField4\n\t\tWHERE\n\t\t\tid = :invoice_id\n\t\tAND domain_id = :domain_id"; return dbQuery($sql, ':index_id', $index_id, ':biller_id', $_POST['biller_id'], ':customer_id', $_POST['customer_id'], ':preference_id', $_POST['preference_id'], ':date', $_POST['date'], ':note', trim($_POST['note']), ':customField1', $_POST['customField1'], ':customField2', $_POST['customField2'], ':customField3', $_POST['customField3'], ':customField4', $_POST['customField4'], ':invoice_id', $invoice_id, ':domain_id', $domain_id); }
</div> <div class="theme-description"> <?php echo $info['description']; ?> </div> <div class="clear"></div> </div> </div> <h2 class="render-title"><?php _e('Available themes'); ?> </h2> <div class="available-theme"> <?php $aThemesToUpdate = json_decode(getPreference('themes_to_update')); $bThemesToUpdate = is_array($aThemesToUpdate) ? true : false; $csrf_token = osc_csrf_token_url(); foreach ($themes as $theme) { ?> <?php if ($theme == osc_theme()) { continue; } $info = WebThemes::newInstance()->loadThemeInfo($theme); ?> <div class="theme"> <div class="theme-stage"> <img src="<?php echo osc_base_url(); ?>
function getData() { //echo "export - get data"; global $smarty; global $siUrl; switch ($this->module) { case "statement": $invoice = new invoice(); $invoice->biller = $this->biller_id; $invoice->customer = $this->customer_id; if ($this->filter_by_date == "yes") { if (isset($this->start_date)) { $invoice->start_date = $this->start_date; } if (isset($this->end_date)) { $invoice->end_date = $this->end_date; } if (isset($this->start_date) and isset($this->end_date)) { $invoice->having = "date_between"; } $having_count = 1; } if ($this->show_only_unpaid == "yes") { if ($having_count == 1) { $invoice->having_and = "money_owed"; } else { $invoice->having = "money_owed"; } } $invoice_all = $invoice->select_all('count'); $invoices = $invoice_all->fetchAll(); foreach ($invoices as $i => $row) { $statement['total'] = $statement['total'] + $row['invoice_total']; $statement['owing'] = $statement['owing'] + $row['owing']; $statement['paid'] = $statement['paid'] + $row['INV_PAID']; } $templatePath = "./templates/default/statement/index.tpl"; $biller_details = getBiller($this->biller_id); $customer_details = getCustomer($this->customer_id); $this->file_name = "statement_" . $this->biller_id . "_" . $this->customer_id . "_" . $invoice->start_date . "_" . $invoice->end_date; $smarty->assign('biller_id', $biller_id); $smarty->assign('biller_details', $biller_details); $smarty->assign('customer_id', $customer_id); $smarty->assign('customer_details', $customer_details); $smarty->assign('show_only_unpaid', $show_only_unpaid); $smarty->assign('filter_by_date', $this->filter_by_date); $smarty->assign('invoices', $invoices); $smarty->assign('start_date', $this->start_date); $smarty->assign('end_date', $this->end_date); $smarty->assign('invoices', $invoices); $smarty->assign('statement', $statement); $data = $smarty->fetch("." . $templatePath); break; case "payment": $payment = getPayment($this->id); /*Code to get the Invoice preference - so can link from this screen back to the invoice - START */ $invoice = getInvoice($payment['ac_inv_id']); $biller = getBiller($payment['biller_id']); $logo = getLogo($biller); $logo = str_replace(" ", "%20", $logo); $customer = getCustomer($payment['customer_id']); $invoiceType = getInvoiceType($invoice['type_id']); $customFieldLabels = getCustomFieldLabels(); $paymentType = getPaymentType($payment['ac_payment_type']); $preference = getPreference($invoice['preference_id']); $smarty->assign("payment", $payment); $smarty->assign("invoice", $invoice); $smarty->assign("biller", $biller); $smarty->assign("logo", $logo); $smarty->assign("customer", $customer); $smarty->assign("invoiceType", $invoiceType); $smarty->assign("paymentType", $paymentType); $smarty->assign("preference", $preference); $smarty->assign("customFieldLabels", $customFieldLabels); $smarty->assign('pageActive', 'payment'); $smarty->assign('active_tab', '#money'); $css = $siUrl . "/templates/invoices/default/style.css"; $smarty->assign('css', $css); $templatePath = "./templates/default/payments/print.tpl"; $data = $smarty->fetch("." . $templatePath); break; case "invoice": $invoice = invoice::select($this->id); $invoice_number_of_taxes = numberOfTaxesForInvoice($this->id); $customer = getCustomer($invoice['customer_id']); $biller = biller::select($invoice['biller_id']); $preference = getPreference($invoice['preference_id']); $defaults = getSystemDefaults(); $logo = getLogo($biller); $logo = str_replace(" ", "%20", $logo); $invoiceItems = invoice::getInvoiceItems($this->id); $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $this->file_name = $spc2us_pref; $customFieldLabels = getCustomFieldLabels(); /*Set the template to the default*/ $template = $defaults['template']; $templatePath = "./templates/invoices/{$template}/template.tpl"; $template_path = "../templates/invoices/{$template}"; $css = $siUrl . "/templates/invoices/{$template}/style.css"; $pluginsdir = "./templates/invoices/{$template}/plugins/"; //$smarty = new Smarty(); $smarty->plugins_dir = $pluginsdir; $pageActive = "invoices"; $smarty->assign('pageActive', $pageActive); if (file_exists($templatePath)) { //echo "test"; $smarty->assign('biller', $biller); $smarty->assign('customer', $customer); $smarty->assign('invoice', $invoice); $smarty->assign('invoice_number_of_taxes', $invoice_number_of_taxes); $smarty->assign('preference', $preference); $smarty->assign('logo', $logo); $smarty->assign('template', $template); $smarty->assign('invoiceItems', $invoiceItems); $smarty->assign('template_path', $template_path); $smarty->assign('css', $css); $smarty->assign('customFieldLabels', $customFieldLabels); $data = $smarty->fetch("." . $templatePath); } break; } return $data; }
function showUpdateTime() { // When we last updated $lastupdate = getPreference("last_update"); print "<p>Data current at " . date("r", $lastupdate) . "<br>\n <a href='#' onclick='resetPreferences();'>Clear Local Data</a></p>"; }