Example #1
0
function array_multi_search($p_needle, $p_haystack)
{
    if (!is_array($p_haystack)) {
        return false;
    }
    if (in_array($p_needle, $p_haystack)) {
        return true;
    }
    foreach ($p_haystack as $row) {
        if (array_multi_search($p_needle, $row)) {
            return true;
        }
    }
    return false;
}
Example #2
0
        echo get_page_link('edit_user');
        ?>
&user_id=<?php 
        echo $item->ID;
        ?>
">Редактировать</a>
                                |
                                <a class="button-control table-delete" data-set-action="delete_user">Удалить</a>
                            </p>
                        </td>
                        <td>
                            <?php 
        if (is_array($item->groups_ID)) {
            $last = get_last_key($item->groups_ID);
            foreach ($item->groups_ID as $key => $group) {
                $key_search = array_multi_search($group, $groups, 'ID');
                if ($key_search !== null) {
                    echo $groups[$key_search]->name;
                    if ($key != $last) {
                        echo ', ';
                    }
                }
            }
        }
        ?>
                        </td>
                    </tr> 
                <?php 
    }
    ?>
            </tbody>
Example #3
0
function delete_module($dir, $full = false)
{
    $active = get_option('active_modules');
    $path = ABSPATH . '/' . MODULES . '/' . $dir;
    if (is_dir($path) && file_exists($path . '/main.php')) {
        if (($key = array_multi_search($dir, $active, 0)) !== null) {
            unset($active[$key]);
            sort($active);
            if (file_exists($path . '/uninstall.php')) {
                require_once $path . '/uninstall.php';
            }
            return update_option('active_modules', json_val_encode($active));
        }
        if ($full) {
            return delete_folder($path);
        }
    }
    return false;
}
Example #4
0
function parse_command($text2parse)
{
    global $area;
    global $area_c;
    global $area_a;
    global $area;
    global $curr_area;
    global $curr_lang;
    global $string;
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    do {
        $PHP_SELF = $_SERVER['PHP_SELF'];
        $has_command1 = stripos($text2parse, '$[');
        if ($has_command1 !== false) {
            $has_command2 = stripos($text2parse, ']$');
            if ($has_command2 !== false) {
                $token = substr($text2parse, $has_command1, $has_command2 - $has_command1 + 2);
                $what = substr($token, 2, strlen($token) - 4);
                $prefix0 = explode(':', $what);
                $what = $prefix0[count($prefix0) - 1];
                $prefix = $prefix0[0];
                if ($prefix != $what) {
                    $prev_prefix = basename(dirname($PHP_SELF));
                    $PHP_SELF = str_ireplace($prev_prefix . SYS_PATH_SEP, $prefix . SYS_PATH_SEP, $PHP_SELF);
                    require_once str_replace(SYS_PATH_SEP_DOUBLE, SYS_PATH_SEP, dirname(__FILE__) . SYS_PATH_SEP) . DCTL_DATA_PATH . $prefix . SYS_PATH_SEP . 'config.inc.php';
                    switch ($prefix) {
                        case WEB_WCTL_NAME:
                            $key = array_multi_search($what, $area_c);
                            break;
                        case WEB_DCTL_NAME:
                            $key = array_multi_search($what, $area_a);
                            break;
                    }
                } else {
                    $key = array_multi_search($what, $area);
                }
                if (!stripos($what, '.php') === false) {
                    $replace = $what;
                } else {
                    $replace = $PHP_SELF;
                }
                $replace .= "?lang=" . $curr_lang . "&amp;area=" . $key;
                if (XMLDB_PATH_BASE_TMP) {
                    $replace .= "&amp;temp=true";
                }
                $text2parse = str_replace($token, $replace, $text2parse);
            }
        }
    } while ($has_command1 && $has_command2);
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    do {
        $has_command1 = stripos($text2parse, '${');
        if (!($has_command1 === false)) {
            $has_command2 = stripos($text2parse, '}$');
            if (!($has_command2 === false)) {
                $token = substr($text2parse, $has_command1, $has_command2 - $has_command1 + 2);
                $what = substr($token, 2, strlen($token) - 4);
                $replace = '';
                switch ($what) {
                    case 'newsletter':
                        $email = '';
                        if (isset($_REQUEST['email'])) {
                            $email = $_REQUEST['email'];
                        }
                        if (!stripos($email, '@') === false) {
                            require_once str_replace('//', '/', dirname(__FILE__) . '/') . '../_shared' . SYS_PATH_SEP . 'config.inc.php';
                            require_once str_replace(SYS_PATH_SEP_DOUBLE, SYS_PATH_SEP, dirname(__FILE__) . SYS_PATH_SEP) . './config.inc.php';
                            $connection = dctl_sql_connect(WEB_NEWSLETTER);
                            if ($connection) {
                                $email = addslashes($email);
                                $email = trim($email);
                                $query = "SELECT * FROM news_address WHERE email = '{$email}'";
                                $result = mysql_query($query);
                                if (mysql_num_rows($result) != false) {
                                    $replace .= "<br /><strong class=\"thankyou\">" . $string[$curr_lang]['mail_yetrecorded'] . " (" . $email . ")...</strong>";
                                } else {
                                    $query = "INSERT INTO news_address (id, email) VALUES (NULL, '{$email}')";
                                    $result = mysql_query($query);
                                    if (mysql_affected_rows() == 1) {
                                        $replace .= "<br /><strong class=\"thankyou\">" . $string[$curr_lang]['mail_ok'] . "...</strong>";
                                    } else {
                                        $replace .= "<br /><strong class=\"thankyou\">" . $string[$curr_lang]['mail_not'] . " (" . $email . ")...</strong>";
                                    }
                                }
                                mysql_close($connection);
                            } else {
                                $replace .= "<br /><strong class=\"thankyou\">" . $string[$curr_lang]['mail_nosrv'] . "...</strong></em>";
                            }
                        } else {
                            $replace .= '<form id="newsletter" action="' . $_SERVER['PHP_SELF'] . '" method="' . DCTL_FORM_METHOD . '" enctype="' . DCTL_FORM_ENCTYPE . '">';
                            $replace .= "<fieldset>";
                            $replace .= "<input class=\"small\" type=\"text\" size=\"20\" name=\"email\" value=\"(e-mail)\" />";
                            $replace .= "<label class=\"small\">";
                            $replace .= "<a class=\"small\" href=\"javascript:submitform('newsletter');\"> -&gt; " . $string[$curr_lang]['mail_sign'] . "</a>";
                            $replace .= "</label>";
                            $replace .= "<input type=\"hidden\" name=\"area\" value=\"" . $curr_area . "\" />";
                            $replace .= "<input type=\"hidden\" name=\"lang\" value=\"" . $curr_lang . "\" />";
                            $replace .= "</fieldset></form>";
                        }
                        break;
                }
                $text2parse = str_replace($token, $replace, $text2parse);
            }
        }
    } while ($has_command1 && $has_command2);
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    return $text2parse;
}
Example #5
0
 ?>
     <table width="100%" class="table table-striped table-hover table-bordered">
         <thead>
             <tr>
                 <th width="20%">Название</th>
                 <th>Описание</th>
                 <th width="5%">Версия</th>
             </tr>
         </thead>
         <tbody>
         <?php 
 foreach ($list as $item) {
     ?>
             <?php 
     $key = null;
     $in = ($key = array_multi_search($item['path'], $active, 0)) !== null ? true : false;
     $on = $in && $active[$key][1] ? true : false;
     echo '<tr class="parenter ';
     if ($in) {
         echo 'installed';
         if ($on) {
             echo ' success';
         }
     } else {
         echo 'active';
     }
     echo '">';
     ?>
                 <td><?php 
     echo $item['name'];
     ?>
Example #6
0
<?php

$active = get_option('active_modules');
if ($active == null) {
    $active = array();
}
$modules = scandir(ABSPATH . '/' . MODULES);
foreach ($modules as $dir) {
    $path = ABSPATH . '/' . MODULES . '/' . $dir;
    $key = null;
    if (is_dir($path) && file_exists($path . '/main.php') && ($key = array_multi_search($dir, $active, 0)) !== null && $active[$key][1] == true) {
        require_once $path . '/main.php';
    }
}
unset($active, $modules);