Exemplo n.º 1
0
 public function _initialize()
 {
     // 模板全局变量
     $aConfVars = array('TITLE', 'SITE_TITLE', 'SITE_COMPANY', 'VAR_REDIRECT');
     $aTplVars = array();
     foreach ($aConfVars as $v) {
         $aTplVars[strtolower($v)] = tl(C($v));
     }
     $this->assign('G_VAR', $aTplVars);
     // 登录认证判断
     $oAminAuth = $this->auth = new t\AdminAuth();
     if ($oAminAuth->isLogin()) {
         $this->_account = $oAminAuth->getUser();
         $this->assign('ACCOUNT', $this->_account);
         if (!strcasecmp(CONTROLLER_NAME, 'Index')) {
         } elseif (!strcasecmp(CONTROLLER_NAME, 'Public')) {
         } else {
             if (!$this->check_access($this->_account['role_id'])) {
                 $this->error("您没有访问权限!", null, -1);
                 //不需要跳转
                 exit;
             }
         }
     } else {
         if (strcasecmp(CONTROLLER_NAME, 'Public')) {
             $tipMsg = strcasecmp(ACTION_NAME, 'login') ? "操作需要登录才能进行" : '';
             $oAminAuth->redirectLogin($tipMsg);
             // 注意:代码永远运行到此处,调用redirect后,程序已经exit
         }
     }
 }
Exemplo n.º 2
0
    /**
     * Draws a simple message saying no cache available of
     * the requested page
     *
     * @param array $data   at this point this view does not make
     * use of the $data info passed to it.
     */
    function renderView($data)
    {
        ?>
        <h1><?php 
        e(tl('nocache_view_no_cache'));
        ?>
</h1>
        <p>
        <a href="<?php 
        e($data['URL']);
        ?>
"><?php 
        e($data['URL']);
        ?>
</a>.<br />
        </p>
        <?php 
        if (isset($data["SUMMARY_STRING"])) {
            ?>
           <p><?php 
            e(tl('nocache_view_summary_contents'));
            ?>
</p>
           <pre>
           <?php 
            e($data["SUMMARY_STRING"]);
            ?>
           </pre>
        <?php 
        }
    }
Exemplo n.º 3
0
 /**
  * Method responsible for drawing links to common subsearches
  *
  * @param array $data makes use of the CSRF token for anti CSRF attacks
  */
 function render($data)
 {
     if (!SUBSEARCH_LINK) {
         return;
     }
     $logged_in = isset($data["ADMIN"]) && $data["ADMIN"];
     if (!isset($data['SUBSEARCH'])) {
         $data['SUBSEARCH'] = "";
     }
     $drop_threshold = 4;
     if (MOBILE) {
         $drop_threshold = 0;
     }
     ?>
         <div class="subsearch" >
         <ul class="out-list">
             <?php 
     $i = 0;
     $found = false;
     foreach ($data["SUBSEARCHES"] as $search) {
         if ($i >= $drop_threshold && ($found || MOBILE)) {
             $append_token = $logged_in ? "&amp;" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] : "";
             e("<li class='outer'><a " . " href='?a=more{$append_token}' ><b>" . tl('subsearch_element_more') . "</b></a>");
             break;
         }
         $i++;
         $source = "?s={$search["FOLDER_NAME"]}";
         $delim = "&amp;";
         if ($search["FOLDER_NAME"] == "") {
             $source = "./";
             $delim = "?";
         }
         if ($search['FOLDER_NAME'] == $data['SUBSEARCH']) {
             e("<li class='outer'><b>" . "{$search['SUBSEARCH_NAME']}</b></li>");
             $found = true;
         } else {
             if ($i <= $drop_threshold) {
                 $query = "";
                 if (isset($data[CSRF_TOKEN]) && $logged_in) {
                     $query .= $delim . CSRF_TOKEN . "=" . $data[CSRF_TOKEN];
                 }
                 if (isset($data['QUERY']) && !isset($data['NO_QUERY'])) {
                     $query .= "{$delim}c=search" . "&amp;q={$data['QUERY']}";
                 }
                 e("<li class='outer'><a href='{$source}{$query}'>" . "{$search['SUBSEARCH_NAME']}</a></li>");
             }
         }
     }
     if ($i > $drop_threshold + 1) {
         e("</ul></div></li>");
     }
     ?>
         </ul>
         </div>
     <?php 
 }
Exemplo n.º 4
0
Arquivo: view.php Projeto: yakar/yioop
 /**
  * The constructor reads in any Element and Helper subclasses which are
  * needed to draw the view. It also reads in the Layout subclass on which
  * the View will be drawn.
  *
  */
 function __construct()
 {
     $layout_name = ucfirst($this->layout) . "Layout";
     if ($this->layout != "") {
         if (file_exists(APP_DIR . "/views/layouts/" . $this->layout . "_layout.php")) {
             require_once APP_DIR . "/views/layouts/" . $this->layout . "_layout.php";
         } else {
             require_once BASE_DIR . "/views/layouts/" . $this->layout . "_layout.php";
         }
     }
     $this->logo_alt_text = tl('view_logo_alt_text');
     $this->layout_object = new $layout_name($this);
 }
Exemplo n.º 5
0
    /**
     * Takes page summaries for image pages and the current query
     * and draw a thumbnail strip so that clicking on an image goes to
     * the cache of that image.
     *
     * @param array $image_pages page data and thumbnails for images
     * @param string $query the current search query
     * @param string $subsearch name of subsearch page this image group on
     */
    function render($image_pages, $query, $subsearch)
    {
        if ($subsearch != 'images') {
            ?>
            <h2><a href="<?php 
            e($query . '&s=images');
            ?>
"
                ><?php 
            e(tl('images_helper_view_image_results'));
            ?>
</a></h2>
        <?php 
        }
        ?>
            <div class="image-list">
        <?php 
        $i = 0;
        $break_frequency = 5;
        foreach ($image_pages as $page) {
            if (CACHE_LINK && (!isset($page[self::ROBOT_METAS]) || !(in_array("NOARCHIVE", $page[self::ROBOT_METAS]) || in_array("NONE", $page[self::ROBOT_METAS])))) {
                $link = $query . "&amp;a=cache&amp;arg=" . urlencode($page[self::URL]) . "&amp;its=" . $page[self::CRAWL_TIME];
            } else {
                $link = htmlentities($page[self::URL]);
            }
            ?>
            <a href="<?php 
            e($link);
            ?>
" rel="nofollow"
            ><img src="<?php 
            e($page[self::THUMB]);
            ?>
" alt="<?php 
            e($page[self::TITLE]);
            ?>
"  /></a>
        <?php 
            $i++;
            if ($i % $break_frequency == 0) {
                e('<br />');
            }
        }
        ?>
        </div>
        <?php 
    }
Exemplo n.º 6
0
function recursive_print_data($data, $l)
{
    if (!is_array($data)) {
        echo tl($l) . htmlentities($data) . "\n";
    } else {
        $width_attr = $l > 0 ? "width='100%'" : "";
        echo tl($l) . "<table border='1' " . $width_attr . ">\n";
        foreach ($data as $key => $value) {
            echo tl($l + 1) . "<tr>\n";
            echo tl($l + 2) . "<td align='center'>\n";
            echo tl($l + 3) . "<b>" . htmlentities($key) . "</b>\n";
            echo tl($l + 2) . "</td>\n";
            echo tl($l + 2) . "<td align='center'>\n";
            recursive_print_data($value, $l + 3);
            echo tl($l + 2) . "</td>\n";
            echo tl($l + 1) . "</tr>\n";
        }
        echo tl($l) . "</table>\n";
    }
}
Exemplo n.º 7
0
                    }
                }
            }
        }
    }
    echo '<p>';
    if (strlen($website) == 0) {
        echo '<strong>' . $person . '</strong><br/>' . $role;
    } else {
        echo '<strong>' . $person . '</strong><br/><a href="http://' . parseLink($website) . '/">' . $role . '</a>';
    }
    echo '</p>';
}
echo '						</div>
						<div class="uk-width-medium-1-2">
							<h2 id="contact">' . tl('Contact') . '</h2>';
for ($i = 0; $i < count($contacts); $i++) {
    $link = $mail = $name = "";
    foreach ($contacts[$i]['contact']->children() as $child) {
        if ($child->getName() == "name") {
            $name = $child;
        } else {
            if ($child->getName() == "link") {
                $link = $child;
            } else {
                if ($child->getName() == "mail") {
                    $mail = $child;
                }
            }
        }
    }
             //echo "<font color='red'>$modulename is installed but not active.</font><br>";
             $installcheck = true;
         } else {
             //echo "$modulename is uninstalled.<br>";
             $uninstallcheck = true;
         }
         if (isset($moduleinfo['invalid']) && $moduleinfo['invalid'] == true) {
             rawoutput("<td><input type='radio' name='modules[{$modulename}]' id='uninstall-{$modulename}' value='{$uninstallop}' checked disabled></td>");
             rawoutput("<td><input type='radio' name='modules[{$modulename}]' id='install-{$modulename}' value='{$installop}' disabled></td>");
             rawoutput("<td><input type='radio' name='modules[{$modulename}]' id='activate-{$modulename}' value='{$activateop}' disabled></td>");
         } else {
             rawoutput("<td><input type='radio' name='modules[{$modulename}]' id='uninstall-{$modulename}' value='{$uninstallop}'" . ($uninstallcheck ? " checked" : "") . "></td>");
             rawoutput("<td><input type='radio' name='modules[{$modulename}]' id='install-{$modulename}' value='{$installop}'" . ($installcheck ? " checked" : "") . "></td>");
             rawoutput("<td><input type='radio' name='modules[{$modulename}]' id='activate-{$modulename}' value='{$activateop}'" . ($activatecheck ? " checked" : "") . "></td>");
         }
         output_notl("<td>" . (in_array($modulename, $recommended_modules) ? tl("`^Yes`0") : tl("`\$No`0")) . "</td>", true);
         require_once "lib/sanitize.php";
         rawoutput("<td><span title=\"" . (isset($moduleinfo['description']) && $moduleinfo['description'] ? $moduleinfo['description'] : sanitize($moduleinfo['formalname'])) . "\">");
         output_notl("`@");
         if (isset($moduleinfo['invalid']) && $moduleinfo['invalid'] == true) {
             rawoutput($moduleinfo['formalname']);
         } else {
             output($moduleinfo['formalname']);
         }
         output_notl(" [`%{$modulename}`@]`0");
         rawoutput("</span></td><td>");
         output_notl("`#{$moduleinfo['moduleauthor']}`0", true);
         rawoutput("</td>");
         rawoutput("</tr>");
     }
 }
Exemplo n.º 9
0
    /**
     * Element used to render the login screen for the admin control panel
     *
     * @param array $data many data from the controller for the footer
     *     (so far none)
     */
    function render($data)
    {
        $logged_in = isset($data['ADMIN']) && $data['ADMIN'];
        if (isset($_SERVER["PATH_INFO"]) && $logged_in) {
            $path_info = $_SERVER["PATH_INFO"];
        } else {
            $path_info = ".";
        }
        $tools = isset($data[CSRF_TOKEN]) && $logged_in ? "?a=more&amp;" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] : "?a=more";
        ?>
            <div>
            - <a href="<?php 
        e($path_info);
        ?>
/blog.php"><?php 
        e(tl('footer_element_blog'));
        ?>
</a> -
            <a href="<?php 
        e($path_info);
        ?>
/privacy.php"><?php 
        e(tl('footer_element_privacy'));
        ?>
</a> -
            <a href="<?php 
        e($path_info);
        ?>
/terms.php"><?php 
        e(tl('footer_element_terms'));
        ?>
</a> -
            <a href="<?php 
        e($path_info);
        ?>
/<?php 
        e($tools);
        ?>
"><?php 
        e(tl('footer_element_tools'));
        ?>
</a> -
            <a href="<?php 
        e($path_info);
        ?>
/bot.php"><?php 
        e(tl('footer_element_bot'));
        ?>
</a> - <?php 
        if (MOBILE) {
            e('<br /> - ');
        }
        ?>
            <a href="http://www.seekquarry.com/"><?php 
        e(tl('footer_element_developed_seek_quarry'));
        ?>
</a> -
            </div>
            <div>
            <?php 
        e(tl('footer_element_copyright_yioop'));
        ?>
             - <a href="http://www.yioop.com/"><?php 
        e(tl('footer_element_php_search_engine'));
        ?>
</a>
            </div>
    <?php 
    }
Exemplo n.º 10
0
    /**
     * Draws the create account web page.
     *
     * @param array $data  contains the anti CSRF token
     *     the view, data for captcha and recover dropdowns
     */
    function renderView($data)
    {
        $logged_in = isset($data['ADMIN']) && $data['ADMIN'];
        $append_url = $logged_in && isset($data[CSRF_TOKEN]) ? CSRF_TOKEN . "=" . $data[CSRF_TOKEN] : "";
        $logo = LOGO;
        if (MOBILE) {
            $logo = M_LOGO;
        }
        $missing = array();
        if (isset($data['MISSING'])) {
            $missing = $data['MISSING'];
        }
        ?>
        <div class="landing non-search">
        <div class="small-top">
            <h1 class="logo"><a href="./?<?php 
        e($append_url);
        ?>
"><img
                src="<?php 
        e($logo);
        ?>
" alt="<?php 
        e($this->logo_alt_text);
        ?>
" /></a><span> - <?php 
        e(tl('register_view_create_account'));
        ?>
</span></h1>
            <?php 
        if ($data['AUTHENTICATION_MODE'] == ZKP_AUTHENTICATION) {
            ?>
                <form method="post"
                    onsubmit="registration('pass-word', 'retype-password', <?php 
            ?>
'fiat-shamir-modulus')">
                <input type="hidden" name="fiat_shamir_modulus"
                    id="fiat-shamir-modulus"
                    value="<?php 
            e($data['FIAT_SHAMIR_MODULUS']);
            ?>
"/>
                <?php 
        } else {
            ?>
                <form method="post">
                <?php 
        }
        ?>
            <input type="hidden" name="c" value="register" />
            <input type="hidden" name="a" value="processAccountData" />
            <?php 
        if (isset($_SESSION["random_string"])) {
            ?>
                <input type='hidden' name='nonce_for_string'
                    id='nonce_for_string' />
                <input type='hidden' name='random_string' id='random_string'
                    value='<?php 
            e($_SESSION["random_string"]);
            ?>
' />
                <input type='hidden' name='time' id='time'
                    value='<?php 
            e($_SESSION["request_time"]);
            ?>
' />
                <input type='hidden' name='level' id='level'
                    value='<?php 
            e($_SESSION["level"]);
            ?>
' />
                <?php 
        }
        ?>
            <div class="register">
                <table>
                    <tr>
                        <th class="table-label">
                            <label for="firstname"><?php 
        e(tl('register_view_firstname'));
        ?>
</label>
                        </th>
                        <td class="table-input">
                            <input id="firstname" type="text"
                                class="narrow-field" maxlength="<?php 
        e(NAME_LEN);
        ?>
"
                                name="first" autocomplete="off"
                                value = "<?php 
        e($data['FIRST']);
        ?>
"/>
                            <?php 
        e(in_array("first", $missing) ? '<span class="red">*</span>' : '');
        ?>
</td>
                    </tr>
                    <tr>
                        <th class="table-label">
                            <label for="lastname"><?php 
        e(tl('register_view_lastname'));
        ?>
</label>
                        </th>
                        <td class="table-input">
                            <input id="lastname" type="text"
                                class="narrow-field" maxlength="<?php 
        e(NAME_LEN);
        ?>
"
                                name="last" autocomplete="off"
                                value = "<?php 
        e($data['LAST']);
        ?>
"/>
                            <?php 
        echo in_array("last", $missing) ? '<span class="red">*</span>' : '';
        ?>
</td>
                    </tr>
                    <tr>
                        <th class="table-label"><label for="username">
                            <?php 
        e(tl('register_view_username'));
        ?>
</label>
                        </th>
                        <td class="table-input">
                            <input id="username" type="text"
                                class="narrow-field" maxlength="<?php 
        e(NAME_LEN);
        ?>
"
                                name="user" autocomplete="off"
                                value = "<?php 
        e($data['USER']);
        ?>
"/>
                            <?php 
        echo in_array("user", $missing) ? '<span class="red">*</span>' : '';
        ?>
</td>
                    </tr>
                    <tr>
                        <th class="table-label"><label for="email"><?php 
        e(tl('register_view_email'));
        ?>
</label>
                        </th>
                        <td class="table-input">
                            <input id="email" type="text"
                                class="narrow-field" maxlength="<?php 
        e(LONG_NAME_LEN);
        ?>
"
                                name="email" autocomplete="off"
                                value = "<?php 
        e($data['EMAIL']);
        ?>
"/>
                            <?php 
        echo in_array("email", $missing) ? '<span class="red">*</span>' : '';
        ?>
</td>
                    </tr>
                    <tr>
                        <th class="table-label">
                            <label for="pass-word"><?php 
        e(tl('register_view_password'));
        ?>
</label>
                        </th>
                        <td class="table-input">
                            <input id="pass-word" type="password"
                                class="narrow-field" maxlength="<?php 
        e(LONG_NAME_LEN);
        ?>
"
                                name="password" value="<?php 
        e($data['PASSWORD']);
        ?>
" />
                            <?php 
        echo in_array("password", $missing) ? '<span class="red">*</span>' : '';
        ?>
</td>
                    </tr>
                    <tr>
                        <th class="table-label">
                            <label for="retype-password"><?php 
        e(tl('register_view_retypepassword'));
        ?>
</label>
                        </th>
                        <td class="table-input">
                            <input id="retype-password" type="password"
                                class="narrow-field" maxlength="<?php 
        e(LONG_NAME_LEN);
        ?>
"
                                name="repassword" value="<?php 
        e($data['REPASSWORD']);
        ?>
" />
                            <?php 
        e(in_array("repassword", $missing) ? '<span class="red">*</span>' : '');
        ?>
</td>
                    </tr>
                    <?php 
        if (isset($_SESSION["random_string"]) || isset($_SESSION["captcha_text"])) {
            $question_sets = array(tl('register_view_account_recovery') => $data['RECOVERY']);
        } else {
            $question_sets = array(tl('register_view_human_check') => $data['CAPTCHA'], tl('register_view_account_recovery') => $data['RECOVERY']);
        }
        $i = 0;
        foreach ($question_sets as $name => $set) {
            $first = true;
            $num = count($set);
            foreach ($set as $question) {
                if ($first) {
                    ?>
                                <tr><th class="table-label"
                                    rowspan='<?php 
                    e($num);
                    ?>
'><?php 
                    e($name);
                    ?>
</th><td class="table-input border-top">
                            <?php 
                } else {
                    ?>
                                <tr><td class="table-input">
                            <?php 
                }
                $this->helper("options")->render("question-{$i}", "question_{$i}", $question, $data["question_{$i}"]);
                $first = false;
                e(in_array("question_{$i}", $missing) ? '<span class="red">*</span>' : '');
                e("</td></tr>");
                $i++;
            }
        }
        if (isset($data['CAPTCHA_IMAGE'])) {
            ?>
                        <tr><th class="table-label" rowspan='2'><label
                            for="user-captcha-text"><?php 
            e(tl('register_view_human_check'));
            ?>
</label></th><td><img class="captcha"
                            src="<?php 
            e($data['CAPTCHA_IMAGE']);
            ?>
" alt="CAPTCHA">
                            </td></tr><tr><td>
                            <input type="text" maxlength="<?php 
            e(CAPTCHA_LEN);
            ?>
"
                            id="user-captcha-text" class="narrow-field"
                            name="user_captcha_text"/></td></tr>
                        <?php 
        }
        ?>
                    <tr>
                        <td></td>
                        <td class="table-input border-top narrow-field" ><?php 
        e(tl('register_view_i_agree'));
        ?>
                        <a href="<?php 
        e(BASE_URL);
        ?>
terms.php"><?php 
        e(tl('register_view_terms'));
        ?>
</a>
                        <?php 
        e(tl('register_view_and'));
        ?>
                        <a href="<?php 
        e(BASE_URL);
        ?>
privacy.php"><?php 
        e(tl('register_view_privacy'));
        ?>
</a><?php 
        e(tl('register_view_period'));
        ?>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td class="table-input border-top">
                        <input type="hidden"
                            name="<?php 
        e(CSRF_TOKEN);
        ?>
"
                            value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
"/>
                            <button  type="submit"><?php 
        e(tl('register_view_create_account'));
        ?>
</button>
                        </td>
                    </tr>
                </table>
            </div>
            </form>
            <div class="signin-exit">
                <ul>
                <li><a href="."><?php 
        e(tl('signin_view_return_yioop'));
        ?>
</a></li>
                </ul>
            </div>
        </div>
        </div>
        <div class='tall-landing-spacer'></div>
        <?php 
        if (isset($_SESSION["random_string"])) {
            ?>
            <script type="text/javascript" >
                document.addEventListener('DOMContentLoaded', function() {
                var body = tag(body);
                body.onload = findNonce('nonce_for_string', 'random_string'
                    , 'time', 'level');
                }, false);
            </script>
            <?php 
        }
    }
Exemplo n.º 11
0
    /**
     * Displays a list of admin activities
     *
     * @param array $data  available activities and CSRF token
     */
    function render($data)
    {
        ?>
        <?php 
        if (isset($data['ACTIVITIES'])) {
            if (MOBILE) {
                ?>
                <div class="frame activity-menu">
                <h2><?php 
                e(tl('activity_element_activities'));
                ?>
</h2>
                <?php 
                $count = count($data['ACTIVITIES']);
                $activities = $data['ACTIVITIES'];
                $out_activities = array();
                $base_url = "?c=admin&amp;" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] . "&amp;a=";
                $current = "";
                foreach ($activities as $activity) {
                    $out_activities[$base_url . $activity['METHOD_NAME']] = $activity['ACTIVITY_NAME'];
                    if (strcmp($activity['ACTIVITY_NAME'], $data['CURRENT_ACTIVITY']) == 0) {
                        $current = $base_url . $activity['METHOD_NAME'];
                    }
                }
                $this->view->helper("options")->render("activity", "a", $out_activities, $current);
                ?>
                <script type="text/javascript">
                activity_select = document.getElementById('activity');
                function activityChange() {
                    document.location = activity_select.value;
                }
                activity_select.onchange = activityChange;
                </script>
                </div>
                <?php 
            } else {
                ?>
                <div class="component-container">
                <?php 
                foreach ($data['COMPONENT_ACTIVITIES'] as $component_name => $activities) {
                    $count = count($activities);
                    ?>
                    <div class="frame activity-menu">
                    <h2><?php 
                    e($component_name);
                    ?>
</h2>
                    <ul>
                    <?php 
                    for ($i = 0; $i < $count; $i++) {
                        if ($i < $count - 1) {
                            $class = "class='bottom-border'";
                        } else {
                            $class = "";
                        }
                        e("<li {$class}><a href='?c=admin&amp;" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] . "&amp;a=" . $activities[$i]['METHOD_NAME'] . "'>" . $activities[$i]['ACTIVITY_NAME'] . "</a></li>");
                    }
                    ?>
                    </ul>
                    </div>
                    <?php 
                }
                ?>
                </div>
                <?php 
            }
        }
    }
Exemplo n.º 12
0
    /**
     * Draws the forms used to configure the search engine.
     *
     * This element has two forms on it: One for setting the working directory
     * for crawls, the other to set-up profile information which is mainly
     * stored in the profile.php file in the working directory. The exception
     * is longer data concerning the crawl robot description which is stored
     * in bot.txt. Some elements on forms are not displayed if they are not
     * relevant (for instance, there is no notion of a username for a sqlite
     * database system, but there is for other DBMSs). Also, if the work
     * directory is not properly configured then only the language portion of
     * the profile form is displayed since there is no real place to store data
     * from the latter form until a proper working directory is established.
     *
     * @param array $data holds data on the profile elements which have been
     *     filled in as well as data about which form fields to display
     */
    function render($data)
    {
        $configure_url = '?c=admin&amp;a=configure&amp;' . CSRF_TOKEN . "=" . $data[CSRF_TOKEN];
        ?>
        <div class="current-activity">
        <form id="configureDirectoryForm" method="post"
            action='<?php 
        e($configure_url);
        ?>
' >
        <?php 
        if (isset($data['lang'])) {
            ?>
            <input type="hidden" name="lang" value="<?php 
            e($data['lang']);
            ?>
" />
        <?php 
        }
        ?>
        <input type="hidden" name="arg" value="directory" />
        <h2><label for="directory-path"><?php 
        e(tl('configure_element_work_directory'));
        ?>
</label></h2>
        <div  class="top-margin"><input type="text" id="directory-path"
            name="WORK_DIRECTORY"  class="extra-wide-field" value='<?php 
        e($data["WORK_DIRECTORY"]);
        ?>
' /><button
                    class="button-box"
                    type="submit"><?php 
        e(tl('configure_element_load_or_create'));
        ?>
</button>
        </div>
        </form>
        <form id="configureProfileForm" method="post"
            enctype='multipart/form-data'>
        <?php 
        if (isset($data['WORK_DIRECTORY'])) {
            ?>
            <input type="hidden" name="WORK_DIRECTORY" value="<?php 
            e($data['WORK_DIRECTORY']);
            ?>
" />
        <?php 
        }
        ?>
        <input type="hidden" name="c" value="admin" />
        <input type="hidden" name="advanced" id='a-settings' value="<?php 
        e($data['advanced']);
        ?>
" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="configure" />
        <input type="hidden" name="arg" value="profile" />
        <h2><?php 
        e(tl('configure_element_component_check'));
        ?>
</h2>
        <div  class="top-margin">
        <?php 
        e($data['SYSTEM_CHECK']);
        ?>
        </div>
        <h2><?php 
        e(tl('configure_element_profile_settings'));
        ?>
</h2>
        <?php 
        if ($data['PROFILE']) {
            ?>
        <div class="top-margin">[<a href="javascript:toggleAdvance()"><?php 
            e(tl('configure_element_toggle_advanced'));
            ?>
</a>]</div>
        <?php 
        }
        ?>
        <div class="bold">
        <div class="top-margin"><span <?php 
        if (!MOBILE && count($data["LANGUAGES"]) > 3) {
            ?>
            style="position:relative; top:-3.2em;" <?php 
        }
        ?>
><label
            for="locale"><?php 
        e(tl('configure_element_default_language'));
        ?>
</label></span>
        <?php 
        $this->view->element("language")->render($data);
        ?>
        </div>
        <?php 
        if ($data['PROFILE']) {
            ?>
            <div id="advance-configure">
            <div class="top-margin">
            <fieldset class="extra-wide-field"><legend><?php 
            e(tl('configure_element_debug_display'));
            ?>
</legend>
                <label for="error-info"><input id='error-info' type="checkbox"
                    name="ERROR_INFO" value="<?php 
            e(ERROR_INFO);
            ?>
"
                    <?php 
            if (($data['DEBUG_LEVEL'] & ERROR_INFO) == ERROR_INFO) {
                e("checked='checked'");
            }
            ?>
                    /><?php 
            e(tl('configure_element_error_info'));
            ?>
</label>
                <label for="query-info"><input id='query-info' type="checkbox"
                    name="QUERY_INFO" value="<?php 
            e(QUERY_INFO);
            ?>
"
                    <?php 
            if (($data['DEBUG_LEVEL'] & QUERY_INFO) == QUERY_INFO) {
                e("checked='checked'");
            }
            ?>
/><?php 
            e(tl('configure_element_query_info'));
            ?>
</label>
                <label for="test-info"><input id='test-info' type="checkbox"
                    name="TEST_INFO" value="<?php 
            e(TEST_INFO);
            ?>
"
                    <?php 
            if (($data['DEBUG_LEVEL'] & TEST_INFO) == TEST_INFO) {
                e("checked='checked'");
            }
            ?>
/><?php 
            e(tl('configure_element_test_info'));
            ?>
</label>
            </fieldset>
            </div>
            <div class="top-margin">
            <fieldset class="extra-wide-field"><legend><?php 
            e(tl('configure_element_site_access'));
            ?>
</legend>
                <label for="web-access"><input id='error-info' type="checkbox"
                    name="WEB_ACCESS" value="true"
                    <?php 
            if ($data['WEB_ACCESS'] == true) {
                e("checked='checked'");
            }
            ?>
                    /><?php 
            e(tl('configure_element_web_access'));
            ?>
</label>
                <label for="rss-access"><input id='rss-access' type="checkbox"
                    name="RSS_ACCESS" value="true"
                    <?php 
            if ($data['RSS_ACCESS'] == true) {
                e("checked='checked'");
            }
            ?>
/><?php 
            e(tl('configure_element_rss_access'));
            ?>
</label>
                <label for="api-access"><input id='api-access' type="checkbox"
                    name="API_ACCESS" value="true"
                    <?php 
            if ($data['API_ACCESS'] == true) {
                e("checked='checked'");
            }
            ?>
/><?php 
            e(tl('configure_element_api_access'));
            ?>
</label>
            </fieldset>
            </div>
            <div class="top-margin">
            <fieldset><legend><?php 
            e(tl('configure_element_customizations'));
            ?>
</legend>
                <div class="top-margin"><label for="back-color"><?php 
            e(tl('configure_element_use_wiki_landing'));
            ?>
</label>
                <input type="checkbox" id="landing-page"
                    name="LANDING_PAGE" value='true' <?php 
            if ($data['LANDING_PAGE'] == true) {
                e("checked='checked'");
            }
            ?>
/></div>
                <div class="top-margin"><label for="back-color"><?php 
            e(tl('configure_element_background_color'));
            ?>
</label>
                <input type="text" id="back-image"
                    name="BACKGROUND_COLOR" class="narrow-field" value='<?php 
            e($data["BACKGROUND_COLOR"]);
            ?>
' /></div>
                <div class="top-margin"><label for="back-image"><?php 
            e(tl('configure_element_background_image'));
            ?>
</label>
                <input type="file" id="back-image"
                    name="BACKGROUND_IMAGE" class="upload-icon"
                    onchange="checkUploadIcon('back-image')"  />
                <?php 
            if (isset($data['BACKGROUND_IMAGE']) && $data['BACKGROUND_IMAGE']) {
                ?>
                    <img id='current-back-image' class="small-icon"
                        src="<?php 
                e($data['BACKGROUND_IMAGE']);
                ?>
" alt="<?php 
                e(tl('configure_element_background_image'));
                ?>
" />
                <?php 
            }
            ?>
                </div>
                <div class="top-margin"><label for="fore-color"><?php 
            e(tl('configure_element_foreground_color'));
            ?>
</label>
                <input type="text" id="fore-color"
                    name="FOREGROUND_COLOR" class="narrow-field" value='<?php 
            e($data["FOREGROUND_COLOR"]);
            ?>
' /></div>
                <div class="top-margin"><label for="top-color"><?php 
            e(tl('configure_element_topbar_color'));
            ?>
</label>
                <input type="text" id="top-color"
                    name="TOPBAR_COLOR" class="narrow-field" value='<?php 
            e($data["TOPBAR_COLOR"]);
            ?>
' /></div>
                <div class="top-margin"><label for="side-color"><?php 
            e(tl('configure_element_sidebar_color'));
            ?>
</label>
                <input type="text" id="side-color"
                    name="SIDEBAR_COLOR" class="narrow-field" value='<?php 
            e($data["SIDEBAR_COLOR"]);
            ?>
' /></div>
                <div class="top-margin"><label for="site-logo"><?php 
            e(tl('configure_element_site_logo'));
            ?>
</label>
                <input type="file" id="site-logo"
                    onchange="checkUploadIcon('site-logo')"
                    name="LOGO" class='icon-upload' />
                <img id='current-site-logo' class="small-icon"
                    src="<?php 
            e($data['LOGO']);
            ?>
" alt="<?php 
            e(tl('configure_element_site_logo'));
            ?>
" />
                <span id='info-site-logo'></span>
                </div>
                <div class="top-margin"><label for="mobile-logo"><?php 
            e(tl('configure_element_mobile_logo'));
            ?>
</label>
                <input type="file" id="mobile-logo"
                    onchange="checkUploadIcon('mobile-logo')"
                    name="M_LOGO" class='icon-upload'  />
                <img id='current-mobile-logo' class="small-icon"
                    src="<?php 
            e($data['M_LOGO']);
            ?>
" alt="<?php 
            e(tl('configure_element_mobile_logo'));
            ?>
" />
                <span id='info-mobile-logo'></span>
                </div>
                <div class="top-margin"><label for="favicon"><?php 
            e(tl('configure_element_favicon'));
            ?>
</label>
                <input type="file" id="favicon"
                    onchange="checkUploadIcon('favicon')"
                    name="FAVICON" class='icon-upload' />
                <img id='current-favicon' class="small-icon"
                    src="<?php 
            e($data['FAVICON']);
            ?>
" alt="<?php 
            e(tl('configure_element_favicon'));
            ?>
" />
                <span id='info-favicon'></span>
                </div>
                <div class="top-margin"><label for="toolbar"><?php 
            e(tl('configure_element_toolbar'));
            ?>
</label>
                <input type="file" id="toolbar"
                    name="SEARCHBAR_PATH" class="extra-wide-field" /></div>
                <div class="top-margin"><label for="timezone"><?php 
            e(tl('configure_element_site_timezone'));
            ?>
</label>
                <input type="text" id="timezone"
                    name="TIMEZONE" class="extra-wide-field" value='<?php 
            e($data["TIMEZONE"]);
            ?>
' /></div>
                <div class="top-margin"><label for="cookie-name"><?php 
            e(tl('configure_element_cookie_name'));
            ?>
</label>
                <input type="text" id="cookie-name"
                    name="SESSION_NAME" class="extra-wide-field" value='<?php 
            e($data["SESSION_NAME"]);
            ?>
' /></div>
                <div class="top-margin"><label for="token-name"><?php 
            e(tl('configure_element_token_name'));
            ?>
</label>
                <input type="text" id="token-name"
                    name="CSRF_TOKEN" class="extra-wide-field" value='<?php 
            e($data["CSRF_TOKEN"]);
            ?>
' /></div>
                <div class="top-margin"><label for="auxiliary-css"><?php 
            e(tl('configure_element_auxiliary_css'));
            ?>
</label>
                <textarea class="short-text-area" name="AUXILIARY_CSS" ><?php 
            e($data['AUXILIARY_CSS']);
            ?>
</textarea></div>
                <div class="center">
                [<a href="<?php 
            e($configure_url . '&amp;arg=reset');
            ?>
"><?php 
            e(tl('configure_element_reset_customizations'));
            ?>
</a>]
                </div>
            </fieldset>
            </div>
            </div>
            <div class="top-margin">
            <fieldset><legend><?php 
            e(tl('configure_element_crawl_robot'));
            ?>
</legend>
                <div><b><label for="crawl-robot-name"><?php 
            e(tl('configure_element_robot_name'));
            ?>
</label></b>
                    <input type="text" id="crawl-robot-name"
                        name="USER_AGENT_SHORT"
                        value="<?php 
            e($data['USER_AGENT_SHORT']);
            ?>
"
                        class="extra-wide-field" />
                </div>
                <div class="top-margin" id='advance-robot'><b><label
                    for="crawl-robot-instance"><?php 
            e(tl('configure_element_robot_instance'));
            ?>
</label></b>
                    <input type="text" id="crawl-robot-instance"
                        name="ROBOT_INSTANCE"
                        value="<?php 
            e($data['ROBOT_INSTANCE']);
            ?>
"
                        class="extra-wide-field" />
                </div>
                <div class="top-margin"><label for="robot-description"><b><?php 
            e(tl('configure_element_robot_description'));
            ?>
</b></label>
                </div>
                <textarea class="tall-text-area" name="ROBOT_DESCRIPTION" ><?php 
            e($data['ROBOT_DESCRIPTION']);
            ?>
</textarea>
            </fieldset>
            </div>
            <div class="top-margin center">
            <button class="button-box" type="submit"><?php 
            e(tl('serversettings_element_submit'));
            ?>
</button>
            </div>
            </div>
        <?php 
        }
        ?>
        </form>
        </div>
        <script type="text/javascript">
        function checkUploadIcon(id)
        {
            var max_icon_size = <?php 
        e(THUMB_SIZE);
        ?>
;
            var upload_icon = elt(id).files[0];
            var upload_info = elt('info-'+id);
            if(upload_icon.type != 'image/png' &&
                upload_icon.type != 'image/jpeg' &&
                upload_icon.type != 'image/x-icon' &&
                upload_icon.type != 'image/gif') {
                doMessage('<h1 class=\"red\" ><?php 
        e(tl("configure_element_invalid_filetype"));
        ?>
</h1>');
                elt(id).files[0] = NULL;
                return;
            }
            if(upload_icon.size > max_icon_size) {
                doMessage('<h1 class=\"red\" ><?php 
        e(tl("configure_element_file_too_big"));
        ?>
</h1>');
                elt(id).files[0] = NULL;
                return;
            }
            setDisplay('current-'+id, false);
            upload_info.className = "upload-info";
            upload_info.innerHTML = upload_icon.name;
        }
        </script>
    <?php 
    }
Exemplo n.º 13
0
    /**
     * Method that draw forms to set up the various external servers
     * that might be connected with a Yioop installation
     *
     * @param array $data holds data on the profile elements which have been
     *     filled in as well as data about which form fields to display
     */
    function render($data)
    {
        ?>
        <div class="current-activity">
        <form id="serverSettingsForm" method="post">
        <input type="hidden" name="c" value="admin" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="serverSettings" />
        <input type="hidden" name="arg" value="update" />
        <h2><?php 
        e(tl('serversettings_element_server_settings'));
        ?>
</h2>
        <div class="bold">
            <div class="top-margin">
            <fieldset><legend><?php 
        e(tl('serversettings_element_name_server'));
        ?>
</legend>
                <div ><b><label for="queue-fetcher-salt"><?php 
        e(tl('serversettings_element_name_server_key'));
        ?>
</label></b>
                    <input type="text" id="queue-fetcher-salt" name="AUTH_KEY"
                        value="<?php 
        e($data['AUTH_KEY']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><b><label for="name-server-url"><?php 
        e(tl('serversettings_element_name_server_url'));
        ?>
</label></b>
                    <input type="text" id="name-server-url" name="NAME_SERVER"
                        value="<?php 
        e($data['NAME_SERVER']);
        ?>
"
                        class="extra-wide-field" />
                </div>
                <?php 
        if (class_exists("Memcache")) {
            ?>
                <div class="top-margin"><label for="use-memcache"><b><?php 
            e(tl('serversettings_element_use_memcache'));
            ?>
</b></label>
                        <input type="checkbox" id="use-memcache"
                            name="USE_MEMCACHE" value="true" <?php 
            e($data['USE_MEMCACHE'] ? "checked='checked'" : "");
            ?>
 />
                </div>
                <div id="memcache">
                    <div class="top-margin"><label for="memcache-servers"
                    ><b><?php 
            e(tl('serversettings_element_memcache_servers'));
            ?>
</b></label>
                    </div>
                    <textarea class="short-text-area" id="memcache-servers"
                    name="MEMCACHE_SERVERS"><?php 
            e($data['MEMCACHE_SERVERS']);
            ?>
</textarea>
                </div>
               <?php 
        }
        ?>
                <div id="filecache">
                <div class="top-margin"><label for="use-filecache"><b><?php 
        e(tl('serversettings_element_use_filecache'));
        ?>
</b></label>
                        <input type="checkbox" id="use-filecache"
                            name="USE_FILECACHE" value="true" <?php 
        e($data['USE_FILECACHE'] ? "checked='checked'" : "");
        ?>
 />
                </div>
                </div>
            </fieldset>
            </div>
            <div class="top-margin">
            <fieldset><legend><?php 
        e(tl('configure_element_database_setup'));
        e("&nbsp;" . $this->view->helper("helpbutton")->render("Database Setup", $data[CSRF_TOKEN]));
        ?>
                </legend>
                <div ><label for="database-system"><b><?php 
        e(tl('serversettings_element_database_system'));
        ?>
</b></label>
                    <?php 
        $this->view->helper("options")->render("database-system", "DBMS", $data['DBMSS'], $data['DBMS']);
        ?>
                </div>
                <div class="top-margin"><b><label for="database-name"><?php 
        e(tl('serversettings_element_databasename'));
        ?>
</label></b>
                    <input type="text" id="database-name" name="DB_NAME"
                        value="<?php 
        e($data['DB_NAME']);
        ?>
"
                        class="wide-field" />
                </div>
                <div id="login-dbms">
                    <div class="top-margin"><b><label for="database-host"><?php 
        e(tl('serversettings_element_databasehost'));
        ?>
</label></b>
                        <input type="text" id="database-user" name="DB_HOST"
                            value="<?php 
        e($data['DB_HOST']);
        ?>
"
                            class="wide-field" />
                    </div>
                    <div class="top-margin"><b><label for="database-user"><?php 
        e(tl('serversettings_element_databaseuser'));
        ?>
</label></b>
                        <input type="text" id="database-user" name="DB_USER"
                            value="<?php 
        e($data['DB_USER']);
        ?>
"
                            class="wide-field" />
                    </div>
                    <div class="top-margin"><b><label
                        for="database-password"><?php 
        e(tl('serversettings_element_databasepassword'));
        ?>
</label></b>
                        <input type="password" id="database-password"
                            name="DB_PASSWORD" value="<?php 
        e($data['DB_PASSWORD']);
        ?>
" class="wide-field" />
                    </div>
                </div>
            </fieldset>
            </div>
            <div class = "top-margin">
            <fieldset >
                <legend><label
                for="account-registration"><?php 
        e(tl('serversettings_element_account_registration'));
        e("&nbsp;" . $this->view->helper("helpbutton")->render("Account Registration", $data[CSRF_TOKEN]));
        ?>
                </label></legend>
                    <?php 
        $this->view->helper("options")->render("account-registration", "REGISTRATION_TYPE", $data['REGISTRATION_TYPES'], $data['REGISTRATION_TYPE']);
        ?>
                <div id="registration-info">
                <div class="top-margin"><b><label for="mail-sender"><?php 
        e(tl('serversettings_element_mail_sender'));
        ?>
</label></b>
                    <input type="text" id="mail-server" name="MAIL_SENDER"
                        value="<?php 
        e($data['MAIL_SENDER']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><b><label for="use-php-mail"><?php 
        e(tl('serversettings_element_use_php_mail'));
        ?>
</label></b>
                    <input type="checkbox" id="use-php-mail" name="USE_MAIL_PHP"
                        value="true" <?php 
        if ($data['USE_MAIL_PHP'] == true) {
            e("checked='checked'");
        }
        ?>
 />
                </div>
                <div id="smtp-info">
                <div class="top-margin"><b><label for="mail-server"><?php 
        e(tl('serversettings_element_mail_server'));
        ?>
</label></b>
                    <input type="text" id="mail-server" name="MAIL_SERVER"
                        value="<?php 
        e($data['MAIL_SERVER']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><b><label for="mail-serverport"><?php 
        e(tl('serversettings_element_mail_serverport'));
        ?>
</label></b>
                    <input type="text" id="mail-port" name="MAIL_SERVERPORT"
                        value="<?php 
        e($data['MAIL_SERVERPORT']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><b><label for="mail-username"><?php 
        e(tl('serversettings_element_mail_username'));
        ?>
</label></b>
                    <input type="text" id="mail-username" name="MAIL_USERNAME"
                        value="<?php 
        e($data['MAIL_USERNAME']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><b><label for="mail-password"><?php 
        e(tl('serversettings_element_mail_password'));
        ?>
</label></b>
                    <input type="password" id="mail-password"
                        name="MAIL_PASSWORD"
                        value="<?php 
        e($data['MAIL_PASSWORD']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><b><label for="mail-security"><?php 
        e(tl('serversettings_element_mail_security'));
        ?>
</label></b>
                    <input type="text" id="mail-security" name="MAIL_SECURITY"
                        value="<?php 
        e($data['MAIL_SECURITY']);
        ?>
"
                        class="wide-field" />
                </div>
                </div>
                </div>
            </fieldset>
            </div>
            <div class="top-margin">
            <fieldset><legend><?php 
        e(tl('serversettings_element_proxy_title'));
        e("&nbsp;" . $this->view->helper("helpbutton")->render("Proxy Server", $data[CSRF_TOKEN]));
        ?>
</legend>
                <div ><b><label for="tor-proxies"><?php 
        e(tl('serversettings_element_tor_proxy'));
        ?>
</label></b>
                    <input type="text" id="tor-proxies" name="TOR_PROXY"
                        value="<?php 
        e($data['TOR_PROXY']);
        ?>
"
                        class="wide-field" />
                </div>
                <div class="top-margin"><label for="use-proxy"><b><?php 
        e(tl('serversettings_element_use_proxy_servers'));
        ?>
</b></label>
                        <input type="checkbox" id="use-proxy"
                            name="USE_PROXY" value="true" <?php 
        e($data['USE_PROXY'] ? "checked='checked'" : "");
        ?>
 />
                </div>
                <div id="proxy">
                    <div class="top-margin"><label for="proxy-servers"
                    ><b><?php 
        e(tl('serversettings_element_proxy_servers'));
        ?>
</b></label>
                    </div>
                    <textarea class="short-text-area" id="proxy-servers"
                    name="PROXY_SERVERS"><?php 
        e($data['PROXY_SERVERS']);
        ?>
</textarea>
                </div>
            </fieldset>
            </div>
            <div class="top-margin">
            <fieldset><legend>
            <?php 
        e(tl('serversettings_element_adserver_configuration'));
        e("&nbsp;" . $this->view->helper("helpbutton")->render("Ad Server", $data[CSRF_TOKEN]));
        ?>
</legend>
            <div><b>
            <?php 
        e(tl('serversettings_element_ad_location'));
        ?>
</b><br />
            <input type='radio' name='AD_LOCATION' value="top"
                onchange="showHideScriptdiv();" <?php 
        e($data['AD_LOCATION'] == 'top' ? 'checked' : '');
        ?>
 /><label for="ad-location-top"><?php 
        e(tl('serversettings_element_top'));
        ?>
</label>
            <input type='radio' name='AD_LOCATION' value="side"
                onclick="showHideScriptdiv();" <?php 
        e($data['AD_LOCATION'] == 'side' ? 'checked' : '');
        ?>
 /><label for="ad-location-top"><?php 
        e(tl('serversettings_element_side'));
        ?>
</label>
            <input type='radio' name='AD_LOCATION' value="both"
                onclick="showHideScriptdiv();" <?php 
        e($data['AD_LOCATION'] == 'both' ? 'checked' : '');
        ?>
 /><label for="ad-location-both"><?php 
        e(tl('serversettings_element_both'));
        ?>
</label>
            <input type='radio' name='AD_LOCATION' value="none"
                onclick="showHideScriptdiv();" <?php 
        e($data['AD_LOCATION'] == 'none' ? 'checked' : '');
        ?>
 /><label for="ad-location-none"><?php 
        e(tl('serversettings_element_none'));
        ?>
</label>
            </div>
            <div id="global-adscript-config">
            <label for="global-adscript"><b><?php 
        e(tl('serversettings_element_global_adscript'));
        ?>
</b></label>
            <textarea class="short-text-area" id="global-adscript"
                name="GLOBAL_ADSCRIPT"><?php 
        e(html_entity_decode($data['GLOBAL_ADSCRIPT'], ENT_QUOTES));
        ?>
</textarea></div>
            <div id="top-adscript-config"><label for="top-adscript"><b><?php 
        e(tl('serversettings_element_top_adscript'));
        ?>
</b></label>
            <textarea class="short-text-area" id="top-adscript"
                name="TOP_ADSCRIPT"><?php 
        e(html_entity_decode($data['TOP_ADSCRIPT'], ENT_QUOTES));
        ?>
</textarea></div>
            <div id="side-adscript-config"><label for="side-adscript"><b><?php 
        e(tl('serversettings_element_side_adscript'));
        ?>
</b></label>
            <textarea class="short-text-area" id="side-adscript"
                name="SIDE_ADSCRIPT"><?php 
        e(html_entity_decode($data['SIDE_ADSCRIPT'], ENT_QUOTES));
        ?>
</textarea></div>
            </fieldset>
            </div>
            <div class="top-margin center">
            <button class="button-box" type="submit"><?php 
        e(tl('serversettings_element_submit'));
        ?>
</button>
            </div>
            </div>
        </form>
        </div>
        <script type="text/javascript">
        window.onload = function()
        {
            showHideScriptdiv();
        }
        /**
         * Method to show/block div including text area depending upon location
         * selected for the advertisement to display on search results page.
         */
        function showHideScriptdiv()
        {
            /*
             * Get the radio button list represnting location for the 
             * advertisement.
             */
            var ad_server_config = document.getElementsByName('AD_LOCATION');
            /*
             * Show/ block div with text area depending upon the radio
             * button value.
             */
            var ad_align = [
                ['block','block','none'], //top[top,global,side]
                ['none','block','block'], //side
                ['block','block','block'], //both
                ['none','none','none'], //none
            ];
            for(var i = 0; i < ad_server_config.length; i++){
                if(ad_server_config[i].checked) {
                    elt('top-adscript-config').style.display = ad_align[i][0];
                    elt('global-adscript-config').style.display =
                        ad_align[i][1];
                    elt('side-adscript-config').style.display = ad_align[i][2];
                    break;
                }
            }
        }
        </script>
    <?php 
    }
Exemplo n.º 14
0
    /**
     * Renders search source and subsearch forms
     *
     * @param array $data available Search sources  and subsearches
     */
    function render($data)
    {
        $pre_base_url = "?" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] . "&amp;c=admin";
        $base_url = $pre_base_url . "&amp;a=searchSources";
        $localize_url = $pre_base_url . "&amp;a=manageLocales" . "&amp;arg=editstrings&amp;selectlocale=" . $data['LOCALE_TAG'] . "&amp;previous_activity=searchSources";
        ?>
        <div class="current-activity">
        <?php 
        if ($data["SOURCE_FORM_TYPE"] == "editsource") {
            ?>
            <div class='float-opposite'><a href='<?php 
            e($base_url);
            ?>
'><?php 
            e(tl('searchsources_element_addsource_form'));
            ?>
</a></div>
            <h2><?php 
            e(tl('searchsources_element_edit_media_source'));
            ?>
</h2>
            <?php 
        } else {
            ?>
            <h2><?php 
            e(tl('searchsources_element_add_media_source'));
            ?>
</h2>
            <?php 
        }
        ?>
        <form id="addSearchSourceForm" method="post">
        <input type="hidden" name="c" value="admin" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="searchSources" />
        <input type="hidden" name="arg" value="<?php 
        e($data['SOURCE_FORM_TYPE']);
        ?>
" />
        <?php 
        if ($data['SOURCE_FORM_TYPE'] == "editsource") {
            ?>
            <input type="hidden" name="ts" value="<?php 
            e($data['ts']);
            ?>
" />
            <?php 
        }
        ?>
        <table class="name-table">
        <tr><td><label for="source-type"><b><?php 
        e(tl('searchsources_element_sourcetype'));
        ?>
</b></label></td><td>
            <?php 
        $this->view->helper("options")->render("source-type", "type", $data['SOURCE_TYPES'], $data['CURRENT_SOURCE']['type']);
        ?>
</td></tr>
        <tr><td><label for="source-name"><b><?php 
        e(tl('searchsources_element_sourcename'));
        ?>
</b></label></td><td>
            <input type="text" id="source-name" name="name"
                value="<?php 
        e($data['CURRENT_SOURCE']['name']);
        ?>
"
                maxlength="<?php 
        e(LONG_NAME_LEN);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td><label for="source-url"><b><?php 
        e(tl('searchsources_element_url'));
        ?>
</b></label></td><td>
            <input type="text" id="source-url" name="source_url"
                value="<?php 
        e($data['CURRENT_SOURCE']['source_url']);
        ?>
"
                maxlength="<?php 
        e(MAX_URL_LEN);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td><label for="source-locale-tag"><b id="locale-text"><?php 
        e(tl('searchsources_element_locale_tag'));
        ?>
</b></label></td><td>
            <?php 
        $this->view->helper("options")->render("source-locale-tag", "language", $data['LANGUAGES'], $data['CURRENT_SOURCE']['language']);
        ?>
</td></tr>
        <tr><td><label for="source-thumbnail"><b id="thumb-text"><?php 
        e(tl('searchsources_element_thumbnail'));
        $aux_info_len = MAX_URL_LEN;
        $num_sub_aux_fields = 5;
        $sub_aux_len = floor(MAX_URL_LEN / $num_sub_aux_fields);
        ?>
</b></label></td><td>
            <input type="text" id="source-thumbnail" name="aux_info"
                value="<?php 
        e($data['CURRENT_SOURCE']['aux_info']);
        ?>
"
                maxlength="<?php 
        e($aux_info_len);
        ?>
" class="wide-field" /></td></tr>
        <tr><td colspan="2"><span id='instruct'><?php 
        e(tl('searchsources_element_feed_instruct'));
        ?>
</span></td></tr>
        <tr><td><label for="item-path"><b id="channel-text"><?php 
        e(tl('searchsources_element_channelpath'));
        ?>
</b></label></td><td>
            <input type="text" id="channel-path" name="channel_path"
                value="<?php 
        e($data['CURRENT_SOURCE']['channel_path']);
        ?>
"
                maxlength="<?php 
        e($sub_aux_len);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td><label for="item-path"><b id="item-text"><?php 
        e(tl('searchsources_element_itempath'));
        ?>
</b></label></td><td>
            <input type="text" id="item-path" name="item_path"
                value="<?php 
        e($data['CURRENT_SOURCE']['item_path']);
        ?>
"
                maxlength="<?php 
        e($sub_aux_len);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td><label for="title-path"><b id="title-text"><?php 
        e(tl('searchsources_element_titlepath'));
        ?>
</b></label></td><td>
            <input type="text" id="title-path" name="title_path"
                value="<?php 
        e($data['CURRENT_SOURCE']['title_path']);
        ?>
"
                maxlength="<?php 
        e($sub_aux_len);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td><label for="description-path"><b id="description-text"><?php 
        e(tl('searchsources_element_descpath'));
        ?>
</b></label></td><td>
            <input type="text" id="description-path" name="description_path"
                value="<?php 
        e($data['CURRENT_SOURCE']['description_path']);
        ?>
"
                maxlength="<?php 
        e($sub_aux_len);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td><label for="date-path"><b id="link-text"><?php 
        e(tl('searchsources_element_linkpath'));
        ?>
</b></label></td><td>
            <input type="text" id="link-path" name="link_path"
                value="<?php 
        e($data['CURRENT_SOURCE']['link_path']);
        ?>
"
                maxlength="<?php 
        e($sub_aux_len);
        ?>
"
                class="wide-field" /></td></tr>
        <tr><td></td><td class="center"><button class="button-box"
            type="submit"><?php 
        e(tl('searchsources_element_submit'));
        ?>
</button></td></tr>
        </table>
        </form>
        <?php 
        $data['FORM_TYPE'] = "";
        $data['TABLE_TITLE'] = tl('searchsources_element_media_sources');
        $data['NO_FLOAT_TABLE'] = true;
        $data["NO_FORM_TAG"] = true;
        $data['ACTIVITY'] = 'searchSources';
        $data['VIEW'] = $this->view;
        $data['NO_SEARCH'] = true;
        $paging_items = array('SUBstart_row', 'SUBend_row', 'SUBnum_show');
        $paging1 = "";
        foreach ($paging_items as $item) {
            if (isset($data[strtoupper($item)])) {
                $paging1 .= "&amp;" . $item . "=" . $data[strtoupper($item)];
            }
        }
        $paging2 = "";
        $paging_items = array('start_row', 'end_row', 'num_show');
        foreach ($paging_items as $item) {
            if (isset($data[strtoupper($item)])) {
                $paging2 .= "&amp;" . $item . "=" . $data[strtoupper($item)];
            }
        }
        $data['PAGING'] = $paging1;
        $this->view->helper("pagingtable")->render($data);
        ?>
        <table class="search-sources-table">
        <tr><th><?php 
        e(tl('searchsources_element_medianame'));
        ?>
</th>
            <th><?php 
        e(tl('searchsources_element_mediatype'));
        ?>
</th><?php 
        if (!MOBILE) {
            e("<th>" . tl('searchsources_element_mediaurls') . "</th>");
        }
        ?>
            <th colspan="2"><?php 
        e(tl('searchsources_element_action'));
        ?>
</th></tr><?php 
        foreach ($data['MEDIA_SOURCES'] as $source) {
            ?>
        <tr><td><b><?php 
            e($source['NAME']);
            ?>
</b></td>
            <td><?php 
            e($data['SOURCE_TYPES'][$source['TYPE']]);
            ?>
</td>
            <?php 
            if (!MOBILE) {
                ?>
                <td><?php 
                e($source['SOURCE_URL'] . "<br />" . $source['AUX_INFO']);
                ?>
</td>
                <?php 
            }
            ?>
            <td><a href="<?php 
            e($base_url . "&amp;arg=editsource&amp;ts=" . $source['TIMESTAMP'] . $paging1 . $paging2);
            ?>
"><?php 
            e(tl('searchsources_element_editmedia'));
            ?>
</a></td>
            <td><a onclick='javascript:return confirm("<?php 
            e(tl('confirm_delete_operation'));
            ?>
");' href="<?php 
            e($base_url . "&amp;arg=deletesource&amp;ts=" . $source['TIMESTAMP'] . $paging1 . $paging2);
            ?>
"><?php 
            e(tl('searchsources_element_deletemedia'));
            ?>
</a></td></tr>
        <?php 
        }
        ?>
        </table>
        <?php 
        if ($data["SEARCH_FORM_TYPE"] == "editsubsearch") {
            ?>
            <div id='subsearch-section'
                class='float-opposite'><a href='<?php 
            e($base_url);
            ?>
'><?php 
            e(tl('searchsources_element_addsearch_form'));
            ?>
</a></div>
            <h2 id="subsearch-head"><?php 
            e(tl('searchsources_element_edit_subsearch'));
            ?>
</h2>
            <?php 
        } else {
            ?>
            <h2 id="subsearch-head"><?php 
            e(tl('searchsources_element_add_subsearch'));
            ?>
</h2>
            <?php 
        }
        ?>
        <form id="SearchSourceForm" method="post" action='#subsearch-head'>
        <input type="hidden" name="c" value="admin" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="searchSources" />
        <input type="hidden" name="arg" value="<?php 
        e($data['SEARCH_FORM_TYPE']);
        ?>
" />
        <table class="name-table">
        <tr><td><label for="subsearch-folder-name"><b><?php 
        e(tl('searchsources_element_foldername'));
        ?>
</b></label></td><td>
            <input type="text" id="subsearch-folder-name" name="folder_name"
                value="<?php 
        e($data['CURRENT_SUBSEARCH']['folder_name']);
        ?>
"
                <?php 
        if ($data['SEARCH_FORM_TYPE'] == 'editsubsearch') {
            e("disabled='disabled'");
        }
        ?>
                maxlength="80" class="wide-field" /></td></tr>
        <tr><td><label for="index-source"><b><?php 
        e(tl('searchsources_element_indexsource'));
        ?>
</b></label></td><td>
            <?php 
        $this->view->helper("options")->render("index-source", "index_identifier", $data['SEARCH_LISTS'], $data['CURRENT_SUBSEARCH']['index_identifier']);
        ?>
</td></tr>
        <tr>
        <td class="table-label"><label for="per-page"><b><?php 
        e(tl('searchsources_element_per_page'));
        ?>
</b></label></td>
            <td><?php 
        $this->view->helper("options")->render("per-page", "per_page", $data['PER_PAGE'], $data['CURRENT_SUBSEARCH']['per_page']);
        ?>
        </td></tr>
        <tr><td></td><td class="center"><button class="button-box"
            type="submit"><?php 
        e(tl('searchsources_element_submit'));
        ?>
</button></td></tr>
        </table>
        </form>
        <?php 
        $data['SUBFORM_TYPE'] = "";
        $data['TABLE_TITLE'] = tl('searchsources_element_subsearches');
        $data['TARGET_FRAGMENT'] = "subsearch-head";
        $data['NO_FLOAT_TABLE'] = true;
        $data['ACTIVITY'] = 'searchSources';
        $data['VIEW'] = $this->view;
        $data['VAR_PREFIX'] = "SUB";
        $data['PAGING'] = $paging2;
        $this->view->helper("pagingtable")->render($data);
        ?>
        <table class="search-sources-table">
        <tr><th><?php 
        e(tl('searchsources_element_dirname'));
        ?>
</th>
            <th><?php 
        e(tl('searchsources_element_index'));
        ?>
</th>
            <?php 
        if (!MOBILE) {
            ?>
                <th><?php 
            e(tl('searchsources_element_localestring'));
            ?>
</th>
                <th><?php 
            e(tl('searchsources_element_perpage'));
            ?>
</th>
                <?php 
        }
        ?>
            <th colspan="3"><?php 
        e(tl('searchsources_element_actions'));
        ?>
</th></tr>
        <?php 
        foreach ($data['SUBSEARCHES'] as $search) {
            ?>
        <tr><td><b><?php 
            e($search['FOLDER_NAME']);
            ?>
</b></td>
            <td><?php 
            e("<b>" . $data["SEARCH_LISTS"][trim($search['INDEX_IDENTIFIER'])] . "</b><br />" . $search['INDEX_IDENTIFIER']);
            ?>
</td><?php 
            if (!MOBILE) {
                ?>
                <td><?php 
                e($search['LOCALE_STRING']);
                ?>
</td>
                <td><?php 
                e($search['PER_PAGE']);
                ?>
</td><?php 
            }
            ?>
            <td><a href="<?php 
            e($base_url . "&amp;arg=editsubsearch&amp;fn=" . $search['FOLDER_NAME'] . $paging1 . $paging2 . "#subsearch-section");
            ?>
"><?php 
            e(tl('searchsources_element_editsource'));
            ?>
</a></td>
            <td><?php 
            if ($data['CAN_LOCALIZE']) {
                ?>
                <a href='<?php 
                e($localize_url . "&amp;filter=" . $search['LOCALE_STRING']);
                ?>
' ><?php 
                e(tl('searchsources_element_localize'));
                ?>
</a><?php 
            } else {
                ?>
                <span class="gray"><?php 
                e(tl('searchsources_element_localize'));
                ?>
</span>
                <?php 
            }
            ?>
            </td>
            <td><a href="<?php 
            e($base_url . '&amp;arg=deletesubsearch&amp;fn=' . $search['FOLDER_NAME'] . $paging1 . $paging2);
            ?>
"><?php 
            e(tl('searchsources_element_deletesubsearch'));
            ?>
</a></td></tr>
        <?php 
        }
        ?>
        </table>
        </div>
        <script type= "text/javascript">
        function switchSourceType()
        {
            var stype = elt("source-type");
            stype = stype.options[stype.selectedIndex].value;
            if(stype == "video") {
                setDisplay("thumb-text", true);
                setDisplay("source-thumbnail", true);
                setDisplay("instruct", false);
                setDisplay("channel-text", false);
                setDisplay("channel-path", false);
                setDisplay("item-text", false);
                setDisplay("item-path", false);
                setDisplay("title-text", false);
                setDisplay("title-path", false);
                setDisplay("description-text", false);
                setDisplay("description-path", false);
                setDisplay("link-text", false);
                setDisplay("link-path", false);
                setDisplay("locale-text", false);
                setDisplay("source-locale-tag", false);
            } else if(stype == "html") {
                setDisplay("thumb-text", false);
                setDisplay("source-thumbnail", false);
                setDisplay("instruct", true);
                setDisplay("channel-text", true);
                setDisplay("channel-path", true);
                setDisplay("item-text", true);
                setDisplay("item-path", true);
                setDisplay("title-text", true);
                setDisplay("title-path", true);
                setDisplay("description-text", true);
                setDisplay("description-path", true);
                setDisplay("link-text", true);
                setDisplay("link-path", true);
                setDisplay("locale-text", true);
                setDisplay("source-locale-tag", true);
            } else {
                setDisplay("thumb-text", false);
                setDisplay("source-thumbnail", false);
                setDisplay("instruct", false);
                setDisplay("channel-text", false);
                setDisplay("channel-path", false);
                setDisplay("item-text", false);
                setDisplay("item-path", false);
                setDisplay("title-text", false);
                setDisplay("title-path", false);
                setDisplay("description-text", false);
                setDisplay("description-path", false);
                setDisplay("link-text", false);
                setDisplay("link-path", false);
                setDisplay("locale-text", true);
                setDisplay("source-locale-tag", true);
            }
        }
        </script>
    <?php 
    }
Exemplo n.º 15
0
    /**
     * Draw the form for advanced search for any HTML table drawn based on
     * using a model's getRow function
     *
     * @param array  $data from the controller with info of what fields might
     *     already be filled.
     * @param object $controller what controller is being used to handle logic
     * @param string $activity what activity the controller was executing
     *     (for return link)
     * @param object $view which view is responsible for calling this helper
     * @param string $title what to display as the header of this form
     * @param string $return_form_name string to use for return link to previous
     *     page
     * @param array $fields a list of searchable fields
     * @param array $dropdowns which fields should be rendered as dropdowns
     * @param string $postfix string to tack on to form variables (might use
     *     to make var names unique on page)
     */
    function render($data, $controller, $activity, $view, $title, $return_form_name, $fields, $dropdowns = array(), $postfix = "")
    {
        $base_url = "?c={$controller}&amp;" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] . "&amp;a={$activity}";
        $old_base_url = $base_url;
        $browse = false;
        if (isset($data['browse'])) {
            $base_url .= "&amp;browse=" . $data['browse'];
            $browse = true;
        }
        e("<div class='float-opposite'><a href='{$old_base_url}'>" . $return_form_name . "</a></div>");
        e("<h2>{$title}" . "&nbsp;");
        e("</h2>");
        $item_sep = MOBILE ? "<br />" : "</td><td>";
        ?>
        <form id="search-form" method="post" autocomplete="off">
        <input type="hidden" name="c" value="<?php 
        e($controller);
        ?>
" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="<?php 
        e($activity);
        ?>
" />
        <input type="hidden" name="arg" value="search" />
        <?php 
        if ($browse) {
            ?>
            <input type="hidden" name="browse" value="true" />
            <?php 
        }
        ?>
        <table class="name-table">
        <?php 
        foreach ($fields as $label => $name) {
            if (is_array($name)) {
                $comparison_types = $name[1];
                $name = $name[0];
            } else {
                $comparison_types = $data['COMPARISON_TYPES'];
            }
            e("<tr><td class='table-label'><label for='{$name}-id'>" . "{$label}:</label>");
            e($item_sep);
            ?>
            <style type="text/css">
            #<?php 
            e($name);
            ?>
-comparison {
                width:100%;
            }
            </style>
            <?php 
            $view->helper("options")->render("{$name}-comparison", "{$name}_comparison", $comparison_types, $data["{$name}_comparison"]);
            e($item_sep);
            $out_name = $name;
            if ($postfix != "") {
                $out_name = $name . "_{$postfix}";
            }
            if (isset($dropdowns[$name])) {
                $dropdowns[$name] = array('-1' => tl('searchform_helper_any')) + $dropdowns[$name];
                ?>
                <style type="text/css">
                #<?php 
                e($name);
                ?>
-id {
                    width:100%;
                }
                </style>
                <?php 
                if ($data["{$out_name}"] == "") {
                    $data["{$out_name}"] = '-1';
                }
                $view->helper("options")->render("{$name}-id", "{$out_name}", $dropdowns[$name], $data["{$out_name}"]);
            } else {
                e("<input type='text' id='{$name}-id' name='{$out_name}' " . "maxlength='<?php e(LONG_NAME_LEN); ?>' " . "value='{$data[$out_name]}' " . "class='narrow-field'  />");
            }
            e($item_sep);
            $view->helper("options")->render("{$name}-sort", "{$name}_sort", $data['SORT_TYPES'], $data["{$name}_sort"]);
            e("</td></tr>");
        }
        ?>
        <tr><?php 
        if (!MOBILE) {
            ?>
<td></td><td></td> <?php 
        }
        ?>
            <td <?php 
        if (!MOBILE) {
            ?>
class="center" <?php 
        }
        ?>
><button class="button-box"
                type="submit"><?php 
        e(tl('searchform_helper_search'));
        ?>
</button></td>
        </tr>
        </table>
        </form>
        <?php 
    }
Exemplo n.º 16
0
 /**
  * Add SCRIPT tags for errors to the view $data array if there were any
  * missing fields on a create account or recover account form.
  * also adds error info if try to create an existing using.
  *
  * @param array& $data contains info for the view on which the above
  *     forms are to be drawn.
  */
 function dataIntegrityCheck(&$data)
 {
     if (!isset($data['SCRIPT'])) {
         $data['SCRIPT'] = "";
     }
     $data['SUCCESS'] = true;
     $this->getCleanFields($data);
     if ($data['MISSING'] != array()) {
         $data['SUCCESS'] = false;
         $message = "doMessage('<h1 class=\"red\" >" . tl('register_controller_error_fields') . "</h1>');";
         if ($data['MISSING'] == array("email")) {
             $message = "doMessage('<h1 class=\"red\" >" . tl('register_controller_check_email') . "</h1>');";
         }
         $data['SCRIPT'] .= $message;
     } else {
         if (isset($data["check_user"]) && $this->model("user")->getUserId($data['USER'])) {
             $data['SUCCESS'] = false;
             $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('register_controller_user_already_exists') . "</h1>');";
         }
     }
 }
Exemplo n.º 17
0
 /**
  * Handles admin request related to the search sources activity
  *
  * The search sources activity allows a user to add/delete search sources
  * for video and news, it also allows a user to control which subsearches
  * appear on the SearchView page
  *
  * @return array $data info about current search sources, and current
  *     sub-searches
  */
 function searchSources()
 {
     $parent = $this->parent;
     $crawl_model = $parent->model("crawl");
     $source_model = $parent->model("source");
     $possible_arguments = array("addsource", "deletesource", "addsubsearch", "deletesubsearch", "editsource", "editsubsearch");
     $data = array();
     $data["ELEMENT"] = "searchsources";
     $data['SCRIPT'] = "";
     $data['SOURCE_TYPES'] = array(-1 => tl('crawl_component_media_kind'), "video" => tl('crawl_component_video'), "rss" => tl('crawl_component_rss_feed'), "html" => tl('crawl_component_html_feed'));
     $source_type_flag = false;
     if (isset($_REQUEST['type']) && in_array($_REQUEST['type'], array_keys($data['SOURCE_TYPES']))) {
         $data['SOURCE_TYPE'] = $_REQUEST['type'];
         $source_type_flag = true;
     } else {
         $data['SOURCE_TYPE'] = -1;
     }
     $machine_urls = $parent->model("machine")->getQueueServerUrls();
     $search_lists = $crawl_model->getCrawlList(false, true, $machine_urls);
     $data["SEARCH_LISTS"] = array(-1 => tl('crawl_component_sources_indexes'));
     foreach ($search_lists as $item) {
         $data["SEARCH_LISTS"]["i:" . $item["CRAWL_TIME"]] = $item["DESCRIPTION"];
     }
     if (isset($_SESSION['USER_ID'])) {
         $user = $_SESSION['USER_ID'];
     } else {
         $user = $_SERVER['REMOTE_ADDR'];
     }
     $search_lists = $crawl_model->getMixList($user);
     foreach ($search_lists as $item) {
         $data["SEARCH_LISTS"]["m:" . $item["TIMESTAMP"]] = $item["NAME"];
     }
     $n = NUM_RESULTS_PER_PAGE;
     $data['PER_PAGE'] = array($n => $n, 2 * $n => 2 * $n, 5 * $n => 5 * $n, 10 * $n => 10 * $n);
     if (isset($_REQUEST['per_page']) && in_array($_REQUEST['per_page'], array_keys($data['PER_PAGE']))) {
         $data['PER_PAGE_SELECTED'] = $_REQUEST['per_page'];
     } else {
         $data['PER_PAGE_SELECTED'] = NUM_RESULTS_PER_PAGE;
     }
     $locales = $parent->model("locale")->getLocaleList();
     $data["LANGUAGES"] = array();
     foreach ($locales as $locale) {
         $data["LANGUAGES"][$locale['LOCALE_TAG']] = $locale['LOCALE_NAME'];
     }
     if (isset($_REQUEST['language']) && in_array($_REQUEST['language'], array_keys($data["LANGUAGES"]))) {
         $data['SOURCE_LOCALE_TAG'] = $_REQUEST['language'];
     } else {
         $data['SOURCE_LOCALE_TAG'] = DEFAULT_LOCALE;
     }
     $data["CURRENT_SOURCE"] = array("name" => "", "type" => $data['SOURCE_TYPE'], "source_url" => "", "aux_info" => "", 'channel_path' => "", 'item_path' => "", 'title_path' => "", 'description_path' => "", 'link_path' => "", "language" => $data['SOURCE_LOCALE_TAG']);
     $data["CURRENT_SUBSEARCH"] = array("locale_string" => "", "folder_name" => "", "index_identifier" => "", "per_page" => $data['PER_PAGE_SELECTED']);
     $data['SOURCE_FORM_TYPE'] = "addsource";
     $data["SEARCH_FORM_TYPE"] = "addsubsearch";
     if (isset($_REQUEST['arg']) && in_array($_REQUEST['arg'], $possible_arguments)) {
         switch ($_REQUEST['arg']) {
             case "addsource":
                 if (!$source_type_flag) {
                     $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_no_source_type') . "</h1>');";
                     break;
                 }
                 $must_have = array("name", "type", 'source_url');
                 $is_html_feed = false;
                 if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'html') {
                     $is_html_feed = true;
                     $must_have = array_merge($must_have, array('channel_path', 'item_path', 'title_path', 'description_path', 'link_path'));
                 }
                 $to_clean = array_merge($must_have, array('aux_info', 'language'));
                 foreach ($to_clean as $clean_me) {
                     $r[$clean_me] = isset($_REQUEST[$clean_me]) ? trim($parent->clean($_REQUEST[$clean_me], "string")) : "";
                     if ($clean_me == "source_url") {
                         $r[$clean_me] = UrlParser::canonicalLink($r[$clean_me], NAME_SERVER);
                         echo $r[$clean_me] . "\n";
                         if (!$r[$clean_me]) {
                             $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_invalid_url') . "</h1>');";
                             break 2;
                         }
                     }
                     if (in_array($clean_me, $must_have) && $r[$clean_me] == "") {
                         $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_missing_fields') . "</h1>');";
                         break 2;
                     }
                 }
                 if ($is_html_feed) {
                     $r['aux_info'] = $r['channel_path'] . "###" . $r['item_path'] . "###" . $r['title_path'] . "###" . $r['description_path'] . "###" . $r['link_path'];
                 }
                 $source_model->addMediaSource($r['name'], $r['type'], $r['source_url'], $r['aux_info'], $r['language']);
                 $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_media_source_added') . "</h1>');";
                 break;
             case "addsubsearch":
                 $to_clean = array("folder_name", 'index_identifier');
                 $must_have = $to_clean;
                 foreach ($to_clean as $clean_me) {
                     $r[$clean_me] = isset($_REQUEST[$clean_me]) ? trim($parent->clean($_REQUEST[$clean_me], "string")) : "";
                     if (in_array($clean_me, $must_have) && ($r[$clean_me] == "" || $r[$clean_me] == -1)) {
                         $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_missing_fields') . "</h1>');";
                         break 2;
                     }
                 }
                 $source_model->addSubsearch($r['folder_name'], $r['index_identifier'], $data['PER_PAGE_SELECTED']);
                 $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_subsearch_added') . "</h1>');";
                 break;
             case "deletesource":
                 if (!isset($_REQUEST['ts'])) {
                     $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_no_delete_source') . "</h1>');";
                     break;
                 }
                 $timestamp = $parent->clean($_REQUEST['ts'], "string");
                 $source_model->deleteMediaSource($timestamp);
                 $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_media_source_deleted') . "</h1>');";
                 break;
             case "deletesubsearch":
                 if (!isset($_REQUEST['fn'])) {
                     $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_no_delete_source') . "</h1>');";
                     break;
                 }
                 $folder_name = $parent->clean($_REQUEST['fn'], "string");
                 $source_model->deleteSubsearch($folder_name);
                 $data['SCRIPT'] .= "doMessage('<h1 class=\"red\" >" . tl('crawl_component_subsearch_deleted') . "</h1>');";
                 break;
             case "editsubsearch":
                 $data['SEARCH_FORM_TYPE'] = "editsubsearch";
                 $subsearch = false;
                 $folder_name = isset($_REQUEST['fn']) ? $parent->clean($_REQUEST['fn'], "string") : "";
                 if ($folder_name) {
                     $subsearch = $source_model->getSubsearch($folder_name);
                 }
                 if (!$subsearch) {
                     $data['SOURCE_FORM_TYPE'] = "addsubsearch";
                     break;
                 }
                 $data['fn'] = $folder_name;
                 $update = false;
                 foreach ($data['CURRENT_SUBSEARCH'] as $field => $value) {
                     $upper_field = strtoupper($field);
                     if (isset($_REQUEST[$field]) && $field != 'name') {
                         $subsearch[$upper_field] = $parent->clean($_REQUEST[$field], "string");
                         $data['CURRENT_SUBSEARCH'][$field] = $subsearch[$upper_field];
                         $update = true;
                     } else {
                         if (isset($subsearch[$upper_field])) {
                             $data['CURRENT_SUBSEARCH'][$field] = $subsearch[$upper_field];
                         }
                     }
                 }
                 if ($update) {
                     $source_model->updateSubsearch($subsearch);
                     $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >" . tl('crawl_component_subsearch_updated') . "</h1>');";
                 }
                 break;
             case "editsource":
                 $data['SOURCE_FORM_TYPE'] = "editsource";
                 $source = false;
                 $timestamp = isset($_REQUEST['ts']) ? $parent->clean($_REQUEST['ts'], "string") : "";
                 if ($timestamp) {
                     $source = $source_model->getMediaSource($timestamp);
                 }
                 if (!$source) {
                     $data['SOURCE_FORM_TYPE'] = "addsource";
                     break;
                 }
                 $data['ts'] = $timestamp;
                 $update = false;
                 $is_html_feed = false;
                 if ($source['TYPE'] == 'html') {
                     $is_html_feed = true;
                     list($source['CHANNEL_PATH'], $source['ITEM_PATH'], $source['TITLE_PATH'], $source['DESCRIPTION_PATH'], $source['LINK_PATH']) = explode("###", $source['AUX_INFO']);
                 }
                 foreach ($data['CURRENT_SOURCE'] as $field => $value) {
                     $upper_field = strtoupper($field);
                     if (isset($_REQUEST[$field]) && $field != 'name') {
                         $source[$upper_field] = $parent->clean($_REQUEST[$field], "string");
                         $data['CURRENT_SOURCE'][$field] = $source[$upper_field];
                         $update = true;
                     } else {
                         if (isset($source[$upper_field])) {
                             $data['CURRENT_SOURCE'][$field] = $source[$upper_field];
                         }
                     }
                 }
                 if ($update) {
                     if ($is_html_feed) {
                         $source['AUX_INFO'] = $source['CHANNEL_PATH'] . "###" . $source['ITEM_PATH'] . "###" . $source['TITLE_PATH'] . "###" . $source['DESCRIPTION_PATH'] . "###" . $source['LINK_PATH'];
                     }
                     unset($source['CHANNEL_PATH']);
                     unset($source['ITEM_PATH']);
                     unset($source['TITLE_PATH']);
                     unset($source['DESCRIPTION_PATH']);
                     unset($source['LINK_PATH']);
                     $source_model->updateMediaSource($source);
                     $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >" . tl('crawl_component_media_source_updated') . "</h1>');";
                 }
                 break;
         }
     }
     $data['CAN_LOCALIZE'] = $parent->model("user")->isAllowedUserActivity($_SESSION['USER_ID'], "manageLocales");
     $parent->pagingLogic($data, $source_model, "MEDIA_SOURCES", DEFAULT_ADMIN_PAGING_NUM / 5, array(array("NAME", "", "", "ASC")));
     $parent->pagingLogic($data, $source_model, "SUBSEARCHES", DEFAULT_ADMIN_PAGING_NUM / 5, array(array("FOLDER_NAME", "", "", "ASC")), "SUB", "SUBSEARCH");
     foreach ($data["SUBSEARCHES"] as $search) {
         if (!isset($data["SEARCH_LISTS"][trim($search['INDEX_IDENTIFIER'])])) {
             $source_model->deleteSubsearch($search["FOLDER_NAME"]);
         }
     }
     $data['SCRIPT'] .= "source_type = elt('source-type');" . "source_type.onchange = switchSourceType;" . "switchSourceType()";
     return $data;
 }
Exemplo n.º 18
0
 /**
  * Write as an string in the current locale the difference between the
  * publication date of a post and the current time
  *
  * @param int $time timestamp for current time
  * @param int $pub_date timestamp for feed_item publication
  * @return string in the current locale the time difference
  */
 function getPubdateString($time, $pub_date)
 {
     $delta = $time - $pub_date;
     if ($delta < ONE_DAY) {
         $num_hours = ceil($delta / ONE_HOUR);
         if ($num_hours <= 2) {
             if ($num_hours > 1) {
                 $pub_date = tl('feeds_helper_view_onehour');
             } else {
                 $num_minutes = floor($delta / ONE_MINUTE);
                 $remainder_seconds = $delta % ONE_MINUTE;
                 $pub_date = tl('feeds_helper_view_minsecs', $num_minutes, $remainder_seconds);
             }
         } else {
             $pub_date = tl('feeds_helper_view_hourdate', $num_hours);
         }
     } else {
         $pub_date = date("d/m/Y", $pub_date);
     }
     return $pub_date;
 }
Exemplo n.º 19
0
    /**
     * Draws configurable options about how a web crawl should be conducted
     *
     * @param array $data keys are generally the different setting that can
     *     be set in the crawl.ini file
     */
    function render($data)
    {
        ?>
        <div class="current-activity">
        <div class="<?php 
        e($data['leftorright']);
        ?>
">
        <a href="?c=admin&amp;a=manageCrawls&amp;<?php 
        e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
        ?>
"
        ><?php 
        e(tl('crawloptions_element_back_to_manage'));
        ?>
</a>
        </div>
        <?php 
        if (isset($data['ts'])) {
            ?>
        <h2><?php 
            e(tl('crawloptions_element_modify_active_crawl'));
            ?>
</h2>
        <?php 
        } else {
            ?>
        <h2><?php 
            e(tl('crawloptions_element_edit_crawl_options'));
            ?>
</h2>
        <?php 
        }
        ?>
        <form id="crawloptionsForm" method="post" action='?'>
        <input type="hidden" name="c" value="admin" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="manageCrawls" />
        <input type="hidden" name="arg" value="options" />
        <input type="hidden" name="posted" value="posted" />
        <input type="hidden" id='crawl-type' name="crawl_type" value="<?php 
        e($data['crawl_type']);
        ?>
" />
        <?php 
        if (isset($data['ts'])) {
            ?>
            <input type="hidden" name="ts" value="<?php 
            e($data['ts']);
            ?>
" />
        <?php 
        }
        ?>
        <ul class='tab-menu-list'>
        <?php 
        if (!isset($data['ts']) || $data['crawl_type'] == CrawlConstants::WEB_CRAWL) {
            ?>
        <li><a  <?php 
            if (!isset($data['ts'])) {
                ?>
            href="javascript:switchTab('webcrawltab', 'archivetab');"
            <?php 
            }
            ?>
            id='webcrawltabitem'
            class="<?php 
            e($data['web_crawl_active']);
            ?>
"><?php 
            e(tl('crawloptions_element_web_crawl'));
            ?>
</a></li>
        <?php 
        }
        if (!isset($data['ts']) || $data['crawl_type'] == CrawlConstants::ARCHIVE_CRAWL) {
            ?>
        <li><a <?php 
            if (!isset($data['ts'])) {
                ?>
            href="javascript:switchTab('archivetab', 'webcrawltab');"
            <?php 
            }
            ?>
            id='archivetabitem'
            class="<?php 
            e($data['archive_crawl_active']);
            ?>
"><?php 
            e(tl('crawloptions_element_archive_crawl'));
            ?>
</a></li>
        <?php 
        }
        ?>
        </ul>
        <div class='tab-menu-content'>
        <div id='webcrawltab'>
        <?php 
        if (!isset($data['ts'])) {
            ?>
        <div class="top-margin"><label for="load-options"><b><?php 
            e(tl('crawloptions_element_load_options'));
            ?>
</b></label><?php 
            $this->view->helper("options")->render("load-options", "load_option", $data['available_options'], $data['options_default']);
            ?>
</div>
        <div class="top-margin"><label for="crawl-order"><b><?php 
            e(tl('crawloptions_element_crawl_order'));
            ?>
</b></label><?php 
            $this->view->helper("options")->render("crawl-order", "crawl_order", $data['available_crawl_orders'], $data['crawl_order']);
            ?>
        </div>
        <?php 
        }
        ?>
        <div class="top-margin"><label for="restrict-sites-by-url"><b><?php 
        e(tl('crawloptions_element_restrict_by_url'));
        ?>
</b></label>
                <input type="checkbox" id="restrict-sites-by-url"
                    class="restrict-sites-by-url"
                    name="restrict_sites_by_url" value="true"
                    onclick="setDisplay('toggle', this.checked)" <?php 
        e($data['TOGGLE_STATE']);
        ?>
 /></div>
        <div id="toggle">
            <div class="top-margin"><label for="allowed-sites"><b><?php 
        e(tl('crawloptions_element_allowed_to_crawl'));
        ?>
</b></label></div>
        <textarea class="short-text-area" id="allowed-sites"
            name="allowed_sites"><?php 
        e($data['allowed_sites']);
        ?>
</textarea></div>
        <div class="top-margin"><label for="disallowed-sites"><b><?php 
        e(tl('crawloptions_element_disallowed_and_quota_sites'));
        ?>
</b></label></div>
        <textarea class="short-text-area" id="disallowed-sites"
            name="disallowed_sites" ><?php 
        e($data['disallowed_sites']);
        ?>
</textarea>
        <?php 
        if (!isset($data['ts'])) {
            ?>
            <div class="top-margin"><label for="seed-sites"><b><?php 
            e(tl('crawloptions_element_seed_sites'));
            ?>
</b></label>
                [<a href="?c=admin&amp;a=manageCrawls&amp;arg=options<?php 
            e('&amp;' . CSRF_TOKEN . '=' . $data[CSRF_TOKEN]);
            ?>
&amp;suggest=add"><?php 
            e(tl('crawloptions_element_add_suggest_urls'));
            ?>
</a>]
            </div>
            <textarea class="tall-text-area" id="seed-sites"
                name="seed_sites" ><?php 
            e($data['seed_sites']);
            ?>
</textarea>
        <?php 
        } else {
            ?>
            <div class="top-margin"><label for="inject-sites"><b><?php 
            e(tl('crawloptions_element_inject_sites'));
            ?>
</b></label>
            [<a href="?c=admin&amp;a=manageCrawls&amp;arg=options<?php 
            e('&amp;' . CSRF_TOKEN . '=' . $data[CSRF_TOKEN] . '&amp;ts=' . $data['ts']);
            ?>
&amp;suggest=add"><?php 
            e(tl('crawloptions_element_add_suggest_urls'));
            ?>
</a>]
            </div></div>
            <?php 
            if ($data['INJECT_SITES'] != "") {
                ?>
                <input type="hidden" name="use_suggest" value="true" />
                <?php 
            }
            ?>
            <textarea class="short-text-area" id="inject-sites"
                name="inject_sites"><?php 
            e($data['INJECT_SITES']);
            ?>
</textarea>
            <?php 
        }
        ?>
        </div>
        <div id='archivetab'>
        <?php 
        if (!isset($data['ts'])) {
            ?>
        <div class="top-margin"><label for="load-options"><b><?php 
            e(tl('crawloptions_element_reindex_crawl'));
            ?>
</b></label><?php 
            $this->view->helper("options")->render("crawl-indexes", "crawl_indexes", $data['available_crawl_indexes'], $data['crawl_index']);
            ?>
</div>
        <?php 
            if (!API_ACCESS) {
                ?>
            <div class="center red"><?php 
                e(tl('crawloptions_element_need_api_for_mix'));
                ?>
</div>
        <?php 
            }
            ?>
        </div>
        <?php 
        }
        ?>
        </div>

        <div class="center slight-pad"><button class="button-box"
            type="submit" name="save_options">
            <?php 
        e(tl('crawloptions_element_save_options'));
        ?>
</button></div>
        </form>
        </div>
        <script type="text/javascript">

        function switchTab(newtab, oldtab)
        {
            setDisplay(newtab, true);
            setDisplay(oldtab, false);
            ntab = elt(newtab+"item");
            if(ntab) {
                ntab.className = 'active';
            }
            otab = elt(oldtab+"item");
            if(otab) {
                otab.className = '';
            }
            ctype = elt('crawl-type');
            if(ctype) {
            ctype.value = (newtab == 'webcrawltab')
                ? '<?php 
        e(CrawlConstants::WEB_CRAWL);
        ?>
' :
                '<?php 
        e(CrawlConstants::ARCHIVE_CRAWL);
        ?>
';
            }
        }
        </script>
    <?php 
    }
Exemplo n.º 20
0
 /**
  * Draws the search for locales forms
  *
  * @param array $data consists of values of locale fields set
  *     so far as well as values of the drops downs on the form
  */
 function renderSearchForm($data)
 {
     $controller = "admin";
     $activity = "manageLocales";
     $view = $this->view;
     $title = tl('managelocales_element_search_locales');
     $return_form_name = tl('managelocales_element_addlocale_form');
     $fields = array(tl('managelocales_element_localename') => "name", tl('managelocales_element_localetag') => "tag", tl('managelocales_element_writingmode') => "mode", tl('managelocales_element_enabled') => array("active", $data['EQUAL_COMPARISON_TYPES']));
     $dropdowns = array("mode" => array("lr-tb" => "lr-rb", "rl-tb" => "rl-tb", "tb-rl" => "tb-rl", "tb-lr" => "tb-lr"), "active" => array("1" => tl('managelocales_element_true'), "0" => tl('managelocales_element_false')));
     $view->helper("searchform")->render($data, $controller, $activity, $view, $title, $return_form_name, $fields, $dropdowns);
 }
Exemplo n.º 21
0
 /**
  * Used to set up view data for table search form (might make use of
  * $_REQUEST if form was submitted, results gotten, and we want to preserve
  * form drop down). Table search forms
  * are used by manageUsers, manageRoles, manageGroups, to do advanced
  * search of the entity they are responsible for.
  *
  * @param array& $data modified to contain the field data needed for
  *     the view to draw the search form
  * @param array $comparison_fields those fields of the entity
  *     in question ( for example, users) which we can search both with
  *     string comparison operators and equality operators
  * @param array $equal_comparison_fields those fields of the entity in
  *     question which can only be search by equality/inequality operators
  * @param string $field_postfix suffix to append onto field names in
  *     case there are multiple forms on the same page
  */
 function tableSearchRequestHandler(&$data, $comparison_fields = array(), $equal_comparison_fields = array(), $field_postfix = "")
 {
     $data['FORM_TYPE'] = "search";
     $data['COMPARISON_TYPES'] = array("=" => tl('admin_controller_equal'), "!=" => tl('admin_controller_not_equal'), "CONTAINS" => tl('admin_controller_contains'), "BEGINS WITH" => tl('admin_controller_begins_with'), "ENDS WITH" => tl('admin_controller_ends_with'));
     $data['EQUAL_COMPARISON_TYPES'] = array("=" => tl('admin_controller_equal'), "!=" => tl('admin_controller_not_equal'));
     $data['SORT_TYPES'] = array("NONE" => tl('admin_controller_no_sort'), "ASC" => tl('admin_controller_sort_ascending'), "DESC" => tl('admin_controller_sort_descending'));
     $paging = "";
     foreach ($comparison_fields as $comparison_start) {
         $comparison = $comparison_start . "_comparison";
         $comparison_types = in_array($comparison_start, $equal_comparison_fields) ? 'EQUAL_COMPARISON_TYPES' : 'COMPARISON_TYPES';
         $data[$comparison] = isset($_REQUEST[$comparison]) && isset($data[$comparison_types][$_REQUEST[$comparison]]) ? $_REQUEST[$comparison] : "=";
         $paging .= "&amp;{$comparison}=" . urlencode($data[$comparison]);
     }
     foreach ($comparison_fields as $sort_start) {
         $sort = $sort_start . "_sort";
         $data[$sort] = isset($_REQUEST[$sort]) && isset($data['SORT_TYPES'][$_REQUEST[$sort]]) ? $_REQUEST[$sort] : "NONE";
         $paging .= "&amp;{$sort}=" . urlencode($data[$sort]);
     }
     $search_array = array();
     foreach ($comparison_fields as $field) {
         $field_name = $field . $field_postfix;
         $field_comparison = $field . "_comparison";
         $field_sort = $field . "_sort";
         $data[$field_name] = isset($_REQUEST[$field_name]) ? $this->clean($_REQUEST[$field_name], "string") : "";
         if ($field_name == 'access' && $data[$field_name] >= 10) {
             $search_array[] = array("status", $data[$field_comparison], $data[$field_name] / 10, $data[$field_sort]);
         } else {
             $search_array[] = array($field, $data[$field_comparison], $data[$field_name], $data[$field_sort]);
         }
         $paging .= "&amp;{$field_name}=" . urlencode($data[$field_name]);
     }
     $data['PAGING'] = $paging;
     return $search_array;
 }
Exemplo n.º 22
0
 /**
  * This Helper method is used to setup params needed for Context-Sensitive
  * help to work. This gets executed if there is atleast one help button
  * rendered on the page. This is executed only once with the help of
  * "isHelpInitialized" variable.
  */
 private function setupHelpParams()
 {
     $this->isHelpInitialized = true;
     $this->localizationdata = "{" . 'wiki_view_edit :"' . tl('wiki_view_edit') . '",' . 'wiki_view_not_available :"' . tl('wiki_view_not_available') . '",' . 'wiki_view_read :"' . tl('wiki_view_read') . '"' . "}";
     $this->back_params = "{";
     /**
      * Use all the GET params to fille the back_params attr
      * this ensures that the user can come back to the exact same url
      * he originated from.
      */
     $back_params_array = array_diff_key($_GET, array_flip(array("a", "c", CSRF_TOKEN, "open_help_page")));
     array_walk($back_params_array, array($this, 'clean'));
     $back_params_only_keys = array_keys($back_params_array);
     $last_key = end($back_params_only_keys);
     foreach ($back_params_array as $key => $value) {
         $this->back_params .= $key . ' : "' . $value . '"';
         if ($key != $last_key) {
             $this->back_params .= ', ';
         }
     }
     $this->back_params .= "}";
     if (isset($_REQUEST['open_help_page'])) {
         $help_page_to_open = $this->clean($_REQUEST['open_help_page']);
         $this->script = 'var matches = ' . 'document.querySelectorAll(\'[data-pagename="' . $help_page_to_open . '"]\');' . "\n\t\t" . "matches[0].click();" . "\n";
     }
 }
Exemplo n.º 23
0
 /**
  * Checks to see if the current machine has php configured in a way
  * Yioop! can run.
  *
  * @return string a message indicatign which required and optional
  *     components are missing; or "Passed" if nothing missing.
  */
 function systemCheck()
 {
     $parent = $this->parent;
     $required_items = array(array("name" => "Multi-Curl", "check" => "curl_multi_init", "type" => "function"), array("name" => "GD Graphics Library", "check" => "imagecreate", "type" => "function"), array("name" => "PDO SQLite3 Library", "check" => "PDO", "type" => "class"), array("name" => "Multibyte Character Library", "check" => "mb_internal_encoding", "type" => "function"));
     $optional_items = array();
     $missing_required = "";
     $comma = "";
     foreach ($required_items as $item) {
         $check_function = $item["type"] . "_exists";
         $check_parts = explode("|", $item["check"]);
         $check_flag = true;
         foreach ($check_parts as $check) {
             if ($check_function($check)) {
                 $check_flag = false;
             }
         }
         if ($check_flag) {
             $missing_required .= $comma . $item["name"];
             $comma = ", ";
         }
     }
     if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
         $missing_required .= $comma . tl("system_component_php_version");
         $comma = ", ";
     }
     $out = "";
     $br = "";
     if (!is_writable(BASE_DIR . "/configs/config.php")) {
         $out .= tl('system_component_no_write_config_php');
         $br = "<br />";
     }
     if (defined(WORK_DIRECTORY) && !is_writable(WORK_DIRECTORY)) {
         $out .= $br . tl('system_component_no_write_work_dir');
         $br = "<br />";
     }
     if (intval(ini_get("post_max_size")) < 2) {
         $out .= $br . tl('system_component_post_size_small');
         $br = "<br />";
     }
     if ($missing_required != "") {
         $out .= $br . tl('system_component_missing_required', $missing_required);
         $br = "<br />";
     }
     $missing_optional = "";
     $comma = "";
     foreach ($optional_items as $item) {
         $check_function = $item["type"] . "_exists";
         $check_parts = explode("|", $item["check"]);
         $check_flag = true;
         foreach ($check_parts as $check) {
             if ($check_function($check)) {
                 $check_flag = false;
             }
         }
         if ($check_flag) {
             $missing_optional .= $comma . $item["name"];
             $comma = ", ";
         }
     }
     if ($missing_optional != "") {
         $out .= $br . tl('system_component_missing_optional', $missing_optional);
         $br = "<br />";
     }
     if ($out == "") {
         $out = tl('system_component_check_passed');
     } else {
         $out = "<span class='red'>{$out}</span>";
     }
     if (file_exists(BASE_DIR . "/configs/local_config.php")) {
         $out .= "<br />" . tl('system_component_using_local_config');
     }
     return $out;
 }
Exemplo n.º 24
0
    /**
     * Renders the list of admin activities and draws the current activity
     * Renders the Javascript to autologout after an hour
     *
     * @param array $data  what is contained in this array depend on the current
     * admin activity. The $data['ELEMENT'] says which activity to render
     */
    function renderView($data)
    {
        $logo = LOGO;
        if (MOBILE) {
            $logo = M_LOGO;
        }
        if (PROFILE) {
            ?>
        <div class="top-bar"><?php 
            $this->element("signin")->render($data);
            ?>
        </div><?php 
        }
        ?>
        <h1 class="admin-heading logo"><a href="./?<?php 
        e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
        ?>
"><img
            src="<?php 
        e($logo);
        ?>
" alt="<?php 
        e($this->logo_alt_text);
        ?>
" /></a><span> - <?php 
        e(tl('admin_view_admin'));
        if (!MOBILE) {
            e(' [' . $data['CURRENT_ACTIVITY'] . ']');
        }
        ?>
</span></h1>
        <?php 
        $this->element("activity")->render($data);
        $this->element("help")->render($data);
        if (isset($data['ELEMENT'])) {
            $element = $data['ELEMENT'];
            $this->element($element)->render($data);
        }
        if (PROFILE) {
            ?>
        <script type="text/javascript">
        /*
            Used to warn that user is about to be logged out
         */
        function logoutWarn()
        {
            doMessage(
                "<h2 class='red'><?php 
            e(tl('adminview_auto_logout_one_minute'));
            ?>
</h2>");
        }
        /*
            Javascript to perform autologout
         */
        function autoLogout()
        {
            document.location='?a=signout';
        }
        //schedule logout warnings
        var sec = 1000;
        var minute = 60*sec;
        setTimeout("logoutWarn()", 59 * minute);
        setTimeout("autoLogout()", 60 * minute);
        </script>
        <?php 
        }
    }
Exemplo n.º 25
0
    /**
     * Draws the log file of a queue_server or a fetcher
     *
     * @param array $data LOG_FILE_DATA has the log data
     */
    function render($data)
    {
        ?>
        <div class="current-activity">
        <div class="<?php 
        e($data['leftorright']);
        ?>
">
            <div class="<?php 
        e($data['leftorright']);
        ?>
">
            <a href="?c=admin&amp;a=manageMachines&amp;<?php 
        e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
        ?>
"
            ><?php 
        e(tl('machinelog_element_back_to_manage'));
        ?>
</a>
            </div>
            <form method="get" action="javascript:logUpdate();" >
                <table class="clear">
                <tr><th><label for="set-filter">
                <?php 
        e(tl('machinelog_element_filter'));
        ?>
</label></th>
                 <td><input type="text" class="narrow-field" id="set-filter"
                    onchange="javascript:logUpdate();"
                    value="<?php 
        e($data['filter']);
        ?>
" /></td></tr>
                </table>
            </form>
        </div>
        <h2><?php 
        e(tl('machinelog_element_log_file', $data['LOG_TYPE']));
        ?>
</h2>
        <?php 
        if (!$data['NO_REFRESH']) {
            ?>
        <p>[<a href="?c=admin&amp;<?php 
            e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
            ?>
&amp;a=manageMachines<?php 
            e($data['REFRESH_LOG']);
            ?>
&amp;NO_REFRESH=true" ><?php 
            e(tl('machinelog_element_refresh_off'));
            ?>
</a>]</p>
        <?php 
        } else {
            ?>
        <p>[<a href="?c=admin&amp;<?php 
            e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
            ?>
&amp;a=manageMachines<?php 
            e($data['REFRESH_LOG']);
            ?>
"><?php 
            e(tl('machinelog_element_refresh_on'));
            ?>
</a>]</p>
        <?php 
        }
        ?>
        <pre><?php 
        e(htmlentities(wordwrap($data["LOG_FILE_DATA"], 60, "\n", true)));
        ?>
</pre>
        <?php 
        if (!$data['NO_REFRESH']) {
            ?>
         <script type="text/javascript" >
        var updateId;
        function logUpdate()
        {
            var filter = elt('set-filter').value;
            var refreshUrl= "?c=admin&f=" + filter + "&<?php 
            e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
            ?>
&a=manageMachines<?php 
            e($data['REFRESH_LOG'] . "");
            ?>
";
            document.location = refreshUrl;
        }
        function doUpdate()
        {
             var sec = 1000;
             updateId = setInterval("logUpdate()", 30*sec);
        }
        </script>
        <?php 
        } else {
            ?>
         <script type="text/javascript" >
        function doUpdate() {}
        </script>
        <?php 
        }
        ?>
    <?php 
    }
Exemplo n.º 26
0
    /**
     * Draws an On Off switch in HTML where to toggle state one
     * clicks a link
     *
     * @param bool $state whether the switch is on or off
     * @param string $on_url  url that is sent when one clicks on
     * @param string $off_url  url that is sent when one clicks off
     * @param bool $caution is set to true if on in the database but the
     *      status received from testing the state of the toggle some other
     *      way is off (causes things to draw in yellow rather than green)
     */
    function render($state, $on_url, $off_url, $caution = false)
    {
        if ($state) {
            $oncolor = $caution ? "back-yellow" : "back-green";
            if ($caution) {
                ?>
                <table class="toggle-table"><tr><td
                class="<?php 
                e($oncolor);
                ?>
"><a href="<?php 
                e($on_url);
                ?>
"><?php 
                e(tl('toggle_helper_on'));
                ?>
</a></td>
                <td><a href="<?php 
                e($off_url);
                ?>
"
                ><?php 
                e(tl('toggle_helper_off'));
                ?>
</a></td></tr></table>
            <?php 
            } else {
                ?>
                <table class="toggle-table"><tr><td
                class="<?php 
                e($oncolor);
                ?>
"><b><?php 
                e(tl('toggle_helper_on'));
                ?>
</b></td>
                <td><a href="<?php 
                e($off_url);
                ?>
"
                ><?php 
                e(tl('toggle_helper_off'));
                ?>
</a></td></tr></table>
            <?php 
            }
            ?>
        <?php 
        } else {
            ?>
            <table class="toggle-table"><tr><td><a href="<?php 
            e($on_url);
            ?>
"
            ><?php 
            e(tl('toggle_helper_on'));
            ?>
</a></td>
            <td  class="back-red"><b><?php 
            e(tl('toggle_helper_off'));
            ?>
</b></td>
            </tr></table>
        <?php 
        }
    }
Exemplo n.º 27
0
 /**
  * Sets up the available perpage language options.
  * If handling data sent from a  form, it stores cleaned versions of
  * the number of results per page and language options into a sesssion
  *
  */
 function processRequest()
 {
     $data = array();
     $view = "settings";
     $changed_settings_flag = false;
     $crawl_model = $this->model("crawl");
     if (isset($_SESSION['USER_ID'])) {
         $user = $_SESSION['USER_ID'];
         $data['ADMIN'] = 1;
     } else {
         $user = $_SERVER['REMOTE_ADDR'];
     }
     $data[CSRF_TOKEN] = $this->generateCSRFToken($user);
     $token_okay = $this->checkCSRFToken(CSRF_TOKEN, $user);
     $languages = $this->model("locale")->getLocaleList();
     foreach ($languages as $language) {
         $data['LANGUAGES'][$language['LOCALE_TAG']] = $language['LOCALE_NAME'];
     }
     if ($token_okay && isset($_REQUEST['lang']) && in_array($_REQUEST['lang'], array_keys($data['LANGUAGES']))) {
         $_SESSION['l'] = $_REQUEST['lang'];
         setLocaleObject($_SESSION['l']);
         $changed_settings_flag = true;
     }
     $data['LOCALE_TAG'] = getLocaleTag();
     $n = NUM_RESULTS_PER_PAGE;
     $data['PER_PAGE'] = array($n => $n, 2 * $n => 2 * $n, 5 * $n => 5 * $n, 10 * $n => 10 * $n);
     if ($token_okay && isset($_REQUEST['perpage']) && in_array($_REQUEST['perpage'], array_keys($data['PER_PAGE']))) {
         $_SESSION['MAX_PAGES_TO_SHOW'] = $_REQUEST['perpage'];
         $changed_settings_flag = true;
     }
     if (isset($_SESSION['MAX_PAGES_TO_SHOW'])) {
         $data['PER_PAGE_SELECTED'] = $_SESSION['MAX_PAGES_TO_SHOW'];
     } else {
         $data['PER_PAGE_SELECTED'] = NUM_RESULTS_PER_PAGE;
     }
     if ($token_okay && isset($_REQUEST['perpage'])) {
         $_SESSION['OPEN_IN_TABS'] = isset($_REQUEST['open_in_tabs']) ? true : false;
     }
     if (isset($_SESSION['OPEN_IN_TABS'])) {
         $data['OPEN_IN_TABS'] = $_SESSION['OPEN_IN_TABS'];
     } else {
         $data['OPEN_IN_TABS'] = false;
     }
     $machine_urls = $this->model("machine")->getQueueServerUrls();
     $crawls = $crawl_model->getCrawlList(false, true, $machine_urls, true);
     $data['CRAWLS'] = array();
     foreach ($crawls as $crawl) {
         $data['CRAWLS'][$crawl['CRAWL_TIME']] = $crawl['DESCRIPTION'] . " ... " . $crawl['COUNT'] . " urls";
     }
     $mixes = $crawl_model->getMixList($user);
     foreach ($mixes as $mix) {
         $data['CRAWLS'][$mix['TIMESTAMP']] = $mix['NAME'] . " ... " . tl('settings_controller_crawl_mix');
     }
     $crawl_stamps = array_keys($data['CRAWLS']);
     if ($token_okay) {
         $changed_settings_flag = $this->loggedInChangeSettings($data);
     } else {
         if (isset($_REQUEST['its']) && in_array($_REQUEST['its'], $crawl_stamps)) {
             $data['its'] = $_REQUEST['its'];
         } else {
             $data['its'] = $crawl_model->getCurrentIndexDatabaseName();
         }
     }
     if ($changed_settings_flag) {
         $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >" . tl('settings_controller_settings_saved') . "</h1>')";
         if ($user != $_SERVER['REMOTE_ADDR']) {
             $this->model("user")->setUserSession($user, $_SESSION);
         }
     }
     $this->displayView($view, $data);
 }
        output("Many high-backed leather chairs fill the room.");
        output("In the chair closest to the fire sits J. C. Petersen, reading a heavy tome entitled \"Alchemy Today.\"`n`n");
        output("As you approach, a large hunting dog at his feet raises her head and looks at you.");
        output("Sensing that you belong, she lays down and goes back to sleep.`n`n");
        commentdisplay("Nearby some other rugged hunters talk:`n", "hunterlodge", "Talk quietly", 25);
        addnav("Use Points");
        modulehook("lodge");
    } else {
        $iname = getsetting("innname", LOCATION_INN);
        output("You pull out your Frequent Boozer Card from %s, with 9 out of the 10 slots punched out with a small profile of %s`0's Head.`n`n", $iname, getsetting('barkeep', '`tCedrik'));
        output("The guard glances at it, advises you not to drink so much, and directs you down the path.");
    }
} else {
    if ($op == "points") {
        output("`b`3Points:`b`n`n");
        $points_messages = modulehook("donator_point_messages", array('messages' => array('default' => tl("`7For each \$1 donated, the account which makes the donation will receive 100 contributor points in the game."))));
        foreach ($points_messages['messages'] as $id => $message) {
            output_notl($message, true);
        }
        output("\"`&But what are points,`7\" you ask?");
        output("Points can be redeemed for various advantages in the game.");
        output("You'll find access to these advantages in the Hunter's Lodge.");
        output("As time goes on, more advantages will likely be added, which can be purchased when they are made available.`n`n");
        output("Donating even one dollar will gain you a membership card to the Hunter's Lodge, an area reserved exclusively for contributors.");
        output("Donations are accepted in whole dollar increments only.`n`n");
        output("\"`&But I don't have access to a PayPal account, or I otherwise can't donate to your very wonderful project!`7\"`n");
        // yes, "referer" is misspelt here, but the game setting was also misspelt
        if (getsetting("refereraward", 25)) {
            output("Well, there is another way that you can obtain points: by referring other people to our site!");
            //CMJ alteration - need to put in some sort of text hook for this module that awards players with a dp every time a referred player gets a newday...
            output("You'll get one Donator Point every time a referred player logs in and gets a New Day.  ");
Exemplo n.º 29
0
    /**
     * Draw form to start a new crawl, has div place holder and ajax code to
     * get info about current crawl
     *
     * @param array $data  information about a crawl such as its description
     */
    function render($data)
    {
        ?>
        <div class="current-activity">
        <h2><?php 
        e(tl('managecrawls_element_create_crawl'));
        ?>
</h2>
        <form id="crawlStartForm" method="get">
        <input type="hidden" name="c" value="admin" />
        <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
        <input type="hidden" name="a" value="manageCrawls" />
        <input type="hidden" name="arg" value="start" />

        <p><label for="description-name"><?php 
        e(tl('managecrawls_element_description'));
        ?>
</label>:
            <input type="text" id="description-name" name="description"
                value="<?php 
        if (isset($data['DESCRIPTION'])) {
            e($data['DESCRIPTION']);
        }
        ?>
" maxlength="<?php 
        e(TITLE_LEN);
        ?>
"
                    class="wide-field"/>
            <button class="button-box" type="submit"><?php 
        e(tl('managecrawls_element_start_new_crawl'));
        ?>
</button>
            <a href="?c=admin&amp;a=manageCrawls<?php 
        ?>
&amp;arg=options&amp;<?php 
        e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
        ?>
"><?php 
        e(tl('managecrawls_element_options'));
        ?>
</a>
        </p>
        </form>
        <div id="crawlstatus" >
        <h2><?php 
        e(tl('managecrawls_element_awaiting_status'));
        ?>
</h2>
        </div>
        <script type="text/javascript" >
        var updateId;
        function crawlStatusUpdate()
        {
            var startUrl = "?c=admin&<?php 
        e(CSRF_TOKEN . "=" . $data[CSRF_TOKEN]);
        ?>
&a=crawlStatus<?php 
        e('&num_show=' . $data['NUM_SHOW'] . "&start_row=" . $data['START_ROW'] . "&end_row=" . $data['END_ROW']);
        ?>
";
            var crawlTag = elt('crawlstatus');
            getPage(crawlTag, startUrl);
        }
        function clearUpdate()
        {
             clearInterval(updateId );
             var crawlTag = elt('crawlstatus');
             crawlTag.innerHTML= "<h2 class='red'><?php 
        e(tl('managecrawls_element_up_longer_update'));
        ?>
</h2>";
        }
        function doUpdate()
        {
             var sec = 1000;
             var minute = 60*sec;
             crawlStatusUpdate();
             updateId = setInterval("crawlStatusUpdate()", 30*sec);
             setTimeout("clearUpdate()", 20*minute + sec);
        }
        </script>
        </div>
    <?php 
    }
Exemplo n.º 30
0
    /**
     * Method that draws forms to to select either among a text or a
     * graphical captcha
     *
     * @param array $data holds data on the profile elements which have been
     *     filled in as well as data about which form fields to display
     */
    function render($data)
    {
        $localize_url = "?" . CSRF_TOKEN . "=" . $data[CSRF_TOKEN] . "&amp;c=admin&amp;a=manageLocales" . "&amp;arg=editstrings&amp;selectlocale=" . $data['LOCALE_TAG'];
        ?>
        <div class = "current-activity">
        <h2><?php 
        e(tl('security_element_auth_captcha'));
        ?>
</h2>
        <form class="top-margin" method="post">
            <input type="hidden" name="c" value="admin" />
            <input type="hidden" name="a" value="security"/>
            <input type="hidden" name="<?php 
        e(CSRF_TOKEN);
        ?>
" value="<?php 
        e($data[CSRF_TOKEN]);
        ?>
" />
            <input type="hidden" name="arg" value="updatetypes"/>
            <div class="top-margin">
            <fieldset>
                <legend><label
                for="authentication-mode"><b><?php 
        e(tl('security_element_authentication_type'));
        e("&nbsp;" . $this->view->helper("helpbutton")->render("Authentication Type", $data[CSRF_TOKEN]));
        ?>
                </label></b></legend>
                    <?php 
        $this->view->helper("options")->render("authentication-mode", "AUTHENTICATION_MODE", $data['AUTHENTICATION_MODES'], $data['AUTHENTICATION_MODE']);
        if (isset($data['ZKP_UNAVAILABLE']) && $data['ZKP_UNAVAILABLE']) {
            e('<div class="red">' . tl('security_element_zero_unavailable') . "</div>");
        }
        ?>
            </fieldset>
            </div>
            <div class="top-margin">
            <fieldset>
                <legend><label
                for="captcha-mode"><b><?php 
        e(tl('security_element_captcha_type'));
        e("&nbsp;" . $this->view->helper("helpbutton")->render("Captcha Type", $data[CSRF_TOKEN]));
        ?>
</b>
                </label></legend>
                <?php 
        $this->view->helper("options")->render("captcha-mode", "CAPTCHA_MODE", $data['CAPTCHA_MODES'], $data['CAPTCHA_MODE']);
        ?>
            </fieldset>
            </div>
            <div class="top-margin center"><button
                class="button-box" type="submit"><?php 
        e(tl('security_element_save'));
        ?>
</button>
            </div>
        </form>
        <h2><?php 
        e(tl('security_element_captcha_recovery_questions'));
        ?>
</h2>
        <?php 
        if ($data['CAN_LOCALIZE']) {
            ?>
            <div class="top-margin">[<a href="<?php 
            e($localize_url . '&amp;filter=register_view_recovery' . '&amp;previous_activity=security');
            ?>
" ><?php 
            e(tl('security_element_edit_recovery'));
            ?>
</a>]
            </div>
            <div class="top-margin">[<a href="<?php 
            e($localize_url . '&amp;filter=register_view_question' . '&amp;previous_activity=security');
            ?>
" ><?php 
            e(tl('security_element_edit_captcha'));
            ?>
</a>]
            </div>
            <?php 
        } else {
            ?>
            <div class="top-margin">[<b class="gray"><?php 
            e(tl('security_element_edit_recovery'));
            ?>
</b>]
            </div>
            <div class="top-margin">[<b class="gray"><?php 
            e(tl('security_element_edit_captcha'));
            ?>
</b>]
            </div>
            <?php 
        }
        ?>
        </div>
        <?php 
    }