public function action_query() { $library_id = $this->auth(); if (Input::get('query') == 'synced_at') { $row = DB::query('select synced_at, slug from libraries where id = ?', array($library_id)); if ($row[0]->slug && $row[0]->slug[0] == '_') { DB::query('update libraries set slug = substr(slug, 2) where id = ?', array($library_id)); $license = updateLicense($library_id); return returnData(array('synced_at' => $row[0]->synced_at, 'license' => $license)); } else { return returnData(array('synced_at' => $row[0]->synced_at)); } } }
function main($args) { $dryrun = in_array("-r", $args); $inline = in_array("-i", $args); $delete = in_array("-d", $args); $verbose = in_array("-v", $args); $args = array_values(array_filter($args, function ($arg) { return !startsWith($arg, "-"); })); $src = $args[0]; if (!file_exists($src)) { throw new Exception("can't find file/folder '{$src}'"); } if ($dryrun) { if ($verbose) { print "DRYRUN MODE\n"; } $changeFiles = []; foreach (getFileset($src) as $file) { if ($verbose) { print "CHECKING FILE '{$file}'\n"; } $file = realpath($file); $lines = explode("\n", file_get_contents($file)); if (willContentChange($lines)) { $changeFiles[] = $file; } } print "FILES THAT WILL CHANGE\n"; print implode("\n - ", $changeFiles); } else { if ($delete) { if ($verbose) { print "LICENSE DELETE MODE\n"; } foreach (getFileset($src) as $file) { if ($verbose) { print "DELETING ANY LICENSE HEADERS FROM FILE '{$file}'\n"; } $lines = explode("\n", file_get_contents(realpath($file))); $lines = cleanUpFileHeader(removeLicense($lines)); file_put_contents($file, implode("\n", $lines)); } } else { $fileContents = []; foreach (getFileset($src) as $file) { if ($verbose) { print "UPDATING FILE '{$file}'\n"; } $file = realpath($file); $contents = file_get_contents($file); $lines = explode("\n", $contents); $fileContents[$file] = implode("\n", updateLicense($lines)); } if ($inline) { if ($verbose) { print "INLINE MODE - WRITING FILES...\n"; } foreach ($fileContents as $fileName => $contents) { if ($verbose) { print "WRITING FILE '{$fileName}'\n"; } file_put_contents($fileName, $contents); } print "WROTE " . count($fileContents) . " FILES\n"; } else { foreach ($fileContents as $fileName => $contents) { print ">>>FILE {$fileName}\n{$contents}\n<<<FILE\n"; } } } } }