function xml_import($args) { $filename = $args['xml_import']; if (!is_file($filename)) { print "error: input filename ({$filename}) doesn't exist.\n"; return; } _debug("please enter your username:"******"importing {$filename} for user {$username}...\n"); $result = db_query("SELECT id FROM ttrss_users WHERE login = '******'"); if (db_num_rows($result) == 0) { print "error: could not find user {$username}.\n"; return; } $owner_uid = db_fetch_result($result, 0, "id"); $this->perform_data_import($filename, $owner_uid); }
function greader_import($args) { $file = $args['greader_import']; if (!file_exists($file)) { _debug("file not found: {$file}"); return; } _debug("please enter your username:"******"looking up user: {$username}..."); $result = db_query("SELECT id FROM ttrss_users\n\t\t\tWHERE login = '******'"); if (db_num_rows($result) == 0) { _debug("user not found."); return; } $owner_uid = db_fetch_result($result, 0, "id"); _debug("processing: {$file} (owner_uid: {$owner_uid})"); $this->import($file, $owner_uid); }
// authentication success. debug("auth: ok"); return TRUE; } else { debug("auth: error"); return FALSE; } } // user not found debug("user not found"); return FALSE; } function read_stdin() { global $stdin_file; global $stdin_term; $str = ''; while (!feof($stdin_file)) { $ch = fread($stdin_file, 1); if (ord($ch) == $stdin_term) { break; } $str .= $ch; } return $str; } $user = read_stdin(); $pass = read_stdin(); $service = read_stdin(); $ret = authenticate($user, $pass, $service, $main_pass_db); exit($ret ? 0 : 1);
$table = $matches[2]; $statement = "CREATE INDEX {$index} ON {$table}"; _debug($statement); db_query($link, $statement); } } fclose($fp); } else { _debug("unable to open schema file."); } _debug("all done."); } if (in_array("-convert-filters", $op)) { _debug("WARNING: this will remove all existing type2 filters."); _debug("Type 'yes' to continue."); if (read_stdin() != 'yes') { exit; } _debug("converting filters..."); db_query($link, "DELETE FROM ttrss_filters2"); $result = db_query($link, "SELECT * FROM ttrss_filters ORDER BY id"); while ($line = db_fetch_assoc($result)) { $owner_uid = $line["owner_uid"]; // date filters are removed if ($line["filter_type"] != 5) { $filter = array(); if (sql_bool_to_bool($line["cat_filter"])) { $feed_id = "CAT:" . (int) $line["cat_id"]; } else { $feed_id = (int) $line["feed_id"]; }
} $chosenMethod = read_stdin(); $methodName = $methods[$chosenMethod - 1]; echo "Ok! You've choose algorithm \"" . $algorithmName . "\" and method \"" . $methodName . "\"\n"; if (!is_null($algorithmMap[$algorithmName]['construct_parameters'])) { echo "Algorithm you've choose needs some constructor parameters: \n"; foreach ($algorithmMap[$algorithmName]['construct_parameters']['parameters'] as $parameterType => $parameterName) { echo "\tPlease enter " . $parameterType . " value. It'll be a " . $parameterName . " for " . $algorithmName . " algorithm:\n"; } $constructParameters = read_stdin(); echo "\n"; echo "Ok! Parameter is: " . $constructParameters; echo "\n\n"; } echo "\n"; echo "Now, enter word you want to " . $methodName . ": \n"; $wordToHash = read_stdin(); $wordToHash = trim($wordToHash); /** * @var \Library\Algorithm\Kakuna|\Library\Algorithm\Seqswap */ try { $result = Hasher::createAlgorithm($algorithmName, $constructParameters)->{$methodName}($wordToHash); } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; return; } echo "Wow! We've done! Here is result: \n"; echo $result; echo "\n\n"; }
function update_self($args) { _debug("Warning: self-updating is experimental. Use at your own risk."); _debug("Please backup your tt-rss directory before continuing. Your database will not be modified."); _debug("Type 'yes' to continue."); if (read_stdin() != 'yes') { exit; } $this->update_self_cli($link, in_array("-force", $args)); }
echo "Payment related_resources:" . $related_resource_count . "(" . $related_resources . ")"; echo "\n \n"; echo "###########################################\n"; echo "Initiating a Payment with PayPal Account... \n"; $url = $host . '/v1/payments/payment'; $payment = array('intent' => 'sale', 'payer' => array('payment_method' => 'paypal'), 'transactions' => array(array('amount' => array('total' => '7.47', 'currency' => 'USD'), 'description' => 'payment using a PayPal account')), 'redirect_urls' => array('return_url' => 'http://www.return.com/?test=123', 'cancel_url' => 'http://www.cancel.com')); $json = json_encode($payment); $json_resp = make_post_call($url, $json); foreach ($json_resp['links'] as $link) { if ($link['rel'] == 'execute') { $payment_execute_url = $link['href']; $payment_execute_method = $link['method']; } else { if ($link['rel'] == 'approval_url') { $payment_approval_url = $link['href']; $payment_approval_method = $link['method']; } } } echo "Payment Created successfully: " . $json_resp['id'] . " with state '" . $json_resp['state'] . "'\n\n"; echo "Please goto " . $payment_approval_url . " in your browser and approve the payment with a PayPal Account.\n"; echo "Enter PayerId from the return url to continue:"; $payerId = read_stdin(); echo "\n \n"; echo "###########################################\n"; echo "Executing the PayPal Payment for PayerId (" . $payerId . ")... \n"; $payment_execute = array('payer_id' => $payerId); $json = json_encode($payment_execute); $json_resp = make_post_call($payment_execute_url, $json); echo "Payment Execute processed " . $json_resp['id'] . " with state '" . $json_resp['state'] . "'"; echo "\n \n";
function update_self($args) { _debug("READ THE FOLLOWING BEFORE CONTINUING!"); _debug("* It is suggested to backup your tt-rss directory first."); _debug("* Your database will not be modified."); _debug("* Your current tt-rss installation directory will not be modified. It will be renamed and left in the parent directory. You will be able to migrate all your customized files after update finishes."); _debug("Type 'yes' to continue."); $input = read_stdin(); if ($input != 'yes' && $input != 'force') { exit; } $this->update_self_cli($input == 'force'); }
if ($yorn == 'y') { if (INST_SHELL == 'brew') { inst_zsh(); } elseif (INST_SHELL == 'apt-get') { $cmd = "sudo apt-get install zsh git-core"; e($cmd, 'run'); } elseif (INST_SHELL == 'yum') { $cmd = 'yum install ncurses-devel;sudo yum install autojump'; e("yum install ag -> http://www.9enjoy.com/ag-the_silver_searcher/", 'yellow'); inst_zsh(); e($cmd, 'run'); } $cmd = "curl -L# http://install.ohmyz.sh > " . getenv('HOME') . "install.ohmyz.sh;sh " . getenv('HOME') . "install.ohmyz.sh;rm " . getenv('HOME') . '/install.ohmyz.sh'; e($cmd, 'run'); $cmd = "mv ~/.zshrc ~/.zshrc__old;ln -s " . _HOME . "/zshrc ~/.zshrc"; e($cmd, 'run'); e('cd ' . _HOME . ';git clone git://github.com/joelthelion/autojump.git;cd autojump;./install.py', 'run'); } e("Change your shell to zsh ! [y/n] !"); $yorn = read_stdin(); if ($yorn == 'y') { system('chsh -s /bin/zsh;source ~/.zshrc'); } e("Install heisoo tools!"); $incFile = HS_LIB . '/hs_sync.phar'; $cmd = "sudo mkdir -p " . HS_LIB . ";sudo mkdir -p /usr/local/bin/;curl -L# https://raw.githubusercontent.com/poyu007/heisoo_env/master/build/hs_sync.phar > ./hs_sync.phar;sudo mv ./hs_sync.phar {$incFile};sudo chmod +x {$incFile}; ln -s " . HS_LIB . "/hs_sync.phar /usr/local/bin/hs_sync;"; e($cmd, 'run'); $cmd = "curl -L# http://get.sensiolabs.org/php-cs-fixer.phar > ./php-cs-fixer.phar;sudo chmod a+x ./php-cs-fixer.phar; sudo mv ./php-cs-fixer.phar " . HS_LIB . "/php-cs-fixer.phar;ln -s " . HS_LIB . '/php-cs-fixer.phar /usr/local/bin/php-cs-fixer.phar'; e($cmd, 'run'); # ln -s $dir/tmux.conf ~/.tmux.conf`; # #brew install ctags # vim +PluginInstall +qall now
echo "What days you want to limit\n"; echo "ex MRF = Mondays, Thursdays, and Fridays\n"; echo ">"; $limit = read_stdin(); echo "Choose what time to not have classes (starting)\n"; echo "ex 800 It must follow this format\n"; echo "If it doesn't matter leave it blank\n"; $from = read_stdin(); echo "Ending time\n"; $to = read_stdin(); echo "Do you want it to be in University City campus only or not\n"; echo "(1 for University City campus 0 for all campuses)\n"; $campus = read_stdin(); echo "Do you want to allow closed classes or not\n"; echo "(1 for closed classes 0 for no closed classes\n"; $close = read_stdin(); #For loop to decipher the combinations for ($i = 0; $i < count($list); $i = $i + 1) { $list_combos = multiply($list[$i], $list_combos, $from, $to, $limit, $campus, $close); } $list_combos_final = array(); for ($i = 0; $i < count($list_combos); $i = $i + 1) { if (count($list_combos[$i]) == count($list)) { array_push($list_combos_final, $list_combos[$i]); } } $list_combos = $list_combos_final; #print the list combinations echo count($list_combos); echo " possible schedules\n\n"; echo "==========================\n";
<?php // show them a message to enter their name echo "Tell us your name: " . PHP_EOL; // the script will wait here until the user has entered something and hit ENTER $name = read_stdin(); // This will display the thank you message including their name they entered. echo "Thank you $name. Welcome to my site" . PHP_EOL; // our function to read from the command line function read_stdin() { $fr=fopen("php://stdin","r"); // open our file pointer to read from stdin $input = fgets($fr,128); // read a maximum of 128 characters $input = rtrim($input); // trim any trailing spaces. fclose ($fr); // close the file handle return $input; // return the text entered } ?>