Exemple #1
0
function Logger($text, $level)
{
    $gLogError = 1;
    $gLogErrorFile = "./log.txt";
    if ($gLogError) {
        $text = date('D M j G:i:s T Y') . "     {$text}" . "\n";
        $file = $gLogErrorFile;
        ErrorLog($text, $file);
    }
}
function DoEmail()
{
    global $config, $dump, $databases, $email, $lang, $out, $REMOTE_ADDR;
    $header = "";
    if ($config['cron_use_sendmail'] == 1) {
        //sendmail
        if (ini_get("sendmail_path") != $config['cron_sendmail']) {
            @ini_set("SMTP", $config['cron_sendmail']);
        }
        if (ini_get("sendmail_from") != $config['email_sender']) {
            @ini_set("SMTP", $config['email_sender']);
        }
    } else {
        //SMTP
    }
    if (ini_get("SMTP") != $config['cron_smtp']) {
        @ini_set("SMTP", $config['cron_smtp']);
    }
    if (ini_get("smtp_port") != 25) {
        @ini_set("smtp_port", 25);
    }
    if ($config['multi_part'] == 0) {
        $file = $dump['backupdatei'];
        $file_name = strpos("/", $file) ? substr($file, strrpos("/", $file)) : $file;
        $file_type = filetype($config['paths']['backup'] . $file);
        $file_size = filesize($config['paths']['backup'] . $file);
        if ($config['email_maxsize'] > 0 && $file_size > $config['email_maxsize'] || $config['send_mail_dump'] == 0) {
            //anhang zu gross
            $subject = "Backup '" . $databases['Name'][$dump['dbindex']] . "' - " . date("d\\.m\\.Y H:i", time());
            $header .= "FROM:" . $config['email_sender'] . "\n";
            if (isset($config['email_recipient_cc']) && trim($config['email_recipient_cc']) > '') {
                $header .= "Cc:     " . $config['email_recipient_cc'] . "\r\n";
            }
            $header .= "MIME-version: 1.0\n";
            $header .= "X-Mailer: PHP/" . phpversion() . "\n";
            $header .= "X-Sender-IP: {$REMOTE_ADDR}\n";
            $header .= "Content-Type: text/html; charset=utf-8\n";
            if ($config['send_mail_dump'] != 0) {
                $msg_body = sprintf(addslashes($lang['L_EMAILBODY_TOOBIG']), byte_output($config['email_maxsize']), $databases['Name'][$dump['dbindex']], "{$file} (" . byte_output(filesize($config['paths']['backup'] . $file)) . ")<br>");
            } else {
                $msg_body = sprintf(addslashes($lang['L_EMAILBODY_NOATTACH']), $databases['Name'][$dump['dbindex']], "{$file} (" . byte_output(filesize($config['paths']['backup'] . $file)) . ")");
            }
            include_once './inc/functions.php';
            $msg_body .= '<a href="' . getServerProtocol() . $_SERVER['HTTP_HOST'] . substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/")) . '/' . $config['paths']['backup'] . $file . '">' . $file . '</a>';
            $email_log = "Email sent to '" . $config['email_recipient'] . "'";
            $email_out = $lang['L_EMAIL_WAS_SEND'] . "`" . $config['email_recipient'] . "`<br>";
        } else {
            //alles ok, anhang generieren
            $msg_body = sprintf(addslashes($lang['L_EMAILBODY_ATTACH']), $databases['Name'][$dump['dbindex']], "{$file} (" . byte_output(filesize($config['paths']['backup'] . $file)) . ")");
            $subject = "Backup '" . $databases['Name'][$dump['dbindex']] . "' - " . date("d\\.m\\.Y", time());
            $fp = fopen($config['paths']['backup'] . $file, "r");
            $contents = fread($fp, $file_size);
            $encoded_file = chunk_split(base64_encode($contents));
            fclose($fp);
            $header .= "FROM:" . $config['email_sender'] . "\n";
            if (isset($config['email_recipient_cc']) && trim($config['email_recipient_cc']) > '') {
                $header .= "Cc:     " . $config['email_recipient_cc'] . "\r\n";
            }
            $header .= "MIME-version: 1.0\n";
            $header .= "Content-type: multipart/mixed; ";
            $header .= "boundary=\"Message-Boundary\"\n";
            $header .= "Content-transfer-encoding: 7BIT\n";
            $header .= "X-attachments: {$file_name}";
            $body_top = "--Message-Boundary\n";
            $body_top .= "Content-type: text/html; charset=utf-8\n";
            $body_top .= "Content-transfer-encoding: 7BIT\n";
            $body_top .= "Content-description: Mail message body\n\n";
            $msg_body = $body_top . $msg_body;
            $msg_body .= "\n\n--Message-Boundary\n";
            $msg_body .= "Content-type: {$file_type}; name=\"{$file}\"\n";
            $msg_body .= "Content-Transfer-Encoding: BASE64\n";
            $msg_body .= "Content-disposition: attachment; filename=\"{$file}\"\n\n";
            $msg_body .= "{$encoded_file}\n";
            $msg_body .= "--Message-Boundary--\n";
            $email_log = "Email was sent to '" . $config['email_recipient'] . "' with '" . $dump['backupdatei'] . "'.";
            $email_out = $lang['L_EMAIL_WAS_SEND'] . "`" . $config['email_recipient'] . "`" . $lang['L_WITH'] . "`" . $dump['backupdatei'] . "`.<br>";
        }
    } else {
        //Multipart
        $mp_sub = "Backup '" . $databases['Name'][$dump['dbindex']] . "' - " . date("d\\.m\\.Y", time());
        $subject = $mp_sub;
        $header .= "FROM:" . $config['email_sender'] . "\n";
        if (isset($config['email_recipient_cc']) && trim($config['email_recipient_cc']) > '') {
            $header .= "Cc:     " . $config['email_recipient_cc'] . "\r\n";
        }
        $header .= "MIME-version: 1.0\n";
        $header .= "X-Mailer: PHP/" . phpversion() . "\n";
        $header .= "X-Sender-IP: {$REMOTE_ADDR}\n";
        $header .= "Content-Type: text/html; charset=utf-8";
        $dateistamm = substr($dump['backupdatei'], 0, strrpos($dump['backupdatei'], "part_")) . "part_";
        $dateiendung = $config['compression'] == 1 ? ".sql.gz" : ".sql";
        $mpdatei = array();
        $mpfiles = "";
        for ($i = 1; $i < $dump['part'] - $dump['part_offset']; $i++) {
            $mpdatei[$i - 1] = $dateistamm . $i . $dateiendung;
            $sz = byte_output(@filesize($config['paths']['backup'] . $mpdatei[$i - 1]));
            $mpfiles .= $mpdatei[$i - 1] . " (" . $sz . ")<br>";
        }
        $msg_body = $config['send_mail_dump'] == 1 ? sprintf(addslashes($lang['L_EMAILBODY_MP_ATTACH']), $databases['Name'][$dump['dbindex']], $mpfiles) : sprintf(addslashes($lang['L_EMAILBODY_MP_NOATTACH']), $databases['Name'][$dump['dbindex']], $mpfiles);
        $email_log = "Email was sent to '" . $config['email_recipient'] . "'";
        $email_out = $lang['L_EMAIL_WAS_SEND'] . "`" . $config['email_recipient'] . "`<br>";
    }
    if (@mail($config['email_recipient'], stripslashes($subject), $msg_body, $header)) {
        $out .= '<span class="success">' . $email_out . '</span>';
        WriteLog("{$email_log}");
    } else {
        $out .= '<span class="error">' . $lang['L_MAILERROR'] . '</span><br>';
        WriteLog("Email to '" . $config['email_recipient'] . "' failed !");
        ErrorLog("Email ", $databases['Name'][$dump['dbindex']], 'Subject: ' . stripslashes($subject), $lang['L_MAILERROR']);
        $dump['errors']++;
    }
    if (isset($mpdatei) && $config['send_mail_dump'] == 1) {
        // && ($config['email_maxsize']==0 || ($config['email_maxsize']>0 && $config['multipartgroesse2']<=$config['email_maxsize']))) {
        for ($i = 0; $i < count($mpdatei); $i++) {
            $file_name = $mpdatei[$i];
            $file_type = filetype($config['paths']['backup'] . $mpdatei[$i]);
            $file_size = filesize($config['paths']['backup'] . $mpdatei[$i]);
            $fp = fopen($config['paths']['backup'] . $mpdatei[$i], "r");
            $contents = fread($fp, $file_size);
            $encoded_file = chunk_split(base64_encode($contents));
            fclose($fp);
            $subject = $mp_sub . "  [Part " . ($i + 1) . " / " . count($mpdatei) . "]";
            $header = "FROM:" . $config['email_sender'] . "\n";
            if (isset($config['email_recipient_cc']) && trim($config['email_recipient_cc']) > '') {
                $header .= "Cc:     " . $config['email_recipient_cc'] . "\r\n";
            }
            $header .= "MIME-version: 1.0\n";
            $header .= "Content-type: multipart/mixed; ";
            $header .= "boundary=\"Message-Boundary\"\n";
            $header .= "Content-transfer-encoding: 7BIT\n";
            $header .= "X-attachments: {$file_name}";
            $body_top = "--Message-Boundary\n";
            $body_top .= "Content-type: text/html; charset=utf-8\n";
            $body_top .= "Content-transfer-encoding: 7BIT\n";
            $body_top .= "Content-description: Mail message body\n\n";
            $msg_body = $body_top . addslashes($lang['L_EMAIL_ONLY_ATTACHMENT'] . $lang['L_EMAILBODY_FOOTER']);
            $msg_body .= "\n\n--Message-Boundary\n";
            $msg_body .= "Content-type: {$file_type}; name=\"" . $mpdatei[$i] . "\"\n";
            $msg_body .= "Content-Transfer-Encoding: BASE64\n";
            $msg_body .= "Content-disposition: attachment; filename=\"" . $mpdatei[$i] . "\"\n\n";
            $msg_body .= "{$encoded_file}\n";
            $msg_body .= "--Message-Boundary--\n";
            $email_log = "Email with {$mpdatei[$i]} was sent to '" . $config['email_recipient'] . "'";
            $email_out = $lang['L_EMAIL_WAS_SEND'] . "`" . $config['email_recipient'] . "`" . $lang['L_WITH'] . "`" . $mpdatei[$i] . "`.<br>";
            if (@mail($config['email_recipient'], stripslashes($subject), $msg_body, $header)) {
                $out .= '<span class="success">' . $email_out . '</span>';
                WriteLog("{$email_log}");
            } else {
                $out .= '<span class="error">' . $lang['L_MAILERROR'] . '</span><br>';
                WriteLog("Email to '" . $config['email_recipient'] . "' failed !");
                ErrorLog("Email ", $databases['Name'][$dump['dbindex']], 'Subject: ' . stripslashes($subject), $lang['L_MAILERROR']);
                $dump['errors']++;
            }
        }
    }
}
 public function ShowData()
 {
     //check pk and ptable are set up
     if (is_empty($this->GetTabledef())) {
         ErrorLog('Primary table not set up for ' . get_class($this));
         return;
     }
     echo '<h1>' . $this->GetTitle() . '</h1>';
     echo '{list.' . get_class($this) . '}';
     $row = null;
     $num_rows = 0;
     if (!isset($_GET['_n_' . $this->GetModuleId()])) {
         $this->GetLimit($limit, $page);
         $dataset = $this->GetDataset();
         $num_rows = $dataset->CountRecords();
         $row = $dataset->GetPage($page, $limit)->fetch();
     }
     $pagination = '';
     $this->GetLimit($limit);
     if ($limit) {
         $pages = max(ceil($num_rows / $limit), 1);
         ob_start();
         utopia::OutputPagination($pages, '_p_' . $this->GetModuleId());
         $pagination = ob_get_clean();
     }
     $records = $num_rows == 0 ? "There are no records to display." : 'Total Rows: ' . $num_rows;
     $pager = '<div class="right">' . $pagination . '</div>';
     uEvents::TriggerEvent('OnShowDataDetail', $this);
     if ($this->flag_is_set(ALLOW_DELETE) && $row) {
         $fltr =& $this->FindFilter($this->GetPrimaryKey(), ctEQ, itNONE);
         $delbtn = $this->GetDeleteButton($this->GetFilterValue($fltr['uid']), 'Delete Record');
         utopia::AppendVar('footer_left', $delbtn);
     }
     //		if (!$this->IsNewRecord()) { // records exist, lets get the first.
     // pagination?
     //			if (mysql_num_rows($result) > 1) {
     // multiple records exist in this set, sort out pagination
     //			}
     //		}
     $order = $this->GetSortOrder();
     $extraCount = 1;
     $secCount = count($this->layoutSections);
     foreach ($this->layoutSections as $sectionID => $sectionInfo) {
         $out = '';
         if ($secCount > 1) {
             $sectionName = $sectionInfo['title'];
             if ($sectionName === '') {
                 if ($sectionID === 0) {
                     $SN = 'General';
                 } else {
                     $SN = "Extra ({$extraCount})";
                     $extraCount++;
                 }
             } else {
                 $SN = ucwords($sectionName);
             }
             $out .= '<h2>' . $SN . '</h2>';
         }
         if (!$this->isAjax) {
             $out .= '<form class="uf" action="" onsubmit="this.action = window.location" method="post">';
         }
         $out .= "<div class=\"table-wrapper\"><table class=\"module-content layoutDetailSection\">";
         $fields = $this->GetFields(true, $sectionID);
         $hasFieldHeaders = false;
         foreach ($fields as $fieldName => $fieldData) {
             $hasFieldHeaders = $hasFieldHeaders || !empty($fieldData['visiblename']);
         }
         $fieldCount = count($fields);
         foreach ($fields as $fieldName => $fieldData) {
             $targetUrl = $this->GetTargetUrl($fieldName, $row);
             $out .= "<tr>";
             if ($hasFieldHeaders) {
                 $out .= "<td class=\"fld\">" . $fieldData['visiblename'] . "</td>";
             }
             $out .= '<td>' . $this->GetCell($fieldName, $row, $targetUrl) . '</td>';
             $out .= "</tr>";
         }
         $out .= "</table></div>";
         if (!$this->isAjax) {
             $out .= '</form>';
         }
         echo $out;
     }
     if ($num_rows > 1) {
         echo '<div class="oh"><b>' . $records . '</b>' . $pager . '</div>';
     }
 }
Exemple #4
0
function Logger_Array($pointer, $arr1, $arr2 = -5, $arr3 = -5, $arr4 = -5, $arr5 = -5, $arr6 = -5, $arr7 = -5, $arr8 = -5, $arr9 = -5, $arr10 = -5, $arr11 = -5, $arr12 = -5)
{
    $arr[0] = $arr1;
    $k = 1;
    if ($arr2 != -5) {
        $arr[1] = $arr2;
        $k++;
    }
    if ($arr3 != -5) {
        $arr[2] = $arr3;
        $k++;
    }
    if ($arr4 != -5) {
        $arr[3] = $arr4;
        $k++;
    }
    if ($arr5 != -5) {
        $arr[4] = $arr5;
        $k++;
    }
    if ($arr6 != -5) {
        $arr[5] = $arr6;
        $k++;
    }
    if ($arr7 != -5) {
        $arr[6] = $arr7;
        $k++;
    }
    if ($arr8 != -5) {
        $arr[7] = $arr8;
        $k++;
    }
    if ($arr9 != -5) {
        $arr[8] = $arr9;
        $k++;
    }
    if ($arr10 != -5) {
        $arr[9] = $arr10;
        $k++;
    }
    if ($arr11 != -5) {
        $arr[10] = $arr11;
        $k++;
    }
    if ($arr12 != -5) {
        $arr[11] = $arr12;
        $k++;
    }
    global $gLogError;
    global $gLogErrorFile;
    if ($gLogError) {
        $text = date('D M j G:i:s T Y') . "     " . $pointer . "   ";
        $file = $gLogErrorFile;
        ErrorLog($text, $file);
        for ($j = 0; $j < $k; $j++) {
            $text = "    ";
            if (is_array($arr[$j])) {
                if (is_array($arr[$j][0])) {
                    for ($i = 0; $i < count($arr[$j]); $i++) {
                        foreach ($arr[$j][$i] as $key => $value) {
                            $text .= $value . "   ";
                        }
                        $text .= "\n";
                    }
                } else {
                    for ($i = 0; $i < count($arr[$j]); $i++) {
                        $text .= $arr[$j][$i] . "   ";
                    }
                }
                $text .= "\n";
            } else {
                $text = $arr[$j] . "\n";
            }
            $file = $gLogErrorFile;
            ErrorLog($text, $file);
        }
    }
}
Exemple #5
0
 public function getAvailableTypes($personId, $year)
 {
     if (!checkClearanceLevel(ORGANIZER)) {
         return false;
     }
     // Sanitize input data
     $personId = sanitizeInput($personId);
     $year = sanitizeInput($year);
     $query = "SELECT * FROM type AS t WHERE NOT EXISTS (SELECT * FROM hours_extra AS he WHERE he.id_type_name=t.id && he.year={$year} && he.id_person={$personId} && NOT (t.name='Projekt' || t.name='Övrigt'))";
     $result = mysql_query($query, $this->dbConn);
     if (!$result) {
         ErrorLog(mysql_error($this->dbConn));
         return false;
     }
     $availableTypes = array();
     while ($row = mysql_fetch_assoc($result)) {
         $availableTypes[$row['id']] = $row;
     }
     return $availableTypes;
 }
 static function DrawInput($fieldName, $inputType, $defaultValue = '', $possibleValues = NULL, $attributes = NULL, $noSubmit = FALSE)
 {
     $out = '';
     if ($attributes === NULL) {
         $attributes = array();
     }
     //		$defaultValue = str_replace(DEFAULT_CURRENCY_HTML,DEFAULT_CURRENCY,$defaultValue);
     //		$defaultValue = str_replace(DEFAULT_CURRENCY,DEFAULT_CURRENCY_HTML,$defaultValue);
     //		if (!isset($attributes['id'])) $attributes['id'] = $fieldName;
     //		if(!isset($attributes['name']) && !$noSubmit) $attributes['name'] = $fieldName;
     $attributes['name'] = $fieldName;
     if (isset($attributes['class'])) {
         $attributes['class'] .= ' inputtype inputtype-' . $inputType;
     } else {
         $attributes['class'] = 'inputtype inputtype-' . $inputType;
     }
     $defaultValue = utopia::jsonTryDecode($defaultValue);
     $attr = BuildAttrString($attributes);
     if (isset(self::$customInputs[$inputType])) {
         return call_user_func_array(self::$customInputs[$inputType], array($fieldName, $inputType, $defaultValue, $possibleValues, $attributes, $noSubmit));
     }
     switch ($inputType) {
         case itNONE:
             $out .= $defaultValue;
             break;
         case itBUTTON:
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' btn';
             } else {
                 $attributes['class'] = 'btn';
             }
             $attributes['class'] .= ' btn-' . $inputType;
             $attributes['class'] = str_replace('inputtype ', '', $attributes['class']);
             $attr = BuildAttrString($attributes);
             $out .= '<button' . $attr . '>' . $defaultValue . '</button>';
             break;
         case itSUBMIT:
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' btn';
             } else {
                 $attributes['class'] = 'btn';
             }
             $attributes['class'] .= ' btn-' . $inputType;
             $attributes['class'] = str_replace('inputtype ', '', $attributes['class']);
             $attr = BuildAttrString($attributes);
             $out .= '<input' . $attr . ' type="submit" value="' . $defaultValue . '"/>';
             break;
         case itRESET:
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' btn';
             } else {
                 $attributes['class'] = 'btn';
             }
             $attributes['class'] .= ' btn-' . $inputType;
             $attributes['class'] = str_replace('inputtype ', '', $attributes['class']);
             $attr = BuildAttrString($attributes);
             $out .= '<input' . $attr . ' type="reset" value="' . $defaultValue . '"/>';
             break;
         case itCHECKBOX:
             if (is_array($possibleValues)) {
                 $at = array();
                 if (isset($attributes['styles'])) {
                     $at['styles'] = $attributes['styles'];
                 }
                 $at = BuildAttrString($at);
                 if (!preg_match('/^usql\\-/', $fieldName)) {
                     $attributes['name'] = $attributes['name'] . '[]';
                     $attr = BuildAttrString($attributes);
                 }
                 $out .= '<span' . $at . ' class="inputtype inputtype-checkboxlist">';
                 foreach ($possibleValues as $key => $val) {
                     $checked = (string) $key === $defaultValue || is_array($defaultValue) && in_array($key, $defaultValue) ? ' checked="checked"' : '';
                     $val = htmlentities($val, ENT_COMPAT, CHARSET_ENCODING);
                     $out .= "<label><input{$attr} type=\"checkbox\"{$checked} value=\"{$key}\"/>{$val}</label>";
                 }
                 $out .= '</span>';
             } else {
                 $checked = $defaultValue == 1 ? ' checked="checked"' : '';
                 $out .= "<input{$attr} type=\"checkbox\"{$checked} value=\"1\"/>";
             }
             break;
         case itOPTION:
             if (!is_array($possibleValues)) {
                 ErrorLog('Option field specified but no possible values found');
                 return '';
             }
             $count = 0;
             $defaultExists = false;
             foreach ($possibleValues as $key => $val) {
                 $count++;
                 $attributes['id'] = "{$fieldName}-{$count}";
                 $attr = BuildAttrString($attributes);
                 $checked = $key == $defaultValue || is_array($defaultValue) && in_array($key, $defaultValue) ? ' checked="checked"' : '';
                 if ($checked != '') {
                     $defaultExists = true;
                 }
                 $out .= "<input type=\"radio\" {$attr} value=\"{$key}\"{$checked}/>{$val}<br/>";
             }
             if (!$defaultExists && $defaultValue != '') {
                 $out .= "<input type=\"radio\" {$attr} value=\"{$val}\" checked=\"true\">{$defaultValue}";
             }
             break;
         case itPASSWORD:
         case itPLAINPASSWORD:
             $out .= "<input type=\"password\" {$attr} value=\"\"/>";
             break;
         case itTEXT:
             $defaultValue = str_replace('"', '&quot;', $defaultValue);
             $out .= "<input type=\"text\" {$attr} value=\"{$defaultValue}\"/>";
             break;
         case itTEXTAREA:
             //sanitise value.
             if (!utopia::SanitiseValue($defaultValue, 'string') && !utopia::SanitiseValue($defaultValue, 'NULL')) {
                 $defaultValue = 'Value has been sanitised: ' . var_export($defaultValue, true);
             }
             $defaultValue = htmlentities($defaultValue, ENT_COMPAT, CHARSET_ENCODING);
             $out .= "<textarea {$attr}>{$defaultValue}</textarea>";
             break;
         case itCOMBO:
             if (empty($possibleValues)) {
                 $possibleValues = array();
             }
             $out .= "<select {$attr}>";
             if (!isset($possibleValues[''])) {
                 // blank value does not exist.
                 if (isset($attributes['placeholder']) && $attributes['placeholder'] && !isset($possibleValues[$attributes['placeholder']])) {
                     $blankVal = $attributes['placeholder'];
                 } else {
                     $blankVal = '&nbsp;';
                 }
                 $possibleValues = array('' => $blankVal) + $possibleValues;
             } else {
                 // blank value exists, ensure it is at the top.
                 $v = $possibleValues[''];
                 unset($possibleValues['']);
                 $possibleValues = array('' => $v) + $possibleValues;
             }
             $defaultExists = false;
             if (is_array($possibleValues)) {
                 foreach ($possibleValues as $key => $val) {
                     if ($val === false) {
                         continue;
                     }
                     $selected = '';
                     if ($defaultValue !== '' && (is_array($defaultValue) && in_array($key, $defaultValue) || (string) $key === (string) $defaultValue)) {
                         $defaultExists = true;
                         $selected = ' selected="selected"';
                     }
                     $valOutput = $key !== $val ? " value=\"{$key}\"" : '';
                     $out .= "<option{$valOutput}{$selected}>{$val}</option>";
                 }
             }
             if (!$defaultExists && $defaultValue) {
                 $out .= "<optgroup label=\"No longer available\"><option selected=\"selected\">{$defaultValue}</option></optgroup>";
             }
             $out .= "</select>";
             break;
         case itLISTBOX:
             if (!is_array($possibleValues)) {
                 ErrorLog('Listbox field specified but no possible values found');
                 return '';
             }
             $out .= "<select size=5 {$attr}><option value=\"\"></option>";
             foreach ($possibleValues as $name => $val) {
                 if (empty($val)) {
                     continue;
                 }
                 $selected = $val == $defaultValue || is_array($defaultValue) && in_array($val, $defaultValue) ? ' selected="selected"' : '';
                 $out .= "<option value=\"{$val}\"{$selected}>{$name}</option>";
             }
             $out .= "</select>";
             break;
         case itFILE:
             //$defaultValue = htmlentities($defaultValue,ENT_QUOTES,CHARSET_ENCODING);
             //$defaultValue = htmlentities($defaultValue);
             $out .= "<input type=\"file\" {$attr}/>";
             break;
         case itDATE:
             //$formattedVal = ($defaultValue === SQL_FORMAT_EMPTY_TIMESTAMP) || ($defaultValue === SQL_FORMAT_EMPTY_DATE) || ($defaultValue === NULL) || ($defaultValue === '') ? '' : $defaultValue;//date('d/m/Y',strptime($defaultValue,'d/m/Y'));
             $formattedVal = $defaultValue;
             $out .= "<input type=\"text\" {$attr} value=\"{$formattedVal}\"/>";
             break;
         default:
             $defaultValue = str_replace('"', '&quot;', $defaultValue);
             $out .= "<input type=\"{$inputType}\" {$attr} value=\"{$defaultValue}\"/>";
             break;
     }
     return $out;
 }
Exemple #7
0
     if (!$res === false) {
         $anzsql = mysql_affected_rows($config['dbconnection']);
         // Anzahl der eingetragenen Datensaetze ermitteln (Indexaktionen nicht zaehlen)
         $command = strtoupper(substr($sql_command, 0, 7));
         if ($command == 'INSERT ') {
             $anzsql = mysql_affected_rows($config['dbconnection']);
             if ($anzsql > 0) {
                 $restore['eintraege_ready'] += $anzsql;
             }
         }
     }
     // Bei MySQL-Fehlern sofort abbrechen und Info ausgeben
     $meldung = mysql_error($config['dbconnection']);
     if ($meldung != '') {
         if (strtolower(substr($meldung, 0, 15)) == 'duplicate entry') {
             ErrorLog('RESTORE', $databases['db_actual'], $sql_command, $meldung, 1);
             $restore['notices']++;
         } else {
             if ($config['stop_with_error'] == 0) {
                 Errorlog("RESTORE", $databases['db_actual'], $sql_command, $meldung);
                 $restore['errors']++;
             } else {
                 Errorlog("RESTORE", $databases['db_actual'], $sql_command, 'Restore failed: ' . $meldung, 0);
                 SQLError($sql_command, $meldung);
                 die;
             }
         }
     }
 }
 $a++;
 $dauer = time() - $restore['startzeit'];
 public function Delete($query, $tablename)
 {
     $status = "";
     $this->dbconnect();
     $runq = mysql_query("DELETE FROM" . $query) or die($this - ErrorLog("ERROR: " . mysql_error()));
     // Possible Scenarios
     if ($runq === true) {
         $status = "OK";
     } else {
         if ($runq === false) {
             $status = "ERROR: " . mysql_error();
         } else {
             $status = mysql_error();
         }
     }
     return $status;
 }
     // Only update if Rank is less than expected.
     if ($rank < $expRank[0] || $rank > $expRank[1]) {
         // Rank seems to be messed up, will reset to minimum rank for this level
         $errmsg = "Rank Correction (" . $playerinfoData1["pID_{$x}"] . "): " . "Score:" . $score . "; " . "Expected:" . $expRank[0] . "-" . $expRank[1] . "; " . "Found:" . $playerinfoData1["rank_{$x}"] . "; " . "New Rank:" . $expRank[0];
         ErrorLog($errmsg, 2);
         $playerinfoData1["rank_{$x}"] = $expRank[0];
     }
 } else {
     // Fail-safe in-case rank data was not obtained and reset to '0' in-game.
     $rank = $playerinfoData1["rank_{$x}"];
     $rank_db = $row['rank'];
     if ($rank_db > $rank) {
         // SNAPSHOT rank data appears to be incorrect, will use current db rank
         $playerinfoData1["rank_{$x}"] = $rank_db;
         $errmsg = "Rank Correction (" . $playerinfoData1["pID_{$x}"] . "), using db rank ({$rank_db})";
         ErrorLog($errmsg, 2);
     }
 }
 // Calculate kill/deathstreak
 $killstreak = $row['killstreak'] > $playerinfoData1["ks_{$x}"] ? $row['killstreak'] : $playerinfoData1["ks_{$x}"];
 $deathstreak = $row['deathstreak'] > $playerinfoData1["ds_{$x}"] ? $row['deathstreak'] : $playerinfoData1["ds_{$x}"];
 // Calculate best round score
 $rndscore = $row['rndscore'] > $playerinfoData1["rs_{$x}"] ? $row['rndscore'] : $playerinfoData1["rs_{$x}"];
 // Check if Minimal Central Update
 if ($centralupdate == 2) {
     // Ignore any Rank Data in SnapShot as this could mess up current data
     $playerinfoData1["rank_{$x}"] = $row['rank'];
 }
 // Calculate rank change
 $chng = $decr = 0;
 if ($playerinfoData1["rank_{$x}"] != $row['rank']) {
$query = "SELECT ip, dnshost, gport, port FROM servers WHERE bydnsname=1";
$result = mysql_query($query);
checkSQLResult($result, $query);
if (!mysql_num_rows($result)) {
    //	ErrorLog("Player (".$data["pid_$x"].") not found in `subaccounts`.",3);
    exit;
}
while ($data = mysql_fetch_assoc($result)) {
    $newip = "";
    $newip = gethostbyname($data['dnshost']);
    if ($newip != $data['dnshost']) {
        if ($newip == $data['ip']) {
            //ErrorLog("NOT CHANGE ".$data['dnshost']." == ".$data['ip'],3);
        } else {
            $query1 = "SELECT id FROM servers WHERE ip='" . $newip . "' AND gport='" . $data['gport'] . "' AND port='" . $data['port'] . "'";
            $result1 = mysql_query($query1);
            checkSQLResult($result1, $query1);
            if (mysql_num_rows($result1)) {
                while ($data1 = mysql_fetch_assoc($result1)) {
                    $query1a = "DELETE FROM servers WHERE id='" . $data1['id'] . "'";
                    $result1a = mysql_query($query1a);
                    checkSQLResult($result1a, $query1a);
                }
            }
            ErrorLog("CHANGE " . $data['dnshost'] . " == " . $data['ip'] . " => " . $newip, 3);
            $query2 = "UPDATE servers VALUE SET ip='" . $newip . "' WHERE dnshost='" . $data['dnshost'] . "'";
            $result2 = mysql_query($query2);
            checkSQLResult($result2, $query2);
        }
    }
}
        if (file_exists($fn_src)) {
            if (file_exists($fn_dest)) {
                $errmsg = "SNAPSHOT Data File Already Exists, Over-writing! ({$fn_src} -> {$fn_dest})";
                ErrorLog($errmsg, 2);
            }
            copy($fn_src, $fn_dest);
            // Remove the original ONLY if it copies
            if (file_exists($fn_dest)) {
                unlink($fn_src);
            }
        }
        $errmsg = "SNAPSHOT Data File Moved! ({$fn_src} -> {$fn_dest})";
        ErrorLog($errmsg, 3);
    }
    $errmsg = "SNAPSHOT Data File Processed: {$stats_filename}";
    ErrorLog($errmsg, -1);
}
// Close database connection
@mysql_close($connection);
/* * **************************************************
 *                 Helper Functions  Not Used         *
 * ************************************************** */
// Compile Awards from SNAPSHOT
function getAwards()
{
    global $data, $x, $awards, $awardsdata;
    foreach ($awardsdata as $award) {
        $awdkey = $award[1] . "_{$x}";
        if (isset($data[$awdkey])) {
            $awards[] = $award[0];
            $awards[] = $award[2] == 0 ? $data[$awdkey] : $award[2];
Exemple #12
0
function checkSQLResult($result, $query)
{
    if (!$result) {
        $msg = 'ERROR: ' . mysql_error() . "\n";
        $msg .= 'Query String: ' . $query;
        ErrorLog($msg, 1);
        return 1;
    } else {
        return 0;
    }
}
function checkSQLResult($result, $query)
{
    if (!$result) {
        $msg = mysql_errno() . ':' . mysql_error() . ' Query String: ' . $query;
        ErrorLog($msg, 1);
        return 1;
    } else {
        return 0;
    }
}
include_once "../database/initSetting.php";
if (isset($_POST) && isset($_POST['method'])) {
    $post = $_POST;
} else {
    echo "not defined";
    exit;
}
$method = $post['method'];
switch ($method) {
    case "SaveSchedule":
        $param = array("scheduleTime" => $post['B64_scheduleTime'], "shiftSchedule" => $post['B64_schedule']);
        $nFID = $post['fid'];
        $aryResult = array();
        $nErrorCode = GetDBData('SaveShiftSchedule', $nFID, $param, $aryResult);
        ErrorLog($nErrorCode);
        $result = array("result" => "success", "data" => $aryResult);
        print_r(json_encode($result));
        break;
    case "LoadSchedule":
        $fid = isset($post['fid']) == true ? $post['fid'] : 0;
        //get fid from cncid
        if ($fid === 0) {
            $nCNCID = $post['cncid'];
            $result_fid = array();
            $nErrorCode = GetDBData('cncGetFactoryID', $nCNCID, array(), $result_fid);
            $fid = $result_fid;
        }
        $nFID = $fid;
        $aryResult = array();
        $nErrorCode = GetDBData('GetShiftSchedule', $nFID, array(), $aryResult);