function test_param_check_passwords()
 {
     set_param('p1', '0');
     set_param('p2', '0');
     $this->assertTrue(param_check_passwords('p1', 'p2', true, 0));
     set_param('p1', '000000');
     set_param('p2', '000000 ');
     $this->assertFalse(param_check_passwords('p1', 'p2'));
     set_param('p1', '1');
     set_param('p2', '2');
     $this->assertFalse(param_check_passwords('p1', 'p2'));
 }
function check_default_settings()
{
    global $parprefix;
    $recset = mysql_query("SELECT * FROM parameter WHERE playerid=0 AND name='{$parprefix}:showartist'");
    if (mysql_num_rows($recset) < 1) {
        // set default values
        set_param("showartist", 1);
        set_param("showtitle", 1);
        set_param("showgenre", 1);
        set_param("showlang", 1);
        set_param("showyear", 1);
        set_param("showrating", 1);
        set_param("showlength", 1);
        set_param("showedit", 1);
        set_param("showdownload", 1);
        set_param("showtoplaylist", 1);
        set_param("brscolumns", 5);
        set_param("playtp", "dl");
    }
}
Example #3
0
        $ItemCache =& get_ItemCache();
        $Item =& $ItemCache->get_by_ID($p, false);
        if (empty($Item)) {
            $Messages->add(sprintf(T_('Front page is set to display page ID=%d but it does not exist.'), $p), 'error');
            $disp = '404';
        }
    }
} elseif (($disp == 'page' || $disp == 'single') && empty($Item)) {
    // 'page' and 'single' are not valid display params if $Item is not set
    // Note: The 'preview' action is the only one exception, but that is handled above in this if statement
    $disp = '404';
    $disp_detail = '404-post_not_found';
}
if ($disp == 'terms') {
    // Display a page of terms & conditions:
    set_param('p', intval($Settings->get('site_terms')));
    $c = 0;
    // Don't display comments
    $ItemCache =& get_ItemCache();
    $Item =& $ItemCache->get_by_ID($p, false);
    if (is_logged_in() && $UserSettings->get('terms_accepted', $current_User->ID)) {
        // Display the message if current user already accepted the terms:
        $Messages->add(T_('You already accepted these terms.'), 'success');
    }
    // Don't redirect to permanent url of the page:
    $redir = 'no';
}
// Check if terms & conditions should be accepted by current user:
if (is_logged_in() && !in_array($disp, array('terms', 'help', 'msgform', 'activateinfo')) && !$UserSettings->get('terms_accepted', $current_User->ID)) {
    // Current user didn't accept the terms yet:
    // Get ID of page with terms & conditions from global settings:
Example #4
0
/**
 * Set a param (global) & Memorize it for automatic future use in regenerate_url()
 *
 * @param string Variable to memorize
 * @param string Type of the variable
 * @param mixed Default value to compare to when regenerating url
 * @param mixed Value to set
 */
function memorize_param($var, $type, $default, $value = NULL)
{
    global $Debuglog, $global_param_list, ${$var};
    if (!isset($global_param_list)) {
        // Init list if necessary:
        if (isset($Debuglog)) {
            $Debuglog->add('init $global_param_list', 'params');
        }
        $global_param_list = array();
    }
    $Debuglog->add("memorize_param: {$var} {$type} default={$default}" . (is_null($value) ? '' : " value={$value}"), 'params');
    $global_param_list[$var] = array('type' => $type, 'default' => $default === true ? NULL : $default);
    if (!is_null($value)) {
        // We want to set the variable too.
        set_param($var, $value);
    }
}
function print_all_reports()
{
    global $atskaite_veids;
    global $lang;
    global $translate;
    global $arrsum;
    global $C_REP;
    global $pavadzimes_tabula;
    global $output_pdf;
    global $output_xml;
    global $output_xml_dir;
    $arrfinal = array();
    $output = "";
    for ($grup = 1; $grup <= $_POST['grup']; $grup++) {
        //Valoda
        if (isset($_POST['valoda' . $grup])) {
            $lang = $_POST['valoda' . $grup];
        } else {
            $lang = 'LAT';
        }
        //        if($_POST['pavadzime']==''){$_POST['pavadzime_head'] = $mpav['pavadzime_head'];}
        if (trim($_POST['pavadzime']) != '') {
            $_POST['pavadzime_head'] = $_POST['pavadzime'];
        }
        set_param('akts_nr', $_POST['akts_nr_head']);
        set_param('pircejs_head', $_POST['pircejs_head']);
        set_param('pircejs_regnum', $_POST['pircejs_regnum']);
        set_param('pardevejs_head', $_POST['pardevejs_head']);
        set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
        set_param('pieg_lig_num', $_POST['pieg_lig_num']);
        set_param('datums', $_POST['datums_head']);
        set_param('iecirknis', $_POST['iecirknis_head']);
        set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
        set_param('pavadzime_head', $_POST['pavadzime_head']);
        set_param('transport_firm', $_POST['transport_firm']);
        set_param('auto', $_POST['auto_head']);
        set_param('soferis', $_POST['soferis_head']);
        set_param('vieta', $_POST['vieta_head']);
        set_param('piezimes', $_POST['piezimes_head']);
        set_param('atbildigais', $_POST['atbildigais_head']);
        set_param('parbaudija', $_POST['parbaudija_head']);
        set_param('veidoja', $_POST['veidoja_head']);
        set_param('custom11', $_POST['custom11_head']);
        set_param('custom12', $_POST['custom12_head']);
        set_param('sortiments', $_POST['sortiments_head']);
        set_param('standarts', $_POST['standarts_head']);
        set_param('metode', $_POST['metode_head']);
        set_param('raukums', $_POST['raukums_head']);
        set_param('merinstruments', $_POST['merinstruments_head']);
        set_param('terminsh', $_POST['terminsh_head']);
        $xml_vars['gvalues' . $grup . '1'] = $_POST['gvalues' . $grup . '1'];
        $xml_vars['gvalues' . $grup . '1_1'] = $_POST['gvalues' . $grup . '1_1'];
        $xml_vars['gvalues' . $grup . '1_2'] = $_POST['gvalues' . $grup . '1_2'];
        $xml_vars['gvalues' . $grup . '2'] = $_POST['gvalues' . $grup . '2'];
        $xml_vars['gvalues' . $grup . '2_1'] = $_POST['gvalues' . $grup . '2_1'];
        $xml_vars['gvalues' . $grup . '2_2'] = $_POST['gvalues' . $grup . '2_2'];
        $xml_vars['gvalues' . $grup . '3'] = $_POST['gvalues' . $grup . '3'];
        $xml_vars['gvalues' . $grup . '3_1'] = $_POST['gvalues' . $grup . '3_1'];
        $xml_vars['gvalues' . $grup . '3_2'] = $_POST['gvalues' . $grup . '3_2'];
        $xml_vars['gvalues' . $grup . '4'] = $_POST['gvalues' . $grup . '4'];
        $xml_vars['gvalues' . $grup . '4_1'] = $_POST['gvalues' . $grup . '4_1'];
        $xml_vars['gvalues' . $grup . '4_2'] = $_POST['gvalues' . $grup . '4_2'];
        $xml_vars['virsmeri' . $grup] = $_POST['virsmeri' . $grup];
        $xml_vars['virsmeri' . $grup . '_1'] = $_POST['virsmeri' . $grup . '_1'];
        $xml_vars['virsmeri' . $grup . '_2'] = $_POST['virsmeri' . $grup . '_2'];
        $xml_vars['virsmeri_brakim' . $grup] = $_POST['virsmeri_brakim' . $grup];
        $xml_vars['virsmeri_brakim' . $grup . '_1'] = $_POST['virsmeri_brakim' . $grup . '_1'];
        $xml_vars['virsmeri_brakim' . $grup . '_2'] = $_POST['virsmeri_brakim' . $grup . '_2'];
        $xml_vars['koeficients' . $grup] = $_POST['koeficients' . $grup];
        $xml_vars['koeficients' . $grup . '_1'] = $_POST['koeficients' . $grup . '_1'];
        $xml_vars['koeficients' . $grup . '_2'] = $_POST['koeficients' . $grup . '_2'];
        $xml_vars['raukums' . $grup] = $_POST['raukums' . $grup];
        $xml_vars['raukums' . $grup . '_1'] = $_POST['raukums' . $grup . '_1'];
        $xml_vars['raukums' . $grup . '_2'] = $_POST['raukums' . $grup . '_2'];
        $xml_vars['pavadzime'] = $_POST['pavadzime'];
        /////////////////////////////////////////////////////////////////////////
        if ($grup == 1) {
            //        $output = $output . "	<html>";
            //        $output = $output . "	<head>";
            if ($output_pdf) {
                require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/g-atskaite.php';
                $g_atskaite = new g_atskaite();
                $g_atskaite->open_pdf();
                $g_atskaite->report_header_pdf($_POST, $lang, $translate);
            } else {
                $output = $output . "\t\t\t\t\t\t <title>Atskaite " . $lang . "</title>";
                $output = $output . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
                $output = $output . "\t\t\t\t\t\t</head>";
                $output = $output . "\t\t\t\t\t\t<center>";
                $output = $output . "\t<STYLE TYPE=\"text/css\">";
                $output = $output . "\t  TD { font-size: 12px; }";
                $output = $output . "\t</STYLE>";
                $output = $output . "\t<table border=0 width=90%><td align=center valign='top'>";
                $output = $output . "\t<table border=0 width=100%><tr>";
                $output = $output . "\t<td width=540><img src=\"images/vmf.gif\"></td>";
                $output = $output . " <td align=center>VMF&nbsp;MI&nbsp;P&nbsp;02.01.02.\n<br />2.variants (12.11.2010.)</td>";
                $output = $output . "\t</tr></table></td>";
                $output = $output . "\t<tr><td align=center valign='top'>";
                $output = $output . "\t<table>";
                $output = $output . "\t<tr>";
                $output = $output . "\t <td align=center width=50></td>";
                $output = $output . "\t <td align=center valign=center><font size=5>" . $translate['virsraksts'][$lang] . get_param('akts_nr') . "</font></td>";
                $output = $output . "\t</tr>";
                $output = $output . "\t</table>";
                $output = $output . "\t<br>";
                $output = $output . "\t<table cellspacing=0 cellpadding=0>";
                if ($_POST['contract_num']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['liguma_nr'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['contract_num'] . "</font></td>";
                }
                if ($_POST['pircejs_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['pircejs'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['pircejs_head'] . "</font></td>";
                }
                if ($_POST['pardevejs_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['pardevejs'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['pardevejs_head'] . "</font></td>";
                }
                if ($_POST['datums_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['datums'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['datums_head'] . "</font></td>";
                }
                if ($_POST['pavadzime_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['pavadzime'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['pavadzime_head'] . "</font></td>";
                }
                if ($_POST['iecirknis_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['iecirknis'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['iecirknis_head'] . "</font></td>";
                }
                if ($_POST['auto_head'] && $atskaite_veids != "nelss") {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['auto_nr'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['auto_head'] . "</font></td>";
                }
                if (strlen($_POST['soferis_head']) > 1) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['soferis'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['soferis_head'] . "</font></td>";
                }
                if ($_POST['vieta_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['uzm_vieta'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['vieta_head'] . "</font></td>";
                }
                if ($_POST['custom12_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $_POST['custom11_head'] . "&nbsp;</font></td><td><font size=3>" . $_POST['custom12_head'] . "</font></td>";
                }
                if ($_POST['sortiments_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['sortiments'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['sortiments_head'] . "</font></td>";
                }
                if ($_POST['standarts_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['standarts'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['standarts_head'] . "</font></td>";
                }
                if ($_POST['metode_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['metode'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['metode_head'] . "</font></td>";
                }
                if ($_POST['raukums_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['raukums'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['raukums_head'] . "</font></td>";
                }
                if ($_POST['merinstruments_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['merinst'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['merinstruments_head'] . "</font></td>";
                }
                if ($_POST['terminsh_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['v_term'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['terminsh_head'] . "</font></td>";
                }
                $output = $output . "</table>";
                $output = $output . "<br><br><br>";
                $output = $output . "<table><tr><td>";
                $output = $output . "<table border=0 cellspacing=0 cellpadding=0>";
            }
        }
        $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
        $C_REP = new C_REPORT($_POST, $DB_CON, $output_xml, $grup);
        if ($C_REP->ERRORS) {
            //            $output = $output . "<html>";
            //            $output = $output . "<head>";
            $output = $output . "<title>Kļūda!</title>";
            $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $output = $output . "</head>";
            $output = $output . "<center>";
            $output = $output . "<STYLE TYPE=\"text/css\">";
            $output = $output . "  TD { font-size: 12px; }";
            $output = $output . "</STYLE>";
            $output = $output . "</style>";
            $output = $output . "<body>";
            $output = $output . "<p class='pagestart'></p><center><br><br>";
            $output = $output . "<b><font color=red>Kļūda!</font></b>";
            $output = $output . "<br><br>";
            $output = $output . $C_REP->ERRORS;
            $output = $output . "</center>";
            /*            $output = $output . "<br><br>";
                        $output = $output . "<input type=button value=\"Atkārtot\" onclick=\"history.back(-1)\">";
            			$output = $output . "<br><br>";*/
            //            $output = $output . "</body>";
            //            $output = $output . "</html>";
            echo $output;
            return $output;
        }
        if ($grup == 1) {
            //šī ir pirmā grupēšanas nosacījumu kopa, kopējam summas no $arr
            $arrsum = $C_REP->arr[count($C_REP->arr) - 1];
            if ($_POST['grup'] != 1) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
            }
            $arrfinal = $C_REP->arr;
        } else {
            //šī nav pirmā grupēšanas nosacījumu kopa, tāpēc pieskaitam doto apakšsummu kopīgajai summai
            $arrsum[summa]->skaits = $arrsum[summa]->skaits + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits;
            $arrsum[summa]->skaits_bad = $arrsum[summa]->skaits_bad + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits_bad;
            $arrsum[summa]->bruto = $arrsum[summa]->bruto + $C_REP->arr[count($C_REP->arr) - 1][summa]->bruto;
            $arrsum[summa]->virsmers = $arrsum[summa]->virsmers + $C_REP->arr[count($C_REP->arr) - 1][summa]->virsmers;
            $arrsum[summa]->redukcija_d = $arrsum[summa]->redukcija_d + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_d;
            $arrsum[summa]->redukcija_l = $arrsum[summa]->redukcija_l + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_l;
            $arrsum[summa]->brakis = $arrsum[summa]->brakis + $C_REP->arr[count($C_REP->arr) - 1][summa]->brakis;
            $arrsum[summa]->neto = $arrsum[summa]->neto + $C_REP->arr[count($C_REP->arr) - 1][summa]->neto;
            if ($grup != $_POST['grup']) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
                //ja nav pēdējā nosacījumu kopa, iztīram kopsummas rindu
            } else {
                $C_REP->arr[count($C_REP->arr) - 1] = $arrsum;
                //ja ir pēdējā nosacījumu kopa, atgriežam kopsummu
            }
            $arrfinal = array_merge($arrfinal, $C_REP->arr);
        }
    }
    if ($_POST['reg_atsk'] == 'on') {
        $skaits = $arrsum[summa]->skaits;
        $skaits_brakis = $arrsum[summa]->skaits_bad;
        $bruto = $arrsum[summa]->bruto;
        $virsmers = $arrsum[summa]->virsmers;
        $redukcija_d = $arrsum[summa]->redukcija_d;
        $redukcija_l = $arrsum[summa]->redukcija_l;
        $redukcija_kopa = $redukcija_l + $redukcija_d;
        $brakis = $arrsum[summa]->brakis;
        $neto = $arrsum[summa]->neto;
        $pavadzime = $_POST['pavadzime'];
        if (trim($_POST['pavadzime']) == '') {
            $pavadzime = $_POST['pavadzime_head'];
        }
        $akta_nr = $_POST['akts_nr_head'];
        $pircejs = $_POST['pircejs_head'];
        $dataKey = explode("/", $_POST['akts_nr_head']);
        $atskaites_veids = get_AtskaitesVeids($dataKey[1]);
        //        set_param('pircejs_regnum',$_POST['pircejs_regnum']);
        $pardevejs = $_POST['pardevejs_head'];
        //        set_param('pardevejs_regnum',$_POST['pardevejs_regnum']);
        $liguma_nr = $h;
        $datums = $_POST['datums_head'];
        $datums = substr($datums, -5, 4) . "-" . substr($datums, -8, 2) . "-" . substr($datums, 0, 2);
        $iecirknis = $_POST['iecirknis_head'];
        $cirsmas_kods = $_POST['cirsmas_kods_head'];
        //        set_param('pavadzime_head',$_POST['pavadzime_head']);
        //        set_param('transport_firm',$_POST['transport_firm']);
        $auto = $_POST['auto_head'];
        $soferis = $_POST['soferis_head'];
        $vieta = AI_returnPlace($_POST['vieta_head']);
        //        set_param('piezimes',$_POST['piezimes_head']);
        //        set_param('atbildigais',$_POST['atbildigais_head']);
        //        set_param('parbaudija',$_POST['parbaudija_head']);
        $veidoja = $_POST['veidoja_head'];
        $piegade = $_POST['kods'];
        //        $atskaites_veids = $_GET["veids"];
        //        set_param('custom11',$_POST['custom11_head']);
        //        set_param('custom12',$_POST['custom12_head']);
        $sortiments = $_POST['sortiments_head'];
        //        set_param('standarts',$_POST['standarts_head']);
        $metode = $_POST['metode_head'];
        //        set_param('raukums',$_POST['raukums_head']);
        //        set_param('merinstruments',$_POST['merinstruments_head']);
        //        set_param('terminsh',$_POST['terminsh_head']);
        $regSQL = "INSERT INTO g_registrs (pircejs,pardevejs,atskaites_veids,piegadatajs,akta_nr,pavadzime,datums_piegade,vieta,soferis,auto_nr,sortiments,skaits_kopa,bruto,neto,virsmers,redukcija,skaits_brakis,brakis,lietotajs_veidoja,atskaites_nr,opcija) VALUES ('{$pircejs}','{$pardevejs}','{$atskaites_veids}','{$piegade}','{$akta_nr}','{$pavadzime}','{$datums}','{$vieta}','{$soferis}','{$auto}','{$sortiments}',{$skaits},{$bruto},{$neto},{$virsmers},{$redukcija_kopa},{$skaits_brakis},{$brakis},'{$veidoja}','{$liguma_nr}','A')";
        mysql_query($regSQL);
    }
    if (!$_POST['negrupet']) {
        usort($arrfinal, 'CompareArrays');
    }
    $arrfinal[-1] = $C_REP->arr[-1];
    $C_REP->arr = $arrfinal;
    if (!$output_pdf) {
        if ($output_xml) {
            $xml_arr = $C_REP->GetXML($pavadzimes_tabula);
            $xml = $xml_arr['file_content'];
        } else {
            $output = $output . $C_REP->GetHTML();
        }
    } else {
        $C_REP->GetHTML($g_atskaite);
    }
    if (!empty($_POST['pavadzime'])) {
        $pavXMLNum = trim($_POST['pavadzime']);
    } else {
        $pavXMLNum = trim($_POST['pavadzime_head']);
    }
    if ($output_xml) {
        $xml = iconv("UTF-8", "cp1257", $xml);
        if (!file_exists("../batch/xml/" . $output_xml_dir) || !is_dir("../batch/xml/" . $output_xml_dir)) {
            mkdir("../batch/xml/" . $output_xml_dir, 0777);
            chmod("../batch/xml/" . $output_xml_dir, 0777);
        }
        if (file_exists("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml")) {
            $output = $output . '</table><BR><BR></td></tr>';
            file_put_contents("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . "_1.xml", $xml);
            $output .= "<font color=red>Šāda pavadzīme jau ir veidota! ../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml </font><BR>";
            $output = $output . "</table></table>";
        } else {
            $output = $output . '</table><BR><BR></td></tr>';
            $arr_Compare = AI_getcompare($pavXMLNum, 'test');
            if ($arr_Compare['skaits_kopa'] != $xml_arr['skaits']) {
                $starpibaSkaitsBalki = $arr_Compare['skaits_kopa'] - $xml_arr['skaits'];
                $output .= "<font color=red>Failā esošo baļķu skaits nesakrīt ar reģistrā esošo baļķu skaitu par " . $starpibaSkaitsBalki . "!</font><BR>";
            }
            if ($arr_Compare['akta_nr'] != $xml_arr['akta_nr']) {
                $starpibaAktaNr = $xml_arr['akta_nr'];
                $output .= "<font color=red>Failā esošais akta numurs(" . $starpibaAktaNr . ") nesakrīt ar reģistrā esošo akta numuru!</font><BR>";
            }
            if ($arr_Compare['bruto'] != $xml_arr['bruto_kopa']) {
                $starpibaBrutoBalki = $arr_Compare['bruto'] - $xml_arr['bruto_kopa'];
                $output .= "<font color=red>Failā esošo baļķu bruto nesakrīt ar reģistrā esošo baļķu bruto par " . $starpibaBrutoBalki . "!</font><BR>";
            }
            file_put_contents("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml", $xml);
            $output .= "Izveidots fails <br />../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml<BR>";
            $output .= "Akta numurs failā " . $xml_arr['akta_nr'] . ".<BR>";
            $output .= "Baļķu skaits failā " . $xml_arr['skaits'] . ".<BR>";
            $output .= "Bruto tilpums failā " . $xml_arr['bruto_kopa'] . " m3.<BR>";
            $output = $output . "</table></table>";
        }
        echo $output;
    } elseif ($output_pdf) {
        $show_reject_codes = !($atskaite_veids == 'vika' || $atskaite_veids == 'gaujaskoks' || $atskaite_veids == 'smiltene' || $atskaite_veids == 'bsw' || $atskaite_veids == 'vudlande' || $atskaite_veids == 'pata_ab');
        $g_atskaite->report_footer_pdf($_POST, $lang, $translate, $show_reject_codes);
        $location = $g_atskaite->pdf_save($atskaite_veids, $_POST['pavadzime']);
        echo "<a href='{$location}'>Atskaite PDF formātā</a><br /><br />";
    } else {
        $output = $output . '</table><BR><BR></td></tr>';
        if ($_POST['piezimes_head']) {
            $output = $output . '<tr><td align=left>' . $translate['piezimes'][$lang] . ': ' . $_POST['piezimes_head'] . '</td></tr>';
        }
        /*Atskaite tiek pievienota papildus informācija par brāki, izņemot VIKAWOOD atskaiti*/
        if ($atskaite_veids == 'vika' || $atskaite_veids == 'gaujaskoks' || $atskaite_veids == 'smiltene' || $atskaite_veids == 'bsw' || $atskaite_veids == '4plus' || $atskaite_veids == 'vudlande' || $atskaite_veids == 'pata_ab' || $atskaite_veids == 'nelss' || $atskaite_veids == 'piebalgas' || $atskaite_veids == 'latvijas_finieris' || $atskaite_veids == 'stora_enso' || $atskaite_veids == 'osukalni' || $atskaite_veids == 'incukalns') {
            $output = $output . "<tr><td height=20></td></tr>";
        } else {
            $output = $output . "<tr><td height=1><br><font size=1><b>Brāķa kodu atšifrējums:</b><br/>0 - Par tievu <br/>1 - Par garu <br/>2 - Max resnākā vieta par lielu <br/>3 - Max tievgalis par lielu <br/>4 - Gadskārtas, Meža trupe, saspiesta koksne, gala plaisas <br/>5 - Sausānis, kaltuši, sānu plaisas <br/>6 - Zari <br>7 - Līkumainība <br/>8 - Cits <br/>9 - Par īsu <br/><br/></td></tr>";
        }
        /************************************************************************************/
        if ($_POST['parbaudija_head'] == 0) {
            if ($_POST['parbaudija_un_atbildigais_head'] == 6) {
                $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
                $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
                $output = $output . "</table></table>";
                //	$output = $output . "</body>";
                //	$output = $output . "</html>";
                echo $output;
            } else {
                $output = $output . "<tr><td align=left>Pārbaudīja/ atbildīgā persona ..................................................." . get_person($_POST['parbaudija_un_atbildigais_head']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
                $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
                $output = $output . "</table></table>";
                //      $output = $output . "</body>";
                //	$output = $output . "</html>";
                echo $output;
            }
        } else {
            $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   <br><br><br>Pārbaudīja .............................................................." . get_person($_POST['parbaudija_head']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
            $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
            $output = $output . "</table></table>";
            //          $output = $output . "</body>";
            //          $output = $output . "</html>";
            echo $output;
        }
    }
}
Example #6
0
/**
 * Initialize internal states for the most common skin displays.
 *
 * For more specific skins, this function may not be called and
 * equivalent code may be customized within the skin.
 *
 * @param string What are we going to display. Most of the time the global $disp should be passed.
 */
function skin_init($disp)
{
    /**
     * @var Blog
     */
    global $Blog;
    /**
     * @var Item
     */
    global $Item;
    /**
     * @var Skin
     */
    global $Skin;
    global $robots_index;
    global $seo_page_type;
    global $redir, $ReqURL, $ReqURI, $m, $w, $preview;
    global $Chapter;
    global $Debuglog;
    /**
     * @var ItemList2
     */
    global $MainList;
    /**
     * This will give more detail when $disp == 'posts'; otherwise it will have the same content as $disp
     * @var string
     */
    global $disp_detail, $Settings;
    global $Timer;
    global $Messages, $PageCache;
    global $Session, $current_User;
    $Timer->resume('skin_init');
    if (empty($disp_detail)) {
        $disp_detail = $disp;
    }
    $Debuglog->add('skin_init: $disp=' . $disp, 'skins');
    // This is the main template; it may be used to display very different things.
    // Do inits depending on current $disp:
    switch ($disp) {
        case 'front':
        case 'posts':
        case 'single':
        case 'page':
        case 'terms':
        case 'download':
        case 'feedback-popup':
            // We need to load posts for this display:
            if ($disp == 'terms') {
                // Initialize the redirect param to know what page redirect after accepting of terms:
                param('redirect_to', 'url', '');
            }
            // Note: even if we request the same post as $Item above, the following will do more restrictions (dates, etc.)
            // Init the MainList object:
            init_MainList($Blog->get_setting('posts_per_page'));
            // Init post navigation
            $post_navigation = $Skin->get_post_navigation();
            if (empty($post_navigation)) {
                $post_navigation = $Blog->get_setting('post_navigation');
            }
            if (!empty($MainList) && $MainList->single_post && ($single_Item =& mainlist_get_item())) {
                // If we are currently viewing a single post
                // We assume the current user will have read the entire post and all its current comments:
                $single_Item->update_read_timestamps(true, true);
                // Restart the items list:
                $MainList->restart();
            }
            break;
        case 'search':
            // Searching post, comments and categories
            load_funcs('collections/_search.funcs.php');
            // Check previous search keywords so it can be displayed in the search input box
            param('s', 'string', '', true);
            break;
    }
    // SEO stuff & redirects if necessary:
    $seo_page_type = NULL;
    switch ($disp) {
        // CONTENT PAGES:
        case 'single':
        case 'page':
        case 'terms':
            if ($disp == 'terms' && !$Item) {
                // Wrong post ID for terms page:
                global $disp;
                $disp = '404';
                $Messages->add(sprintf(T_('Terms not found. (post ID #%s)'), get_param('p')), 'error');
                break;
            }
            if (!$preview && empty($Item)) {
                // No Item, incorrect request and incorrect state of the application, a 404 redirect should have already happened
                //debug_die( 'Invalid page URL!' );
            }
            if ($disp == 'single') {
                $seo_page_type = 'Single post page';
            } else {
                $seo_page_type = '"Page" page';
            }
            if (!$preview) {
                // Check if item has a goal to insert a hit into DB
                $Item->check_goal();
            }
            // Check if the post has 'redirected' status:
            if (!$preview && $Item->status == 'redirected' && $redir == 'yes') {
                // $redir=no here allows to force a 'single post' URL for commenting
                // Redirect to the URL specified in the post:
                $Debuglog->add('Redirecting to post URL [' . $Item->url . '].');
                header_redirect($Item->url, true, true);
            }
            // Check if we want to redirect to a canonical URL for the post
            // Please document encountered problems.
            if (!$preview && ($Blog->get_setting('canonical_item_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_item_urls'))) {
                // We want to redirect to the Item's canonical URL:
                $canonical_url = $Item->get_permanent_url('', '', '&');
                if (preg_match('|[&?](page=\\d+)|', $ReqURI, $page_param)) {
                    // A certain post page has been requested, keep only this param and discard all others:
                    $canonical_url = url_add_param($canonical_url, $page_param[1], '&');
                }
                if (preg_match('|[&?](mode=quote&[qcp]+=\\d+)|', $ReqURI, $page_param)) {
                    // A quote of comment/post, keep only these params and discard all others:
                    $canonical_url = url_add_param($canonical_url, $page_param[1], '&');
                }
                if (!is_same_url($ReqURL, $canonical_url)) {
                    // The requested URL does not look like the canonical URL for this post...
                    // url difference was resolved
                    $url_resolved = false;
                    // Check if the difference is because of an allowed post navigation param
                    if (preg_match('|[&?]cat=(\\d+)|', $ReqURI, $cat_param)) {
                        // A category post navigation param is set
                        $extended_url = '';
                        if ($post_navigation == 'same_category' && isset($cat_param[1])) {
                            // navigatie through posts from the same category
                            $category_ids = postcats_get_byID($Item->ID);
                            if (in_array($cat_param[1], $category_ids)) {
                                // cat param is one of this Item categories
                                $extended_url = $Item->add_navigation_param($canonical_url, $post_navigation, $cat_param[1], '&');
                                // Set MainList navigation target to the requested category
                                $MainList->nav_target = $cat_param[1];
                            }
                        }
                        $url_resolved = is_same_url($ReqURL, $extended_url);
                    }
                    if (preg_match('|[&?]tag=([^&A-Z]+)|', $ReqURI, $tag_param)) {
                        // A tag post navigation param is set
                        $extended_url = '';
                        if ($post_navigation == 'same_tag' && isset($tag_param[1])) {
                            // navigatie through posts from the same tag
                            $tag_names = $Item->get_tags();
                            if (in_array($tag_param[1], $tag_names)) {
                                // tag param is one of this Item tags
                                $extended_url = $Item->add_navigation_param($canonical_url, $post_navigation, $tag_param[1], '&');
                                // Set MainList navigation target to the requested tag
                                $MainList->nav_target = $tag_param[1];
                            }
                        }
                        $url_resolved = is_same_url($ReqURL, $extended_url);
                    }
                    if (!$url_resolved && $Blog->get_setting('canonical_item_urls') && $redir == 'yes' && !$Item->check_cross_post_nav('auto', $Blog->ID)) {
                        // REDIRECT TO THE CANONICAL URL:
                        $Debuglog->add('Redirecting to canonical URL [' . $canonical_url . '].');
                        header_redirect($canonical_url, true);
                    } else {
                        // Use rel="canoncial":
                        add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                    }
                    // EXITED.
                }
            }
            if (!$MainList->result_num_rows) {
                // There is nothing to display for this page, don't index it!
                $robots_index = false;
            }
            break;
        case 'download':
            if (empty($Item)) {
                // No Item, incorrect request and incorrect state of the application, a 404 redirect should have already happened
                debug_die('Invalid page URL!');
            }
            $download_link_ID = param('download', 'integer', 0);
            // Check if we can allow to download the selected file
            $LinkCache =& get_LinkCache();
            if (!(($download_Link =& $LinkCache->get_by_ID($download_link_ID, false, false)) && ($LinkItem =& $download_Link->get_LinkOwner()) && ($LinkItem->Item && $LinkItem->Item->ID == $Item->ID) && ($download_File =& $download_Link->get_File()) && $download_File->exists())) {
                // Bad request, Redirect to Item permanent url
                $Messages->add(T_('The requested file is not available for download.'), 'error');
                $canonical_url = $Item->get_permanent_url('', '', '&');
                $Debuglog->add('Redirecting to canonical URL [' . $canonical_url . '].');
                header_redirect($canonical_url, true);
            }
            // Save the downloading Link to the global vars
            $GLOBALS['download_Link'] =& $download_Link;
            // Save global $Item to $download_Item, because $Item can be rewritten by function get_featured_Item() in some skins
            $GLOBALS['download_Item'] =& $Item;
            init_ajax_forms('blog');
            // auto requires jQuery
            // Initialize JavaScript to download file after X seconds
            add_js_headline('
jQuery( document ).ready( function ()
{
	jQuery( "#download_timer_js" ).show();
} );

var b2evo_download_timer = ' . intval($Blog->get_setting('download_delay')) . ';
var downloadInterval = setInterval( function()
{
	jQuery( "#download_timer" ).html( b2evo_download_timer );
	if( b2evo_download_timer == 0 )
	{ // Stop timer and download a file
		clearInterval( downloadInterval );
		jQuery( "#download_help_url" ).show();
	}
	b2evo_download_timer--;
}, 1000 );');
            // Use meta tag to download file when JavaScript is NOT enabled
            add_headline('<meta http-equiv="refresh" content="' . intval($Blog->get_setting('download_delay')) . '; url=' . $download_Link->get_download_url(array('type' => 'action')) . '" />');
            $seo_page_type = 'Download page';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'posts':
            init_ajax_forms('blog');
            // auto requires jQuery
            // fp> if we add this here, we have to exetnd the inner if()
            // init_ratings_js( 'blog' );
            // Get list of active filters:
            $active_filters = $MainList->get_active_filters();
            if (!empty($active_filters)) {
                // The current page is being filtered...
                if (array_diff($active_filters, array('page')) == array()) {
                    // This is just a follow "paged" page
                    $disp_detail = 'posts-next';
                    $seo_page_type = 'Next page';
                    if ($Blog->get_setting('paged_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                } elseif (array_diff($active_filters, array('cat_array', 'cat_modifier', 'cat_focus', 'posts', 'page')) == array()) {
                    // This is a category page
                    $disp_detail = 'posts-cat';
                    $seo_page_type = 'Category page';
                    if ($Blog->get_setting('chapter_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                    global $cat, $catsel;
                    if (empty($catsel) && preg_match('~^[0-9]+$~', $cat)) {
                        // We are on a single cat page:
                        // NOTE: we must have selected EXACTLY ONE CATEGORY through the cat parameter
                        // BUT: - this can resolve to including children
                        //      - selecting exactly one cat through catsel[] is NOT OK since not equivalent (will exclude children)
                        // echo 'SINGLE CAT PAGE';
                        if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_cat_urls')) {
                            // Check if the URL was canonical:
                            if (!isset($Chapter)) {
                                $ChapterCache =& get_ChapterCache();
                                /**
                                 * @var Chapter
                                 */
                                $Chapter =& $ChapterCache->get_by_ID($MainList->filters['cat_array'][0], false);
                            }
                            if ($Chapter) {
                                if ($Chapter->parent_ID) {
                                    // This is a sub-category page (i-e: not a level 1 category)
                                    $disp_detail = 'posts-subcat';
                                }
                                $canonical_url = $Chapter->get_permanent_url(NULL, NULL, $MainList->get_active_filter('page'), NULL, '&');
                                if (!is_same_url($ReqURL, $canonical_url)) {
                                    // fp> TODO: we're going to lose the additional params, it would be better to keep them...
                                    // fp> what additional params actually?
                                    if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes') {
                                        // REDIRECT TO THE CANONICAL URL:
                                        header_redirect($canonical_url, true);
                                    } else {
                                        // Use rel="canonical":
                                        add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                                    }
                                }
                            } else {
                                // If the requested chapter was not found display 404 page
                                $Messages->add(T_('The requested chapter was not found'));
                                global $disp;
                                $disp = '404';
                                break;
                            }
                        }
                        if ($post_navigation == 'same_category') {
                            // Category is set and post navigation should go through the same category, set navigation target param
                            $MainList->nav_target = $cat;
                        }
                    }
                } elseif (array_diff($active_filters, array('tags', 'posts', 'page')) == array()) {
                    // This is a tag page
                    $disp_detail = 'posts-tag';
                    $seo_page_type = 'Tag page';
                    if ($Blog->get_setting('tag_noindex')) {
                        // We prefer robots not to index tag pages:
                        $robots_index = false;
                    }
                    if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_tag_urls')) {
                        // Check if the URL was canonical:
                        $canonical_url = $Blog->gen_tag_url($MainList->get_active_filter('tags'), $MainList->get_active_filter('page'), '&');
                        if (!is_same_url($ReqURL, $canonical_url)) {
                            if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes') {
                                // REDIRECT TO THE CANONICAL URL:
                                header_redirect($canonical_url, true);
                            } else {
                                // Use rel="canoncial":
                                add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                            }
                        }
                    }
                    $tag = $MainList->get_active_filter('tags');
                    if ($post_navigation == 'same_tag' && !empty($tag)) {
                        // Tag is set and post navigation should go through the same tag, set navigation target param
                        $MainList->nav_target = $tag;
                    }
                } elseif (array_diff($active_filters, array('ymdhms', 'week', 'posts', 'page')) == array()) {
                    // This is an archive page
                    // echo 'archive page';
                    $disp_detail = 'posts-date';
                    $seo_page_type = 'Date archive page';
                    if ($Blog->get_setting('canonical_archive_urls') && $redir == 'yes' || $Blog->get_setting('relcanonical_archive_urls')) {
                        // Check if the URL was canonical:
                        $canonical_url = $Blog->gen_archive_url(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2), $w, '&', $MainList->get_active_filter('page'));
                        if (!is_same_url($ReqURL, $canonical_url)) {
                            if ($Blog->get_setting('canonical_archive_urls') && $redir == 'yes') {
                                // REDIRECT TO THE CANONICAL URL:
                                header_redirect($canonical_url, true);
                            } else {
                                // Use rel="canoncial":
                                add_headline('<link rel="canonical" href="' . $canonical_url . '" />');
                            }
                        }
                    }
                    if ($Blog->get_setting('archive_noindex')) {
                        // We prefer robots not to index archive pages:
                        $robots_index = false;
                    }
                } else {
                    // Other filtered pages:
                    // pre_dump( $active_filters );
                    $disp_detail = 'posts-filtered';
                    $seo_page_type = 'Other filtered page';
                    if ($Blog->get_setting('filtered_noindex')) {
                        // We prefer robots not to index other filtered pages:
                        $robots_index = false;
                    }
                }
            } elseif ($Blog->get_setting('front_disp') == 'posts') {
                // This is the default blog page only if the 'front_disp' is set to 'posts'
                $disp_detail = 'posts-default';
                $seo_page_type = 'Default page';
                if ($Blog->get_setting('default_noindex')) {
                    // We prefer robots not to index archive pages:
                    $robots_index = false;
                }
            }
            break;
        case 'search':
            $seo_page_type = 'Search page';
            if ($Blog->get_setting('filtered_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
            // SPECIAL FEATURE PAGES:
        // SPECIAL FEATURE PAGES:
        case 'feedback-popup':
            $seo_page_type = 'Comment popup';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'arcdir':
            $seo_page_type = 'Date archive directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'catdir':
            $seo_page_type = 'Category directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'msgform':
            global $disp;
            // get expected message form type
            $msg_type = param('msg_type', 'string', '');
            // initialize
            $recipient_User = NULL;
            $Comment = NULL;
            $allow_msgform = NULL;
            // get possible params
            $recipient_id = param('recipient_id', 'integer', 0, true);
            $comment_id = param('comment_id', 'integer', 0, true);
            $post_id = param('post_id', 'integer', 0, true);
            $subject = param('subject', 'string', '');
            // try to init recipient_User
            if (!empty($recipient_id)) {
                $UserCache =& get_UserCache();
                $recipient_User =& $UserCache->get_by_ID($recipient_id);
            } elseif (!empty($comment_id)) {
                // comment id is set, try to get comment author user
                $CommentCache =& get_CommentCache();
                $Comment = $CommentCache->get_by_ID($comment_id, false);
                if ($Comment = $CommentCache->get_by_ID($comment_id, false)) {
                    $recipient_User =& $Comment->get_author_User();
                    if (empty($recipient_User) && $Comment->allow_msgform && is_email($Comment->get_author_email())) {
                        // set allow message form to email because comment author (not registered) accepts email
                        $allow_msgform = 'email';
                        param('recipient_address', 'string', $Comment->get_author_email());
                        param('recipient_name', 'string', $Comment->get_author_name());
                    }
                }
            } else {
                // Recipient was not defined, try set the blog owner as recipient
                global $Blog;
                if (empty($Blog)) {
                    // Blog is not set, this is an invalid request
                    debug_die('Invalid send message request!');
                }
                $recipient_User = $Blog->get_owner_User();
            }
            if ($recipient_User) {
                // recipient User is set
                // get_msgform_possibility returns NULL (false), only if there is no messaging option between current_User and recipient user
                $allow_msgform = $recipient_User->get_msgform_possibility();
                if ($msg_type == 'email' && $recipient_User->get_msgform_possibility(NULL, 'email') != 'email') {
                    // User doesn't want to receive email messages, Restrict if this was requested by wrong url:
                    $msg_type = '';
                }
                if ($allow_msgform == 'login') {
                    // user must login first to be able to send a message to this User
                    $disp = 'login';
                    param('action', 'string', 'req_login');
                    // override redirect to param
                    param('redirect_to', 'url', regenerate_url(), true, true);
                    if (($msg_Blog =& get_setting_Blog('msg_blog_ID')) && $Blog->ID != $msg_Blog->ID) {
                        // Redirect to special blog for messaging actions if it is defined in general settings
                        header_redirect(url_add_param($msg_Blog->get('msgformurl', array('glue' => '&')), 'redirect_to=' . rawurlencode($redirect_to), '&'));
                    }
                    $Messages->add(T_('You must log in before you can contact this user'));
                } elseif ($allow_msgform == 'PM' && check_user_status('can_be_validated')) {
                    // user is not activated
                    if ($recipient_User->accepts_email()) {
                        // recipient User accepts email allow to send email
                        $allow_msgform = 'email';
                        $msg_type = 'email';
                        $activateinfo_link = 'href="' . get_activate_info_url(NULL, '&amp;') . '"';
                        $Messages->add(sprintf(T_('You must activate your account before you can send a private message to %s. However you can send them an email if you\'d like. <a %s>More info &raquo;</a>'), $recipient_User->get('login'), $activateinfo_link), 'warning');
                    } else {
                        // Redirect to the activate info page for not activated users
                        $Messages->add(T_('You must activate your account before you can contact a user. <b>See below:</b>'));
                        header_redirect(get_activate_info_url(), 302);
                        // will have exited
                    }
                } elseif ($msg_type == 'PM' && $allow_msgform == 'email') {
                    // only email is allowed but user expect private message form
                    if (!empty($current_User) && $recipient_id == $current_User->ID) {
                        $Messages->add(T_('You cannot send a private message to yourself. However you can send yourself an email if you\'d like.'), 'warning');
                    } else {
                        $Messages->add(sprintf(T_('You cannot send a private message to %s. However you can send them an email if you\'d like.'), $recipient_User->get('login')), 'warning');
                    }
                } elseif ($msg_type != 'email' && $allow_msgform == 'PM') {
                    // private message form should be displayed, change display to create new individual thread with the given recipient user
                    // check if creating new PM is allowed
                    if (check_create_thread_limit(true)) {
                        // thread limit reached
                        header_redirect();
                        // exited here
                    }
                    global $edited_Thread, $edited_Message, $recipients_selected;
                    // Load classes
                    load_class('messaging/model/_thread.class.php', 'Thread');
                    load_class('messaging/model/_message.class.php', 'Message');
                    // Set global variable to auto define the FB autocomplete plugin field
                    $recipients_selected = array(array('id' => $recipient_User->ID, 'title' => $recipient_User->login));
                    init_tokeninput_js('blog');
                    $disp = 'threads';
                    $edited_Thread = new Thread();
                    $edited_Message = new Message();
                    $edited_Message->Thread =& $edited_Thread;
                    $edited_Thread->recipients = $recipient_User->login;
                    param('action', 'string', 'new', true);
                    param('thrdtype', 'string', 'individual', true);
                }
                if ($allow_msgform == 'email') {
                    // set recippient user param
                    set_param('recipient_id', $recipient_User->ID);
                }
            }
            if ($allow_msgform == NULL) {
                // should be Prevented by UI
                if (!empty($recipient_User)) {
                    $Messages->add(sprintf(T_('The user "%s" does not want to be contacted through the message form.'), $recipient_User->get('login')), 'error');
                } elseif (!empty($Comment)) {
                    $Messages->add(T_('This commentator does not want to get contacted through the message form.'), 'error');
                }
                $blogurl = $Blog->gen_blogurl();
                // If it was a front page request or the front page is set to 'msgform' then we must not redirect to the front page because it is forbidden for the current User
                $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'msgform' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                header_redirect($redirect_to, 302);
                // exited here
            }
            if ($allow_msgform == 'PM' || $allow_msgform == 'email') {
                // Some message form is available
                // Get the suggested subject for the email:
                if (empty($subject)) {
                    // no subject provided by param:
                    global $DB;
                    if (!empty($comment_id)) {
                        // fp>TODO there should be NO SQL in this file. Make a $ItemCache->get_by_comment_ID().
                        $row = $DB->get_row('
							SELECT post_title
								FROM T_items__item, T_comments
							 WHERE comment_ID = ' . $DB->quote($comment_id) . '
								 AND post_ID = comment_item_ID');
                        if ($row) {
                            $subject = T_('Re:') . ' ' . sprintf(T_('Comment on %s'), $row->post_title);
                        }
                    }
                    if (empty($subject) && !empty($post_id)) {
                        // fp>TODO there should be NO SQL in this file. Use $ItemCache->get_by_ID.
                        $row = $DB->get_row('
								SELECT post_title
									FROM T_items__item
								 WHERE post_ID = ' . $post_id);
                        if ($row) {
                            $subject = T_('Re:') . ' ' . $row->post_title;
                        }
                    }
                }
                if ($allow_msgform == 'PM' && isset($edited_Thread)) {
                    $edited_Thread->title = $subject;
                } else {
                    param('subject', 'string', $subject, true);
                }
            }
            if (($msg_Blog =& get_setting_Blog('msg_blog_ID')) && $Blog->ID != $msg_Blog->ID) {
                // Redirect to special blog for messaging actions if it is defined in general settings
                header_redirect($msg_Blog->get('msgformurl', array('glue' => '&')));
            }
            $seo_page_type = 'Contact form';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'messages':
        case 'contacts':
        case 'threads':
            switch ($disp) {
                case 'messages':
                    // Actions ONLY for disp=messages
                    // fp> The correct place to get thrd_ID is here, because we want it in redirect_to in case we need to ask for login.
                    $thrd_ID = param('thrd_ID', 'integer', '', true);
                    if (!is_logged_in()) {
                        // Redirect to the login page for anonymous users
                        $Messages->add(T_('You must log in to read your messages.'));
                        header_redirect(get_login_url('cannot see messages'), 302);
                        // will have exited
                    }
                    // check if user status allow to view messages
                    if (!$current_User->check_status('can_view_messages')) {
                        // user status does not allow to view messages
                        if ($current_User->check_status('can_be_validated')) {
                            // user is logged in but his/her account is not activate yet
                            $Messages->add(T_('You must activate your account before you can read & send messages. <b>See below:</b>'));
                            header_redirect(get_activate_info_url(), 302);
                            // will have exited
                        }
                        $Messages->add('You are not allowed to view Messages!');
                        header_redirect($Blog->gen_blogurl(), 302);
                        // will have exited
                    }
                    // check if user permissions allow to view messages
                    if (!$current_User->check_perm('perm_messaging', 'reply')) {
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Messages!');
                        header_redirect($Blog->gen_blogurl(), 302);
                        // will have exited
                    }
                    if (!empty($thrd_ID)) {
                        // if this thread exists and current user is part of this thread update status because won't be any unread messages on this conversation
                        // we need to mark this early to make sure the unread message count will be correct in the evobar
                        mark_as_read_by_user($thrd_ID, $current_User->ID);
                    }
                    if (($unsaved_message_params = get_message_params_from_session()) !== NULL) {
                        // set Message and Thread saved params from Session
                        global $edited_Message, $action;
                        load_class('messaging/model/_message.class.php', 'Message');
                        $edited_Message = new Message();
                        $edited_Message->text = $unsaved_message_params['message'];
                        $edited_Message->original_text = $unsaved_message_params['message_original'];
                        $edited_Message->set_renderers($unsaved_message_params['renderers']);
                        $edited_Message->thread_ID = $thrd_ID;
                        $action = $unsaved_message_params['action'];
                    }
                    break;
                case 'contacts':
                    // Actions ONLY for disp=contacts
                    if (!is_logged_in()) {
                        // Redirect to the login page for anonymous users
                        $Messages->add(T_('You must log in to manage your contacts.'));
                        header_redirect(get_login_url('cannot see contacts'), 302);
                        // will have exited
                    }
                    if (!$current_User->check_status('can_view_contacts')) {
                        // user is logged in, but his status doesn't allow to view contacts
                        if ($current_User->check_status('can_be_validated')) {
                            // user is logged in but his/her account was not activated yet
                            // Redirect to the account activation page
                            $Messages->add(T_('You must activate your account before you can manage your contacts. <b>See below:</b>'));
                            header_redirect(get_activate_info_url(), 302);
                            // will have exited
                        }
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Contacts!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'contacts' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'contacts' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                    }
                    if (has_cross_country_restriction('any') && empty($current_User->ctry_ID)) {
                        // User may browse/contact other users only from the same country
                        $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                        header_redirect(get_user_profile_url());
                    }
                    // Get action parameter from request:
                    $action = param_action();
                    if (!$current_User->check_perm('perm_messaging', 'reply')) {
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Contacts!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'contacts' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'contacts' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                        // will have exited
                    }
                    switch ($action) {
                        case 'add_user':
                            // Add user to contacts list
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $user_ID = param('user_ID', 'integer', 0);
                            if ($user_ID > 0) {
                                // Add user to contacts
                                if (create_contacts_user($user_ID)) {
                                    // Add user to the group
                                    $group_ID = param('group_ID', 'string', '');
                                    if ($result = create_contacts_group_users($group_ID, $user_ID, 'group_ID_combo')) {
                                        // User has been added to the group
                                        $Messages->add(sprintf(T_('User has been added to the &laquo;%s&raquo; group.'), $result['group_name']), 'success');
                                    } else {
                                        // User has been added ONLY to the contacts list
                                        $Messages->add('User has been added to your contacts.', 'success');
                                    }
                                }
                                header_redirect($Blog->get('userurl', array('url_suffix' => 'user_ID=' . $user_ID, 'glue' => '&')));
                            }
                            break;
                        case 'unblock':
                            // Unblock user
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $user_ID = param('user_ID', 'integer', 0);
                            if ($user_ID > 0) {
                                set_contact_blocked($user_ID, 0);
                                $Messages->add(T_('Contact was unblocked.'), 'success');
                            }
                            break;
                        case 'remove_user':
                            // Remove user from contacts group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $view = param('view', 'string', 'profile');
                            $user_ID = param('user_ID', 'integer', 0);
                            $group_ID = param('group_ID', 'integer', 0);
                            if ($user_ID > 0 && $group_ID > 0) {
                                // Remove user from selected group
                                if (remove_contacts_group_user($group_ID, $user_ID)) {
                                    // User has been removed from the group
                                    if ($view == 'contacts') {
                                        // Redirect to the contacts list
                                        header_redirect($Blog->get('contactsurl', array('glue' => '&')));
                                    } else {
                                        // Redirect to the user profile page
                                        header_redirect($Blog->get('userurl', array('url_suffix' => 'user_ID=' . $user_ID, 'glue' => '&')));
                                    }
                                }
                            }
                            break;
                        case 'add_group':
                            // Add users to the group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $group = param('group', 'string', '');
                            $users = param('users', 'string', '');
                            if ($result = create_contacts_group_users($group, $users)) {
                                // Users have been added to the group
                                $Messages->add(sprintf(T_('%d contacts have been added to the &laquo;%s&raquo; group.'), $result['count_users'], $result['group_name']), 'success');
                                $redirect_to = $Blog->get('contactsurl', array('glue' => '&'));
                                $item_ID = param('item_ID', 'integer', 0);
                                if ($item_ID > 0) {
                                    $redirect_to = url_add_param($redirect_to, 'item_ID=' . $item_ID, '&');
                                }
                                header_redirect($redirect_to);
                            }
                            break;
                        case 'rename_group':
                            // Rename the group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $group_ID = param('group_ID', 'integer', true);
                            if (rename_contacts_group($group_ID)) {
                                $item_ID = param('item_ID', 'integer', 0);
                                $redirect_to = url_add_param($Blog->get('contactsurl', array('glue' => '&')), 'g=' . $group_ID, '&');
                                if ($item_ID > 0) {
                                    $redirect_to = url_add_param($redirect_to, 'item_ID=' . $item_ID, '&');
                                }
                                $Messages->add(T_('The group has been renamed.'), 'success');
                                header_redirect($redirect_to);
                            }
                            break;
                        case 'delete_group':
                            // Delete the group
                            // Check that this action request is not a CSRF hacked request:
                            $Session->assert_received_crumb('messaging_contacts');
                            $group_ID = param('group_ID', 'integer', true);
                            if (delete_contacts_group($group_ID)) {
                                $item_ID = param('item_ID', 'integer', 0);
                                $redirect_to = $Blog->get('contactsurl', array('glue' => '&'));
                                if ($item_ID > 0) {
                                    $redirect_to = url_add_param($redirect_to, 'item_ID=' . $item_ID, '&');
                                }
                                $Messages->add(T_('The group has been deleted.'), 'success');
                                header_redirect($redirect_to);
                            }
                            break;
                    }
                    modules_call_method('switch_contacts_actions', array('action' => $action));
                    break;
                case 'threads':
                    // Actions ONLY for disp=threads
                    if (!is_logged_in()) {
                        // Redirect to the login page for anonymous users
                        $Messages->add(T_('You must log in to read your messages.'));
                        header_redirect(get_login_url('cannot see messages'), 302);
                        // will have exited
                    }
                    if (!$current_User->check_status('can_view_threads')) {
                        // user status does not allow to view threads
                        if ($current_User->check_status('can_be_validated')) {
                            // user is logged in but his/her account is not activate yet
                            $Messages->add(T_('You must activate your account before you can read & send messages. <b>See below:</b>'));
                            header_redirect(get_activate_info_url(), 302);
                            // will have exited
                        }
                        $Messages->add('You are not allowed to view Messages!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'threads' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'threads' ? url_add_param($blogurl, 'disp=404', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                        // will have exited
                    }
                    if (!$current_User->check_perm('perm_messaging', 'reply')) {
                        // Redirect to the blog url for users without messaging permission
                        $Messages->add('You are not allowed to view Messages!');
                        $blogurl = $Blog->gen_blogurl();
                        // If it was a front page request or the front page is set to display 'threads' then we must not redirect to the front page because it is forbidden for the current User
                        $redirect_to = is_front_page() || $Blog->get_setting('front_disp') == 'threads' ? url_add_param($blogurl, 'disp=403', '&') : $blogurl;
                        header_redirect($redirect_to, 302);
                        // will have exited
                    }
                    $action = param('action', 'string', 'view');
                    if ($action == 'new') {
                        // Before new message form is displayed ...
                        if (has_cross_country_restriction('contact') && empty($current_User->ctry_ID)) {
                            // Cross country contact restriction is enabled, but user country is not set yet
                            $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                            header_redirect(get_user_profile_url());
                        } elseif (check_create_thread_limit(true)) {
                            // don't allow to create new thread, because the new thread limit was already reached
                            set_param('action', 'view');
                        }
                    }
                    // Load classes
                    load_class('messaging/model/_thread.class.php', 'Thread');
                    load_class('messaging/model/_message.class.php', 'Message');
                    // Get action parameter from request:
                    $action = param_action('view');
                    switch ($action) {
                        case 'new':
                            // Check permission:
                            $current_User->check_perm('perm_messaging', 'reply', true);
                            global $edited_Thread, $edited_Message;
                            $edited_Thread = new Thread();
                            $edited_Message = new Message();
                            $edited_Message->Thread =& $edited_Thread;
                            modules_call_method('update_new_thread', array('Thread' => &$edited_Thread));
                            if (($unsaved_message_params = get_message_params_from_session()) !== NULL) {
                                // set Message and Thread saved params from Session
                                $edited_Message->text = $unsaved_message_params['message'];
                                $edited_Message->original_text = $unsaved_message_params['message_original'];
                                $edited_Message->set_renderers($unsaved_message_params['renderers']);
                                $edited_Thread->title = $unsaved_message_params['subject'];
                                $edited_Thread->recipients = $unsaved_message_params['thrd_recipients'];
                                $edited_Message->Thread = $edited_Thread;
                                global $thrd_recipients_array, $thrdtype, $action, $creating_success;
                                $thrd_recipients_array = $unsaved_message_params['thrd_recipients_array'];
                                $thrdtype = $unsaved_message_params['thrdtype'];
                                $action = $unsaved_message_params['action'];
                                $creating_success = !empty($unsaved_message_params['creating_success']) ? $unsaved_message_params['creating_success'] : false;
                            } else {
                                if (empty($edited_Thread->recipients)) {
                                    $edited_Thread->recipients = param('thrd_recipients', 'string', '');
                                }
                                if (empty($edited_Thread->title)) {
                                    $edited_Thread->title = param('subject', 'string', '');
                                }
                            }
                            break;
                        default:
                            // Check permission:
                            $current_User->check_perm('perm_messaging', 'reply', true);
                            break;
                    }
                    break;
            }
            // Actions for disp = messages, contacts, threads:
            if (($msg_Blog =& get_setting_Blog('msg_blog_ID')) && $Blog->ID != $msg_Blog->ID) {
                // Redirect to special blog for messaging actions if it is defined in general settings
                $blog_url_params = array('glue' => '&');
                if (!empty($thrd_ID)) {
                    // Don't forget the important param on redirect
                    $blog_url_params['url_suffix'] = 'thrd_ID=' . $thrd_ID;
                }
                header_redirect($msg_Blog->get($disp . 'url', $blog_url_params));
            }
            // just in case some robot would be logged in:
            $seo_page_type = 'Messaging module';
            $robots_index = false;
            // Display messages depending on user email status
            display_user_email_status_message();
            break;
        case 'login':
            global $Plugins, $transmit_hashed_password;
            if (is_logged_in()) {
                // User is already logged in
                if ($current_User->check_status('can_be_validated')) {
                    // account is not active yet, redirect to the account activation page
                    $Messages->add(T_('You are logged in but your account is not activated. You will find instructions about activating your account below:'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // User is already logged in, redirect to "redirect_to" page
                $Messages->add(T_('You are already logged in.'), 'note');
                $redirect_to = param('redirect_to', 'url', NULL);
                if (empty($redirect_to)) {
                    // If empty redirect to referer page
                    $redirect_to = '';
                }
                header_redirect($redirect_to, 302);
                // will have exited
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('loginurl', array('glue' => '&')));
            }
            $seo_page_type = 'Login form';
            $robots_index = false;
            break;
        case 'register':
            if (is_logged_in()) {
                // If user is logged in the register form should not be displayed. In this case redirect to the blog home page.
                $Messages->add(T_('You are already logged in.'), 'note');
                header_redirect($Blog->gen_blogurl(), false);
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('registerurl', array('glue' => '&')));
            }
            $seo_page_type = 'Register form';
            $robots_index = false;
            // Check invitation code if it exists and registration is enabled
            global $display_invitation;
            $display_invitation = check_invitation_code();
            break;
        case 'lostpassword':
            if (is_logged_in()) {
                // If user is logged in the lost password form should not be displayed. In this case redirect to the blog home page.
                $Messages->add(T_('You are already logged in.'), 'note');
                header_redirect($Blog->gen_blogurl(), false);
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('lostpasswordurl', array('glue' => '&')));
            }
            $seo_page_type = 'Lost password form';
            $robots_index = false;
            break;
        case 'activateinfo':
            if (!is_logged_in()) {
                // Redirect to the login page for anonymous users
                $Messages->add(T_('You must log in before you can activate your account.'));
                header_redirect(get_login_url('cannot see messages'), 302);
                // will have exited
            }
            if (!$current_User->check_status('can_be_validated')) {
                // don't display activateinfo screen
                $after_email_validation = $Settings->get('after_email_validation');
                if ($after_email_validation == 'return_to_original') {
                    // we want to return to original page after account activation
                    // check if Session 'validatemail.redirect_to' param is still set
                    $redirect_to = $Session->get('core.validatemail.redirect_to');
                    if (empty($redirect_to)) {
                        // Session param is empty try to get general redirect_to param
                        $redirect_to = param('redirect_to', 'url', '');
                    } else {
                        // cleanup validateemail.redirect_to param from session
                        $Session->delete('core.validatemail.redirect_to');
                    }
                } else {
                    // go to after email validation url which is set in the user general settings form
                    $redirect_to = $after_email_validation;
                }
                if (empty($redirect_to) || preg_match('#disp=activateinfo#', $redirect_to)) {
                    // redirect_to is pointing to the activate info display or is empty
                    // redirect to referer page
                    $redirect_to = '';
                }
                if ($current_User->check_status('is_validated')) {
                    $Messages->add(T_('Your account has already been activated.'));
                }
                header_redirect($redirect_to, 302);
                // will have exited
            }
            if (($login_Blog =& get_setting_Blog('login_blog_ID')) && $Blog->ID != $login_Blog->ID) {
                // Redirect to special blog for login/register actions if it is defined in general settings
                header_redirect($login_Blog->get('activateinfourl', array('glue' => '&')));
            }
            break;
        case 'profile':
        case 'avatar':
            $action = param_action();
            if ($action == 'crop' && is_logged_in()) {
                // Check data for crop action:
                global $current_User, $cropped_File;
                $file_ID = param('file_ID', 'integer');
                if (!($cropped_File = $current_User->get_File_by_ID($file_ID, $error_code))) {
                    // Current user cannot crop this file
                    set_param('action', '');
                }
            }
        case 'pwdchange':
        case 'userprefs':
        case 'subs':
            $seo_page_type = 'Special feature page';
            if ($Blog->get_setting('special_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            // Display messages depending on user email status
            display_user_email_status_message();
            break;
        case 'users':
            if (!is_logged_in() && !$Settings->get('allow_anonymous_user_list')) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $Messages->add(T_('You must log in to view the user directory.'));
                header_redirect(get_login_url('cannot see user'), 302);
                // will have exited
            }
            if (is_logged_in() && !check_user_status('can_view_users')) {
                // user status doesn't permit to view users list
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view the user directory. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // set where to redirect
                $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
                $Messages->add(T_('Your account status currently does not permit to view the user directory.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (has_cross_country_restriction('users', 'list') && empty($current_User->ctry_ID)) {
                // User may browse other users only from the same country
                $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                header_redirect(get_user_profile_url());
            }
            $seo_page_type = 'Users list';
            $robots_index = false;
            break;
        case 'user':
            // get user_ID because we want it in redirect_to in case we need to ask for login.
            $user_ID = param('user_ID', 'integer', '', true);
            // set where to redirect in case of error
            $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $user_available_by_group_level = true;
                if (!empty($user_ID)) {
                    $UserCache =& get_UserCache();
                    if ($User =& $UserCache->get_by_ID($user_ID, false)) {
                        // If user exists we can check if the anonymous users have an access to view the user by group level limitation
                        $User->get_Group();
                        $user_available_by_group_level = $User->Group->level >= $Settings->get('allow_anonymous_user_level_min') && $User->Group->level <= $Settings->get('allow_anonymous_user_level_max');
                    }
                }
                if (!$Settings->get('allow_anonymous_user_profiles') || !$user_available_by_group_level || empty($user_ID)) {
                    // If this user is not available for anonymous users
                    $Messages->add(T_('You must log in to view this user profile.'));
                    header_redirect(get_login_url('cannot see user'), 302);
                    // will have exited
                }
            }
            if (is_logged_in() && !check_user_status('can_view_user', $user_ID)) {
                // user is logged in, but his/her status doesn't permit to view user profile
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view this user profile. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                $Messages->add(T_('Your account status currently does not permit to view this user profile.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (!empty($user_ID)) {
                $UserCache =& get_UserCache();
                $User =& $UserCache->get_by_ID($user_ID, false);
                if (empty($User)) {
                    $Messages->add(T_('The requested user does not exist!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if ($User->check_status('is_closed')) {
                    $Messages->add(T_('The requested user account is closed!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if (has_cross_country_restriction('any')) {
                    if (empty($current_User->ctry_ID)) {
                        // Current User country is not set
                        $Messages->add(T_('Please specify your country before attempting to contact other users.'));
                        header_redirect(get_user_profile_url());
                        // will have exited
                    }
                    if (has_cross_country_restriction('users', 'profile') && $current_User->ctry_ID !== $User->ctry_ID) {
                        // Current user country is different then edited user country and cross country user browsing is not enabled.
                        $Messages->add(T_('You don\'t have permission to view this user profile.'));
                        header_redirect(url_add_param($error_redirect_to, 'disp=403', '&'));
                        // will have exited
                    }
                }
            }
            // Initialize users list from session cache in order to display prev/next links:
            // It is used to navigate between users
            load_class('users/model/_userlist.class.php', 'UserList');
            global $UserList;
            $UserList = new UserList();
            $UserList->memorize = false;
            $UserList->load_from_Request();
            $seo_page_type = 'User display';
            break;
        case 'edit':
            global $current_User, $post_ID;
            // Post ID, go from $_GET when we edit a post from Front-office
            //          or from $_POST when we switch from Back-office
            $post_ID = param('p', 'integer', empty($post_ID) ? 0 : $post_ID, true);
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $redirect_to = url_add_param($Blog->gen_blogurl(), 'disp=edit');
                $Messages->add(T_('You must log in to create & edit posts.'));
                header_redirect(get_login_url('cannot edit posts', $redirect_to), 302);
                // will have exited
            }
            if (!$current_User->check_status('can_edit_post')) {
                if ($current_User->check_status('can_be_validated')) {
                    // user is logged in but his/her account was not activated yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can create & edit posts. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // Redirect to the blog url for users without messaging permission
                $Messages->add(T_('You are not allowed to create & edit posts!'));
                header_redirect($Blog->gen_blogurl(), 302);
            }
            // user logged in and the account was activated
            check_item_perm_edit($post_ID);
            if (!blog_has_cats($Blog->ID)) {
                // No categories are in this blog
                $error_message = T_('Since this blog has no categories, you cannot post into it.');
                if ($current_User->check_perm('blog_cats', 'edit', false, $Blog->ID)) {
                    // If current user has a permission to create a category
                    global $admin_url;
                    $error_message .= ' ' . sprintf(T_('You must <a %s>create categories</a> first.'), 'href="' . $admin_url . '?ctrl=chapters&amp;blog=' . $Blog->ID . '"');
                }
                $Messages->add($error_message, 'error');
                header_redirect($Blog->gen_blogurl(), 302);
            }
            // Prepare the 'In-skin editing':
            init_inskin_editing();
            break;
        case 'edit_comment':
            global $current_User, $edited_Comment, $comment_Item, $Item, $comment_title, $comment_content, $display_params;
            // comment ID
            $comment_ID = param('c', 'integer', 0, true);
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $redirect_to = url_add_param($Blog->gen_blogurl(), 'disp=edit_comment');
                $Messages->add(T_('You must log in to edit comments.'));
                header_redirect(get_login_url('cannot edit comments', $redirect_to), 302);
                // will have exited
            }
            if (!$current_User->check_status('can_edit_comment')) {
                if ($current_User->check_status('can_be_validated')) {
                    // user is logged in but his/her account was not activated yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can edit comments. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                // Redirect to the blog url for users without messaging permission
                $Messages->add('You are not allowed to edit comments!');
                header_redirect($Blog->gen_blogurl(), 302);
            }
            if (empty($comment_ID)) {
                // Can't edit a not exisiting comment
                $Messages->add('Invalid comment edit URL!');
                global $disp;
                $disp = 404;
                break;
            }
            $CommentCache =& get_CommentCache();
            $edited_Comment = $CommentCache->get_by_ID($comment_ID);
            $comment_Item = $edited_Comment->get_Item();
            if (!$current_User->check_perm('comment!CURSTATUS', 'edit', false, $edited_Comment)) {
                // If User has no permission to edit comments with this comment status:
                $Messages->add('You are not allowed to edit the previously selected comment!');
                header_redirect($Blog->gen_blogurl(), 302);
            }
            $comment_title = '';
            $comment_content = htmlspecialchars_decode($edited_Comment->content);
            // Format content for editing, if we were not already in editing...
            $Plugins_admin =& get_Plugins_admin();
            $comment_Item->load_Blog();
            $params = array('object_type' => 'Comment', 'object_Blog' => &$comment_Item->Blog);
            $Plugins_admin->unfilter_contents($comment_title, $comment_content, $edited_Comment->get_renderers_validated(), $params);
            $Item = $comment_Item;
            $display_params = array();
            break;
        case 'useritems':
        case 'usercomments':
            global $display_params, $viewed_User;
            // get user_ID because we want it in redirect_to in case we need to ask for login.
            $user_ID = param('user_ID', 'integer', true, true);
            if (empty($user_ID)) {
                bad_request_die(sprintf(T_('Parameter &laquo;%s&raquo; is required!'), 'user_ID'));
            }
            // set where to redirect in case of error
            $error_redirect_to = empty($Blog) ? $baseurl : $Blog->gen_blogurl();
            if (!is_logged_in()) {
                // Redirect to the login page if not logged in and allow anonymous user setting is OFF
                $Messages->add(T_('You must log in to view this user profile.'));
                header_redirect(get_login_url('cannot see user'), 302);
                // will have exited
            }
            if (is_logged_in() && !check_user_status('can_view_user', $user_ID)) {
                // user is logged in, but his/her status doesn't permit to view user profile
                if (check_user_status('can_be_validated')) {
                    // user is logged in but his/her account is not active yet
                    // Redirect to the account activation page
                    $Messages->add(T_('You must activate your account before you can view this user profile. <b>See below:</b>'));
                    header_redirect(get_activate_info_url(), 302);
                    // will have exited
                }
                $Messages->add(T_('Your account status currently does not permit to view this user profile.'));
                header_redirect($error_redirect_to, 302);
                // will have exited
            }
            if (!empty($user_ID)) {
                $UserCache =& get_UserCache();
                $viewed_User = $UserCache->get_by_ID($user_ID, false);
                if (empty($viewed_User)) {
                    $Messages->add(T_('The requested user does not exist!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
                if ($viewed_User->check_status('is_closed')) {
                    $Messages->add(T_('The requested user account is closed!'));
                    header_redirect($error_redirect_to);
                    // will have exited
                }
            }
            $display_params = !empty($Skin) ? $Skin->get_template('Results') : NULL;
            if ($disp == 'useritems') {
                // Init items list
                global $user_ItemList;
                $useritems_Blog = NULL;
                $user_ItemList = new ItemList2($useritems_Blog, NULL, NULL, NULL, 'ItemCache', 'useritems_');
                $user_ItemList->load_from_Request();
                $user_ItemList->set_filters(array('authors' => $user_ID), true, true);
                $user_ItemList->query();
            } else {
                // Init comments list
                global $user_CommentList;
                $user_CommentList = new CommentList2(NULL, NULL, 'CommentCache', 'usercmts_');
                $user_CommentList->load_from_Request();
                $user_CommentList->set_filters(array('author_IDs' => $user_ID), true, true);
                $user_CommentList->query();
            }
            break;
        case 'comments':
            if (!$Blog->get_setting('comments_latest')) {
                // If latest comments page is disabled - Display 404 page with error message
                $Messages->add(T_('This feature is disabled.'), 'error');
                global $disp;
                $disp = '404';
            }
            break;
        case 'closeaccount':
            global $current_User;
            if (!$Settings->get('account_close_enabled') || is_logged_in() && $current_User->check_perm('users', 'edit', false) || !is_logged_in() && !$Session->get('account_closing_success')) {
                // If an account closing page is disabled - Display 404 page with error message
                // Don't allow admins close own accounts from front office
                // Don't display this message for not logged in users, except of one case to display a bye message after account closing
                global $disp;
                $disp = '404';
            } elseif ($Session->get('account_closing_success')) {
                // User has closed the account
                global $account_closing_success;
                $account_closing_success = $Session->get('account_closing_success');
                // Unset this temp session var to don't display the message twice
                $Session->delete('account_closing_success');
                if (is_logged_in()) {
                    // log out current User
                    logout();
                }
            }
            break;
        case 'tags':
            $seo_page_type = 'Tags';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
    }
    $Debuglog->add('skin_init: $disp=' . $disp . ' / $disp_detail=' . $disp_detail . ' / $seo_page_type=' . $seo_page_type, 'skins');
    // Make this switch block special only for 404 page
    switch ($disp) {
        case '404':
            // We have a 404 unresolved content error
            // How do we want do deal with it?
            skin_404_header();
            // This MAY or MAY not have exited -- will exit on 30x redirect, otherwise will return here.
            // Just in case some dumb robot needs extra directives on this:
            $robots_index = false;
            break;
    }
    global $Hit, $check_browser_version;
    if ($check_browser_version && $Hit->get_browser_version() > 0 && $Hit->is_IE(9, '<')) {
        // Display info message if browser IE < 9 version and it is allowed by config var:
        global $debug;
        $Messages->add(T_('Your web browser is too old. For this site to work correctly, we recommend you use a more recent browser.'), 'note');
        if ($debug) {
            $Messages->add('User Agent: ' . $Hit->get_user_agent(), 'note');
        }
    }
    // dummy var for backward compatibility with versions < 2.4.1 -- prevents "Undefined variable"
    global $global_Cache, $credit_links;
    $credit_links = $global_Cache->get('creds');
    $Timer->pause('skin_init');
    // Check if user is logged in with a not active account, and display an error message if required
    check_allow_disp($disp);
    // initialize Blog enabled widgets, before displaying anything
    init_blog_widgets($Blog->ID);
    // Initialize displaying....
    $Timer->start('Skin:display_init');
    $Skin->display_init();
    $Timer->pause('Skin:display_init');
    // Send default headers:
    // See comments inside of this function:
    headers_content_mightcache('text/html');
    // In most situations, you do NOT want to cache dynamic content!
    // Never allow Messages to be cached!
    if ($Messages->count() && !empty($PageCache)) {
        // Abort PageCache collect
        $PageCache->abort_collect();
    }
}
function print_report()
{
    $output = '';
    $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
    $C_REP = new C_REPORT($_POST, $DB_CON, false);
    /////////////////////////////////////////////////////////////////////////
    $_POST['pavadzime_head'] = $_POST['pavadzime'];
    set_param('akts_nr', $_POST['akts_nr_head']);
    set_param('pircejs_head', $_POST['pircejs_head']);
    set_param('pircejs_regnum', $_POST['pircejs_regnum']);
    set_param('pardevejs_head', $_POST['pardevejs_head']);
    set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
    set_param('pieg_lig_num', $_POST['pieg_lig_num']);
    set_param('datums', $_POST['datums_head']);
    set_param('iecirknis', $_POST['iecirknis_head']);
    set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
    set_param('pavadzime_head', $_POST['pavadzime_head']);
    set_param('transport_firm', $_POST['transport_firm']);
    set_param('auto', $_POST['auto_head']);
    set_param('soferis', $_POST['soferis_head']);
    set_param('vieta', $_POST['vieta_head']);
    set_param('piezimes', $_POST['piezimes_head']);
    set_param('atbildigais', $_POST['atbildigais_head']);
    set_param('custom11', $_POST['custom11_head']);
    set_param('custom12', $_POST['custom12_head']);
    set_param('sortiments', $_POST['sortiments_head']);
    set_param('standarts', $_POST['standarts_head']);
    set_param('metode', $_POST['metode_head']);
    set_param('raukums', $_POST['raukums_head']);
    set_param('merinstruments', $_POST['merinstruments_head']);
    set_param('terminsh', $_POST['terminsh_head']);
    $xml_vars['gvalues1'] = $_POST['gvalues1'];
    $xml_vars['gvalues1_1'] = $_POST['gvalues1_1'];
    $xml_vars['gvalues1_2'] = $_POST['gvalues1_2'];
    $xml_vars['gvalues2'] = $_POST['gvalues2'];
    $xml_vars['gvalues2_1'] = $_POST['gvalues2_1'];
    $xml_vars['gvalues2_2'] = $_POST['gvalues2_2'];
    $xml_vars['gvalues3'] = $_POST['gvalues3'];
    $xml_vars['gvalues3_1'] = $_POST['gvalues3_1'];
    $xml_vars['gvalues3_2'] = $_POST['gvalues3_2'];
    $xml_vars['gvalues4'] = $_POST['gvalues4'];
    $xml_vars['gvalues4_1'] = $_POST['gvalues4_1'];
    $xml_vars['gvalues4_2'] = $_POST['gvalues4_2'];
    $xml_vars['virsmeri'] = $_POST['virsmeri'];
    $xml_vars['virsmeri_1'] = $_POST['virsmeri_1'];
    $xml_vars['virsmeri_2'] = $_POST['virsmeri_2'];
    $xml_vars['koeficients'] = $_POST['koeficients'];
    $xml_vars['koeficients_1'] = $_POST['koeficients_1'];
    $xml_vars['koeficients_2'] = $_POST['koeficients_2'];
    $xml_vars['raukums'] = $_POST['raukums'];
    $xml_vars['raukums_1'] = $_POST['raukums_1'];
    $xml_vars['raukums_2'] = $_POST['raukums_2'];
    $xml_vars['pavadzime'] = $_POST['pavadzime'];
    /////////////////////////////////////////////////////////////////////////
    if ($C_REP->ERRORS) {
        $output = $output . "<html>";
        $output = $output . "<head>";
        $output = $output . "<title>Kļūda!</title>";
        $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
        $output = $output . "</head>";
        $output = $output . "<center>";
        $output = $output . "<STYLE TYPE=\"text/css\">";
        $output = $output . "  TD { font-size: 12px; }";
        $output = $output . "</STYLE>";
        $output = $output . "</style>";
        $output = $output . "<body>";
        $output = $output . "<p class='pagestart'></p><center><br><br>";
        $output = $output . "<b><font color=red>Kļūda!</font></b>";
        $output = $output . "<br><br>";
        $output = $output . $C_REP->ERRORS;
        $output = $output . "</center>";
        $output = $output . "<br><br>";
        $output = $output . "<input type=button value=\"Atkārtot\" onclick=\"history.back(-1)\">";
        $output = $output . "</body>";
        $output = $output . "</html>";
        return $output;
    }
    $output = $output . "\t<html>";
    $output = $output . "\t<head>";
    $output = $output . "\t\t\t\t\t\t <title>Atskaite</title>";
    $output = $output . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
    $output = $output . "\t\t\t\t\t\t</head>";
    $output = $output . "\t\t\t\t\t\t<center>";
    $output = $output . "\t<STYLE TYPE=\"text/css\">";
    $output = $output . "\t  TD { font-size: 12px; }";
    $output = $output . "\t</STYLE>";
    $output = $output . "\t<table border=0 width=90%>";
    $output = $output . "\t<tr>";
    $output = $output . "\t<td><img src=\"images/vmf.gif\"></td>";
    $output = $output . "\t</tr>";
    $output = $output . "\t<tr><td align=center>";
    $output = $output . "\t<table>";
    $output = $output . "\t<tr>";
    $output = $output . "\t <td align=center width=50></td>";
    $output = $output . "\t <td align=center valign=center><font size=5>Testēšanas pārskats nr. " . get_param('akts_nr') . "</font></td>";
    $output = $output . "\t</tr>";
    $output = $output . "\t</table>";
    $output = $output . "\t<br>";
    $output = $output . "\t<table cellspacing=0 cellpadding=0>";
    if ($_POST['contract_num']) {
        $output = $output . "<tr><td align=right>Līguma Nr.:&nbsp;</td><td>" . $_POST['contract_num'] . "</td>";
    }
    if ($_POST['pircejs_head']) {
        $output = $output . "<tr><td align=right>Pircējs:&nbsp;</td><td>" . $_POST['pircejs_head'] . "</td>";
    }
    if ($_POST['pardevejs_head']) {
        $output = $output . "<tr><td align=right>Pārdevējs:&nbsp;</td><td>" . $_POST['pardevejs_head'] . "</td>";
    }
    if ($_POST['datums_head']) {
        $output = $output . "<tr><td align=right>Datums:&nbsp;</td><td>" . $_POST['datums_head'] . "</td>";
    }
    if ($_POST['pavadzime_head']) {
        $output = $output . "<tr><td align=right>Pavadzīme:&nbsp;</td><td>" . $_POST['pavadzime_head'] . "</td>";
    }
    if ($_POST['iecirknis_head']) {
        $output = $output . "<tr><td align=right>Iecirknis:&nbsp;</td><td>" . $_POST['iecirknis_head'] . "</td>";
    }
    if ($_POST['auto_head']) {
        $output = $output . "<tr><td align=right>Automašīnas nr.:&nbsp;</td><td>" . $_POST['auto_head'] . "</td>";
    }
    if ($_POST['soferis_head']) {
        $output = $output . "<tr><td align=right>Šoferis:&nbsp;</td><td>" . $_POST['soferis_head'] . "</td>";
    }
    if ($_POST['vieta_head']) {
        $output = $output . "<tr><td align=right>Uzmērīšanas vieta:&nbsp;</td><td>" . $_POST['vieta_head'] . "</td>";
    }
    if ($_POST['custom12']) {
        $output = $output . "<tr><td align=right>" . $custom11 . "&nbsp;</td><td>" . $_POST['custom12'] . "</td>";
    }
    if ($_POST['sortiments_head']) {
        $output = $output . "<tr><td align=right>Sortiments:&nbsp;</td><td>" . $_POST['sortiments_head'] . "</td>";
    }
    if ($_POST['standarts_head']) {
        $output = $output . "<tr><td align=right>Standarts:&nbsp;</td><td>" . $_POST['standarts_head'] . "</td>";
    }
    if ($_POST['metode_head']) {
        $output = $output . "<tr><td align=right>Metode un paņēmiens:&nbsp;</td><td>" . $_POST['metode_head'] . "</td>";
    }
    if ($_POST['raukums_head']) {
        $output = $output . "<tr><td align=right>Raukums:&nbsp;</td><td>" . $_POST['raukums_head'] . "</td>";
    }
    if ($_POST['merinstruments_head']) {
        $output = $output . "<tr><td align=right>Mērinstruments:&nbsp;</td><td>" . $_POST['merinstruments_head'] . "</td>";
    }
    if ($_POST['terminsh_head']) {
        $output = $output . "<tr><td align=right>Verificēšanas termiņš:&nbsp;</td><td>" . $_POST['terminsh_head'] . "</td>";
    }
    $output = $output . "</table>";
    $output = $output . "<br><br><br>";
    $output = $output . "<table><tr><td>";
    $output = $output . $C_REP->GetHTML();
    $output = $output . '<BR><BR></td></tr>';
    if ($_POST['piezimes_head']) {
        $output = $output . '<tr><td align=left>Piezīmes: ' . $_POST['piezimes_head'] . '</td></tr>';
    }
    $output = $output . "<tr><td height=20></td></tr>";
    $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "</td></tr>";
    $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Artilērijas iela 40, korpuss 12, Rīga, LV-1009 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
    $output = $output . "</table></table>";
    $output = $output . "</body>";
    $output = $output . "</html>";
    return $output;
}
Example #8
0
function print_all_reports()
{
    global $lang;
    global $translate;
    global $arrsum;
    global $C_REP;
    $arrfinal = array();
    $output = "";
    for ($grup = 1; $grup <= $_POST['grup']; $grup++) {
        //Valoda
        if (isset($_POST['valoda' . $grup])) {
            $lang = $_POST['valoda' . $grup];
        } else {
            $lang = 'LAT';
        }
        $_POST['pavadzime_head'] = $_POST['pavadzime'];
        set_param('akts_nr', $_POST['akts_nr_head']);
        set_param('pircejs_head', $_POST['pircejs_head']);
        set_param('pircejs_regnum', $_POST['pircejs_regnum']);
        set_param('pardevejs_head', $_POST['pardevejs_head']);
        set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
        set_param('pieg_lig_num', $_POST['pieg_lig_num']);
        set_param('datums', $_POST['datums_head']);
        set_param('iecirknis', $_POST['iecirknis_head']);
        set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
        set_param('pavadzime_head', $_POST['pavadzime_head']);
        set_param('transport_firm', $_POST['transport_firm']);
        set_param('auto', $_POST['auto_head']);
        set_param('soferis', $_POST['soferis_head']);
        set_param('vieta', $_POST['vieta_head']);
        set_param('piezimes', $_POST['piezimes_head']);
        set_param('atbildigais', $_POST['atbildigais_head']);
        set_param('custom11', $_POST['custom11_head']);
        set_param('custom12', $_POST['custom12_head']);
        set_param('sortiments', $_POST['sortiments_head']);
        set_param('standarts', $_POST['standarts_head']);
        set_param('metode', $_POST['metode_head']);
        set_param('raukums', $_POST['raukums_head']);
        set_param('merinstruments', $_POST['merinstruments_head']);
        set_param('terminsh', $_POST['terminsh_head']);
        $xml_vars['gvalues' . $grup . '1'] = $_POST['gvalues' . $grup . '1'];
        $xml_vars['gvalues' . $grup . '1_1'] = $_POST['gvalues' . $grup . '1_1'];
        $xml_vars['gvalues' . $grup . '1_2'] = $_POST['gvalues' . $grup . '1_2'];
        $xml_vars['gvalues' . $grup . '2'] = $_POST['gvalues' . $grup . '2'];
        $xml_vars['gvalues' . $grup . '2_1'] = $_POST['gvalues' . $grup . '2_1'];
        $xml_vars['gvalues' . $grup . '2_2'] = $_POST['gvalues' . $grup . '2_2'];
        $xml_vars['gvalues' . $grup . '3'] = $_POST['gvalues' . $grup . '3'];
        $xml_vars['gvalues' . $grup . '3_1'] = $_POST['gvalues' . $grup . '3_1'];
        $xml_vars['gvalues' . $grup . '3_2'] = $_POST['gvalues' . $grup . '3_2'];
        $xml_vars['gvalues' . $grup . '4'] = $_POST['gvalues' . $grup . '4'];
        $xml_vars['gvalues' . $grup . '4_1'] = $_POST['gvalues' . $grup . '4_1'];
        $xml_vars['gvalues' . $grup . '4_2'] = $_POST['gvalues' . $grup . '4_2'];
        $xml_vars['virsmeri' . $grup] = $_POST['virsmeri' . $grup];
        $xml_vars['virsmeri' . $grup . '_1'] = $_POST['virsmeri' . $grup . '_1'];
        $xml_vars['virsmeri' . $grup . '_2'] = $_POST['virsmeri' . $grup . '_2'];
        $xml_vars['koeficients' . $grup] = $_POST['koeficients' . $grup];
        $xml_vars['koeficients' . $grup . '_1'] = $_POST['koeficients' . $grup . '_1'];
        $xml_vars['koeficients' . $grup . '_2'] = $_POST['koeficients' . $grup . '_2'];
        $xml_vars['raukums' . $grup] = $_POST['raukums' . $grup];
        $xml_vars['raukums' . $grup . '_1'] = $_POST['raukums' . $grup . '_1'];
        $xml_vars['raukums' . $grup . '_2'] = $_POST['raukums' . $grup . '_2'];
        $xml_vars['pavadzime'] = $_POST['pavadzime'];
        /////////////////////////////////////////////////////////////////////////
        if ($C_REP->ERRORS) {
            //$output = $output . "<html>";
            //$output = $output . "<head>";
            $output = $output . "<title>Kļūda!</title>";
            $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $output = $output . "</head>";
            $output = $output . "<center>";
            $output = $output . "<STYLE TYPE=\"text/css\">";
            $output = $output . "  TD { font-size: 12px; }";
            $output = $output . "</STYLE>";
            $output = $output . "</style>";
            $output = $output . "<body>";
            $output = $output . "<p class='pagestart'></p><center><br><br>";
            $output = $output . "<b><font color=red>Kļūda!</font></b>";
            $output = $output . "<br><br>";
            $output = $output . $C_REP->ERRORS;
            $output = $output . "</center>";
            $output = $output . "<br><br>";
            $output = $output . "<input type=button value=\"Atkārtot\" onclick=\"history.back(-1)\">";
            //$output = $output . "</body>";
            //$output = $output . "</html>";
            return $output;
        }
        if ($grup == 1) {
            //$output = $output . "	<html>";
            //$output = $output . "	<head>";
            $output = $output . "\t\t\t\t\t\t <title>Atskaite " . $lang . "</title>";
            $output = $output . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $output = $output . "\t\t\t\t\t\t</head>";
            $output = $output . "\t\t\t\t\t\t<center>";
            $output = $output . "\t<STYLE TYPE=\"text/css\">";
            $output = $output . "\t  TD { font-size: 12px; }";
            $output = $output . "\t</STYLE>";
            $output = $output . "\t<table border=0 width=90%>";
            $output = $output . "\t<tr>";
            $output = $output . "\t<td><img src=\"images/vmf.gif\"></td>";
            $output = $output . "\t</tr>";
            $output = $output . "\t<tr><td align=center valign='top'>";
            $output = $output . "\t<table>";
            $output = $output . "\t<tr>";
            $output = $output . "\t <td align=center width=50></td>";
            $output = $output . "\t <td align=center valign=center><font size=5>" . $translate['virsraksts'][$lang] . get_param('akts_nr') . "</font></td>";
            $output = $output . "\t</tr>";
            $output = $output . "\t</table>";
            $output = $output . "\t<br>";
            $output = $output . "\t<table cellspacing=0 cellpadding=0>";
            if ($_POST['contract_num']) {
                $output = $output . "<tr><td align=right>" . $translate['liguma_nr'][$lang] . ":&nbsp;</td><td>" . $_POST['contract_num'] . "</td>";
            }
            if ($_POST['pircejs_head']) {
                $output = $output . "<tr><td align=right>" . $translate['pircejs'][$lang] . ":&nbsp;</td><td>" . $_POST['pircejs_head'] . "</td>";
            }
            if ($_POST['pardevejs_head']) {
                $output = $output . "<tr><td align=right>" . $translate['pardevejs'][$lang] . ":&nbsp;</td><td>" . $_POST['pardevejs_head'] . "</td>";
            }
            if ($_POST['datums_head']) {
                $output = $output . "<tr><td align=right>" . $translate['datums'][$lang] . ":&nbsp;</td><td>" . $_POST['datums_head'] . "</td>";
            }
            if ($_POST['pavadzime_head']) {
                $output = $output . "<tr><td align=right>" . $translate['pavadzime'][$lang] . ":&nbsp;</td><td>" . $_POST['pavadzime_head'] . "</td>";
            }
            if ($_POST['iecirknis_head']) {
                $output = $output . "<tr><td align=right>" . $translate['iecirknis'][$lang] . ":&nbsp;</td><td>" . $_POST['iecirknis_head'] . "</td>";
            }
            if ($_POST['auto_head']) {
                $output = $output . "<tr><td align=right>" . $translate['auto_nr'][$lang] . ":&nbsp;</td><td>" . $_POST['auto_head'] . "</td>";
            }
            if ($_POST['soferis_head']) {
                $output = $output . "<tr><td align=right>" . $translate['soferis'][$lang] . ":&nbsp;</td><td>" . $_POST['soferis_head'] . "</td>";
            }
            if ($_POST['vieta_head']) {
                $output = $output . "<tr><td align=right>" . $translate['uzm_vieta'][$lang] . ":&nbsp;</td><td>" . $_POST['vieta_head'] . "</td>";
            }
            if ($_POST['custom12']) {
                $output = $output . "<tr><td align=right>" . $custom11 . "&nbsp;</td><td>" . $_POST['custom12'] . "</td>";
            }
            if ($_POST['sortiments_head']) {
                $output = $output . "<tr><td align=right>" . $translate['sortiments'][$lang] . ":&nbsp;</td><td>" . $_POST['sortiments_head'] . "</td>";
            }
            if ($_POST['standarts_head']) {
                $output = $output . "<tr><td align=right>" . $translate['standarts'][$lang] . ":&nbsp;</td><td>" . $_POST['standarts_head'] . "</td>";
            }
            if ($_POST['metode_head']) {
                $output = $output . "<tr><td align=right>" . $translate['metode'][$lang] . ":&nbsp;</td><td>" . $_POST['metode_head'] . "</td>";
            }
            if ($_POST['raukums_head']) {
                $output = $output . "<tr><td align=right>" . $translate['raukums'][$lang] . ":&nbsp;</td><td>" . $_POST['raukums_head'] . "</td>";
            }
            if ($_POST['merinstruments_head']) {
                $output = $output . "<tr><td align=right>" . $translate['merinst'][$lang] . ":&nbsp;</td><td>" . $_POST['merinstruments_head'] . "</td>";
            }
            if ($_POST['terminsh_head']) {
                $output = $output . "<tr><td align=right>" . $translate['v_term'][$lang] . ":&nbsp;</td><td>" . $_POST['terminsh_head'] . "</td>";
            }
            $output = $output . "</table>";
            $output = $output . "<br><br><br>";
            $output = $output . "<table><tr><td>";
            $output = $output . "<table border=0 cellspacing=0 cellpadding=0>";
        }
        $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
        $C_REP = new C_REPORT($_POST, $DB_CON, false, $grup);
        if ($grup == 1) {
            //šī ir pirmā grupēšanas nosacījumu kopa, kopējam summas no $arr
            $arrsum = $C_REP->arr[count($C_REP->arr) - 1];
            if ($_POST['grup'] != 1) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
            }
            $arrfinal = $C_REP->arr;
        } else {
            //šī nav pirmā grupēšanas nosacījumu kopa, tāpēc pieskaitam doto apakšsummu kopīgajai summai
            $arrsum[summa]->skaits = $arrsum[summa]->skaits + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits;
            $arrsum[summa]->skaits_bad = $arrsum[summa]->skaits_bad + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits_bad;
            $arrsum[summa]->bruto = $arrsum[summa]->bruto + $C_REP->arr[count($C_REP->arr) - 1][summa]->bruto;
            $arrsum[summa]->virsmers = $arrsum[summa]->virsmers + $C_REP->arr[count($C_REP->arr) - 1][summa]->virsmers;
            $arrsum[summa]->redukcija_d = $arrsum[summa]->redukcija_d + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_d;
            $arrsum[summa]->redukcija_l = $arrsum[summa]->redukcija_l + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_l;
            $arrsum[summa]->brakis = $arrsum[summa]->brakis + $C_REP->arr[count($C_REP->arr) - 1][summa]->brakis;
            $arrsum[summa]->neto = $arrsum[summa]->neto + $C_REP->arr[count($C_REP->arr) - 1][summa]->neto;
            if ($grup != $_POST['grup']) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
                //ja nav pēdējā nosacījumu kopa, iztīram kopsummas rindu
            } else {
                $C_REP->arr[count($C_REP->arr) - 1] = $arrsum;
                //ja ir pēdējā nosacījumu kopa, atgriežam kopsummu
            }
            //$C_REP->arr[-1] = array(); //virsrakstus nevajag
            $arrfinal = array_merge($arrfinal, $C_REP->arr);
        }
        /*
        if ($grup < $_POST['grup']) {
        	echo "<p style='page-break-before:always;'>";
        }
        */
    }
    usort($arrfinal, 'CompareArrays');
    $arrfinal[-1] = $C_REP->arr[-1];
    $C_REP->arr = $arrfinal;
    $output = $output . $C_REP->GetHTML();
    $output = $output . '</table><BR><BR></td></tr>';
    if ($_POST['piezimes_head']) {
        $output = $output . '<tr><td align=left>' . $translate['piezimes'][$lang] . ': ' . $_POST['piezimes_head'] . '</td></tr>';
    }
    $output = $output . "<tr><td height=20></td></tr>";
    $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "</td></tr>";
    $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Artilērijas iela 40, korpuss 12, Rīga, LV-1009 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
    $output = $output . "</table></table>";
    echo $output;
}
$Form = new Form(NULL, 'blogperm_checkchanges', 'post', 'fieldset');
$Form->begin_form('fform');
$Form->add_crumb('collection');
$Form->hidden_ctrl();
$Form->hidden('tab', 'perm');
$Form->hidden('blog', $edited_Blog->ID);
$Form->begin_fieldset(T_('User permissions') . get_manual_link('user_permissions'));
/*
 * Query user list:
 */
if (get_param('action') == 'filter2') {
    $keywords = param('keywords2', 'string', '', true);
    set_param('keywords1', $keywords);
} else {
    $keywords = param('keywords1', 'string', '', true);
    set_param('keywords2', $keywords);
}
$SQL = new SQL();
$SQL->SELECT('user_ID, user_login, user_level, bloguser_perm_poststatuses + 0 as perm_poststatuses, bloguser_perm_edit, bloguser_ismember,' . 'bloguser_perm_delcmts, bloguser_perm_recycle_owncmts, bloguser_perm_vote_spam_cmts, bloguser_perm_cmtstatuses + 0 as perm_cmtstatuses, bloguser_perm_edit_cmt,' . 'bloguser_perm_delpost, bloguser_perm_edit_ts, bloguser_perm_cats,' . 'bloguser_perm_properties, bloguser_perm_admin, bloguser_perm_media_upload,' . 'bloguser_perm_media_browse, bloguser_perm_media_change, bloguser_perm_page,' . 'bloguser_perm_intro, bloguser_perm_podcast, bloguser_perm_sidebar');
$SQL->FROM('T_users LEFT JOIN T_coll_user_perms ON (
				 						user_ID = bloguser_user_ID
										AND bloguser_blog_ID = ' . $edited_Blog->ID . ' )');
$SQL->ORDER_BY('bloguser_ismember DESC, *, user_login, user_ID');
if (!empty($keywords)) {
    $SQL->add_search_field('user_login');
    $SQL->add_search_field('user_firstname');
    $SQL->add_search_field('user_lastname');
    $SQL->add_search_field('user_nickname');
    $SQL->add_search_field('user_email');
    $SQL->WHERE_keywords($keywords, 'AND');
}
 *
 * @package evoskins
 * @subpackage bootstrap_manual
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
if (version_compare($app_version, '6.4') < 0) {
    // Older skins (versions 2.x and above) should work on newer b2evo versions, but newer skins may not work on older b2evo versions.
    die('This skin is designed for b2evolution 6.4 and above. Please <a href="http://b2evolution.net/downloads/index.html">upgrade your b2evolution</a>.');
}
if (!empty($requested_404_title)) {
    // Initialize a prefilled search form
    set_param('s', str_replace('-', ' ', $requested_404_title));
    set_param('sentence', 'OR');
    set_param('title', '');
    // Empty this param to exclude a filter by post_urltitle
}
// This is the main template; it may be used to display very different things.
// Do inits depending on current $disp:
skin_init(!empty($requested_404_title) ? 'search' : $disp);
// -------------------------- HTML HEADER INCLUDED HERE --------------------------
skin_include('_html_header.inc.php', array());
// -------------------------------- END OF HEADER --------------------------------
// ---------------------------- SITE HEADER INCLUDED HERE ----------------------------
// If site headers are enabled, they will be included here:
siteskin_include('_site_body_header.inc.php');
// ------------------------------- END OF SITE HEADER --------------------------------
?>

<div class="container">
Example #11
0
 /**
  * Set an order of a list (Use this function after when all $this->cols are already defined)
  *
  * @param string Field name
  * @param string Order direction (A|D)
  * @param boolean Save the filters from Session
  */
 function set_order($order_field, $direction = 'D', $save_filters = false)
 {
     global $Session;
     if (empty($this->cols)) {
         // The columns are not defined yet, Exit here
         return;
     }
     // Force filter param to reset the previous filters
     set_param('filter', 'new');
     $this->refresh_query = true;
     foreach ($this->cols as $col_num => $col) {
         // Find a column number
         if ($col['order'] == $order_field) {
             break;
         }
     }
     if ($save_filters) {
         // Get the filters from Session
         $this->filters = $Session->get($this->filterset_name);
         if (!is_array($this->filters)) {
             $this->filters = array();
         }
         $this->filters = array_merge($this->default_filters, $this->filters);
     } else {
         // Reset the filters
         $this->filters = array();
     }
     // Rewrite a previous order to new value
     $this->filters['order'] = str_repeat('-', $col_num) . $direction;
     $this->order = $this->filters['order'];
     // Save a new order
     $Session->set($this->filterset_name, $this->filters);
     $this->save_filterset();
 }
Example #12
0
 /**
  * Set a parameter from a Request form value.
  *
  * @param string Dataobject parameter name
  * @param string Request parameter name (NULL means to use Dataobject param name with its prefix)
  * @param boolean true to set to NULL if empty string value
  * @return boolean true, if value has been set/changed, false if not.
  */
 function set_from_Request($parname, $var = NULL, $make_null = false, $cleanup_function = NULL)
 {
     if (empty($var)) {
         $var = $this->dbprefix . $parname;
     }
     $value = get_param($var);
     if (!empty($cleanup_function)) {
         //We want to apply a cleanup function
         $value = $cleanup_function($value);
         set_param($var, $value);
     }
     return $this->set($parname, $value, $make_null);
 }
 *
 * @package admin
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $kind, $admin_url, $action, $AdminUI;
$kind_title = get_collection_kinds($kind);
echo action_icon(T_('Abort creating new collection'), 'close', $admin_url . '?ctrl=dashboard', ' ' . sprintf(T_('Abort new "%s" collection'), $kind_title), 3, 3, array('class' => 'action_icon floatright'));
echo '<h2 class="page-title">' . sprintf(T_('New %s'), $kind_title) . ':</h2>';
if ($action == 'new-selskin') {
    // Select an existing skin
    echo '<h3>' . sprintf(T_('Pick an existing skin below: (or <a %s>install a new one now</a>)'), 'href="' . $admin_url . '?ctrl=collections&amp;action=new-installskin&amp;kind=' . $kind . '&amp;skin_type=normal"') . '</h3>';
    $SkinCache =& get_SkinCache();
    $SkinCache->load_all();
    // TODO: this is like touching private parts :>
    foreach ($SkinCache->cache as $Skin) {
        if ($Skin->type != 'normal') {
            // This skin cannot be used here...
            continue;
        }
        $disp_params = array('function' => 'pick', 'select_url' => '?ctrl=collections&amp;action=new-name&amp;kind=' . $kind . '&amp;skin_ID=' . $Skin->ID);
        // Display skinshot:
        Skin::disp_skinshot($Skin->folder, $Skin->name, $disp_params);
    }
    echo '<div class="clear"></div>';
} elseif ($action == 'new-installskin') {
    // Display a form to install new skin
    set_param('redirect_to', $admin_url . '?ctrl=collections&action=new-selskin&kind=' . $kind);
    $AdminUI->disp_view('skins/views/_skin_list_available.view.php');
}
Example #14
0
/**
 * Get threads SQL
 *
 * @param array Params
 * @return Results object
 */
function get_threads_results($params = array())
{
    global $perm_abuse_management, $current_User, $DB;
    // Make sure we are not missing any param:
    $params = array_merge(array('results_param_prefix' => 'thrd_', 'user_ID' => $current_User->ID, 'sent_user_ID' => '', 'search_word' => '', 'search_user' => '', 'show_closed_threads' => NULL, 'only_sql' => false), $params);
    $filter_sql = '';
    if (!empty($params['search_word']) || !empty($params['search_user']) || !empty($params['sent_user_ID'])) {
        // We want to filter on search keyword:
        $filter_sql = array();
        if (!empty($params['search_word'])) {
            // Search by title
            $filter_sql[] = 'thrd_title LIKE "%' . $DB->escape($params['search_word']) . '%"';
        }
        if (!empty($params['search_user'])) {
            // Search by user names
            // Get all threads IDs with searching user name
            $threads_SQL = new SQL();
            $threads_SQL->SELECT('tsta_thread_ID');
            $threads_SQL->FROM('T_users');
            $threads_SQL->FROM_add('INNER JOIN T_messaging__threadstatus ON tsta_user_ID = user_ID');
            $threads_SQL->WHERE('user_login LIKE "%' . $DB->escape($params['search_user']) . '%"');
            $threads_SQL->WHERE_or('user_firstname LIKE "%' . $DB->escape($params['search_user']) . '%"');
            $threads_SQL->WHERE_or('user_lastname LIKE "%' . $DB->escape($params['search_user']) . '%"');
            $threads_SQL->WHERE_or('user_nickname LIKE "%' . $DB->escape($params['search_user']) . '%"');
            $threads_IDs = $DB->get_col($threads_SQL->get());
            if (empty($threads_IDs)) {
                // No found related threads
                $threads_IDs[] = '-1';
            }
            $filter_sql[] = 'tsta_thread_ID IN ( ' . implode(',', $threads_IDs) . ' )';
        }
        if (!empty($params['sent_user_ID'])) {
            // Get all threads IDs with searching user name
            $threads_SQL = new SQL();
            $threads_SQL->SELECT('DISTINCT( msg_thread_ID )');
            $threads_SQL->FROM('T_messaging__message');
            $threads_SQL->WHERE('msg_author_user_ID = ' . $DB->quote($params['sent_user_ID']));
            $threads_IDs = $DB->get_col($threads_SQL->get());
            if (empty($threads_IDs)) {
                // No found related threads
                $threads_IDs[] = '-1';
            }
            $filter_sql[] = 'tsta_thread_ID IN ( ' . implode(',', $threads_IDs) . ' )';
        }
        $filter_sql = count($filter_sql) > 0 ? implode(' OR ', $filter_sql) : '';
    }
    $thrd_msg_ID = $perm_abuse_management ? '"abuse"' : 'tsta_first_unread_msg_ID';
    // Create SELECT SQL query
    $select_SQL = new SQL();
    $select_SQL->SELECT('thrd_ID, thrd_title, thrd_datemodified, ' . $thrd_msg_ID . ' AS thrd_msg_ID, tsta_thread_leave_msg_ID, msg_datetime AS thrd_unread_since');
    $select_SQL->FROM('T_messaging__threadstatus');
    $select_SQL->FROM_add('INNER JOIN T_messaging__thread ON tsta_thread_ID = thrd_ID');
    $select_SQL->FROM_add('LEFT OUTER JOIN T_messaging__message ON tsta_first_unread_msg_ID = msg_ID');
    if (!$perm_abuse_management) {
        // Limit threads by current user
        $select_SQL->WHERE('tsta_user_ID = ' . $params['user_ID']);
        if ($params['show_closed_threads'] === NULL) {
            // Explicit param value was not set, use the default
            // Show closed messages by default only if there are unread messages in closed conversations
            $params['show_closed_threads'] = $DB->get_var('SELECT COUNT( tsta_thread_ID )
					FROM T_messaging__threadstatus
					WHERE tsta_thread_leave_msg_ID IS NOT NULL AND tsta_first_unread_msg_ID IS NOT NULL
					AND tsta_first_unread_msg_ID <= tsta_thread_leave_msg_ID AND tsta_user_ID = ' . $params['user_ID']);
            // Set 'show_closed' param value, so the checkobx filter can be displayed correctly
            set_param('show_closed', $params['show_closed_threads'] ? true : false);
        }
        if (!$params['show_closed_threads']) {
            // Don't show the closed conversations
            $select_SQL->WHERE_and('( tsta_thread_leave_msg_ID IS NULL )');
        }
    }
    if (!empty($filter_sql)) {
        // Filter
        $select_SQL->WHERE_and($filter_sql);
    }
    $select_SQL->ORDER_BY('tsta_first_unread_msg_ID DESC, thrd_datemodified DESC');
    if ($perm_abuse_management) {
        $select_SQL->GROUP_BY('tsta_thread_ID');
    }
    // Create COUNT SQL query
    $count_SQL = new SQL();
    $count_SQL->SELECT('COUNT( DISTINCT tsta_thread_ID )');
    $count_SQL->FROM('T_messaging__threadstatus');
    if (!empty($filter_sql)) {
        // Filter
        $count_SQL->FROM_add('INNER JOIN T_messaging__thread ON tsta_thread_ID = thrd_ID');
    }
    if (!$perm_abuse_management) {
        // Limit threads by current user
        $count_SQL->WHERE('tsta_user_ID = ' . $params['user_ID']);
        if (!$params['show_closed_threads']) {
            // Don't show the closed conversations
            $count_SQL->WHERE_and('( tsta_thread_leave_msg_ID IS NULL )');
        }
    }
    if (!empty($filter_sql)) {
        // Filter
        $count_SQL->WHERE_and($filter_sql);
    }
    if ($params['only_sql']) {
        // Return only SQL object
        return $select_SQL;
    }
    // Create result set:
    $Results = new Results($select_SQL->get(), $params['results_param_prefix'], '', NULL, $count_SQL->get());
    return $Results;
}
Example #15
0
function print_all_reports($atskaites_kods, $tmp_returnResult)
{
    global $lang;
    global $translate;
    global $arrsum;
    global $C_REP;
    global $pavadzimes_tabula;
    global $output_pdf;
    global $subMakeAll;
    global $output_xml;
    global $prefix_subname;
    global $output_xml_dir;
    $arrfinal = array();
    $output = "";
    $tmp_translation['pavadzime'] = "<b>Pavadzīme</b>";
    $tmp_translation['fsc'] = "Sertifikācija";
    $tmp_translation['transp_darba_uzd'] = "Transp. darba uzd.";
    $tmp_translation['pircejs_regnum'] = "Pircējs Reg. Num.";
    $tmp_translation['pardevejs_regnum'] = "Pārdevējs Reg. Num.";
    $tmp_translation['transport_firm'] = "Transp. firma";
    $tmp_translation['kad_piegad'] = "<b>Pavadzīmes datums</b>";
    $tmp_translation['kad_uzmer'] = "Uzm. datums";
    $tmp_translation['auto_head'] = "Automašīnas nr.";
    $tmp_translation['soferis_head'] = "Šoferis";
    $tmp_translation['iecirknis_head'] = "Iecirknis";
    $tmp_translation['pircejs_head'] = "Pircējs";
    $tmp_translation['pardevejs_head'] = "Pārdevējs";
    $tmp_translation['standarts_head'] = "Standarts";
    $tmp_translation['metode_head'] = "Metode";
    $tmp_translation['cirsma_head'] = "Cirsma";
    $tmp_translation['iecirknis_head'] = "Iecirknis";
    $tmp_translation['vieta_head'] = "Uzmērīšanas vieta";
    $tmp_translation['custom12_head'] = $_POST['custom11_head'];
    $tmp_translation['piezimes_head'] = "Piezīmes";
    $tmp_translation['sortiments_head'] = "Sortiments";
    $tmp_translation['raukums_head'] = "Raukums";
    $tmp_translation['merinstruments_head'] = "Mērinstruments";
    $tmp_translation['terminsh_head'] = "Pārbaudes termiņš";
    $lang = 'LAT';
    if (trim($_POST['pavadzime']) != '') {
        $_POST['pavadzime_head'] = $_POST['pavadzime'];
    }
    set_param('akts_nr', $_POST['akts_nr_head']);
    set_param('fsc', $_POST['fsc']);
    set_param('pircejs_head', $_POST['pircejs_head']);
    set_param('pircejs_regnum', $_POST['pircejs_regnum']);
    set_param('pardevejs_head', $_POST['pardevejs_head']);
    set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
    set_param('pieg_lig_num', $_POST['pieg_lig_num']);
    set_param('datums', $_POST['datums_head']);
    set_param('iecirknis', $_POST['iecirknis_head']);
    set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
    set_param('pavadzime_head', $_POST['pavadzime_head']);
    set_param('transport_firm', $_POST['transport_firm']);
    set_param('auto', $_POST['auto_head']);
    set_param('soferis', $_POST['soferis_head']);
    set_param('vieta', $_POST['vieta_head']);
    set_param('piezimes', $_POST['piezimes_head']);
    set_param('atbildigais', $_POST['atbildigais_head']);
    set_param('parbaudija', $_POST['parbaudija_head']);
    set_param('veidoja', $_POST['veidoja_head']);
    set_param('custom11', $_POST['custom11_head']);
    set_param('custom12', $_POST['custom12_head']);
    set_param('sortiments', $_POST['sortiments_head']);
    set_param('standarts', $_POST['standarts_head']);
    set_param('metode', $_POST['metode_head']);
    set_param('raukums', $_POST['raukums_head']);
    set_param('merinstruments', $_POST['merinstruments_head']);
    set_param('terminsh', $_POST['terminsh_head']);
    if ($output_pdf) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/g-atskaite.php';
        $g_atskaite = new g_atskaite();
        $g_atskaite->open_pdf();
        $g_atskaite->report_header_pdf($_POST, $lang, $translate);
    } else {
        $newOutput = $newOutput . "\t\t\t\t\t\t <title>Atskaite " . $lang . "</title>";
        $newOutput = $newOutput . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
        $newOutput = $newOutput . "\t\t\t\t\t\t</head>";
        $newOutput = $newOutput . "\t\t\t\t\t\t<center>";
        $newOutput = $newOutput . "\t<STYLE TYPE=\"text/css\">";
        $newOutput = $newOutput . "\t  TD { font-size: 12px; }";
        $newOutput = $newOutput . "\t</STYLE>";
        $newOutput = $newOutput . "\t<table border=0 width=90%><td align=center valign='top'>";
        $newOutput = $newOutput . "\t<table border=0 width=100%><tr>";
        if (($atskaites_kods == 16 || $subMakeAll) && !$output_pdf) {
            $newOutput = $newOutput . "\t<td width=540><img src=\"images/vmf.gif\"></td><td align=center>VMF&nbsp;MI&nbsp;P&nbsp;02.01.02.\n<br />3. variants (22.02.2011.)</td></tr></table><table><tr><td align=center width=50></td>";
        } else {
            $newOutput = $newOutput . "\t<td width=540><img src=\"images/vmf.gif\"></td><td align=center>VMF&nbsp;MI&nbsp;P&nbsp;02.01.04.\n<br />1. variants (12.11.2010.)</td></tr></table><table><tr><td align=center width=50></td>";
        }
        $newOutput = $newOutput . "\t <td align=center valign=center><font size=5>Testēšanas pārskats nr." . get_param('akts_nr') . "</font></td>";
        $newOutput = $newOutput . "\t</tr></table><br><table cellspacing=0 cellpadding=0 style=\"width:850;\">";
        foreach ($_POST['head'] as $key => $tmp_item_head) {
            $newOutput = $newOutput . "<tr><td align=right><font size=3>" . $tmp_translation[$key] . ":&nbsp;</font></td><td><font size=3>" . $tmp_item_head . "</font></td>";
        }
        $newOutput = $newOutput . "</table><br>";
    }
    //Insert Global new
    $genGlobal_registrs_id = 0;
    if (!$output_xml && !$output_pdf) {
        if ($_POST['reg_atsk'] == 'on') {
            $pavadzime_tmpIns = $_POST['pavadzime'];
            $mysqlGlobal_registrs_insert_txt = "INSERT INTO `g_registrs` (`datums_registrets`,`pavadzime`,`opcija`) values ('" . date("Y-m-d H:i:s") . "','{$pavadzime_tmpIns}','U')";
            $mysqlGlobal_registrs_insert = mysql_query($mysqlGlobal_registrs_insert_txt);
            $genGlobal_registrs_id = mysql_insert_id();
        }
    }
    $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
    $C_REP = new C_REPORT($_POST, $DB_CON, $output_xml, $prefix_subname, $atskaites_kods, $output_pdf, $subMakeAll, $genGlobal_registrs_id, $pavadzime_tmpIns);
    $newOutput .= "<table style=\"border-width:1px;border-style:solid;width:750;\">";
    foreach ($C_REP->arrPrintOut as $tmp_item_1) {
        if ($tmp_item_1['nosaukums'] == 1) {
            $newOutput .= "<tr bgcolor=\"#e1e1e1\" style=\"font-weight:bold;\">";
        } else {
            $newOutput .= "<tr>";
        }
        foreach ($tmp_item_1 as $key => $tmp_item_2) {
            if (($atskaites_kods == 16 || $atskaites_kods == 666 || $subMakeAll || trim($_POST['pavadzime_head']) == '') && !$output_pdf) {
                if ($key != "nosaukums" && $key != "brakis_un_neto" && $key != "redukcija_un_virsmers") {
                    //            if($key != "nosaukums"){
                    $newOutput .= "<td align=center ><font size=3>";
                    $newOutput .= $tmp_item_2;
                    $newOutput .= "</font></td>";
                }
            } else {
                if ($key != "nosaukums" && $key != "garums" && $key != "virsmers" && $key != "redukcija" && $key != "redukcija_un_virsmers") {
                    //            if($key != "nosaukums"){
                    $newOutput .= "<td align=center ><font size=3>";
                    $newOutput .= $tmp_item_2;
                    $newOutput .= "</font></td>";
                }
            }
        }
        $newOutput .= "</tr>";
    }
    $newOutput .= "</table><br /><br /><br /><br />";
    if ($_POST['piezimes_head']) {
        $newOutput = $newOutput . '<tr><td align=left>' . $tmp_translation['piezimes_head'] . ': ' . $_POST['piezimes_head'] . '<br /><br /><br /><br /><br /></td></tr>';
    }
    if ($_POST['parbaudija_head'] == 0) {
        if ($_POST['parbaudija_un_atbildigais_head'] == 6) {
            $newOutput = $newOutput . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n                                            <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
            $newOutput = $newOutput . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
            $newOutput = $newOutput . "</table>";
        } else {
            $newOutput = $newOutput . "<tr><td align=left>Pārbaudīja/ atbildīgā persona ..................................................." . get_person($_POST['parbaudija_un_atbildigais_head']) . "\n                                            <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
            $newOutput = $newOutput . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
            $newOutput = $newOutput . "</table>";
        }
    } else {
        $newOutput = $newOutput . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n                                           <br><br><br>Pārbaudīja .............................................................." . get_person($_POST['parbaudija_head']) . "\n                                           <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
        $newOutput = $newOutput . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
        $newOutput = $newOutput . "</table>";
    }
    if (!$output_xml && !$output_pdf) {
        if ($_POST['reg_atsk'] == 'on') {
            $skaits = $C_REP->regSuperSum[skaits];
            $skaits_brakis = $C_REP->regSuperSum[skaits_brakis];
            $bruto = $C_REP->regSuperSum[bruto];
            $virsmers = $C_REP->regSuperSum[virsmers];
            $redukcija_kopa = $C_REP->regSuperSum[redukcija];
            $brakis = $C_REP->regSuperSum[brakis];
            $neto = $C_REP->regSuperSum[neto];
            $pavadzime = $_POST['pavadzime'];
            if (trim($_POST['pavadzime']) == '') {
                $pavadzime = $_POST['pavadzime_head'];
            }
            $akta_nr = $_POST['akts_nr_head'];
            $pircejs = $_POST['head']['pircejs_head'];
            $dataKey = explode("/", $_POST['akts_nr_head']);
            $atskaites_veids = get_AtskaitesVeids($dataKey[1]);
            $pardevejs = $_POST['head']['pardevejs_head'];
            $liguma_nr = $h;
            $datums = $_POST['head']['kad_uzmer'];
            $datums_piegade = $_POST['head']['kad_piegad'];
            $temp_datums = $datums;
            $temp_datums_arr = explode('.', $temp_datums);
            $datums = $temp_datums_arr[2] . '-' . $temp_datums_arr[1] . '-' . $temp_datums_arr[0];
            $temp_datums_piegad_arr = explode('.', $datums_piegade);
            $datums_piegade = $temp_datums_piegad_arr[2] . '-' . $temp_datums_piegad_arr[1] . '-' . $temp_datums_piegad_arr[0];
            if ($_POST['datums_head']) {
                $datums = $_POST['datums_head'];
                $datums = substr($datums, -5, 4) . "-" . substr($datums, -8, 2) . "-" . substr($datums, 0, 2);
            }
            $iecirknis = $_POST['iecirknis_head'];
            $piegade = $_POST['kods'];
            $cirsmas_kods = $_POST['cirsmas_kods_head'];
            $auto = $_POST['head']['auto_head'];
            $soferis = $_POST['head']['soferis_head'];
            $vieta = AI_returnPlace($_POST['vieta_head']);
            $veidoja = $_POST['veidoja_head'];
            $sortiments = $_POST['head']['sortiments_head'];
            $metode = $_POST['head']['metode_head'];
            $regSQL_update = "UPDATE `g_registrs` SET `pircejs` = '{$pircejs}', `pardevejs` = '{$pardevejs}', `atskaites_veids` = '{$atskaites_veids}', `piegadatajs` = '{$piegade}', `akta_nr` = '{$akta_nr}', `datums_piegade` = '{$datums_piegade}', `iecirknis` = '{$iecirknis}', `datums_uzmer` = '{$datums}', `vieta` = '{$vieta}', `soferis` = '{$soferis}', `auto_nr` = '{$auto}', `sortiments` = '{$sortiments}', `skaits_kopa` = '{$skaits}', `bruto` = '{$bruto}', `neto` = '{$neto}', `virsmers` = '{$virsmers}', `redukcija` = '{$redukcija_kopa}', `skaits_brakis` = '{$skaits_brakis}', `brakis` = '{$brakis}', `lietotajs_veidoja` = '{$veidoja}', `atskaites_nr` = '{$liguma_nr}', `opcija` = 'A' WHERE `id` = {$genGlobal_registrs_id}";
            //        $regSQL = "INSERT INTO g_registrs (pircejs,pardevejs,atskaites_veids,piegadatajs,akta_nr,pavadzime,datums_piegade,vieta,soferis,auto_nr,sortiments,skaits_kopa,bruto,neto,virsmers,redukcija,skaits_brakis,brakis,lietotajs_veidoja,atskaites_nr,opcija) VALUES ('$pircejs','$pardevejs','$atskaites_veids','$piegade','$akta_nr','$pavadzime','$datums','$vieta','$soferis','$auto','$sortiments',$skaits,$bruto,$neto,$virsmers,$redukcija_kopa,$skaits_brakis,$brakis,'$veidoja','$liguma_nr','A')";
            //        echo $regSQL;
            mysql_query($regSQL_update);
        }
    }
    if (!$_POST['negrupet']) {
        usort($arrfinal, 'CompareArrays');
    }
    $arrfinal[-1] = $C_REP->arr[-1];
    $C_REP->arr = $arrfinal;
    if (!$output_pdf) {
        if ($output_xml) {
            $atskaite_veids = $_GET['veids'];
            $xml_arr = $C_REP->GetXML_new($atskaites_kods);
            $xml = $xml_arr['file_content'];
        } else {
            //		$output = $output . $C_REP->GetHTML();
        }
    } else {
        //		$C_REP->GetHTML($g_atskaite);
    }
    if (!empty($_POST['pavadzime'])) {
        $pavXMLNum = trim($_POST['pavadzime']);
    } else {
        $pavXMLNum = trim($_POST['pavadzime_head']);
    }
    if ($output_xml) {
        $xml = iconv("UTF-8", "cp1257", $xml);
        //		if(!file_exists("../batch/xml/".$output_xml_dir) || !is_dir("../batch/xml/".$output_xml_dir)){
        //			mkdir("../batch/xml/".$output_xml_dir, 0777);
        //			chmod("../batch/xml/".$output_xml_dir, 0777);
        //		}
        //		$returnResult = "../batch/xml/".$output_xml_dir;
        $new_xml_data_file = $tmp_returnResult . "/" . $pavXMLNum . ".xml";
        if (file_exists($new_xml_data_file)) {
            $output = $output . '</table><BR><BR></td></tr>';
            file_put_contents("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . "_1.xml", $xml);
            $output .= "<font color=red>Šāda pavadzīme jau ir veidota! ../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml </font><BR>";
            $output = $output . "</table></table>";
        } else {
            //      $output = $output . '</table><BR><BR></td></tr>';
            $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $arr_Compare = AI_getcompare($pavXMLNum, 'test');
            file_put_contents($new_xml_data_file, $xml);
            $output .= "<table width='580' style='border-width:1px;border-style:solid;' width=100%>";
            $output .= "<thead><td align=center bgcolor=#7EB000><b>*.<i>XML</i> datu faila pārbaude</b><br></td></tr></thead>";
            $output .= "<tbody>";
            if ($arr_Compare['skaits_kopa'] != $xml_arr['skaits']) {
                $starpibaSkaitsBalki = $arr_Compare['skaits_kopa'] - $xml_arr['skaits'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu skaits nesakrīt ar reģistrā esošo baļķu skaitu par " . $starpibaSkaitsBalki . "!</font></td></tr>";
            }
            if ($arr_Compare['akta_nr'] != $xml_arr['akta_nr']) {
                $starpibaAktaNr = $xml_arr['akta_nr'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošais akta numurs(" . $starpibaAktaNr . ") nesakrīt ar reģistrā esošo akta numuru!</font></td></tr>";
            }
            if (round($arr_Compare['neto'], 3) != round($xml_arr['neto_kopa'], 3)) {
                $starpibaNetoBalki = $arr_Compare['neto'] - $xml_arr['neto_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu neto nesakrīt ar reģistrā esošo baļķu neto par " . $starpibaNetoBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['brakis'], 3) != round($xml_arr['brakis_kopa'], 3)) {
                $starpibaBrakisBalki = $arr_Compare['brakis'] - $xml_arr['brakis_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu brāķis nesakrīt ar reģistrā esošo baļķu brāķi par " . $starpibaBrakisBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['redukcija'], 3) != round($xml_arr['redukcija_kopa'], 3)) {
                $starpibaRedukcijaBalki = $arr_Compare['redukcija'] - $xml_arr['redukcija_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu redukcija nesakrīt ar reģistrā esošo baļķu redukciju par " . $starpibaRedukcijaBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['virsmers'], 3) != round($xml_arr['virsmers_kopa'], 3)) {
                $starpibaVirsmersBalki = $arr_Compare['virsmers'] - $xml_arr['virsmers_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu virsmērs nesakrīt ar reģistrā esošo baļķu virsmēru par " . $starpibaVirsmersBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['bruto'], 3) != round($xml_arr['bruto_kopa'], 3)) {
                $starpibaBrutoBalki = $arr_Compare['bruto'] - $xml_arr['bruto_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu bruto nesakrīt ar reģistrā esošo baļķu bruto par " . $starpibaBrutoBalki . "!</font></td></tr>";
            }
            $output .= "<tr><td collspan=2>Izveidots fails <a href='../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml' target='_blank'>{$pavXMLNum}</a></td></tr>";
            $output .= "<tr><td>Akta numurs failā " . $xml_arr['akta_nr'] . "</td></tr>";
            $output .= "<tr><td>Baļķu skaits failā " . $xml_arr['skaits'] . "</td></tr>";
            $output .= "<tr><td>Bruto tilpums failā " . $xml_arr['bruto_kopa'] . " m3</td></tr>";
            $output .= "<tr><td>Brāķa tilpums failā " . $xml_arr['brakis_kopa'] . " m3</td></tr>";
            $output .= "<tr><td>Neto tilpums failā " . $xml_arr['neto_kopa'] . "m3</td></tr>";
            //			$output .= "<tr><td>Virsmēra tilpums failā </td><td>".$xml_arr['virsmers_kopa']." m3</td></tr>";
            //			$output .= "<tr><td>Redukcijas tilpums failā </td><td>".$xml_arr['redukcija_kopa']." m3</td></tr>";
            $output = $output . "</tbody></table>";
        }
        echo $output;
    } elseif ($output_pdf) {
        $show_reject_codes = false;
        $g_atskaite->report_pdf($C_REP->arrPrintOut);
        $g_atskaite->report_footer_pdf($_POST, $lang, $translate, $show_reject_codes);
        $new_xml_data_file = $tmp_returnResult . "/" . $pavXMLNum . ".pdf";
        $location = $g_atskaite->pdf_save($new_xml_data_file, $pavXMLNum);
        //    echo '<iframe width="50%" style="height: 85em;" src="'.$location.'"></iframe>';
        //		echo "<a href='$location'>Atskaite PDF formātā</a><br /><br />";
    } else {
        echo $newOutput;
    }
    return true;
}
Example #16
0
 /**
  * Event handler: Called at the begining of the "Register as new user" form.
  *
  * You might want to use this to inject antispam payload to use
  * in {@link Plugin::RegisterFormSent()}.
  *
  * @param array Associative array of parameters
  *   - 'Form': the comment form generating object (by reference)
  *   - 'inskin': boolean true if the form is displayed in skin
  */
 function DisplayRegisterFormBefore(&$params)
 {
     global $Settings;
     $registration_require_country = (bool) $Settings->get('registration_require_country');
     if (!$registration_require_country) {
         // Country is not required on registration form. Exit here.
         return;
     }
     $detect_registration = $this->Settings->get('detect_registration');
     if ($detect_registration == 'no') {
         // No detect country on registration
         return;
     }
     $Country = $this->get_country_by_IP($_SERVER['REMOTE_ADDR']);
     if (!$Country) {
         // No found country by IP address
         return;
     }
     switch ($detect_registration) {
         case 'auto':
             // Auto select current country in list
             $country = param('country', 'integer', 0);
             if (empty($country)) {
                 // Set country ID if user didn't select country yet
                 set_param('country', $Country->ID);
             }
             break;
         case 'hide':
             // Hide country selector if a country has been detected
             if (!isset($params['Form'])) {
                 // there's no Form where we add to, but we create our own form:
                 $Form = new Form(regenerate_url());
             } else {
                 $Form =& $params['Form'];
             }
             // Disable this setting temporary to hide a select list with countries
             $Settings->set('registration_require_country', 0);
             // Append a hidden input element with autodetected country ID
             $Form->hidden('country', $Country->ID);
             break;
     }
 }
     // set saved Comment attributes from Session
     $comment_content = $Comment->content;
     $comment_author = $Comment->author;
     $comment_author_email = $Comment->author_email;
     $comment_author_url = $Comment->author_url;
     // comment_attachments contains all file IDs that have been attached
     $comment_attachments = $Comment->preview_attachments;
     // checked_attachments contains all attachment file IDs which checkbox was checked in
     $checked_attachments = $Comment->checked_attachments;
 }
 if ($params['comment_mode'] == 'quote') {
     // These params go from ajax form loading, Used to reply with quote
     set_param('mode', $params['comment_mode']);
     set_param('qc', $params['comment_qc']);
     set_param('qp', $params['comment_qp']);
     set_param($dummy_fields['content'], $params[$dummy_fields['content']]);
 }
 $mode = param('mode', 'string');
 if ($mode == 'quote') {
     // Quote for comment/post
     $comment_content = param($dummy_fields['content'], 'html');
     $quoted_comment_ID = param('qc', 'integer', 0);
     $quoted_post_ID = param('qp', 'integer', 0);
     if (!empty($quoted_comment_ID)) {
         $CommentCache =& get_CommentCache();
         $quoted_Comment =& $CommentCache->get_by_ID($quoted_comment_ID, false);
         $quoted_Item = $quoted_Comment->get_Item();
         if ($quoted_User = $quoted_Comment->get_author_User()) {
             // User is registered
             $quoted_login = $quoted_User->login;
         } else {
 function SetParam()
 {
     set_param('akts_nr', $this->MyPOST['akts_nr_head']);
     set_param('pircejs', $this->MyPOST['pircejs_head']);
     set_param('pardevejs', $this->MyPOST['pardevejs_head']);
     set_param('pieg_lig_num', $this->MyPOST['pieg_lig_num']);
     set_param('datums', $this->MyPOST['datums_head']);
     set_param('iecirknis', $this->MyPOST['iecirknis_head']);
     set_param('pavadzime_head', $this->MyPOST['pavadzime_head']);
     set_param('auto', $this->MyPOST['auto_head']);
     set_param('soferis', $this->MyPOST['soferis_head']);
     set_param('vieta', $this->MyPOST['vieta_head']);
     set_param('piezimes', $this->MyPOST['piezimes_head']);
     set_param('atbildigais', $this->MyPOST['atbildigais_head']);
     set_param('custom11', $this->MyPOST['custom11_head']);
     set_param('custom12', $this->MyPOST['custom12_head']);
 }
Example #19
0
        load_class('messaging/model/_thread.class.php', 'Thread');
        load_class('messaging/model/_message.class.php', 'Message');
        // Set global variable to auto define the FB autocomplete plugin field
        $recipients_selected = array(array('id' => $recipient_User->ID, 'title' => $recipient_User->login));
        init_tokeninput_js('blog');
        $disp = 'threads';
        $edited_Thread = new Thread();
        $edited_Message = new Message();
        $edited_Message->Thread =& $edited_Thread;
        $edited_Thread->recipients = $recipient_User->login;
        param('action', 'string', 'new', true);
        param('thrdtype', 'string', 'individual', true);
    }
    if ($allow_msgform == 'email') {
        // set recippient user param
        set_param('recipient_id', $recipient_User->ID);
    }
}
if ($allow_msgform == NULL) {
    // should be Prevented by UI
    if (!empty($recipient_User)) {
        $Messages->add(T_('The user does not want to get contacted through the message form.'));
    } elseif (!empty($Comment)) {
        $Messages->add(T_('This commentator does not want to get contacted through the message form.'));
    }
    header_redirect();
    // exited here
}
if ($allow_msgform == 'PM' || $allow_msgform == 'email') {
    // Some message form is available
    // Get the suggested subject for the email:
Example #20
0
/**
 * Check invitation code and display error on incorrect code
 * This function is used on registration form
 *
 * @param string Name of invitation field
 * @return string What field to display on registration form for invitation code:
 *        ''      - Don't display a field of invitation code
 *        'info'  - Display an info field with invitation code
 *        'input' - Display an input field to change invitation code
 *        'deny'  - Don't display a registration form at all
 */
function check_invitation_code($invitation_name = 'invitation')
{
    global $Settings;
    if ($Settings->get('newusers_canregister') == 'no') {
        // Don't display a registration form when it is disabled for all
        return 'deny';
    }
    $invitation = param($invitation_name, 'string');
    if ($invitation == 'y') {
        // It is used to enter an invatation code manually
        set_param($invitation_name, '');
        return 'input';
    } elseif (!empty($invitation)) {
        // Check invitation code if it is entered
        if (!preg_match('#^[A-Za-z0-9\\-_]{3,32}$#', $invitation)) {
            // Invitation code has incorrect format
            param_error($invitation_name, T_('Invitation code is incorrect!'));
            return 'input';
        } else {
            // Check invitation code in DB
            global $DB, $localtimenow;
            $SQL = new SQL();
            $SQL->SELECT('ivc_ID');
            $SQL->FROM('T_users__invitation_code');
            $SQL->WHERE('ivc_code = ' . $DB->quote($invitation));
            $SQL->WHERE_and('ivc_expire_ts > ' . $DB->quote(date('Y-m-d H:i:s', $localtimenow)));
            $invitation_ID = $DB->get_var($SQL->get());
            if (is_null($invitation_ID)) {
                // Invitation code doesn't exist in DB or it is expired
                param_error($invitation_name, T_('Invitation code is incorrect!'));
                return 'input';
            } else {
                // Invitation code is correct, Display it as info field on the registration form
                return 'info';
            }
        }
    }
    if (empty($invitation) && $Settings->get('newusers_canregister') == 'invite') {
        // Users can register only with invitation code
        if ($Settings->get('registration_is_public')) {
            // Display registration form even when invitation code is empty but setting "Registration links" is enabled
            // The invitation field should be visible for this case
            return 'input';
        } else {
            // Don't display a registration form
            return 'deny';
        }
    }
    if ($Settings->get('newusers_canregister') == 'invite') {
        // Always display the invitation field when users can register ONLY with invitation code
        return 'input';
    } else {
        // Don't display a field for invitation code, when this setting == 'yes'(Users can register themselves freely)
        return '';
    }
}
Example #21
0
        $CommentList->load_from_Request();
        /**
         * Mass delete comments
         */
        param('mass_type', 'string', '');
        if ($action == 'mass_delete' && !empty($mass_type)) {
            // Check that this action request is not a CSRF hacked request:
            $Session->assert_received_crumb('comment');
            // Init the comment list query, but don't execute it
            $CommentList->query_init();
            // Set sql query to get deletable comment ids
            $deletable_comments_query = 'SELECT DISTINCT ' . $CommentList->Cache->dbIDname . ' ' . $CommentList->CommentQuery->get_from() . $CommentList->CommentQuery->get_where();
            // Set an action param to display a correct template
            $process_action = $action;
            unset($_POST['actionArray']);
            set_param('action', 'list');
            // Try to obtain some serious time to do some serious processing (15 minutes)
            set_max_execution_time(10000);
        }
        break;
    default:
        debug_die('unhandled action 2');
}
/*
 * Page navigation:
 */
$AdminUI->set_path('collections', 'comments');
if ($tab3 == 'fullview') {
    // Load jquery UI to animate background color on change comment status and to transfer a comment to recycle bin
    require_js('#jqueryUI#');
}
Example #22
0
        // will have exited
    }
    $Messages->add('You are not allowed to view Messages!');
    header_redirect($Blog->gen_blogurl(), 302);
    // will have exited
}
if (!$current_User->check_perm('perm_messaging', 'reply')) {
    // Redirect to the blog url for users without messaging permission
    $Messages->add('You are not allowed to view Messages!');
    header_redirect($Blog->gen_blogurl(), 302);
    // will have exited
}
$action = param('action', 'string', 'view');
if ($action == 'new' && check_create_thread_limit(true)) {
    // don't allow to create new thread, because the new thread limit was already reached
    set_param('action', 'view');
}
// var bgxy_expand is used by toggle_filter_area() and toggle_clickopen()
// var htsrv_url is used for AJAX callbacks
add_js_headline("// Paths used by JS functions:\r\n\t\tvar bgxy_expand = '" . get_icon('expand', 'xy') . "';\r\n\t\tvar bgxy_collapse = '" . get_icon('collapse', 'xy') . "';");
// Require results.css to display thread query results in a table
require_css('results.css');
// Results/tables styles
// Load classes
load_class('messaging/model/_thread.class.php', 'Thread');
load_class('messaging/model/_message.class.php', 'Message');
// Get action parameter from request:
$action = param_action('view');
switch ($action) {
    case 'new':
        // Check permission:
Example #23
0
 function SetParam()
 {
     set_param('akts_nr', $this->MyPOST['akts_nr_head']);
     set_param('pircejs', $this->MyPOST['pircejs_head']);
     set_param('pardevejs', $this->MyPOST['pardevejs_head']);
     set_param('pieg_lig_num', $this->MyPOST['pieg_lig_num']);
     set_param('datums', $this->MyPOST['datums_head']);
     set_param('iecirknis', $this->MyPOST['iecirknis_head']);
     set_param('pavadzime_head', $this->MyPOST['pavadzime_head']);
     set_param('auto', $this->MyPOST['auto_head']);
     set_param('soferis', $this->MyPOST['soferis_head']);
     set_param('vieta', $this->MyPOST['vieta_head']);
     set_param('piezimes', $this->MyPOST['piezimes_head']);
     set_param('atbildigais', $this->MyPOST['atbildigais_head']);
     set_param('custom11', $this->MyPOST['custom11_head']);
     set_param('custom12', $this->MyPOST['custom12_head']);
     set_param('sortiments', $this->MyPOST['sortiments_head']);
     set_param('standarts', $this->MyPOST['standarts_head']);
     set_param('metode', $this->MyPOST['metode_head']);
     set_param('raukums', $this->MyPOST['raukums_head']);
     set_param('merinstruments', $this->MyPOST['merinstruments_head']);
     set_param('terminsh', $this->MyPOST['terminsh_head']);
 }
Example #24
0
            $Messages->add($msg, 'success');
            $action = 'list';
        } else {
            // not confirmed, Check for restrictions:
            // Get the page number we come from:
            $previous_page = param('results_' . $GenericElementCache->dbprefix . 'page', 'integer', 1, true);
            if (!$edited_GenericElement->check_delete(sprintf(T_('Cannot delete element &laquo;%s&raquo;'), $edited_GenericElement->dget('name')))) {
                // There are restrictions:
                $action = 'edit';
            }
        }
        break;
    case 'sort_by_order':
        // The list is sorted by the order column now.
        $Results->order = '--A';
        set_param('results_' . $GenericElementCache->dbprefix . 'order', '--A');
        $action = 'list';
        break;
}
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
$AdminUI->disp_html_head();
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
$AdminUI->disp_body_top();
/**
 * Display payload:
 */
switch ($action) {
    case 'nil':
        // Do nothing
        break;
    case 'new':
 function init_param($para_types, $var, $type = '', $default = NO_DEFAULT_PARAM, $must_exist = false, $set_global = true, $global_override = true)
 {
     if (!is_array($para_types)) {
         if ($para_types) {
             $para_tmp = $para_types;
             $para_types = array();
             $para_types[] = $para_tmp;
         } else {
             $para_types = array('POST', 'GET');
         }
     }
     $para_found = false;
     foreach ($para_types as $para_type) {
         switch (strtoupper($para_type)) {
             case 'POST':
                 if (isset($_POST[$var])) {
                     $para_value = remove_magic_quotes($_POST[$var]);
                     $para_found = true;
                 }
                 break;
             case 'GET':
                 if (isset($_GET[$var])) {
                     $para_value = remove_magic_quotes($_GET[$var]);
                     $para_found = true;
                 }
                 break;
             case 'COOKIE':
                 if (isset($_COOKIE[$var])) {
                     $para_value = remove_magic_quotes($_COOKIE[$var]);
                     $para_found = true;
                 }
                 break;
             case 'SESSION':
                 if (isset($_SESSION[$var])) {
                     $para_value = $_SESSION[$var];
                     $para_found = true;
                 }
                 break;
             default:
         }
         if ($para_found) {
             break;
         }
     }
     if ($must_exist && !$para_found) {
         redirect_header("", 5, "Required parameter isn't set. [" . $var . "]");
     }
     if (!$para_found) {
         if ($default !== NO_DEFAULT_PARAM) {
             $para_value = $default;
         } elseif ($type == 'string-yn') {
             $para_value = 'N';
         } elseif ($type == 'check-01') {
             $para_value = '0';
         }
     }
     if (isset($para_value)) {
         if (!empty($type)) {
             // Force the type
             switch ($type) {
                 case 'html':
                     // do nothing
                     break;
                 case 'clean-html':
                     $para_value = trim(clean_html($para_value));
                     break;
                 case 'string':
                     $para_value = trim(strip_tags($para_value));
                     break;
                 case 'string-yn':
                     $para_value = $para_value == 'Y' ? 'Y' : 'N';
                     break;
                 case 'check-01':
                     $para_value = $para_value == '1' ? '1' : '0';
                     break;
                 case 'array-int':
                     settype($para_value, 'array');
                     array_walk($para_value, '_array_int_callback');
                     break;
                 default:
                     settype($para_value, $type);
             }
         }
         set_param($var, $para_value);
     }
     if ($set_global) {
         if ($global_override || empty($GLOBALS[$var])) {
             if (!empty($GLOBALS[$var])) {
                 unset($GLOBALS[$var]);
             }
             if (!empty($para_value)) {
                 $GLOBALS[$var] = $para_value;
             }
         }
     }
     if (!empty($para_value)) {
         return $para_value;
     } else {
         return false;
     }
 }
 /**
  * Get a param from Request and save it to UserSettings, or default to previously saved user setting.
  *
  * If the user setting was not set before (and there's no default given that gets returned), $default gets used.
  *
  * @todo Move this to _abstractsettings.class.php - the other Settings object can also make use of it!
  *
  * @param string Request param name
  * @param string User setting name. Make sure this is unique!
  * @param string Force value type to one of:
  * - integer
  * - float
  * - string (strips (HTML-)Tags, trims whitespace)
  * - array
  * - object
  * - null
  * - html (does nothing)
  * - '' (does nothing)
  * - '/^...$/' check regexp pattern match (string)
  * - boolean (will force type to boolean, but you can't use 'true' as a default since it has special meaning. There is no real reason to pass booleans on a URL though. Passing 0 and 1 as integers seems to be best practice).
  * Value type will be forced only if resulting value (probably from default then) is !== NULL
  * @param mixed Default value or TRUE if user input required
  * @param boolean Do we need to memorize this to regenerate the URL for this page?
  * @param boolean Override if variable already set
  * @return NULL|mixed NULL, if neither a param was given nor {@link $UserSettings} knows about it.
  */
 function param_Request($param_name, $uset_name, $type = '', $default = '', $memorize = false, $override = false)
 {
     $value = param($param_name, $type, NULL, $memorize, $override, false);
     // we pass NULL here, to see if it got set at all
     if ($value !== false) {
         // we got a value
         $this->set($uset_name, $value);
         $this->dbupdate();
     } else {
         // get the value from user settings
         $value = $this->get($uset_name);
         if (is_null($value)) {
             // it's not saved yet and there's not default defined ($_defaults)
             $value = $default;
         }
         if ($memorize) {
             // Memorize param
             memorize_param($param_name, $type, $default, $value);
         }
     }
     set_param($param_name, $value);
     return get_param($param_name);
 }
Example #27
0
     set_param('keywords', $user_search);
     set_param('filter', 'new');
     load_class('users/model/_userlist.class.php', 'UserList');
     $UserList = new UserList('admin', $UserSettings->get('results_per_page'), 'users_', array('join_city' => false));
     $UserList->load_from_Request();
     // Make query to get a count of users
     $UserList->query();
     if ($UserList->get_total_rows() == 1) {
         // If we find only one user by quick search we do a redirect to user's edit page
         $User = $UserList->rows[0];
         if (!empty($User)) {
             header_redirect('?ctrl=user&user_tab=profile&user_ID=' . $User->user_ID);
         }
     }
     // Unset the filter to avoid the step 1 in the function $UserList->query() on the users list
     set_param('filter', '');
     break;
 case 'remove_sender_customization':
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('users');
     // Check required permission
     $current_User->check_perm('users', 'edit', true);
     // get the type of the removable sender customization
     $type = param('type', 'string', true);
     // Set remove custom settings query
     $remove_query = 'DELETE FROM T_users__usersettings WHERE uset_name = "%s" AND uset_value != %s';
     if ($type == 'sender_email') {
         // Remove custom sender emails
         $DB->query(sprintf($remove_query, 'notification_sender_email', $DB->quote($Settings->get('notification_sender_email'))));
     } elseif ($type == 'sender_name') {
         // Remove custom sender names
Example #28
0
function print_report($grup)
{
    $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
    $C_REP = new C_REPORT($_POST, $DB_CON, true, $grup);
    global $arrsum;
    //echo '$grup = ' . $grup;
    //print_r ($C_REP->arr);
    if ($grup == 1) {
        $arrsum = $C_REP->arr[count($C_REP->arr) - 1];
    } else {
        $arrsum[summa]->skaits = $arrsum[summa]->skaits + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits;
    }
    if ($grup == $_POST['grup']) {
        if ($arrsum[summa]->skaits != $arrsum[correct_count]) {
            $C_REP->ERRORS .= "Kļūda grupēšanā! Sagrupēti " . (int) $arrsum[summa]->skaits . " baļķi no " . $arrsum[correct_count] . ".<br><br>";
        }
    }
    /////////////////////////////////////////////////////////////////////////
    $_POST['pavadzime_head'] = $_POST['pavadzime'];
    set_param('akts_nr', $_POST['akts_nr_head']);
    set_param('pircejs_head', $_POST['pircejs_head']);
    set_param('pircejs_regnum', $_POST['pircejs_regnum']);
    set_param('pardevejs_head', $_POST['pardevejs_head']);
    set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
    set_param('pieg_lig_num', $_POST['pieg_lig_num']);
    set_param('datums', $_POST['datums_head']);
    set_param('iecirknis', $_POST['iecirknis_head']);
    set_param('pavadzime_head', $_POST['pavadzime_head']);
    set_param('transport_firm', $_POST['transport_firm']);
    set_param('auto', $_POST['auto_head']);
    set_param('soferis', $_POST['soferis_head']);
    set_param('vieta', $_POST['vieta_head']);
    set_param('piezimes', $_POST['piezimes_head']);
    set_param('atbildigais', $_POST['atbildigais_head']);
    set_param('custom11', $_POST['custom11_head']);
    set_param('custom12', $_POST['custom12_head']);
    $xml_vars['gvalues' . $grup . '1'] = $_POST['gvalues' . $grup . '1'];
    $xml_vars['gvalues' . $grup . '1_1'] = $_POST['gvalues' . $grup . '1_1'];
    $xml_vars['gvalues' . $grup . '1_2'] = $_POST['gvalues' . $grup . '1_2'];
    $xml_vars['gvalues' . $grup . '2'] = $_POST['gvalues' . $grup . '2'];
    $xml_vars['gvalues' . $grup . '2_1'] = $_POST['gvalues' . $grup . '2_1'];
    $xml_vars['gvalues' . $grup . '2_2'] = $_POST['gvalues' . $grup . '2_2'];
    $xml_vars['gvalues' . $grup . '3'] = $_POST['gvalues' . $grup . '3'];
    $xml_vars['gvalues' . $grup . '3_1'] = $_POST['gvalues' . $grup . '3_1'];
    $xml_vars['gvalues' . $grup . '3_2'] = $_POST['gvalues' . $grup . '3_2'];
    $xml_vars['gvalues' . $grup . '4'] = $_POST['gvalues' . $grup . '4'];
    $xml_vars['gvalues' . $grup . '4_1'] = $_POST['gvalues' . $grup . '4_1'];
    $xml_vars['gvalues' . $grup . '4_2'] = $_POST['gvalues' . $grup . '4_2'];
    $xml_vars['virsmeri' . $grup] = $_POST['virsmeri' . $grup];
    $xml_vars['virsmeri' . $grup . '_1'] = $_POST['virsmeri' . $grup . '_1'];
    $xml_vars['virsmeri' . $grup . '_2'] = $_POST['virsmeri' . $grup . '_2'];
    $xml_vars['koeficients' . $grup] = $_POST['koeficients' . $grup];
    $xml_vars['koeficients' . $grup . '_1'] = $_POST['koeficients' . $grup . '_1'];
    $xml_vars['koeficients' . $grup . '_2'] = $_POST['koeficients' . $grup . '_2'];
    $xml_vars['raukums' . $grup] = $_POST['raukums' . $grup];
    $xml_vars['raukums' . $grup . '_1'] = $_POST['raukums' . $grup . '_1'];
    $xml_vars['raukums' . $grup . '_2'] = $_POST['raukums' . $grup . '_2'];
    $xml_vars['pavadzime'] = $_POST['pavadzime'];
    /////////////////////////////////////////////////////////////////////////
    if ($C_REP->ERRORS) {
        ?>
<head>
					 <title>Kļūda!</title>
					 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
					</head>
					
					<center>
					<STYLE TYPE="text/css">
					  TD { font-size: 12px; }
					</STYLE>
					</style>
					<body>
						<center><br><br>
						<b><font color=red>Kļūda!</font></b>
						<br><br>
						<?php 
        echo $C_REP->ERRORS;
        ?>
						</center>
						<br><br>
						<input type=button value="Atkārtot" onclick="history.back(-1)">
					</body>
					</html>
			<?php 
        exit;
    }
    //echo $C_REP->GetHTML();
    //exit();
    //create header///
    //header ("Content-type: text/xml");
    //header ("Content-type: file");
    //header ("Content-Disposition: attachment; filename=".$_POST['pavadzime'].".xml");
    if (!$_POST['pavadzime_id']) {
        $_POST['pavadzime_id'] = GetFromPavadzime($_POST['pavadzime'], 'id');
    }
    $pavadz_datums = GetFromPavadzimeID($_POST['pavadzime_id'], 'kad_piegad', 'vikawood_pavadzime');
    if ($pavadz_datums == '0000-00-00') {
        $pavadz_datums = false;
    }
    if (!$pavadz_datums) {
        $pavadz_datums = GetPavadzimeDatumsID($_POST['pavadzime_id']);
        if ($pavadz_datums == '0000-00-00') {
            $pavadz_datums = '';
        }
        $pavadz_datums = str_replace('.', '-', $pavadz_datums);
    }
    if ($pavadz_datums) {
        $pavadz_datums = substr($pavadz_datums, 0, 10);
    }
    if (!$uzmerisanas_datums) {
        $uzmerisanas_datums = GetUzmerisanasDatumsID($_POST['pavadzime_id']);
        if ($uzmerisanas_datums == '0000-00-00') {
            $uzmerisanas_datums = '';
        }
        $uzmerisanas_datums = str_replace('.', '-', $uzmerisanas_datums);
    }
    if ($uzmerisanas_datums) {
        $uzmerisanas_datums = substr($uzmerisanas_datums, 0, 10);
    }
    $arr = $C_REP->GetDataArray();
    $lsk = 5;
    $output = "";
    if ($_POST['grup'] == 1) {
        $output = $output . '<?xml version="1.0" encoding="UTF-8"?>';
        $output = $output . "<Invoice>";
        $output = $output . "\t<EntryDate>" . trim($_POST['datums_head']) . "</EntryDate>";
        $output = $output . "\t<InvoiceNumber>" . $_POST['pavadzime_head'] . "</InvoiceNumber>";
        $output = $output . "\t<InvoiceDate>" . $pavadz_datums . "</InvoiceDate>";
        $output = $output . "\t<ContractNumber>" . $_POST['pieg_lig_num'] . "</ContractNumber>";
        $output = $output . "\t<MeasurerDocNr>" . $_POST['akts_nr_head'] . "</MeasurerDocNr>";
        $output = $output . "\t<Supplier>";
        $output = $output . "\t\t<Name>" . $_POST['pardevejs_head'] . "</Name>";
        $output = $output . "\t\t<RegNr>" . $_POST['pardevejs_regnum'] . "</RegNr>";
        $output = $output . "\t</Supplier>";
        $output = $output . "\t<Reciever>";
        $output = $output . "\t\t<Name>" . $_POST['pircejs_head'] . "</Name>";
        $output = $output . "\t\t<RegNr>" . $_POST['pircejs_regnum'] . "</RegNr>";
        $output = $output . "\t</Reciever>";
        $output = $output . "\t<Carrier>";
        if ($_POST['transport_firm']) {
            $output = $output . "<FirmName>" . $_POST['transport_firm'] . "</FirmName>";
        } else {
            $rAuto = mysql_query("select * from auto where numurs = '" . GetFromPavadzimeID($_POST['pavadzime_id'], 'auto', 'vikawood_pavadzime') . "'");
            if (mysql_num_rows($rAuto) > 0) {
                $mAuto = mysql_fetch_array($rAuto);
                $parvadatajs_id = $mAuto['parvadatajs'];
                $rParvadatajs = mysql_query("select * from parvadatajs where id = {$parvadatajs_id}");
                $mParvadatajs = mysql_fetch_array($rParvadatajs);
                $output = $output . "<FirmName>" . $mParvadatajs['nosaukums'] . "</FirmName>";
            }
        }
        $output = $output . "<TruckNumber>" . trim(GetFromPavadzimeID($_POST['pavadzime_id'], 'auto', 'vikawood_pavadzime')) . "</TruckNumber> ";
        $output = $output . "<Driver>" . GetFromPavadzimeID($_POST['pavadzime_id'], 'soferis', 'vikawood_pavadzime') . "</Driver>";
        $output = $output . "</Carrier>";
        $output = $output . "<Measuring>";
        $output = $output . "\t<MeasuringDate>" . $uzmerisanas_datums . "</MeasuringDate>";
        $output = $output . "\t<OperatorName>VMF Latvia</OperatorName>";
        $output = $output . "\t<MeasureMethod>I</MeasureMethod>";
        $output = $output . "</Measuring>";
        $output = $output . "<AssortmOrigin> ";
        $output = $output . "\t<FSCNumber>" . GetFromPavadzimeID($_POST['pavadzime_id'], 'fsc', 'vikawood_pavadzime') . "</FSCNumber>";
        $output = $output . "\t<SlashCode>" . GetFromPavadzimeID($_POST['pavadzime_id'], 'cirsmas_kods', 'vikawood_pavadzime') . "</SlashCode>";
        $output = $output . "</AssortmOrigin >";
    }
    if ($lsk > 1) {
        for ($j = $lsk - 2; $j >= 0; $j--) {
            $v = $arr[0][$j];
            for ($i = 0; $i < count($arr); $i++) {
                // iekopējam ja tukšs
                if ($arr[$i][$j] == "" && $arr[$i][$j + 1] != "") {
                    $arr[$i][$j] = $v;
                }
                // ja nav tukšs paņem vērtību
                if ($arr[$i][$j] != "") {
                    $v = $arr[$i][$j];
                }
            }
        }
    }
    /// drukājam tabulu
    for ($i = 0; $i < count($arr); $i++) {
        if ($arr[$i][summa]->skaits != 0 && !$arr[$i][-1]) {
            $output = $output . "\n\n<DataRow>\n";
            $output = $output . "<AssortmentGroup>ZB</AssortmentGroup>\n";
            $refused = false;
            $caurm_kods = '';
            for ($j = 0; $j < $lsk; $j++) {
                switch ($arr[-1][$j]) {
                    case 'suga':
                        //$arr[$i][$j]=$LVM_sugas[$arr[$i][$j]]; // pārveidojam uz LVM sugām P:E
                        $output = $output . "<Specie>" . $arr[$i][$j] . "</Specie>\n";
                        break;
                    case 'brakis':
                        if (round($arr[$i][summa]->brakis, 3) > 0 && trim($arr[$i][$j]) == "") {
                            $arr[$i][$j] = "D";
                        }
                        if ($arr[$i][$j] != '') {
                            $refused = true;
                            $output = $output . "<RejectReason>" . $arr[$i][$j] . "</RejectReason>\n";
                        }
                        break;
                    case 'mind_pirms_red':
                        $SG = trim($arr[$i][$j]);
                        if ($SG == '0-79') {
                            $SG = "M";
                        }
                        //echo $SG . '<br />';
                        if ($SG == '120-129' || $SG == '130-139') {
                            $SG = '120-139';
                        }
                        $output = $output . "<SizeGroup>" . $SG . "</SizeGroup>\n";
                        $caurm_kods = trim($arr[$i][$j]);
                        if ($caurm_kods == '120-129' || $caurm_kods == '130-139') {
                            $caurm_kods = '120-139';
                        }
                        break;
                    case 'garums':
                        $a = explode('-', $arr[$i][$j]);
                        $output = $output . "<Length>\n<LowerLimit>{$a['0']}</LowerLimit>\n<UpperLimit>{$a['1']}</UpperLimit>\n</Length>\n";
                        break;
                    case 'cenu_matrica':
                        $output = $output . "<Price>" . $arr[$i][$j] . "</Price>\n";
                    default:
                        //echo "<kaut_kas>".$arr[$i][$j]."</kaut_kas>\n";
                }
            }
            //echo "<td align=right>".round($arr[$i][summa]->bruto,3)."</td><td width=5>";
            $output = $output . "<Assortment>" . get_LVM_asort_kods_no_caurm_kods($caurm_kods) . "</Assortment>";
            $output = $output . "<Overlength>" . round($arr[$i][summa]->virsmers, 3) . "</Overlength>\n";
            $output = $output . "<LengthReduction>" . round($arr[$i][summa]->redukcija_d + $arr[$i][summa]->redukcija_l, 3) . "</LengthReduction>\n";
            if ($refused) {
                $volume = round($arr[$i][summa]->brakis, 3);
            } else {
                $volume = round($arr[$i][summa]->neto, 3);
            }
            $output = $output . "<NetVolume>" . $volume . "</NetVolume>\n";
            $output = $output . "<Count>" . round($arr[$i][summa]->skaits, 3) . "</Count>\n";
            $output = $output . "<NotAgreed>0</NotAgreed>\n";
            $output = $output . "</DataRow>";
        }
    }
    if ($grup == $_POST['grup']) {
        $output = $output . "</Invoice>";
    }
    return $output;
}