function footer($lang, $components = false) { $languages = false; $contact_page = $newsletter_page = $user_page = $nobody_page = $account_page = $admin_page = false; $is_identified = user_is_identified(); $is_admin = user_has_role('administrator'); $nobody_page = $is_identified ? url('nobody', $lang) : false; if ($components) { foreach ($components as $v => $param) { switch ($v) { case 'languages': if ($param) { $languages = build('languages', $lang, $param); } break; case 'contact': if ($param) { $contact_page = url('contact', $lang); } break; case 'newsletter': if ($param) { $newsletter_page = url('newslettersubscribe', $lang); } break; case 'account': if ($param) { if ($is_identified) { if (!$is_admin) { $account_page = url('account', $lang); } } else { $user_page = url('user', $lang); } } break; case 'admin': if ($param) { $admin_page = $is_admin ? url('admin', $lang) : false; } break; default: break; } } } $output = view('footer', $lang, compact('languages', 'contact_page', 'newsletter_page', 'user_page', 'nobody_page', 'account_page', 'admin_page')); return $output; }
function toolbar($lang, $components = false) { $scroll = $nobody_page = $edit_page = $view_page = $validate_page = $admin_page = false; $is_identified = user_is_identified(); $is_admin = user_has_role('administrator'); $is_writer = user_has_role('writer'); if ($components) { foreach ($components as $v => $param) { switch ($v) { case 'scroll': $scroll = $param ? true : false; break; case 'edit': if ($param) { if ($is_writer) { $edit_page = $param; } } break; case 'view': if ($param) { if ($is_writer) { $view_page = $param; } } break; case 'validate': if ($param) { if ($is_writer) { $validate_page = $param; } } break; case 'admin': if ($param) { if ($is_admin) { $admin_page = url('admin', $lang); } } break; default: break; } } } $output = view('toolbar', $lang, compact('scroll', 'nobody_page', 'edit_page', 'view_page', 'validate_page', 'admin_page')); return $output; }
function account($lang) { if (!user_is_identified()) { return run('user', $lang); } head('title', translate('account:title', $lang)); head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $banner = build('banner', $lang); $user_id = user_profile('id'); $useredit = build('useredit', $lang, $user_id); $content = view('account', $lang, compact('useredit')); $output = layout('standard', compact('banner', 'content')); return $output; }
function paypalcheckout($lang, $amount, $currency, $tax = 0, $context = false) { global $base_url, $paypal_url, $sitename, $supported_languages; if (!user_is_identified()) { return run('error/unauthorized', $lang); } if (!(is_numeric($amount) and $amount > 0)) { return run('error/badrequest', $lang); } $amt = paypal_amt($amount); if (!validate_currency($currency)) { return run('error/badrequest', $lang); } $currencycode = $currency; if (!(is_numeric($tax) and $tax >= 0)) { return run('error/badrequest', $lang); } $taxamt = paypal_amt($tax); $itemamt = paypal_amt($amount - $tax); $name = translate('donate:name', $lang); $locale = $lang; if (!$locale) { $locale = user_profile('locale'); } if (!$locale) { $locale = $supported_languages[0]; } $localecode = paypal_localecode($locale); $email = user_profile('mail'); $brandname = $sitename; $hdrimg = $base_url . '/logos/sitelogo.png'; $returnurl = $base_url . url('paypalreturn', $lang); $cancelurl = $base_url . url('paypalcancel', $lang); $params = array('LOCALECODE' => $localecode, 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', 'PAYMENTREQUEST_0_CURRENCYCODE' => $currencycode, 'PAYMENTREQUEST_0_AMT' => $amt, 'PAYMENTREQUEST_0_ITEMAMT' => $itemamt, 'PAYMENTREQUEST_0_TAXAMT' => $taxamt, 'L_PAYMENTREQUEST_0_NAME0' => $name, 'L_PAYMENTREQUEST_0_AMT0' => $itemamt, 'L_PAYMENTREQUEST_0_TAXAMT0' => $taxamt, 'L_PAYMENTREQUEST_0_QTY0' => '1', 'NOSHIPPING' => '1', 'ALLOWNOTE' => '0', 'EMAIL' => $email, 'BRANDNAME' => $sitename, 'HDRIMG' => $hdrimg, 'RETURNURL' => $returnurl, 'CANCELURL' => $cancelurl); $r = paypal_setexpresscheckout($params); if (!$r) { return run('error/internalerror', $lang); } $token = $r['TOKEN']; $_SESSION['paypal'] = compact('token', 'amt', 'itemamt', 'taxamt', 'currencycode', 'context'); reload($paypal_url . '/webscr&cmd=_express-checkout&token=' . $token); }
function donation($lang) { global $paypal_username, $paypal_password, $paypal_signature; if (empty($paypal_username) or empty($paypal_password) or empty($paypal_signature)) { return run('error/notimplemented', $lang); } if (!user_is_identified()) { return run('user', $lang, array('r' => url('donation', $lang))); } head('title', translate('donation:title', $lang)); head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $contact = true; $banner = build('banner', $lang, compact('contact')); $donateme = build('donateme', $lang); $content = view('donation', $lang, compact('donateme')); $output = layout('standard', compact('banner', 'content')); return $output; }
function banner($lang, $components = false) { global $home_action; $home_page = url($home_action, $lang); $logo = view('logo', $lang, compact('home_page')); $menu = $languages = $headline = $search = $donate = false; $contact_page = $user_page = $nobody_page = $account_page = $edit_page = $view_page = $validate_page = $admin_page = false; $is_identified = user_is_identified(); $is_admin = user_has_role('administrator'); $is_writer = user_has_role('writer'); if ($is_identified) { $nobody_page = url('nobody', $lang); } if ($components) { foreach ($components as $v => $param) { switch ($v) { case 'account': if ($param) { if ($is_identified) { $account_page = url('account', $lang); } else { $user_page = url('user', $lang); } } break; case 'contact': if ($param) { $contact_page = url('contact', $lang); } break; case 'languages': if ($param) { $languages = build('languages', $lang, $param); } break; case 'donate': if ($param) { $donate = build('donate', $lang); } break; case 'headline': if ($param) { $headline = view('headline', false, $param); } break; case 'search': if ($param) { $search = view('searchinput', $lang, $param); } break; case 'edit': if ($param) { if ($is_writer) { $edit_page = $param; } } break; case 'view': if ($param) { if ($is_writer) { $view_page = $param; } } break; case 'validate': if ($param) { if ($is_writer) { $validate_page = $param; } } break; case 'admin': if ($param) { if ($is_admin) { $admin_page = url('admin', $lang); } } break; default: break; } } } $menu = view('bannermenu', $lang, compact('user_page', 'nobody_page', 'account_page', 'contact_page', 'edit_page', 'view_page', 'validate_page', 'admin_page')); $output = view('banner', false, compact('logo', 'menu', 'languages', 'headline', 'search', 'donate')); return $output; }
function user_has_role($role) { return user_is_identified() and !empty($_SESSION['user']['role']) and in_array($role, $_SESSION['user']['role']); }