public function generate($folder, $name = null) { $sqlite = new \Sqlite3($folder . '/dump.sqlite'); $sqlQuery = 'SELECT * FROM results WHERE analyzer in ' . $this->themesList; $res = $sqlite->query($sqlQuery); $results = array(); $titleCache = array(); $severityCache = array(); $results = array(); while ($row = $res->fetchArray(SQLITE3_ASSOC)) { if (!isset($titleCache[$row['analyzer']])) { $analyzer = Analyzer::getInstance($row['analyzer']); $titleCache[$row['analyzer']] = $analyzer->getDescription()->getName(); $severityCache[$row['analyzer']] = $analyzer->getSeverity(); $clearphp = $analyzer->getDescription()->getClearPHP(); } else { $clearphp = ''; } $message = array('code' => $row['fullcode'], 'line' => $row['line'], 'clearphp' => $clearphp); if (!isset($results[$titleCache[$row['analyzer']]])) { $results[$titleCache[$row['analyzer']]] = array(); } $results[$titleCache[$row['analyzer']]][] = $message; $this->count(); } if ($name === null) { return json_encode($results); } else { file_put_contents($folder . '/' . $name . '.' . self::FILE_EXTENSION, json_encode($results)); return true; } }
public function generate($folder, $name = null) { $list = Analyzer::getThemeAnalyzers($this->themesToShow); $list = '"' . join('", "', $list) . '"'; $sqlite = new \Sqlite3($folder . '/dump.sqlite'); $sqlQuery = 'SELECT * FROM results WHERE analyzer in (' . $list . ')'; $res = $sqlite->query($sqlQuery); $results = array(); $titleCache = array(); $severityCache = array(); while ($row = $res->fetchArray(SQLITE3_ASSOC)) { if (!isset($results[$row['file']])) { $file = array('errors' => 0, 'warnings' => 0, 'fixable' => 0, 'filename' => $row['file'], 'messages' => array()); $results[$row['file']] = $file; } if (!isset($titleCache[$row['analyzer']])) { $analyzer = Analyzer::getInstance($row['analyzer']); $titleCache[$row['analyzer']] = $analyzer->getDescription()->getName(); $severityCache[$row['analyzer']] = $analyzer->getSeverity(); } $message = array('type' => 'warning', 'source' => $row['analyzer'], 'severity' => $severityCache[$row['analyzer']], 'fixable' => 'fixable', 'message' => $titleCache[$row['analyzer']]); if (!isset($results[$row['file']]['messages'][$row['line']])) { $results[$row['file']]['messages'][$row['line']] = array(0 => array()); } $results[$row['file']]['messages'][$row['line']][0][] = $message; ++$results[$row['file']]['warnings']; $this->count(); } if ($name === null) { return json_encode($results); } else { file_put_contents($folder . '/' . $name . '.' . self::FILE_EXTENSION, json_encode($results)); return true; } }
public function db() : Sqlite3 { if (!$this->db) { $db = new Sqlite3($this->dbPath, SQLITE3_OPEN_READWRITE); $openErr = $db->lastErrorCode(); if ($openErr) { throw new Exception($db->lastErrorMsg()); } $db->enableExceptions(true); $this->db = $db; } return $this->db; }
/** * Run the database seeds. * * @return void */ public function run() { $database = new Sqlite3(database_path('database.sqlite.seed')); $table_users = 'SELECT name, email, password, provider_name, provider_id, remember_token, created_at, updated_at FROM users'; $results = $database->query($table_users); while ($row = $results->fetchArray(PDO::FETCH_OBJ)) { DB::table('users')->insert($row); } $table_categories = 'SELECT category_id, name, slug, created_at, updated_at FROM categories'; $results = $database->query($table_categories); while ($row = $results->fetchArray(PDO::FETCH_OBJ)) { DB::table('categories')->insert($row); } $table_articles = 'SELECT user_id, category_id, title, slug, content, created_at, updated_at, published_at, deleted_at FROM articles'; $results = $database->query($table_articles); while ($row = $results->fetchArray(PDO::FETCH_OBJ)) { DB::table('articles')->insert($row); } $table_topics = 'SELECT name, slug, created_at, updated_at FROM topics'; $results = $database->query($table_topics); while ($row = $results->fetchArray(PDO::FETCH_OBJ)) { DB::table('topics')->insert($row); } $table_article_topic = 'SELECT article_id, topic_id FROM article_topic'; $results = $database->query($table_article_topic); while ($row = $results->fetchArray(PDO::FETCH_OBJ)) { DB::table('article_topic')->insert($row); } $table_comments = 'SELECT user_id, article_id, comment_id, content, created_at, updated_at, deleted_at FROM comments'; $results = $database->query($table_comments); while ($row = $results->fetchArray(PDO::FETCH_OBJ)) { DB::table('comments')->insert($row); } }
public function __invoke() { $root = __DIR__ . '/..'; $db = new Sqlite3($root . '/db/data.sqlite3', SQLITE3_OPEN_READWRITE); $openErr = $db->lastErrorCode(); if ($openErr) { throw new Exception($db->lastErrorMsg()); } $db->enableExceptions(true); $stmt = $db->prepare(self::QUERY_SOLDIERS_LIST); $result = $stmt->execute(); /** * @var $soldierList Soldier[] */ $soldierList = []; while ($record = $result->fetchArray(SQLITE3_ASSOC)) { $soldierIdentity = new SoldierIdentity($record['firstName'], $record['lastName'], $record['nickName'], $record['nationality']); $soliderServiceRecord = new SoldierServiceRecord($record['status'], $record['rank'], $record['specialization'], $record['numMissions'], $record['numKills'], $record['hp'], $record['will'], $record['defence'], $record['aim']); $soldierList[] = new Soldier($soldierIdentity, $soliderServiceRecord); } $this->response->setBody((new TemplateFactory([$root . '/tpl']))->loadTemplate('home.twig')->render(['soldierList' => $soldierList])); }
public function run() { if (!file_exists($this->config->projects_root . '/projects/' . $this->config->project)) { throw new NoSuchProject($this->config->project); } $res = $this->gremlin->query('g.V().hasLabel("Project").values("fullcode")'); if ($res->results[0] !== $this->config->project) { throw new NotProjectInGraph($this->config->project, $res->results[0]); } // move this to .dump.sqlite then rename at the end, or any imtermediate time // Mention that some are not yet arrived in the snitch $this->sqliteFile = $this->config->projects_root . '/projects/' . $this->config->project . '/.dump.sqlite'; $this->sqliteFileFinal = $this->config->projects_root . '/projects/' . $this->config->project . '/dump.sqlite'; if (file_exists($this->sqliteFile)) { unlink($this->sqliteFile); display('Removing old .dump.sqlite'); } $this->addSnitch(); Analyzer::initDocs(); Analyzer::$gremlinStatic = $this->gremlin; if ($this->config->update === true) { copy($this->sqliteFileFinal, $this->sqliteFile); $sqlite = new \Sqlite3($this->sqliteFile); } else { $sqlite = new \Sqlite3($this->sqliteFile); $this->getAtomCounts($sqlite); $this->collectStructures($sqlite); $sqlite->query('CREATE TABLE themas ( id INTEGER PRIMARY KEY AUTOINCREMENT, thema STRING )'); $sqlite->query('CREATE TABLE results ( id INTEGER PRIMARY KEY AUTOINCREMENT, fullcode STRING, file STRING, line INTEGER, namespace STRING, class STRING, function STRING, analyzer STRING, severity STRING )'); $sqlite->query('CREATE TABLE resultsCounts ( id INTEGER PRIMARY KEY AUTOINCREMENT, analyzer STRING, count INTEGER DEFAULT -6)'); display('Inited tables'); } $sqlQuery = <<<SQL DELETE FROM results WHERE analyzer = :analyzer SQL; $this->cleanResults = $sqlite->prepare($sqlQuery); $sqlQuery = <<<SQL REPLACE INTO results ("id", "fullcode", "file", "line", "namespace", "class", "function", "analyzer", "severity") VALUES ( NULL, :fullcode, :file, :line, :namespace, :class, :function, :analyzer, :severity ) SQL; $this->stmtResults = $sqlite->prepare($sqlQuery); $sqlQuery = <<<SQL REPLACE INTO resultsCounts ("id", "analyzer", "count") VALUES (NULL, :class, :count ) SQL; $this->stmtResultsCounts = $sqlite->prepare($sqlQuery); $themes = array(); if ($this->config->thema !== null) { $thema = $this->config->thema; $themes = Analyzer::getThemeAnalyzers($thema); if (empty($themes)) { $r = Analyzer::getSuggestionThema($thema); if (count($r) > 0) { echo 'did you mean : ', implode(', ', str_replace('_', '/', $r)), "\n"; } throw new NoSuchThema($thema); } display('Processing thema : ' . $thema); } elseif ($this->config->program !== null) { $analyzer = $this->config->program; if (!Analyzer::getClass($analyzer)) { $r = Analyzer::getSuggestionClass($analyzer); if (count($r) > 0) { echo 'did you mean : ', implode(', ', str_replace('_', '/', $r)), "\n"; } throw new NoSuchAnalyzer($analyzer); } $themes = array($analyzer); display('Processing one analyzer : ' . $analyzer); } else { display('No analysis dump requested (-T <thema> | -P <Analyzer>)'); $this->finish(); return; } /* $res = $sqlite->query('SELECT COUNT(*) FROM themas WHERE thema="'.$thema.'"'); $count = $res->fetchArray(\SQLITE3_NUM); if ($count === 1) { display("$thema was already run\n"); } else { display("$thema was not already run\n"); } die(); print_r($themes); */ $sqlitePath = $this->config->projects_root . '/projects/' . $this->config->project . '/datastore.sqlite'; $counts = array(); $datastore = new \Sqlite3($sqlitePath, \SQLITE3_OPEN_READONLY); $datastore->busyTimeout(5000); $res = $datastore->query('SELECT * FROM analyzed'); while ($row = $res->fetchArray(\SQLITE3_ASSOC)) { $counts[$row['analyzer']] = $row['counts']; } $this->log->log('count analyzed : ' . count($counts) . "\n"); $this->log->log('counts ' . implode(', ', $counts) . "\n"); $datastore->close(); unset($datastore); foreach ($themes as $id => $thema) { if (isset($counts[$thema])) { display($thema . ' : ' . ($counts[$thema] >= 0 ? 'Yes' : 'N/A') . "\n"); $this->processResults($thema, $counts[$thema]); unset($themes[$id]); } else { display($thema . " : No\n"); } } $this->log->log('Still ' . count($themes) . " to be processed\n"); display('Still ' . count($themes) . " to be processed\n"); if (count($themes) === 0) { if ($this->config->thema !== null) { $sqlite->query('INSERT INTO themas ("id", "thema") VALUES ( NULL, "' . $this->config->thema . '")'); } } $this->finish(); }
/** * When was queue last accessed? * @return int timestamp */ function getLastAccess() { $lastAccess = (int) $this->getQueuesModel()->getConnection()->querySingle("\n SELECT created\n\t\t\tFROM files\n\t\t\tWHERE queueID = '" . Sqlite3::escapeString($this->getQueueID()) . "'\n\t\t\tORDER BY created DESC\n "); return $lastAccess; }
/** * @return void */ public function rollback() { $this->dbConnection->query("ROLLBACK"); return; }
<?php $db = new Sqlite3('messages'); $sql = <<<EOF CREATE TABLE COMPANY (ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, EMAIL INT NOT NULL, SUBJECT TEXT NOT NULL, MSGBODY TEXT \t\tNOT NULL); EOF; $stmt = $db->exec($sql); if (!$stmt) { echo $db->lastErrorMsg(); } else { echo "created successfully"; } $db->close();
public function deleteRow($table, $data) { if (empty($data)) { return true; } $this->checkTable($table); $first = current($data); if (is_array($first)) { $cols = array_keys($first); } else { $query = "PRAGMA table_info({$table})"; $res = self::$sqliteRead->query($query); $cols = array(); while ($row = $res->fetchArray()) { if ($row['name'] == 'id') { continue; } $cols[] = $row['name']; } } foreach ($data as $col => $row) { if (is_array($row)) { $d = array_values($row); foreach ($d as &$e) { $e = \Sqlite3::escapeString($e); } unset($e); } else { $d = array($row); } $query = 'DELETE FROM ' . $table . ' WHERE ' . $col . " IN ('" . implode("', '", $d) . "')"; self::$sqliteWrite->querySingle($query); } return true; }
function project($path) { if (isset($_REQUEST['project'])) { // Validation if (!file_exists('./projects/' . $_REQUEST['project'])) { echo json_encode(['project' => $_REQUEST['project'], 'progress' => 0, 'status' => 'Not found']); // empty array exit; } elseif (!file_exists('./projects/' . $_REQUEST['project'] . '/datastore.sqlite')) { echo json_encode(['project' => $_REQUEST['project'], 'progress' => 0, 'status' => 'Initialization']); exit; } else { $return = array('project' => $_REQUEST['project']); $sqlite = new \Sqlite3('./projects/' . $_REQUEST['project'] . '/datastore.sqlite'); $res = $sqlite->query('SELECT value FROM hash WHERE key="tokens"'); $row = $res->fetchArray(); $return['size'] = $row[0]; if (file_exists('./projects/' . $_REQUEST['project'] . '/report')) { $return['report'] = true; if (!file_exists('./projects/' . escapeshellarg($_REQUEST['project']) . '/report')) { shell_exec('cd ./projects/' . escapeshellarg($_REQUEST['project']) . '; zip -r report.zip report > /dev/null 2>/dev/null &'); $return['zip'] = false; $return['status'] = 'Archiving'; } else { $return['zip'] = true; // Not status anymore } } else { $return['status'] = 'Running'; } echo json_encode($return); } } elseif (isset($_REQUEST['vcs'])) { $project = 'a' . substr(md5($_REQUEST['vcs']), 0, 8); if (file_exists('./projects/' . $project)) { echo json_encode(['project' => $project]); exit; } shell_exec('__PHP__ __EXAKAT__ init -p ' . $project . ' -R ' . escapeshellarg($_REQUEST['vcs'])); pushToQueue($project); echo json_encode(['project' => $project]); } exit; }
* along with Exakat. If not, see <http://www.gnu.org/licenses/>. * * The latest code can be found at <http://exakat.io/>. * */ $rows = glob('projects/*', GLOB_ONLYDIR); $finals = []; foreach ($rows as $row) { // print $row."\n"; $final = [basename($row)]; $sqliteFilename = $row . '/datastore.sqlite'; if (!file_exists($sqliteFilename)) { print "No {$sqliteFilename}\n"; continue; } $sqlite = new \Sqlite3($sqliteFilename); $res = $sqlite->querySingle('SELECT name FROM sqlite_master WHERE type="table" AND name="hash";'); if ($res === null) { print "No hash table in {$row}\n"; continue; } $res = $sqlite->query('SELECT * FROM hash WHERE key = "loc";'); $sqlRow = $res->fetchArray(); $final[] = $sqlRow['value']; $res = $sqlite->query('SELECT * FROM hash WHERE key = "tokens";'); $sqlRow = $res->fetchArray(); $final[] = $sqlRow['value']; $finals[] = $final; } $fp = fopen('size.csv', 'w+'); foreach ($finals as $final) {
<?php /** ** ispy_count.php, to get number of rows in tha db * **/ require_once __DIR__ . '/ispy_config.php'; $ispy_config = new IspyConfig(); $sqli = new Sqlite3($ispy_config->db); if (!$sqli) { die('Could not connect: ' . $sqli->error); } $sql = "SELECT * FROM `uploads`"; $result = $sqli->query($sql); if (!$result) { die('ispy select all not completed: ' . $sqli->lastErrorMsg); } $numRows = 0; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $numRows++; } if (!$numRows) { die('ispy numrows not completed: ' . $sqli->lastErrorMsg); } // free result set $result->finalize(); $sqli->close(); echo $numRows;
* it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation,either version 3 of the License,or * (at your option) any later version. * * Exakat is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Exakat. If not,see <http://www.gnu.org/licenses/>. * * The latest code can be found at <http://exakat.io/>. * */ $sqlite = new \Sqlite3('data/analyzers.sqlite'); $res = $sqlite->query('SELECT COUNT(*) FROM categories c JOIN analyzers_categories ac ON c.id = ac.id_categories JOIN analyzers a ON a.id = ac.id_analyzer WHERE c.name = "Analyze"'); $analyzer_count = $res->fetchArray(\SQLITE3_NUM)[0]; $extension_list = array(); $ext = glob('./human/en/Extensions/Ext*.ini'); foreach ($ext as $f) { $ini = parse_ini_file($f); $extension_list[] = '* ' . $ini['name']; } $extension_list = join("\n", $extension_list);
<?php $db = new Sqlite3('/var/www/html/db.sqlite'); $grls = $db->query("SELECT * FROM girls"); $rows = $grls->fetchArray(); /*while($row = $rows){ }*/ $left = "123 123"; $right = "234 234"; ?> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="materialize/css/materialize.min.css"> <link rel="stylesheet" href="styles/smash.css"> <script src="js/jquery-2.1.4.min.js"></script> </head> <body> <nav> <div class="nav-wrapper"> <a href="#" class="brand-logo right">Hot Or Not</a> <ul id="nav-mobile" class="left hide-on-med-and-down"> <li><a href="results.php">TOP - 100</a></li> </ul> </div> </nav> <div class="container fluid"> <div class="row" style="padding-top: 10%"></div>
<?php require_once __DIR__ . '/ispy_config.php'; $ispy_config = new IspyConfig(); $sqli = new Sqlite3($ispy_config->db); if (!$sqli) { die('Could not connect: ' . $sqli->lastErrorMsg); } // grab limit and offset $limit = $sqli->escapeString($_GET['limit']); $offset = $sqli->escapeString($_GET['offset']); $count = $sqli->escapeString($_GET['count']); // grab bottom three entries from table $sql = "SELECT * FROM `uploads` ORDER BY `id` DESC LIMIT {$limit} OFFSET {$offset};"; $result = $sqli->query($sql); if (!$result) { die('ispy insert not completed: ' . $sqli->error); } $i = 0; // loop through result entries do we need this??? // or can we just return the data jsonencoded while ($row = $result->fetchArray(SQLITE3_ASSOC)) { foreach ($row as $key => $value) { $selection[$key] = $value; } // push $selection assoc array to array of assoc arrays $result_array[$i] = $selection; $i++; } // json encode data for ajax parser $data = json_encode($result_array);
if (!file_exists($row . '/log/project.timing.csv')) { print "{$row} has no log/project.timing.csv\n"; continue; } $csv = file_get_contents($row . '/log/project.timing.csv'); if (!preg_match('/Final\\t([\\d\\.]+)\\t([\\d\\.]+)/is', $csv, $r)) { print "{$row} has no Final in log/project.timing.csv\n"; continue; } $final[] = $r[2]; $sqliteFilename = $row . '/datastore.sqlite'; if (!file_exists($sqliteFilename)) { print "No {$sqliteFilename}\n"; continue; } $sqlite = new \Sqlite3($sqliteFilename); $res = $sqlite->query('SELECT * FROM hash WHERE key = "tokens";'); $sqlRow = $res->fetchArray(); $final[] = $sqlRow['value']; $res = $sqlite->query('SELECT * FROM hash WHERE key = "loc";'); $sqlRow = $res->fetchArray(); $final[] = $sqlRow['value']; $res = $sqlite->query('SELECT * FROM hash WHERE key = "neo4jSize";'); $sqlRow = $res->fetchArray(); if (is_array($sqlRow)) { preg_match('/\\d+[KMG]/', $sqlRow['value'], $size); $size = $size[0]; $size = str_replace('K', '000', $size); $size = str_replace('M', '000000', $size); $size = str_replace('G', '000000000', $size); $final[] = $size;
public function checkData() { //php_constant_arguments.json $functions = json_decode(file_get_contents('data/php_constant_arguments.json')); $php_constants = parse_ini_file('data/php_constants.ini'); $php_constants = $php_constants['constants']; $total = 0; foreach ($functions as $style) { // combinaison or alternative foreach ($style as $methods) { // method name foreach ($methods as $method) { $diff = array_diff((array) $method, $php_constants); if (!empty($diff)) { print 'constants[] = \'' . implode("';\nconstants[] = '", $diff) . "'\n"; } $total += count($diff); } } } //methods.json $sqlite = new Sqlite3('data/methods.sqlite'); $res = $sqlite->query('SELECT name FROM methods WHERE name NOT IN ("flush", "key", "stat") GROUP BY lower(name) HAVING count(*) > 1'); $leftovers = array(); while ($row = $res->fetchArray(\SQLITE3_NUM)) { $leftovers[] = $row[0]; } if (!empty($leftovers)) { print count($leftovers) . " PHP native functions are in double ; " . implode(', ', $leftovers) . "\n"; } else { // function column must be lowercase $sqlite->query('UPDATE bugfixes SET function=LOWER(function)'); unset($sqlite); print "All native functions are OK\n"; } }
$ispy_config = new IspyConfig(); // make GET request to pick up latest instagram photos $r = new HttpRequest('https://api.instagram.com/v1/tags/foolprooffour/media/recent?client_id=' . $ispy_config->instagram_client_id, HttpRequest::METH_GET); try { $r->send(); if ($r->getResponseCode() == 200) { $results = $r->getResponseBody(); $results = json_decode($results, true); } } catch (HttpException $ex) { echo $ex; } /** * adding instagram photos to the db */ $sqli = new Sqlite3($ispy_config->db); if (!$sqli) { die('Could not connect: ' . $sqli->lastErrorMsg); } // pull latest photo from db and it's created time $sql = "SELECT `date_added` FROM `uploads` ORDER BY `id` DESC LIMIT 1;"; $sqli_result = $sqli->query($sql); $latest_date_str = $sqli_result->fetchArray(SQLITE3_ASSOC); $latest_date = strtotime($latest_date_str["date_added"]); if (!$sqli_result) { die('ispy insert not completed: ' . $sqli->lastErrorMsg); } foreach ($results['data'] as $result) { // break if you find a photo created later than the latest if (isset($latest_date) && (int) $result["created_time"] <= $latest_date) { break;
<?php include 'ispy_upload_photo_fb.php'; require_once __DIR__ . '/ispy_config.php'; $ispy_config = new IspyConfig(); /** * ispy_db_call.php, to record form entries to the db * */ if (empty($photo["id"])) { die('Upload failed: no photo detected.'); } $sqli = new Sqlite3($ispy_config->db); if (!$sqli) { die('Could not connect: ' . $sqli->lastErrorMsg); } // escape properties in _POST into variables $name = $sqli->escapeString($_POST["name"]); $date = $sqli->escapeString($_POST["date"]); $location = $sqli->escapeString($_POST["location"]); $email = $sqli->escapeString($_POST["email"]); $comments = $sqli->escapeString($_POST["comments"]); $file_name = 'https://graph.facebook.com/' . $sqli->escapeString($photo["id"]) . '/picture'; // convert date from string to date date_default_timezone_set('America/Los_Angeles'); $date_added = date('d\\/m\\/y H:i:s PST'); !isset($date) ? $date = NOW() : ''; $sql = "INSERT INTO uploads (`name`, `date`, `location`, `photo`, `email`, `comments`, `date_added`)\n VALUES ('{$name}', '{$date}', '{$location}', '{$file_name}', '{$email}', '{$comments}', NOW());"; $result = $sqli->query($sql); if (!$result) { die('ispy insert not completed: ' . $sqli->lastErrorMsg); }
continue; } // $this->log->log("$analyzer_class\t".($end - $begin)."\t$count\t$processed\t$queries\t$rawQueries"); // 1 : error log (+ project name) // 2 : project name // 3 : file name // 4 : duration // 5 : found issues // 6 : processed prospects // 7 : distinct queries count // 8 : total queries $final[] = $r[2]; $final[] = $r[4]; $final[] = $r[5]; $final[] = $r[6]; $sqliteFilename = str_replace('log/analyze.analyze.log', 'datastore.sqlite', $r[1]); if (!file_exists($sqliteFilename)) { print "No {$sqliteFilename}\n"; continue; } $sqlite = new \Sqlite3($sqliteFilename); $res = $sqlite->query('SELECT * FROM hash WHERE key = "tokens";'); $sqlRow = $res->fetchArray(); $final[] = $sqlRow['value']; $finals[] = $final; } $fp = fopen('timing2.csv', 'w+'); foreach ($finals as $final) { fputcsv($fp, $final); } fclose($fp);