public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
public static function get_instance() { if (self::$instance === NULL) { self::$instance = new self(); } return self::$instance; }
/** * Singleton method that returns a unique instance of the class. * * @return */ private static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (self::$instance === null) { self::$instance = new Settings(); } return self::$instance; }
static function getInstance() { if (self::$instance == NULL) { self::$instance = new Settings(); } return self::$instance; }
static function initate() { $class = __CLASS__; if (!isset(self::$instance)) { self::$instance = new $class(); } return self::$instance; }
function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public function get_post_image_url($filename) { $settings = Settings::instance(); $supportedFormats = array("jpg", "png", "gif"); $slug = pathinfo($filename, PATHINFO_FILENAME); foreach ($supportedFormats as $fmt) { $imgFile = sprintf("%s%s.%s", $settings->posts_dir, $slug, $fmt); if (file_exists($imgFile)) { return sprintf("%s/%s.%s", "{$blog_url}posts", $slug, $fmt); } } return false; }
public function run() { $menu = Menu::instance(); $manager = Manager::instance(); $settings = Settings::instance(); $attachment_edit = AttachmentEdit::instance(); $menu->set_manager($manager); $menu->set_settings($settings); $menu->init_pages(); add_action('wpod', array($menu, 'add_components')); add_action('admin_enqueue_scripts', array($attachment_edit, 'enqueue_scripts'), 10, 1); add_action('attachment_submitbox_misc_actions', array($attachment_edit, 'attachment_submitbox_misc_actions'), 100, 0); add_filter('map_meta_cap', array($this, 'map_meta_cap'), 10, 4); }
private static function instance($mailer_settings = array()) { if (empty(self::$default_settings)) { self::$default_settings = Settings::instance()->getValues('Emails'); } if (empty($mailer_settings)) { $mailer_settings = self::$default_settings; } if (empty(self::$_mailer)) { self::$_mailer = new Mailer(); self::$_mailer->LE = defined('IS_WINDOWS') ? "\r\n" : "\n"; self::$_mailer->PluginDir = Registry::get('config.dir.lib') . 'vendor/phpmailer/phpmailer'; } if ($mailer_settings['mailer_send_method'] == 'smtp') { self::$_mailer->IsSMTP(); self::$_mailer->SMTPAuth = $mailer_settings['mailer_smtp_auth'] == 'Y' ? true : false; self::$_mailer->Host = $mailer_settings['mailer_smtp_host']; self::$_mailer->Username = $mailer_settings['mailer_smtp_username']; self::$_mailer->Password = $mailer_settings['mailer_smtp_password']; self::$_mailer->SMTPSecure = $mailer_settings['mailer_smtp_ecrypted_connection']; } elseif ($mailer_settings['mailer_send_method'] == 'sendmail') { self::$_mailer->IsSendmail(); self::$_mailer->Sendmail = $mailer_settings['mailer_sendmail_path']; } else { self::$_mailer->IsMail(); } return self::$_mailer; }
public function __construct() { $this->settings = Settings::instance(); }
public static function init() { if(! isset(self::$instance)) { self::$instance = new Settings(getrootdirsrvinclude()."settings.php"); } return self::$instance; }
/** * Get Instance of Singleton Object * * @return Setting */ public static function getInstance() { /* Check Instance */ if (!self::$instance instanceof self) { self::$instance = new self(); } /* Return */ return self::$instance; }
public function __construct() { $this->settings = Settings::instance(); $this->tools = new Tools(); }
public function save() { if ($_POST["submit"] == "submit" && (!file_exists($this->settings_file) || isset($_SESSION['user']))) { $hasher = new \Phpass\Hash(); $settings = Settings::instance(); $blog_email = $settings->get('blog_email'); $blog_twitter = $settings->get('blog_twitter'); $blog_url = $settings->get('blog_url'); $blog_title = $settings->get('blog_title'); $meta_description = $settings->get('meta_description'); $intro_title = $settings->get('intro_title'); $intro_text = $settings->get('intro_text'); $template = $settings->get('template'); $password = $settings->get('password'); $header_inject = $settings->get('header_inject'); $footer_inject = $settings->get('footer_inject'); // Get submitted setup values. if (isset($_POST["blog_email"])) { $blog_email = $_POST["blog_email"]; } if (isset($_POST["blog_twitter"])) { $blog_twitter = $_POST["blog_twitter"]; } if (isset($_POST["blog_url"])) { $blog_url = $_POST["blog_url"]; } if (isset($_POST["blog_title"])) { $blog_title = $_POST["blog_title"]; } if (isset($_POST["meta_description"])) { $meta_description = $_POST["meta_description"]; } if (isset($_POST["intro_title"])) { $intro_title = $_POST["intro_title"]; } if (isset($_POST["intro_text"])) { $intro_text = $_POST["intro_text"]; } if (isset($_POST["template"])) { $template = $_POST["template"]; } // There must always be a $password, but it can be changed optionally in the // settings, so you might not always get it in $_POST. if (!isset($password) || !empty($_POST["password"])) { $password = $hasher->HashPassword($_POST["password"]); } if (!isset($header_inject)) { $header_inject = ""; } if (isset($_POST["header_inject"])) { $header_inject = addslashes($_POST["header_inject"]); } if (!isset($footer_inject)) { $footer_inject = ""; } if (isset($_POST["footer_inject"])) { $footer_inject = addslashes($_POST["footer_inject"]); } // Get subdirectory $this->dir .= str_replace('dropplets/save.php', '', $_SERVER["REQUEST_URI"]); // Output submitted setup values. $config[] = $this->settings_format("blog_email", $blog_email); $config[] = $this->settings_format("blog_twitter", $blog_twitter); $config[] = $this->settings_format("blog_url", $blog_url); $config[] = $this->settings_format("blog_title", $blog_title); $config[] = $this->settings_format("meta_description", $meta_description); $config[] = $this->settings_format("intro_title", $intro_title); $config[] = $this->settings_format("intro_text", $intro_text); $config[] = "password = '******'"; $config[] = $this->settings_format("header_inject", $header_inject); $config[] = $this->settings_format("footer_inject", $footer_inject); $config[] = $this->settings_format("template", $template); // Create the settings file. file_put_contents($this->settings_file, implode("\n", $config)); // Generate the .htaccess file on initial setup only. if (!file_exists($this->htaccess_file)) { // Parameters for the htaccess file. $htaccess[] = "# Pretty Permalinks"; $htaccess[] = "RewriteRule ^(images)(\$|/) - [L]"; $htaccess[] = "RewriteCond %{REQUEST_URI} !^action=logout [NC]"; $htaccess[] = "RewriteCond %{REQUEST_URI} !^action=login [NC]"; $htaccess[] = "Options +FollowSymLinks -MultiViews"; $htaccess[] = "RewriteEngine on"; $htaccess[] = "RewriteBase " . $this->dir; $htaccess[] = "RewriteCond %{REQUEST_URI} !index\\.php"; $htaccess[] = "RewriteCond %{REQUEST_FILENAME} !-f"; $htaccess[] = "RewriteRule ^(.*)\$ index.php?filename=\$1 [NC,QSA,L]"; // Generate the .htaccess file. file_put_contents($this->htaccess_file, implode("\n", $htaccess)); } // Redirect header("Location: " . $blog_url); } }
public static function digg() { $settings = Settings::instance(1); return $settings->get('digg'); }
public function save() { if ($_POST["submit"] == "submit" && (!file_exists($this->settings_file) || isset($_SESSION['user']))) { $hasher = new \Phpass\Hash(); $settings = Settings::instance(); $blog_email = $settings->get('blog_email'); $blog_twitter = $settings->get('blog_twitter'); $blog_url = $settings->get('blog_url'); $blog_title = $settings->get('blog_title'); $meta_description = $settings->get('meta_description'); $intro_title = $settings->get('intro_title'); $intro_text = $settings->get('intro_text'); $template = $settings->get('template'); $password = $settings->get('password'); $header_inject = $settings->get('header_inject'); $footer_inject = $settings->get('footer_inject'); // Get submitted setup values. if (isset($_POST["blog_email"])) { $blog_email = $_POST["blog_email"]; } if (isset($_POST["blog_twitter"])) { $blog_twitter = $_POST["blog_twitter"]; } if (isset($_POST["blog_url"])) { $blog_url = $_POST["blog_url"]; } if (isset($_POST["blog_title"])) { $blog_title = $_POST["blog_title"]; } if (isset($_POST["meta_description"])) { $meta_description = $_POST["meta_description"]; } if (isset($_POST["intro_title"])) { $intro_title = $_POST["intro_title"]; } if (isset($_POST["intro_text"])) { $intro_text = $_POST["intro_text"]; } if (isset($_POST["template"])) { $template = $_POST["template"]; } if (isset($_POST["file_ext"])) { $file_ext = $_POST["file_ext"]; } // There must always be a $password, but it can be changed optionally in the // settings, so you might not always get it in $_POST. if (!isset($password) || !empty($_POST["password"])) { $password = $hasher->HashPassword($_POST["password"]); } if (!isset($header_inject)) { $header_inject = ""; } if (isset($_POST["header_inject"])) { $header_inject = addslashes($_POST["header_inject"]); } if (!isset($footer_inject)) { $footer_inject = ""; } if (isset($_POST["footer_inject"])) { $footer_inject = addslashes($_POST["footer_inject"]); } // Output submitted setup values. $config[] = $this->settings_format("blog_email", $blog_email); $config[] = $this->settings_format("blog_twitter", $blog_twitter); $config[] = $this->settings_format("blog_url", $blog_url); $config[] = $this->settings_format("blog_title", $blog_title); $config[] = $this->settings_format("meta_description", $meta_description); $config[] = $this->settings_format("intro_title", $intro_title); $config[] = $this->settings_format("intro_text", $intro_text); $config[] = "password = '******'"; $config[] = $this->settings_format("header_inject", $header_inject); $config[] = $this->settings_format("footer_inject", $footer_inject); $config[] = $this->settings_format("template", $template); $config[] = $this->settings_format("file_ext", $file_ext); // Create the settings file. file_put_contents($this->settings_file, implode("\n", $config)); // Redirect header("Location: " . $blog_url); } }
public function __construct() { $this->settings = Settings::instance(); $this->posts = new PostHelper(); }
/** * Creates database and imports dump there * @param string $db_name db name * @return boolean true on success, false - otherwise */ public static function createDb($db_name = '') { $snapshot_dir = Registry::get('config.dir.snapshots'); $dbdump_filename = empty($db_name) ? 'cmp_current.sql' : 'cmp_release.sql'; if (!fn_mkdir($snapshot_dir)) { fn_set_notification('E', __('error'), __('text_cannot_create_directory', array('[directory]' => fn_get_rel_dir($snapshot_dir)))); return false; } $dump_file = $snapshot_dir . $dbdump_filename; if (is_file($dump_file)) { if (!is_writable($dump_file)) { fn_set_notification('E', __('error'), __('dump_file_not_writable')); return false; } } $fd = @fopen($snapshot_dir . $dbdump_filename, 'w'); if (!$fd) { fn_set_notification('E', __('error'), __('dump_cant_create_file')); return false; } if (!empty($db_name)) { Database::changeDb($db_name); } // set export format db_query("SET @SQL_MODE = 'MYSQL323'"); fn_start_scroller(); $create_statements = array(); $insert_statements = array(); $status_data = db_get_array("SHOW TABLE STATUS"); $dbdump_tables = array(); foreach ($status_data as $k => $v) { $dbdump_tables[] = $v['Name']; } // get status data $t_status = db_get_hash_array("SHOW TABLE STATUS", 'Name'); foreach ($dbdump_tables as $k => $table) { fn_echo('<br />' . __('backupping_data') . ': <b>' . $table . '</b> '); $total_rows = db_get_field("SELECT COUNT(*) FROM {$table}"); $index = db_get_array("SHOW INDEX FROM {$table}"); $order_by = array(); foreach ($index as $kk => $vv) { if ($vv['Key_name'] == 'PRIMARY') { $order_by[] = '`' . $vv['Column_name'] . '`'; } } if (!empty($order_by)) { $order_by = 'ORDER BY ' . implode(',', $order_by); } else { $order_by = ''; } // Define iterator if (!empty($t_status[$table]) && $t_status[$table]['Avg_row_length'] < DB_MAX_ROW_SIZE) { $it = DB_ROWS_PER_PASS; } else { $it = 1; } for ($i = 0; $i < $total_rows; $i = $i + $it) { $table_data = db_get_array("SELECT * FROM {$table} {$order_by} LIMIT {$i}, {$it}"); foreach ($table_data as $_tdata) { $_tdata = fn_add_slashes($_tdata, true); $values = array(); foreach ($_tdata as $v) { $values[] = $v !== null ? "'{$v}'" : 'NULL'; } fwrite($fd, "INSERT INTO {$table} (`" . implode('`, `', array_keys($_tdata)) . "`) VALUES (" . implode(', ', $values) . ");\n"); } fn_echo(' .'); } } fn_stop_scroller(); if (!empty($db_name)) { Settings::instance()->reloadSections(); } if (fn_allowed_for('ULTIMATE')) { $companies = fn_get_short_companies(); asort($companies); $settings['company_root'] = Settings::instance()->getList(); foreach ($companies as $k => $v) { $settings['company_' . $k] = Settings::instance()->getList(0, 0, false, $k); } } else { $settings['company_root'] = Settings::instance()->getList(); } if (!empty($db_name)) { Database::changeDb(Registry::get('config.db_name')); } $settings = self::processSettings($settings, ''); $settings = self::formatSettings($settings['data']); ksort($settings); $data = print_r($settings, true); fwrite($fd, $data); fclose($fd); @chmod($snapshot_dir . $dbdump_filename, DEFAULT_FILE_PERMISSIONS); return true; }
public static function init2() { if(! isset(self::$instance)) { self::$instance = new Settings("../settings.php"); } return self::$instance; }