Esempio n. 1
0
 public function buildFullTemplate($sections, $replacementTags, $useRegEx = false)
 {
     $content = '';
     foreach ($sections as $section => $notFoundReturn) {
         $content .= getSection($section, $notFoundReturn);
     }
     if ($useRegEx) {
         $search = array_keys($replacementTags);
         $replace = array_values($replacementTags);
         $content = preg_replace($search, $replace, $content);
     } else {
         foreach ($replacementTags as $search => $replace) {
             $content = str_replace($search, $replace, $content);
         }
     }
     return $content;
 }
Esempio n. 2
0
/**
 * Function Save
 *
 *
 * @return string
 */
function Save()
{
    global $page_template, $error_response, $session_dir;
    $tagSearch = array();
    $varReplace = array();
    $pattern = "RANDOM PICKUP LINE";
    $errorMessage = '';
    #$error_response = "No AIML category found. This is a Default Response.";
    $conversation_lines = '1';
    $remember_up_to = '10';
    $_SESSION['errorMessage'] = '';
    // First off, write the config file
    $myPostVars = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    ksort($myPostVars);
    $configContents = file_get_contents(_INSTALL_PATH_ . 'config.template.php');
    $configContents = str_replace('[session_dir]', $session_dir, $configContents);
    if (!file_exists(_SESSION_PATH_)) {
        // Create the sessions folder, and set permissions
        mkdir(_SESSION_PATH_, 0755);
        // Place an empty index file in the sessions folder to prevent direct access to the folder from a web browser
        file_put_contents(_SESSION_PATH_ . 'index.html', '');
    }
    foreach ($myPostVars as $key => $value) {
        $tagSearch[] = "[{$key}]";
        $varReplace[] = $value;
    }
    $configContents = str_replace($tagSearch, $varReplace, $configContents);
    $saveFile = file_put_contents(_CONF_PATH_ . 'global_config.php', $configContents);
    // Now, update the data to the database, starting with making sure the tables are installed
    $dbh = $myPostVars['dbh'];
    $dbn = $myPostVars['dbn'];
    $dbu = $myPostVars['dbu'];
    $dbp = $myPostVars['dbp'];
    try {
        $dbConn = new PDO("mysql:host={$dbh};dbname={$dbn};charset=utf8", $dbu, $dbp);
        $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $dbConn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
    } catch (Exception $e) {
        header('Content-type: text/plain');
        var_dump($e);
        exit('Cannot connect to the database! ' . $e->getMessage());
    }
    $sql = "show tables;";
    $sth = $dbConn->prepare($sql);
    $sth->execute();
    $row = $sth->fetch();
    if (empty($row)) {
        $sql = file_get_contents('new.sql');
        $sth = $dbConn->prepare($sql);
        $sth->execute();
        $affectedRows = $sth->rowCount();
    } else {
        // Let's make sure that the srai lookup table exists
        try {
            $sql = 'select bot_id from srai_lookup;';
            $sth = $dbConn->prepare($sql);
            $sth->execute();
            $result = $sth->fetchAll();
        } catch (Exception $e) {
            try {
                $sql = "DROP TABLE IF EXISTS `srai_lookup`; CREATE TABLE IF NOT EXISTS `srai_lookup` (`id` int(11) NOT NULL AUTO_INCREMENT, `bot_id` int(11) NOT NULL, `pattern` text NOT NULL, `template_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `pattern` (`pattern`(64)) COMMENT 'Search against this for performance boost') ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Contains previously stored SRAI calls' AUTO_INCREMENT=1;";
                $sth = $dbConn->prepare($sql);
                $sth->execute();
            } catch (Exception $e) {
                $errorMessage .= 'Could not add SRAI lookup table! Error is: ' . $e->getMessage();
            }
        }
    }
    $sql = 'select `error_response` from `bots` where 1 limit 1';
    $sth = $dbConn->prepare($sql);
    $sth->execute();
    $row = $sth->fetch();
    $error_response = $row['error_response'];
    $sql = 'select `bot_id` from `bots`;';
    $sth = $dbConn->prepare($sql);
    $sth->execute();
    $result = $sth->fetchAll();
    if (count($result) == 0) {
        $sql_template = "\nINSERT IGNORE INTO `bots` (`bot_id`, `bot_name`, `bot_desc`, `bot_active`, `bot_parent_id`, `format`, `save_state`, `conversation_lines`, `remember_up_to`, `debugemail`, `debugshow`, `debugmode`, `error_response`, `default_aiml_pattern`)\nVALUES ([default_bot_id], '[bot_name]', '[bot_desc]', '[bot_active]', '[bot_parent_id]', '[format]', '[save_state]',\n'{$conversation_lines}', '{$remember_up_to}', '[debugemail]', '[debugshow]', '[debugmode]', '{$error_response}', '{$pattern}');";
        $bot_id = 1;
        $sql = str_replace('[default_bot_id]', $bot_id, $sql_template);
        $sql = str_replace('[bot_name]', $myPostVars['bot_name'], $sql);
        $sql = str_replace('[bot_desc]', $myPostVars['bot_desc'], $sql);
        $sql = str_replace('[bot_active]', $myPostVars['bot_active'], $sql);
        $sql = str_replace('[bot_parent_id]', 1, $sql);
        $sql = str_replace('[format]', $myPostVars['format'], $sql);
        // "Use PHP from DB setting
        // "Update PHP in DB setting
        $sql = str_replace('[save_state]', $myPostVars['save_state'], $sql);
        $sql = str_replace('[conversation_lines]', $conversation_lines, $sql);
        $sql = str_replace('[remember_up_to]', $remember_up_to, $sql);
        $sql = str_replace('[debugemail]', $myPostVars['debugemail'], $sql);
        $sql = str_replace('[debugshow]', $myPostVars['debug_level'], $sql);
        $sql = str_replace('[debugmode]', $myPostVars['debug_mode'], $sql);
        $sql = str_replace('[error_response]', $error_response, $sql);
        $sql = str_replace('[aiml_pattern]', $pattern, $sql);
        try {
            $sth = $dbConn->prepare($sql);
            $sth->execute();
            $affectedRows = $sth->rowCount();
            $errorMessage .= $affectedRows > 0 ? '' : ' Could not create new bot!';
        } catch (Exception $e) {
            $errorMessage .= $e->getMessage();
        }
    }
    $cur_ip = $_SERVER['REMOTE_ADDR'];
    $encrypted_adm_dbp = md5($myPostVars['adm_dbp']);
    $adm_dbu = $myPostVars['adm_dbu'];
    $sql = "select id from `myprogramo` where `user_name` = '{$adm_dbu}' and `password` = '{$encrypted_adm_dbp}';";
    $sth = $dbConn->prepare($sql);
    $sth->execute();
    $result = $sth->fetchAll();
    if (count($result) == 0) {
        $sql = "insert ignore into `myprogramo` (`id`, `user_name`, `password`, `last_ip`) values(null, '{$adm_dbu}', '{$encrypted_adm_dbp}', '{$cur_ip}');";
        try {
            $sth = $dbConn->prepare($sql);
            $sth->execute();
            $affectedRows = $sth->rowCount();
            $errorMessage .= $affectedRows > 0 ? '' : ' Could not create new Admin!';
        } catch (Exception $e) {
            $errorMessage .= $e->getMessage();
        }
    }
    if (empty($errorMessage)) {
        $out = getSection('InstallComplete', $page_template);
    } else {
        $out = getSection('InstallError', $page_template);
    }
    return $out . $errorMessage;
}
Esempio n. 3
0
function Save()
{
    global $page_template;
    $default_pattern = "RANDOM PICKUP LINE";
    $default_error_response = "No AIML category found. This is a Default Response.";
    $default_conversation_lines = '1';
    $default_remember_up_to = '10';
    $_SESSION['errorMessage'] = '';
    // First off, write the config file
    $myPostVars = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    ksort($myPostVars);
    $configContents = file_get_contents(_CONF_PATH_ . 'global_config.tpl');
    foreach ($myPostVars as $key => $value) {
        $tagSearch[] = "[{$key}]";
        $varReplace[] = $value;
    }
    $configContents = str_replace($tagSearch, $varReplace, $configContents);
    $saveFile = file_put_contents(_CONF_PATH_ . 'global_config.php', $configContents);
    #die("<pre>Executing function Save - Config file saved as config.php.test\n\n</pre>\n");
    // Now, update the data to the database, starting with making sure the tables are installed
    $sql = "show tables;";
    $conn = mysql_connect($myPostVars['dbh'], $myPostVars['dbu'], $myPostVars['dbp']) or install_error('Could not connect to the database!', mysql_error(), $sql);
    $dbn = $myPostVars['dbn'];
    $db = mysql_select_db($dbn, $conn) or install_error("Can't select the database {$dbn}!", mysql_error(), "use {$dbn}");
    $result = mysql_query($sql, $conn) or install_error('Unknown database error!', mysql_error(), $sql);
    $out = mysql_fetch_assoc($result);
    if (empty($out)) {
        $sql = file_get_contents('new.sql');
        $queries = preg_split("/;/", $sql);
        foreach ($queries as $query) {
            if (strlen(trim($query)) > 0) {
                $result = mysql_query($query, $conn) or install_error('Error creating new tables for DB!', mysql_error(), $sql);
                $success = mysql_affected_rows();
            }
        }
    }
    $sql = 'select `error_response` from `bots` where 1 limit 1';
    $result = mysql_query($sql, $conn) or upgrade($conn);
    $sql = 'select `php_code` from `aiml` where 1 limit 1';
    $result = mysql_query($sql, $conn) or upgrade($conn);
    //  $default_pattern, $default_remember_up_to, $default_conversation_lines, $default_error_response
    $sql_template = "\nINSERT IGNORE INTO `bots` (`bot_id`, `bot_name`, `bot_desc`, `bot_active`, `bot_parent_id`, `format`, `use_aiml_code`, `update_aiml_code`, `save_state`, `conversation_lines`, `remember_up_to`, `debugemail`, `debugshow`, `debugmode`, `error_response`, `default_aiml_pattern`)\nVALUES ([bot_id], '[bot_name]', '[bot_desc]', '[bot_active]', '[bot_parent_id]', '[format]', '[use_aiml_code]', '[update_aiml_code]', '[save_state]', \n'{$default_conversation_lines}', '{$default_remember_up_to}', '[debugemail]', '[debugshow]', '[debugmode]', '{$default_error_response}', '{$default_pattern}');";
    require_once _LIB_PATH_ . 'error_functions.php';
    require_once _LIB_PATH_ . 'db_functions.php';
    $bot_id = 1;
    $sql = str_replace('[bot_id]', $bot_id, $sql_template);
    $sql = str_replace('[bot_name]', $myPostVars["bot_name"], $sql);
    $sql = str_replace('[bot_desc]', $myPostVars["bot_desc"], $sql);
    $sql = str_replace('[bot_active]', $myPostVars["bot_active"], $sql);
    $sql = str_replace('[bot_parent_id]', 1, $sql);
    $sql = str_replace('[format]', $myPostVars["default_format"], $sql);
    // "Use PHP from DB setting
    if (!isset($myPostVars["default_use_aiml_code"])) {
        $myPostVars["default_use_aiml_code"] = 0;
    }
    $sql = str_replace('[use_aiml_code]', $myPostVars["default_use_aiml_code"], $sql);
    // "Update PHP in DB setting
    if (!isset($myPostVars["default_update_aiml_code"])) {
        $myPostVars["default_update_aiml_code"] = 0;
    }
    $sql = str_replace('[update_aiml_code]', $myPostVars["default_update_aiml_code"], $sql);
    $sql = str_replace('[save_state]', $myPostVars["default_save_state"], $sql);
    $sql = str_replace('[conversation_lines]', $default_conversation_lines, $sql);
    $sql = str_replace('[remember_up_to]', $default_remember_up_to, $sql);
    $sql = str_replace('[debugemail]', $myPostVars["default_debugemail"], $sql);
    $sql = str_replace('[debugshow]', $myPostVars["default_debugshow"], $sql);
    $sql = str_replace('[debugmode]', $myPostVars["default_debugmode"], $sql);
    $sql = str_replace('[error_response]', $default_error_response, $sql);
    $sql = str_replace('[default_aiml_pattern]', $default_pattern, $sql);
    $save = file_put_contents(_CONF_PATH_ . 'sql.txt', $sql);
    $x = db_query($sql, $conn) or install_error('Could not enter bot info for bot #' . $bot_id . '!', mysql_error(), $sql);
    $encrypted_adm_dbp = md5($myPostVars["adm_dbp"]);
    $adm_dbu = $myPostVars["adm_dbu"];
    $cur_ip = $_SERVER['REMOTE_ADDR'];
    $adminSQL = "insert ignore into `myprogramo` (`id`, `uname`, `pword`, `lastip`) values(null, '{$adm_dbu}', '{$encrypted_adm_dbp}', '{$cur_ip}');";
    $result = db_query($adminSQL, $conn) or install_error('Could not add admin credentials! Check line #' . __LINE__, mysql_error(), $sql);
    mysql_close($conn);
    return ($result and empty($_SESSION['errorMessage'])) ? getSection('InstallComplete', $page_template) : getSection('InstallError', $page_template);
}
Esempio n. 4
0
    if (substr(JVERSION, 0, 3) >= '1.6') {
        return NULL;
    } elseif (JRequest::getCmd('view', 0) == "section") {
        return $id;
    } elseif (JRequest::getCmd('view', 0) == "category") {
        $sql = "SELECT section FROM #__categories WHERE id = {$id} ";
        $database->setQuery($sql);
        return $database->loadResult();
    } elseif (JRequest::getCmd('view', 0) == "article") {
        $temp = explode(":", $id);
        $sql = "SELECT sectionid FROM #__content WHERE id = " . $temp[0];
        $database->setQuery($sql);
        return $database->loadResult();
    }
}
$sectionId = getSection(JRequest::getInt('id'));
#------------------------------ Category ID -------------------------------#
function getCategory($id)
{
    $database = JFactory::getDBO();
    if (JRequest::getCmd('view', 0) == "section") {
        return NULL;
    } elseif (JRequest::getCmd('view', 0) == "category" || JRequest::getCmd('view', 0) == "categories") {
        return $id;
    } elseif (JRequest::getCmd('view', 0) == "article") {
        $temp = explode(":", $id);
        $sql = "SELECT catid FROM #__content WHERE id = " . $temp[0];
        $database->setQuery($sql);
        return $database->loadResult();
    }
}
Esempio n. 5
0
if (isset($_SESSION['droits'])) {
    $droits = $_SESSION['droits'];
}
$action = false;
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
}
if ($droits == 'maitre' || $droits == 'moderateur') {
    if ($action == 'ajoutSection') {
        $reponse = ajoutSection();
    } else {
        if ($action == 'supprSection') {
            $reponse = supprSection();
        } else {
            if ($action == 'getSection') {
                $reponse = getSection();
            } else {
                if ($action == 'editSection') {
                    $reponse = editSection();
                } else {
                    if ($action == 'ajoutPost') {
                        $reponse = ajoutPost();
                    } else {
                        if ($action == 'ajoutFil') {
                            $reponse = ajoutFil();
                        } else {
                            if ($action == 'editPost') {
                                $reponse = editerPost();
                            } else {
                                if ($action == 'getPost') {
                                    $reponse = getPost();
Esempio n. 6
0
function drawMenu($appurl, $phpurl, $doc, $section, $menuOrder)
{
    /* function drawMenu
    		void function
    
    		PURPOSE: draw the sidebar menu for the finding aids
    		PARAMS:
    			phpurl = the URL of the PHP script we're acting on
    			appurl = the URL of the env-sensitive path to the eXibit db
    			doc = the LDPD # of the finding aid
    			section = the section being queried (to provide context-sensitive nav)
    
    		ASSUMPTIONS:
    			main method produced viable, non-null variables
    
    	*/
    $final = "";
    foreach (array_keys($menuOrder) as $k) {
        $final .= '<div class="item">';
        /*
        			if ($k == $section)
        				$final .= "<span style=color:#336699;>&raquo;&nbsp;</span>";
        		
        			else
        				$final .=  "&nbsp;&nbsp;&nbsp;";
        */
        //$final .=  '<a href="' . $phpurl . $doc . '/' . '">';
        if ($section == "dsc") {
            $final .= '<a href="' . $phpurl . $doc . '/summary#' . $k . '">';
        } else {
            $final .= '<a href="#' . $k . '">';
        }
        $final .= $menuOrder[$k] . '</a>';
        if ($k == "using_collection") {
            $accessRestrict = getSection($appurl, $phpurl, $doc, $section, $menuOrder, "access");
            $count = isRestricted($accessRestrict);
            if ($count > 0) {
                $final .= "<br /><span class=\"highlight\"><a href=\"" . $phpurl . $doc . "/summary#using_collection\" class=\"highlight\" style=\"text-decoration:none;font-size:10px;font-weight:normal;\">Note: some material may be restricted or offsite</a></span>";
            }
        }
        $final .= "</div>";
    }
    // end FOREACH $menuOrder
    /*
    $accessRestrict = getSection($appurl, $phpurl, $doc, $section, $menuOrder, "access");
    $count = isRestricted($accessRestrict);
    if ($count > 0) 
    $final .= "<div class=\"highlight\"><a href=\"" . $phpurl . $doc . "/summary#using_collection\" class=\"highlight\" style=\"text-decoration:none;\">!</a></div>";
    */
    return $final;
}
Esempio n. 7
0
function getFile()
{
    $file = implode(".", array(getSection(), 'php'));
    if (file_exists($file)) {
        return $file;
    }
    return false;
}
Esempio n. 8
0
function get_cats_urls()
{
    global $sitemapstr, $numlinks;
    $cats = get_cats_ar();
    $def = "http://ychebniki.ru/categories/catlist/";
    foreach ($cats as $key => $val) {
        $isFinish = false;
        $section = getSection($val['topcat']);
        $url = $def . "section/" . $section . "/";
        if ($val['cat'] != 0) {
            $url .= "cat/" . $val['cat'];
        }
        $sitemapstr .= get_sitemap_url($url, 0.5);
        $numlinks++;
        if ($numlinks > 39999) {
            finish_file();
        }
    }
}
Esempio n. 9
0
On<?php 
    }
    ?>
">Programming</a></td>
								</tr>
								<tr>
									<td class="navSubSection"><a href="ProductDesign.action" class="subNav<?php 
    if (getSubSection() == "productDesign") {
        ?>
On<?php 
    }
    ?>
">Product Design</a></td>
								</tr>
							<?php 
} elseif (getSection() == "blog") {
    $posts = get("posts");
    ?>
								<tr>
									<td id="blogPosts">
									<?php 
    foreach ($posts as $curPost) {
        ?>
										<div><a href="Blog.action?blogId=<?php 
        echo $curPost->getId();
        ?>
"><?php 
        echo $curPost->getTitle();
        ?>
</a> <span class="aside"><br /><?php 
        echo $curPost->getDateCreated();
Esempio n. 10
0
//Program-O  chatbot admin area
//Written by Elizabeth Perreau and Dave Morton
//May 2011
//for more information and support please visit www.program-o.com
//-----------------------------------------------------------------------------------------------
// help.php
ini_set("display_errors", false);
ini_set("log_errors", true);
ini_set("error_log", "../logs/error.log");
define('SECTION_START', '<!-- Section [section] Start -->');
# search params for start and end of sections
define('SECTION_END', '<!-- Section [section] End -->');
# search params for start and end of sections
$template = file_get_contents('help.tpl.htm');
$content = getSection('HelpPage', $template, false);
$helpContent = getSection('HelpMain', $template);
$content = str_replace('[helpContent]', $helpContent, $content);
die($content);
function getSection($sectionName, $page_template, $notFoundReturn = true)
{
    $sectionStart = str_replace('[section]', $sectionName, SECTION_START);
    $sectionStartLen = strlen($sectionStart);
    $sectionEnd = str_replace('[section]', $sectionName, SECTION_END);
    $startPos = strpos($page_template, $sectionStart, 0);
    if ($startPos === false) {
        if ($notFoundReturn) {
            return '';
        } else {
            $startPos = 0;
        }
    } else {
Esempio n. 11
0
    echo $thisCat->name;
    ?>
</h2>
						</div>
						<div class="box-content">
							<?php 
    $wpquery_args = array('post_type' => $thisPostType, 'tax_query' => array(array('taxonomy' => $thisTax, 'field' => 'slug', 'terms' => $thisCat->slug)), 'meta_query' => array(array('key' => '_netevl_' . $thisPostType . '_skupina', 'value' => 'standardy')));
    $posts = new WP_Query($wpquery_args);
    if ($posts->post_count > 0) {
        getSection('Standardy', $posts, $thisPostType);
    }
    wp_reset_postdata();
    $wpquery_args = array('post_type' => $thisPostType, 'tax_query' => array(array('taxonomy' => $thisTax, 'field' => 'slug', 'terms' => $thisCat->slug)), 'meta_query' => array(array('key' => '_netevl_' . $thisPostType . '_skupina', 'value' => 'interpretace')));
    $posts = new WP_Query($wpquery_args);
    if ($posts->post_count > 0) {
        getSection('Interpretace', $posts, $thisPostType);
    }
    wp_reset_postdata();
    ?>
						</div>
					</div>
					<?php 
}
?>
				</main>
				<?php 
get_sidebar();
?>
			</div>
		</div>
	</div>
Esempio n. 12
0
/////////  added here for php5 ? ... menotume 2006/4/15
sessionStaticInfo();
/////////////////
if (isset($_POST['settheme'])) {
    $theme = $_POST['settheme'];
    setcookie('themename', $theme, time() + 60 * 60 * 24 * 60, '/');
} else {
    $theme = $_COOKIE['themename'];
}
if (!$theme) {
    $theme = DEFAULT_THEME;
}
if ($_SESSION['required']) {
    $_POST['link'] = 'required';
}
getSection($phpFile, $phpFunc, $SectionTitle);
require_once $phpFile;
if (!function_exists($phpFunc)) {
    echo "FATAL ERROR: function <b>{$func}</b> does not exist in <b>{$phpFile}</b>!";
    exit;
}
define(THEME_NAME, $theme);
define(THEME_DIR, $_SESSION['themes'][$theme][1] . '/');
define(FLAG_DIR, "templates/flags/");
if (isAuthenticated()) {
    $Authenticated = true;
    $UserName = $_SESSION['callsign'];
    $UserID = $_SESSION['playerid'];
    $UserLevel = $_SESSION['level'];
    // ADDED BY BLAST007 TO COMBAT SPAM
    if (strtolower($UserName) == 'sportcunt') {