function delivery_start_msg($pi, $user_id)
{
    $ot_info_data = mysql_get_rows('messages', array('where' => "payment_id = '{$pi}' AND msg_type = 1"), 1);
    $insert_data = array('message' => '<div class="start-order-box"><div class="icon-order-start mb10"></div>Order is started. And it will deliver within ' . $ot_info_data['days'] . ' days.</div>', 'receiver_id' => $user_id, 'msg_type' => 0, 'payment_id' => $pi);
    insertDB($insert_data, 'messages');
    $insert_data['sender_id'] = NULL;
    return $insert_data;
}
Exemple #2
0
function scrap($db, $y, $m, $d, $time)
{
    $postFields = array('strYear' => $y, 'strMonth' => $m, 'strDay' => $d);
    try {
        $url = 'http://g1.taisugar.com.tw/Sugar/Sugar_show_His.asp';
        $sugar = curl($url, $postFields);
        $packtSugarXpath = returnXPathObject($sugar);
        $td = $packtSugarXpath->query('//td');
        // return DOMNodeList
        $td_title = $td->length;
        $td_first = 13;
        $td_second = 14;
        $td_third = 15;
        $td_diff = 7;
        if ($td_title > 13) {
            $pid = filter_var($td->item($td_first)->nodeValue, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
            $kg = filter_var($td->item($td_second)->nodeValue, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
            $bag = filter_var($td->item($td_third)->nodeValue, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
            $result['pid'] = clean($pid);
            $result['pricePerKg'] = $kg;
            $result['pricePerBag'] = $bag;
            $result['time'] = $time;
            while ($result['pid'] != '01021050') {
                $td_first = $td_first + $td_diff;
                $td_second = $td_second + $td_diff;
                $td_third = $td_third + $td_diff;
                $pid = filter_var($td->item($td_first)->nodeValue, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
                $kg = filter_var($td->item($td_second)->nodeValue, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
                $bag = filter_var($td->item($td_third)->nodeValue, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
                $result['pid'] = clean($pid);
                $result['pricePerKg'] = $kg;
                $result['pricePerBag'] = $bag;
                $result['time'] = $time;
            }
            insertDB($db, $result['pid'], $result['pricePerKg'], $result['pricePerBag'], $result['time']);
            print_r($result);
        } else {
            // echo 'no data input';
        }
    } catch (Exception $ex) {
        echo "failed </br>";
    }
}
Exemple #3
0
 //必須・入稿規定等のチェック
 $error .= errorCheckPostData($targetDbColumn, $columnItem, $mustItem[$userAuth], $textLimitItem[$userAuth], $isNumItem, $isMailItem);
 //エラーがなければ書き込み
 if (!$error) {
     //データ作成
     foreach ($targetDbColumn as $key) {
         $data[$key] = isset($_REQUEST[$key]) ? $_REQUEST[$key] : '';
     }
     if (is_array($forceInsertData)) {
         foreach ($forceInsertData as $key => $val) {
             $data[$key] = $val;
         }
     }
     //新規
     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>";
    curl_setopt_array($request, array(CURLOPT_URL => $url, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => http_build_query(array('cmd' => '_notify-validate') + $ipn_post_data), CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER => FALSE, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE, CURLOPT_CAINFO => 'cacert.pem'));
    // Execute request and get response and status code
    $response = curl_exec($request);
    $status = curl_getinfo($request, CURLINFO_HTTP_CODE);
    // Close connection
    curl_close($request);
    if ($status == 200 && $response == 'VERIFIED') {
        // TODO : Check condition for unique txn_id
        $service_data = array();
        $package_data = array();
        $qry = "SELECT * FROM service_packages WHERE id = '{$ipn_post_data['option_selection1']}'";
        $result = mysql_query($qry);
        if (mysql_num_rows($result) > 0) {
            $package_data = mysql_fetch_assoc($result);
            $service_data = mysql_get_rows('services', array('where' => "id = '{$package_data['service_id']}'"), 1);
            if (!is_array($service_data)) {
                $service_data = array();
            }
        }
        $custom = explode('||', $ipn_post_data['custom']);
        $insert_data = array('user_id' => $custom[1], 'client_id' => $ipn_post_data['option_selection2'], 'item_name' => count($service_data) > 0 ? $service_data['name'] : '', 'quantity' => $ipn_post_data['quantity'], 'amount' => $ipn_post_data['mc_gross'], 'txn_id' => $ipn_post_data['txn_id'], 'date' => date('Y-m-d H:i:s', strtotime($ipn_post_data['payment_date'])), 'payment_status' => $ipn_post_data['payment_status'], 'info_updated' => 1, 'package' => $ipn_post_data['item_name'], 'test_ipn' => $ipn_post_data['test_ipn'], 'unique_key' => $custom[0], 'package_id' => $ipn_post_data['option_selection1'], 'post_data' => json_encode($ipn_post_data), 'job_status' => 1);
        $payment_id = insertDB($insert_data, 'payments');
        // TODO : Insert in message
        if (count($package_data) > 0) {
            $message_data = array('receiver_id' => $custom[1], 'payment_id' => $payment_id, 'message' => secure_data($package_data['required_data']), 'deliverable' => secure_data($package_data['deliverable']), 'days' => secure_data($package_data['days_to_complete']), 'msg_type' => 1);
            insertDB($message_data, 'messages');
        }
        // TODO : Send email + save proper data in db
    }
    exit;
}
Exemple #5
0
<?php

session_start();
require 'connectDB.php';
require 'password.php';
$username = $_POST['username'];
$password = $_POST['password'];
$memberType = $_POST['position'];
$hash = password_hash($password, PASSWORD_DEFAULT);
$db = connectDB();
$query = "INSERT INTO member (member_type, password, user_name) VALUES ('{$memberType}', '{$hash}', '{$username}');";
insertDB($query);
$_SESSION['username'] = $username;
header("location:syndicateForm.php");
        break;
    }
    $insert_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);
        }
    }
    $insert_data['image'] = $image;
}
$insert_data['created_at'] = date('Y-m-d H:i:s', time());
if ($error == 0) {
    insertDB($insert_data, 'courses');
    $_SESSION['msg_selector'] = 'success';
    $_SESSION['msg_message'] = 'Course added succesfully.';
    $return_data['status'] = 1;
    $return_data['message'] = 'Course added successfully.';
} else {
    $return_data['message'] = $message;
}
echo json_encode($return_data);
exit;
    }
    // dmexpert id available
    if ($dmid) {
        $service_data = mysql_get_rows('services', array('where' => "id = '{$package_data['service_id']}'"), 1);
        if (!is_array($service_data)) {
            $service_data = array();
        }
        $insert_data['item_name'] = count($service_data) > 0 ? $service_data['name'] : '';
        $insert_data['package'] = $package_data['job'];
        $insert_data['package_id'] = $dmid;
        $msg_insert_data['message'] = secure_data($package_data['required_data']);
        $msg_insert_data['deliverable'] = secure_data($package_data['deliverable']);
        $msg_insert_data['days'] = secure_data($package_data['days_to_complete']);
    } else {
        if (is_array($def_data)) {
            $msg_insert_data['message'] = secure_data($def_data['required_data']);
            $msg_insert_data['deliverable'] = secure_data($def_data['deliverable']);
            $msg_insert_data['days'] = secure_data($def_data['days_to_complete']);
        } else {
            $msg_insert_data['days'] = secure_data($outsource_data['days_complete']);
        }
    }
    // Insert in payment table
    $payment_id = insertDB($insert_data, 'payments');
    $msg_insert_data['payment_id'] = $payment_id;
    // Insert in message table
    insertDB($msg_insert_data, 'messages');
    $return_data['status'] = 1;
    $return_data['payment_id'] = $payment_id;
}
echo json_encode($return_data);
function insertVote()
{
    $db = connectDB();
    $voteString = getVoteString();
    $username = getUserName();
    $recruit = getRecruit();
    $pos = strpos($recruit, "name=");
    $name = substr($recruit, 0, $pos);
    $votes = 0;
    $found = false;
    //Get recruit ID
    foreach ($db->query("SELECT recruit_id FROM recruit WHERE name='" . $name . "'") as $row) {
        $recruitID = $row['recruit_id'];
    }
    //Get member ID
    foreach ($db->query("SELECT member_id, member_type FROM member WHERE user_name='" . $username . "'") as $row) {
        $memberID = $row['member_id'];
        $memberType = $row['member_type'];
    }
    //Check if the user has voted on this recruit already
    foreach ($db->query("SELECT member_id, recruit_id FROM votes") as $row) {
        //If found, alter original vote
        if ($row['member_id'] == $memberID && $row['recruit_id'] == $recruitID) {
            $query = "UPDATE votes SET vote='" . $voteString . "' WHERE member_id='" . $memberID . "' AND recruit_id='" . $recruitID . "';";
            insertDB($query);
            $found = true;
        }
    }
    //If not, insert vote
    if (!$found) {
        $query = "INSERT INTO votes (member_id, vote, recruit_id, member_type) VALUES ({$memberID}, '{$voteString}', {$recruitID}, '{$memberType}');";
        insertDB($query);
    }
    //Add up votes
    foreach ($db->query("SELECT vote, member_type FROM votes where recruit_id='" . $recruitID . "'") as $row) {
        if ($row['member_type']) {
            header("location:recruitResults.php");
        }
        if ($row['vote'] == "Yes") {
            if ($row['member_type'] == "staff") {
                $votes += 3;
            } else {
                if ($row['member_type'] == "officer") {
                    $votes += 2;
                } else {
                    if ($row['member_type'] == "regular") {
                        $votes++;
                    }
                }
            }
        } else {
            if ($row['vote'] == "No") {
                if ($row['member_type'] == "staff") {
                    $votes += -3;
                } else {
                    if ($row['member_type'] == "officer") {
                        $votes += -2;
                    } else {
                        if ($row['member_type'] == "regular") {
                            $votes--;
                        }
                    }
                }
            } else {
            }
        }
    }
    //Update the count
    $query = "UPDATE recruit SET vote_count='" . $votes . "' WHERE recruit_id='" . $recruitID . "';";
    insertDB($query);
}
Exemple #9
0
function crawlStatus($currElement)
{
    $src = $hyperlink = $locn = $userURL = $followers = $rts = $rtu = null;
    //$currElement = $statusArray[$i];
    $createdAt = return_between($currElement, "<created_at>", "</created_at>", EXCL);
    //format the date to Database datetime type (for date based comparisons)
    $dtFormat = dateFormat($createdAt);
    $tempsid = split_string($currElement, "</created_at>", AFTER, EXCL);
    $tempsid = split_string($tempsid, "</id>", BEFORE, EXCL);
    $sid = split_string($tempsid, "<id>", AFTER, EXCL);
    $text = return_between($currElement, "<text>", "</text>", EXCL);
    //this and next functions called to handle unicode characters or non english text
    $text = utf8_to_unicode($text);
    $text = unicode_to_entities_preserving_ascii($text);
    //preg match to extract URL from tweets, if present (currently for http), match string can be modified for better handling
    $do = preg_match('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', $text, $matches);
    if ($do = true) {
        //if url present
        $hyperlink = expandTinyURL(htmlentities($matches['0']));
    }
    //tweets usually contain tiny urls ->expansion needed
    $src = return_between($currElement, "<source>", "</source>", EXCL);
    $src = strip_tags($src);
    //gathering reply to information, if the tweet is a reply
    $rts = return_between($currElement, "<in_reply_to_status_id>", "</in_reply_to_status_id>", EXCL);
    $rtu = return_between($currElement, "<in_reply_to_user_id>", "</in_reply_to_user_id>", EXCL);
    //extracting user information as an array
    $userprofile = return_between($currElement, "<user>", "</user>", EXCL);
    $flag = 0;
    insertDB($sid, $text, $hyperlink, $dtFormat, $rts, $rtu, $src, $userprofile);
}
<?php

require_once '../config.php';
checkAjax();
$section_id = secure_data($_POST['section_id']);
$name = secure_data($_POST['name']);
$return_data = array('status' => 0);
if ($section_id > 0) {
    // Edit
    $qry = "UPDATE course_sections SET `name` = '{$name}' WHERE id='{$section_id}' AND type=1";
    mysql_query($qry);
    $return_data['id'] = $section_id;
    $return_data['type'] = 'edit';
} else {
    // Add
    $course_id = secure_data($_POST['course_id']);
    $insert_data = array('name' => $name, 'course_id' => $course_id, 'type' => 1, 'created_at' => date('Y-m-d H:i:s'));
    $return_data['id'] = insertDB($insert_data, 'course_sections');
    $return_data['type'] = 'insert';
}
$return_data['name'] = $name;
$return_data['status'] = 1;
echo json_encode($return_data);
exit;
<?php

require 'connectDB.php';
$recruit = "insert into recruit (member_id, name, vote_count, creation_date) values('4', 'John', '0', CURDATE());";
insertDB($recruit);
$recruit = "insert into recruit (member_id, name, vote_count, creation_date) values('4', 'Shane', '0', CURDATE());";
insertDB($recruit);
$recruit = "insert into recruit (member_id, name, vote_count, creation_date) values('4', 'Bill', '0', CURDATE());";
insertDB($recruit);
$recruit = "insert into recruit (member_id, name, vote_count, creation_date) values('4', 'Charlie', '3', CURDATE());";
insertDB($recruit);
echo "Inserted into DB!";
$z = 0;
$source = file_get_html('http://www.uni-koeln.de/uni/gebaeude/liste.html');
$table = $source->find('table', 1);
foreach ($table->find('tr') as $row) {
    if ($i == 0) {
        $i = 1;
        continue;
    }
    if ($z < 200) {
        //Werte manipulieren, maximal 100 gleichzeitig, performancebedingt
        $z++;
        continue;
    } else {
        if ($z >= 262) {
            //...
            insertDB($gebaeude);
            echo $j . "\n" . $k . "\n";
            var_dump($gebaeude);
            exit;
        }
    }
    $nr = trim($row->find('td', 0)->plaintext);
    $name = $nr . " " . $row->find('td', 2)->plaintext;
    $strasse = $row->find('td', 3)->plaintext;
    $strasse_plus = preg_replace('/ /', '+', $strasse);
    $replace = array('ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss');
    $strasse_plus = strtr($strasse_plus, $replace);
    //fetching geodata from google API
    $geodata = json_decode(file_get_contents(utf8_encode("http://maps.googleapis.com/maps/api/geocode/json?address={$strasse_plus},Koeln&sensor=false")), true);
    if ($geodata["status"] != "OK") {
        $k++;
 /**
  *
  */
 public function step4()
 {
     $time = date("Y-m-d H:m:s");
     $db_host = $_POST["db_host"];
     $db_port = $_POST["db_port"];
     $db_user = $_POST["db_user"];
     $db_password = $_POST["db_password"];
     $db_name = $_POST["db_name"];
     $db_prefix = $_POST["db_prefix"];
     if ($_POST['admin_password'] != $_POST['admin_password2'] || trim($_POST['admin_password']) == '' || trim($_POST['admin_password2']) == '') {
         $this->error("两次输入的密码不一致,请重新设定!,或者密码为空");
     } else {
         $admin_user = $_POST['admin_user'];
         $admin_password = encrypt($_POST['admin_password']);
         $admin_email = $_POST['admin_email'];
         $user_session = encrypt($admin_user . $admin_password . time());
     }
     $title = $_POST['cfg_title'];
     $site_url = $_POST['cfg_basehost'] . $_POST['cfg_cmspath'];
     if (!test_db_connect($db_host . ":" . $db_port, $db_user, $db_password)) {
         $this->error("数据库服务器或登录密码无效,\n\n无法连接数据库,请重新设定!");
     }
     $conn = mysql_connect($db_host . ":" . $db_port, $db_user, $db_password);
     mysql_query("CREATE DATABASE IF NOT EXISTS `" . $db_name . "`;", $conn);
     if (!mysql_select_db($db_name)) {
         $this->error("选择数据库失败,可能是你没权限,请预先创建一个数据库!");
     }
     mysql_query("set character set 'utf8'");
     mysql_query("set names 'utf8'");
     $file = WEB_ROOT . 'Data/Install/db_config_sample.php';
     if (!File::file_exists($file)) {
         $this->error('Data/Install/db_config_sample.php文件不存在,请检查');
     }
     $content = File::readFile($file);
     $content = str_replace("~dbhost~", $db_host, $content);
     $content = str_replace("~dbport~", $db_port, $content);
     $content = str_replace("~dbname~", $db_name, $content);
     $content = str_replace("~dbuser~", $db_user, $content);
     $content = str_replace("~dbpwd~", $db_password, $content);
     $content = str_replace("~dbprefix~", $db_prefix, $content);
     if (!File::writeFile(WEB_ROOT . 'db_config.php', $content, 'w+')) {
         $this->error("数据库配置文件写入失败,请您手动根据Data/Install/db_config_sample.php文件在根目录创建文件");
     }
     File::makeDir(WEB_ROOT . 'Data/Cache');
     $sql_empty = File::readFile(WEB_ROOT . 'Data/Install/greencms_empty.sql');
     $sql_query = str_replace('{$db_prefix}', $db_prefix, $sql_empty);
     $file = WEB_ROOT . 'Data/Cache/greencms_sample.sql';
     File::writeFile($file, $sql_query, 'w+');
     insertDB($file, $conn);
     File::delFile($file);
     $sql_empty = File::readFile(WEB_ROOT . 'Data/Install/greencms_init.sql');
     $sql_query = str_replace('{$db_prefix}', $db_prefix, $sql_empty);
     $file2 = WEB_ROOT . 'Data/Cache/greencms_init_sample.sql';
     File::writeFile($file2, $sql_query, 'w+');
     insertDB($file2, $conn);
     File::delFile($file2);
     /**
      * 插入管理员数据&更新配置
      */
     $admin_query = "INSERT INTO `{$db_prefix}user` (`user_id`, `user_login`, `user_pass`, `user_nicename`, `user_email`,\n        `user_url`, `user_registered`, `user_activation_key`, `user_status`,  `user_intro`,\n        `user_level`, `user_session`) VALUES(1, '{$admin_user}', '" . $admin_password . "', '管理员', '{$admin_email}',\n         '', '{$time}', '', 1, '我是admin,欢迎使用', 2, '{$user_session}');";
     if (!mysql_query($admin_query, $conn)) {
         $this->error(' 插入管理员数据出错');
     }
     $cquery = "Update `{$db_prefix}options` set option_value='{$title}' where option_name='title';";
     if (!mysql_query($cquery, $conn)) {
         $this->error(' 更新配置数据出错');
     }
     $cquery = "Update `{$db_prefix}options` set option_value='{$site_url}' where option_name='site_url';";
     if (!mysql_query($cquery, $conn)) {
         $this->error(' 更新配置数据出错');
     }
     $software_version = GreenCMS_Version;
     $software_build = GreenCMS_Build;
     $cquery = "Update `{$db_prefix}options` set option_value='{$software_version}' where option_name='software_version';";
     if (!mysql_query($cquery, $conn)) {
         $this->error(' 更新配置数据出错');
     }
     $cquery = "Update `{$db_prefix}options` set option_value='{$software_build}' where option_name='software_build';";
     if (!mysql_query($cquery, $conn)) {
         $this->error(' 更新配置数据出错');
     }
     //TODO              写不下去了
     $this->redirect('Install/Index/step5');
 }
             $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) {
             $messages .= $msg . "<br>";
         }
     }
     $return_data['message'] = $messages;
 }
Exemple #15
0
    file_put_contents('log.txt',$lastmod."\r\n",FILE_APPEND);
*/
//If method = POST
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //Cases for action switch
    //  switch ($_POST['action']){
    //    case ("insert"):
    if ($_POST["action"] == "insert") {
        $fname = $_POST['fname'];
        $sname = $_POST['sname'];
        $company = $_POST['company'];
        $phone = $_POST['phone'];
        $carpark = $_POST['carpark'];
        $carreg = $_POST['carreg'];
        $visit = $_POST['visit'];
        insertDB($fname, $sname, $company, $phone, $carpark, $carreg, $visit);
    } else {
        if ($_POST["action"] == "current") {
            currentPeople();
        } else {
            if ($_POST["action"] == "signout") {
                $ID = $_POST['id'];
                mysqli_query($conn, "UPDATE details SET dleave=NOW() WHERE idDetails='{$ID}'");
            } else {
                if ($_POST["action"] == "delete") {
                    $ID = $_POST['id'];
                    mysqli_query($conn, "DELETE FROM details WHERE idDetails = '{$ID}' ");
                    //deleteRecord($ID);
                } else {
                    if ($_POST["action"] == "search") {
                        $fname = $_POST['fname'];
<?php

include 'config.php';
checkAjax();
$return_data = array('status' => 0);
$section_id = secure_data($_POST['sectionId']);
$step_id = secure_data($_POST['stepId']);
$enable = secure_data($_POST['changeEnable']);
$user_id = $_SESSION['agent'];
// Check if record exists or not
$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;
     }
 }
 $insert_data = array();
 $insert_data[0] = array('message' => secure_data($bkodata['message']), 'sender_id' => $user_data['id'], 'msg_type' => $msg_type, 'payment_id' => $payment_data['id']);
 $attachment_update = isset($bkodata['attachment_update']) ? secure_data($bkodata['attachment_update']) : '';
 if ($attachment_update == 1) {
     $attachment = secure_data($bkodata['attachment']);
     $insert_data[0]['attachment'] = $attachment;
     if ($attachment) {
         $src = $post_data['path'] . $attachment;
         $des = UPLOAD_ROOT . 'attachment/' . $attachment;
         // TODO : check condition image accesible
         copy($src, $des);
     }
 }
 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');
     }
 }
<?php

include 'config.php';
$allowed_domains = array('localhost', 'basekit-staging.digibuzz24.net');
$settings = json_decode(file_get_contents('admin/data/settings.txt'));
$email = secure_data($_GET['e']);
//echo "<pre>"; print_r($_SERVER); exit;
$ref_domain = '';
$referrer = @$_SERVER['HTTP_REFERER'];
if ($referrer) {
    $parse = parse_url($referrer);
    $ref_domain = preg_replace('#^www\\.(.+\\.)#i', '$1', $parse['host']);
}
if ($email && filter_var($email, FILTER_VALIDATE_EMAIL) && $ref_domain && in_array($ref_domain, $allowed_domains)) {
    $user_data = mysql_get_rows('users', array('where' => 'email = "' . $email . '"'), 1);
    if (!$user_data) {
        $email_arr = explode('@', $email);
        $username = $email_arr[0];
        $insert_data = array('email' => $email, 'username' => $username, 'password' => md5(rand(5, 6)), 'type' => 2, 'status' => 1, 'created_at' => date('Y-m-d H:i:s'));
        $id = insertDB($insert_data, 'users');
    } else {
        $id = $user_data['id'];
    }
    $_SESSION['agent'] = $id;
    header("Location: dashboard.php");
    exit;
} else {
    header("Location: login.php");
    exit;
}
    $insert_data = array('message' => $message, 'days' => $days);
    $attachment_update = secure_data($_POST['attachment_update']);
    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 = 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;
    }
    $insert_data[$field] = $val;
}
if ($error == 0) {
    $parent = $insert_data['parent'];
    $course_id = selectDB(" WHERE id='{$parent}'", 'course_sections', 'course_id');
    $insert_data['created_at'] = date('Y-m-d H:i:s', time());
    $insert_data['type'] = 2;
    $insert_data['course_id'] = $course_id;
    insertDB($insert_data, 'course_sections');
    $_SESSION['msg_selector'] = 'success';
    $_SESSION['msg_message'] = 'step added succesfully.';
    $return_data['cid'] = $course_id;
    $return_data['status'] = 1;
    $return_data['message'] = 'step added successfully.';
} else {
    $return_data['message'] = $message;
}
echo json_encode($return_data);
exit;
 function mailSend($Data, $tempData)
 {
     global $clientMailto, $clientSubject, $clientMailBody, $guestMailFrom, $guestMailFromName, $guestSubject, $guestMailBody, $cliantEnv, $guestMailBodyMobile, $mailcc;
     //DBからclientMailtoを取得・DBに内容を書き込み
     if ($this->extramode == "online") {
         //DB接続
         global $dbHost, $dbId, $dbPassword, $dbName, $userTb, $qaTb;
         $db = new DB();
         $db->connect($dbHost, $dbId, $dbPassword, $dbName);
         //個別データを取得
         $sql = 'SELECT mailAddress FROM ' . $userTb;
         $dataArray = $db->getArray($sql, 'ASSOC');
         if (is_array($dataArray)) {
             foreach ($dataArray as $line) {
                 $mailtoArray[] = $line['mailAddress'];
             }
             $clientMailto = implode(",", $mailtoArray);
         } else {
             //DBから取れない時はエラー
             return false;
         }
         //書き込み
         $insertData['name'] = sqlite_escape_string($Data['name']);
         $insertData['pref'] = sqlite_escape_string($Data['pref']);
         $insertData['mail'] = sqlite_escape_string($Data['mail']);
         $insertData['categoryID'] = sqlite_escape_string($Data['categoryID']);
         $insertData['title'] = sqlite_escape_string($Data['title']);
         $insertData['question'] = sqlite_escape_string($Data['question']);
         $insertData['entryDay'] = date("Y/m/d");
         $insertData['dbUpDay'] = date("Y/m/d");
         if (!insertDB($dbName, $qaTb, $insertData)) {
             return false;
         }
         $db->disconnect();
     }
     //送信内容作成
     $clientText = $this->tempReplace($clientMailBody, $tempData);
     $Data['email'] = isset($Data['email']) && $Data['email'] ? $Data['email'] : $Data['mail'];
     if ($cliantEnv == 'PC' && $guestMailBodyMobile) {
         if (isset($Data['domain']) && $Data['domain']) {
             if ($this->mailAddressMobileCheck($Data['email'] . '@' . $Data['domain'])) {
                 $guestText = $this->tempReplace($guestMailBodyMobile, $tempData);
             } else {
                 $guestText = $this->tempReplace($guestMailBody, $tempData);
             }
         } else {
             if ($this->mailAddressMobileCheck($Data['email'])) {
                 $guestText = $this->tempReplace($guestMailBodyMobile, $tempData);
             } else {
                 $guestText = $this->tempReplace($guestMailBody, $tempData);
             }
         }
     } else {
         $guestText = $this->tempReplace($guestMailBody, $tempData);
     }
     //mailfrom
     $Data['name'] = isset($Data['nameA']) && $Data['nameA'] ? $Data['nameA'] . " " . $Data['nameB'] : $Data['name'];
     if (isset($Data['domain']) && $Data['domain']) {
         $clientMailFrom = 'From: ' . mb_encode_mimeheader($Data['name'] . '様') . '<' . ($Data['email'] . '@' . $Data['domain'] ? $Data['email'] . '@' . $Data['domain'] : $clientMailto) . '>';
     } else {
         $clientMailFrom = 'From: ' . mb_encode_mimeheader($Data['name'] . '様') . '<' . ($Data['email'] ? $Data['email'] : $clientMailto) . '>';
     }
     $guestMailTo = $Data['email'];
     $guestMailFrom = 'From: ' . mb_encode_mimeheader($guestMailFromName) . '<' . $guestMailFrom . '>';
     //mailcc
     if ($mailcc != false) {
         mb_send_mail($mailcc, $clientSubject, mb_convert_kana($clientText, "KV"), $clientMailFrom);
         usleep(100000);
     }
     //メール送信
     if (mb_send_mail($clientMailto, $clientSubject, mb_convert_kana($clientText, "KV"), $clientMailFrom)) {
         usleep(100000);
         if ($guestText) {
             if (mb_send_mail($guestMailTo, $guestSubject, mb_convert_kana($guestText, "KV"), $guestMailFrom)) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Exemple #22
0
function savePrint()
{
    global $conn, $fname, $sname, $company, $phone, $carpark, $carreg, $visit, $darrive, $dleave, $fullname;
    insertDB($conn, $fname, $sname, $company, $phone, $carpark, $carreg, $visit, $darrive, $dleave, $fullname);
    printLabel();
}
Exemple #23
-1
function readCSV($dir, $csvFile, $tableName)
{
    // connect
    $m = new MongoClient();
    // select a database
    $db = $m->trend;
    $collection = $db->{$tableName};
    // Get yeat and month from csvFile
    list($year, $month, $rest) = explode("_", $csvFile, 3);
    $year = intval($year);
    $month = intval($month);
    assert($year != null && $month != null);
    $row = 0;
    if (($handle = fopen("{$dir}/{$csvFile}", "r")) == FALSE) {
        echo "{$dir} . {$csvFile} not found!";
        return;
    }
    while (($data = fgetcsv($handle, 10000000, ",")) !== FALSE) {
        // table head field
        if ($row++ == 0) {
            $thdata = array_values($data);
            $fields = getFields($data);
            $types = getTypes($fields);
            // Num of Fields
            $numFields = count($fields);
            // Add meta fields
            $fields[] = "year";
            $fields[] = "month";
            $fields[] = "state";
            $fields[] = "city";
            $fields[] = "county";
            $fields[] = "region";
            //$fields[] = "xlsrow";
            // types
            $types[] = "i";
            $types[] = "i";
            $types[] = "s";
            $types[] = "s";
            $types[] = "s";
            $types[] = "s";
            //$types[] = "i";
            print_r($fields);
            //make a unique/index index
            //makeDBIndex($db, $collection, $fields);
            continue;
        }
        // Another table head?
        $diff = array_diff($thdata, $data);
        // all same?
        if (count($diff) == 0) {
            echo "Skip another table head";
            continue;
        }
        $num = count($data);
        if ($num != $numFields) {
            echo "<!> {$num} fields in line {$row}!\n";
            print_r($data);
            continue;
        }
        assert($fields);
        // add year and month
        $data[] = $year;
        $data[] = $month;
        list($state, $city, $county, $region) = explode(" ", trim($data[0]), 4);
        // data 0 should be the full loc
        $data[] = $state;
        $data[] = $city;
        $data[] = $county;
        $data[] = $region;
        $data[] = $row;
        // echo "$data[0] $data[1]";
        // Let's insert
        insertDB($db, $collection, $types, $fields, $data);
    }
    fclose($handle);
    // mk grpo
    echo "<!> Inserted {$row} rows!\n";
    echo "<!> making agg for {$year}/{$month}...\n";
    mkgrp($db, $tableName, $year, $month);
}