Esempio n. 1
0
function overwrite_value_config($config, $key, $new_value)
{
    global $base_dir;
    unset($config[$key]);
    $config[$key] = $new_value;
    save_config($config, $base_dir);
}
Esempio n. 2
0
 private static function WebRoot()
 {
     global $INI;
     if (defined('WEB_ROOT')) {
         return $INI;
     }
     /* validator */
     $script_name = $_SERVER['SCRIPT_NAME'];
     if (preg_match('#^(.*)/app.php$#', $script_name, $m)) {
         $INI['webroot'] = $m[1];
         save_config('php');
     }
     if (isset($INI['webroot'])) {
         define('WEB_ROOT', $INI['webroot']);
     } else {
         $document_root = $_SERVER['DOCUMENT_ROOT'];
         $docroot = rtrim(str_replace('\\', '/', $document_root), '/');
         if (!$docroot) {
             $script_filename = $_SERVER['SCRIPT_FILENAME'];
             $script_filename = str_replace('\\', '/', $script_filename);
             $script_name = $_SERVER['SCRIPT_NAME'];
             $script_name = str_replace('\\', '/', $script_name);
             $lengthf = strlen($script_filename);
             $lengthn = strlen($script_name);
             $length = $lengthf - $lengthn;
             $docroot = rtrim(substr($script_filename, 0, $length), '/');
         }
         $webroot = trim(substr(WWW_ROOT, strlen($docroot)), '\\/');
         define('WEB_ROOT', $webroot ? "/{$webroot}" : '');
     }
     return $INI;
 }
Esempio n. 3
0
function migrate_config()
{
    $curr_dir = dirname(__FILE__);
    if (!is_readable($curr_dir . '/admin/incConfig.php') || !detect_config(false)) {
        return false;
        // nothing to migrate
    }
    @(include $curr_dir . '/admin/incConfig.php');
    @(include $curr_dir . '/config.php');
    $config_array = array('dbServer' => $dbServer, 'dbUsername' => $dbUsername, 'dbPassword' => $dbPassword, 'dbDatabase' => $dbDatabase, 'adminConfig' => $adminConfig);
    if (save_config($config_array)) {
        @rename($curr_dir . '/admin/incConfig.php', $curr_dir . '/admin/incConfig.bak.php');
        @unlink($curr_dir . '/admin/incConfig.php');
        return true;
    }
    return false;
}
Esempio n. 4
0
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoConfig.class.php";
    include_once "libs/paloSantoACL.class.php";
    include_once "libs/paloSantoForm.class.php";
    require_once "libs/misc.lib.php";
    include_once "lib/paloSantoVoiceMail.class.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    //segun el usuario que esta logoneado consulto si tiene asignada extension para buscar los voicemails
    $pDB = new paloDB($arrConf['elastix_dsn']['acl']);
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrAMP = $pConfig->leer_configuracion(false);
    $dsnAsterisk = $arrAMP['AMPDBENGINE']['valor'] . "://" . $arrAMP['AMPDBUSER']['valor'] . ":" . $arrAMP['AMPDBPASS']['valor'] . "@" . $arrAMP['AMPDBHOST']['valor'] . "/asterisk";
    $pDB_ast = new paloDB($dsnAsterisk);
    if (!empty($pDB->errMsg)) {
        echo "ERROR DE DB: {$pDB->errMsg} <br>";
    }
    $arrData = array();
    $pACL = new paloACL($pDB);
    if (!empty($pACL->errMsg)) {
        echo "ERROR DE ACL: {$pACL->errMsg} <br>";
    }
    $arrVoiceData = array();
    $inicio = $fin = $total = 0;
    $extension = $pACL->getUserExtension($_SESSION['elastix_user']);
    $ext = $extension;
    $esAdministrador = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']);
    $bandCustom = true;
    if (is_null($ext) || $ext == "") {
        $bandCustom = false;
        if (!$esAdministrador) {
            $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
            return "";
        }
    }
    if ($esAdministrador) {
        $extension = "[[:digit:]]+";
    }
    $smarty->assign("menu", "voicemail");
    $smarty->assign("Filter", $arrLang['Show']);
    //formulario para el filtro
    $arrFormElements = createFieldFormVoiceList($arrLang);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Por omision las fechas toman el sgte. valor (la fecha de hoy)
    $date_start = date("Y-m-d") . " 00:00:00";
    $date_end = date("Y-m-d") . " 23:59:59";
    $dateStartFilter = getParameter('date_start');
    $dateEndFilter = getParameter('date_end');
    $report = false;
    if (getParameter('filter')) {
        if ($oFilterForm->validateForm($_POST)) {
            // Exito, puedo procesar los datos ahora.
            $date_start = translateDate($dateStartFilter) . " 00:00:00";
            $date_end = translateDate($dateEndFilter) . " 23:59:59";
            $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter);
        } else {
            // Error
            $smarty->assign("mb_title", $arrLang["Validation Error"]);
            $arrErrores = $oFilterForm->arrErroresValidacion;
            $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>";
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}, ";
            }
            $strErrorMsg .= "";
            $smarty->assign("mb_message", $strErrorMsg);
        }
        if ($dateStartFilter == "") {
            $dateStartFilter = " ";
        }
        if ($dateEndFilter == "") {
            $dateEndFilter = " ";
        }
        //se añade control a los filtros
        $report = true;
        $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    } else {
        if (isset($dateStartFilter) and isset($dateEndFilter)) {
            $report = true;
            $date_start = translateDate($dateStartFilter) . " 00:00:00";
            $date_end = translateDate($dateEndFilter) . " 23:59:59";
            $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter);
            $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter);
            $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_GET);
        } else {
            $report = true;
            //se añade control a los filtros
            $arrDate = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"));
            $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", array('date_start' => date("d M Y"), 'date_end' => date("d M Y")));
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    if ($report) {
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrDate['date_start'] . ", " . _tr("End Date") . " = " . $arrDate['date_end'], $arrDate, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true);
    }
    if (getParameter('submit_eliminar')) {
        borrarVoicemails();
        if ($oFilterForm->validateForm($_POST)) {
            // Exito, puedo procesar los datos ahora.
            $date_start = translateDate($_POST['date_start']) . " 00:00:00";
            $date_end = translateDate($_POST['date_end']) . " 23:59:59";
            $arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end']);
        }
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    }
    if (getParameter('config')) {
        if (!(is_null($ext) || $ext == "")) {
            return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast);
        }
    }
    if (getParameter('save')) {
        if (!save_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast)) {
            return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast);
        }
    }
    if (getParameter('action') == "display_record") {
        $file = getParameter("name");
        $ext = getParameter("ext");
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        $extension = $pACL->getUserExtension($user);
        $esAdministrador = $pACL->isUserAdministratorGroup($user);
        $path = "/var/spool/asterisk/voicemail/default";
        $voicemailPath = "{$path}/{$ext}/INBOX/" . base64_decode($file);
        $tmpfile = basename($voicemailPath);
        $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}";
        if (!is_file($filetmp)) {
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        if (!$esAdministrador) {
            if ($extension != $ext) {
                die("<b>404 " . $arrLang["no_file"] . "</b>");
            }
            $voicemailPath = "{$path}/{$extension}/INBOX/" . base64_decode($file);
        }
        if (isset($file) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", base64_decode($file))) {
            if (!is_file($voicemailPath)) {
                die("<b>404 " . $arrLang["no_file"] . "</b>");
            }
            $sContenido = "";
            $name = basename($voicemailPath);
            $format = substr(strtolower($name), -3);
            // This will set the Content-Type to the appropriate setting for the file
            $ctype = '';
            switch ($format) {
                case "mp3":
                    $ctype = "audio/mpeg";
                    break;
                case "wav":
                    $ctype = "audio/x-wav";
                    break;
                case "Wav":
                    $ctype = "audio/x-wav";
                    break;
                case "WAV":
                    $ctype = "audio/x-wav";
                    break;
                case "gsm":
                    $ctype = "audio/x-gsm";
                    break;
                    // not downloadable
                // not downloadable
                default:
                    die("<b>404 " . $arrLang["no_file"] . "</b>");
                    break;
            }
            if ($sContenido == "") {
                $session_id = session_id();
            }
            $sContenido = <<<contenido
                    <embed src='index.php?menu={$module_name}&action=download&ext={$ext}&name={$file}&rawmode=yes&elastixSession={$session_id}' width=300, height=20 autoplay=true loop=false type="{$ctype}"></embed><br>
contenido;
            $smarty->assign("CONTENT", $sContenido);
            $smarty->display("_common/popup.tpl");
        } else {
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        return;
    }
    if (getParameter('action') == "download") {
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        $extension = $pACL->getUserExtension($user);
        $esAdministrador = $pACL->isUserAdministratorGroup($user);
        $record = getParameter("name");
        $ext = getParameter("ext");
        if (!preg_match("/^[[:digit:]]+\$/", $ext)) {
            Header("HTTP/1.1 404 Not Found");
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        $record = base64_decode($record);
        $path = "/var/spool/asterisk/voicemail/default";
        $voicemailPath = "{$path}/{$ext}/INBOX/" . $record;
        //"$path/$record";
        $tmpfile = basename($voicemailPath);
        $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}";
        if (!is_file($filetmp)) {
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        if (!$esAdministrador) {
            if ($extension != $ext) {
                Header("HTTP/1.1 404 Not Found");
                die("<b>404 " . $arrLang["no_extension"] . "</b>");
            }
            $voicemailPath = "{$path}/{$extension}/INBOX/" . $record;
        }
        if (isset($record) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", $record)) {
            // See if the file exists
            if (!is_file($voicemailPath)) {
                Header("HTTP/1.1 404 Not Found");
                die("<b>404 " . $arrLang["no_file"] . "</b>");
            }
            // Gather relevent info about file
            $size = filesize($voicemailPath);
            $name = basename($voicemailPath);
            //$extension = strtolower(substr(strrchr($name,"."),1));
            $extension = substr(strtolower($name), -3);
            // This will set the Content-Type to the appropriate setting for the file
            $ctype = '';
            switch ($extension) {
                case "mp3":
                    $ctype = "audio/mpeg";
                    break;
                case "wav":
                    $ctype = "audio/x-wav";
                    break;
                case "Wav":
                    $ctype = "audio/x-wav";
                    break;
                case "WAV":
                    $ctype = "audio/x-wav";
                    break;
                case "gsm":
                    $ctype = "audio/x-gsm";
                    break;
                    // not downloadable
                // not downloadable
                default:
                    die("<b>404 " . $arrLang["no_file"] . "</b>");
                    break;
            }
            // need to check if file is mislabeled or a liar.
            $fp = fopen($voicemailPath, "rb");
            if ($size && $ctype && $fp) {
                header("Pragma: public");
                header("Expires: 0");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Cache-Control: public");
                header("Content-Description: wav file");
                header("Content-Type: " . $ctype);
                header("Content-Disposition: attachment; filename=" . $name);
                header("Content-Transfer-Encoding: binary");
                header("Content-length: " . $size);
                fpassthru($fp);
            }
        } else {
            Header("HTTP/1.1 404 Not Found");
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        return;
    }
    $end = 0;
    $url = array('menu' => $module_name);
    //si tiene extension consulto sino, muestro un mensaje de que no tiene asociada extension
    $archivos = array();
    if (!(is_null($ext) || $ext == "") || $esAdministrador) {
        if (is_null($ext) || $ext == "") {
            $smarty->assign("mb_message", "<b>" . $arrLang["no_extension_assigned"] . "</b>");
        }
        $path = "/var/spool/asterisk/voicemail/default";
        $folder = "INBOX";
        if ($esAdministrador) {
            if ($handle = opendir($path)) {
                while (false !== ($dir = readdir($handle))) {
                    if ($dir != "." && $dir != ".." && ereg($extension, $dir, $regs) && is_dir($path . "/" . $dir)) {
                        $directorios[] = $dir;
                    }
                }
            }
        } else {
            $directorios[] = $extension;
        }
        //if($esAdministrador)
        $arrData = array();
        foreach ($directorios as $directorio) {
            $voicemailPath = "{$path}/{$directorio}/{$folder}";
            if (file_exists($voicemailPath)) {
                if ($handle = opendir($voicemailPath)) {
                    $bExito = true;
                    while (false !== ($file = readdir($handle))) {
                        //no tomar en cuenta . y ..
                        //buscar los archivos de texto (txt) que son los que contienen los datos de las llamadas
                        if ($file != "." && $file != ".." && ereg("(.+)\\.[txt|TXT]", $file, $regs)) {
                            //leer la info del archivo
                            $pConfig = new paloConfig($voicemailPath, $file, "=", "[[:space:]]*=[[:space:]]*");
                            $arrVoiceMailDes = array();
                            $arrVoiceMailDes = $pConfig->leer_configuracion(false);
                            //verifico que tenga datos
                            if (is_array($arrVoiceMailDes) && count($arrVoiceMailDes) > 0 && isset($arrVoiceMailDes['origtime']['valor'])) {
                                //uso las fechas del filtro
                                //si la fecha de llamada esta dentro del rango, la muestro
                                $fecha = date("Y-m-d", $arrVoiceMailDes['origtime']['valor']);
                                $hora = date("H:i:s", $arrVoiceMailDes['origtime']['valor']);
                                if (strtotime("{$fecha} {$hora}") <= strtotime($date_end) && strtotime("{$fecha} {$hora}") >= strtotime($date_start)) {
                                    $arrTmp[0] = "<input type='checkbox' name='" . utf8_encode("voc-" . $file) . ",{$directorio}' />";
                                    $arrTmp[1] = $fecha;
                                    $arrTmp[2] = $hora;
                                    $arrTmp[3] = $arrVoiceMailDes['callerid']['valor'];
                                    $arrTmp[4] = $arrVoiceMailDes['origmailbox']['valor'];
                                    $arrTmp[5] = $arrVoiceMailDes['duration']['valor'] . ' sec.';
                                    $pathRecordFile = base64_encode($regs[1] . '.wav');
                                    $recordingLink = "<a href='#' onClick=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&ext={$directorio}&name={$pathRecordFile}&rawmode=yes',350,100); return false;\">{$arrLang['Listen']}</a>&nbsp;";
                                    $recordingLink .= "<a href='?menu={$module_name}&action=download&ext={$directorio}&name={$pathRecordFile}&rawmode=yes'>{$arrLang['Download']}</a>";
                                    $arrTmp[6] = $recordingLink;
                                    $arrData[] = $arrTmp;
                                }
                            }
                        }
                    }
                    closedir($handle);
                }
            } else {
                // No vale la ruta
            }
        }
        /*
        function sort_voicemails_hora_desc($a, $b) { return ($a[2] == $b[2]) ? 0 : (($a[2] < $b[2]) ? 1 : -1); }
        function sort_voicemails_fecha_desc($a, $b) { return ($a[1] == $b[1]) ? 0 : (($a[1] < $b[1]) ? 1 : -1); }
        usort($arrData, 'sort_voicemails_hora_desc');
        usort($arrData, 'sort_voicemails_fecha_desc');
        */
        $fechas = array();
        $horas = array();
        foreach ($arrData as $llave => $fila) {
            $fechas[$llave] = $fila[1];
            $horas[$llave] = $fila[2];
        }
        array_multisort($fechas, SORT_DESC, $horas, SORT_DESC, $arrData);
        //Paginacion
        $limit = 15;
        $total = count($arrData);
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $end = $offset + $limit <= $total ? $offset + $limit : $total;
        // Construyo el URL base
        if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) and count($arrFilterExtraVars) > 0) {
            $url = array_merge($url, $arrFilterExtraVars);
        }
        //Fin Paginacion
        $arrVoiceData = array_slice($arrData, $offset, $limit);
    } else {
        $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
    }
    $arrGrid = array("title" => $arrLang["Voicemail List"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_voicemail.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Date"], "property1" => ""), 2 => array("name" => $arrLang["Time"], "property1" => ""), 3 => array("name" => $arrLang["CallerID"], "property1" => ""), 4 => array("name" => $arrLang["Extension"], "property1" => ""), 5 => array("name" => $arrLang["Duration"], "property1" => ""), 6 => array("name" => $arrLang["Message"], "property1" => "")));
    if ($bandCustom == true) {
        $oGrid->customAction("config", _tr("Configuration"));
    }
    $oGrid->deleteList(_tr("Are you sure you wish to delete voicemails?"), "submit_eliminar", _tr("Delete"));
    $oGrid->showFilter($htmlFilter);
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrVoiceData, $arrLang);
    if (strpos($contenidoModulo, '<form') === FALSE) {
        $contenidoModulo = "<form style='margin-bottom:0;' method='POST' action='?menu={$module_name}'>{$contenidoModulo}</form>";
    }
    return $contenidoModulo;
}
     $r = tep_db_query($q);
     $items_confirmed = array();
     while ($row = tep_db_fetch_array($r)) {
         $items_confirmed[] = $row['jng_sp_orders_items_id'];
     }
     if (count($items_confirmed) > 0) {
         $class_jo->confirmOrderDelivery($items_confirmed);
     }
     echo 'UPDATED';
     exit;
 } elseif ($_POST['me_action'] == 'CHANGESTOCKDELAY') {
     $new_delay = intval($_POST['new_delay']);
     if ($new_delay >= 60) {
         $config_open_orders = load_config('open-orders');
         $config_open_orders['stock-delay-non-zalando'] = $new_delay;
         save_config('open-orders', $config_open_orders);
     } else {
         $new_delay = 0;
     }
     echo utf8_encode(strval($new_delay));
     exit;
 } elseif ($_POST['me_action'] == 'CLOSEORDERSINSENTTAB') {
     if (isset($_POST['tobeclosed']) && is_array($_POST['tobeclosed'])) {
         $sp_list = $class_sp->retrieveList();
         foreach ($_POST['tobeclosed'] as $tbc) {
             list($jng_sp_id, $sent_date) = explode('|', $tbc);
             $q = "SELECT DISTINCT joi.jng_sp_orders_items_id, jo.jng_sp_orders_id";
             $q .= " FROM jng_sp_orders jo";
             $q .= " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id = jo.jng_sp_orders_id AND joi.status=9 AND joi.confirm_delivery='0'";
             $q .= " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id=joi.jng_sp_orders_items_id AND joish.status=joi.status";
             $q .= " WHERE jo.jng_sp_id={$jng_sp_id} AND joish.status_date LIKE '{$sent_date}%'";
Esempio n. 6
0
					</div>
				</div>
			<?php 
        include_once "{$curr_dir}/footer.php";
        exit;
    }
    /* if db test is successful, output success message and exit */
    if ($test) {
        exit;
    }
    /* create database tables */
    $silent = false;
    include "{$curr_dir}/updateDB.php";
    /* attempt to save db config file */
    $new_config = array('dbServer' => undo_magic_quotes($db_server), 'dbUsername' => undo_magic_quotes($db_username), 'dbPassword' => undo_magic_quotes($db_password), 'dbDatabase' => undo_magic_quotes($db_name), 'adminConfig' => array('adminUsername' => $username, 'adminPassword' => md5($password), 'notifyAdminNewMembers' => false, 'defaultSignUp' => 1, 'anonymousGroup' => 'anonymous', 'anonymousMember' => 'guest', 'groupsPerPage' => 10, 'membersPerPage' => 10, 'recordsPerPage' => 10, 'custom1' => 'Full Name', 'custom2' => 'Address', 'custom3' => 'City', 'custom4' => 'State', 'MySQLDateFormat' => '%m/%d/%Y', 'PHPDateFormat' => 'n/j/Y', 'PHPDateTimeFormat' => 'm/d/Y, h:i a', 'senderName' => 'Membership management', 'senderEmail' => $email, 'approvalSubject' => 'Your membership is now approved', 'approvalMessage' => "Dear member,\n\nYour membership is now approved by the admin. You can log in to your account here:\nhttp://{$_SERVER['HTTP_HOST']}" . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "\n\nRegards,\nAdmin", 'hide_twitter_feed' => false));
    $save_result = save_config($new_config);
    if ($save_result !== true) {
        // display instructions for manually creating them if saving not successful
        $folder_path_formatted = '<strong>' . dirname(__FILE__) . '</strong>';
        ?>
				<div class="row">
					<div class="col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
						<p style="background-color: white; padding: 20px; margin-bottom: 40px; border-radius: 4px;"><img src="logo.png"></p>
						<div class="alert alert-danger"><?php 
        echo $Translation['error:'] . ' ' . $save_result['error'];
        ?>
</div>
						<?php 
        printf($Translation['failed to create config instructions'], $folder_path_formatted);
        ?>
						<pre style="overflow: scroll; font-size: large;"><?php 
 public function copy($newThemeName = '')
 {
     if (!is_dir($this->_themeDir)) {
         return array('errors' => 'Theme `' . $this->_themeName . '` doesn\'t exist');
     }
     ProviderLog::start('copyTheme');
     $newThemeName = $newThemeName ? checkThemeName($newThemeName) : checkThemeName($this->_themeName);
     $this->prepareCopyRename($newThemeName, false);
     save_config($this->_previewThemeDir, $this->_previewThemeDir, $this->_themeName);
     // HACK: We have to rename source Config.xml back
     Designer::addTheme($newThemeName);
     ProviderLog::end('copyTheme');
     return array('result' => 'done', 'log' => ProviderLog::getLog(), 'newName' => $newThemeName);
 }
Esempio n. 8
0
    $proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
    if (login() && $proper) {
        $newKey = from($_REQUEST, 'newKey');
        $newValue = from($_REQUEST, 'newValue');
        $new_config = array();
        $new_Keys = array();
        if (!empty($newKey)) {
            $new_Keys[$newKey] = $newValue;
        }
        foreach ($_POST as $name => $value) {
            if (substr($name, 0, 8) == "-config-") {
                $name = str_replace("_", ".", substr($name, 8));
                $new_config[$name] = $value;
            }
        }
        save_config($new_config, $new_Keys);
        $login = site_url() . 'admin/config';
        header("location: {$login}");
    } else {
        $login = site_url() . 'login';
        header("location: {$login}");
    }
    die;
});
// Show Backup page
get('/admin/backup', function () {
    if (login()) {
        config('views.root', 'system/admin/views');
        render('backup', array('title' => 'Backup content - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'bodyclass' => 'backup', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Backup'));
    } else {
        $login = site_url() . 'login';
Esempio n. 9
0
     exit;
 } elseif ($_POST['me_action'] == 'KPI-LEAD-RELOADTABLE') {
     $status = tep_db_prepare_input($_POST['status']);
     $closing_date_start = tep_db_prepare_input($_POST['closing_date_start']);
     $closing_date_end = tep_db_prepare_input($_POST['closing_date_end']);
     echo utf8_encode(kpiLeadtimeLoad($status, $closing_date_start, $closing_date_end));
     exit;
 } elseif ($_POST['me_action'] == 'KPI-FCHECK-UPDATECONFIG') {
     $kpi_lead_config_data = tep_db_prepare_input($_POST['kpi_fcheck_config_data']);
     $config_temp = explode('||', $kpi_lead_config_data);
     $config = array();
     foreach ($config_temp as $ct) {
         list($cn, $cv) = explode('|', $ct);
         $config[$cn] = $cv;
     }
     save_config('kpi-leadtime', $config);
     echo utf8_encode('ok');
     exit;
 } elseif ($_POST['me_action'] == 'KPI-FCHECK-RELOADTABLE') {
     if (isset($_POST['seldate'])) {
         $seldate = tep_db_prepare_input($_POST['seldate']);
         $seldate_ts = strtotime($seldate);
         $seldate_ts_start = $seldate_ts - 7 * 86400;
         $date_start = date('Y-m-d', $seldate_ts_start);
         $date_end = date('Y-m-d', $seldate_ts);
     } else {
         $date_start = date('Y-m-d', strtotime('-7 days'));
         $date_end = date('Y-m-d');
     }
     $result = '<div id="kpi-fcheck">';
     //Preparing Result
Esempio n. 10
0
            if (is_exists_s_config_group_item_var($config_group_item_r['group_id'], $config_group_item_r['id'], $config_group_item_r['keyid'])) {
                if (!delete_s_config_group_item_vars($config_group_item_r['group_id'], $config_group_item_r['id'], $config_group_item_r['keyid'])) {
                    $errors[] = array('error' => 'Config Group Item Var not deleted', 'detail' => db_error());
                }
            }
        }
    }
}
@set_time_limit(0);
if (strlen($HTTP_VARS['group_id']) == 0) {
    $HTTP_VARS['group_id'] = 'site';
}
// process any updates
if ($HTTP_VARS['op'] == 'save') {
    //print_r($HTTP_VARS);
    save_config($HTTP_VARS, $errors);
}
if (is_not_empty_array($errors)) {
    echo format_error_block($errors);
}
echo get_javascript("admin/config/select.js");
echo "<div class=\"tabContainer\">";
$config_group_rs = NULL;
$results = fetch_s_config_group_rs();
if ($results) {
    while ($config_group_r = db_fetch_assoc($results)) {
        $config_group_rs[] = $config_group_r;
    }
    db_free_result($results);
}
if (is_array($config_group_rs)) {
$api_status_ok = true;
$exchange_rate = array();
$exchange_rate['date'] = date('d.m.Y H:i:s');
$currencies = getAllCurrencies();
foreach ($currencies as $c_from) {
    foreach ($currencies as $c_to) {
        $key = generateExchangeRateKey($c_from, $c_to);
        if ($c_from == $c_to) {
            $rate = 1;
        } else {
            $rate = getExchangeRateOnline($c_from, $c_to);
            if ($rate == 0 || $rate === false) {
                $api_status_ok = false;
            }
        }
        $exchange_rate[$key] = $rate;
        $logger->write('Rate for ' . $key . ': ' . $rate);
    }
}
if ($api_status_ok) {
    save_config('exchange-rate', $exchange_rate);
    $logger->write('Save rate to configuration file');
} else {
    $subject = 'IMPORTANT & URGENT: Exchange Rate Cron Failed!';
    $content = '<p>Dear All, there seems to be a problem running ' . 'cron/daily-exchange-rate.php! It is not saved and ' . 'last success value is kept.</p>' . '<p>Please check the log and try to rerun it manually.' . ' If you keep receiving this error, create a 2 stars bug report!</p>';
    tep_mail(EMAIL_NAME_DEBUGR, EMAIL_ADDRESS_DEBUGR, $subject, $content, FROM_EMAIL_NAME, FROM_EMAIL_ADDRESS);
    $logger->write('Problem found! A notification is sent to IT Team.');
}
$logger->close();
echo 'Done!';
tep_db_close();
Esempio n. 12
0
/**
 * @brief Set a new administrator password
 *
 * @note    The password will be trimmed, salted, crypted with sha256 and stored in $config.
 *          Optionally, $config can be written in config.php.
 *
 * @param string    $old_password       The current administrator password (plain, not crypted)
 * @param string    $new_password_1     The new administrator password (plain, not crypted) (first time)
 * @param string    $new_password_2     The new administrator password (plain, not crypted) (second time)
 * @param boolean   $save_config        If true, the config.php file will be overwritten.
 *                                      If false, the new password will be stored in $config,
 *                                      but you must manually save the $config with save_config()!
 *
 * @throws Exception    if the old password is not correct
 * @throws Exception    if the new password is not allowed (maybe empty)
 * @throws Exception    if the new passworts are different
 * @throws Exception    if $config could not be saved in config.php
 */
function set_admin_password($old_password, $new_password_1, $new_password_2, $save_config = true)
{
    global $config;
    $salt = 'h>]gW3$*j&o;O"s;@&G)';
    settype($old_password, 'string');
    settype($new_password_1, 'string');
    settype($new_password_2, 'string');
    $old_password = trim($old_password);
    $new_password_1 = trim($new_password_1);
    $new_password_2 = trim($new_password_2);
    if (!is_admin_password($old_password)) {
        throw new Exception('Das eingegebene Administratorpasswort ist nicht korrekt!');
    }
    if (mb_strlen($new_password_1) < 4) {
        throw new Exception('Das neue Passwort muss mindestens 4 Zeichen lang sein!');
    }
    if ($new_password_1 !== $new_password_2) {
        throw new Exception('Die neuen Passwörter stimmen nicht überein!');
    }
    // all ok, save the new password
    $config['admin']['password'] = hash('sha256', $salt . $new_password_1);
    if ($save_config) {
        save_config();
    }
}
Esempio n. 13
0
 public static function queryDepotSummary($includes_refill = false, $save_to_config = true)
 {
     //TODO: Please consider to also includes warehouse id as filter when we want to add new depot
     set_time_limit(0);
     self::loadDIOHsettings();
     $depot_summary = load_config('depot-summary');
     $totalstars = 3;
     $goodstock_tolerance = 0;
     use_class('logger');
     $logger = new logger('classes', 'product');
     $logger->write('QUERY DEPOT SUMMARY!');
     $logger->write('Previous Summary Result:');
     foreach ($depot_summary as $key => $value) {
         $logger->write("{$key} = {$value}");
     }
     $refill_data = array();
     if ($includes_refill) {
         use_class('depot_orders');
         $q = "SELECT products_id, articles_id, SUM(quantity) AS refill_qty";
         $q .= " FROM depot_orders";
         $q .= " WHERE trans_type IN (" . depot_orders::FILTER_TRANS_TYPE_ALLREFILL . ")";
         $q .= " AND status NOT IN ( " . depot_orders::FILTER_STATUS_CLOSE . ")";
         $q .= " GROUP BY products_id, articles_id";
         $r = tep_db_query($q);
         while ($row = tep_db_fetch_array($r)) {
             $refill_data["{$row['products_id']}-{$row['articles_id']}"] = $row['refill_qty'];
         }
     }
     $q = "SELECT ps.products_id, ps.articles_id, p.stars, (ps.stock-ps.booking_active) AS stock_available, p.material_expenses";
     $q .= " FROM products p";
     $q .= " LEFT JOIN products_stock ps ON ps.products_id=p.products_id";
     $q .= " WHERE p.products_status='1' OR ps.stock>0";
     $q .= " ORDER BY products_id, articles_id";
     $r = tep_db_query($q);
     $product = null;
     $overstock = array();
     $shortages = array();
     $goodstock = array();
     for ($s = 0; $s <= $totalstars; $s++) {
         $overstock[$s]['products'] = array();
         $overstock[$s]['articles'] = 0;
         $overstock[$s]['quantity'] = 0;
         $overstock[$s]['value'] = 0;
         $shortages[$s]['products'] = array();
         $shortages[$s]['articles'] = 0;
         $shortages[$s]['quantity'] = 0;
         $shortages[$s]['value'] = 0;
         $goodstock[$s]['products'] = array();
         $goodstock[$s]['articles'] = 0;
         $goodstock[$s]['quantity'] = 0;
         $goodstock[$s]['value'] = 0;
     }
     $rowcounter = 0;
     while ($row = tep_db_fetch_array($r)) {
         $rowcounter++;
         $stock_refill = $includes_refill && isset($refill_data["{$row['products_id']}-{$row['articles_id']}"]) ? $refill_data["{$row['products_id']}-{$row['articles_id']}"] : 0;
         $stock_available = ($row['stock_available'] < 0 ? 0 : $row['stock_available']) + $stock_refill;
         $material_expenses = isset($row['material_expenses']) && $row['material_expenses'] > 0 ? self::getMaterialExpenseInDefaultCurrency($row['material_expenses']) : 0;
         if (product::$diohStopLevel[$row['stars']] == 0) {
             //NO TARGET, NO NEED TO COUNT
             if ($stock_available == 0) {
                 $goodstock[$row['stars']]['products'][] = $row['products_id'];
                 $goodstock[$row['stars']]['articles']++;
             } else {
                 $overstock[$row['stars']]['products'][] = $row['products_id'];
                 $overstock[$row['stars']]['articles']++;
                 $overstock[$row['stars']]['quantity'] += $stock_available;
                 $overstock[$row['stars']]['value'] += $stock_available * $material_expenses;
             }
         } else {
             if (is_null($product) || is_object($product) && $product->id != $row['products_id']) {
                 $product = new product($row['products_id']);
             }
             $stock_target = $product->getDIOHstockTarget($row['articles_id']);
             $stock_diff = $stock_available - $stock_target;
             if ($stock_diff > $goodstock_tolerance) {
                 //OVERSTOCK
                 $overstock_quantity = $stock_diff - $goodstock_tolerance;
                 $overstock[$product->stars]['products'][] = $product->id;
                 $overstock[$product->stars]['articles']++;
                 $overstock[$product->stars]['quantity'] += $overstock_quantity;
                 $goodstock[$product->stars]['quantity'] += $stock_available - $overstock_quantity;
                 $overstock[$product->stars]['value'] += $overstock_quantity * $material_expenses;
                 $goodstock[$product->stars]['value'] += ($stock_available - $overstock_quantity) * $material_expenses;
             } elseif ($stock_diff < -1 * $goodstock_tolerance) {
                 //SHORTAGE
                 $shortages_quantity = abs($stock_diff) - $goodstock_tolerance;
                 $shortages[$product->stars]['products'][] = $product->id;
                 $shortages[$product->stars]['articles']++;
                 $shortages[$product->stars]['quantity'] += $shortages_quantity;
                 $shortages[$product->stars]['quantity'] += $stock_available;
                 $shortages[$product->stars]['value'] += $shortages_quantity * $material_expenses;
                 $shortages[$product->stars]['value'] += $stock_available * $material_expenses;
             } else {
                 $goodstock[$product->stars]['products'][] = $product->id;
                 $goodstock[$product->stars]['articles']++;
                 $goodstock[$product->stars]['quantity'] += $stock_available;
                 $goodstock[$product->stars]['value'] += $stock_available * $material_expenses;
             }
         }
         //            echo '. ';
     }
     $logger->write('Total rows from query = ' . $rowcounter);
     for ($s = 0; $s <= $totalstars; $s++) {
         $overstock[$s]['products'] = count(array_unique($overstock[$s]['products']));
         $shortages[$s]['products'] = count(array_unique($shortages[$s]['products']));
         $goodstock[$s]['products'] = count(array_unique($goodstock[$s]['products']));
     }
     //        echo '<pre>';
     //        var_dump($goodstock);
     //        var_dump($overstock);
     //        var_dump($shortages);
     //        echo '</pre>';
     $depot_summary['lastrun'] = time();
     $depot_summary['diohTarget-0'] = self::$diohStopLevel[0];
     $depot_summary['diohTarget-1'] = self::$diohStopLevel[1];
     $depot_summary['diohTarget-2'] = self::$diohStopLevel[2];
     $depot_summary['diohTarget-3'] = self::$diohStopLevel[3];
     $depot_summary['overstock-3-products'] = $overstock[3]['products'];
     $depot_summary['overstock-3-articles'] = $overstock[3]['articles'];
     $depot_summary['overstock-3-quantity'] = $overstock[3]['quantity'];
     $depot_summary['overstock-3-value'] = $overstock[3]['value'];
     $depot_summary['overstock-2-products'] = $overstock[2]['products'];
     $depot_summary['overstock-2-articles'] = $overstock[2]['articles'];
     $depot_summary['overstock-2-quantity'] = $overstock[2]['quantity'];
     $depot_summary['overstock-2-value'] = $overstock[2]['value'];
     $depot_summary['overstock-1-products'] = $overstock[1]['products'];
     $depot_summary['overstock-1-articles'] = $overstock[1]['articles'];
     $depot_summary['overstock-1-quantity'] = $overstock[1]['quantity'];
     $depot_summary['overstock-1-value'] = $overstock[1]['value'];
     $depot_summary['overstock-0-products'] = $overstock[0]['products'];
     $depot_summary['overstock-0-articles'] = $overstock[0]['articles'];
     $depot_summary['overstock-0-quantity'] = $overstock[0]['quantity'];
     $depot_summary['overstock-0-value'] = $overstock[0]['value'];
     $depot_summary['goodstock-3-products'] = $goodstock[3]['products'];
     $depot_summary['goodstock-3-articles'] = $goodstock[3]['articles'];
     $depot_summary['goodstock-3-quantity'] = $goodstock[3]['quantity'];
     $depot_summary['goodstock-3-value'] = $goodstock[3]['value'];
     $depot_summary['goodstock-2-products'] = $goodstock[2]['products'];
     $depot_summary['goodstock-2-articles'] = $goodstock[2]['articles'];
     $depot_summary['goodstock-2-quantity'] = $goodstock[2]['quantity'];
     $depot_summary['goodstock-2-value'] = $goodstock[2]['value'];
     $depot_summary['goodstock-1-products'] = $goodstock[1]['products'];
     $depot_summary['goodstock-1-articles'] = $goodstock[1]['articles'];
     $depot_summary['goodstock-1-quantity'] = $goodstock[1]['quantity'];
     $depot_summary['goodstock-1-value'] = $goodstock[1]['value'];
     $depot_summary['goodstock-0-products'] = $goodstock[0]['products'];
     $depot_summary['goodstock-0-articles'] = $goodstock[0]['articles'];
     $depot_summary['goodstock-0-quantity'] = $goodstock[0]['quantity'];
     $depot_summary['goodstock-0-value'] = $goodstock[0]['value'];
     $depot_summary['shortages-3-products'] = $shortages[3]['products'];
     $depot_summary['shortages-3-articles'] = $shortages[3]['articles'];
     $depot_summary['shortages-3-quantity'] = $shortages[3]['quantity'];
     $depot_summary['shortages-2-products'] = $shortages[2]['products'];
     $depot_summary['shortages-2-articles'] = $shortages[2]['articles'];
     $depot_summary['shortages-2-quantity'] = $shortages[2]['quantity'];
     $depot_summary['shortages-2-value'] = $shortages[2]['value'];
     $depot_summary['shortages-1-products'] = $shortages[1]['products'];
     $depot_summary['shortages-1-articles'] = $shortages[1]['articles'];
     $depot_summary['shortages-1-quantity'] = $shortages[1]['quantity'];
     $depot_summary['shortages-1-value'] = $shortages[1]['value'];
     $depot_summary['shortages-0-products'] = $shortages[0]['products'];
     $depot_summary['shortages-0-articles'] = $shortages[0]['articles'];
     $depot_summary['shortages-0-quantity'] = $shortages[0]['quantity'];
     $depot_summary['shortages-0-value'] = $shortages[0]['value'];
     if ($save_to_config) {
         save_config('depot-summary', $depot_summary);
     }
     $logger->write('New value successfully saved');
     $logger->close();
     //        echo 'Done!';
     return $depot_summary;
 }
function processRename($themeDir, $previewThemeDir, $newThemeDir, $newThemePreviewDir, $newThemeName, $rename = true)
{
    save_config($previewThemeDir, $previewThemeDir, $newThemeName);
    // Check with upload archive & rename
    copyOrRename($previewThemeDir, $newThemePreviewDir, $rename);
    copyOrRename($themeDir, $newThemeDir, $rename);
}
Esempio n. 15
0
     if (!preg_match('/^[A-Za-z0-9_\\|]+$/', $uploads_extensions)) {
         trigger_error($ind295, E_USER_WARNING);
     }
     $exts = explode('|', $uploads_extensions);
     $good_exts = array();
     for ($i = 0, $num_exts = sizeof($exts); $i < $num_exts; ++$i) {
         if ($exts[$i] && !in_array($exts[$i], $good_exts)) {
             $good_exts[] = $exts[$i];
         }
     }
     $uploads_extensions = implode('|', $good_exts);
     $configs = config_array();
     $configs['uploads_size'] = $uploads_size;
     $configs['uploads_active'] = $uploads_active;
     $configs['uploads_ext'] = $uploads_extensions;
     save_config($configs);
     $title = $ind21;
     echo make_redirect($ind22, '?id=uploads', $ind338);
 } else {
     if ($id == 'help') {
         /*id Help*/
         if (!has_access(NEWS_REPORTER)) {
             trigger_error($ind19, E_USER_WARNING);
         }
         $message = '';
         $version = '';
         $title = $ind152;
         if ($fp = @fsockopen('www.fusionnews.net', 80, $errno, $errstr, 10)) {
             $out = 'GET /version/fnews_version.txt HTTP/1.1' . "\r\n";
             $out .= 'Host: www.fusionnews.net' . "\r\n";
             $out .= 'Connection: close' . "\r\n\r\n";
Esempio n. 16
0
<?php

// KioCMS - Kiofol Content Managment System
// modules/news/admin/settings.php
$info = new Infobox();
$save = $_POST['save'] ? true : false;
$form = $save ? $_POST['form'] : $news;
$form['bbcode'] = $save ? $_POST['bbcode'] : $news['bbcode'] ? 1 : 0;
$form['sort'] = $save ? $form['sort'] : explode(' ', $form['sort']);
$form['blocks'] = $save ? array_diff($blocks, $_POST['blocks']) : ($news['blocks'] ? explode(', ', $news['blocks']) : '');
if ($save) {
    $errors[0] = !$form['limit'] ? 'Pole <strong>wpisów na stronę</strong> nie może zostać puste.' : '';
    $errors[1] = !$form['sort'] ? 'Należy określić <strong>sortowanie wpisów</strong>.' : '';
    if (!in_array(true, $errors)) {
        $form['sort'] = $form['sort'][0] . ' ' . $form['sort'][1];
        save_config($news, 'news', HREF . 'admin/modules/news/settings');
    } else {
        $info->negative($errors);
    }
} else {
    $info->neutral(array($lang_admin['MODULE_SETTINGS'], $lang_system['REQUIRED']));
}
$tpl = new PHPTAL('modules/news/admin/settings.html');
$tpl->form = $form;
$tpl->lang2 = $lang2;
$tpl->lang_admin = $lang_admin;
$tpl->info = $info->show();
$tpl->columns = form_columns();
$tpl->blocks = form_blocks();
echo $tpl->execute();
Esempio n. 17
0
			}
		}
	}
	if ($_POST['act'] == 'add')
	{
		if ($_POST['new_serial'] != '')
		{
			$all_serials[] = $_POST['new_serial'];
		}
	}
	if ($_POST['act'] == 'clean')
	{
		clean_file();
	}
	$all_serials = array_values($all_serials);
	save_config($all_serials);
}
?>

<html>
<head>
	<title>USBlogger</title>
	<style>
		.data {
			border: 1px solid grey;
		}
	</style>
	<script src="jquery-1.6.4.min.js" type="text/javascript"></script>
	<script src="jquery.timers-1.2.js" type="text/javascript"></script>
	<script type="text/javascript">
	function remove(id)
Esempio n. 18
0
 function setting($action = NULL, $back = NULL)
 {
     if ($action == 'save') {
         save_config($_POST);
         $back = $back == NULL ? '/admin/setting' : '/admin/' . $back;
         info_page(_text('admin_setting_success'), $back);
         return true;
     }
     $data = NULL;
     $this->view('setting', $data);
 }
Esempio n. 19
0
/**
 * @brief Update the user's config.php to the latest version
 *
 * @retval array    If there are messages to display, this function will return an array of string.
 *                  If there are no messages, this function will return an empty array.
 *
 * @throws Exception if there was an error
 */
function update_users_config_php()
{
    global $config;
    $messages = array();
    $current = $config['system']['current_config_version'];
    $latest = $config['system']['latest_config_version'];
    while ($current < $latest) {
        switch ($current) {
            case 0:
                // this is used for all Part-DB versions before v0.3.0.RC1
                // set the most important settings
                global $mysql_server;
                $config['db']['host'] = $mysql_server;
                global $db_user;
                $config['db']['user'] = $db_user;
                global $db_password;
                $config['db']['password'] = $db_password;
                global $database;
                $config['db']['name'] = $database;
                global $http_charset;
                $config['html']['http_charset'] = $http_charset;
                global $disable_update_list;
                $config['startup']['disable_update_list'] = $disable_update_list;
                global $disable_devices;
                $config['devices']['disable'] = $disable_devices;
                global $disable_footprints;
                $config['footprints']['disable'] = $disable_footprints;
                global $disable_help;
                $config['menu']['disable_help'] = $disable_help;
                global $disable_config;
                $config['menu']['disable_config'] = $disable_config;
                global $use_modal_dialog;
                $config['popup']['modal'] = $use_modal_dialog;
                global $dialog_width;
                $config['popup']['width'] = $dialog_width;
                global $dialog_height;
                $config['popup']['height'] = $dialog_height;
                global $banner;
                $config['startup']['custom_banner'] = $banner;
                // check if the config.php is really from Part-DB 0.2.2
                if (!isset($mysql_server)) {
                    throw new Exception('Fehler beim Updaten der config.php: Unbekannte Version!');
                }
                /*
                 * Please Note:     We have migrated the old database connection and some other settings into the new config.php.
                 *                  But we cannot set the locales, database backup path and the administrator password.
                 *                  So these three Installers (install.php) will be shown on next startup.
                 */
                $config['installation_complete']['database'] = true;
                $messages[] = 'ACHTUNG: Für hochgeladene Bilder und andere Dateien gibt es jetzt das Verzeichnis "media" im Unterverzeichnis "data". ' . 'Falls Sie bereits eigene Dateien im Verzeichnis "img" haben (was für hochgeladene Bilder bisher der Zielordner war), ' . 'müssen Sie diese nun von Hand in der Ordner "data/media/" verschieben! Achten Sie darauf, dass die versteckte Datei ' . '"data/media/.htaccess" nicht gelöscht wird, diese ist wichtig für den sicheren Betrieb von Part-DB. ' . 'Die Dateipfade werden beim folgenden Datenbankupdate automatisch angepasst.';
                break;
            case 1:
                // remove for example ".utf8" in $config['language'] because of a change in start_session.php
                if (strpos($config['language'], '.') > 0) {
                    $config['language'] = substr($config['language'], 0, strpos($config['language'], '.'));
                }
                break;
            default:
                throw new Exception('Unbekannte config.php-Version: "' . $current . '"');
                break;
        }
        $current++;
    }
    save_config();
    // now save all changes
    return $messages;
}
        $languages_id = tep_db_prepare_input($_POST['languages_id']);
        $obj->deleteContent($languages_id);
        exit;
    } elseif ($_POST['me_action'] == 'SAVELANGUAGE') {
        $languages_id = tep_db_prepare_input($_POST['languages_id']);
        $email_subject = tep_db_prepare_input($_POST['email_subject']);
        $email_content = tep_db_prepare_input($_POST['email_content']);
        $obj->updateContent($languages_id, $email_subject, $email_content);
        echo utf8_encode($languages_id);
        exit;
    } elseif ($_POST['me_action'] == 'UDPATECONFIGPDD') {
        $config_id = tep_db_prepare_input($_POST['config_id']);
        $config_value = tep_db_prepare_input($_POST['config_value']);
        $config = load_config('open-orders');
        $config[$config_id] = $config_value;
        save_config('open-orders', $config);
        $config = load_config('open-orders');
        $ajaxResult = array();
        $ajaxResult['config_id'] = $config_id;
        $ajaxResult['config_value'] = $config[$config_id];
        ajaxReturn($ajaxResult);
    }
}
if (isset($_GET['preview']) && $_GET['preview'] == 'true') {
    //PREVIEW
    $languages_id = tep_db_prepare_input($_GET['languages_id']);
    $content = $obj->previewContent($languages_id);
    $title = 'Template Preview';
} else {
    if (isset($_GET['deleted']) && $_GET['deleted'] > 0) {
        $messagebox->add('Template ID ' . $_GET['deleted'] . ' is successfully deleted!', 'green');
Esempio n. 21
0
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
	<td width="5" valign="top"></td><td></td><td width="5"></td>
</tr>
<tr height="600" valign="top">
    <td background="../imagenes/borde_izq_tabla.png">&nbsp;</td>
    <td>&nbsp;
		<!--Todo el contenido de cada página--->
		<?php 
menu_interno();
switch ($op) {
    case "config":
        config();
        break;
    case "save_config":
        save_config($hora_1, $hora_2);
        config();
        break;
    case "borrar":
        borrar($id_, $for_id, $fechai, $fechaf, $orden);
        listado($orden, $fechai, $fechaf, $for_id, $reenviar);
        break;
    case "reenviar":
        reenviar($orden, $fechai, $fechaf, $for_id, $mails);
        listado($orden, $fechai, $fechaf, $for_id, $reenviar);
        break;
    case "del_all":
        del_all($orden, $fechai, $fechaf, $for_id, $mails);
        listado($orden, $fechai, $fechaf, $for_id, $reenviar);
        break;
    default:
        }
        save_config('forecasting', $forecasting_conf);
        $styles = $class_s->retrieveList('L', "s.styles_id = {$styles_id}");
        $result = displayLTFCollection($styles[0]['styles_id'], $styles[0]['name'], $styles[0]['products']);
        echo utf8_encode($result);
        exit;
    } elseif ($_POST['me_action'] == 'REMOVELTFCOLLECTION') {
        $target_id = tep_db_prepare_input($_POST['target_id']);
        $target_id_split = explode('-', $target_id);
        $styles_id = $target_id_split[2];
        $fc_vars = explode(',', $forecasting_conf[forecasting::CONFIG_KEY_LEVELLING_COLLECTION_IDS]);
        $styles_id_key = array_search($styles_id, $fc_vars);
        if ($styles_id_key !== false) {
            unset($fc_vars[$styles_id_key]);
            $forecasting_conf[forecasting::CONFIG_KEY_LEVELLING_COLLECTION_IDS] = implode(',', $fc_vars);
            save_config('forecasting', $forecasting_conf);
        }
        echo utf8_encode($target_id);
        exit;
    }
}
$year_start = '2013';
$year_end = date('Y') + 1;
$year_options = array();
for ($y = $year_start; $y <= $year_end; $y++) {
    $year_options[$y] = $y;
}
$week_options = array();
for ($w = 1; $w <= 52; $w++) {
    $week_options[$w] = str_pad($w, 2, '0', STR_PAD_LEFT);
}
         $type = str_replace('set-', '', $type);
     } elseif (stripos($type, 'set-pi-red-brand-') !== false) {
         $tmp = explode('-', $type);
         $brand_id = end($tmp);
         $is_added = $value == 1;
         if ($is_added && !in_array($brand_id, $brand_using_red_paper)) {
             $brand_using_red_paper[] = $brand_id;
             sort($brand_using_red_paper);
             $pi_settings['red-paper-brand-id'] = implode(',', $brand_using_red_paper);
             save_config('production-instruction-settings', $pi_settings);
         } elseif (!$is_added && in_array($brand_id, $brand_using_red_paper)) {
             $key = array_search($brand_id, $brand_using_red_paper);
             unset($brand_using_red_paper[$key]);
             sort($brand_using_red_paper);
             $pi_settings['red-paper-brand-id'] = implode(',', $brand_using_red_paper);
             save_config('production-instruction-settings', $pi_settings);
         }
         $value = $brand_id;
         $type = str_replace('set-', '', $type);
     } else {
         $pbgs = array('value' => $value);
         tep_db_perform('products_best_good_settings', $pbgs, 'update', "id={$type}");
     }
     $result['type'] = $type;
     $result['value'] = $value;
     ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'RECALCMARGIN') {
     set_time_limit(0);
     use_class('logger');
     $logger = new logger('cron', 'daily-counter-products-matexp');
Esempio n. 24
0
    Session::Set('error', 'static/user/ 不可写');
    redirect('install.php');
}
if (!$m) {
    Session::Set('error', '错误的数据库配置');
    redirect('install.php');
}
if (!mysql_select_db($db['name'], $m) && !mysql_query("CREATE database `{$db['name']}`;", $m)) {
    Session::Set('error', "选择数据库 {$db['name']} 错误,可能不存在?");
    redirect('install.php');
}
mysql_select_db($db['name'], $m);
$dir = dirname(__FILE__);
$sql = '';
$f = file($dir . '/include/db/db.sql');
foreach ($f as $l) {
    if (strpos(trim($l), '--') === 0 || strpos(trim($l), '/*') === 0 || !trim($l)) {
        continue;
    }
    $sql .= $l;
}
mysql_query("SET names UTF8;");
$sqls = explode(';', $sql);
foreach ($sqls as $sql) {
    mysql_query($sql, $m);
}
$PHP = $INI = array('db' => $db);
if (save_config()) {
    Session::Set('notice', '最土团购程序商业版安装成功,请及时删除根目录下install.php文件!');
}
redirect('index.php');
Esempio n. 25
0
 /**
  * @brief Update the database to the latest version
  *
  * @warning     Database Transactions won't work for the update process,
  *              because transactions don't work with "DROP TABLE" and "CREATE TABLE"!!
  *              So we use the config "$config['update']['next_step']" to memorize an error.
  *
  * @param boolean $continue_last_attempt        @li if true and the last update attempt was not successfully,
  *                                                  the update will continue at the last step which has produced an error
  *                                              @li if false, the update will start with the first update step,
  *                                                  even if there was an error. this is used if the user has loaded a
  *                                                  new database (backup last imported) after an update error.
  *
  * @retval array       the update log as an array: 'text' as string and 'error' as boolean (if this message is associated with an error).
  *
  * @throws Exception if there was an error
  *
  * @todo    the parameter "$continue_last_attempt" is not very pretty, it would be better if this function
  *          detects automatically if the user has loaded a new database.
  */
 public function update($continue_last_attempt = true)
 {
     global $config;
     $error = false;
     $log = array();
     //Lambda function to simply add a message to log
     $add_log = function ($msg, $err = false) use(&$log) {
         $log[] = array('text' => $msg, 'error' => $err);
     };
     $current = $this->get_current_version();
     $latest = $this->get_latest_version();
     if ($this->transaction_active) {
         throw new Exception('Ein Datenbankupdate kann nicht mitten in einer offenen Transaktion durchgeführt werden!');
     }
     // Later in the updateprocess, we will store the position of the update step in the config.php if an error occurs,
     // so the next attempt can start at the same position. But if the user has no write access to the config.php,
     // this will not work. So we will try to write the configs to the config.php now. If this is not successfully,
     // the function "save_config()" will throw an exception and the update proccess is aborted.
     save_config();
     debug('hint', 'Update von Datenbankversion "' . $current . '" auf Version "' . $latest . '" wird gestartet...');
     $add_log('Ihre Datenbank wird von der Version ' . $current . ' auf die Version ' . $latest . ' aktualisiert:');
     if (!in_array($config['db']['type'], array('sqlite', 'sqlite2'))) {
         // Lock Database
         try {
             $add_log('Datenbank wird gesperrt...');
             $query_data = $this->query("SELECT GET_LOCK('UpdatePartDB', 3)");
         } catch (Exception $exception) {
             $add_log('FEHLER: Wird zur Zeit schon ein Update durchgeführt?', true);
             $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
             $error = true;
         }
     }
     // change SQL mode
     try {
         $add_log('SQL_MODE wird gesetzt...');
         $this->execute("SET SQL_MODE=''");
     } catch (Exception $exception) {
         $add_log('FEHLER!', true);
         $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
         $error = true;
     }
     while ($current < $latest && !$error) {
         $add_log('');
         $add_log('Update v' . $current . ' --> v' . ($current + 1) . '...');
         $steps = get_db_update_steps($current);
         if (count($steps) == 0) {
             $add_log('FEHLER: Keine Updateschritte für Version ' . $current . ' gefunden!', true);
             $error = true;
             break;
         }
         if ($config['db']['update_error']['version'] == $current) {
             $start_position = $config['db']['update_error']['next_step'];
         } else {
             $start_position = 0;
         }
         // no error, start with the first update step
         for ($steps_pos = $start_position; $steps_pos < count($steps) && !$error; $steps_pos++) {
             $query = $this->convert_mysql_query($steps[$steps_pos]);
             if ($query === NULL) {
                 // for "dummys" (steps which are removed afterwards)
                 continue;
             }
             try {
                 $this->pdo->beginTransaction();
                 $this->pdo->exec($query);
                 $this->pdo->commit();
                 $add_log('Schritt: ' . $query . '...OK');
             } catch (PDOException $e) {
                 try {
                     $this->pdo->rollback();
                 } catch (PDOException $e2) {
                 }
                 // rollback last query, ignore exceptions
                 debug('error', '$query="' . $query . '"', __FILE__, __LINE__, __METHOD__);
                 debug('error', 'Fehlermeldung: "' . $e->getMessage() . '"', __FILE__, __LINE__, __METHOD__);
                 $add_log('Schritt: ' . $query . '...FEHLER!', true);
                 $add_log('Fehlermeldung: ' . $e->getMessage(), true);
                 $error = true;
                 break;
             }
         }
         // set the new database version
         if (!$error) {
             try {
                 if ($current != 0) {
                     $pdo_statement = $this->pdo->prepare("UPDATE internal SET keyValue=? WHERE keyName='dbVersion'");
                     $pdo_statement->bindValue(1, $current + 1);
                     $pdo_statement->execute();
                 }
             } catch (Exception $exception) {
                 $add_log('FEHLER: Die neue Version konnte nicht gesetzt werden!', true);
                 $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
                 $error = true;
                 break;
             }
         }
         try {
             // memorize the current steps position
             if ($error) {
                 $config['db']['update_error']['next_step'] = $steps_pos;
                 $config['db']['update_error']['version'] = $current;
             } else {
                 $config['db']['update_error']['next_step'] = 0;
                 $config['db']['update_error']['version'] = -1;
             }
             save_config();
         } catch (Exception $exception) {
             $add_log('FEHLER: Die aktuelle Update-Position konnte nicht in der config.php gespeichert werden!', true);
             $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
             $error = true;
             break;
         }
         if (!$error) {
             try {
                 $current = $this->get_current_version();
             } catch (Exception $exception) {
                 $add_log('FEHLER: Die aktuelle Version konnte nicht gelesen werden!', true);
                 $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
                 $error = true;
                 break;
             }
         }
         if ($current <= 1 && !$error) {
             $add_log('FEHLER: Die neue Version konnte nicht gesetzt werden!', true);
             $error = true;
             break;
         }
     }
     $add_log('');
     // change SQL mode
     try {
         $add_log('SQL_MODE wird gesetzt...');
         $this->execute("SET SQL_MODE='" . $this->sql_mode . "'");
     } catch (Exception $exception) {
         $add_log('FEHLER!', true);
         $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
         $error = true;
     }
     // Release Database
     if (!in_array($config['db']['type'], array('sqlite', 'sqlite2'))) {
         try {
             $add_log('Datenbank wird freigegeben...');
             $query_data = $this->query("SELECT RELEASE_LOCK('UpdatePartDB')");
         } catch (Exception $exception) {
             $add_log('FEHLER: Die Datenbank konnte nicht entsperrt werden!', true);
             $add_log('Fehlermeldung: ' . $exception->getMessage(), true);
             $error = true;
         }
     }
     if ($error) {
         debug('error', 'ABBRUCH: Das Update konnte nicht durchgeführt werden!');
         debug('error', 'Zweitletzte Zeile: ' . $log[count($log) - 2]['text']);
         debug('error', 'Letzte Zeile: ' . $log[count($log) - 1]['text']);
         $add_log('ABBRUCH: Das Update konnte nicht durchgeführt werden!', true);
     } else {
         debug('success', 'Das Update wurde erfolgreich durchgeführt.');
         $add_log('Das Update wurde erfolgreich durchgeführt.');
     }
     return $log;
 }
function add_files_to_archive_root(&$archive, $base_upload_dir, $user_template_dir, $base_preview_dir, $user_theme_name)
{
    save_config($base_preview_dir, $base_upload_dir, $user_theme_name);
    $paths = array('Readme.txt' => FilesHelper::normalizePath($user_template_dir . '/Readme.txt'), 'Config.xml' => FilesHelper::normalizePath($base_upload_dir . '/designer/Export/Config.xml'));
    foreach ($paths as $name => $path) {
        if (!file_exists($path)) {
            continue;
        }
        $dir = dirname($path);
        addToArchive($archive, $path, $dir);
    }
}
Esempio n. 27
0
         $_SESSION['completed']['allow_password_change'] = true;
     }
     break;
 case 'language':
     $GO_CONFIG->language = $_POST['language'];
     if (save_config($GO_CONFIG)) {
         $_SESSION['completed']['language'] = true;
     }
     break;
 case 'smtp':
     $GO_CONFIG->mailer = $_POST['mailer'];
     $GO_CONFIG->smtp_port = isset($_POST['smtp_port']) ? trim($_POST['smtp_port']) : '';
     $GO_CONFIG->smtp_server = isset($_POST['smtp_server']) ? trim($_POST['smtp_server']) : '';
     $GO_CONFIG->max_attachment_size = trim($_POST['max_attachment_size']);
     $GO_CONFIG->email_connectstring_options = trim($_POST['email_connectstring_options']);
     if (save_config($GO_CONFIG)) {
         $_SESSION['completed']['smtp'] = true;
     }
     break;
 case 'send_info':
     if ($_REQUEST['info'] != 'no') {
         $body = "Group-Office title: " . $GO_CONFIG->title . "\r\n";
         $body .= "Usage: " . $_REQUEST['info'] . "\r\n";
         $body .= "Users: " . $_REQUEST['users'] . "\r\n";
         $body .= "Host: " . $GO_CONFIG->full_url . "\r\n";
         $body .= "Webmaster: " . $GO_CONFIG->webmaster_email . "\r\n";
         if ($_REQUEST['email'] != '') {
             $body .= "Contact about Group-Office Professional at: " . $_REQUEST['email'] . "\r\n";
             $body .= "Name: " . $_REQUEST['name'] . "\r\n";
         }
         sendmail('*****@*****.**', $GO_CONFIG->webmaster_email, $GO_CONFIG->title, "Group-Office usage information", $body);
Esempio n. 28
0
/**
 * Save Auth code
 *
 * @param array $params
 *
 * @return string
 */
function save_authcode(&$params)
{
    // if authcode set in request, don't change the config file
    if (isset($params['auth_code']) && trim($params['auth_code']) != '') {
        return $params['auth_code'];
    }
    // generate new authcode
    $auth_code = generate_authcode();
    if (!@is_writable(LC_DIR_CONFIG . constant('LC_CONFIG_FILE')) || !($config = file(LC_DIR_CONFIG . constant('LC_CONFIG_FILE')))) {
        message(xtr('Cannot open config file \':filename\' for writing!', array(':filename' => constant('LC_CONFIG_FILE'))));
        exit;
    }
    $new_config = '';
    foreach ($config as $num => $line) {
        $new_config .= preg_replace('/^auth_code.*=.*/', 'auth_code = "' . $auth_code . '"', $line);
    }
    if (!save_config($new_config)) {
        message(xtr('Config file \':filename\' write failed!', array(':filename' => constant('LC_CONFIG_FILE'))));
        exit;
    }
    return get_authcode();
}
Esempio n. 29
0
	need_manager(true);
	unset($_POST['commit']);
	$INI = Config::MergeINI($INI, $_POST);
	$INI = ZSystem::GetUnsetINI($INI);

	$INI['system']['gzip'] = abs(intval($INI['system']['gzip']>0));
	$INI['system']['partnerdown'] = abs(intval($INI['system']['partnerdown']>0));
	$INI['system']['conduser'] = abs(intval($INI['system']['conduser']>0));
	$INI['system']['currencyname'] = strtoupper($INI['system']['currencyname']);
	//2013.07.29
	$sorts = array('MO', 'NO', 'AF', 'NI');
	$sorts_key = array_search($INI['system']['sorttype'], $sorts);
	if(!$sorts_key) $sorts_key = 0;
	$INI['system']['sorttype'] = $sorts[($sorts_key + 1)%4];
	
	save_config();

	$value = Utility::ExtraEncode($INI);
	$table = new Table('system', array('value'=>$value));
	if ( $system ) $table->SetPK('id', 1);
	$flag = $table->update(array( 'value'));
    log_admin('system', '编辑基本设置',$_POST);
	Session::Set('notice', '更新系统信息成功');
	redirect( null );
}

include template("manage_system_index{$ts}");

function current_system_index($s=null) {
	global $city;
	$filter = array(
/**
 * Switch the environment
 */
function pantheon_switch_environment($current_env_id)
{
    global $script, $env_id, $config;
    $environments = ['dev', 'test', 'live'];
    foreach ($environments as $env) {
        if ($env == $current_env_id) {
            break;
        }
    }
    $next_env = current($environments) ? current($environments) : 'dev';
    $config->env_id = $next_env;
    save_config($config);
}