<?php require_once dirname(__file__) . "/parse.php"; require_once dirname(__file__) . "/predict.php"; $users = parse_csv("anonwhipdata.csv"); $predictor = new Predictor($users); $sqdiff = 0; $matches = 0; $sqcount = 0; foreach ($users as $user) { if ($user->monthly_rate) { $predictor = new Predictor($users); $result = $predictor->predict($user); if ($result) { $difference = $user->monthly_rate - $result->monthly_rate; $sqdiff += $difference * $difference; $sqcount += 1; $matches += $result->matches; } } } printf("%0.2f %0.2f\n", sqrt($sqdiff / $sqcount), ($matches / $sqcount));
<?php global $agent_sensors; if ($agent_data['nvidia']['smi'] != '') { $nvidia = parse_csv($agent_data['nvidia']['smi']); if (count($nvidia)) { echo "nvidia-smi: "; foreach ($nvidia as $card) { /* Currently not used: [fan.speed [%]] => 66 % [utilization.gpu [%]] => [Not Supported] [utilization.memory [%]] => [Not Supported] */ if ($card['temperature.gpu'] != '[Not Supported]') { discover_sensor($valid['sensor'], 'temperature', $device, '', $card['index'], 'nvidia-smi', "Nvidia Card " . ($card['index'] + 1) . ": " . $card['name'], '1', '1', NULL, NULL, NULL, 100, $card['temperature.gpu'], 'agent'); $agent_sensors['temperature']['nvidia-smi'][$card['index']] = array('description' => "Nvidia Card " . ($card['index'] + 1) . ": " . $card['name'], 'current' => $card['temperature.gpu'], 'index' => $card['index']); } if ($card['power.draw [W]'] != '[Not Supported]') { discover_sensor($valid['sensor'], 'power', $device, '', $card['index'], 'nvidia-smi', "Nvidia Card " . ($card['index'] + 1) . ": " . $card['name'], '1', '1', NULL, NULL, NULL, NULL, $card['power.draw [W]'], 'agent'); $agent_sensors['power']['nvidia-smi'][$card['index']] = array('description' => "Nvidia Card " . ($card['index'] + 1) . ": " . $card['name'], 'current' => $card['power.draw [W]'], 'index' => $card['index']); } } echo "\n"; } } // EOF
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage poller * @copyright (C) 2006-2014 Adam Armstrong * */ if (!empty($agent_data['app']['zimbra'])) { foreach ($agent_data['app']['zimbra'] as $key => $value) { # key is "vm", "mysql" etc, value is the csv output $zimbra[$key] = parse_csv($value); } if (is_array($zimbra['mtaqueue'])) { /* timestamp, KBytes, requests 04/23/2013 18:19:30, 0, 0 */ $rrd_filename = "app-zimbra-mtaqueue.rrd"; unset($rrd_values); foreach (array('KBytes', 'requests') as $key) { $rrd_values[] = is_numeric($zimbra['mtaqueue'][0][$key]) ? $zimbra['mtaqueue'][0][$key] : "U"; } rrdtool_create($device, $rrd_filename, " \\\n DS:kBytes:GAUGE:600:0:125000000000 \\\n DS:requests:GAUGE:600:0:125000000000 "); rrdtool_update($device, $rrd_filename, "N:" . implode(':', $rrd_values)); } if (is_array($zimbra['fd'])) {
} } function _parse_engine_co2($value) { return intval($value); } function _parse_fuel($value) { $value = strtolower($value); return in_array($value, array("heavy-oil")) ? "diesel" : $value; } function _parse_transmission($value) { if ($value) { $value = strtolower($value); if (in_array($value, array("automatic", "cvt", "manual"))) { return $value; } elseif ($value == "tiptronic") { return "automatic.tiptronic"; } else { return "unknown"; } } } function _parse_rate($value) { return $value ? intval($value) : null; } echo parse_csv("anonwhipdata.csv"); echo "\n";
die();*/ //master file contains all the information about the files with external addresses $master_url = "https://spreadsheets.google.com/a/g.kohovolit.eu/spreadsheet/pub?hl=en_US&hl=en_US&key=0ApmBqWaAzMn_dHJlNjN2WWpaLVVXc005N2E0bTdVeXc&output=csv&dummy=4"; $master_html = grabber($master_url); //parse master csv $master = parse_csv($master_html); //get the last name/town scraped scraperwiki::save_var('run_first', 0); //temp!! $run_first = scraperwiki::get_var('run_first', 0); //for each parliament/town foreach ((array) $master as $key => $row) { if ($key >= $run_first) { $url = $row['link']; $html = grabber($url); $town = parse_csv($html); //add info about parliament, disambiguation foreach ((array) $town as $t_key => $t) { $town[$t_key]['parliament_code'] = $row['parliament_code']; $town[$t_key]['parliament_name'] = $row['parliament_name']; $town[$t_key]['term_name'] = $row['term']; if (!isset($town[$t_key]['disambiguation'])) { $town[$t_key]['disambiguation'] = ''; } } $towns[] = $town; scraperwiki::save_var('run_first', $key); } } //save data foreach ((array) $towns as $town) {
function product_import() { global $txp_user, $textile; define("TEMP_IMPATH", '../images/_import/'); if (isset($_FILES["thefile"])) { $thefile = $_FILES["thefile"]["tmp_name"]; move_uploaded_file($thefile, "../files/import.csv"); chmod("../files/import.csv", 0666); $data = parse_csv("../files/import.csv", true); foreach ($data as $row) { $title = implode(",", $row); $title = explode(",", $title); $title = $title[0]; extract($row); if ($row['STATUS'] == 'Live') { $status = 4; } else { if ($row['STATUS'] == 'Hidden') { $status = 2; } else { $status = 3; } } if (!empty($row['VENDOR'])) { include_once txpath . '/lib/classTextile.php'; $textile = new Textile(); $vendor = dumbDown($textile->TextileThis(trim(doSlash($row['VENDOR'])), 1)); $vendor = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $row['VENDOR'])); } if (!empty($CATEGORY_1)) { $CATEGORY_1 = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $CATEGORY_1)); } if (!empty($CATEGORY_2)) { $CATEGORY_2 = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $CATEGORY_2)); } safe_insert("textpattern", "Title = '{$title}',\n\t\t\t\t\tBody = '{$DESCRIPTION}',\n\t\t\t\t\tStatus = {$status},\n\t\t\t\t\tPosted = now(),\n\t\t\t\t\tLastMod = now(),\n\t\t\t\t\tAuthorID = '{$txp_user}',\n\t\t\t\t\tSection = 'store',\n\t\t\t\t\tCategory1 = '{$CATEGORY_1}',\n\t\t\t\t\tCategory2 = '{$CATEGORY_2}',\n\t\t\t\t\tcustom_1 = '{$PRICE}',\n\t\t\t\t\tcustom_2 = '{$WEIGHT}',\n\t\t\t\t\tcustom_3 = '{$SKU}',\n\t\t\t\t\tcustom_4 = '{$ITEMS_IN_STOCK}',\n\t\t\t\t\tcustom_5 = '{$vendor}',\n\t\t\t\t\tuid\t\t\t\t= '" . md5(uniqid(rand(), true)) . "',\n\t\t\t\t\tfeed_time\t\t= now()"); //echo mysql_error(); $ID = mysql_insert_id(); //echo $ID; print_r($product); die(); if (!empty($row['PRODUCT_IMAGE_1'])) { $img = TEMP_IMPATH . $row['PRODUCT_IMAGE_1']; upload_image($img, '1', $ID); } if (!empty($row['PRODUCT_IMAGE_2'])) { $img = TEMP_IMPATH . $row['PRODUCT_IMAGE_2']; upload_image($img, '2', $ID); } if (!empty($row['PRODUCT_IMAGE_3'])) { $img = TEMP_IMPATH . $row['PRODUCT_IMAGE_3']; upload_image($img, '3', $ID); } if (!empty($row['PRODUCT_IMAGE_4'])) { $img = TEMP_IMPATH . $row['PRODUCT_IMAGE_4']; upload_image($img, '4', $ID); } $customFields = ''; if (!empty($row['CUSTOM_FIELD_LABEL_1'])) { $field = array('label' => $row['CUSTOM_FIELD_LABEL_1'], 'value' => $row['CUSTOM_FIELD_VALUE_1']); $customFields[] = $field; } if (!empty($row['CUSTOM_FIELD_LABEL_2'])) { $field = array('label' => $row['CUSTOM_FIELD_LABEL_2'], 'value' => $row['CUSTOM_FIELD_VALUE_2']); $customFields[] = $field; } if (!empty($row['CUSTOM_FIELD_LABEL_3'])) { $field = array('label' => $row['CUSTOM_FIELD_LABEL_3'], 'value' => $row['CUSTOM_FIELD_VALUE_3']); $customFields[] = $field; } if (!empty($row['CUSTOM_FIELD_LABEL_4'])) { $field = array('label' => $row['CUSTOM_FIELD_LABEL_4'], 'value' => $row['CUSTOM_FIELD_VALUE_4']); $customFields[] = $field; } if (count($customFields) > 0) { save_custom_fields($customFields, $ID); } } products_list('', '', "Products Imported"); } else { products_list('', '', 'Error: Couldn\'t Find Uploaded File!'); } }
<?php if (empty($argv[1])) { die("Syntax: php {$argv[0]} <csv-file>\n"); } $csv_file = $argv[1]; $excludes = array('live', 'adops', 'adops1', 'adops2', 'adops3', 'adops4', 'adops5'); $content_path = '/srv/www/wp-content-sites'; $branches = parse_csv($csv_file); if (empty($branches)) { die("Nothing to cleanup\n"); } $paths = glob($content_path . "/*"); foreach ($paths as $path) { $branch = basename($path); if (in_array($branch, $excludes)) { continue; } if (empty($branches[$branch])) { echo "Remove: {$path}\n"; exec('rm -rf ' . escapeshellarg($path)); continue; } if (file_exists($path . '/themes/vip')) { $theme_paths = glob($path . '/themes/vip/*'); foreach ($theme_paths as $theme_path) { $theme = basename($theme_path); if (!in_array($theme, $branches[$branch])) { echo "Remove: {$theme_path}\n"; exec('rm -rf ' . escapeshellarg($theme_path)); }
$error .= "- Code is blank<br>"; } if ($new_description == '') { $error .= "- Description is blank<br>"; } if ($new_code != '') { $sql = "SELECT * from codes where field_id='" . jb_escape_sql($field_id) . "' AND code like '%" . jb_escape_sql($new_code) . "%' "; $result = JB_mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { $error .= "- The new Code is too similar to an already existing code. Please try to come up with a different code.<br>"; } } return $error; } if ($_REQUEST['bulk_submit'] != '') { $lines = parse_csv($_REQUEST['csv_codes']); foreach ($lines as $line) { echo $line[0] . ", " . $line[1] . "<br>"; $error = validate_code($field_id, trim($line[0]), trim($line[1])); if ($error == '') { JB_insert_code($field_id, trim($line[0]), trim($line[1])); } else { $JBMarkup->error_msg('<b>ERROR!</b> Cannot save ' . $line[0] . ' code because:'); echo $error; } $error = ''; } $JBMarkup->ok_msg('Bulk import complted'); } if ($_REQUEST['new_code'] != '') { $error = validate_code($field_id, $_REQUEST['new_code'], $_REQUEST['new_description']);
function plugin_qform_mkform($data, $style = 'table') { global $vars, $script; $qm = get_qm(); $page = $vars['page']; $posted = isset($_SESSION['qform']) ? $_SESSION['qform'] : false; $els = $data['element']; $data_set = array(); $enctype = ''; foreach ($els as $key => $el) { switch ($el['type']) { // !input[type=text] case 'text': $str = isset($posted[$el['id']]) ? $posted[$el['id']] : $el['default']; if ($el['size']) { $size = ' size="' . $el['size'] . '"'; $st_size = 'width:' . $el['size'] . 'em;'; } else { $size = $st_size = ''; } $content = '<input type="text" name="qform[' . $el['id'] . ']" value="' . $str . '"' . $size . ' style="' . $st_size . '" />'; $valid = $el['validation'] == '' ? false : true; break; // !input[type=checkbox] // !input[type=checkbox] case 'check': $content = ''; foreach ($el['option'] as $k => $v) { $chked = $v == $el['default'] ? 'checked="checked"' : ''; if (isset($posted[$el['id']])) { $chked = isset($posted[$el['id']][$k]) ? 'checked="checked"' : ''; } $content .= <<<EOD \t<label><input type="checkbox" name="qform[{$el['id']}][{$k}]" {$chked} value="{$v}"> {$v} </label> EOD; } $valid = $el['validation'] == '' ? false : true; break; // !select // !select case 'select': $content = <<<EOD \t<select name="qform[{$el['id']}]"> EOD; foreach ($el['option'] as $k => $v) { $chked = $v == $el['default'] ? 'selected="selected"' : ''; if (isset($posted[$el['id']])) { $chked = $v == $posted[$el['id']] ? 'selected="selected"' : ''; } $content .= <<<EOD \t\t<option value="{$v}" {$chked}>{$v}</option> EOD; } $content .= '</select>'; $valid = false; break; // !input[type=radio] // !input[type=radio] case 'radio': $content = ''; foreach ($el['option'] as $k => $v) { $chked = $v == $el['default'] ? 'checked="checked"' : ''; if (isset($posted[$el['id']])) { $chked = $v == $posted[$el['id']] ? 'checked="checked"' : ''; } $content .= <<<EOD \t<label><input type="radio" name="qform[{$el['id']}]" value="{$v}" {$chked}> {$v} </label> EOD; } $valid = false; break; // !textarea(memo) // !textarea(memo) case 'memo': if (isset($posted[$el['id']])) { $default = htmlspecialchars($posted[$el['id']]); } else { $default = str_replace('&br;', "\n", $el['default']); } $content = '<textarea name="qform[' . $el['id'] . ']" rows="' . $el['rows'] . '" style="width:97%">' . $default . '</textarea>'; $valid = $el['validation'] == '' ? false : true; break; // !input[name='qform[email]'] // !input[name='qform[email]'] case 'email': // qhm $str = isset($posted['email']) ? $posted['email'] : ''; // qhm $readonly = ''; $str = isset($posted['email']) ? $posted['email'] : $_SESSION['commu_user']['email']; $readonly = isset($_SESSION['commu_user']['email']) ? ' readonly="readonly"' : ''; $content = '<input type="text" name="qform[email]" value="' . $str . '" style="width:97%"' . $readonly . ' />'; if (trim($el['confirm']) && !$readonly) { $val = isset($posted['email2']) ? $posted['email2'] : ''; $content .= '<br /><br /><input type="text" name="qform[email2]" value="' . h($val) . '" style="width:97%" />'; $content .= '<br /><span style="font-size:.8em;">※確認のためもう一度入力してください</span>'; } $valid = $el['validation'] == '' ? false : true; break; // !input[type='qform[name'] // !input[type='qform[name'] case 'lname': $str = ''; // qhm $lname = isset($posted['lname']) ? $posted['lname'] : ''; // qhm $fname = isset($posted['fname']) ? $posted['fname'] : ''; // qhm $l_readonly = ''; // qhm $f_readonly = ''; $lname = isset($posted['lname']) ? $posted['lname'] : $_SESSION['commu_user']['lastname']; $fname = isset($posted['fname']) ? $posted['fname'] : $_SESSION['commu_user']['firstname']; $l_readonly = isset($_SESSION['commu_user']['lastname']) ? ' readonly="readonly"' : ''; $f_readonly = isset($_SESSION['commu_user']['firstname']) ? ' readonly="readonly"' : ''; $content = '<input type="text" name="qform[lname]" value="' . $lname . '" size="10" style="width:auto;"' . $l_readonly . ' /> <input type="text" name="qform[fname]" value="' . $fname . '" size="10" style="width:auto;"' . $f_readonly . ' />'; $valid = $el['validation'] == '' ? false : true; break; // !input[type='qform[name_kana]'] // !input[type='qform[name_kana]'] case 'lname_kana': $str = ''; $lname_kana = isset($posted['lname_kana']) ? $posted['lname_kana'] : ''; $fname_kana = isset($posted['fname_kana']) ? $posted['fname_kana'] : ''; $l_readonly = ''; $f_readonly = ''; // commu $lname = isset($posted['lname']) ? $posted['lname'] : $_SESSION['commu_user']['lastname']; // commu $fname = isset($posted['fname']) ? $posted['fname'] : $_SESSION['commu_user']['firstname']; // commu $l_readonly = isset($_SESSION['commu_user']['lastname']) ? ' readonly="readonly"' : ''; // commu $f_readonly = isset($_SESSION['commu_user']['firstname']) ? ' readonly="readonly"' : ''; $content = '<input type="text" name="qform[lname_kana]" value="' . $lname_kana . '" size="10" style="width:auto;"' . $l_readonly . ' /> <input type="text" name="qform[fname_kana]" value="' . $fname_kana . '" size="10" style="width:auto;"' . $f_readonly . ' />'; $valid = $el['validation'] == '' ? false : true; break; //!address //!address case 'address_zip': // $selected = isset($posted['address_state']) ? $posted['address_state'] : '東京都'; $selected = isset($posted['address_state']) ? $posted['address_state'] : ($els['address_state']['default'] != '' ? $els['address_state']['default'] : '東京都'); $options = parse_csv($qm->m['plg_qform']['states']); $str = ''; foreach ($options as $op) { $sld = $op == $selected ? 'selected="selected"' : ''; $str .= '<option value="' . $op . '" ' . $sld . '>' . $op . '</option>' . "\n"; } $arr = array(); foreach (array('zip', 'city', 'street') as $n) { $arr[$n] = isset($posted['address_' . $n]) ? $posted['address_' . $n] : ''; } $content = <<<EOD <p style="line-height:2em; margin:0 0;">{$qm->m['plg_qform']['zipcode']} : <input type="text" name="qform[address_zip]" value="{$arr['zip']}" style="width:7em;" /><br /> {$qm->m['plg_qform']['state']} : <select name="qform[address_state]">{$str}</select><br /> {$qm->m['plg_qform']['city']} : <input type="text" name="qform[address_city]" value="{$arr['city']}" style="width:70%;" /><br /> {$qm->m['plg_qform']['street']} : <input type="text" name="qform[address_street]" value="{$arr['street']}" style="width:70%;" /></p> EOD; $valid = $el['validation'] == '' ? false : true; break; // !states // !states case 'state': $default = $el['default'] != '' ? $el['default'] : $qm->m['plg_qform']['def_state']; $selected = isset($posted['state']) ? $posted['state'] : $default; $options = parse_csv($qm->m['plg_qform']['states']); $str = ''; foreach ($options as $op) { $sld = $op == $selected ? 'selected="selected"' : ''; $str .= '<option value="' . $op . '" ' . $sld . '>' . $op . '</option>' . "\n"; } $content = '<select name="qform[state]">' . $str . '</select>'; $valid = $el['validation'] == '' ? false : true; break; // !contract // !contract case 'contract': //self include if ($vars['page'] == $el['pagename']) { $contract = '<p style="color:red;">' . $qm->m['plg_qform']['err_looppage'] . '</p>'; } else { if (is_page($el['pagename'])) { $contract = convert_html(get_source($el['pagename'])); $contract = '<div style="width:100%;max-height:150px;overflow-y:scroll;margin:5px auto;border:1px solid #ccc;">' . $contract . '</div>'; // $contract .= '<div style="text-align:right;"><a href="">利用規約を開く</a></div>'; } else { $contract = '<p style="color:red;">' . $qm->m['fmt_err_notfoundpage_title'] . '</p>'; } } $cblabel = strlen($el['cblabel']) ? $el['cblabel'] : $qm->m['plg_qform']['lbl_agree']; $content = ' ' . $contract . ' <div style="margin:5px 0 auto;text-align:center;"> <label><input type="checkbox" name="qform[contract]" value="' . $qm->m['plg_qform']['agree'] . '" /> ' . $cblabel . '</label> </div> '; $valid = true; break; // !添付ファイル // !添付ファイル case 'attach': $content = '<input type="file" name="qform[' . $el['id'] . ']" />'; $valid = $el['validation'] == '' ? false : true; $enctype = ' enctype="multipart/form-data" '; break; // !buttons setting // !buttons setting case 'buttons': $qm->m['plg_qform']['btn_confirm'] = $el['confirm']; $qm->m['plg_qform']['btn_back'] = $el['back']; $qm->m['plg_qform']['btn_submit'] = $el['submit']; $content = ''; break; default: $content = ''; } if ($content !== '') { $data_set[] = array('label' => $el['label'], 'content' => $content, 'exp' => $el['exp'], 'valid' => $valid); } } $keitai = ''; if (UA_PROFILE == 'keitai') { $keitai = '<input type="hidden" name="mobssid" value="yes" /> <input type="hidden" name="' . session_name() . '" value="' . session_id() . '" /> '; } $form = '<form action="' . $script . '" method="post" class="qform_form"' . $enctype . '>' . "\n"; $form .= '<input type="hidden" name="cmd" value="read" /> '; $form .= '<input type="hidden" name="page" value="' . $page . '" /> '; $form .= '<input type="hidden" name="qform_condition" value="confirm" /> '; $form .= $keitai; $form .= plugin_qform_format($data_set, $style); $form .= '<p style="text-align:center"><input type="submit" name="submit" value="' . $qm->m['plg_qform']['btn_confirm'] . '" /></p>'; $form .= '</form>'; return $form; }
function readData() { global $filename; $file = file_get_contents($filename); $rows = parse_csv($file); // print_r($rows); $fields = array('first_name', 'last_name', 'preferred_name', 'date_of_birth', 'phone_mobile', 'email', 'primary_address_street', 'primary_address_city', 'primary_address_state', 'primary_address_postalcode', 'arrest_date', 'arrest_time', 'arrest_city_c', 'arrest_location', 'support_needs_c', 'felony_charges', 'police_report_number_c', 'docket_c', 'first_appearance_date_c', 'next_hearing_time_c', 'cant_attend_c', 'medical_needs_c', 'description'); $data = array(); $row = $rows[0]; $fieldcount = count($row); if (count($fields) + 2 != $fieldcount) { if ($fieldcount == 1) { $msg = "No online intakes to import"; } else { $msg = "field count mismatch: is " . count($row) . " but should be " . (count($fields) + 2) . "\n"; } print "<div class='message'>{$msg}</div>"; exit; } $id = array_shift($row); $date = array_shift($row); foreach ($fields as $field) { $value = array_shift($row); if (strpos($field, 'date') !== false) { $value = fixDate($value); } else { if ($field == 'arrest_city_c') { $data['jurisdiction_c'] = $value == 'San Francisco' ? 'SF' : 'A'; } else { if ($field == 'description') { $value .= "\nUpdated from online intake on " . substr($date, 0, 10); } } } $value = str_replace(";", "\n", $value); $data[$field] = $value; } $data['release_type_c'] = 'unkown_released'; $arrestee = array_shift(dbLookupArray("select * from arrestees where id='{$id}'")); if (isset($arrestee['release_type_c'])) { if ($arrestee['release_type_c'] != 'in') { $data['release_type_c'] = $arrestee['release_type_c']; } } return $data; }
<?php include_once 'include/variables.php'; include_once 'include/functions.php'; // These str_replace() commands are a weak prevention mechanism against SQL attacks, but also prevent bugs with names like "O'Hara". $textarea = str_replace('\'', '', $_POST['textarea']); $textarea = str_replace('"', '', $textarea); $csv = parse_csv($textarea); foreach ($csv as $line) { if ($line[0] != '') { $db_insert = $DB->prepare($DB_INSERT_STRING); $db_insert->bind_param('sssssss', $line[0], $line[1], $line[2], $line[3], $line[4], $line[5], $line[6]); $db_insert->execute(); } } header('Location: index.php');
function amuCSVToRegister() { global $wpdb; $rawCSVdata = $_POST['filecontents']; $parsedData = parse_csv($rawCSVdata); $reorderedData = reorder_csv($parsedData); $userData = json_decode($reorderedData); $confirmationStack = array(); $line = 0; //pull out each user data array and process individually foreach ($userData as $userRow) { $line++; if ($userRow->user_login !== '') { //create new user object $newUser = new amuUserObject($userRow); //register initial user info $newid = $newUser->amuRegisterUser(); if (is_int($newid)) { //update users data based on input $newUser->amuUpdateUserData(); //send user a notification email $newUser->amuSendUserEmail(); //add any additional meta data fields $newUser->amuUpdateUserMeta($userRow); //set confirmation message $confirmUpdate = '<p><strong>' . $line . '</strong>. ' . __('New user successfully registered.', 'amulang') . ' <strong>' . __('Login', 'amulang') . ':</strong> ' . $newUser->user_login . ' <strong>' . __('Password', 'amulang') . ':</strong> ' . $newUser->user_pass . ' <strong>' . __('Email', 'amulang') . ':</strong> ' . $newUser->user_email . '</p>'; } else { //return failure message $confirmUpdate = '<p>' . $line . '. ' . $newid . '</p>'; } //kill reusable object unset($newUser); } else { //return failure message $confirmUpdate = '<p>' . $line . '. ' . __('No user_login was found. This line was skipped.', 'amulang') . '</p>'; } //add success or failure message to stack $confirmationStack[] = $confirmUpdate; } echo '<h3>' . __('Results of your new user registrations', 'amulang') . '</h3>'; //admin notifications $adminUser = new amuAdminObject(); $sendRegResults = $adminUser->amuAdminConfirmation($confirmationStack); $stackDisplay = $adminUser->amuShowStack($confirmationStack); //print notifications to screen echo $sendRegResults; echo '<div class="stackwrap">' . $stackDisplay . '</div>'; }
/** * Performs the load of the CSV file into the database */ function main() { $mysql; $opts = parseOpts(); $hostname = $opts['hostname']; $username = $opts['username']; $password = $opts['password'] != false ? $opts['password'] : ''; $database = $opts['database']; $filename = $opts['filename']; $mysql = fetch_db_connection($hostname, $username, $password, $database); $modules = parse_csv($filename); $queries = buildQueries($modules); $count = 0; foreach ($queries as $query) { $res = $mysql->query($query); if ($res) { $count++; } } echo "Inserted " . $count . " plugins in the database via CSV.\n"; }