function import($file, $dlc) { global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); createTable("npcitems"); foreach ($c as $t) { list($id, $item, $count, $condition) = explode("|", $t); $id = hexdec($id); $item = hexdec($item); if ($id == 0) { continue; } $prep = $db->prepare("insert into npcitems (baseID,item,count,condition,dlc) values (?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $item, $count, $condition, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } } }
function import($file, $dlc) { global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); createTable("npcs"); foreach ($c as $t) { list($id, $female, $race, $essential, $deathitem, $template, $flags) = explode("|", $t); $id = hexdec($id); $race = hexdec($race); $deathitem = hexdec($deathitem); $template = hexdec($template); $flags = hexdec($flags); if ($id == 0) { continue; } $prep = $db->prepare("insert into npcs (baseID,essential,female,race,template,flags,deathitem,dlc) values (?, ?, ?, ?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $essential, $female, $race, $template, $flags, $deathitem, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } } }
/** * @var \Zend\Db\Adapter\Driver\Pdo\Result $results * @var \Zend\Db\Adapter\Driver\StatementInterface $statement */ function renderResults(Result $results, StatementInterface $statement = null) { $headers = []; $queryInformation = null; $outputData = null; $resultContents = null; if ($statement) { $queryInformation = SqlFormatter::format($statement->getSql()); if ($statement->getParameterContainer()->count()) { $queryInformation .= createTable(array_keys($statement->getParameterContainer()->getNamedArray()), [array_values($statement->getParameterContainer()->getNamedArray())]); } } if ($results->count()) { foreach ($results as $result) { $headers = array_keys($result); $outputData[] = $result; } } // Results if ($outputData) { $resultContents = createTable([$headers], $outputData); } // Wrapper Table $table = new Table(new ConsoleOutput()); $table->setHeaders([['Query Results', 'Generated SQL']])->setRows([[$resultContents, $queryInformation]])->render(); }
function addCity() { $arr = $_POST; $city_get = getTemp($arr['city']); $city_info['city'] = $arr['city']; $city_info['pinyin'] = $city_get['pinyin']; $city_info['pubDate'] = $city_get['date']; $city_info['longitude'] = $city_get['longitude']; $city_info['latitude'] = $city_get['latitude']; $city_info['altitude'] = $city_get['altitude']; $city_info['pId'] = $arr['pId']; $city_info['totalCap'] = 0; $cName = $city_info['city']; $pinyin = $city_info['pinyin']; $str = "<?php" . "\r\n" . "require_once '../lib/mysql.func.php';\r\n" . "require_once '../lib/temp.func.php';\r\n" . "\r\n" . "mysql_connect(\"localhost:/tmp/mysql.sock\",\"root\",\"\");\r\n" . "mysql_set_charset(\"utf8\");\r\n" . "mysql_select_db(\"biogas\");\r\n" . "\r\n" . "\$res = getItem('" . $cName . "');\r\n" . "\$res_insert = array();\r\n" . "\$res_insert['date'] = \$res['date'];\r\n" . "\$res_insert['l_tmp'] = \$res['l_tmp'];\r\n" . "\$res_insert['h_tmp'] = \$res['h_tmp'];\r\n" . "insert(\$res['pinyin'].\"_tmp\", \$res_insert);"; $filename = '../tmp_update/' . $pinyin . '_update.php'; if (insert("biogas_city", $city_info)) { createTable($city_info['pinyin']); //(1) 创建城市温度表 file_put_contents($filename, $str); //(2) 创建温度更新脚本 chmod($filename, 0777); $mes = "添加成功!<br/><a href='addCity.php'>继续添加!</a>|<a href='listCity.php'>查看列表!</a>"; } else { $mes = "添加失败!<br/><a href='addCity.php'>重新添加!</a>|<a href='listCity.php'>查看列表!</a>"; } return $mes; }
function import($file, $dlc) { global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); createTable("interiors"); foreach ($c as $t) { list($id, $x1, $y1, $z1, $x2, $y2, $z2) = explode("|", $t); if ($id == 0) { continue; } $prep = $db->prepare("insert into interiors (baseID,x1,y1,z1,x2,y2,z2) values (?, ?, ?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $x1, $y1, $z1, $x2, $y2, $z2, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } } }
/** * Creates the basic token table for a survey * * @param mixed $iSurveyID * @param mixed $aAttributeFields * @return False if failed , else DB object */ function createTokenTable($iSurveyID, $aAttributeFields = array()) { Yii::app()->loadHelper('database'); $fields = array('tid' => 'pk', 'participant_id' => 'varchar(50)', 'firstname' => 'varchar(40)', 'lastname' => 'varchar(40)', 'email' => 'text', 'emailstatus' => 'text', 'token' => 'varchar(35)', 'language' => 'varchar(25)', 'blacklisted' => 'varchar(17)', 'sent' => "varchar(17) DEFAULT 'N'", 'remindersent' => "varchar(17) DEFAULT 'N'", 'remindercount' => 'integer DEFAULT 0', 'completed' => "varchar(17) DEFAULT 'N'", 'usesleft' => 'integer DEFAULT 1', 'validfrom' => 'datetime', 'validuntil' => 'datetime', 'mpid' => 'integer'); foreach ($aAttributeFields as $sAttributeField) { $fields[$sAttributeField] = 'string'; } try { $sTableName = "{{tokens_" . intval($iSurveyID) . "}}"; createTable($sTableName, $fields); try { Yii::app()->db->createCommand()->createIndex("idx_token_token_{$iSurveyID}_" . rand(1, 50000), "{{tokens_" . intval($iSurveyID) . "}}", 'token'); } catch (Exception $e) { } // create fields for the custom token attributes associated with this survey $tokenattributefieldnames = Survey::model()->findByPk($iSurveyID)->tokenAttributes; foreach ($tokenattributefieldnames as $attrname => $attrdetails) { Yii::app()->db->createCommand(Yii::app()->db->getSchema()->addColumn("{{tokens_" . intval($iSurveyID) . "}}", $attrname, 'VARCHAR(255)'))->execute(); } Yii::app()->db->schema->getTable($sTableName, true); // Refresh schema cache just in case the table existed in the past return true; } catch (Exception $e) { return false; } }
function import($file, $dlc) { global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); createTable("exteriors"); foreach ($c as $t) { list($name, $id, $x, $y, $wrld) = explode("|", $t); $id = hexdec($id); $wrld = hexdec($wrld); if ($id == 0) { continue; } $name = trim($name); $prep = $db->prepare("insert into exteriors (baseID,x,y,wrld,dlc) values (?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $x, $y, $wrld, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } } }
function import($file, $dlc) { $res = 0; global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); foreach ($c as $t) { list($tb, $id, $name, $description) = explode("|", $t); $id = hexdec($id); createTable($tb); $prep = $db->prepare("insert into {$tb} (baseID,name,description,dlc) values (?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $name, $description, $dlc)); if ($r) { $res++; } } return $res; }
function import($file, $dlc) { global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); createTable("races"); foreach ($c as $t) { list($id, $name, $child, $younger, $older) = explode("|", $t); $id = hexdec($id); $younger = hexdec($younger); $older = hexdec($older); if ($id == 0) { continue; } $prep = $db->prepare("insert into races (baseID,child,younger,older,dlc) values (?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $child, $younger, $older, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } } }
function import($file, $dlc) { $res = 0; global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); $tb = 'crefs'; createTable($tb); foreach ($c as $t) { list($empty, $eid, $ref, $base, $count, $health, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $lock, $key, $link) = explode("|", $t); $ref = hexdec($ref); $base = hexdec($base); $cell = hexdec($cell); $flags = hexdec($flags); if (!$ref) { continue; } $prep = $db->prepare("insert into {$tb} (editor,refID,baseID,cell,x,y,z,ax,ay,az,flags,dlc) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $db->errorInfo()[2]; continue; } $r = $prep->execute(array($eid, $ref, $base, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $dlc)); if ($r) { $res++; } } return $res; }
function arenaInstal() { $sql = "CREATE TABLE %tabname% (\n id mediumint(9) NOT NULL AUTO_INCREMENT,\n countUsers TINYINT NOT NULL,\n price float DEFAULT '1' NOT NULL,\n idUser bigint(20) NOT NULL,\n timeCreate DATETIME NOT NULL,\n won ENUM('A', 'B', 'W','?') NOT NULL, \n url VARCHAR(128) NOT NULL,\n UNIQUE KEY id (id)\n );"; /* W - wait check, ? - begining */ createTable($sql, ARENA_TABLE_ORDERS); $sql = "CREATE TABLE %tabname% (\n idUser bigint(20) NOT NULL,\n idOrder mediumint(9) NOT NULL,\n team ENUM('A', 'B') NOT NULL\n );"; createTable($sql, ARENA_TABLE_USER2ORDER); $sql = "CREATE TABLE %tabname% (\n id mediumint(9) NOT NULL AUTO_INCREMENT,\n idUser bigint(20) NOT NULL,\n timeCreate DATETIME NOT NULL,\n info text NOT NULL,\n UNIQUE KEY id (id)\n \n );"; createTable($sql, ARENA_TABLE_COMMENTS); $sql = "CREATE TABLE %tabname% (\n idComment mediumint(9) NOT NULL,\n idOrder mediumint(9) NOT NULL \n );"; createTable($sql, ARENA_TABLE_COMMENT2ORDER); }
/** * Creates the basic token table for a survey * * @param mixed $iSurveyID * @param mixed $aAttributeFields * @return False if failed , else DB object */ function createTokenTable($iSurveyID, $aAttributeFields = array()) { Yii::app()->loadHelper('database'); $fields = array('tid' => 'pk', 'participant_id' => 'varchar(50)', 'firstname' => 'varchar(40)', 'lastname' => 'varchar(40)', 'email' => 'text', 'emailstatus' => 'text', 'token' => 'varchar(35)', 'language' => 'varchar(25)', 'blacklisted' => 'varchar(17)', 'sent' => "varchar(17) DEFAULT 'N'", 'remindersent' => "varchar(17) DEFAULT 'N'", 'remindercount' => 'integer DEFAULT 0', 'completed' => "varchar(17) DEFAULT 'N'", 'usesleft' => 'integer DEFAULT 1', 'validfrom' => 'datetime', 'validuntil' => 'datetime', 'mpid' => 'integer'); foreach ($aAttributeFields as $sAttributeField) { $fields[$sAttributeField] = 'string'; } try { createTable("{{tokens_" . intval($iSurveyID) . "}}", $fields); return true; } catch (Exception $e) { return false; } }
function connectLTI() { //Check if the LTI table exists and if it doesn't created it now createTable('LTI'); //Make the LTI connection | the Secret | Store as Session | Redirect after success $context = new BLTI($GLOBALS['ltiSecret'], true, false); //Valid LTI connection if ($context->valid == true) { //Check if nonce exists within 90 minute timeline if (secureLTI($_REQUEST['oauth_nonce'], $_REQUEST['oauth_timestamp'])) { } } else { echo "Unable to make a valid LTI connection. Refresh and try again."; die; } //LTI connection made successfully and nonce is OK. Return the LTI object return $context; }
function fileToDatabase($txtfile, $tablename) { $file = fopen($txtfile, "r"); while (!feof($file)) { $line = fgets($file); $pieces = explode(",", $line); $date = $pieces[0]; $open = $pieces[1]; $high = $pieces[2]; $low = $pieces[3]; $close = $pieces[4]; $volume = $pieces[5]; // $adj_close = $pieces[6]; $change = $close - $open; $percent_change = $change / $open * 100; createTable($tablename); $sql = "SELECT * FROM {$tablename}"; require '../includes/connect.php'; $result = mysqli_query($connect, $sql); //creates table if one doesnt exist if (!$result) { $sql3 = "INSERT INTO {$tablename} (date, open, high, low, close, volume, amount_change, percent_change)\n VALUES ('{$date}','{$open}','{$high}','{$low}','{$close}','{$volume}','{$change}','{$percent_change}')"; $result3 = mysqli_query($connect, $sql3); ini_set('max_execution_time', 60); //300 seconds = 5 minutes if ($result3) { } else { echo '<br />' . "error with the database " . mysqli_error($connect); return false; } } elseif ($result) { $sql3 = "INSERT IGNORE INTO {$tablename} (date, open, high, low, close, volume, amount_change, percent_change)\n VALUES ('{$date}','{$open}','{$high}','{$low}','{$close}','{$volume}','{$change}','{$percent_change}')"; $result3 = mysqli_query($connect, $sql3); ini_set('max_execution_time', 60); //300 seconds = 5 minutes if ($result3) { } else { echo '<br />' . "error with the database " . mysqli_error($connect); return false; } } } fclose($file); }
function createOutput($records, $sql, $description) { //Report Number and Name echo "<h3>" . $description . "</h3>"; echo "SQL Statement:"; echo "<p class='sqlStatement'> " . formatSQL($sql) . "</p>"; echo "<br>"; //Get Size of Data Array //get row count $row = sizeof($records); //get column count /*Count Recursive counts all elements in the array, But every row in the array has a title and data row thats why you have to divide with 2 and then divide with the amount of array rows*/ $column = (count($records, COUNT_RECURSIVE) - $row) / 2 / $row; //Get Titles $titles = getTitles($records); //Create Table createTable($records, $row, $column, $titles); }
function showTable($datas, $editable) { $output = ""; $openTable = "<div id=\"myTable\" >"; //border=1 $closeTable = "</div>"; $openRow = "<div class='item'>"; $closeRow = "</div>"; $output .= $openTable; $venues = $datas['venues']; $categories = $datas['categories']; $events = $datas['events']; // for each item, create the table and store in variable foreach ($events as $event) { $output .= $openRow . createTable($event, $venues, $categories, $editable) . $closeRow . "\n"; } $output .= $closeTable; return $output; }
function import($file, $dlc) { global $db; $f = file_get_contents($file); if ($f === FALSE) { die("Error loading {$file}"); } $c = explode("\n", $f); createTable("weapons"); createItems("items"); foreach ($c as $t) { list($id, $value, $hp, $weight, $dmg, $reload, $rate, $automatic, $slot, $ammo) = explode("|", $t); $id = hexdec($id); $slot = hexdec($slot); $automatic = hexdec($automatic); $ammo = hexdec($ammo); if ($id == 0) { continue; } $prep = $db->prepare("insert into weapons (baseID,damage,reload,rate,automatic,ammo,dlc) values (?, ?, ?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $dmg, $reload, $rate, $automatic, $ammo, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } $prep = $db->prepare("insert into items (baseID,value,health, weight, slot, dlc) values (?, ?, ?, ?, ?, ?)"); if ($prep === FALSE) { echo "Fail: " . $id; continue; } $r = $prep->execute(array($id, $value, $hp, $weight, $slot, $dlc)); if (!$r) { $arr = $prep->errorInfo(); echo $arr[2]; } } }
function mongo2mysql($db, $colname, $year, $month) { $col = new MongoCollection($db, $colname); // mysql $conn = new mysqli("p:localhost", "trend", "only!trend!", "trend"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $cursor = $col->find()->timeout(-1); $idx = 0; foreach ($cursor as $doc) { if ($idx++ === 0) { $table = createTable($conn, $colname, $doc); echo $table; } //insrt DB insert($conn, $colname, $doc); echo " {$idx} \n"; } $conn->close(); }
function a3n_cricmgt_activation() { require_once ABSPATH . '/wp-admin/includes/upgrade.php'; global $wpdb; $db_table_fixture = $wpdb->prefix . 'a3n_fixture'; $attr_fixture = "CREATE TABLE " . $db_table_fixture . " (" . " id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, " . " TeamA int(10) , " . " TeamB int(10) , " . " _group varchar(5), " . " matchdate datetime NOT NULL, " . " tournamentId int, " . " PRIMARY KEY ( id ) ) "; createTable($db_table_fixture, $attr_fixture, $wpdb); $db_table_match_summary = $wpdb->prefix . 'a3n_match_summary'; $attr_match_summary = "CREATE TABLE " . $db_table_match_summary . " (" . " id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT," . " fixtureId int NOT NULL," . " TeamA_score varchar(20)," . " TeamA_wicket varchar(20)," . " TeamA_over varchar(20), " . " TeamB_score varchar(20)," . " TeamB_wicket varchar(20)," . " TeamB_over varchar(100) NOT NULL," . " result varchar(500)," . " mom varchar(100)," . " PRIMARY KEY ( id ) ) "; createTable($db_table_match_summary, $attr_match_summary, $wpdb); $db_table_point_table = $wpdb->prefix . 'a3n_point_table'; $attr_point_table = "CREATE TABLE " . $db_table_point_table . " (" . " id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, " . " tournamentID int (5)," . " position int (2)," . " _group varchar(5)," . " team int (3)," . " match_played int(2)," . " win int(2)," . " loss int(2)," . " tie_NR int(2)," . " runs_for varchar(5)," . " overs_for varchar(5)," . " runs_against varchar(5)," . " overs_against varchar(5)," . " nrr int(10)," . " point FLOAT," . " PRIMARY KEY (id) ) "; createTable($db_table_point_table, $attr_point_table, $wpdb); $db_table_team = $wpdb->prefix . 'a3n_team'; $attr_team = "CREATE TABLE " . $db_table_team . " (" . " id int(2) UNSIGNED NOT NULL AUTO_INCREMENT, " . " team varchar(50)," . " PRIMARY KEY (id) ) "; createTable($db_table_team, $attr_team, $wpdb); $db_table_tournament = $wpdb->prefix . 'a3n_tournament'; $attr_tournament = "CREATE TABLE " . $db_table_tournament . " (" . " id int(5) UNSIGNED NOT NULL AUTO_INCREMENT, " . " tournament varchar(50), " . " format varchar(10), " . " season varchar(5), " . " PRIMARY KEY (id) ) "; createTable($db_table_tournament, $attr_tournament, $wpdb); //$db_table_batting_details = $wpdb->prefix . 'batting_details'; //NOT IMPLEMENTED IN THE VERSION 1 //$db_table_bowling_details = $wpdb->prefix . 'bowling_details'; //NOT IMPLEMENTED IN THE VERSION 1 //$db_table_players = $wpdb->prefix . 'players';//NOT IMPLEMENTED IN THE VERSION 1 }
} </style> </head> <body> <?php $counter = 0; print '<div class="parent_div">'; $date = new DateTime(); $date->setTimezone(new DateTimeZone('America/New_York')); while ($counter < 5) { print '<div id="a' . $counter . '" class="date">'; $month = (int) $date->format('m'); $day = (int) $date->format('d'); $day_of_week = $date->format('l'); print '<span>' . $month . '/' . $day . ' ' . $day_of_week . '</span>'; createTable($date); $date->modify('+1 day'); print '</div>'; $counter++; } print '</div>'; function createTable($current_date) { print '<table cellspacing="0" class="food_table">'; $ur = new Database(); $ur->db_connect(); $dateformat = $current_date->format('Y-m-d'); $query = "SELECT * FROM free_food_events WHERE '{$dateformat}' = date(event_when) ORDER BY event_when;"; $result = $ur->do_query($query); $counter = 0; while ($row = mysqli_fetch_array($result)) {
function formStart($additional = '') { global $form_action, $page, $p; # depending on server software we can post to the directory, or need to pass on the page if ($form_action) { $html = sprintf('<form method="post" action="%s" %s>', $form_action, $additional); # retain all get variables as hidden ones foreach (array('p', 'page') as $key) { $val = $_REQUEST[$key]; if ($val) { $html .= sprintf('<input type="hidden" name="%s" value="%s" />', $key, htmlspecialchars($val)); } } } else { $html = sprintf('<form method="post" action="" %s>', $additional); } if (!empty($_SESSION['logindetails']['id'])) { ## create the token table, if necessary if (!Sql_Check_For_Table('admintoken')) { createTable('admintoken'); } $key = md5(time() . mt_rand(0, 10000)); Sql_Query(sprintf('insert into %s (adminid,value,entered,expires) values(%d,"%s",%d,date_add(now(),interval 1 hour))', $GLOBALS['tables']['admintoken'], $_SESSION['logindetails']['id'], $key, time()), 1); $html .= sprintf('<input type="hidden" name="formtoken" value="%s" />', $key); ## keep the token table empty Sql_Query(sprintf('delete from %s where expires < now()', $GLOBALS['tables']['admintoken']), 1); } return $html; }
// echo createTable( $semesterArray, $templateTools, $campusTeamMinArray, false, $campusTeamLink, true, true ); ?> <br/> */ ?> </td> </tr> <tr> <td valign="top"> <span class="text"><?php echo $templateTools->getPageLabel('[SemesterStats]'); ?> </span></br> <?php echo createTable($semesterArray, $templateTools, $semesterStatsArray, true, $semStatsLink, false); ?> <br/> </td> </tr> </table> <?php function createTable($semesterArray, $templateTools, $statsArray, $lookupCategoryLabel = true, $drillDownLink = "#", $includeTotal = true, $includeColunmTotal = false) { $columnTotal = array(); $tableString = "<table>"; $tableString .= "<tr>"; $tableString .= "<td class=\"smalltext\"> </td>"; foreach ($semesterArray as $semesterID => $semDesc) {
$data = array('user' => array(array('login' => 'user1', 'customerId' => 10, 'firstName' => 'John', 'lastName' => 'Doe', 'password' => $db->func('SHA1(?)', array("secretpassword+salt")), 'expires' => $db->now('+1Y'), 'loginCount' => $db->inc()), array('login' => 'user2', 'customerId' => 10, 'firstName' => 'Mike', 'lastName' => NULL, 'password' => $db->func('SHA1(?)', array("secretpassword2+salt")), 'expires' => $db->now('+1Y'), 'loginCount' => $db->inc(2)), array('login' => 'user3', 'active' => true, 'customerId' => 11, 'firstName' => 'Pete', 'lastName' => 'D', 'password' => $db->func('SHA1(?)', array("secretpassword2+salt")), 'expires' => $db->now('+1Y'), 'loginCount' => $db->inc(3))), 'product' => array(array('customerId' => 1, 'userId' => 1, 'productName' => 'product1'), array('customerId' => 1, 'userId' => 1, 'productName' => 'product2'), array('customerId' => 1, 'userId' => 1, 'productName' => 'product3'), array('customerId' => 1, 'userId' => 2, 'productName' => 'product4'), array('customerId' => 1, 'userId' => 2, 'productName' => 'product5'))); function createTable($name, $data) { global $db; //$q = "CREATE TABLE $name (id INT(9) UNSIGNED PRIMARY KEY NOT NULL"; $q = "CREATE TABLE {$name} (id INT(9) UNSIGNED PRIMARY KEY AUTO_INCREMENT"; foreach ($data as $k => $v) { $q .= ", {$k} {$v}"; } $q .= ")"; $db->rawQuery($q); } // rawQuery test foreach ($tables as $name => $fields) { $db->rawQuery("DROP TABLE " . $name); createTable($name, $fields); } foreach ($data as $name => $datas) { foreach ($data[$name] as $userData) { $obj = new $name($userData); $id = $obj->save(); if ($obj->errors) { echo "errors:"; print_r($obj->errors); exit; } } } $products = product::ArrayBuilder()->get(2); foreach ($products as $p) { if (!is_array($p)) {
} else { header_html(); if ($action == "listDBs") { listDatabases(); } else { if ($action == "createDB") { createDatabase(); } else { if ($action == "dropDB") { dropDatabase(); } else { if ($action == "listTables") { listTables(); } else { if ($action == "createTable") { createTable(); } else { if ($action == "dropTable") { dropTable(); } else { if ($action == "viewSchema") { viewSchema(); } else { if ($action == "query") { viewData($queryStr); } else { if ($action == "addField") { manageField("add"); } else { if ($action == "addField_submit") { manageField_submit("add");
edit_db_info_file("dbname", 1, $dbname); edit_db_info_file("dbuser", 2, $dbuser); edit_db_info_file("dbpass", 3, $dbpassword); edit_db_info_file("dbtable", 4, $dbtable); /** END ENCRYPTION **/ //Replacing the value $NameofActivity->nodeValue = $_POST['name_of_activity']; /*$DatabaseName->nodeValue = $_POST['database_name']; $DatabaseUser->nodeValue = $_POST['database_user']; $DatabasePassword->nodeValue = $_POST['database_password']; $DatabaseTable->nodeValue = $_POST['database_table'];*/ $Domain->nodeValue = str_replace("thfl-admin/dashboard.php", "", $_SERVER['HTTP_REFERER']); $EmailDomain->nodeValue = $_POST['email_domain']; $Location->nodeValue = $_POST['location']; $xml->save("../config.xml") or die("Couldn't save"); $result = createTable($_POST['database_table']); echo "Database Configuration Updated"; } elseif (isset($_POST['activity'])) { $xml = new DOMDocument('1.0', 'utf-8'); $xml->formatOutput = true; $xml->preserveWhiteSpace = false; $check = $xml->load('../config.xml'); if ($check === FALSE) { $xml->load('../../../thfl-admin/config.xml') or die("Couldn't find XML file even after 1 FALSE"); } //Get item Element $element = $xml->getElementsByTagName('Configuration')->item(0) or die("Couldn't find Configuration node for activity"); //Load child elements $NameofActivity = $element->getElementsByTagName('Activity')->item(0) or die("Couldn't load Activity"); //Replacing the value $NameofActivity->nodeValue = trim($_POST['activity']);
function importIntoMySQL($options) { $username = $options["u"]; $password = $options["p"]; $host = $options["h"]; $dbname = $options["d"]; //database connection details $conn = new mysqli($host, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $val = "select 1 from `Users` LIMIT 1"; if ($conn->query($val) === FALSE) { echo 'Table Users does not existed' . PHP_EOL; createTable($options); } $csv_file = $options["file"]; if (($handle = fopen($csv_file, "r")) !== FALSE) { fgetcsv($handle); while (($data = fgetcsv($handle, ",")) !== FALSE) { $num = count($data); for ($c = 0; $c < $num; $c++) { $col[$c] = $data[$c]; } $name = mysqli_real_escape_string($conn, ucfirst($col[0])); $surname = mysqli_real_escape_string($conn, ucfirst($col[1])); $email = strtolower(trim($col[2])); $status = emailValidate($email); if (!$status) { echo $name . " " . $surname . " "; echo "This ({$email}) email address is not valid." . PHP_EOL; } else { $sql = "INSERT INTO `Users`( `name`, `surname`, `email`) VALUES ('" . $name . "','" . $surname . "','" . mysqli_real_escape_string($conn, $email) . "') "; if ($conn->query($sql) === TRUE) { echo "New record created successfully" . PHP_EOL; } else { echo "Error: " . $sql . "<br>" . $conn->error . PHP_EOL; } } } fclose($handle); } $conn->close(); }
$htmlPdfReport->set('</table>'); //Hosts if (count($param['hosts']) > 0) { $htmlPdfReport->set('<table class="tableTitle w100" style="margin-top:5px;"><tr><td class="w100">' . _('Hosts') . '</td></tr></table>'); $htmlPdfReport->set('<table class="w100">'); foreach ($param['hosts'] as $host_id => $host_data) { $host_ip = $host_data[2]; $data['asset'] = $host_ip; $data['date'] = ' - '; $filter = "AND id = '{$host_id}'"; $query_temp['dayAttackHost'] = $pdf->MetricsNoPDF('day', 'attack', 'host', $filter, $dates_filter['max_a_date']); $data['data'] = $query_temp['dayAttackHost']; createTable($data, &$htmlPdfReport); } $htmlPdfReport->set('</table>'); } //Nets if (count($param['nets']) > 0) { $htmlPdfReport->set('<table class="tableTitle w100" style="margin-top:5px;"><tr><td class="w100">' . _('Nets') . '</td></tr></table>'); $htmlPdfReport->set('<table class="w100">'); foreach ($param['nets'] as $net_id => $net_data) { $data['asset'] = $net_data['ips']; $data['date'] = ' - '; $filter = "AND id='{$net_id}'"; $query_temp['dayAttackNet'] = $pdf->MetricsNoPDF('day', 'attack', 'net', $filter, $dates_filter['max_a_date']); $data['data'] = $query_temp['dayAttackNet']; createTable($data, &$htmlPdfReport); } $htmlPdfReport->set('</table>'); } }
//Try to make the connection. if ($conn->connect_error) { //If it doesn't work, spit out the error and kill the program. die("\n[ERROR]: Connection failed: " . $conn->connect_error); } else { fwrite(STDOUT, "\nConnection successful\n"); } } else { fwrite(STDOUT, "\n[ERROR]: To make a connection, the user(-u), the password(-p) and the host(-h) need to be supplied"); } } //Now the appropriate functions will be called. //Create a Table. if ($cTable && $conn != "" && !$dryrun) { //If we have a connection, and we need to create a table... createTable($conn); //Create the table. } else { if ($cTable && $conn == "" && $dryrun) { //If we're on a dry run we cannot make a table. fwrite(STDOUT, "\n[ERROR]: Cannot alter the Database on a dry run (--dry_run)"); } } //Read in and insert into DB. if ($fileName != "" && !$cTable && $conn != "" && !$dryrun) { readFromFile($conn, $fileName, $dryrun); } //Read in and display details. if ($dryrun && !$cTable && $conn == "") { if ($fileName != "") { readFromFile($conn, $fileName, $dryrun);
<?php require 'config.php'; function createTable($dbname, $host, $name, $pw) { $sql = array("fmdb_user" => "CREATE TABLE IF NOT EXISTS `fmdb_user`( \n\t\t\t`id` int not null auto_increment,\n\t\t\t`uid` text not null,\n\t\t\t`name` text not null,\n \t\t`password` text not null,\n \t\t`starCount` int not null,\n \t\t`downloadCount` int not null,\n \t\t`privilege` int not null,\n \t\t`group` int not null,\n \t\t`userpath` text not null,\n \t\t`lastLoginTime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \n\t\t\tprimary key(`id`))default charset=utf8;", "fmdb_file" => "CREATE TABLE IF NOT EXISTS `fmdb_file`(\n\t\t\t`id` int not null auto_increment,\n\t\t\t`fid` text not null,\n\t\t\t`uid` text not null,\n\t\t\t`path` text not null,\n\t\t\t`fileExt` text not null,\n\t\t\t`tags` text not null,\n\t\t\t`isStard` int not null,\n\t\t\t`isDeleted` int not null,\n\t\t\t`downloadCount` int not null,\n\t\t\t`isDisplayed` int not null,\n\t\t\t`title` varchar(255) not null,\n\t\t\t`author` varchar(255) not null,\n\t\t\t`description` varchar(255) not null,\n\t\t\t`group` text not null,\n\t\t\t`createTime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n\t\t\tprimary key(`id`))default charset=utf8;", "fmdb_download" => "CREATE TABLE IF NOT EXISTS `fmdb_download`(\n\t\t\t`id` int not null auto_increment,\n\t\t\t`donid` text not null,\n\t\t\t`fid` text not null,\n\t\t\t`uid` text not null,\n\t\t\t`downloadTime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n\t\t\tprimary key(`id`))default charset=utf8;", "fmdb_stars" => "CREATE TABLE IF NOT EXISTS `fmdb_stars`( \n\t\t\t`id` int not null auto_increment, \n\t\t\t`stid` text not null,\n\t\t\t`uid` text not null,\n\t\t\t`fid` text not null,\n\t\t\tprimary key(`id`))default charset=utf8;", "fmdb_comments" => "CREATE TABLE IF NOT EXISTS `fmdb_comments`(\n\t\t\t`id` int not null auto_increment,\n\t\t\t`coid` text not null,\n\t\t\t`fid` text not null,\n\t\t\t`uid` text not null,\n\t\t\t`content` text not null,\n\t\t\t`commentTime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n\t\t\tprimary key(`id`))default charset=utf8;", "fmdb_workpoints" => "CREATE TABLE IF NOT EXISTS `fmdb_workpoints`(\n\t\t\t`id` int not null auto_increment,\n\t\t\t`wpid` text not null,\n\t\t\t`uid` text not null,\n\t\t\t`fid` text not null,\n\t\t\t`grade` int not null,\n\t\t\tprimary key(`id`))default charset=utf8;", "fmdb_group" => "CREATE TABLE IF NOT EXISTS `fmdb_group`(\n\t\t\t`id` int not null auto_increment,\n\t\t\t`gpid` text not null,\n\t\t\t`groupname` text not null,\n\t\t\t`parent` text not null,\n\t\t\tprimary key(`id`))default charset=utf8;"); $pdo = new PDO("mysql:dbname={$dbname};host={$host}", $name, $pw); foreach ($sql as $key => $sqlStatement) { $res = $pdo->exec($sqlStatement); if (!$res) { print_r($pdo->errorInfo()); } } } createTable($dbname, $host, $user, $password);
} } $total['p_h'] = "\$ " . number_format($p_h, 2); $tot = floatval($tot + $p_h); $total['subTotal'] = "\$ " . number_format($total['subTotal'], 2); $total['total'] = "\$ " . number_format($tot, 2); $total['gst'] = "\$ " . number_format(floatval($_POST['gst']), 2); /*//check if payment complete if ($_POST['paid']=='no') $payment['payment'] = $paidby.' (DEBT)'; else $payment['payment'] = $paidby.' (PAID)';*/ $payment['payment'] = $paidby; $payment['tendered'] = $totpartial; $payment['debtbal'] = $paybalam; $pdf->SetXY(10, 75); createTable($pdf, $data, $disc, $total, $payment, $paybaltx); $x = 10; $y = $pdf->GetY() - 5.3 * 8; $pdf->SetXY($x, $y); $pdf->SetFont('Arial', '', 10); $pdf->Cell(90, 5.3, $cRow['company_banking'], 0, 2); $pdf->Cell(90, 5.3, 'Accept: ' . $cRow['company_payment'], 0, 2); $pdf->Cell(90, 5.3, isset($adnote) && trim($adnote) != "" ? "MultiPay: {$adnote}" : "", 0, 2); //add notes / payment info $notelist = array(); if (isset($_POST["notes"]) && trim($_POST["notes"]) != "") { //$pdf->Cell(125, 5.3, 'Notes:', 'TLR', 2); //$pdf->SetLeftMargin(15); //$pdf->SetRightMargin(75); //$pdf->SetFont('Arial', 'I', 10); //$pdf->write(3, (isset($adnote)&&trim($adnote)!=""? str_replace("\n",", ",$_POST["notes"]):$_POST["notes"]));