function run_disallow_permissions() { $settings = getSettings(); $root = ".."; pake_echo_action("permissions", "allow permissions..."); pake_chmod('', $root, 0755); }
function getUserConfig($configKey, $baseFolder = null, $reset = false) { $configKey = strtolower($configKey); if ($reset) { if (isset($_SESSION['USERCONFIG'][$configKey])) { unset($_SESSION['USERCONFIG'][$configKey]); } } if (isset($_SESSION['USERCONFIG']) && isset($_SESSION['USERCONFIG'][$configKey])) { return $_SESSION['USERCONFIG'][$configKey]; } $configData = getSettings($configKey); if (strlen($configData) > 2) { $_SESSION['USERCONFIG'][$configKey] = json_decode($configData, true); return $_SESSION['USERCONFIG'][$configKey]; } if ($baseFolder == null) { $bt = debug_backtrace(); $baseFolder = dirname($bt[0]['file']) . "/"; } $configArr = [APPROOT . APPS_DATA_FOLDER . "jsonData/" . $configKey . ".json", $baseFolder . "config.json"]; foreach ($configArr as $f) { if (file_exists($f)) { $configData = file_get_contents($f); $_SESSION['USERCONFIG'][$configKey] = json_decode($configData, true); setSettings($configKey, $configData); return $_SESSION['USERCONFIG'][$configKey]; } } return false; }
function showModuleSettings($module, $key) { $table = getSettings($module); table_open(); if ($table) { tr_open(); td_open(1); echo getString("settings_description", "Beskrivelse"); td_close(); td_open(1); echo getString("settings_value", "Verdi"); td_close(); td_open(1); echo getString("settings_type", "Type"); td_close(); td_open(1); echo getString("settings_edit", "Endre"); td_close(); tr_close(); while ($row = nextResultInTable($table)) { tr_open(); td_open(1); echo $row['description']; td_close(); form_start_post(); if ($row['settingskey'] == $key) { showSetting($row, true); td_open(1); form_hidden("m_c", "showSettingsGUI"); form_hidden("module", $module); form_hidden("key", $row['settingskey']); form_hidden("save", true); form_submit("submit", getString("settings_save_setting", "Lagre")); td_close(); } else { showSetting($row, false); td_open(1); form_hidden("m_c", "showSettingsGUI"); form_hidden("module", $module); form_hidden("key", $row['settingskey']); form_submit("submit", getString("settings_edit_setting", "Endre")); td_close(); } form_end(); tr_close(); } } else { // ingen settings, gi beskjed: tr_open(); td_open(1); echo getString("settings_could_not_find_settings_for_this_module", "Fant ingen innstillinger for denne modulen"); td_close(); tr_close(); } table_close(); }
function printSettings($uid, $pid, $name, $typeid) { echo "\n\t\t<li class=\"plant\" data-uid=\"" . $uid . "\" data-pid=\"" . $pid . "\" data-plant-nickname=\"" . $name . "\" data-plant-type=\"" . getCommonName($typeid) . "\"><h2 class=\"name button\">" . $name . " <span>(" . getCommonName($typeid) . ")</span></h2>\n\t\t\t<ul class=\"sub\">"; $info = getSettings($uid, $pid); foreach ($info as $key => $value) { $key = str_replace("_", " ", $key); echo "<li class='plant{$key}'><span class='key'>" . $key . "</span><span class=\"value\">" . ucfirst($value) . "</span></li>"; } echo "\n\t\t\t<li data-value=\"alert\" class=\"button green \">Set Alert Type</li>\n\t\t\t<li class=\"button red\">Delete</li>\n\t\t\t</ul>\n\t\t</li>\n\t\t"; }
function processSettings($calID) { //get settings from calendar $dbSet = getSettings(); if (!empty($dbSet)) { echo "<li>Calendar settings retrieved from database.</li>\n"; } //convert 2.7.1 date settings to new settings $ds = isset($dbSet['dateSep']) ? $dbSet['dateSep'] : '.'; //dateSep: LuxCal 2.7.1 if (isset($dbSet['dateFormat'])) { switch ($dbSet['dateFormat']) { //dateSep: LuxCal 2.7.1 format case '1': $dbSet['dateFormat'] = 'd' . $ds . 'm' . $ds . 'y'; break; case '2': $dbSet['dateFormat'] = 'm' . $ds . 'd' . $ds . 'y'; break; case '3': $dbSet['dateFormat'] = 'y' . $ds . 'm' . $ds . 'd'; } } if (empty($dbSet['MdFormat'])) { $dbSet['MdFormat'] = empty($dbSet['dateUSorEU']) ? 'M d' : 'd M'; } //dateUSorEU: LuxCal 2.7.1 if (empty($dbSet['MdyFormat'])) { $dbSet['MdyFormat'] = empty($dbSet['dateUSorEU']) ? 'M d, y' : 'd M y'; } if (empty($dbSet['MyFormat'])) { $dbSet['MyFormat'] = empty($dbSet['dateUSorEU']) ? 'M y' : 'M y'; } if (empty($dbSet['DMdFormat'])) { $dbSet['DMdFormat'] = empty($dbSet['dateUSorEU']) ? 'WD, M d' : 'WD d M'; } if (empty($dbSet['DMdyFormat'])) { $dbSet['DMdyFormat'] = empty($dbSet['dateUSorEU']) ? 'WD, M d, y' : 'WD d M y'; } if (empty($dbSet['timeFormat'])) { $dbSet['timeFormat'] = empty($dbSet['time24']) ? 'h:ma' : 'h.m'; } //time24: LuxCal 2.7.1 //check and complete settings checkSettings($dbSet); //if $dbSet['x'] empty, set to default value echo "<li>Calendar settings verified/completed.</li>\n"; //save calendar settings to calendar $result = saveSettings($calID, $dbSet, true); if ($result === false) { exit('Error: Unable to save settings in database. Check database credentials.'); } echo "<li>Calendar settings saved to database.</li>\n"; return $result; }
public function getSettings() { $settings = getSettings(); if (strstr($_SERVER['HTTP_REFERER'], 'admin')) { $langs = $this->config->item('languages'); $language = $this->config->item('language'); $locale = $langs[$language][0]; } else { $locale = MY_Controller::getCurrentLocale(); } $settings['curLocale'] = $locale; return json_encode($settings); }
function runClient() { $settings = getSettings(); $client = Client::getInstance($settings); $type = 'echo'; $data = array('foo' => 'bar', 'baz' => 9001); $resultId = $client->putRequest($type, $data); Common::$lg->addDebug("Client put request {$resultId} on AMQ"); $result = $client->getResult($resultId); Common::$lg->addDebug("Client got data for {$resultId}"); if ($result->{'foo'} == $data['foo'] && $result->{'baz'} == $data['baz']) { exit(0); } else { echo "Client received wrong data for {$resultId}"; exit(1); } }
function writeGlobalCache() { global $db, $_SYS; $row = getSettings(0); $apikey = $row['apikey']; $tmparr = array(); if (!empty($apikey)) { $row['apikey'] = array(); $tmpapis = explode("\n", $apikey); foreach ($tmpapis as $tmpapi) { $tmpapikv = explode(":", $tmpapi); if (is_array($tmpapikv) && !empty($tmpapikv[0]) && !empty($tmpapikv[1])) { $row['apikey'][$tmpapikv[0]] = trim($tmpapikv[1]); } } } $str = "<?php \r\n \$cache_global = " . varToStr($row) . "; \r\n?>"; writeFile(getCacheFilePath("global.php"), $str); }
deleteJob($_REQUEST["job_id"]); header("Location: " . $GLOBALS['contextpath'] . "/user/" . $_SESSION['username'] . "/"); } exit; break; case "reset": if (is_numeric($_REQUEST["job_id"])) { resetJob($_REQUEST["job_id"]); header("Location: " . $GLOBALS['contextpath'] . "/job/" . $_REQUEST["job_id"] . "/"); } case "viewall": header("Location: " . $GLOBALS['contextpath'] . "/user/" . $_SESSION['username'] . "/"); break; default: getJobs(); exit; break; } exit; break; case "useragents": getUserAgents(); exit; break; case "settings": getSettings(); exit; break; } } }
// include the default language require_once WB_PATH . '/modules/foldergallery/languages/EN.php'; // check if module language file exists for the language set by the user (e.g. DE, EN) if (file_exists(WB_PATH . '/modules/foldergallery/languages/' . LANGUAGE . '.php')) { require_once WB_PATH . '/modules/foldergallery/languages/' . LANGUAGE . '.php'; } // Files includen require_once WB_PATH . '/modules/foldergallery/info.php'; require_once WB_PATH . '/modules/foldergallery/admin/scripts/backend.functions.php'; require_once WB_PATH . '/modules/foldergallery/class/class.upload.php'; require_once WB_PATH . '/modules/foldergallery/class/validator.php'; require_once WB_PATH . '/modules/foldergallery/class/DirectoryHandler.Class.php'; // Set the mySQL encoding to utf8 $oldMysqlEncoding = mysql_client_encoding(); mysql_set_charset('utf8', $database->db_handle); $settings = getSettings($section_id); $root_dir = $settings['root_dir']; //Chio if (isset($_GET['cat_id']) && is_numeric($_GET['cat_id'])) { $cat_id = $_GET['cat_id']; } else { $error['no_cat_id'] = 1; $admin->print_error('lost cat', ADMIN_URL . '/pages/modify.php?page_id=' . $page_id . '§ion_id=' . $section_id); die; } // Kategorie Infos aus der DB holen $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE id=' . $cat_id . ' LIMIT 1;'; $query = $database->query($sql); $categorie = $query->fetchRow(); if (is_array($categorie)) { if ($categorie['parent'] != -1) {
//Insert a log message into the error log function errorlog($msg, &$db) { $insert['msg'] = $msg; $insert['time'] = time(); $query = $db->autoexecute('log_errors', $insert, 'INSERT'); } //Insert a log message into the GM log function gmlog($msg, &$db) { $insert['msg'] = $msg; $insert['time'] = time(); $query = $db->autoexecute('log_gm', $insert, 'INSERT'); } //Get all settings variables function getSettings(&$db) { $query = $db->execute("select `name`, `value` from `settings`"); while ($set = $query->fetchrow()) { $setting->{$set}['name'] = $set['value']; } return $setting; } $setting = getSettings($db); //Get the player's IP address $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; //Check that the player has the appropriate permission of a GM rank above 20 if (check_permissions($player, 21) == 0) { header("Location: ../logout.php"); exit; }
<?php require_once '../configuration_admin.php'; // start the session $session = getSession(); // get smarty handle $smarty = getSmartyHandle(); $GLOBALS['applog']->logMessage(var_export($_REQUEST, true), LOGGER_ERROR, 'edit_custom'); // check permissions if ($session->isLoggedIn()) { // get handle on database $db = getDBHandle(); // get handle on the settings $settings = getSettings(); // define standard fields to parse/clear $fields = array('eventHeaderCustom', 'eventTextCustom', 'eventSubtextCustom', 'eventLinkCustom', 'boingoLinkCustom'); if (isset($_REQUEST['submit'])) { $GLOBALS['applog']->logMessage("normal form submission hit", LOGGER_ERROR, 'edit_custom'); // some of the fields just get dumped into settings $fields = array('eventLinkCustom', 'boingoLinkCustom'); foreach ($fields as $key) { if (strlen($_REQUEST[$key])) { $GLOBALS['applog']->logMessage("Saving setting {$key}, value " . $_REQUEST[$key], LOGGER_DEBUG, 'edit_custom'); $settings->__set($key, $_REQUEST[$key]); } } // some get truncated if they are too long $fields = array('eventHeaderCustom', 'eventTextCustom', 'eventSubtextCustom'); foreach ($fields as $key) { if (strlen($_REQUEST[$key])) { if (strlen($_REQUEST[$key]) > $GLOBALS['textRestrictions'][$key]) {
<table align="center" width="800"> <tr align="center" height="25"> <td bgcolor="#AAAAAA"><strong>Index</strong></td> <td bgcolor="#AAAAAA"><strong>Ontology Prefix</strong></td> <td bgcolor="#AAAAAA"><strong>Classes</strong></td> <td bgcolor="#AAAAAA"><strong>Object Properties</strong></td> <td bgcolor="#AAAAAA"><strong>Datatype Properties</strong></td> <td bgcolor="#AAAAAA"><strong>Annotation Properties</strong></td> <td bgcolor="#AAAAAA"><strong>Total</strong></td> </tr> <?php foreach ($rs as $row) { $o = $row['ontology_abbrv']; $settings = getSettings($o); $classQueryString = "\nPREFIX rdf: <{$settings['ns_rdf']}>\nPREFIX owl: <{$settings['ns_owl']}>\nSELECT count(distinct ?s) as ?cCount\nFROM <{$settings['ns_main']}>\nWHERE\n{\n?s a owl:Class .\nFILTER (isIRI(?s)).\n}\n"; $objectQueryString = "\nPREFIX rdf: <{$settings['ns_rdf']}>\nPREFIX owl: <{$settings['ns_owl']}>\nSELECT count(distinct ?s) as ?oCount\nFROM <{$settings['ns_main']}>\nWHERE\n{\n?s a owl:ObjectProperty .\nFILTER (isIRI(?s)).\n}\n"; $datatypeQueryString = "\nPREFIX rdf: <{$settings['ns_rdf']}>\nPREFIX owl: <{$settings['ns_owl']}>\nSELECT count(distinct ?s) as ?dCount\nFROM <{$settings['ns_main']}>\nWHERE\n{\n?s a owl:DatatypeProperty .\nFILTER (isIRI(?s)).\n}\n"; $annotationQueryString = "\nPREFIX rdf: <{$settings['ns_rdf']}>\nPREFIX owl: <{$settings['ns_owl']}>\nSELECT count(distinct ?s) as ?aCount\nFROM <{$settings['ns_main']}>\nWHERE\n{\n?s a owl:AnnotationProperty .\nFILTER (isIRI(?s)).\n}\n"; $cCountResult = json_query($classQueryString); $aCountResult = json_query($annotationQueryString); $dCountResult = json_query($datatypeQueryString); $oCountResult = json_query($objectQueryString); $cCount = $cCountResult[0]['cCount']; $aCount = $aCountResult[0]['aCount']; $dCount = $dCountResult[0]['dCount']; $oCount = $oCountResult[0]['oCount']; $total = $cCount + $aCount + $dCount + $oCount; ?> <tr align="center" height="25" <?php
<?php require './vendor/autoload.php'; require './src/functions.php'; require_once './src/workflows.php'; $w = new Workflows('com.vdesabou.spotify.mini.player'); // // Read settings from JSON // $settings = getSettings($w); $oauth_client_id = $settings->oauth_client_id; $oauth_client_secret = $settings->oauth_client_secret; $oauth_redirect_uri = $settings->oauth_redirect_uri; try { $session = new SpotifyWebAPI\Session($oauth_client_id, $oauth_client_secret, $oauth_redirect_uri); if (!empty($_GET['code'])) { // Request a access token using the code from Spotify $ret = $session->requestAccessToken($_GET['code']); if ($ret == true) { $api = new SpotifyWebAPI\SpotifyWebAPI(); // Set the code on the API wrapper $api->setAccessToken($session->getAccessToken()); $user = $api->me(); $ret = updateSetting($w, 'oauth_access_token', $session->getAccessToken()); if ($ret == false) { echo "There was an error when updating settings"; exec("kill -9 \$(ps -efx | grep \"php -S localhost:15298\" | grep -v grep | awk '{print \$2}')"); return; } $ret = updateSetting($w, 'oauth_expires', time()); if ($ret == false) {
} catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } } } if (isset($_POST['regid']) && isset($_POST['sendEmail']) && isset($_POST['template']) && !$cancelProcess) { $CustomMsg; $Header; $Subject; $Body; $Footer; $email; $template; $userid = $_SESSION['UserID']; $data = getSettings($userid); $useremail = $data->email; $userfriendlyemail = $data->friendlyemail; $userbcc = $data->bcc; if ($userbcc != 1) { //it is a no, blank it $userbcc = ""; } else { $userbcc = $useremail; } $template = $_POST['template']; $regid = $_POST['regid']; $tbl = "registration"; //grab the message to be sent if (!$cancelProcess) { $result = mysql_query("SELECT CustomMessageBody,EmailAddress FROM " . $tbl . " WHERE regid='" . $regid . "'");
function import_sql($source, $result_code = 'import_ok') { global $modx, $e; $tbl_active_users = $modx->getFullTableName('active_users'); $rs = $modx->db->select('count(*)', $tbl_active_users, "action='27'"); if (0 < $modx->db->getValue($rs)) { $modx->webAlertAndQuit("Resource is edit now by any user."); } $settings = getSettings(); if (strpos($source, "\r") !== false) { $source = str_replace(array("\r\n", "\n", "\r"), "\n", $source); } $sql_array = preg_split('@;[ \\t]*\\n@', $source); foreach ($sql_array as $sql_entry) { $sql_entry = trim($sql_entry, "\r\n; "); if (empty($sql_entry)) { continue; } $rs = $modx->db->query($sql_entry); } restoreSettings($settings); $modx->clearCache(); $_SESSION['last_result'] = $modx->db->makeArray($rs); $_SESSION['result_msg'] = $result_code; }
<?php $data_setting = array('group' => 'page'); $settings = getSettings($data_setting); if ($settings) { foreach ($settings as $setting) { if ($setting['key'] == 'security') { $security = $setting['value']; } } } $title = $lang['head_security']; ?> <h5><?php echo $lang['head_security']; ?> </h5> <article class="auction_container"> <?php echo $security; ?> <img class="bottom" src="includes/images/bottom/security.png" alt="security"> </article>
function updateSettings($datas) { foreach ($datas as $data) { $data_setting = array('group' => $data['group'], 'Key' => $data['Key'], 'Value' => $data['Value']); $settings = getSettings($data_setting); if (count($settings) > 0) { $query = editSettings($data_setting); } else { $query = insertSettings($data_setting); } } if ($query) { return true; } return false; }
/** * Stores test information to * the database for the first time. * * @param $jsonQuestions | string * * @return void * */ function createTest($jsonQuestions) { // date_default_timezone_set("UTC"); $test_id = ""; $user_id = $_SESSION['user_id']; $duration = getSettings()[0]['duration']; $startedAt = date('Y-m-d H:i:s'); $data = ['user_id' => $user_id, 'started_at' => $startedAt, 'json' => $jsonQuestions, 'duration' => $duration]; if (insert('test_info', $data)) { return mysql_insert_id(); } return false; }
function id_projectGrid($attrs) { ob_start(); if (isset($attrs['columns'])) { $wide = $attrs['columns']; } else { $wide = 3; } $width = 90 / $wide; $margin = 10 / ($wide - 1); if (isset($attrs['max'])) { $max = $attrs['max']; } else { $max = null; } // project category if (isset($attrs['category'])) { $category = $attrs['category']; $args = array('post_type' => 'ignition_product', 'tax_query' => array(array('taxonomy' => 'project_category', 'field' => 'id', 'terms' => $category))); } else { // in case category isn't defined, query args must contain post type $args['post_type'] = 'ignition_product'; } if (isset($max)) { $args['posts_per_page'] = $max; } // --> Custom args - START // orderby possible values - days_left, percent_raised, funds_raised, rand, title, date (default) if (isset($attrs['orderby'])) { if ($attrs['orderby'] == 'days_left') { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = 'ign_days_left'; } else { if ($attrs['orderby'] == 'percent_raised') { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = 'ign_percent_raised'; } else { if ($attrs['orderby'] == 'funds_raised') { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = 'ign_fund_raised'; } else { // reserved for later use $args['orderby'] = $attrs['orderby']; } } } } // order possible values = ASC, DESC (default) if (isset($attrs['order'])) { $args['order'] = $attrs['order']; } // author (single name) if (isset($attrs['author'])) { $args['author_name'] = $attrs['author']; } // --> Custom args - END // moved this block before the query call require 'languages/text_variables.php'; $custom = false; if (isset($attrs['deck'])) { $deck_id = $attrs['deck']; $settings = Deck::get_deck_attrs($deck_id); if (!empty($settings)) { $attrs = unserialize($settings->attributes); $custom = true; } } // start the actual query, which will also output decks $posts = get_posts($args); $project_ids = array(); echo '<div class="ignitiondeck"><div class="grid_wrap" data-wide="' . $wide . '">'; $i = 1; foreach ($posts as $post) { $post_id = $post->ID; $project_id = get_post_meta($post_id, 'ign_project_id', true); // no more "pass" checks are required, because the query gets all proper projects in proper order and settings $deck = new Deck($project_id); $mini_deck = $deck->mini_deck(); $post_id = $deck->get_project_postid(); $status = get_post_status($post_id); $custom = apply_filters('idcf_custom_deck', $custom, $post_id); $attrs = apply_filters('idcf_deck_attrs', isset($attrs) ? $attrs : null, $post_id); if (strtoupper($status) == 'PUBLISH') { $settings = getSettings(); echo '<div class="grid_item" style="float: left; margin: 0 ' . $margin . '% ' . $margin . '% 0; width: ' . $width . '%;">'; include 'templates/_miniWidget.php'; echo '</div>'; $i++; } } // end with query and continue with original code echo '</div></div>'; echo '<br style="clear: both"/>'; $grid = ob_get_contents(); ob_end_clean(); return $grid; }
<?php /*! * ************************************************************** **************** ProQuiz V2 ****************************** ***************************************************************/ /* documentation at: http://proquiz.softon.org/documentation/ /* Designed & Maintained by /* - Softon Technologies /* Developer /* - Manzovi /* For Support Contact @ /* - proquiz@softon.org /* Release Date : 02 Feb 2011 /* Licensed under GPL license: /* http://www.gnu.org/licenses/gpl.html */ include_once 'functions.php'; if (empty($_SESSION['UA_DETAILS'])) { header('Location:login.php?error=take_quiz'); } elseif (getSettings($db, 'custquiz') != '1') { if (getSettParam($db, 'custquiz') != 'installed') { header('Location:quiz_menu.php?error=quiz_notinstalled'); } else { header('Location:quiz_menu.php?error=quiz_disabled'); } } elseif (getSettParam($db, 'custquiz') != 'installed') { header('Location:quiz_menu.php?error=quiz_notinstalled'); }
$_SESSION['cP'] = $set['defaultView']; } else { //internal hit //connect to db $dbPfix = dbConnect(); //test session if (isset($_SESSION['cal'])) { //active $calID = $_SESSION['cal']; } else { //expired, get cal & user ID $calID = $_SESSION['cal'] = isset($_COOKIE['LCALcid']) ? @unserialize($_COOKIE['LCALcid']) : $dbPfix; $_SESSION['uid'] = isset($_COOKIE['LCALuid']) ? @unserialize($_COOKIE['LCALuid']) : 1; } //get settings from database $set = getSettings(); } //set time zone date_default_timezone_set($set['timeZone']); //load session data from db if ($set['restLastSel']) { loadSession($sessID, $calID); } //echo "sessID: ".$sessID." / calID: ".$calID." / restLastSel: ".$set['restLastSel']." / cP: ".$_SESSION['cP']; //test //after login bake is set (1:bake, -1:eat cookie) if (isset($_REQUEST['bake'])) { setcookie('LCALuid', serialize($_SESSION['uid']), time() + 86400 * $set['cookieExp'] * $_REQUEST['bake']); //set or refresh saveSession($sessID, $calID, $_REQUEST['bake']); } //check for mobile browsers
<?php include "../includes/config.php"; include "../includes/classes.php"; include getLanguage(null, !empty($_GET['lang']) ? $_GET['lang'] : $_COOKIE['lang'], 2); session_start(); $db = new mysqli($CONF['host'], $CONF['user'], $CONF['pass'], $CONF['name']); if ($db->connect_errno) { echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error; } $db->set_charset("utf8"); $resultSettings = $db->query(getSettings()); $settings = $resultSettings->fetch_assoc(); if (isset($_SESSION['usernameAdmin']) && isset($_SESSION['passwordAdmin'])) { $loggedInAdmin = new loggedInAdmin(); $loggedInAdmin->db = $db; $loggedInAdmin->url = $CONF['url']; $loggedInAdmin->username = $_SESSION['usernameAdmin']; $loggedInAdmin->password = $_SESSION['passwordAdmin']; $loggedIn = $loggedInAdmin->verify(); if ($loggedIn['username']) { $managePayments = new managePayments(); $managePayments->db = $db; $managePayments->url = $CONF['url']; $managePayments->per_page = $settings['rperpage']; if (isset($_POST['start'])) { echo $managePayments->getPayments($_POST['start']); } } }
* twitteroauthsec */ } } if(!$result){ $settingRes['db']=$db->lastErrorMsg(); } else{ $settingRes['db']=$db->changes().' Record updated successfully.'; } $db->close(); return $settingRes; } $settingRes=getSettings(); #Add columns to settings DB if not already there # 5/30/14 - tasubgroupopt #custom | for_any_group | for_all_group # tasubgroup # Group ID# # 4/24/15 - critsPlugin # 1 for activate CRITs, 0 for no CRITs # critsPage # IP address/hostname of CRITs instance API # critsLogin # username=<username>&api_key=<apikey> function addColumn($settingRes,$newColName,$newColVal){ if(!isset($settingRes[$newColName])){ $db=new SQLite3('./admin/admin.db'); $altercmd = 'ALTER TABLE admin ADD COLUMN '.$newColName.' TEXT'; $result = $db->exec($altercmd); if(!$result){ $settingRes['dbmod']=$db->lastErrorMsg(); }
<?php /*! * ************************************************************** **************** ProQuiz V2 ****************************** ***************************************************************/ /* documentation at: http://proquiz.softon.org/documentation/ /* Designed & Maintained by /* - Softon Technologies /* Developer /* - Manzovi /* For Support Contact @ /* - proquiz@softon.org /* Release Date : 02 Feb 2011 /* Licensed under GPL license: /* http://www.gnu.org/licenses/gpl.html */ include_once 'functions.php'; if (empty($_SESSION['UA_DETAILS'])) { header('Location:login.php?error=take_quiz'); } elseif (getSettings($db, 'lquiz') != '1') { if (getSettParam($db, 'lquiz') != 'installed') { header('Location:quiz_menu.php?error=quiz_notinstalled'); } else { header('Location:quiz_menu.php?error=quiz_disabled'); } } elseif (getSettParam($db, 'lquiz') != 'installed') { header('Location:quiz_menu.php?error=quiz_notinstalled'); }
public function index($isExchange = FALSE) { $translation = $this->session->userdata('translation'); $po_table = ''; $name = $translation['name']; $type = $translation['type']; $lang = $translation['lang']; if ($translation && $name && $type && $lang) { if (!$isExchange) { $po_table = $this->renderModulePoFile($name, $type, $lang); } else { $po_table = $this->exchangePoArray; } } $this->getExistingLocales(); \CMSFactory\assetManager::create()->registerScript('admin')->registerStyle('admin')->setData('langs', $this->langs)->setData('settings', getSettings())->setData('languages_names', get_language_names())->setData('editorStyles', getEditorStyles())->renderAdmin('list'); if ($translation) { $names = ''; switch ($type) { case 'modules': $names = $this->renderModulesNames($lang); break; case 'templates': $names = $this->renderTemplatesNames($lang); break; } $names = trim(preg_replace('/\\s\\s+/', ' ', $names)); $names = preg_replace('/<link[\\W\\w]+\\/>/', '', $names); $names = preg_replace('/<script[\\W\\w]+<\\/script>/', '', $names); $data = trim(preg_replace('/\\s\\s+/', ' ', $po_table)); jsCode("Translator.start(" . json_encode($data) . "," . json_encode($names) . ", '" . $type . "', '" . $lang . "', '" . $name . "');"); } else { jsCode("Translator.render('');"); } }
function antiHack($db, $quiz) { $threshold = getSettings($db, 'ahthold'); $detT = $quiz['PARAMS']['total_time'] * 60 + $threshold - ($quiz['PARAMS']['quiz_end_ts'] - $quiz['PARAMS']['quiz_start_ts']); if ($detT < 0) { // Delete Record if (getSettings($db, 'delrecord')) { $this->delRecord($db, $quiz['PARAMS']['instid']); } // Deactivate User if (getSettings($db, 'deactuser') && $_SESSION['UA_DETAILS']['level'] != 'admin') { $this->deactUser($db, $quiz['PARAMS']['user']); } return false; } else { return true; } }
/** * refreshLibrary function. * * @access public * @param mixed $w * @return void */ function refreshLibrary($w) { if (!file_exists($w->data() . '/library.db')) { displayNotificationWithArtwork("Refresh library called while library does not exist", './images/warning.png'); return; } touch($w->data() . "/update_library_in_progress"); $w->write('InitRefreshLibrary▹' . 0 . '▹' . 0 . '▹' . time() . '▹' . 'starting', 'update_library_in_progress'); $in_progress_data = $w->read('update_library_in_progress'); // // Read settings from JSON // $settings = getSettings($w); $country_code = $settings->country_code; $userid = $settings->userid; $words = explode('▹', $in_progress_data); putenv('LANG=fr_FR.UTF-8'); ini_set('memory_limit', '512M'); $nb_playlist = 0; // db for fetch artworks $fetch_artworks_existed = true; $dbfile = $w->data() . '/fetch_artworks.db'; if (!file_exists($dbfile)) { touch($dbfile); $fetch_artworks_existed = false; } // kill previous process if running $pid = exec("ps -efx | grep \"php\" | egrep \"DOWNLOAD_ARTWORKS\" | grep -v grep | awk '{print \$2}'"); if ($pid != "") { logMsg("KILL Download daemon <{$pid}>"); $ret = exec("kill -9 \"{$pid}\""); } if (file_exists($w->data() . '/download_artworks_in_progress')) { deleteTheFile($w->data() . '/download_artworks_in_progress'); } try { $dbartworks = new PDO("sqlite:{$dbfile}", "", "", array(PDO::ATTR_PERSISTENT => true)); $dbartworks->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($dbartworks, $w); $dbartworks = null; $db = null; return false; } // DB artowrks if ($fetch_artworks_existed == false) { try { $dbartworks->exec("create table artists (artist_name text PRIMARY KEY NOT NULL, already_fetched boolean)"); $dbartworks->exec("create table tracks (track_uri text PRIMARY KEY NOT NULL, already_fetched boolean)"); $dbartworks->exec("create table albums (album_uri text PRIMARY KEY NOT NULL, already_fetched boolean)"); } catch (PDOException $e) { logMsg("Error(updateLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($dbartworks, $w); $dbartworks = null; $db = null; return false; } } try { // artworks $insertArtistArtwork = "insert or ignore into artists values (:artist_name,:already_fetched)"; $stmtArtistArtwork = $dbartworks->prepare($insertArtistArtwork); $insertTrackArtwork = "insert or ignore into tracks values (:track_uri,:already_fetched)"; $stmtTrackArtwork = $dbartworks->prepare($insertTrackArtwork); $insertAlbumArtwork = "insert or ignore into albums values (:album_uri,:already_fetched)"; $stmtAlbumArtwork = $dbartworks->prepare($insertAlbumArtwork); } catch (PDOException $e) { logMsg("Error(updateLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($dbartworks, $w); $dbartworks = null; $db = null; return false; } $artworksToDownload = false; rename($w->data() . '/library.db', $w->data() . '/library_old.db'); copy($w->data() . '/library_old.db', $w->data() . '/library_new.db'); $dbfile = $w->data() . '/library_new.db'; $nb_added_playlists = 0; $nb_removed_playlists = 0; $nb_updated_playlists = 0; try { $db = new PDO("sqlite:{$dbfile}", "", "", array(PDO::ATTR_PERSISTENT => true)); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->exec("drop table counters"); $db->exec("create table counters (all_tracks int, yourmusic_tracks int, all_artists int, yourmusic_artists int, all_albums int, yourmusic_albums int, playlists int)"); $getPlaylists = "select * from playlists where uri=:uri"; $stmtGetPlaylists = $db->prepare($getPlaylists); $insertPlaylist = "insert into playlists values (:uri,:name,:nb_tracks,:owner,:username,:playlist_artwork_path,:ownedbyuser,:nb_playable_tracks,:duration_playlist,:nb_times_played,:collaborative,:public)"; $stmtPlaylist = $db->prepare($insertPlaylist); $insertTrack = "insert into tracks values (:yourmusic,:popularity,:uri,:album_uri,:artist_uri,:track_name,:album_name,:artist_name,:album_type,:track_artwork_path,:artist_artwork_path,:album_artwork_path,:playlist_name,:playlist_uri,:playable,:added_at,:duration,:nb_times_played,:local_track)"; $stmtTrack = $db->prepare($insertTrack); $deleteFromTracks = "delete from tracks where playlist_uri=:playlist_uri"; $stmtDeleteFromTracks = $db->prepare($deleteFromTracks); $updatePlaylistsNbTracks = "update playlists set nb_tracks=:nb_tracks,nb_playable_tracks=:nb_playable_tracks,duration_playlist=:duration_playlist,public=:public where uri=:uri"; $stmtUpdatePlaylistsNbTracks = $db->prepare($updatePlaylistsNbTracks); $deleteFromTracksYourMusic = "delete from tracks where yourmusic=:yourmusic"; $stmtDeleteFromTracksYourMusic = $db->prepare($deleteFromTracksYourMusic); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } $savedListPlaylist = array(); $offsetGetUserPlaylists = 0; $limitGetUserPlaylists = 50; do { $retry = true; $nb_retry = 0; $api = getSpotifyWebAPI($w); while ($retry) { try { // refresh api $api = getSpotifyWebAPI($w, $api); $userPlaylists = $api->getUserPlaylists(urlencode($userid), array('limit' => $limitGetUserPlaylists, 'offset' => $offsetGetUserPlaylists)); $retry = false; } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { logMsg("Error(getUserPlaylists): retry " . $nb_retry . " (exception " . print_r($e) . ")"); if ($e->getCode() == 429 || $e->getCode() == 404 || $e->getCode() == 500 || $e->getCode() == 502 || $e->getCode() == 503 || $e->getCode() == 0) { // retry if ($nb_retry > 10) { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } $nb_retry++; sleep(5); } else { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } } } $nb_playlist_total = $userPlaylists->total; foreach ($userPlaylists->items as $playlist) { if ($playlist->name != "") { $savedListPlaylist[] = $playlist; } } $offsetGetUserPlaylists += $limitGetUserPlaylists; } while ($offsetGetUserPlaylists < $userPlaylists->total); // consider Your Music as a playlist for progress bar $nb_playlist_total++; foreach ($savedListPlaylist as $playlist) { $tracks = $playlist->tracks; $owner = $playlist->owner; $nb_playlist++; $w->write('Refresh Library▹' . $nb_playlist . '▹' . $nb_playlist_total . '▹' . $words[3] . '▹' . escapeQuery($playlist->name), 'update_library_in_progress'); try { // Loop on existing playlists in library $stmtGetPlaylists->bindValue(':uri', $playlist->uri); $stmtGetPlaylists->execute(); $noresult = true; while ($playlists = $stmtGetPlaylists->fetch()) { $noresult = false; break; } } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } // Playlist does not exist, add it if ($noresult == true) { $nb_added_playlists++; $playlist_artwork_path = getPlaylistArtwork($w, $playlist->uri, true, true); if ("-" . $owner->id . "-" == "-" . $userid . "-") { $ownedbyuser = 1; } else { $ownedbyuser = 0; } $nb_track_playlist = 0; $duration_playlist = 0; $offsetGetUserPlaylistTracks = 0; $limitGetUserPlaylistTracks = 100; do { $retry = true; $nb_retry = 0; while ($retry) { try { // refresh api $api = getSpotifyWebAPI($w, $api); $userPlaylistTracks = $api->getUserPlaylistTracks(urlencode($owner->id), $playlist->id, array('fields' => array('total', 'items(added_at)', 'items(is_local)', 'items.track(is_playable,duration_ms,uri,popularity,name)', 'items.track.album(album_type,images,uri,name)', 'items.track.artists(name,uri)'), 'limit' => $limitGetUserPlaylistTracks, 'offset' => $offsetGetUserPlaylistTracks, 'market' => $country_code)); $retry = false; } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { logMsg("Error(getUserPlaylistTracks): retry " . $nb_retry . " (exception " . print_r($e) . ")"); if ($e->getCode() == 429 || $e->getCode() == 404 || $e->getCode() == 500 || $e->getCode() == 502 || $e->getCode() == 503 || $e->getCode() == 0) { // retry if ($nb_retry > 10) { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } $nb_retry++; sleep(5); } else { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } } } foreach ($userPlaylistTracks->items as $item) { $track = $item->track; $artists = $track->artists; $artist = $artists[0]; $album = $track->album; $playable = 0; $local_track = 0; if (isset($track->is_playable) && $track->is_playable) { $playable = 1; } if (isset($item->is_local) && $item->is_local) { $playable = 1; $local_track = 1; } try { // // Download artworks in Fetch later mode $thetrackuri = 'spotify:track:faketrackuri'; if ($local_track == 0 && isset($track->uri)) { $thetrackuri = $track->uri; } list($already_present, $track_artwork_path) = getTrackOrAlbumArtwork($w, $thetrackuri, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtTrackArtwork->bindValue(':track_uri', $thetrackuri); $stmtTrackArtwork->bindValue(':already_fetched', 0); $stmtTrackArtwork->execute(); } $theartistname = 'fakeartist'; if (isset($artist->name)) { $theartistname = $artist->name; } list($already_present, $artist_artwork_path) = getArtistArtwork($w, $theartistname, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtArtistArtwork->bindValue(':artist_name', $theartistname); $stmtArtistArtwork->bindValue(':already_fetched', 0); $stmtArtistArtwork->execute(); } $thealbumuri = 'spotify:album:fakealbumuri'; if (isset($album->uri)) { $thealbumuri = $album->uri; } list($already_present, $album_artwork_path) = getTrackOrAlbumArtwork($w, $thealbumuri, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtAlbumArtwork->bindValue(':album_uri', $thealbumuri); $stmtAlbumArtwork->bindValue(':already_fetched', 0); $stmtAlbumArtwork->execute(); } } catch (PDOException $e) { logMsg("Error(updateLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($dbartworks, $w); $dbartworks = null; $db = null; return false; } $duration_playlist += $track->duration_ms; try { $stmtTrack->bindValue(':yourmusic', 0); $stmtTrack->bindValue(':popularity', $track->popularity); $stmtTrack->bindValue(':uri', $track->uri); $stmtTrack->bindValue(':album_uri', $album->uri); $stmtTrack->bindValue(':artist_uri', $artist->uri); $stmtTrack->bindValue(':track_name', escapeQuery($track->name)); $stmtTrack->bindValue(':album_name', escapeQuery($album->name)); $stmtTrack->bindValue(':artist_name', escapeQuery($artist->name)); $stmtTrack->bindValue(':album_type', $album->album_type); $stmtTrack->bindValue(':track_artwork_path', $track_artwork_path); $stmtTrack->bindValue(':artist_artwork_path', $artist_artwork_path); $stmtTrack->bindValue(':album_artwork_path', $album_artwork_path); $stmtTrack->bindValue(':playlist_name', escapeQuery($playlist->name)); $stmtTrack->bindValue(':playlist_uri', $playlist->uri); $stmtTrack->bindValue(':playable', $playable); $stmtTrack->bindValue(':added_at', $item->added_at); $stmtTrack->bindValue(':duration', beautifyTime($track->duration_ms / 1000)); $stmtTrack->bindValue(':nb_times_played', 0); $stmtTrack->bindValue(':local_track', $local_track); $stmtTrack->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } $nb_track_playlist++; } $offsetGetUserPlaylistTracks += $limitGetUserPlaylistTracks; } while ($offsetGetUserPlaylistTracks < $userPlaylistTracks->total); try { $stmtPlaylist->bindValue(':uri', $playlist->uri); $stmtPlaylist->bindValue(':name', escapeQuery($playlist->name)); $stmtPlaylist->bindValue(':nb_tracks', $tracks->total); $stmtPlaylist->bindValue(':owner', $owner->id); $stmtPlaylist->bindValue(':username', $owner->id); $stmtPlaylist->bindValue(':playlist_artwork_path', $playlist_artwork_path); $stmtPlaylist->bindValue(':ownedbyuser', $ownedbyuser); $stmtPlaylist->bindValue(':nb_playable_tracks', $nb_track_playlist); $stmtPlaylist->bindValue(':duration_playlist', beautifyTime($duration_playlist / 1000, true)); $stmtPlaylist->bindValue(':nb_times_played', 0); $stmtPlaylist->bindValue(':collaborative', $playlist->collaborative); $stmtPlaylist->bindValue(':public', $playlist->public); $stmtPlaylist->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } displayNotificationWithArtwork('Added playlist ' . escapeQuery($playlist->name), $playlist_artwork_path, 'Refresh Library'); } else { // number of tracks has changed or playlist name has changed or the privacy has changed // update the playlist if ($playlists[2] != $tracks->total || $playlists[1] != escapeQuery($playlist->name) || ($playlists[11] == '' && $playlist->public == true || $playlists[11] == true && $playlist->public == '')) { $nb_updated_playlists++; // force refresh of playlist artwork getPlaylistArtwork($w, $playlist->uri, true, true); try { if ($playlists[1] != escapeQuery($playlist->name)) { $updatePlaylistsName = "update playlists set name=:name where uri=:uri"; $stmtUpdatePlaylistsName = $db->prepare($updatePlaylistsName); $stmtUpdatePlaylistsName->bindValue(':name', escapeQuery($playlist->name)); $stmtUpdatePlaylistsName->bindValue(':uri', $playlist->uri); $stmtUpdatePlaylistsName->execute(); } $stmtDeleteFromTracks->bindValue(':playlist_uri', $playlist->uri); $stmtDeleteFromTracks->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } $tmp = explode(':', $playlist->uri); $duration_playlist = 0; $nb_track_playlist = 0; $offsetGetUserPlaylistTracks = 0; $limitGetUserPlaylistTracks = 100; do { $retry = true; $nb_retry = 0; while ($retry) { try { // refresh api $api = getSpotifyWebAPI($w, $api); $userPlaylistTracks = $api->getUserPlaylistTracks(urlencode($tmp[2]), $tmp[4], array('fields' => array('total', 'items(added_at)', 'items(is_local)', 'items.track(is_playable,duration_ms,uri,popularity,name)', 'items.track.album(album_type,images,uri,name)', 'items.track.artists(name,uri)'), 'limit' => $limitGetUserPlaylistTracks, 'offset' => $offsetGetUserPlaylistTracks, 'market' => $country_code)); $retry = false; } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { logMsg("Error(getUserPlaylistTracks): retry " . $nb_retry . " (exception " . print_r($e) . ")"); if ($e->getCode() == 429 || $e->getCode() == 404 || $e->getCode() == 500 || $e->getCode() == 502 || $e->getCode() == 503 || $e->getCode() == 0) { // retry if ($nb_retry > 10) { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } $nb_retry++; sleep(5); } else { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } } } foreach ($userPlaylistTracks->items as $item) { $track = $item->track; $artists = $track->artists; $artist = $artists[0]; $album = $track->album; $playable = 0; $local_track = 0; if (isset($track->is_playable) && $track->is_playable) { $playable = 1; } if (isset($item->is_local) && $item->is_local) { $playable = 1; $local_track = 1; } try { // // Download artworks in Fetch later mode $thetrackuri = 'spotify:track:faketrackuri'; if ($local_track == 0 && isset($track->uri)) { $thetrackuri = $track->uri; } list($already_present, $track_artwork_path) = getTrackOrAlbumArtwork($w, $thetrackuri, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtTrackArtwork->bindValue(':track_uri', $thetrackuri); $stmtTrackArtwork->bindValue(':already_fetched', 0); $stmtTrackArtwork->execute(); } $theartistname = 'fakeartist'; if (isset($artist->name)) { $theartistname = $artist->name; } list($already_present, $artist_artwork_path) = getArtistArtwork($w, $theartistname, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtArtistArtwork->bindValue(':artist_name', $theartistname); $stmtArtistArtwork->bindValue(':already_fetched', 0); $stmtArtistArtwork->execute(); } $thealbumuri = 'spotify:album:fakealbumuri'; if (isset($album->uri)) { $thealbumuri = $album->uri; } list($already_present, $album_artwork_path) = getTrackOrAlbumArtwork($w, $thealbumuri, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtAlbumArtwork->bindValue(':album_uri', $thealbumuri); $stmtAlbumArtwork->bindValue(':already_fetched', 0); $stmtAlbumArtwork->execute(); } } catch (PDOException $e) { logMsg("Error(updateLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($dbartworks, $w); $dbartworks = null; $db = null; return false; } $duration_playlist += $track->duration_ms; try { $stmtTrack->bindValue(':yourmusic', 0); $stmtTrack->bindValue(':popularity', $track->popularity); $stmtTrack->bindValue(':uri', $track->uri); $stmtTrack->bindValue(':album_uri', $album->uri); $stmtTrack->bindValue(':artist_uri', $artist->uri); $stmtTrack->bindValue(':track_name', escapeQuery($track->name)); $stmtTrack->bindValue(':album_name', escapeQuery($album->name)); $stmtTrack->bindValue(':artist_name', escapeQuery($artist->name)); $stmtTrack->bindValue(':album_type', $album->album_type); $stmtTrack->bindValue(':track_artwork_path', $track_artwork_path); $stmtTrack->bindValue(':artist_artwork_path', $artist_artwork_path); $stmtTrack->bindValue(':album_artwork_path', $album_artwork_path); $stmtTrack->bindValue(':playlist_name', escapeQuery($playlist->name)); $stmtTrack->bindValue(':playlist_uri', $playlist->uri); $stmtTrack->bindValue(':playable', $playable); $stmtTrack->bindValue(':added_at', $item->added_at); $stmtTrack->bindValue(':duration', beautifyTime($track->duration_ms / 1000)); $stmtTrack->bindValue(':nb_times_played', 0); $stmtTrack->bindValue(':local_track', $local_track); $stmtTrack->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } $nb_track_playlist++; } $offsetGetUserPlaylistTracks += $limitGetUserPlaylistTracks; } while ($offsetGetUserPlaylistTracks < $userPlaylistTracks->total); try { $stmtUpdatePlaylistsNbTracks->bindValue(':nb_tracks', $userPlaylistTracks->total); $stmtUpdatePlaylistsNbTracks->bindValue(':nb_playable_tracks', $nb_track_playlist); $stmtUpdatePlaylistsNbTracks->bindValue(':duration_playlist', beautifyTime($duration_playlist / 1000, true)); $stmtUpdatePlaylistsNbTracks->bindValue(':uri', $playlist->uri); $stmtUpdatePlaylistsNbTracks->bindValue(':public', $playlist->public); $stmtUpdatePlaylistsNbTracks->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } displayNotificationWithArtwork('Updated playlist ' . escapeQuery($playlist->name), getPlaylistArtwork($w, $playlist->uri, true), 'Refresh Library'); } else { continue; } } } try { // check for deleted playlists $getPlaylists = "select * from playlists"; $stmt = $db->prepare($getPlaylists); $stmt->execute(); while ($playlist_in_db = $stmt->fetch()) { $found = false; foreach ($savedListPlaylist as $playlist) { if ($playlist->uri == $playlist_in_db[0]) { $found = true; break; } } if ($found == false) { $nb_removed_playlists++; $deleteFromPlaylist = "delete from playlists where uri=:uri"; $stmtDelete = $db->prepare($deleteFromPlaylist); $stmtDelete->bindValue(':uri', $playlist_in_db[0]); $stmtDelete->execute(); $deleteFromTracks = "delete from tracks where playlist_uri=:uri"; $stmtDelete = $db->prepare($deleteFromTracks); $stmtDelete->bindValue(':uri', $playlist_in_db[0]); $stmtDelete->execute(); displayNotificationWithArtwork('Removed playlist ' . $playlist_in_db[1], getPlaylistArtwork($w, $playlist_in_db[0], false), 'Refresh Library'); } } } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return; } // check for update to Your Music $retry = true; $nb_retry = 0; while ($retry) { try { // refresh api $api = getSpotifyWebAPI($w, $api); // get only one, we just want to check total for now $userMySavedTracks = $api->getMySavedTracks(array('limit' => 1, 'offset' => 0)); $retry = false; } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { logMsg("Error(getMySavedTracks): retry " . $nb_retry . " (exception " . print_r($e) . ")"); if ($e->getCode() == 429 || $e->getCode() == 404 || $e->getCode() == 500 || $e->getCode() == 502 || $e->getCode() == 503 || $e->getCode() == 0) { // retry if ($nb_retry > 10) { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } $nb_retry++; sleep(5); } else { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } } } try { // get current number of track in Your Music $getCount = 'select count(distinct uri) from tracks where yourmusic=1'; $stmt = $db->prepare($getCount); $stmt->execute(); $yourmusic_tracks = $stmt->fetch(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $db = null; return; } $your_music_updated = false; if ($yourmusic_tracks[0] != $userMySavedTracks->total) { $your_music_updated = true; // Your Music has changed, update it $nb_playlist++; $w->write('Refresh Library▹' . $nb_playlist . '▹' . $nb_playlist_total . '▹' . $words[3] . '▹' . 'Your Music', 'update_library_in_progress'); // delete tracks try { $stmtDeleteFromTracksYourMusic->bindValue(':yourmusic', 1); $stmtDeleteFromTracksYourMusic->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $db = null; return; } $offsetGetMySavedTracks = 0; $limitGetMySavedTracks = 50; do { $retry = true; $nb_retry = 0; while ($retry) { try { // refresh api $api = getSpotifyWebAPI($w, $api); $userMySavedTracks = $api->getMySavedTracks(array('limit' => $limitGetMySavedTracks, 'offset' => $offsetGetMySavedTracks, 'market' => $country_code)); $retry = false; } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { logMsg("Error(getMySavedTracks): retry " . $nb_retry . " (exception " . print_r($e) . ")"); if ($e->getCode() == 429 || $e->getCode() == 404 || $e->getCode() == 500 || $e->getCode() == 502 || $e->getCode() == 503 || $e->getCode() == 0) { // retry if ($nb_retry > 10) { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } $nb_retry++; sleep(5); } else { handleSpotifyWebAPIException($w, $e); $retry = false; return false; } } } foreach ($userMySavedTracks->items as $item) { $track = $item->track; $artists = $track->artists; $artist = $artists[0]; $album = $track->album; $playable = 0; $local_track = 0; if (isset($track->is_playable) && $track->is_playable) { $playable = 1; } if (isset($item->is_local) && $item->is_local) { $playable = 1; $local_track = 1; } try { // // Download artworks in Fetch later mode $thetrackuri = 'spotify:track:faketrackuri'; if ($local_track == 0 && isset($track->uri)) { $thetrackuri = $track->uri; } list($already_present, $track_artwork_path) = getTrackOrAlbumArtwork($w, $thetrackuri, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtTrackArtwork->bindValue(':track_uri', $thetrackuri); $stmtTrackArtwork->bindValue(':already_fetched', 0); $stmtTrackArtwork->execute(); } $theartistname = 'fakeartist'; if (isset($artist->name)) { $theartistname = $artist->name; } list($already_present, $artist_artwork_path) = getArtistArtwork($w, $theartistname, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtArtistArtwork->bindValue(':artist_name', $theartistname); $stmtArtistArtwork->bindValue(':already_fetched', 0); $stmtArtistArtwork->execute(); } $thealbumuri = 'spotify:album:fakealbumuri'; if (isset($album->uri)) { $thealbumuri = $album->uri; } list($already_present, $album_artwork_path) = getTrackOrAlbumArtwork($w, $thealbumuri, true, true); if ($already_present == false) { $artworksToDownload = true; $stmtAlbumArtwork->bindValue(':album_uri', $thealbumuri); $stmtAlbumArtwork->bindValue(':already_fetched', 0); $stmtAlbumArtwork->execute(); } } catch (PDOException $e) { logMsg("Error(updateLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($dbartworks, $w); $dbartworks = null; $db = null; return false; } try { $stmtTrack->bindValue(':yourmusic', 1); $stmtTrack->bindValue(':popularity', $track->popularity); $stmtTrack->bindValue(':uri', $track->uri); $stmtTrack->bindValue(':album_uri', $album->uri); $stmtTrack->bindValue(':artist_uri', $artist->uri); $stmtTrack->bindValue(':track_name', escapeQuery($track->name)); $stmtTrack->bindValue(':album_name', escapeQuery($album->name)); $stmtTrack->bindValue(':artist_name', escapeQuery($artist->name)); $stmtTrack->bindValue(':album_type', $album->album_type); $stmtTrack->bindValue(':track_artwork_path', $track_artwork_path); $stmtTrack->bindValue(':artist_artwork_path', $artist_artwork_path); $stmtTrack->bindValue(':album_artwork_path', $album_artwork_path); $stmtTrack->bindValue(':playlist_name', ''); $stmtTrack->bindValue(':playlist_uri', ''); $stmtTrack->bindValue(':playable', $playable); $stmtTrack->bindValue(':added_at', $item->added_at); $stmtTrack->bindValue(':duration', beautifyTime($track->duration_ms / 1000)); $stmtTrack->bindValue(':nb_times_played', 0); $stmtTrack->bindValue(':local_track', $local_track); $stmtTrack->execute(); } catch (PDOException $e) { logMsg("Error(refreshLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $db = null; return; } } $offsetGetMySavedTracks += $limitGetMySavedTracks; } while ($offsetGetMySavedTracks < $userMySavedTracks->total); } // update counters try { $getCount = 'select count(distinct uri) from tracks'; $stmt = $db->prepare($getCount); $stmt->execute(); $all_tracks = $stmt->fetch(); $getCount = 'select count(distinct uri) from tracks where yourmusic=1'; $stmt = $db->prepare($getCount); $stmt->execute(); $yourmusic_tracks = $stmt->fetch(); $getCount = 'select count(distinct artist_name) from tracks'; $stmt = $db->prepare($getCount); $stmt->execute(); $all_artists = $stmt->fetch(); $getCount = 'select count(distinct artist_name) from tracks where yourmusic=1'; $stmt = $db->prepare($getCount); $stmt->execute(); $yourmusic_artists = $stmt->fetch(); $getCount = 'select count(distinct album_name) from tracks'; $stmt = $db->prepare($getCount); $stmt->execute(); $all_albums = $stmt->fetch(); $getCount = 'select count(distinct album_name) from tracks where yourmusic=1'; $stmt = $db->prepare($getCount); $stmt->execute(); $yourmusic_albums = $stmt->fetch(); $getCount = 'select count(*) from playlists'; $stmt = $db->prepare($getCount); $stmt->execute(); $playlists_count = $stmt->fetch(); $insertCounter = "insert into counters values (:all_tracks,:yourmusic_tracks,:all_artists,:yourmusic_artists,:all_albums,:yourmusic_albums,:playlists)"; $stmt = $db->prepare($insertCounter); $stmt->bindValue(':all_tracks', $all_tracks[0]); $stmt->bindValue(':yourmusic_tracks', $yourmusic_tracks[0]); $stmt->bindValue(':all_artists', $all_artists[0]); $stmt->bindValue(':yourmusic_artists', $yourmusic_artists[0]); $stmt->bindValue(':all_albums', $all_albums[0]); $stmt->bindValue(':yourmusic_albums', $yourmusic_albums[0]); $stmt->bindValue(':playlists', $playlists_count[0]); $stmt->execute(); } catch (PDOException $e) { logMsg("Error(updateLibrary): (exception " . print_r($e) . ")"); handleDbIssuePdoEcho($db, $w); $dbartworks = null; $db = null; return false; } $elapsed_time = time() - $words[3]; $changedPlaylists = false; $changedYourMusic = false; $addedMsg = ''; $removedMsg = ''; $updatedMsg = ''; $yourMusicMsg = ''; if ($nb_added_playlists > 0) { $addedMsg = $nb_added_playlists . ' added'; $changedPlaylists = true; } if ($nb_removed_playlists > 0) { $removedMsg = $nb_removed_playlists . ' removed'; $changedPlaylists = true; } if ($nb_updated_playlists > 0) { $updatedMsg = $nb_updated_playlists . ' updated'; $changedPlaylists = true; } if ($your_music_updated) { $yourMusicMsg = ' - Your Music: updated'; $changedYourMusic = true; } if ($changedPlaylists && $changedYourMusic) { $message = 'Playlists: ' . $addedMsg . ' ' . $removedMsg . ' ' . $updatedMsg . ' ' . $yourMusicMsg; } elseif ($changedPlaylists) { $message = 'Playlists: ' . $addedMsg . ' ' . $removedMsg . ' ' . $updatedMsg; } elseif ($changedYourMusic) { $message = $yourMusicMsg; } else { $message = 'No change'; } displayNotificationWithArtwork($message . " - took " . beautifyTime($elapsed_time, true), './images/update.png', 'Library refreshed'); if (file_exists($w->data() . '/library_old.db')) { deleteTheFile($w->data() . '/library_old.db'); } rename($w->data() . '/library_new.db', $w->data() . '/library.db'); // Download artworks in background logMsg("========DOWNLOAD_ARTWORKS DURING REFRESH LIBRARY ========"); exec("php -f ./src/action.php -- \"\" \"DOWNLOAD_ARTWORKS\" \"DOWNLOAD_ARTWORKS\" >> \"" . $w->cache() . "/action.log\" 2>&1 & "); deleteTheFile($w->data() . '/update_library_in_progress'); }
if ($nets && is_array($nets)) { foreach ($nets as $n => $zone) { if (strpos($n, "/") === false) { // No /, it's a host. Skip, we'll pick it up later continue; } list($network, $cidr) = explode("/", $n); $driver->addNetworkToZone($zone, $network, $cidr); } } // Turns out that this is unreliable. Which is why we use sigSleep below. pcntl_signal(SIGHUP, "sigHupHandler"); // Always run the update the first time. $lastfin = 1; while (true) { $fwconf = getSettings($mysettings); if (!$fwconf['active']) { fwLog("Not active. Shutting down"); shutdown(); } checkPhar(); $runafter = $lastfin + $fwconf['period']; if ($runafter < time()) { // We finished more than $period ago. We can run again. updateFirewallRules($lastfin === 1); // param (bool) true if this is the first run. $lastfin = time(); continue; } else { // Sleep until we're ready to go again. sigSleep($fwconf['period'] / 10);
function mini_deck() { $the_project = parent::the_project(); $prod_settings = parent::get_project_settings(); if (empty($prod_settings)) { $prod_settings = getProductDefaultSettings(); } $post_id = parent::get_project_postid(); $item_fund_goal = apply_filters('id_project_goal', parent::the_goal(), $post_id); $item_fund_end = parent::end_date(); $disable_levels = get_post_meta($post_id, 'ign_disable_levels', true); if ($disable_levels == 'on') { $no_levels = 0; } else { $no_levels = get_post_meta($post_id, $name = "ign_product_level_count", true); } $project_desc = html_entity_decode(get_post_meta($post_id, "ign_project_description", true)); $project_type = get_post_meta($post_id, 'ign_project_type', true); $end_type = get_post_meta($post_id, 'ign_end_type', true); $p_current_sale = apply_filters('id_funds_raised', parent::get_project_raised(), $post_id); $p_count = new stdClass(); $p_count->p_number = apply_filters('id_number_pledges', parent::get_project_orders(), $post_id); $rating_per = apply_filters('id_percentage_raised', parent::percent(), apply_filters('id_funds_raised', parent::get_project_raised(), $post_id, true), $post_id, apply_filters('id_project_goal', parent::the_goal(), $post_id, true)); $successful = parent::successful(); $days_left = apply_filters('id_project_days_left', parent::days_left(), $post_id); $end_month = parent::end_month(); $end_day = parent::end_day(); $end_year = parent::end_year(); //GETTING the main settings of ignitiondeck $settings = getSettings(); if ($settings->id_widget_link == "") { $affiliate_link = "http://ignitiondeck.com"; } else { $affiliate_link = $settings->id_widget_link; } $unique_widget_id = rand(101282, 293773); //GETTING the currency symbol $currencyCodeValue = $prod_settings->currency_code; $cCode = setCurrencyCode($currencyCodeValue); $the_deck = new stdClass(); $the_deck->project = $the_project; $the_deck->prod_settings = $prod_settings; $the_deck->post_id = $post_id; $the_deck->item_fund_goal = $item_fund_goal; $the_deck->item_fund_end = $item_fund_end; $the_deck->disable_levels = $disable_levels; $the_deck->no_levels = $no_levels; $the_deck->project_desc = $project_desc; $the_deck->project_type = $project_type; $the_deck->end_type = $end_type; $the_deck->p_current_sale = $p_current_sale; $the_deck->p_count = $p_count; $the_deck->rating_per = $rating_per; $the_deck->successful = $successful; $the_deck->days_left = $days_left; $the_deck->month = apply_filters('id_end_month', $end_month); $the_deck->day = $end_day; $the_deck->year = $end_year; $the_deck->settings = $settings; $the_deck->cCode = $cCode; $the_deck->affiliate_link = $affiliate_link; return $the_deck; }