Beispiel #1
0
function uploadImg()
{
    echo "<pre>";
    print_r($_FILES);
    print_r($_REQUEST['name']);
    echo "</pre>";
    $unlink_file = $_REQUEST['name'];
    $img_name = str_replace(".jpg", ".png", $unlink_file);
    //Borra la imagen original..
    if (unlink($unlink_file)) {
        echo "Imagen original eliminada correctamente..";
        //Sube al servidor la imagen modificada..
        if (move_uploaded_file($_FILES['file']['tmp_name'], "./" . $img_name)) {
            //Actualiza DB..
            if (updateDB($img_name)) {
                echo "DB modifiada con exito..";
            } else {
                echo "No se pudo actualizar la DB..";
            }
        } else {
            echo "Fallo la subida..";
        }
    } else {
        echo "No se pudo borrar la imagen original..";
    }
    /*
    	define('UPLOAD_DIR', 'img/');
    	$img = $_POST['img'];
    	$img = str_replace('data:image/png;base64,', '', $img);
    	$img = str_replace(' ', '+', $img);
    	$data = base64_decode($img);
    	$file = UPLOAD_DIR . uniqid() . '.png';
    	$success = file_put_contents($file, $data);
    	print $success ? $file : 'Unable to save the file.';
    */
}
Beispiel #2
0
function save($action)
{
    global $dbn, $action;
    #return 'action = ' . $action;
    if (isset($_POST['memberSelect'])) {
        $id = $_POST['memberSelect'];
    } else {
        if (!isset($_POST['uname']) or !isset($_POST['pword']) or !isset($_POST['pwordConfirm'])) {
            return 'You left something out!';
        }
        $id = $_POST['id'];
        $uname = $_POST['uname'];
        $pword1 = $_POST['pword'];
        $pword2 = $_POST['pwordConfirm'];
        $pword = md5($pword1);
        if ($action != 'Delete' and $pword1 != $pword2) {
            return 'The passwords don\'t match!';
        }
    }
    switch ($action) {
        case 'Add':
            $ip = $_SERVER['REMOTE_HOST'];
            $sql = "insert into myprogramo (id, uname, pword, lastip, lastlogin) values (null, '{$uname}', '{$pword}','{$ip}', CURRENT_TIMESTAMP);";
            $out = "Account for {$uname} successfully added!";
            break;
        case 'Delete':
            $action = 'Add';
            $sql = "DELETE FROM `{$dbn}`.`myprogramo` WHERE `myprogramo`.`id` = {$id} LIMIT 1";
            $out = "Account for {$uname} successfully deleted!";
            break;
        case 'Edit':
            $action = 'Add';
            $sql = "update myprogramo set uname = '{$uname}', pword = '{$pword}' where id = {$id};";
            $out = "Account for {$uname} successfully updated!";
            break;
        default:
            $action = 'Edit';
            $sql = '';
            $out = '';
    }
    $x = !empty($sql) ? updateDB($sql) : '';
    #return "action = $action<br />\n SQL = $sql";
    return $out;
}
Beispiel #3
0
// какие валюты запрошены
$currencyBase = $_REQUEST['b'];
// какая - базовая
$dtTo = $_REQUEST['to'];
// только конец диапазона, потому что вынимаем всегда на год назад
// если базовая не рубль, мы её принудительно включим в перечень запрошенных, если её там нет, чтобы данные по ней вытащить из источника и/или базы
if ($currencyBase != 'RUB') {
    if (array_search($currencyBase, $currencies) === false) {
        $currencies[] = $currencyBase;
    }
}
// инициализация базы
$db = new SQLite3('rates.db');
initDB($db);
// обновляем базу по запрошенному перечню и дате конца периода
updateDB($db, $currencies, $dtTo);
// готовим ответ, обращаясь уже к базе
// здесь будем вынимать данные, заполнять пустые даты, приводить курсы к базовой валюте, пересчитывая по рублю
$res['data'] = prepareResponse($db, $currencies, $currencyBase, $dtTo);
// отправляем приложению
header('Access-Control-Allow-Origin: *');
header('Content-type: application/json');
echo json_encode($res);
// ------------------------------------------------
// готовим данные
function prepareResponse($db, $currencies, $currencyBase, $dtTo)
{
    $res = array();
    // для каждой валюты в запросе
    foreach ($currencies as $currency) {
        if ($currency == 'RUB') {
 function step07_dealSQL()
 {
     // $this->closeSite();
     $filePath = $targetDir = DATA_PATH . '/update/download/unzip/updateDB.php';
     if (!file_exists($filePath)) {
         // 如果本次升级没有数据库的更新,直接返回
         echo 1;
         exit;
     }
     require_once $filePath;
     updateDB();
     unlink($filePath);
     // 数据库验证
     $filePath = $targetDir = DATA_PATH . '/update/download/unzip/checkDB.php';
     if (!file_exists($filePath)) {
         // 如果本次升级没有数据库的更新后的验证代码,直接返回
         echo 1;
         exit;
     }
     require_once $filePath;
     // checkDB方法正常返回1 否则返回异常的说明信息,如:ts_xxx数据表创建不成功
     checkDB();
     unlink($filePath);
     echo 1;
 }
$is_exists = mysql_get_rows('user_completed_couse', array('where' => "section_id='{$section_id}' AND user_id='{$user_id}'"), 1);
if ($is_exists === '') {
    $section_data = mysql_get_rows('course_sections', array('where' => "id='{$section_id}'"), 1);
    $insert_values = array('user_id' => $user_id, 'course_id' => $section_data['course_id'], 'section_id' => $section_id);
    $id = insertDB($insert_values, 'user_completed_couse');
    $completed = array();
} else {
    $id = $is_exists['id'];
    if (trim($is_exists['completed']) === '') {
        $completed = array();
    } else {
        $completed = explode(',', trim($is_exists['completed']));
    }
}
if ($enable == 1) {
    $completed[] = $step_id;
    array_unique($completed);
    $str_completed = implode(',', $completed);
    updateDB("completed = '{$str_completed}'", "WHERE id='{$id}'", 'user_completed_couse');
    $return_data['status'] = 1;
    $return_data['enable'] = 1;
} else {
    $completed = array_diff($completed, array($step_id));
    array_unique($completed);
    $str_completed = implode(',', $completed);
    updateDB("completed = '{$str_completed}'", "WHERE id='{$id}'", 'user_completed_couse');
    $return_data['status'] = 1;
    $return_data['enable'] = 0;
}
echo json_encode($return_data);
exit;
    if ($name == 'email') {
        $email = $value;
        // XXX do stripslashes() here and below?
    } elseif ($name == 'rationale') {
        $rationale = $value;
    } elseif ($value == 'TBW' || $value == 'WIP' || $value == 'SCS' || $value == 'none') {
        // Ignore any other values, including empty values.
        $status[addslashes($name)] = $value;
    }
}
// Ensure that email and rationale were provided
if ($email == '' || !Email::isValidEmail($email) || $rationale == '' || !isUTF8($rationale) || mb_strlen($rationale) > 125) {
    getMissingInfo($email, $rationale, $status);
} else {
    if ($_SERVER['PATH_INFO'] == '/confirm') {
        updateDB($email, $rationale, $status);
        outputConfirmed();
    } else {
        $body = getMailConfirmRequest($email, $rationale, $status);
        $sig = "HTML5 Status Updates\nhttp://www.whatwg.org/html5";
        $mail = new Email();
        $mail->setSubject("HTML5 Status Update");
        $mail->addRecipient('To', '*****@*****.**', 'Lachlan Hunt');
        $mail->setFrom("*****@*****.**", "WHATWG");
        $mail->setSignature($sig);
        $mail->setText($body);
        $mail->send();
        outputConfirmation($body, $sig);
    }
}
function getMissingInfo($email, $rationale, $status)
Beispiel #7
0
    }
    if (!empty($_POST['lastname'])) {
        $lastname_edit = $_POST['lastname'];
        $input_cols[] = "lastname";
        $input_adds[] = $lastname_edit;
        $valid = true;
    }
    if (!empty($_POST['birthdate'])) {
        $birthdate_edit = $_POST['birthdate'];
        $input_cols[] = "birthdate";
        $input_adds[] = $birthdate_edit;
        $valid = true;
    }
    $edit_input = array($input_cols, $input_adds);
    if ($valid) {
        updateDB("users", $edit_input, array("id", $user_id));
    }
}
?>

<form id='form_users_edit' action="" method="post">
    <?php 
echo "<table id='table_users' border cellpadding='5px'> \n            <tr style='color:red; font-weight:bold; text-align:center; '>\n            <td style='padding:10px;'>Username</td>\n            <td style='padding:10px;''>Email</td>\n            <td style='padding:10px;''>Password</td>\n            <td style='padding:10px;''>First Name</td>\n            <td style='padding:10px;''>Last Name</td>\n            <td style='padding:10px;''>BirthDate</td>\n            <td style='padding:10px;''>O</td>\n            </tr>";
$sql = select("users", array("id", "username", "email", "password", "firstname", "lastname", "birthdate"));
echo 'Number of Affected Rows : ' . count(mysqli_fetch_array($sql));
while ($rows = mysqli_fetch_array($sql)) {
    echo "<tr><td>" . $rows['username'] . "</td>";
    echo "<td>" . $rows['email'] . "</td>";
    echo "<td>" . $rows['password'] . "</td>";
    echo "<td>" . $rows['firstname'] . "</td>";
    echo "<td>" . $rows['lastname'] . "</td>";
Beispiel #8
0
     $result->close();
     $mysqli->commit();
     echo "<li>Updating standard_setting values in the properties table</li>\n";
     ob_flush();
     flush();
     // Call the standard_setting list page to populate the results in std_set table.
     $result = $mysqli->prepare("SELECT DISTINCT property_id, total_mark FROM properties WHERE marking LIKE '2,%'");
     $result->execute();
     $result->store_result();
     $result->bind_result($property_id, $total_mark);
     while ($result->fetch()) {
         $no_reviews = 0;
         $reviews = get_reviews($mysqli, 'index', $property_id, $total_mark, $no_reviews);
         foreach ($reviews as $review) {
             if ($review['method'] != 'Hofstee') {
                 updateDB($review, $mysqli);
             }
         }
     }
     $result->close();
 }
 // 04/07/2013 (cczsa1) - enhanced question type config
 $new_lines = array("\n// Enhanced Calculation question config\n", "\$enhancedcalculation = array('host' => 'localhost', 'port'=>6311,'timeout'=>5); //default enhancedcalc Rserve config options\n", "//but use phpEval as default for enhanced calculation questions\n", "\$enhancedcalc_type = 'phpEval'; //set the enhanced calculation to use php for maths \n", "\$enhancedcalculation = array(); //no config options for phpEval enhancedcalc plugin");
 $target_line = '$cfg_password_expire';
 $updater_utils->add_line($string, '$enhancedcalculation', $new_lines, 80, $cfg_web_root, $target_line, 1);
 // 04/07/2013 (cczsa1) - add new field to logs to indicate an error state
 if (!$updater_utils->does_column_exist('log0', 'errorstate')) {
     $updater_utils->execute_query("ALTER TABLE log0 ADD COLUMN errorstate tinyint unsigned NOT NULL DEFAULT '0' AFTER user_answer", true);
 }
 if (!$updater_utils->does_column_exist('log0_deleted', 'errorstate')) {
     $updater_utils->execute_query("ALTER TABLE log0_deleted ADD COLUMN errorstate tinyint unsigned NOT NULL DEFAULT '0' AFTER user_answer", true);
Beispiel #9
0
            if ($doUpdate) {
                $sSQL = "INSERT INTO egive_egv (egv_egiveID, egv_famID, egv_DateEntered, egv_EnteredBy) VALUES ('" . $egiveID . "','" . $famID . "','" . date("YmdHis") . "','" . $_SESSION['iUserID'] . "');";
                RunQuery($sSQL);
            }
            foreach ($giftDataMissingEgiveID as $data) {
                $fields = explode('|', $data);
                if ($fields[2] == $egiveID) {
                    $transId = $fields[0];
                    $date = $fields[1];
                    $name = $fields[3];
                    $amount = $fields[4];
                    $fundId = $fields[5];
                    $comment = $fields[6];
                    $frequency = $fields[7];
                    $groupKey = $fields[8];
                    updateDB($famID, $transId, $date, $name, $amount, $fundId, $comment, $frequency, $groupKey);
                }
            }
        } else {
            ++$importError;
        }
    }
    $_SESSION['giftDataMissingEgiveID'] = $giftDataMissingEgiveID;
    $_SESSION['egiveID2NameWithUnderscores'] = $egiveID2NameWithUnderscores;
    importDoneFixOrContinue();
} else {
    ?>
	<table cellpadding="3" align="left">
	<tr><td>
		<form method="post" action="eGive.php?DepositSlipID=<?php 
    echo $iDepositSlipID;
Beispiel #10
0
function convert($fromFile, $toFile)
{
    global $FFMPEG, $count, $REGISTERED_MEDIA_EXTENSION, $FROM_DIR, $con;
    $cmd = $FFMPEG . " -v warning -i " . escapeshellarg($fromFile) . " -map 0 -sn -vcodec libx264 -acodec libfaac " . escapeshellarg($toFile) . " -y 2>&1";
    //$cmd = $FFMPEG . " -v warning -i '" . $fromFile . "' -map 0 -sn -vcodec copy -acodec copy '" . $toFile . "' -y 2>&1";
    //$cmd = "cp '" . $fromFile . "'  '" . $toFile. "' 2>&1";
    echo $cmd . "\n";
    $exec_output = array();
    $return_var = -1;
    exec($cmd, $exec_output, $return_var);
    $path = preg_split("|/|i", $fromFile);
    if ($return_var == 0) {
        //echo $fromFile . " - Ok\n";
        $updDB = updateDB(str_replace($FROM_DIR, '', $fromFile), str_replace($FROM_DIR, '', $toFile));
        if ($updDB) {
            echo str_replace($FROM_DIR, '', $fromFile) . " updated\n";
            exec("rm -f " . escapeshellarg($fromFile));
        } else {
            echo str_replace($FROM_DIR, '', $fromFile) . " NOT UPDATED !!!!!\n";
        }
    } else {
        echo "\tError executing:\n";
        for ($i = 0; $i < sizeof($exec_output); $i++) {
            echo "\t" . $exec_output[$i] . "\n";
        }
    }
}
Beispiel #11
0
             }
             if (!fwrite($handle, $dump_buffer)) {
                 $keyMessage = 'ErrorWriteDump';
                 $error = 1;
             } else {
                 $keyMessage = 'WriteDumpConfirm';
             }
             fclose($handle);
         }
         //end else
         if ($error != 1) {
             $_SESSION['hostDB_old'] = $_POST['dbHost_old'];
             $_SESSION['nameDB_old'] = $_POST['dbName_old'];
             $_SESSION['userDB_old'] = $_POST['dbAdminUsername_old'];
             $_SESSION['passDB_old'] = $_POST['dbAdminPasswd_old'];
             if (!updateDB($_POST['dbHost'], $_POST['dbAdminUsername'], $_POST['dbAdminPasswd'], $_POST['dbName'], $_POST['dbHost_old'], $_POST['dbAdminUsername_old'], $_POST['dbAdminPasswd_old'], $_POST['dbName_old'])) {
                 $keyMessage = 'ErrorUpdateDb';
             } else {
                 $keyMessage = 'UpdateDb';
                 $enableUpdateImage = 1;
             }
         }
     } else {
         $error = 1;
         $keyMessage = 'WrongDbName';
     }
 } else {
     $error = 1;
     $keyMessage = 'WrongDbCredit';
 }
 break;
                 }
             }
             insertDB($insert_data[0], 'messages');
             // Start order if not started
             if ($job_type !== '') {
                 if ($job_type == 2 && $payment_data['order_started'] == 0) {
                     // TODO : change status 2 - Done
                     $order_date = date('Y-m-d H:i:s');
                     updateDB("order_started = 1, order_start_date = '{$order_date}', job_status = 2", "WHERE id = '{$payment_data['id']}'", 'payments');
                     $insert_data[1] = delivery_start_msg($payment_data['id'], $user_data['id']);
                 } elseif ($job_type == 4 && in_array($payment_data['job_status'], array(3))) {
                     updateDB("job_status = 4", "WHERE id = '{$payment_data['id']}'", 'payments');
                 } elseif ($job_type == 5 && in_array($payment_data['job_status'], array(3))) {
                     updateDB("job_status = 5", "WHERE id = '{$payment_data['id']}'", 'payments');
                 } elseif ($job_type == 6) {
                     updateDB("job_status = 6", "WHERE id = '{$payment_data['id']}'", 'payments');
                 }
             }
             $return_data['status'] = 1;
             $return_data['message'] = 'Message sent successfully';
         } else {
             $messages = '';
             foreach ($v->errors() as $k => $msgs) {
                 foreach ($msgs as $msg) {
                     $messages .= $msg . "<br>";
                 }
             }
             $return_data['message'] = $messages;
         }
     }
 }
Beispiel #13
0
function parseAIML($fn, $aimlContent)
{
    if (empty($aimlContent)) {
        return "File {$fn} was empty!";
    }
    global $debugmode, $bot_id, $default_charset;
    $fileName = basename($fn);
    $success = false;
    $dbconn = db_open();
    #Clear the database of the old entries
    $sql = "DELETE FROM `aiml`  WHERE `filename` = '{$fileName}' AND bot_id = '{$bot_id}'";
    if (isset($_POST['clearDB'])) {
        $x = updateDB($sql);
    }
    $myBot_id = isset($_POST['bot_id']) ? $_POST['bot_id'] : $bot_id;
    # Read new file into the XML parser
    $sql_start = "insert into `aiml` (`id`, `bot_id`, `aiml`, `pattern`, `thatpattern`, `template`, `topic`, `filename`, `php_code`) values\n";
    $sql = $sql_start;
    $sql_template = "(NULL, {$myBot_id}, '[aiml_add]', '[pattern]', '[that]', '[template]', '[topic]', '{$fileName}', ''),\n";
    # Validate the incoming document
    /*******************************************************/
    /*       Set up for validation from a common DTD       */
    /*       This will involve removing the XML and        */
    /*       AIML tags from the beginning of the file      */
    /*       and replacing them with our own tags          */
    /*******************************************************/
    $validAIMLHeader = '<?xml version="1.0" encoding="[charset]"?>
<!DOCTYPE aiml PUBLIC "-//W3C//DTD Specification Version 1.0//EN" "http://www.program-o.com/xml/aiml.dtd">
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1">';
    $validAIMLHeader = str_replace('[charset]', $default_charset, $validAIMLHeader);
    $aimlTagStart = stripos($aimlContent, '<aiml', 0);
    $aimlTagEnd = strpos($aimlContent, '>', $aimlTagStart) + 1;
    $aimlFile = $validAIMLHeader . substr($aimlContent, $aimlTagEnd);
    //die('<pre>' . htmlentities("File contents:<br />\n$aimlFile"));
    try {
        libxml_use_internal_errors(true);
        $xml = new DOMDocument();
        $xml->loadXML($aimlFile);
        //$xml->validate();
        $aiml = new SimpleXMLElement($xml->saveXML());
        $rowCount = 0;
        if (!empty($aiml->topic)) {
            foreach ($aiml->topic as $topicXML) {
                # handle any topic tag(s) in the file
                $topicAttributes = $topicXML->attributes();
                $topic = $topicAttributes['name'];
                foreach ($topicXML->category as $category) {
                    $fullCategory = $category->asXML();
                    $pattern = $category->pattern;
                    $pattern = str_replace("'", ' ', $pattern);
                    $that = $category->that;
                    $template = $category->template->asXML();
                    $template = str_replace('<template>', '', $template);
                    $template = str_replace('</template>', '', $template);
                    $aiml_add = str_replace("\r\n", '', $fullCategory);
                    # Strip CRLF from category (windows)
                    $aiml_add = str_replace("\n", '', $aiml_add);
                    # Strip LF from category (mac/*nix)
                    $sql_add = str_replace('[aiml_add]', mysql_real_escape_string($aiml_add), $sql_template);
                    $sql_add = str_replace('[pattern]', $pattern, $sql_add);
                    $sql_add = str_replace('[that]', $that, $sql_add);
                    $sql_add = str_replace('[template]', mysql_real_escape_string($template), $sql_add);
                    $sql_add = str_replace('[topic]', $topic, $sql_add);
                    $sql .= "{$sql_add}";
                    $rowCount++;
                    if ($rowCount >= 100) {
                        $rowCount = 0;
                        $sql = rtrim($sql, ",\n") . ';';
                        $success = updateDB($sql) >= 0 ? true : false;
                        $sql = $sql_start;
                    }
                }
            }
        }
        if (!empty($aiml->category)) {
            foreach ($aiml->category as $category) {
                $fullCategory = $category->asXML();
                $pattern = $category->pattern;
                $pattern = str_replace("'", ' ', $pattern);
                $that = $category->that;
                $template = $category->template->asXML();
                $template = str_replace('<template>', '', $template);
                $template = str_replace('</template>', '', $template);
                $aiml_add = str_replace("\r\n", '', $fullCategory);
                # Strip CRLF from category (windows)
                $aiml_add = str_replace("\n", '', $aiml_add);
                # Strip LF from category (mac/*nix)
                $sql_add = str_replace('[aiml_add]', mysql_real_escape_string($aiml_add), $sql_template);
                $sql_add = str_replace('[pattern]', $pattern, $sql_add);
                $sql_add = str_replace('[that]', $that, $sql_add);
                $sql_add = str_replace('[template]', mysql_real_escape_string($template), $sql_add);
                $sql_add = str_replace('[topic]', '', $sql_add);
                $sql .= "{$sql_add}";
                $rowCount++;
                if ($rowCount >= 100) {
                    $rowCount = 0;
                    $sql = rtrim($sql, ",\n") . ';';
                    $success = updateDB($sql) >= 0 ? true : false;
                    $sql = $sql_start;
                }
            }
        }
        if ($sql != $sql_start) {
            $sql = rtrim($sql, ",\n") . ';';
            $success = updateDB($sql) >= 0 ? true : false;
        }
        $msg = "Successfully added {$fileName} to the database.<br />\n";
    } catch (Exception $e) {
        $success = false;
        $msg = "There was a problem adding file {$fileName} to the database. Please validate the file and try again.<br >\n";
        $msg = libxml_display_errors($msg);
    }
    return $msg;
}
Beispiel #14
0
<pre>
<?php 
require_once "../init_database_data.php";
require_once $store_config['code'] . "stores/" . $store_config["dbms"] . "store_install.phtml";
$cache_store = $cache_config["dbms"] . "store_install";
$cachestore = new $cache_store(".", $cache_config);
function updateDB($store, $properties)
{
    foreach ($properties as $name => $property) {
        echo "\tAltering store_prop_{$name}\n";
        if ($store->has_property($name)) {
            $store->alter_property($name, $property);
        } else {
            $store->create_property($name, $property);
        }
    }
}
updateDB($store, $properties);
updateDB($cachestore, $cacheproperties);
?>
</pre>
<?php

header("Content-type: text/xml");
require_once 'Excel/reader.php';
//echo $numRows."<br/>";
//echo $numCols;
if (isset($_GET)) {
    $startIndex = $_GET["startIndex"];
    $endIndex = $_GET["endIndex"];
    updateDB($startIndex, $endIndex);
}
//update the products based on the Excel
function updateDB($startIndex, $endIndex)
{
    //need to copy the code that does the excel reading
    $analysisData = new Spreadsheet_Excel_Reader();
    // Set output Encoding.
    $analysisData->setOutputEncoding('CP1251');
    $inputFileName = 'ReverseGeoCodingForStopsVerification.xls';
    $analysisData->read($inputFileName);
    error_reporting(E_ALL ^ E_NOTICE);
    $numRows = $analysisData->sheets[0]['numRows'];
    $numCols = $analysisData->sheets[0]['numCols'];
    //echo $numRows.",".$numCols;
    $strRoute = '<Routes>';
    for ($i = $startIndex; $i <= $endIndex; $i++) {
        $stopId = $analysisData->sheets[0]['cells'][$i][1];
        $StopName = $analysisData->sheets[0]['cells'][$i][2];
        $Buses = $analysisData->sheets[0]['cells'][$i][3];
        $latitude = $analysisData->sheets[0]['cells'][$i][4];
        $longitude = $analysisData->sheets[0]['cells'][$i][5];
Beispiel #16
0
    $err = explode(',', $_GET['errors']);
}
if (!empty($_GET['successes'])) {
    $succ = explode(',', $_GET['successes']);
}
$hutId = $_GET['id'];
$hutName = getHutName($hutId);
$hutDetails = fetchHutDetails($hutId);
//Fetch information specific to koie
$errors = array();
$successes = array();
if (!empty($_POST)) {
    $errors = array();
    foreach ($_POST as $id => $value) {
        if (is_numeric($id) and is_numeric($value) and isset($value)) {
            $updateDB = updateDB($id, $value);
            if (!$updateDB) {
                $errors[] = lang("DATABASE_NOT_UPDATED");
            }
        }
    }
    if (empty($errors)) {
        $successes[] = lang("DATABASE_UPDATED");
    }
}
if (!empty($_POST['nyinventar'])) {
    $navn = trim($_POST['nyinventar']);
    $verdi = $_POST['nyinventarverdi'];
    if (!empty($navn) && !empty($verdi)) {
        if (ctype_digit($verdi)) {
            $added = addInventar($navn, $hutId, $verdi);
Beispiel #17
0
    }
} else {
    $mode = "index";
}
require_once 'head.php';
switch ($mode) {
    case 'index':
        viewFront();
        break;
    case 'gallery':
        viewGallery();
        break;
    case 'login':
        viewLogin();
        break;
    case 'register':
        viewRegister();
        break;
    case 'upload':
        viewUpload();
        break;
    case 'logout':
        logOut();
        break;
    case 'updateDB':
        updateDB();
        break;
    default:
        viewFront();
}
require_once 'foot.html';
Beispiel #18
0
    }
    $db->free($query);
    $dbVersion = $numRows < 1 ? MAX_DB_VERSION : $newestVersionFound;
    // if $dbVersion is 0, updateVersion0 will create the table in question instead
    if ($dbVersion > 0 && $numRows < 1) {
        $db->SQL('INSERT INTO `misc_data` (`db.Version`) VALUES (' . $dbVersion . ')');
    } elseif ($dbVersion > 0 && $numRows > 1) {
        $db->SQL('DELETE FROM `misc_data`');
        $db->SQL('INSERT INTO `misc_data` (`db.Version`) VALUES (' . $dbVersion . ')');
    }
}
// call the updating code now that we know the current db version
// use a while loop instead of iterating inside the update function
// so we keep the used stack memory low
while ($dbVersion < MAX_DB_VERSION) {
    updateDB($dbVersion);
}
echo 'The used database (' . $config->getValue('dbName') . ') is up to date (version ' . $dbVersion . ').' . "\n";
exit;
function status($message = '')
{
    echo $message . "\n";
}
function updateDB(&$version)
{
    global $config;
    echo 'Database (' . $config->getValue('dbName') . ') is at version ' . $version . "\n";
    if ($version < MAX_DB_VERSION) {
        echo 'Updating...' . "\n";
        $updateVersionFunction = 'updateVersion' . $version;
        $updateWorked = $updateVersionFunction();
Beispiel #19
0
    PrintText("\n\nCategory ID: {$cat_id}\n=====================================");
    $sph->multiInit(getOptions());
    $stop_after = 31;
    // $count = 1;
    // foreach($category as $one_title){
    for ($cat = 0; $cat < sizeof($category); $cat++) {
        $one_title = $category[$cat];
        PrintText("{$cat}: {$one_title}");
        $sph->setOptions(getOptions());
        $sph->setAttribute('what', 'jobs');
        $sph->setAttribute('lposition', $one_title);
        $sph->addQuery();
        if ($cat % $stop_after == 0 && $cat != 0) {
            getSPHresutls($sph, &$ids, $cat_id);
            // PrintText("\n-------\nafter function ids:\n");
            // var_dump($ids);
            updateDB($ids, $cat_id);
            unset($ids);
            $ids = NULL;
        }
        // $count++;
    }
    getSPHresutls($sph, &$ids, $cat_id);
    updateDB($ids, $cat_id);
    unset($ids);
    $ids = NULL;
    // PrintText("\n-------\nafter function ids:\n");
    // var_dump($ids);
}
PrintText("\nEND:\n");
var_dump($ids);
    if ($attachment_update == 1) {
        $attachment = secure_data($_POST['attachment']);
        $insert_data['attachment'] = $attachment;
        if ($attachment) {
            $src = UPLOAD_ROOT . 'temp/' . $attachment;
            $des = UPLOAD_ROOT . 'attachment/' . $attachment;
            rename($src, $des);
        }
    }
    $insert_data['sender_id'] = $_SESSION['agent'];
    $insert_data['msg_type'] = 1;
    $insert_data['payment_id'] = secure_data($_POST['pi']);
    // Insert
    insertDB($insert_data, 'messages');
    // Update
    updateDB("info_updated = '1'", 'WHERE id = ' . $insert_data['payment_id'], 'payments');
    ob_start();
    include "info_display.php";
    $html = ob_get_contents();
    ob_end_clean();
    $return_data['html'] = $html;
    $return_data['status'] = 1;
    $return_data['message'] = 'Info updated successfully';
} else {
    $messages = '';
    foreach ($v->errors() as $k => $msgs) {
        foreach ($msgs as $msg) {
            $messages .= $msg . "<br>";
        }
    }
    $return_data['message'] = $messages;
Beispiel #21
0
}
// save data
if ($save) {
    // uncomment the following line to provide simple protection for your own public access videoDB
    //if (!preg_match('/[0-9]{2+}/', $id)) break;
    // implicit owner id if not set
    if (!$owner_id) {
        $owner_id = get_current_user_id();
    }
    // generate diskid
    if (empty($diskid) && $config['autoid'] && $mediatype != MEDIA_WISHLIST) {
        $diskid = getDiskId();
    }
    // write videodata table
    $SETS = prepareSQL($GLOBALS);
    $id = updateDB($SETS, $id, $oldmediatype == MEDIA_WISHLIST && $mediatype != MEDIA_WISHLIST);
    // save genres
    setItemGenres($id, $genres);
    // set seen for currently logged in user
    set_userseen($id, $seen);
    // uploaded cover?
    processUpload($id, $_FILES['coverupload']['tmp_name'], $_FILES['coverupload']['type'], $_FILES['coverupload']['name']);
    // make sure no artifacts
    $smarty->clearCache('list.tpl');
    $smarty->clearCache('show.tpl', get_current_user_id() . '|' . $id);
    // add another?
    if ($add_flag) {
        // remove id to prevent edit mode instead of new
        $id = '';
        $smarty->assign('add_flag', $add_flag);
    } else {
Beispiel #22
0
if (0 == errorCount()) {
    for ($x = 0; $x < count($folders); $x++) {
        buildFilesList($cache, $files_list, GIT, $exclude_files, $folders[$x]);
    }
}
if (0 == errorCount() && $cache[1] == GITNEW) {
    downloadFiles($files_list);
}
if (0 == errorCount()) {
    backupFiles($tmp_folder, $files_list);
}
if (0 == errorCount()) {
    copyFiles($files_list);
}
if (0 == errorCount()) {
    $dbupdate = updateDB($nuConfigDBHost, $nuConfigDBName, $nuConfigDBUser, $nuConfigDBPassword);
}
if (errorCount() > 0) {
    $finalResult['message'] = 'ERRORS';
} else {
    $finalResult['message'] = 'SUCCESS';
}
$successCount = count($success);
$finalResult['errors'] = $errors;
$finalResult['success'] = array("{$successCount} File(s) updated");
$finalResult['cache'] = $cache;
$finalResult['dbupdate'] = $dbupdate;
$json = json_encode($finalResult);
//flush();
header('Content-Type: application/json');
echo $json;
     $fields_enc = array('required_data', 'deliverable');
     $insert_data = array();
     $update_data = '';
     foreach ($fields as $field) {
         if (in_array($field, $fields_enc)) {
             $insert_data[$field] = secure_data(htmlspecialchars($_POST[$field]));
         } else {
             $insert_data[$field] = secure_data($_POST[$field]);
         }
         $update_data .= $update_data !== '' ? ", " : "";
         $update_data .= "`{$field}` = '{$insert_data[$field]}'";
     }
     if ($job_id) {
         // Update
         $where = " WHERE id = '{$job_id}' AND service_id = '{$service}'";
         updateDB($update_data, $where, 'service_packages');
         $return_data['type'] = 'update';
     } else {
         // Insert
         $insert_data['service_id'] = $service;
         $job_id = insertDB($insert_data, 'service_packages');
         $return_data['type'] = 'insert';
     }
     $return_data['id'] = $job_id;
     $return_data['name'] = $insert_data['job'];
     $return_data['status'] = 1;
     $return_data['message'] = 'Job updated successfully';
 } else {
     $messages = '';
     foreach ($v->errors() as $k => $msgs) {
         foreach ($msgs as $msg) {
            */
            // On test si le fichier existe déjà sur le serveur.
            $id_copie = $_POST["id_copie"];
            $fileinfo = pathinfo($file);
            // On cherche une entrée libre sur la table "units" dans notre BDD et
            // on récupère son id
            // on ajoute i afin de differencier les differentes copies !
            $idUnite = $id_copie * 10 + $i;
            // On fait en sorte que l'id soit le nom de l'unité sur le dossier /Images
            $uploadImageID = $dir . $idUnite . '.' . $fileinfo['extension'];
            if (!file_exists($uploadImageID)) {
                // si le fichier n'existe pas sur le serveur on procède à l'upload.
                if (move_uploaded_file($myFiles["tmp_name"][$i], $uploadImageID)) {
                    // On met à jour la base de donnée en ajoutant l'unité à l'id récupéré
                    // par find_unset_entry
                    updateDB($idUnite);
                    $msg = "le fichier " . $fileinfo["filename"] . " a été bien envoyé.";
                    ?>
          <script>
          // notifier la secrétaire du succès de l'upload du fichier.
          $( document ).ready(function() {
            window.parent.$.notify("<?php 
                    echo $msg;
                    ?>
", "success");
          });
          </script>
          <?php 
                } else {
                    $msg = "Désolé, le fichier " . $fileinfo["filename"] . " n'a pas pu être envoyé.\n          Veuillez réessayer";
                    ?>
    $update_data .= "`{$field}` = '{$val}'";
    $post_data[$field] = $val;
}
$file_change = secure_data($_POST['file_change']);
if ($file_change == 1) {
    $image = secure_data($_POST['image']);
    if ($image !== '') {
        $src = UPLOAD_ROOT . 'temp/' . $image;
        $destination = UPLOAD_ROOT . 'course/' . $image;
        $destination_thumb = UPLOAD_ROOT . 'course/thumb/' . $image;
        if (file_exists($src)) {
            copy($src, $destination);
            generatethumb($src, $destination_thumb, 580, 367);
            unlink($src);
        }
    }
    $post_data['image'] = $image;
    $update_data .= $update_data !== '' ? ", " : "";
    $update_data .= "`image` = '" . $image . "'";
}
if ($error == 0) {
    updateDB($update_data, " WHERE id='{$id}'", 'courses');
    $_SESSION['msg_selector'] = 'success';
    $_SESSION['msg_message'] = 'Course updated succesfully.';
    $return_data['status'] = 1;
    $return_data['message'] = 'Course updated successfully.';
} else {
    $return_data['message'] = $message;
}
echo json_encode($return_data);
exit;
Beispiel #26
0
        if ($basemode != 'rewrite') {
            if (insertDB($targetDbName, $targetTableName, $data)) {
                $localMenu = str_replace('ID=newID', 'ID=' . $_REQUEST['ID'], $localMenu);
                $error = "{$localMenu}\n<p>正常に登録されました。</p>\n";
                $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
                header("Location: http://" . $_SERVER['HTTP_HOST'] . "{$uri}/");
                foreach ($_REQUEST as $key => $val) {
                    $_REQUEST[$key] = '';
                }
                $flugInputOK = "1";
            } else {
                $error = "<p class=\"error\">登録できませんでした。</p>";
            }
        } else {
            $where = 'WHERE userID = "' . $_REQUEST['userID'] . '"';
            if (updateDB($targetDbName, $targetTableName, $data, $where)) {
                $error = "<p>ID:" . $_REQUEST['userID'] . "は正常に修正されました。</p>";
                $error .= "<p><a href=\"./\">" . $h2Text . "一覧へ行く</a></p>";
                //DB接続
                $db = new DB();
                $db->connect($dbHost, $dbId, $dbPassword, $targetDbName);
                //Clinicデータ取得
                $sql = 'SELECT * FROM ' . $targetTableName . ' WHERE userID = "' . $_REQUEST['userID'] . '";';
                $dataArray = $db->getRow($sql, 'ASSOC');
                $db->disconnect();
            } else {
                $error = "<p class=\"error\">運用ID:" . $_REQUEST['userID'] . "は修正できませんでした。</p>";
            }
        }
    }
}
Beispiel #27
0
function FetchSaveMovie($id, $lookup)
{
    $debug = 0;
    $video = runSQL('SELECT * FROM ' . TBL_DATA . ' WHERE id = ' . $id);
    // get fields (according to list) from db to be saved later
    if ($debug) {
        echo "\n=================== Video DB Data ============================\n";
        print_r($video[0]);
        echo "\n=================== Video DB Data ============================\n";
    }
    $imdbID = $video[0]['imdbID'];
    echo "Movie/imdb -- " . $video[0]['title'] . "/" . $video[0]['imdbID'] . "\n";
    if (empty($imdbID)) {
        echo "No imdbID\n";
        return;
    }
    if (empty($engine)) {
        $engine = engineGetEngine($imdbID);
    }
    if ($debug) {
        echo "IMDBID = {$imdbID}, engine = {$engine}\n";
    }
    $imdbdata = engineGetData($imdbID, $engine);
    # removed due to performance issues of is_utf8
    // fix erroneous IMDB encoding issues
    if (!is_utf8($imdbdata)) {
        echo "Applying encoding fix\n";
        $imdbdata = fix_utf8($imdbdata);
    }
    if (empty($imdbdata[title])) {
        echo "Fetch failed , try again...\n";
        $imdbdata = engineGetData($imdbID, $engine);
    }
    if (empty($imdbdata[title])) {
        echo "Fetch failed again , next movie";
        return;
    }
    if ($debug) {
        echo "\n===================  IMDB Data ============================\n";
        print_r($imdbdata);
        echo "\n===================  IMDB Data ============================\n";
    }
    if (!empty($imdbdata[title])) {
        //
        // NOTE: comment out any of the following lines if you do not want them updated
        //
        $video[0][title] = $imdbdata[title];
        $video[0][subtitle] = $imdbdata[subtitle];
        $video[0][year] = $imdbdata[year];
        $video[0][imgurl] = $imdbdata[coverurl];
        $video[0][runtime] = $imdbdata[runtime];
        $video[0][director] = $imdbdata[director];
        $video[0][rating] = $imdbdata[rating];
        $video[0][country] = $imdbdata[country];
        $video[0][language] = $imdbdata[language];
        $video[0][actors] = $imdbdata[cast];
        $video[0][plot] = $imdbdata[plot];
    }
    if (count($genres) == 0 || $lookup > 1) {
        $genres = array();
        $gnames = $imdbdata['genres'];
        if (isset($gnames)) {
            foreach ($gnames as $gname) {
                // check if genre is found- otherwise fail silently
                if (is_numeric($genre = getGenreId($gname))) {
                    $genres[] = $genre;
                } else {
                    echo "MISSING GENRE {$gname}\n";
                }
            }
        }
    }
    // custom filds , not working for now
    for ($i = 1; $i <= 4; $i++) {
        $custom = 'custom' . $i;
        $type = $config[$custom . 'type'];
        if (!empty($type)) {
            // copy imdb data into corresponding custom field
            $video[0][$custom] = $imdbdata[$type];
            echo "CUSTOM {$custom} {$type} = {$imdbdata[$type]}\n";
        }
    }
    //  -------- SAVE
    $SETS = prepareSQL($video[0]);
    if ($debug) {
        echo "\n===================  Final Data ============================\n";
        echo "SETS = {$SETS} \n";
        echo "\n===================  Final Data ============================\n";
    }
    $id = updateDB($SETS, $id);
    // save genres
    setItemGenres($id, $genres);
    // set seen for currently logged in user
    set_userseen($id, $seen);
}
$update_data = '';
$post_data = array();
$return_data = array('status' => 0);
foreach ($fields as $field) {
    if ($field === 'content') {
        $val = addslashes(trim($_POST[$field]));
    } else {
        $val = secure_data($_POST[$field]);
    }
    if (in_array($field, $required_fields) && $val === '') {
        $error = 1;
        $message .= $message !== '' ? '<br>Please fill up all data' : 'Please fill up all data';
        break;
    }
    $update_data .= $update_data !== '' ? ", " : "";
    $update_data .= "`{$field}` = '{$val}'";
    $post_data[$field] = $val;
}
if ($error == 0) {
    updateDB($update_data, " WHERE id='{$id}'", 'course_sections');
    $course_id = selectDB(" WHERE id='{$id}'", 'course_sections', 'course_id');
    $_SESSION['msg_selector'] = 'success';
    $_SESSION['msg_message'] = 'step updated succesfully.';
    $return_data['cid'] = $course_id;
    $return_data['status'] = 1;
    $return_data['message'] = 'step updated successfully.';
} else {
    $return_data['message'] = $message;
}
echo json_encode($return_data);
exit;
Beispiel #29
0
		if ($result->num_rows > 0) {
			while($row = $result->fetch_assoc()) {
				$studentNumbersFromDB .= $row['studentnumber']." "; //the extra space string here creates a delimiter
			}
		}
		
		//if the user signed in with a student number existing in the DB, update rather than insert.
		//also, sometimes the user might have a cookie for their information; this accounts for that
		$snForDB = isset($_SESSION['studentNumber']) ? $_SESSION['studentNumber'] : $_COOKIE['studentNumber'];
		$nameForDB = (isset($_SESSION['firstName']) ? $_SESSION['firstName'] : $_COOKIE['firstName'])." ".
			(isset($_SESSION['lastName']) ? $_SESSION['lastName'] : $_COOKIE['lastName']);
		$progForDB = isset($_SESSION['programs']) ? $_SESSION['programs'] : $_COOKIE['programs'];
		$coursesforDB = isset($_SESSION['courses']) ? $_SESSION['courses'] : $_COOKIE['courses'];
		
		if (strpos($studentNumbersFromDB, $snForDB) !== false) {
			updateDB($snForDB, $nameForDB, $progForDB, $coursesforDB);
		} else {
			insertIntoDB($snForDB, $nameForDB, $progForDB, $coursesforDB);
		}
		?>
	</body>
</html>
<?php
} else {
	header("Location: index.php");
}
function updateDB($studentnumber, $fullname, $program, $courses) {
	global $conn;
	$sql = "UPDATE `rosenich`.`students` SET fullname='$fullname', 
		program='$program', courses='$courses' 
		WHERE studentnumber='$studentnumber'";
     if ($job_type == 2 && $payment_data['order_started'] == 0) {
         // TODO : change status 2 - Done
         $order_date = date('Y-m-d H:i:s', $time);
         updateDB("order_started = 1, order_start_date = '{$order_date}', job_status = 2", "WHERE id = '{$pi}'", 'payments');
         $insert_data[1] = delivery_start_msg($pi, $user_id);
         $info_data = mysql_get_rows('messages', array('where' => "payment_id='{$payment_data['id']}' AND msg_type='1'"), 1);
         $return_data['od'] = $order_date;
         $return_data['dd'] = 'Before ' . date('Y-m-d H:i:s', strtotime($order_date) + $info_data['days'] * 86400);
     } elseif ($job_type == 4 && in_array($payment_data['job_status'], array(3))) {
         updateDB("job_status = 4", "WHERE id = '{$pi}'", 'payments');
         $info_data = mysql_get_rows('messages', array('where' => "payment_id='{$payment_data['id']}' AND msg_type='1'"), 1);
         $return_data['dd'] = 'Before ' . date('Y-m-d H:i:s', strtotime($payment_data['order_start_date']) + $info_data['days'] * 86400);
     } elseif ($job_type == 5 && in_array($payment_data['job_status'], array(3))) {
         updateDB("job_status = 5", "WHERE id = '{$pi}'", 'payments');
     } elseif ($job_type == 6) {
         updateDB("job_status = 6", "WHERE id = '{$pi}'", 'payments');
         $return_data['dd'] = '-';
     }
     if (in_array($job_type, array(2, 4, 5, 6)) && !is_null($payment_data['bkid']) && $payment_data['bkid'] !== '') {
         $user_data = mysql_get_rows('users', array('where' => "id='{$user_id}'"), 1);
         $curl_pay_data = $payment_data;
         unlink($curl_pay_data['post_data']);
         $curl_data = array('job_type' => $job_type, 'time' => $time, 'bkid' => $payment_data['bkid'], 'email' => $user_data['email'], 'payment_data' => $curl_pay_data, 'access' => md5('dmexpert-to-basekit-api'));
         $extra_data = array(CURLOPT_REFERER => 'http://www.dmexpert.net');
         $url = BK_URL . 'agent/dashboard/updatemessage';
         run_curl($url, $curl_data, $extra_data);
     }
 }
 ob_start();
 include "msg_display.php";
 $html = ob_get_contents();