function current_lang_id() { if (session()->has('locale')) { return App\Lang::where('code', session()->get('locale'))->first()->id; } else { return get_default_lang()->id; } }
public function admin_ajax() { $action = Input::get('action'); if ($action == 'menu_link') { $type = Input::get('type'); $item_id = Input::get('item_id'); $link = Input::get('link'); if ($item_id == 0) { $value = $link; } else { $value = $item_id; } switch ($type) { case 'cat': $cats = Lang::where('id', get_default_lang()->id)->with('cats')->first()->cats()->where('type', 'cat')->lists('name', 'id')->toArray(); $output = Form::select('link', $cats, [$value], ['class' => 'form-control']); break; case 'page': $posts = Lang::where('id', get_default_lang()->id)->with('posts')->first()->posts()->where('post_type', 'page')->lists('post_title', 'id'); $output = Form::select('link', $posts, $value, ['class' => 'form-control']); break; case 'post': $posts = Lang::where('id', get_default_lang()->id)->with('posts')->first()->posts()->where('post_type', 'post')->lists('post_title', 'id'); $output = Form::select('link', $posts, $value, ['class' => 'form-control']); break; case 'custom': $output = Form::text('link', $value, ['class' => 'form-control', 'placeholder' => 'http://']); break; default: break; } return $output; } if ($action == 'media_upload') { echo 'media_upload'; } if ($action == 'append_modal') { // $data = [ // 'files' => Post::where('post_type', 'fileimage')->get() // ]; return redirect()->route('file.dialog'); } }
function line($line, $lang = '') { if ($line == 'db_error_heading') { return $line; } $l = $lang == '' ? get_lang() : $lang; $CI =& get_instance(); $ret = $this->get(array('lang' => $l)); $this->result_mode = 'object'; if (isset($ret->value)) { // If we can get the value, then use the value return $ret->value; } if ($l == get_default_lang()) { // If this is the default language, just return the line return $line; } return $this->line($line, get_default_lang()); // Return the default line for this }
function fb_connect_create_account() { global $config, $db, $plugin_config; $this_config = $plugin_config['protect']['fb_connect']; $testmode = $this_config['testmode']; // Check create account is allowed if (!$this_config['newaccount']) { header("Location: " . $config['root_url'] . "/signup.php?fb=manual"); exit; } // Check login to Facebook $fbuserid = fb_connect_get_fbuser(); if (!$fbuserid) { header("Location: " . $config['root_url'] . "/signup.php?fb=cancel"); exit; } // Check there is not already a linked account list($l, $p) = fb_connect_check_logged_in(); if (strlen($l) && strlen($p)) { header("Location: " . $config['root_url'] . "/login.php"); exit; } // Check facebook email is available, that it is not proxied (too long), and not already exists in aMember if (!$_SESSION['fbme']['email'] || strlen($_SESSION['fbme']['email']) > 64 || $config['unique_email'] && $db->users_find_by_string($_SESSION['fbme']['email'], 'email', 1)) { if ($testmode == 1) { $db->log_error("fb_connect: Create account aborted: Has a proxied email, no email address or email already exists ({$_SESSION['fbme']['email']})"); } header("Location: " . $config['root_url'] . "/signup.php?fb=email"); exit; } // Ok, now we can create the account $vars = array(); $vars['name_f'] = $_SESSION['fbme']['first_name']; $vars['name_l'] = $_SESSION['fbme']['last_name']; $vars['email'] = $_SESSION['fbme']['email']; $vars['login'] = generate_login($vars); $vars['pass'] = $vars['pass0'] = $vars['pass1'] = generate_password($vars); if ($GLOBALS['_LANG_SELECTED'] != get_default_lang()) { $vars['selected_lang'] = $GLOBALS['_LANG_SELECTED']; } $member_id = $db->add_pending_user($vars); $db->query("UPDATE {$db->config['prefix']}members SET fbuserid = '{$fbuserid}' WHERE member_id = '{$member_id}' LIMIT 1"); $db->log_error("fb_connect: Created aMember account for Facebook user ({$fbuserid}) - " . print_r($vars, 1)); $is_affiliate = '0'; //only member newsletters if ($db->get_signup_threads_c($is_affiliate)) { $db->subscribe_member($member_id, $is_affiliate); } if ($config['auto_login_after_signup']) { $_SESSION['_amember_login'] = $vars['login']; $_SESSION['_amember_pass'] = $vars['pass']; } // Now add Facebook product subscripton, if set if ($this_config['newaccountproduct']) { $fb_product =& get_product($this_config['newaccountproduct']); $fb_payment = array('member_id' => $member_id, 'product_id' => $fb_product->config['product_id'], 'completed' => 0, 'paysys_id' => 'free', 'begin_date' => $begin_date = date('Y-m-d'), 'expire_date' => $fb_product->get_expire($begin_date)); $db->add_payment($fb_payment); if ($testmode == 1) { $db->log_error("fb_connect: Added subscription (product #{$this_config['newaccountproduct']} ) for Facebook user ({$fbuserid}), login = {$vars['login']}"); } // Now go to thanks page... $payment_id = $GLOBALS['_amember_added_payment_id']; $vcode = md5($payment_id . $begin_date . $member_id); header("Location: " . $config['root_url'] . "/plugins/protect/fb_connect/thanks.php?payment_id={$payment_id}&vcode={$vcode}"); exit; } // Account only - go to member page... header("Location: " . $config['root_url'] . "/member.php"); exit; }
function get_lang() { $lang = guess_lang(); if ($lang != null) { return $lang; } return get_default_lang(); }
function find_applicable() { global $db; $v = $db->escape_array($vv = (array) $this); if ($v['product_id'] > 0) { $where_product_id = " AND ((product_id = '{$v['product_id']}') OR (IFNULL(product_id, 0) = 0))"; } else { $where_product_id = " AND IFNULL(product_id, 0) = 0 "; } if ($v['day'] != '') { $where_day = " AND day = '{$v['day']}' "; } else { $where_day = " AND day is NULL "; } $def_lang = get_default_lang(); if ($v['lang'] != '') { $where_lang = " AND (lang = '{$v['lang']}' OR lang = '{$def_lang}')"; } $id = $db->query_one($s = "SELECT email_template_id\n FROM {$db->config[prefix]}email_templates\n WHERE name='{$v['name']}'\n {$where_lang}\n {$where_product_id}\n {$where_day}\n ORDER BY product_id DESC, lang='{$v['lang']}' DESC\n "); if ($id) { return $this->load($id); } else { return false; } }
/** * Function must return a needed language to use * based on auth'ed user, session, cookie or get/port vars, * or config settings * @return string like "en" or "ru_KOI8" */ function guess_language() { global $_LANG_SELECTED; if ($_GET['lang'] != '') { $_SESSION['amember_lang'] = $_GET['lang']; $lang = $_GET['lang']; // user is logged-in and changed language global $db; if ($db && $_SESSION['_amember_user'] && $_SESSION['_amember_user']['data']['selected_lang'] != $lang) { #print "Changing language to [$lang]<br />\n"; $u = $db->get_user($_SESSION['_amember_user']['member_id']); $u['data']['selected_lang'] = $lang; $db->update_user($u['member_id'], $u); $_SESSION['_amember_user']['data']['selected_lang'] = $lang; } } elseif ($_SESSION['amember_lang'] != '') { $lang = $_SESSION['amember_lang']; } elseif ($_SESSION['_amember_user']['data']['selected_lang'] != '') { $lang = $_SESSION['_amember_user']['data']['selected_lang']; } else { $lang = get_default_lang(); } return $_LANG_SELECTED = $lang; }
$display_agreement++; } if ($display_agreement && !$vars['i_agree']){ display_agreement(serialize($vars)); // defined in the product.inc.php exit(); } */ $login = $vars['login']; do { // to easy exit using break() $member_id = $db->check_uniq_login($vars['login'], $vars['email'], $vars['pass0'], 1); $member_id_exists = 0; if ($config['verify_email']) { $vars['email_verified'] = -1; } if ($GLOBALS['_LANG_SELECTED'] != get_default_lang()) { $vars['selected_lang'] = $GLOBALS['_LANG_SELECTED']; } if (!$vars['aff_payout_type']) { // if payout type not selected $payout_methods = aff_get_payout_methods(1); if (count($payout_methods) == 1) { // if there is only one payout type $payout_methods = array_keys($payout_methods); $vars['aff_payout_type'] = $payout_methods[0]; } } if ($member_id < 0) { $member_id = $db->add_pending_user($vars); $is_affiliate = '2'; //only affiliate
<?php include("get.php"); include("update.php"); // DEFINE VALUE $req_cat_id = $_POST['cat_id']; $lang_code = $_POST['custom_option_lang']; // CALL FUNCTION $default_value = get_default_lang($req_cat_id); $check_dml = count_category_lang($req_cat_id, $lang_code); /* -- DATA VARIABLE -- */ // DEFAULT VALUE $def_id = $default_value['catgoery_id']; $def_name = $default_value['category_name']; $def_desc = $default_value['category_description']; $def_level = $default_value['category_level']; $def_order = $default_value['category_order']; $def_active = $default_value['category_active_status']; $def_visibility = $default_value['category_visibility_status']; // DUAL VALUE $dual_param = $_POST['cat_id']; $dual_name = addslashes($_POST['category_name']); $dual_desc = $def_desc; $dual_level = $def_level;
function convert_templates() { global $PARSED_EMAIL_TEMPLATES_CONFIG, $config, $db; print <<<CUT <html><head><title>Import E-Mail Templates</title></head> <body> <h3>Import E-Mail Templates (from files to database)</h3> CUT; foreach ($PARSED_EMAIL_TEMPLATES_CONFIG['emails'] as $k => $em) { if ($em['file'] == '') { continue; } $file = $config['root_dir'] . "/templates/" . $em['file']; if (!file_exists($file)) { print "<li style='color:red;font-weight:bold;'>File [{$file}] for template [{$k}] does not exists. Not imported</li>"; continue; } $cnt = join('', file($file)); $db->query("DELETE FROM {$db->config[prefix]}email_templates\n WHERE name='{$k}' AND\n (product_id IS NULL or product_id = 0)\n "); $e =& new aMemberEmailTemplate(); $e->subject = $k; parse_text_template($cnt, $e); $e->name = $k; $e->lang = get_default_lang(); if ($k == 'mail_expire') { $e->day = $config['mail_expire_days'] ? $config['mail_expire_days'] : 1; } $e->save(); print "<li>Template [{$em['file']}] ({$k}) has been imported successfully</li>"; } // import autoresponders $prlist = $db->get_products_list(); $prlist[] = array('product_id' => null, 'autoresponder' => $config['autoresponder']); foreach ($prlist as $pr) { if (!preg_match_all('/^\\s*(\\d+)\\s*\\-\\s*(.+?)\\s*$/m', $pr['autoresponder'], $regs)) { continue; } foreach ($regs[1] as $kk => $k) { $file = $config['root_dir'] . "/templates/" . ($fff = $regs[2][$kk]); if (!file_exists($file)) { print "<li style='color:red;font-weight:bold;'>File [{$file}] for autoresponse template [{$k}] does not exists. Not imported</li>"; continue; } $cnt = join('', file($file)); $where_product_id = $pr['product_id'] > 0 ? " AND product_id = {$pr['product_id']} " : " AND product_id IS NULL "; $dayk = intval($k); $db->query("DELETE FROM {$db->config[prefix]}email_templates\n WHERE name='mail_autoresponder' \n {$where_product_id}\n AND day = '{$dayk}'\n "); $e =& new aMemberEmailTemplate(); $e->subject = "Periodical E-Mail Message"; parse_text_template($cnt, $e); $e->name = "mail_autoresponder"; $e->day = intval($k); $e->product_id = $pr['product_id']; $e->lang = get_default_lang(); $e->save(); print "<li>Autoresponse Template [{$fff}] (mail_autoresponse-{$pr['product_id']}-{$k}) has been imported successfully</li>"; } } print "</body></html>"; }
function openid_create_account() { global $config, $db, $plugin_config; $this_config = $plugin_config['protect']['openid']; $testmode = $this_config['testmode']; // Check create account is allowed if (!$this_config['newaccount']) { header("Location: " . $config['root_url'] . "/signup.php"); exit; } // Check login to OpenID if (!$_SESSION['openid']['identity']) { header("Location: " . $config['root_url'] . "/signup.php"); exit; } // Check there is not already a linked account list($l, $p) = openid_check_logged_in(); if (strlen($l) && strlen($p)) { header("Location: " . $config['root_url'] . "/login.php"); exit; } // Check OpenID email is available, that it is not too long, and not already exists in aMember $email = $_SESSION['openid']['data']['contact/email']; if (!$email || strlen($email) > 64 || $config['unique_email'] && $db->users_find_by_string($email, 'email', 1)) { if ($testmode == 1) { $db->log_error("openid: Create account aborted: Email address too long, not provided, or already exists ({$email})"); } header("Location: " . $config['root_url'] . "/signup.php"); exit; } // Check all required information has been supplied $ax_required = array_filter((array) $this_config['ax_required']); $ax_missing = array(); foreach ($ax_required as $ax) { if (!$_SESSION['openid']['data'][$ax]) { $ax_missing[] = $ax; } } if (count($ax_missing) > 0) { $ax_missing = implode(", ", $ax_missing); if ($testmode == 1) { $db->log_error("openid: Auto-create account aborted: The following required items were missing ({$ax_missing})"); } header("Location: " . $config['root_url'] . "/signup.php"); exit; } // Ok, now we can create the account $vars = array(); if ($_SESSION['openid']['data']['namePerson/first'] && $_SESSION['openid']['data']['namePerson/last']) { $vars['name_f'] = $_SESSION['openid']['data']['namePerson/first']; $vars['name_l'] = $_SESSION['openid']['data']['namePerson/last']; } else { if ($_SESSION['openid']['data']['namePerson']) { list($vars['name_f'], $vars['name_l']) = explode(" ", $_SESSION['openid']['data']['namePerson']); } } foreach ($ax_required as $ax) { $vars[openid_ax2field($ax)] = $_SESSION['openid']['data'][$ax]; if ($ax == 'person/gender') { $vars['is_male'] = $_SESSION['openid']['data'][$ax] == "M" ? 1 : 0; } } $vars['pass'] = $vars['pass0'] = $vars['pass1'] = generate_password($vars); $vars['email'] = $email; $vars['login'] = generate_login($vars); if ($GLOBALS['_LANG_SELECTED'] != get_default_lang()) { $vars['selected_lang'] = $GLOBALS['_LANG_SELECTED']; } $member_id = $db->add_pending_user($vars); $openid = $db->escape($_SESSION['openid']['identity']); $db->query("UPDATE {$db->config['prefix']}members SET openid = '{$openid}' WHERE member_id = '{$member_id}' LIMIT 1"); $db->log_error("openid: Created aMember account for OpenID user ({$openid}) - " . print_r($vars, 1)); $is_affiliate = '0'; //only member newsletters if ($db->get_signup_threads_c($is_affiliate)) { $db->subscribe_member($member_id, $is_affiliate); } // Now add OpenID product subscripton, if set if ($this_config['newaccountproduct']) { $openid_product =& get_product($this_config['newaccountproduct']); $openid_payment = array('member_id' => $member_id, 'product_id' => $openid_product->config['product_id'], 'completed' => 0, 'paysys_id' => 'free', 'begin_date' => $begin_date = date('Y-m-d'), 'expire_date' => $openid_product->get_expire($begin_date)); $db->add_payment($openid_payment); if ($testmode == 1) { $db->log_error("openid: Added subscription (product #{$this_config['newaccountproduct']} ) for OpenID user ({$openid}), login = {$vars['login']}"); } // Now go to thanks page... $payment_id = $GLOBALS['_amember_added_payment_id']; $vcode = md5($payment_id . $begin_date . $member_id); header("Location: " . $config['root_url'] . "/plugins/protect/openid/thanks.php?payment_id={$payment_id}&vcode={$vcode}"); exit; } // Account only - go to member page... header("Location: " . $config['root_url'] . "/member.php"); exit; }