コード例 #1
0
function parseDBLine($record)
{
    $dbRecord = array();
    // note that the fields start off at 0, and they are simply parsed
    // in order
    $field = 0;
    print_r("original record");
    print_r($record);
    list($dbRecord["FirstName"], $dbRecord["LastName"]) = parseName($record[$field++]);
    $dbRecord["Email"] = parseEmail($record[$field++]);
    $dbRecord["Phone"] = parsePhone($record[$field++]);
    $dbRecord["Title"] = null;
    $dbRecord["CustomerCNotes"] = parseCustomerCNotes($record[$field++]);
    list($dbRecord["Street1"], $dbRecord["Street2"], $dbRecord["City"], $dbRecord["State"], $dbRecord["Zip"]) = parseAddress($record[$field++]);
    $dbRecord["Country"] = "US";
    $dbRecord["AdminCNotes"] = parseAdminCNotes($record[$field++]);
    $dbRecord["OrderedDate"] = $dbRecord["MetDate"] = parseMetDate($record[$field++]);
    $dbRecord["CustomerONotes"] = parseCustomerONotes($record[$field++]);
    $dbRecord["AdminONotes"] = parseAdminONotes($record[$field++]);
    $dbRecord["Charity"] = parseCharity($record[$field++]);
    $dbRecord["RequestedPay"] = parsePaymentRequested($record[$field++]);
    $dbRecord["PaidDate"] = parsePaid($record[$field++], "10/1/2014");
    $dbRecord["ReleasedToShipping"] = parseReleasedToShipping($record[$field++], "10/1/2014");
    $dbRecord["ShippedDate"] = parseShipped($record[$field++], "10/1/14");
    $dbRecord["IsExpedited"] = parseExpedite($record[$field++]);
    $dbRecord["WasCanceled"] = parseCanceled($record[$field++]);
    $dbRecord["InvoiceNumber"] = $dbRecord["InvoiceID"] = $dbRecord["InvoiceURL"] = null;
    $dbRecord["Carrier"] = $dbRecord["TrackingNum"] = $dbRecord["WasReceived"] = null;
    $dbRecord["Discount"] = $dbRecord["ShippingFee"] = $dbRecord["ExpediteFee"] = null;
    $dbRecord["Products"] = parseProducts($record[$field++]);
    var_dump($dbRecord);
    return $dbRecord;
}
コード例 #2
0
ファイル: nankai_urp.php プロジェクト: noikiy/print
function getName($number, $password)
{
    $data['svpn_name'] = $number;
    $data['svpn_password'] = $password;
    $base = 'https://221.238.246.69:443';
    $url = 'https://221.238.246.69:443/por/login_psw.csp';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_USERAGENT, 'AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1');
    #获取cookie
    $content = curl_exec($ch);
    if (preg_match('/Set-Cookie:(.*);/iU', $content, $matchs)) {
        $cookie = $matchs[1];
    }
    #设置cookie
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    #登录VPN
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    unset($data);
    $content = curl_exec($ch);
    #登录urp
    $urp['Login.Token1'] = $number;
    $urp['Login.Token2'] = $password;
    curl_setopt($ch, CURLOPT_URL, 'https://221.238.246.69:443/web/1/http/0/urp.nankai.edu.cn/userPasswordValidate1.portal');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($urp));
    $content = curl_exec($ch);
    #获取信息
    curl_setopt($ch, CURLOPT_URL, 'https://221.238.246.69:443/web/1/http/0/urp.nankai.edu.cn/index.portal');
    $content = curl_exec($ch);
    #关闭curl
    curl_close($ch);
    return parseName($content, '您好,', '欢迎来到南开大学信息门户');
}
コード例 #3
0
}
// Select all the rows in the markers table
$query = "SELECT * FROM landpks_input_data WHERE boolean_test_plot = 0";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
mysql_close($connection);
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<plots>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)) {
    // ADD TO XML DOCUMENT NODE
    echo '<plot ';
    echo 'name="' . parseToXML(parseName($row['name'])) . '" ';
    echo 'recorder_name="' . parseToXML($row['recorder_name']) . '" ';
    echo 'lat="' . $row['latitude'] . '" ';
    echo 'lng="' . $row['longitude'] . '" ';
    echo 'slope="' . $row['slope'] . '" ';
    echo 'slope_shape="' . $row['slope_shape'] . '" ';
    echo 'land_cover="' . $row['land_cover'] . '" ';
    if ($row['boolean_grazed'] == 1) {
        echo 'grazed= "Yes" ';
    } else {
        echo 'grazed= "No" ';
    }
    if ($row['boolean_flooding'] == 1) {
        echo 'flooding= "Yes" ';
    } else {
        echo 'flooding= "No" ';
コード例 #4
0
ファイル: functions.php プロジェクト: 962464/thinkphp
/**
 * 解析资源地址并导入类库文件
 * 例如 module/controller addon://module/behavior
 * @param string $name 资源地址 格式:[扩展://][模块/]资源名
 * @param string $layer 分层名称
 * @return string
 */
function parse_res_name($name, $layer, $level = 1)
{
    if (strpos($name, '://')) {
        // 指定扩展资源
        list($extend, $name) = explode('://', $name);
    } else {
        $extend = '';
    }
    if (strpos($name, '/') && substr_count($name, '/') >= $level) {
        // 指定模块
        list($module, $name) = explode('/', $name, 2);
    } else {
        $module = MODULE_NAME;
    }
    $array = explode('/', $name);
    $class = $module . '\\' . $layer;
    foreach ($array as $name) {
        $class .= '\\' . parseName($name, 1);
    }
    // 导入资源类库
    if ($extend) {
        // 扩展资源
        $class = $extend . '\\' . $class;
    }
    return $class . $layer;
}
コード例 #5
0
function process_author(&$field)
{
    // field corresponds to a person: make sure they're in the database, and set the field's value to that per_id.
    // We will need to get fairly sophisticated about this eventually, but for now this quick hacque will do.
    $titleDT = defined('DT_NAME') ? DT_NAME : 0;
    $person_bib_ids = array();
    $persons = parseName($field->getRawValue());
    foreach ($persons as $person) {
        if (@$person['anonymous']) {
            array_push($person_bib_ids, 'anonymous');
            continue;
        }
        if (@$person['others']) {
            array_push($person_bib_ids, 'et al.');
            continue;
        }
        if (@$person['questionable']) {
            // a "questionable" name -- e.g. one that could not be parsed, one that looks like an organisation etc.
            return NULL;
        }
        $res = mysql_query('select rec_ID from Records
            left join recDetails SURNAME on SURNAME.dtl_RecID=rec_ID and SURNAME.dtl_DetailTypeID=$titleDT
            left join recDetails GIVENNAMES on GIVENNAMES.dtl_RecID=rec_ID and GIVENNAMES.dtl_DetailTypeID=291
            where rec_RecTypeID = 75
            and SURNAME.dtl_Value = "' . mysql_real_escape_string(trim($person['surname'] . ' ' . @$person['postfix'])) . '"
            and GIVENNAMES.dtl_Value = "' . mysql_real_escape_string(trim($person['first names'])) . '"');
        //MAGIC NUMBER
        if (mysql_num_rows($res) > 0) {
            // an exact match on the citation value: don't want to know if there's more than one person with this name!
            $rec_id = mysql_fetch_row($res);
            $rec_id = $rec_id[0];
        } else {
            // no match -- insert a new person
            mysql_query('insert into Records (rec_Title, rec_RecTypeID, rec_FlagTemporary, rec_Modified, rec_Added) values ("' . mysql_real_escape_string(trim($person['surname'] . ' ' . @$person['postfix']) . ', ' . $person['first names']) . '", 75, 1, now(), now())');
            $rec_id = mysql_insert_id();
            mysql_query('insert into recDetails (dtl_RecID, dtl_DetailTypeID, dtl_Value) values (' . $rec_id . ', 160, "' . mysql_real_escape_string(trim($person['surname'] . ' ' . @$person['postfix'])) . '"),
                (' . $rec_id . ', 291, "' . mysql_real_escape_string($person['first names']) . '")');
            //MAGIC NUMBER
            mysql_query("update Records set rec_Hash = hhash(rec_ID) where rec_ID = {$rec_id}");
        }
        array_push($person_bib_ids, $rec_id);
    }
    $field->_value = $person_bib_ids;
}
コード例 #6
0
ファイル: temp.php プロジェクト: bluecat/iiwork-php
/** memo
 * @class io
 * @param
		$data: 자료
		$ret: return 모드
 * @return 
 */
function parseMemo(&$data, $ret = 0)
{
    global $mini;
    // decode
    foreach ($data as $key => $val) {
        str($data[$key], 'decode');
    }
    // 이름
    foreach (array('name_from', 'name_target') as $val) {
        parseName($data, $val);
    }
    // 관리자 체크박스
    $data['checkbox'] = "<input type='checkbox' name='no[]' value='{$data['no']}' class='middle' />";
    // 시간
    if ($data['date_read'] == '0000-00-00 00:00:00') {
        $data['date_read'] = '';
    }
    $data['time'] = strtotime($data['date']);
    $data['date_out'] = date("m/d H:i", $data['time']);
    $data['date_str'] = $mini['time'] - $data['time'] < $mini['set']['date_str'] * 86400 ? dateSec($mini['time'] - $data['time']) . "전" : "";
    if (!$data['date_str']) {
        $data['date_str'] = $data['date_out'];
    }
    // 내용
    $data['ment_text'] = $data['ment'];
    $data['ment_title'] = nl2br2(str($data['ment_text'], 'encode', 1));
    $data['ment'] = nl2br($data['ment']);
    $data['ment'] = str_replace("<br /><!--n-->", "\n", $data['ment']);
    // XHTML 설정
    $data['ment'] = str_replace(array("&amp;lt;script", "&amp;lt;/script"), array("&lt;script", "&lt;/script"), $data['ment']);
    // 태그 없는 변수
    $data['ment_notag'] = strip_tags($data['ment']);
    // 링크
    $data['js_send_from'] = "onclick='sendMemo({$data['from_member']});'";
    $data['js_send_target'] = "onclick='sendMemo({$data['target_member']});'";
    $data['js_memo_next'] = "onclick='memoAction(\"next\", \"{$data['no']}\");'";
    $data['js_memo_read'] = "onclick='memoAction(\"read\", \"{$data['no']}\");'";
    $data['js_memo_read_all'] = "onclick='memoAction(\"read_all\");'";
    $data['js_memo_close'] = "onclick='memoAction(\"close\");'";
    if ($ret) {
        return $data;
    }
}
コード例 #7
0
ファイル: functions.php プロジェクト: 962464/thinkphp
/**
 * URL组装 支持不同URL模式
 * @param string $url URL表达式,格式:'[模块/控制器/操作#锚点@域名]?参数1=值1&参数2=值2...'
 * @param string|array $vars 传入的参数,支持数组和字符串
 * @param string|boolean $suffix 伪静态后缀,默认为true表示获取配置值
 * @param boolean $domain 是否显示域名
 * @return string
 */
function U($url = '', $vars = '', $suffix = true, $domain = false)
{
    // 解析URL
    $info = parse_url($url);
    $url = !empty($info['path']) ? $info['path'] : ACTION_NAME;
    if (isset($info['fragment'])) {
        // 解析锚点
        $anchor = $info['fragment'];
        if (false !== strpos($anchor, '?')) {
            // 解析参数
            list($anchor, $info['query']) = explode('?', $anchor, 2);
        }
        if (false !== strpos($anchor, '@')) {
            // 解析域名
            list($anchor, $host) = explode('@', $anchor, 2);
        }
    } elseif (false !== strpos($url, '@')) {
        // 解析域名
        list($url, $host) = explode('@', $info['path'], 2);
    }
    // 解析子域名
    if (isset($host)) {
        $domain = $host . (strpos($host, '.') ? '' : strstr($_SERVER['HTTP_HOST'], '.'));
    } elseif (true === $domain) {
        $domain = $_SERVER['HTTP_HOST'];
        if (C('APP_SUB_DOMAIN_DEPLOY')) {
            // 开启子域名部署
            $domain = 'localhost' == $domain ? 'localhost' : 'www' . strstr($_SERVER['HTTP_HOST'], '.');
            // '子域名'=>array('模块[/控制器]');
            foreach (C('APP_SUB_DOMAIN_RULES') as $key => $rule) {
                $rule = is_array($rule) ? $rule[0] : $rule;
                if (false === strpos($key, '*') && 0 === strpos($url, $rule)) {
                    $domain = $key . strstr($domain, '.');
                    // 生成对应子域名
                    $url = substr_replace($url, '', 0, strlen($rule));
                    break;
                }
            }
        }
    }
    // 解析参数
    if (is_string($vars)) {
        // aaa=1&bbb=2 转换成数组
        parse_str($vars, $vars);
    } elseif (!is_array($vars)) {
        $vars = array();
    }
    if (isset($info['query'])) {
        // 解析地址里面参数 合并到vars
        parse_str($info['query'], $params);
        $vars = array_merge($params, $vars);
    }
    // URL组装
    $depr = C('URL_PATHINFO_DEPR');
    $urlCase = C('URL_CASE_INSENSITIVE');
    if ($url) {
        if (0 === strpos($url, '/')) {
            // 定义路由
            $route = true;
            $url = substr($url, 1);
            if ('/' != $depr) {
                $url = str_replace('/', $depr, $url);
            }
        } else {
            if ('/' != $depr) {
                // 安全替换
                $url = str_replace('/', $depr, $url);
            }
            // 解析模块、控制器和操作
            $url = trim($url, $depr);
            $path = explode($depr, $url);
            $var = array();
            $varModule = C('VAR_MODULE');
            $varController = C('VAR_CONTROLLER');
            $varAction = C('VAR_ACTION');
            $var[$varAction] = !empty($path) ? array_pop($path) : ACTION_NAME;
            $var[$varController] = !empty($path) ? array_pop($path) : CONTROLLER_NAME;
            if ($maps = C('URL_ACTION_MAP')) {
                if (isset($maps[strtolower($var[$varController])])) {
                    $maps = $maps[strtolower($var[$varController])];
                    if ($action = array_search(strtolower($var[$varAction]), $maps)) {
                        $var[$varAction] = $action;
                    }
                }
            }
            if ($maps = C('URL_CONTROLLER_MAP')) {
                if ($controller = array_search(strtolower($var[$varController]), $maps)) {
                    $var[$varController] = $controller;
                }
            }
            if ($urlCase) {
                $var[$varController] = parseName($var[$varController]);
            }
            $module = '';
            if (!empty($path)) {
                $var[$varModule] = implode($depr, $path);
            } else {
                if (C('MULTI_MODULE')) {
                    if (MODULE_NAME != C('DEFAULT_MODULE') || !C('MODULE_ALLOW_LIST')) {
                        $var[$varModule] = MODULE_NAME;
                    }
                }
            }
            if ($maps = C('URL_MODULE_MAP')) {
                if ($_module = array_search(strtolower($var[$varModule]), $maps)) {
                    $var[$varModule] = $_module;
                }
            }
            if (isset($var[$varModule])) {
                $module = $var[$varModule];
                unset($var[$varModule]);
            }
        }
    }
    if (C('URL_MODEL') == 0) {
        // 普通模式URL转换
        $url = __APP__ . '?' . C('VAR_MODULE') . "={$module}&" . http_build_query(array_reverse($var));
        if ($urlCase) {
            $url = strtolower($url);
        }
        if (!empty($vars)) {
            $vars = http_build_query($vars);
            $url .= '&' . $vars;
        }
    } else {
        // PATHINFO模式或者兼容URL模式
        if (isset($route)) {
            $url = __APP__ . '/' . rtrim($url, $depr);
        } else {
            $module = defined('BIND_MODULE') && BIND_MODULE == $module ? '' : $module;
            $url = __APP__ . '/' . ($module ? $module . MODULE_PATHINFO_DEPR : '') . implode($depr, array_reverse($var));
        }
        if ($urlCase) {
            $url = strtolower($url);
        }
        if (!empty($vars)) {
            // 添加参数
            foreach ($vars as $var => $val) {
                if ('' !== trim($val)) {
                    $url .= $depr . $var . $depr . urlencode($val);
                }
            }
        }
        if ($suffix) {
            $suffix = true === $suffix ? C('URL_HTML_SUFFIX') : $suffix;
            if ($pos = strpos($suffix, '|')) {
                $suffix = substr($suffix, 0, $pos);
            }
            if ($suffix && '/' != substr($url, -1)) {
                $url .= '.' . ltrim($suffix, '.');
            }
        }
    }
    if (isset($anchor)) {
        $url .= '#' . $anchor;
    }
    if ($domain) {
        $url = (is_ssl() ? 'https://' : 'http://') . $domain . $url;
    }
    return $url;
}
コード例 #8
0
ファイル: example.php プロジェクト: phamd/Timeline-Editor
// This PHP block is only required for server-side saving of inputs.
// Note: This file has been simplified and stripped of a bunch of specifics.
function parseName($name)
{
    $name = preg_replace('/[^A-Za-z0-9_\\-\\s]/', '_', $name);
    // Allow underscores, dashes, spaces.
    $name = preg_replace('/\\s+/', ' ', $name);
    // Reduce multiple spaces to one.
    $name = substr($name, 0, 255);
    // Limit to 255 characters.
    return $name;
}
$timelineDir = 'path/to/timelines/';
$historyName = isset($_POST['historyName']) ? parseName($_POST['historyName']) : null;
$historyAction = isset($_POST['historyAction']) ? parseName($_POST['historyAction']) : null;
$historyData = isset($_POST['historyData']) ? $_POST['historyData'] : null;
switch ($historyAction) {
    case 'save':
        if ($historyName && is_string($historyData) && is_array(json_decode($historyData, true))) {
            file_put_contents($timelineDir . $historyName, $historyData);
        }
        return;
    case 'load':
        echo file_get_contents($timelineDir . $historyName);
        return;
    case 'list':
        echo json_encode(array_map('basename', glob($timelineDir . '*')));
        return;
    case 'delete':
        if (is_file($timelineDir . $historyName)) {
コード例 #9
0
ファイル: url.php プロジェクト: lunnlew/Norma_Code
 protected static function parseUrl($url)
 {
     $request = Request::instance();
     if (0 === strpos($url, '/')) {
         // 直接作为路由地址解析
         $url = substr($url, 1);
     } elseif (false !== strpos($url, '\\')) {
         // 解析到类
         $url = ltrim(str_replace('\\', '/', $url), '/');
     } elseif (0 === strpos($url, '@')) {
         // 解析到控制器
         $url = substr($url, 1);
     } else {
         // 解析到 模块/控制器/操作
         $module = $request->module();
         $module = $module ? $module . '/' : '';
         $controller = $request->controller();
         if ('' == $url) {
             // 空字符串输出当前的 模块/控制器/操作
             $url = $module . $controller . '/' . $request->action();
         } else {
             $path = explode('/', $url);
             $action = Config::get('url_convert') ? strtolower(array_pop($path)) : array_pop($path);
             $controller = empty($path) ? $controller : (Config::get('url_convert') ? parseName(array_pop($path)) : array_pop($path));
             $module = empty($path) ? $module : array_pop($path) . '/';
             $url = $module . $controller . '/' . $action;
         }
     }
     return $url;
 }
コード例 #10
0
ファイル: upload.php プロジェクト: siddharthgoel88/DASHServer
    debug("Created {$midts} from {$midvideoname}");
}
/*
Logic handling upload of the streamlets
*/
if ($_FILES["uploaded"]["size"] < 20000000) {
    if ($_FILES["uploaded"]["error"] > 0) {
        $error = "Return Code: " . $_FILES["uploaded"]["error"];
        debug($error);
    } else {
        debug("Upload: " . $_FILES["uploaded"]["name"]);
        debug("Type: " . $_FILES["uploaded"]["type"]);
        debug("Size: " . $_FILES["uploaded"]["size"] / 1024 . " Kb");
        debug("Temp file: " . $_FILES["uploaded"]["tmp_name"]);
        $fullname = $_FILES["uploaded"]["name"];
        parseName($fullname);
        $videodir = "upload/" . $videoname . "/high";
        $videopath = "{$videodir}/{$videoname}-720*480---{$segmentNumber}.mp4";
        if (!file_exists($videodir)) {
            mkdir($videodir, 0777, true);
        }
        move_uploaded_file($_FILES["uploaded"]["tmp_name"], $videopath);
        debug("Stored in: {$videopath}");
        $tspath = "{$videodir}/{$videoname}-720*480---{$segmentNumber}.ts";
        system("/usr/local/bin/mp42ts {$videopath} {$tspath}");
        transcode();
        #      }
    }
} else {
    echo "Invalid file";
}