function get_password() { $site_password = common::readSingleline('Enter system user password, and hit return: '); $site_password2 = common::readSingleline('Retype system user password, and hit return: '); if ($site_password == $site_password2) { return $site_password; } else { get_password(); } }
/** * adds an user by prompt * @param array $options * @return int $res */ function useradd_add($options = null) { $values['email'] = common::readSingleline("Enter Email of super user (you will use this as login): "); $values['password'] = common::readSingleline("Enter password: "); $values['password'] = md5($values['password']); $values['username'] = $values['email']; $values['verified'] = 1; $values['admin'] = 1; $values['super'] = 1; $values['type'] = 'email'; $res = useradd_db_insert($values); if ($res) { return 0; } else { return 1; } }
/** * set csendgrid config in config.ini */ function heroku_set_sendgrid_conf() { $user = heroku_get_setting('SENDGRID_USERNAME'); $pass = heroku_get_setting('SENDGRID_PASSWORD'); if ($user && $pass) { $config_file = heroku_get_config_filename(); conf::$vars['coscms_main'] = conf::getIniFileArray($config_file, true); $from_text = common::readSingleline('Enter which from text should be seen in his inbx, e.g. CosCMS (not the email)'); $reply = common::readSingleline('Enter which email users should reply to (an email):'); conf::$vars['coscms_main']['site_email'] = "{$from_text} <{$user}>"; conf::$vars['coscms_main']['site_email_reply'] = "{$from_text} <{$reply}>"; conf::$vars['coscms_main']['smtp_params_host'] = "smtp.sendgrid.net"; conf::$vars['coscms_main']['smtp_params_sender'] = $user; conf::$vars['coscms_main']['smtp_params_username'] = $user; conf::$vars['coscms_main']['smtp_params_password'] = $pass; conf::$vars['coscms_main']['smtp_params_auth'] = "true"; conf::$vars['coscms_main']['smtp_params_port'] = 587; $content = conf::arrayToIniFile(conf::$vars['coscms_main'], false); $path = conf::pathBase() . "/config/config.ini"; file_put_contents($path, $content); } }
function miau_test($options) { echo common::colorOutput('These are the options given to function miau_test()', 'Cyan'); echo PHP_EOL; // Print the arguments print_r($options); // echo a string with a newline echo common::echoMessage('Draw a cat!'); // echo a colored string. You will need to add newlines echo common::colorOutput('Miau', 'y') . PHP_EOL; // Read a line from the user $str = common::readSingleline('What does a cat say? (Enter input) '); // Echo a formatted status echo common::echoStatus('OK', 'y', $str); // confirm with a yes or a no $res = common::readlineConfirm('Please confirm that you are sure ' . $str); // readlineConfirm return 1 on 'y' and 0 on 'n' if (!$res) { echo common::colorOutput('Ok - you made a mistake!', 'r') . PHP_EOL; } else { echo common::colorOutput('OK. You are sure. ', 'b') . PHP_EOL; } }
/** * function for tagging all modules and templates * @param array options from cli env */ function cos_git_tag_all($options) { $profile = new profile(); $version = common::readSingleline('Enter tag version to use '); $modules = $profile->getModules(); foreach ($modules as $key => $val) { $tags = git::getTagsModule($val['module_name'], 'module'); if (in_array($version, $tags)) { common::echoStatus('NOTICE', 'y', "Tag already exists local for module '{$val['module_name']}'."); } $val['new_version'] = $version; cos_git_tag($val, 'module'); } $templates = $profile->getTemplates(); foreach ($templates as $key => $val) { $tags = git::getTagsModule($val['module_name'], 'template'); if (in_array($version, $tags)) { common::echoStatus('NOTICE', 'y', "Tag already exists local for template '{$val['module_name']}'"); } $val['new_version'] = $version; cos_git_tag($val, 'template'); } }