Example #1
0
function in_array_r($needle, $haystack, $strict = false)
{
    foreach ($haystack as $item) {
        if (($strict ? $item === $needle : $item == $needle) || is_array($item) && in_array_r($needle, $item, $strict)) {
            return true;
        }
    }
    return false;
}
 function in_array_r($needle, $haystack)
 {
     foreach ($haystack as $item) {
         if ($item === $needle || is_array($item) && in_array_r($needle, $item)) {
             return true;
         }
     }
     return false;
 }
Example #3
0
/**
 * Recursive in_array function
 *
 * @param  array $needle
 * @param  array $haystack
 * @return boolean
 */
function in_array_r($needle, $haystack)
{
    if (!is_array($needle)) {
        return in_array_r(array($needle), $haystack);
    }
    foreach ($needle as $item) {
        if (in_array($item, $haystack)) {
            return true;
        }
    }
    return false;
}
Example #4
0
 private function in_array_r($needle, $haystack)
 {
     $found = false;
     foreach ($haystack as $item) {
         if ($item === $needle) {
             $found = true;
             break;
         } elseif (is_array($item)) {
             $found = in_array_r($needle, $item);
             if ($found) {
                 break;
             }
         }
     }
     return $found;
 }
 public function form($instance)
 {
     // Extracting defined values and defining default values for variables
     $instance = wp_parse_args((array) $instance, array('title' => '', 'features' => array(), 'url' => ''));
     // $title 				= esc_attr( $instance['title'] );
     $url = esc_url($instance['url']);
     $active_features = $instance['features'];
     // Store all active features first in (array) $all_features
     $all_features = $active_features;
     // Append non-active features to (array) $all_features
     foreach ($this->feature_list as $feature) {
         if (!in_array_r($feature, $active_features)) {
             $all_features[] = array('name' => $feature);
         }
     }
     // Display the admin form
     include plugin_dir_path(__FILE__) . 'inc/admin-widget.php';
 }
Example #6
0
function parseNavArray($nav_array, $page_url, $level = 1)
{
    $output = "";
    foreach ($nav_array as $nav_title => $nav_url) {
        if (is_array($nav_url)) {
            $nav_class = '';
            if (in_array_r($page_url, $nav_url)) {
                $nav_class = ' active';
            }
            // end if (in_array_r($page_url, $nav_url))
            if ($level == 1) {
                $output .= '<li class="dropdown' . $nav_class . '">' . '<a class="dropdown-toggle" data-toggle="dropdown">' . $nav_title . ' <b class="caret"></b>' . '</a>' . '<ul class="dropdown-menu">' . parseNavArray($nav_url, $page_url, $level + 1) . '</ul>' . '</li>';
            } else {
                // end if ($level == 1)
                $output .= '<li class="dropdown-submenu">' . '<a>' . $nav_title . '</a>' . '<ul class="dropdown-menu">' . parseNavArray($nav_url, $page_url, $level + 1) . '</ul>' . '</li>';
            }
            // end if ($level == 1) else
        } else {
            if ($nav_url == "divider") {
                // end if (is_array($nav_url))
                $output .= '<li class="divider"></li>';
            } else {
                if ($nav_url == $page_url) {
                    // end if ($nav_url == "divider")
                    if ($level == 1) {
                        $output .= '<li class="active"><a>' . $nav_title . '</a></li>';
                    } else {
                        // end if ($level == 1)
                        $output .= '<li class="disabled"><a>' . $nav_title . '</a></li>';
                    }
                    // end if ($level == 1) else
                } else {
                    // end if ($nav_url == $page_url)
                    $output .= '<li><a href="' . $nav_url . '">' . $nav_title . '</a></li>';
                }
            }
        }
        // end if ($nav_url == $page_url) else
    }
    // end foreach ($nav_array as $nav_title => $nav_url)
    return $output;
}
Example #7
0
 static function subcategorias($client)
 {
     if (self::tieneCatCustom($client)) {
         $cats = self::categoriasCustom($client);
         $c = array();
         foreach ($cats['data'] as $cat) {
             if ($cat['activo'] == 1 && !in_array_r($cat['subcategoria'], $c)) {
                 $c[] = array('categoria' => $cat['categoria'], 'subcategoria' => $cat['subcategoria']);
             }
         }
         return $c;
     } else {
         PDOSql::$pdobj = pdoConnect();
         $cats = Sql::fetch("SELECT categoria, subcategoria from cats ORDER BY id ASC");
         $c = array();
         foreach ($cats as $cat) {
             if (!in_array_r($cat['subcategoria'], $c)) {
                 $c[] = array('categoria' => $cat['categoria'], 'subcategoria' => $cat['subcategoria']);
             }
         }
         return $c;
     }
 }
 /**
  * Datenbank pruefen
  *
  * *Description* Pruefe bei Systemstart ob alle notwendigen Tabellen und Spalten angelegt sind 
  * 
  * @param string
  *
  * @return array
  */
 public function checkDB($setting = 'complete')
 {
     $missing = array('error' => FALSE, 'message' => NULL);
     $tableCols = parent::dbStrukture('cols');
     // Prüfe ob Tabellen existieren
     $stmt = $this->db->query("SHOW TABLES");
     $tables = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     if (!empty($tables)) {
         foreach (parent::dbStrukture('tables') as $table) {
             if (in_array_r(TBL_PRFX . $table, $tables)) {
                 // Prüfe ob alle Spalten existieren bei complete
                 if ($setting != 'short') {
                     $stmt = $this->db->query("SHOW COLUMNS FROM " . TBL_PRFX . $table);
                     $columns = $stmt->fetchAll(\PDO::FETCH_COLUMN);
                     if (!empty($columns)) {
                         foreach ($tableCols[$table] as $column) {
                             if (!in_array_r($column, $columns)) {
                                 $missing['message'][] = 'missing column ' . $column . ' in table ' . $table;
                             }
                         }
                     } else {
                         $missing['message'][] = 'missing all cols in table ' . $table;
                     }
                 }
             } else {
                 $missing['message'][] = 'missing table ' . $table;
             }
         }
     } else {
         $missing['message'][] = 'missing all tables';
     }
     if (!empty($missing['message'])) {
         $missing['error'] = TRUE;
     }
     return $missing;
 }
 /**
  * Filter berdasarkan nama provinsi
  */
 public function getCities($index)
 {
     $provinsi = $this->_data[$index]['provinsi'];
     $kota = array_filter($this->_data, function ($data) use($provinsi) {
         return preg_match('/\\b' . $provinsi . '\\b/', $data['provinsi']);
     });
     $_kota = array();
     foreach ($kota as $k => $v) {
         if (!in_array_r($v['kota'], $_kota)) {
             $_kota[$k] = array('name' => $v['kota'], 'kecamatan' => array($k => array('kode' => $v['code'], 'nama' => $v['kecamatan'])));
             $index = $k;
         } else {
             $_kota[$index]['kecamatan'][$k] = array('kode' => $v['code'], 'nama' => $v['kecamatan']);
         }
     }
     return $_kota;
 }
Example #10
0
function bbconnect_process_country($country)
{
    $bbconnect_helper_country = bbconnect_helper_country();
    if (strlen($country) > 3) {
        $country = in_array_r($country, $bbconnect_helper_country, true);
    } else {
        $country = substr($country, 0, 2);
    }
    return $country;
}
Example #11
0
function in_array_r($needle, $haystack, $strict = false)
{
    if (is_array($haystack)) {
        foreach ($haystack as $key => $item) {
            if (($strict ? $item === $needle : $item == $needle) || is_array($item) && in_array_r($needle, $item, $strict)) {
                return array('key' => $key, 'slice' => $item);
            }
        }
    }
    return false;
}
Example #12
0
 /**
  * Builds the Page Tree into HTML
  * 
  * @param array $links      Page Tree array from `navigation_m->get_link_tree`
  * @param bool  $return_arr Return as an Array instead of HTML
  * @return array|string
  */
 private function _build_links($links = array(), $return_arr = true)
 {
     static $current_link = false;
     static $level = 0;
     $top = $this->attribute('top', false);
     $separator = $this->attribute('separator', '');
     $link_class = $this->attribute('link_class', '');
     $more_class = $this->attribute('more_class', 'has_children');
     $current_class = $this->attribute('class', 'current');
     $first_class = $this->attribute('first_class', 'first');
     $last_class = $this->attribute('last_class', 'last');
     $parent_class = $this->attribute('parent_class', 'parent');
     $dropdown_class = $this->attribute('dropdown_class', 'dropdown');
     $output = $return_arr ? array() : '';
     $wrap = $this->attribute('wrap');
     $max_depth = $this->attribute('max_depth');
     $i = 1;
     $total = sizeof($links);
     if (!$return_arr) {
         $tag = $this->attribute('tag', 'li');
         $list_tag = $this->attribute('list_tag', 'ul');
         switch ($this->attribute('indent')) {
             case 't':
             case 'tab':
             case '	':
                 $indent = "\t";
                 break;
             case 's':
             case 'space':
             case ' ':
                 $indent = "    ";
                 break;
             default:
                 $indent = false;
                 break;
         }
         if ($indent) {
             $ident_a = repeater($indent, $level);
             $ident_b = $ident_a . $indent;
             $ident_c = $ident_b . $indent;
         }
     }
     foreach ($links as $link) {
         $item = array();
         $wrapper = array();
         // attributes of anchor
         $item['url'] = $link['url'];
         $item['title'] = $link['title'];
         $item['total'] = $total;
         if ($wrap) {
             $item['title'] = '<' . $wrap . '>' . $item['title'] . '</' . $wrap . '>';
         }
         $item['attributes']['target'] = $link['target'] ? 'target="' . $link['target'] . '"' : null;
         $item['attributes']['class'] = $link_class ? 'class="' . $link_class . '"' : '';
         // attributes of anchor wrapper
         $wrapper['class'] = $link['class'] ? explode(' ', $link['class']) : array();
         $wrapper['children'] = $return_arr ? array() : null;
         $wrapper['separator'] = $separator;
         // is single ?
         if ($total === 1) {
             $wrapper['class'][] = 'single';
         } elseif ($i === 1) {
             $wrapper['class'][] = $first_class;
         } elseif ($i === $total) {
             $wrapper['class'][] = $last_class;
             $wrapper['separator'] = '';
         }
         // has children ? build children
         if ($link['children']) {
             ++$level;
             if (!$max_depth or $level < $max_depth) {
                 $wrapper['class'][] = $more_class;
                 $wrapper['children'] = $this->_build_links($link['children'], $return_arr);
             }
             --$level;
         }
         // is this the link to the page that we're on?
         if (preg_match('@^' . current_url() . '/?$@', $link['url']) or $link['link_type'] == 'page' and $link['is_home'] and site_url() == current_url()) {
             $current_link = $link['url'];
             $wrapper['class'][] = $current_class;
         }
         // Is this page a parent of the current page?
         // Get the URI and compare
         $uri_segments = explode('/', str_replace(site_url(), '', $link['url']));
         foreach ($uri_segments as $k => $seg) {
             if (!$seg) {
                 unset($uri_segments[$k]);
             }
         }
         $short_segments = array_slice($this->uri->segment_array(), 0, count($uri_segments));
         if (!array_diff($short_segments, $uri_segments)) {
             $wrapper['class'][] = $parent_class;
         }
         // is the link we're currently working with found inside the children html?
         if (!in_array($current_class, $wrapper['class']) and isset($wrapper['children']) and $current_link and (is_array($wrapper['children']) and in_array_r($current_link, $wrapper['children']) or is_string($wrapper['children']) and strpos($wrapper['children'], $current_link))) {
             // that means that this link is a parent
             $wrapper['class'][] = 'has_' . $current_class;
         } elseif ($link['module_name'] === $this->module and !preg_match('@^' . current_url() . '/?$@', $link['url'])) {
             $wrapper['class'][] = 'has_' . $current_class;
         }
         ++$i;
         if ($return_arr) {
             $item['target'] =& $item['attributes']['target'];
             $item['class'] =& $item['attributes']['class'];
             $item['children'] = $wrapper['children'];
             if ($wrapper['class'] && $item['class']) {
                 $item['class'] = implode(' ', $wrapper['class']) . ' ' . substr($item['class'], 7, -1);
             } elseif ($wrapper['class']) {
                 $item['class'] = implode(' ', $wrapper['class']);
             }
             if ($item['target']) {
                 $item['target'] = substr($item['target'], 8, -1);
             }
             // assign attributes to level family
             $output[] = $item;
         } else {
             $add_first_tag = $level === 0 && !in_array($this->attribute('items_only', 'true'), array('1', 'y', 'yes', 'true'));
             // render and indent or only render inline?
             if ($indent) {
                 // remove all empty values so we don't have an empty class attribute
                 $classes = implode(' ', array_filter($wrapper['class']));
                 $output .= $add_first_tag ? "<{$list_tag}>" . PHP_EOL : '';
                 $output .= $ident_b . '<' . $tag . ($classes > '' ? ' class="' . $classes . '">' : '>') . PHP_EOL;
                 $output .= $ident_c . (($level == 0 and $top == 'text' and $wrapper['children']) ? $item['title'] : anchor($item['url'], $item['title'], trim(implode(' ', $item['attributes'])))) . PHP_EOL;
                 if ($wrapper['children']) {
                     $output .= $ident_c . "<{$list_tag}>" . PHP_EOL;
                     $output .= $ident_c . $indent . str_replace(PHP_EOL, PHP_EOL . $indent, trim($ident_c . $wrapper['children'])) . PHP_EOL;
                     $output .= $ident_c . "</{$list_tag}>" . PHP_EOL;
                 }
                 $output .= $wrapper['separator'] ? $ident_c . $wrapper['separator'] . PHP_EOL : '';
                 $output .= $ident_b . "</{$tag}>" . PHP_EOL;
                 $output .= $add_first_tag ? $ident_a . "</{$list_tag}>" . PHP_EOL : '';
             } else {
                 // remove all empty values so we don't have an empty class attribute
                 $classes = implode(' ', array_filter($wrapper['class']));
                 $output .= $add_first_tag ? "<{$list_tag}>" : '';
                 $output .= '<' . $tag . ($classes > '' ? ' class="' . $classes . '">' : '>');
                 $output .= ($level == 0 and $top == 'text' and $wrapper['children']) ? $item['title'] : anchor($item['url'], $item['title'], trim(implode(' ', $item['attributes'])));
                 if ($wrapper['children']) {
                     $output .= '<' . $list_tag . ' class="' . $dropdown_class . '">';
                     $output .= $wrapper['children'];
                     $output .= "</{$list_tag}>";
                 }
                 $output .= $wrapper['separator'];
                 $output .= "</{$tag}>";
                 $output .= $add_first_tag ? "</{$list_tag}>" : '';
             }
         }
     }
     return $output;
 }
Example #13
0
 function sc_ra_ads($name)
 {
     if (qw_hook_exist(__FUNCTION__)) {
         $args = func_get_args();
         array_unshift($args, $this);
         return qw_event_hook(__FUNCTION__, $args, NULL);
     }
     $option = ra_opt('ra_qaads');
     if (is_array($option)) {
         if (in_array_r($name, $option)) {
             foreach ($option as $opt) {
                 if (ra_edit_mode() && $opt['name'] == $name) {
                     $this->output('<div style="height:100px;background:#333;text-align:center;font-size:20px;margin-bottom:20px;">', $opt['name'], '</div>');
                 } elseif ($opt['name'] == $name) {
                     $this->output(str_replace('\\', '', base64_decode($opt['code'])));
                 }
             }
         } else {
             $this->output('No ads code found with this name');
         }
     }
 }
Example #14
0
    }
}
?>
                  
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
foreach ($users as $value) {
    echo '<tr>
                                    <td>' . $value->username . '</td>';
    foreach ($roles as $val) {
        if (_is('RC Admin') && $val['role_name'] == "GR Admin") {
            //                                            echo '<td style="text-align:center"><input  ' . (in_array_r($value->id, $val['assignedusers'], true) ? 'checked' : '') . ' data-user="******" data-role="' . $val['id'] . '" type="checkbox" class="iCheckmodule minimal"></td>';
        } else {
            echo '<td style="text-align:center"><input  ' . (in_array_r($value->id, $val['assignedusers'], true) ? 'checked' : '') . ' data-user="******" data-role="' . $val['id'] . '" type="checkbox" class="iCheckmodule minimal"></td>';
        }
    }
    echo '</tr>';
}
?>
                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div><!-- /.col -->

        </div><!-- /.row -->

    </section>
</section>
     $package_name = htmlspecialchars($item['name']);
     $package = $queries->getWhere('donation_packages', array('name', '=', $package_name));
     if (!count($package)) {
         // No, it doesn't exist
         $package_id = $item['id'];
         $package_category = $item['categoryid'];
         $package_description = htmlspecialchars($item['description']);
         $package_price = $item['price'];
         $package_url = htmlspecialchars($item['url']);
         $queries->create('donation_packages', array('name' => $package_name, 'description' => $package_description, 'cost' => $package_price, 'package_id' => $package_id, 'active' => 1, 'package_order' => 0, 'category' => $package_category, 'url' => $package_url));
     }
 }
 // Delete any packages which don't exist on the web store anymore
 $packages = $queries->getWhere('donation_packages', array('id', '<>', 0));
 foreach ($packages as $package) {
     if (!in_array_r($package->package_id, $mm_gui['result'])) {
         // It doesn't exist anymore
         $queries->delete('donation_packages', array('id', '=', $package->id));
     }
 }
 /*
  * DONORS SYNC
  */
 foreach ($mm_donors['result'] as $item) {
     // Does it already exist in the database?
     $date = date('Y-m-d H:i:s', strtotime($item['date']));
     $donor_query = $queries->getWhere('buycraft_data', array('time', '=', $date));
     if (count($donor_query)) {
         // Already exists, we can stop now
         break;
     }
/**
 * Calls the various functions to deal with webhook events.
 *
 * @since 1.0.0
 */
function bbconnect_parse_request($wp)
{
    // DO WE HAVE BBCONNECT AS AN EXPLICIT VALUE?
    $bbc_top = in_array_r('bbconnect', $wp->query_vars, true);
    // DO WE HAVE BBCONNECT AS AN INVISIBLE REFERENCE?
    if (isset($wp->query_vars['bbconnectref'])) {
        if ('true' == get_option('bbconnectpanels_embed') && false == $bbc_top) {
            $bbc_top = 'pagename';
            $wp->query_vars['pagename'] = 'bbconnect';
        }
    }
    // DO WE HAVE BBCONNECT AS A PROXY FOR WP RESETS?
    if (isset($_GET['key']) && isset($_GET['login'])) {
        if ('true' == get_option('bbconnectpanels_embed') && false == $bbc_top) {
            $bbc_top = 'pagename';
            $wp->query_vars['pagename'] = 'bbconnect';
        }
        $wp->query_vars['bbc_wp_key'] = $_GET['key'];
        $wp->query_vars['bbc_wp_login'] = $_GET['login'];
    }
    // HERE, WE ARE LOOKING FOR A SUBROUTINE OF BBCONNECT
    if (array_key_exists('bbconnect', $wp->query_vars)) {
        switch ($wp->query_vars['bbconnect']) {
            // EXTEND THE HOOK SYSTEM
            default:
                do_action('bbconnect_parse_switch', $wp);
                break;
        }
        // HERE, WE ARE DEALING WITH BBCONNECT TOP-LEVEL FUNCTIONALITY
        // PROCESS EMBEDS AND REDIRECTS
    } else {
        if (false != $bbc_top) {
            //if ( 'pagename' == $bbc_top || 'name' == $bbc_top ) {
            //unset( $wp->query_vars['pagename'] );
            add_filter('wp_title', 'bbconnect_page_title');
            do_action('bbconnect_system_page', $wp);
            //}
        }
    }
}
</div>

<a href="javascript:void(0);" class="btn" onclick="$('#allUser').toggleClass('hide');">เพิ่ม</a>
<div class="row hide" id="allUser">
	<div class="col s12">
		<div class="col s12 input-field">
			<input type="text" id="instantFilter">
			<label for="instantFilter">กรองรายชื่อ</label>
		</div>
		<table class="bordered highlight" id="tableAllUser">
			<tbody>
				<?php 
foreach ($dataEmpList as $row) {
    ?>
					<?php 
    if (in_array_r($row["UserID"], $dataEmpShiftworkList)) {
        ?>
						<tr class="hide">
					<?php 
    } else {
        ?>
						<tr>
					<?php 
    }
    ?>
						<td id="userID_<?php 
    echo $row["UserID"];
    ?>
"><?php 
    echo $row["EmpID"];
    ?>
 public function getResult($limit = 0, $email = -1)
 {
     if ($email != -1) {
         if ($limit == -1) {
             $query = $this->pdo->prepare('SELECT * FROM ' . RESULT_TABLE . ' ORDER BY totalScr DESC');
         } else {
             //											$query = $this->pdo->prepare('SELECT companyName,email,name,totalScr FROM '.RESULT_TABLE.' WHERE totalScr <> 0 GROUP BY email ORDER BY totalScr DESC');
             $query = $this->pdo->prepare('SELECT edate,companyName,email,name,SUM(totalScr) as totalScr,MAX(rawScr) as rawScr, COUNT(totalScr) as totalRows  FROM ' . RESULT_TABLE . ' WHERE totalScr > 0 GROUP BY email ORDER BY totalScr DESC');
             //$query = $this->pdo->prepare('SELECT companyName,email,name,SUM(totalScr) as totalScr FROM '.RESULT_TABLE.' WHERE totalScr <> 0 GROUP BY email ORDER BY rawScr DESC LIMIT 10');
         }
         if (strcmp($limit, "getResultforSubmit") == 0) {
             $email_query = $this->pdo->prepare('SELECT * FROM ' . RESULT_TABLE . ' WHERE email="' . $email . '" AND hashtag="' . $_SESSION['hash'] . '" ORDER BY totalScr DESC LIMIT 1');
         } else {
             $email_query = $this->pdo->prepare('SELECT * FROM ' . RESULT_TABLE . ' WHERE email="' . $email . '" ORDER BY totalScr DESC LIMIT 1');
         }
         try {
             $result_data = $query->execute();
             $email_data = $email_query->execute();
         } catch (PDOException $err) {
             return "Error: " . $err->getMessage();
         }
         $result_data = $query->fetchAll(PDO::FETCH_ASSOC);
         $tmp_data = $result_data;
         $email_data = $email_query->fetchAll(PDO::FETCH_ASSOC);
         if (!in_array_r($email_data[0]['email'], $result_data)) {
             // do something if the given value does not exist in the array
             $result_data[count($result_data) - 1] = $email_data[0];
         }
         $result_data = $tmp_data;
         //								echo $limit;
         if (strcmp($limit, "getResult") == 0) {
             $result_data = $email_data;
         }
         if (strcmp($limit, "getResultforSubmit") == 0) {
             $result_data = $email_data;
         }
     } else {
         if ($limit == -1) {
             $query = $this->pdo->prepare('SELECT edate,name,email,location,minScr,maxScr,totalGameTime,companyName,SUM(totalScr) as totalScr, COUNT(totalScr) as totalRows FROM ' . RESULT_TABLE . ' WHERE totalScr >= 0 GROUP BY email ORDER BY totalScr DESC');
             //$query = $this->pdo->prepare('SELECT * FROM '.RESULT_TABLE.' ORDER BY totalScr DESC');
         } else {
             //$query = $this->pdo->prepare('SELECT companyName,email,name,totalScr FROM '.RESULT_TABLE.' WHERE totalScr <> 0 GROUP BY email ORDER BY totalScr DESC LIMIT 10');
             $query = $this->pdo->prepare('SELECT edate,companyName,email,name,SUM(totalScr) as totalScr,MAX(rawScr) as rawScr, COUNT(totalScr) as totalRows  FROM ' . RESULT_TABLE . ' WHERE totalScr <> 0 GROUP BY email ORDER BY totalScr DESC');
             //										$query = $this->pdo->prepare('SELECT companyName,email,name,SUM(totalScr) as totalScr,MAX(rawScr) as rawScr FROM '.RESULT_TABLE.' WHERE totalScr <> 0 GROUP BY email ORDER BY totalScr DESC LIMIT 10');
             $query2 = $this->pdo->prepare('SELECT edate,companyName,name,max(totalScr) as rawScr,email, COUNT(totalScr) as totalRows  FROM ' . RESULT_TABLE . ' WHERE totalScr <> 0 GROUP BY email ORDER BY totalScr DESC LIMIT 10');
         }
         try {
             $result_data = $query->execute();
         } catch (PDOException $err) {
             return "Error: " . $err->getMessage();
         }
         $result_data = $query->fetchAll(PDO::FETCH_ASSOC);
     }
     return $result_data;
 }
Example #19
0
function updatecycleV3()
{
    $db_server = mysqli_connect("localhost", "root", "root", "schedule");
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    $today = date('Y-m-d');
    //Here's the goal of V3 - take all inactive days. then run the usual update sequence checking only if a day is a weekend or on the inactive array
    $findoffdays = "SELECT daate FROM days where active = 'n';";
    $offdaysresult = mysqli_query($db_server, $findoffdays);
    if ($findoffdays->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }
    $offdays_array = mysqli_fetch_all($offdaysresult, MYSQLI_NUM);
    mylog(print_r($offdays_array, true));
    $x = 1;
    $cyc_array = array('A', 'B', 'C', 'D', 'E', 'F');
    $letter = 'A';
    $cyc = 0;
    while ($x <= 200) {
        $startdate = "2016-01-04";
        $dategivenbyadmin = strtotime($startdate);
        $formatteddateforcondish = date('Y-m-d', $dategivenbyadmin);
        mylog("{$dategivenbyadmin} is the DATE GIVEN BY ADMIN");
        $nextday = date('Y-m-d', strtotime("+ {$x} days", "{$dategivenbyadmin}"));
        mylog("{$x} days after {$dategivenbyadmin} is {$nextday}");
        //$activeday = checkforinactiveday($nextday);
        //if it's a weekend, skip
        if (date('D', strtotime("+ {$x} days", "{$dategivenbyadmin}")) === "Sun" || date('D', strtotime("+ {$x} days", "{$dategivenbyadmin}")) === "Sat") {
            mylog("{$nextday} is a weekend 395");
            $x = $x + 1;
        } elseif (in_array_r($nextday, $offdays_array, true)) {
            mylog("{$nextday} is in the {$offdays} list");
            $x = $x + 1;
        } else {
            $letter = $cyc_array[$cyc];
            //mylog("should be starting with $letter");
            $cyc = $cyc == 5 ? 0 : $cyc + 1;
            mylog("the cyc value for {$nextday} should be {$cyc}");
            mylog("the letter value for {$nextday} should be {$letter}");
            $dayquery = "UPDATE days SET cycleday = '{$letter}', daymodified = '{$today}' WHERE daate = '{$nextday}';";
            mylog("update query looks like {$dayquery}");
            $dayqueryresult = mysqli_query($db_server, $dayquery);
            mylog('ran the inactive day query');
            if ($dayqueryresult->connect_errno) {
                echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
            }
            $x = $x + 1;
            //$cyc = $cyc + 1;
        }
    }
}
Example #20
0
function fi_info_shared($d, $id)
{
    $sh = in_array_r($_SESSION['curdir'], $d, 0);
    $j = 'fifunc___fi*';
    $dj = ajx($d) . '_' . $id;
    if ($sh) {
        $t = nms(74);
    } else {
        $t = nms(75);
    }
    $c = $sh ? 'color:#bd0000' : '';
    $ret .= blj('', $id . 'fishr', $j . 'share_' . $dj, picto('share', $c));
    if ($sh) {
        $ret .= blj('', $id . 'fivrd', $j . 'vdir_' . $sh . '_' . $id, fi_pic('virtual_dir')) . ' ';
    }
    return $ret;
}
function bbconnect_rows($args = null)
{
    global $wpdb;
    global $totalValues, $fieldInfos;
    $positionInarray = 0;
    //determine which position we have in array
    $blog_prefix = $wpdb->get_blog_prefix(get_current_blog_id());
    // SET THE DEFAULTS TO BE OVERRIDDEN AS DESIRED
    $defaults = array('user_id' => false, 'action_search' => false, 'action_array' => false, 'post_vars' => false, 'table_body' => false, 'action' => 'view', 'bbconnect_address_count' => 0, 'return' => false, 'tdw' => false, 'thiskey' => '', 'return_def' => true);
    // PARSE THE INCOMING ARGS
    $args = wp_parse_args($args, $defaults);
    // EXTRACT THE VARIABLES
    extract($args, EXTR_SKIP);
    // SET A LOOKUP ARRAY FOR THE INITIAL QUERY
    $post_matches = array();
    if (isset($post_vars['search'])) {
        foreach ($post_vars['search'] as $k => $v) {
            if (isset($v['type']) && 'user' == $v['type'] && isset($v['field']) && isset($v['query'])) {
                $post_matches[$v['field']] = $v['query'];
            }
        }
    }
    // GET THE USER DATA
    $current_member = get_userdata($user_id);
    if (!$current_member) {
        return false;
    }
    // CHANGE DISPLAY BASED ON ACTION
    if ('edit' == $action) {
        $display = ' style="display: block;"';
    } else {
        $display = ' disabled="disabled"';
    }
    // RETRIEVE THE USER ROW
    if (false == $return) {
        // RETRIEVE THE AVATAR
        $user_avatar = apply_filters('bbconnect_reports_user_avatar', get_avatar($current_member->user_email, 32), $current_member);
        // RETRIEVE THE PROFILE FIELDS
        $user_fields = array($current_member->first_name . ' ' . $current_member->last_name);
        $user_fields = apply_filters('bbconnect_reports_user_fields', $user_fields, $current_member);
        // RETRIEVE THE ACTIONS
        $user_actions = array();
        if (is_admin()) {
            $user_actions['edit'] = '<a href="' . admin_url('/users.php?page=bbconnect_edit_user&user_id=' . $current_member->ID) . '">' . __('edit') . '</a>';
            $user_actions['edit in new tab'] = '<a href="' . admin_url('/users.php?page=bbconnect_edit_user&user_id=' . $current_member->ID) . '" target="_blank">' . __('edit in new tab') . '</a>';
            $user_actions['email'] = '<a href="mailto:' . $current_member->user_email . '">' . __('email') . '</a>';
        } else {
            $user_actions['view'] = '<a href="' . home_url('/bbconnect/?rel=viewprofile&amp;uid=' . $current_member->ID) . '" class="bbconnectpanels-toggle" title="profile-' . $current_member->ID . '">' . __('view', 'bbconnect') . '</a>';
        }
        $user_actions = apply_filters('bbconnect_reports_user_actions', $user_actions, $current_member);
        // USER SETUP
        $return_html = '<tr>';
        // if ( is_admin() ) {
        //     $return_html .= '<td class="gredit-column" width="3%">';
        //     $return_html .= '<input type="checkbox" name="gredit_users[]" value="'.$current_member->ID.'" class="gredit-user subgredit"'.$display.' />';
        //     $return_html .= '<input type="hidden" value="'.$current_member->user_email.'" disabled="disabled" />';
        //     $return_html .= '</td>';
        // }
        $return_html .= '<td style="text-align:left;" class="bbconnect-column-default" width="' . $tdw . '%">';
        $return_html .= '<div class="username column-username">';
        // USER AVATAR
        $return_html .= '<div class="bbconnect-reports-user-avatar">' . $user_avatar . '</div>';
        // USER INFO - OPEN
        $return_html .= '<div class="bbconnect-reports-user-info">';
        // USER FIELDS
        $return_html .= '<div class="bbconnect-reports-user-fields">';
        $return_html .= implode('<br />', $user_fields);
        $return_html .= '</span>';
        $return_html .= '<br />';
        // USER ACTIONS
        $return_html .= '<div class="bbconnect-reports-user-actions">';
        $return_html .= implode(' | ', $user_actions);
        $return_html .= '</span>';
        // USER INFO - CLOSE
        $return_html .= '</div>';
        // USER CLOSEOUT
        $return_html .= '</div>';
        $return_html .= '</td>';
        // RESOURCE CLEANUP
        unset($user_avatar);
        unset($user_fields);
        unset($user_actions);
    } else {
        $return_val = array();
        if (false != $return_def) {
            $return_val['ID'] = $current_member->ID;
            $return_val['email'] = $current_member->user_email;
            $return_val['first_name'] = $current_member->first_name;
            $return_val['last_name'] = $current_member->last_name;
            //$return_val['organization'] = $current_member->bbconnect_organization;
        }
    }
    if (!empty($table_body)) {
        $tempTotals = array();
        foreach ($table_body as $key => $value) {
            //declare an empty array to hold temporal total values
            $positionInarray++;
            // HORRIBLY HACKISH MANIPULATIONS FOR ADDRESSES...
            if (false != strstr($key, 'address')) {
                // THE KEY WITH THE NUMERIC IDENTIFIER
                $origkey = $key;
                // THE NUMERIC IDENTIFIER
                $thiskey = str_replace('_', '', substr($key, -2));
                // THE KEY WITH THE NUMERIC IDENTIFIER REMOVED
                if (is_numeric($thiskey)) {
                    $key = substr($key, 0, -2);
                }
            }
            // SET THE ARRAY KEY
            //if ( isset( $post_vars['search'] ) )
            //$thiskey = in_array_r($value, $post_vars['search'], true);
            if (false == $return) {
                $align = is_numeric($current_member->{$key}) ? 'right' : 'right';
                $return_html .= '<td width="' . $tdw . '%" style="text-align: ' . $align . ';">';
                //$return_html .= $key . ' ' . $value;
            }
            // TAXONOMIES
            if (is_array($value)) {
                // KEYS USED AS OBJECT VARS CANNOT HAVE DASHES
                $alt_key = str_replace('-', '', $key);
                if (!empty($current_member->{$key})) {
                    foreach ($current_member->{$key} as $subkey => $subvalue) {
                        if ('bbconnect' == substr($key, 0, 9)) {
                            $key = substr($key, 10);
                        }
                        $term_name = get_term_by('id', $subvalue, $key);
                        if (in_array_r($subvalue, $value)) {
                            $ret_arr[] = '<span class="highlight">' . $term_name->name . '</span>';
                        } else {
                            $ret_arr[] = $term_name->name;
                        }
                    }
                } else {
                    if (!empty($current_member->{$alt_key})) {
                        foreach ($current_member->{$alt_key} as $subkey => $subvalue) {
                            $term_name = get_term_by('id', $subvalue, substr($key, 10));
                            if (in_array_r($subvalue, $value)) {
                                $ret_arr[] = '<span class="highlight">' . $term_name->name . '</span>';
                            } else {
                                $ret_arr[] = $term_name->name;
                            }
                        }
                    } else {
                        $ret_arr = '';
                        //bbconnect_grex_input( array( 'u_key' => $current_member->ID, 'g_key' => $key, 'g_val' => $current_member->$key ) );
                    }
                }
                if (false == $return) {
                    if (!is_array($ret_arr)) {
                        $return_html .= '';
                        //$return_html .= bbconnect_grex_input( array( 'u_key' => $current_member->ID, 'g_key' => $key, 'g_val' => $current_member->$key ) );
                    } else {
                        $return_html .= implode(', ', $ret_arr);
                        //$return_html .= bbconnect_grex_input( array( 'u_key' => $current_member->ID, 'g_key' => $key, 'g_val' => strip_tags( implode( '|', $ret_arr ) ) ) );
                    }
                } else {
                    if (!is_array($ret_arr)) {
                        $return_val[$key] = $current_member->{$key};
                    } else {
                        $return_val[$key] = strip_tags(implode(',', $ret_arr));
                    }
                }
                unset($ret_arr);
                // META
            } else {
                if (is_array($current_member->{$key})) {
                    $marray_out = array();
                    foreach ($current_member->{$key} as $meta_key => $meta_value) {
                        if (is_array($meta_value)) {
                            if (is_assoc($meta_value)) {
                                if (!empty($meta_value['value'])) {
                                    $hlpre = '';
                                    $hlpos = '';
                                    $meta_type = '';
                                    if (isset($post_matches[$key]) && !empty($post_matches[$key])) {
                                        if (false !== strpos($meta_value['value'], $post_matches[$key])) {
                                            $hlpre = '<span class="highlight">';
                                            $hlpos = '</span>';
                                        }
                                    }
                                    if (isset($meta_value['type']) && !empty($meta_value['type'])) {
                                        $meta_type = $meta_value['type'] . ': ';
                                    }
                                    $marray_out[] = $hlpre . $meta_type . $meta_value['value'] . $hlpos;
                                }
                            }
                        } else {
                            if ($blog_prefix . 'capabilities' == $key) {
                                if (in_array($meta_key, $current_member->roles)) {
                                    $marray_out[] = $meta_key;
                                }
                            } elseif (1 == $meta_value || 'true' == $meta_value) {
                                $marray_out[] = 'yes';
                            } elseif (0 == $meta_value || 'false' == $meta_value) {
                                $marray_out[] = 'no';
                            } else {
                                $marray_out[] = $meta_value;
                            }
                        }
                    }
                    if (false == $return) {
                        $return_html .= implode('<br />', $marray_out);
                        //$return_html .= bbconnect_grex_input( array( 'u_key' => $current_member->ID, 'g_key' => $key, 'g_val' => implode( '|', $marray_out ) ) );
                    } else {
                        $return_val[$key] = implode('|', $marray_out);
                    }
                    unset($marray_out);
                } else {
                    // IF THIS IS AN ADDRESS FIELD, LOOP THROUGH AND PRESENT ALL RESULTS
                    if (false != strstr($key, 'address') && is_numeric($thiskey)) {
                        // PRE-PROCESS THE META KEY FOR THE GENERAL CHARACTERISTIC
                        // UPON-WHICH THE INDIVIDUAL ADDRESSES CAN BE APPENDED...
                        $pre_add_base = strrchr($key, '_');
                        $pro_add_base = 0 - strlen($pre_add_base);
                        $add_base = substr($key, 0, $pro_add_base);
                        // IF THERE ARE POST-OPS INVOLVED, LIMIT THE DISPLAY TO THE INTERESECT
                        if (isset($post_vars['search'][$thiskey]['post_ops']) && !empty($post_vars['search'][$thiskey]['post_ops'])) {
                            $post_op_arr = $post_vars['search'][$thiskey]['post_ops'];
                            $po_s = array();
                            // GET THE SUFFIX
                            foreach ($post_op_arr as $pkey => $pval) {
                                $cur_po_preval = 'bbconnect_' . $pval;
                                $origkey = substr($key, 0, -2) . substr($pval, 2);
                                $cur_po_val = $current_member->{$cur_po_preval};
                                $pre_po_s = strrchr($cur_po_val, '_');
                                $po_s[] = substr($pre_po_s, 1);
                            }
                            $po_s_array = array_unique($po_s);
                            if (count($po_s_array) == 1) {
                                $po_add = $po_s_array[0];
                            }
                        }
                        // SET THE VARS
                        $cur_address = array();
                        for ($i = 1; $i <= $bbconnect_address_count; $i++) {
                            $cur_ite = $add_base . '_' . $i;
                            if (isset($po_add)) {
                                if ($i != $po_add) {
                                    continue;
                                } else {
                                    $sub_ite = $add_base . '_' . $po_add;
                                    $cur_address[$cur_ite] = $current_member->{$cur_ite};
                                    $cur_grex_key = $cur_ite;
                                }
                            } else {
                                if (isset($post_vars['search'][$thiskey]['query']) && !empty($post_vars['search'][$thiskey]['query'])) {
                                    if (is_array($post_vars['search'][$thiskey]['query'])) {
                                        foreach ($post_vars['search'][$thiskey]['query'] as $val) {
                                            if (false !== stripos($current_member->{$cur_ite}, $val)) {
                                                $cur_address[$cur_ite] = $current_member->{$cur_ite};
                                                $cur_grex_key = $cur_ite;
                                                break;
                                            }
                                        }
                                    } else {
                                        if (false !== stripos($current_member->{$cur_ite}, $post_vars['search'][$thiskey]['query'])) {
                                            $cur_address[$cur_ite] = $current_member->{$cur_ite};
                                            $cur_grex_key = $cur_ite;
                                            break;
                                        }
                                    }
                                } else {
                                    if ($current_member->{$cur_ite}) {
                                        $cur_address[$cur_ite] = $current_member->{$cur_ite};
                                        $cur_grex_key[] = $cur_ite;
                                    } else {
                                        $cur_address[$cur_ite] = false;
                                        $cur_grex_key[] = $cur_ite;
                                    }
                                }
                            }
                        }
                        if (false == $return) {
                            // EXCEPTIONS FOR STATES
                            $cur_address_filtered = array();
                            if (false !== strpos($key, 'address_state')) {
                                array_filter($cur_address);
                                foreach ($cur_address as $ck => $cv) {
                                    $cur_address_filtered[$ck] = bbconnect_state_lookdown($cur_ite, $cv);
                                }
                                $cur_address = $cur_address_filtered;
                            } elseif (false !== strpos($key, 'address_country')) {
                                $bbconnect_helper_country = bbconnect_helper_country();
                                array_filter($cur_address);
                                foreach ($cur_address as $ck => $cv) {
                                    if (array_key_exists($cv, $bbconnect_helper_country)) {
                                        $cur_address_filtered[$ck] = $bbconnect_helper_country[$cv];
                                    } else {
                                        $cur_address_filtered[$ck] = $cv;
                                    }
                                }
                                $cur_address = $cur_address_filtered;
                            }
                            $return_html .= implode('<br />', array_filter($cur_address));
                            if (isset($cur_grex_key) && is_array($cur_grex_key)) {
                                $cur_grex_val = $cur_address;
                            } else {
                                $cur_grex_val = urlencode(serialize($cur_address));
                                $cur_grex_key = array();
                                //if ( !isset( $cur_grex_key ) ) $return_html .= ''; //<p>'.$value.'</p>
                            }
                            //$return_html .= bbconnect_grex_input( array( 'u_key' => $current_member->ID, 'g_key' => $cur_grex_key, 'g_val' => $cur_grex_val ) );
                        } else {
                            if (false === $post_vars) {
                                if (false !== strpos($origkey, 'address_state')) {
                                    $return_val[$origkey] = bbconnect_state_lookdown($origkey, $current_member->{$origkey});
                                } else {
                                    $return_val[$origkey] = $current_member->{$origkey};
                                }
                            } else {
                                foreach ($cur_address as $ka => $va) {
                                    // EXCEPTIONS FOR STATES
                                    if (false !== strpos($ka, 'address_state')) {
                                        $return_val[$ka] = bbconnect_state_lookdown($ka, $va);
                                    } else {
                                        $return_val[$ka] = $va;
                                    }
                                }
                                //$return_val[$origkey] = implode( '|', $cur_address );
                            }
                        }
                        unset($cur_address);
                        unset($cur_grex_key);
                    } else {
                        if (false == $return) {
                            $fieldInfo = get_option('bbconnect_' . $key);
                            $fieldInfos[$positionInarray] = $fieldInfo;
                            if ($key == 'bbconnect_bb_work_queue' && function_exists('bbconnect_workqueues_get_action_items')) {
                                $args = array('author' => $current_member->ID);
                                $notes = bbconnect_workqueues_get_action_items($args);
                                $type_list = array();
                                foreach ($notes as $note) {
                                    $note_types = wp_get_post_terms($note->ID, 'bb_note_type');
                                    foreach ($note_types as $note_type) {
                                        if ($note_type->parent > 0) {
                                            $type_list[$note_type->name] = $note_type->name;
                                            break;
                                        }
                                    }
                                }
                                $return_html .= implode(', ', $type_list);
                            } elseif ($key == 'bbconnect_category_id' || $key == 'bbconnect_segment_id') {
                                if (!empty($current_member->{$key})) {
                                    $return_html .= get_the_title($current_member->{$key});
                                }
                            } elseif ($fieldInfo['options']['field_type'] == 'date' && is_real_date($current_member->{$key})) {
                                $new_date_string = date('d F Y', strtotime($current_member->{$key}));
                                $return_html .= $new_date_string;
                            } elseif ($fieldInfo['options']['field_type'] == 'number' && $fieldInfo['options']['is_currency'] && $current_member->{$key} != '') {
                                $return_html .= '$' . number_format($current_member->{$key}, 2);
                            } else {
                                if (is_string($current_member->{$key})) {
                                    $return_html .= $current_member->{$key};
                                }
                            }
                            //check if value is numeric and find total
                            if ($fieldInfo['options']['field_type'] == 'number' && is_numeric($current_member->{$key}) && $current_member->{$key} > 0) {
                                $tempTotals[$positionInarray] = !empty($totalValues[$positionInarray]) ? $totalValues[$positionInarray] + $current_member->{$key} : $current_member->{$key};
                            } else {
                                $tempTotals[$positionInarray] = !empty($totalValues[$positionInarray]) ? $totalValues[$positionInarray] : 0;
                            }
                            //$positionInarray++;
                            //if reached the max position in array, then go back to zero
                            if ($positionInarray == count($table_body)) {
                                foreach ($tempTotals as $keytemp => $valuetemp) {
                                    if ($valuetemp) {
                                        $totalValues = $tempTotals;
                                        break;
                                    }
                                }
                                $positionInarray = 0;
                                $tempTotals = array();
                            }
                            //insert into totals array if tempvalues not empty
                            //$return_html .= bbconnect_grex_input( array( 'u_key' => $current_member->ID, 'g_key' => $key, 'g_val' => $current_member->$key ) );
                        } else {
                            $return_val[$key] = $current_member->{$key};
                        }
                    }
                }
            }
            if (false == $return) {
                $return_html .= '</td>';
            }
        }
    }
    //global $action_array;
    if (is_array($action_array)) {
        if (false == $return) {
            $return_html .= '<td width="' . $tdw * 2 . '%"><table width="100%">';
        }
        if (isset($action_array[$current_member->ID])) {
            foreach ($action_array[$current_member->ID] as $key => $value) {
                if (false == $return) {
                    $return_html .= '<tr>';
                    if (is_admin()) {
                        $return_html .= '<td class="gredit-column" width="3%"><input type="checkbox" name="gredit_actions[' . $current_member->ID . '][]" value="' . $value['ID'] . '" class="gredit-action subgredit"' . $display . ' /></td>';
                    }
                    $return_html .= '<td width="' . round($tdw * 2 - 7, 2) . '%" class="action-detail ' . $value['post_type'] . '">';
                    $inner_return_hmtl = '';
                    if (is_admin()) {
                        $return_html .= apply_filters('bbconnect_action_detail_html', $inner_return_hmtl, $value);
                    } else {
                        $return_html .= apply_filters('bbconnect_action_detail_html_public', $inner_return_hmtl, $value);
                    }
                    $return_html .= '</td></tr>';
                } else {
                    $return_val = apply_filters('bbconnect_action_detail_val', $return_val, $value);
                }
            }
        }
        if (false == $return) {
            $return_html .= '</table></td>';
        }
    }
    unset($current_member);
    if (false == $return) {
        $return_html .= '</tr>';
    }
    if (false == $return) {
        return $return_html;
    } else {
        return $return_val;
    }
}
Example #22
0
/*
-----------------------------------------------------
    SAMP līmeņu spraudņa konfigurācija
-----------------------------------------------------
*/
$db = new db($samp['db']['host'], $samp['db']['username'], $samp['db']['password'], $samp['db']['database']);
if ($db->connected === false) {
    die(baltsms::alert("Nevar izveidot savienojumu ar MySQL serveri. Pārbaudi norādītos pieejas datus!", "danger"));
}
$lang[$p] = $c['lang'][$p][$c['page']['lang_personal']];
if (isset($_POST['code'])) {
    $errors = array();
    if (empty($_POST['nickname'])) {
        $errors[] = $lang[$p]['error_empty_nickname'];
    } else {
        if (in_array_r($_POST['nickname'], $samp['rcon'][$_POST['server']]->getBasicPlayers())) {
            $errors[] = $lang[$p]['error_inserver'];
        }
    }
    if (empty($_POST['server'])) {
        $errors[] = $lang[$p]['error_empty_server'];
    }
    if (empty($_POST['price']) and !empty($_POST['server'])) {
        $errors[] = $lang[$p]['error_empty_price'];
    } else {
        if (!isset($c[$p]['prices'][$_POST['server']][$_POST['price']])) {
            $errors[] = $lang[$p]['error_price_not_listed'];
        }
    }
    if (empty($_POST['code'])) {
        $errors[] = $lang[$p]['error_empty_code'];
Example #23
0
 public function cms()
 {
     $questionnaire_id = $this->session->userdata('questionnaire_id');
     if (!$questionnaire_id) {
         show_404();
     }
     // Load the rules arrays
     $this->config->load('form_validation');
     $cms_rules = $this->config->item('cms_rules');
     $key_services_rules = $this->config->item('key_services_rules');
     $reference_websites_rules = $this->config->item('reference_websites_rules');
     $website_images_rules = $this->config->item('website_images_rules');
     $this->load->library('form_validation');
     $this->form_validation->set_error_delimiters('<div class="alert alert-danger" role="alert">', '</div>');
     // Create additional validation rules from the key services rules
     foreach ($key_services_rules as $key_services_rule) {
         $field_name_template = $key_services_rule['field'];
         $field_name = str_replace('%d', '', $field_name_template);
         // Skip the descriptive label which will not have a field name set
         if ($field_name_template) {
             $this->form_validation->set_rules($field_name, $key_services_rule['label'], $key_services_rule['rules']);
         }
     }
     // Create additional validation rules from the reference websites rules
     foreach ($reference_websites_rules as $reference_websites_rule) {
         $field_name_template = $reference_websites_rule['field'];
         $field_name = str_replace('%d', '', $field_name_template);
         // Skip the descriptive label which will not have a field name set
         if ($field_name_template) {
             $this->form_validation->set_rules($field_name, $reference_websites_rule['label'], $reference_websites_rule['rules']);
         }
     }
     // Create additional validation rules from the website images rules
     foreach ($website_images_rules as $website_images_rule) {
         $field_name_template = $website_images_rule['field'];
         $field_name = str_replace('%d', '', $field_name_template);
         // Skip the descriptive label which will not have a field name set
         if ($field_name_template) {
             $this->form_validation->set_rules($field_name, $website_images_rule['label'], $website_images_rule['rules']);
         }
     }
     // Main CMS Validation
     if ($this->form_validation->run('cms_rules') == TRUE) {
         $this->load->helper('array');
         $blank_elements = 0;
         $total_elements = 0;
         /* Process the answers for Key Services */
         $processed = $this->process_key_services($this->input->post('company_key_services'), $questionnaire_id);
         $blank_elements += $processed ? 0 : 1;
         $total_elements++;
         /* Process the answers for Website Function */
         $processed = $this->process_website_function($this->input->post('website_function'), $questionnaire_id);
         $blank_elements += $processed ? 0 : 1;
         $total_elements++;
         /* Process the answers for Reference Websites */
         $processed = $this->process_reference_websites($this->input->post('company_reference_websites'), $questionnaire_id);
         $blank_elements += $processed ? 0 : 1;
         $total_elements++;
         /* Process the answers for Website Images */
         $processed = $this->process_website_images($this->input->post('company_website_images'), $questionnaire_id);
         $blank_elements += $processed ? 0 : 1;
         $total_elements++;
         $form_data = $this->input->post();
         unset($form_data['website_function']);
         // Process CMS Answers
         foreach ($form_data as $form_element => $form_element_value) {
             // Append array brackets to names of arrays
             if (is_array($form_data[$form_element])) {
                 $form_element_name = "{$form_element}[]";
             } else {
                 $form_element_name = $form_element;
             }
             // Remove any form elements that are not CMS form elements
             if (!in_array_r($form_element_name, $cms_rules)) {
                 unset($form_data[$form_element]);
                 continue;
             }
             // Remove any 'other' elements if empty or where the parent element is not set
             if (substr($form_element, -6) == '_other') {
                 $parent_element = substr($form_element, 0, -6);
                 if (empty($form_element_value) || array_key_exists($parent_element, $form_data) === false) {
                     unset($form_data[$form_element]);
                     continue;
                 }
             }
             // Remove the 'IE Version' element if empty or where the parent element is not set
             if ($form_element == 'your_browser_ie') {
                 if (empty($form_element_value) || array_key_exists('your_browser', $form_data) === false) {
                     unset($form_data[$form_element]);
                     continue;
                 }
             }
             // Set any empty values to NULL
             if (empty($form_element_value)) {
                 $form_data[$form_element] = null;
             }
         }
         // Save CMS Answers to database
         $progress = $this->cms_answers_model->save_cms_answers($questionnaire_id, $form_data, $blank_elements, $total_elements);
         $this->load->model('questionnaires_model');
         $this->questionnaires_model->set_questionnaire_progress($questionnaire_id, $progress);
         // Update client last activity
         $client_id = $this->session->userdata('client_id');
         $this->load->model('clients_model');
         $this->clients_model->update_client_last_activity($client_id);
         // If the progress is 100%, e-mail the client and the issuer that the questionnaire is complete
         if ($progress == 100) {
             $this->send_completion_emails($questionnaire_id);
         }
         // Set success message and return to admin home
         $this->session->set_flashdata('message_severity', 'success');
         $this->session->set_flashdata('message_content', "<strong>Success!</strong> Answers successfully saved.");
         redirect('questions');
         exit;
     }
     $data = array();
     // Load form constants
     $data['website_look_options'] = unserialize(WEBSITE_LOOK_OPTIONS);
     $data['website_elements'] = unserialize(WEBSITE_ELEMENTS);
     $data['website_social_media'] = unserialize(WEBSITE_SOCIAL_MEDIA);
     $data['os_platform'] = unserialize(OS_PLATFORM);
     $data['mobile_os_platform'] = unserialize(MOBILE_OS_PLATFORM);
     $data['web_browsers'] = unserialize(WEB_BROWSERS);
     // Get the form labels from the rules array
     $data['cms_rules'] = $cms_rules;
     $data['key_services_rules'] = $key_services_rules;
     $data['reference_websites_rules'] = $reference_websites_rules;
     $data['website_images_rules'] = $website_images_rules;
     // Load any previous answers
     $data['cms'] = $this->cms_answers_model->load_cms_answers($questionnaire_id);
     $data['key_services'] = $this->key_services_model->load_key_services($questionnaire_id);
     $data['reference_websites'] = $this->reference_websites_model->load_reference_websites($questionnaire_id);
     $data['website_images'] = $this->website_images_model->load_website_images($questionnaire_id);
     // Set body attributes
     $this->layout->set_body_attributes('class="cms-questions" data-spy="scroll" data-target="#side-nav"');
     // Font Awesome CDN
     $this->layout->add_stylesheet('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
     // Load jQuery UI resources
     $this->layout->add_script('/assets/js/validator/validator.min.js');
     // Load JavaScript Bootstrap Validator resources
     $this->layout->add_stylesheet('/assets/css/jquery-ui/jquery-ui.min.css');
     $this->layout->add_script('/assets/js/jquery-ui/jquery-ui.min.js');
     // Bigstock API
     $this->layout->add_stylesheet('/assets/css/bigstock-api/bigstock-api.css');
     $this->layout->add_script('/assets/js/bigstock-api/bigstock-api.js');
     // General CMS Questionnaire style and script
     $this->layout->add_stylesheet('/assets/css/cms-questions.css');
     $this->layout->add_script('/assets/js/cms-questions.js');
     // Load the view
     $this->layout->set_page_title('Website Design Questionnaire');
     $this->layout->view('questions/cms', $data);
 }
function bbconnect_ffc($args = null)
{
    // SET THE DEFAULTS TO BE OVERRIDDEN AS DESIRED
    $defaults = array('context' => false, 'c_array' => false, 'fields' => array(), 'options' => false, 'columns' => 1, 'title' => __('Add fields', 'bbconnect'));
    // PARSE THE INCOMING ARGS
    $args = wp_parse_args($args, $defaults);
    // EXTRACT THE VARIABLES
    extract($args, EXTR_SKIP);
    if (false === $context) {
        return false;
    }
    if (!is_array($c_array)) {
        $c_array = get_option($context);
    }
    // SET ADDITIONAL PRESETS
    $delete = __('Delete', 'bbconnect');
    $undo = __('Undo', 'bbconnect');
    ?>

	<div id="<?php 
    echo $context;
    ?>
_select" class="options-field options-selector">
		<?php 
    if (false != $title) {
        echo '<h3>' . $title . '</h3>';
    }
    ?>
		<select id="<?php 
    echo $context;
    ?>
_select_field">
			<option value=""><?php 
    _e('Make A Selection', 'bbconnect');
    ?>
</option>
			<?php 
    $fields_display = array();
    foreach ($fields as $k => $v) {
        $disabled = '';
        if (is_array($v)) {
            echo '<optgroup label="' . $k . '">';
            foreach ($v as $gk => $gv) {
                if (in_array_r($k, $c_array)) {
                    $disabled = ' disabled="disabled"';
                }
                echo '<option value="' . $gk . '"' . $disabled . '>' . $gv . '</option>';
                $fields_display[$gk] = $gv;
            }
        } else {
            if (in_array_r($k, $c_array)) {
                $disabled = ' disabled="disabled"';
            }
            echo '<option value="' . $k . '"' . $disabled . '>' . $v . '</option>';
            $fields_display[$k] = $v;
        }
    }
    ?>
		</select>
		<a id="<?php 
    echo $context;
    ?>
_add_field" class="button add-ffc-field"><?php 
    _e('+ Add', 'bbconnect');
    ?>
</a>
	</div>
			
	<div id="<?php 
    echo $context;
    ?>
-sort" class="options-field">
		<div class="inside t-panel" style="display: block;">
			<input type="hidden" name="_bbc_option[<?php 
    echo $context;
    ?>
][e]" value="1" />
			<div class="column-holder<?php 
    if ((int) $columns == 1) {
        echo ' full';
    }
    ?>
">
				<ul data-col="column_1" id="<?php 
    echo $context;
    ?>
-one" title="<?php 
    echo $context;
    ?>
" class="<?php 
    echo $context;
    ?>
-sortable connected-<?php 
    echo $context;
    ?>
-sortable primary-list column">
				<?php 
    // LOOP THROUGH ALL OF THE FIELDS
    // RETRIEVE THEIR VALUES FOR DISPLAY
    // IF IT'S A GROUP, MAKE A SUBLIST
    // WE'LL USE DRAG & DROP FOR SORTING
    if (isset($c_array['column_1']) && !empty($c_array['column_1'])) {
        $column_1 = $c_array['column_1'];
        foreach ($column_1 as $k => $v) {
            if (false !== strpos($v, 'error')) {
                $alt_error = ' error-wash';
            } else {
                $alt_error = '';
            }
            ?>
					<li>
						<div class="t-wrapper<?php 
            echo $alt_error;
            ?>
">
							<span>
								<span class="handle"></span>
								<span class="t-trigger" title="option-<?php 
            echo $context . $v;
            ?>
">
									<?php 
            echo $fields_display[$v];
            ?>
								</span>
							</span>
							<span class="right">
								<a class="delete" title="<?php 
            echo $delete;
            ?>
" rel="<?php 
            echo $v;
            ?>
">&nbsp;</a>
								<a class="undo" title="<?php 
            echo $undo;
            ?>
">&nbsp;</a>
							</span>
							<div id="option-<?php 
            echo $context . $v;
            ?>
" class="inside t-panel" style="display: none;">
								<input class="column-input" type="hidden" id="<?php 
            echo $k;
            ?>
" name="_bbc_option[<?php 
            echo $context;
            ?>
][column_1][]" value="<?php 
            echo $v;
            ?>
" />
								<div id="option-<?php 
            echo $context . $v;
            ?>
-field">
									<?php 
            do_action('bbconnect_ffc_option', $context, $v, $c_array);
            ?>
								</div>
							</div>
						</div>
					</li>
					<?php 
        }
    }
    ?>
				</ul>
			</div>
			<?php 
    if ((int) $columns > 1) {
        ?>
			<div class="column-holder">
				<ul data-col="column_2" id="<?php 
        echo $context;
        ?>
-two" title="<?php 
        echo $context;
        ?>
" class="<?php 
        echo $context;
        ?>
-sortable connected-<?php 
        echo $context;
        ?>
-sortable primary-list column">
				<?php 
        // LOOP THROUGH ALL OF THE FIELDS
        // RETRIEVE THEIR VALUES FOR DISPLAY
        // IF IT'S A GROUP, MAKE A SUBLIST
        // WE'LL USE DRAG & DROP FOR SORTING
        if (isset($c_array['column_2']) && !empty($c_array['column_2'])) {
            $column_2 = $c_array['column_2'];
            foreach ($column_2 as $k => $v) {
                if (false !== strpos($v, 'error')) {
                    $alt_error = ' error-wash';
                } else {
                    $alt_error = '';
                }
                ?>
					<li>
						<div class="t-wrapper<?php 
                echo $alt_error;
                ?>
">
							<span>
								<span class="handle"></span>
								<span class="t-trigger" title="option-<?php 
                echo $context . $v;
                ?>
">
									<?php 
                echo $fields_display[$v];
                ?>
								</span>
							</span>
							<span class="right">
								<a class="delete" title="<?php 
                echo $delete;
                ?>
" rel="<?php 
                echo $v;
                ?>
">&nbsp;</a>
								<a class="undo" title="<?php 
                echo $undo;
                ?>
">&nbsp;</a>
							</span>
							<div id="option-<?php 
                echo $context . $v;
                ?>
" class="inside t-panel" style="display: none;">
								<input class="column-input" type="hidden" id="<?php 
                echo $k;
                ?>
" name="_bbc_option[<?php 
                echo $context;
                ?>
][column_2][]" value="<?php 
                echo $v;
                ?>
" />
								<div id="option-<?php 
                echo $context . $v;
                ?>
-field">
									<?php 
                do_action('bbconnect_ffc_option', $context, $v, $c_array);
                ?>
								</div>
							</div>
						</div>
					</li>
					<?php 
            }
        }
        ?>
				</ul>
			</div>
			<?php 
    }
    ?>
		</div>
	</div>
	<script type="text/javascript">
		jQuery.noConflict();
		jQuery(document).ready(function() {
			jQuery('#<?php 
    echo $context;
    ?>
-sort').on('click', '.delete', function(){
				var fid = jQuery(this).attr('rel');
				jQuery('#<?php 
    echo $context;
    ?>
_select_field option[value='+fid+']').removeAttr('disabled'); // NOT DONE!
				jQuery(this).closest('li').remove();
			});
			// SORTING FUNCTION FOR LISTS
			jQuery(function() {
				jQuery('.<?php 
    echo $context;
    ?>
-sortable').sortable({
					connectWith: '.connected-<?php 
    echo $context;
    ?>
-sortable', 
					handle: '.handle', 
					appendTo: document.body, 
					placeholder: 'pp-ui-highlight', 
					forcePlaceholderSize: true, 
					forceHelperSize: true,  
					update: function(event, ui) { 
						var cid = jQuery(this).data('col');
						var oid = jQuery(this).attr('title');
						var fid = ui.item.attr('id');
						ui.item.find('.column-input').attr('name','_bbc_option['+oid+']['+cid+'][]');
					}
				}).disableSelection();
			});
			jQuery('#<?php 
    echo $context;
    ?>
_add_field').click(function(){
				//var cref = jQuery(this).previous('select');
				var fid = jQuery('#<?php 
    echo $context;
    ?>
_select_field').closest('select').val();
				
				if ( fid.length == 0 ) {
					return false;
				}
				
				var fna = jQuery('#<?php 
    echo $context;
    ?>
_select_field option:selected').text();
				var selected = jQuery('#<?php 
    echo $context;
    ?>
_select_field option:selected');
				jQuery('#<?php 
    echo $context;
    ?>
_select_field option:selected').attr('disabled','disabled');
				jQuery('#<?php 
    echo $context;
    ?>
_select_field').closest('select').val('');
				//alert('yeah');
				jQuery('<li><div class="t-wrapper"><span><span class="handle"></span><span class="t-trigger open" title="option-<?php 
    echo $context;
    ?>
'+fid+'">'+fna+'</span></span><span class="right"><a class="delete" title="<?php 
    echo $delete;
    ?>
" rel="'+fid+'">&nbsp;</a><a class="undo" title="<?php 
    echo $undo;
    ?>
">&nbsp;</a></span><div id="option-<?php 
    echo $context;
    ?>
'+fid+'" class="inside t-panel" style="display: none;"><input class="column-input" type="hidden" id="'+fid+'" name="_bbc_option[<?php 
    echo $context;
    ?>
][column_1][]" value="'+fid+'" /><div id="option-<?php 
    echo $context;
    ?>
'+fid+'-field"></div></div></div></li>').appendTo('#<?php 
    echo $context;
    ?>
-one');
				
				jQuery('#option-<?php 
    echo $context;
    ?>
'+fid).each(function(){
	
					// SHOW THE OPTION PANEL
					jQuery(this).show();
					
					// PLAY THE LOADER
					jQuery('#option-<?php 
    echo $context;
    ?>
'+fid+'-field').empty().html('<div style="padding:10px 0;"><img src="'+bbconnectAdminAjax.ajaxload+'" /></div>');
						 
					jQuery.post( 
						bbconnectAdminAjax.ajaxurl, 
						{ action : 'bbconnect_ffc_new_option', v : fid, context : '<?php 
    echo $context;
    ?>
', bbconnect_admin_nonce : bbconnectAdminAjax.bbconnect_admin_nonce },
					    function( response ) {
					        // DISPLAY THE RESPONSE
					        jQuery('#option-<?php 
    echo $context;
    ?>
'+fid+'-field').empty().html(response);
					        //jQuery('.chzn-select').chosen();
					    }
					);
				});
				
				
				//attr('name','_bbc_option[<?php 
    echo $context;
    ?>
][ffc_opts]['+fid+']');
				//jQuery('.temp').removeClass('temp'); // formerly had list with class of temp
				return false;
			});
		});
	</script>
<?php 
}
 private function processSolrResult($result, &$suggestions, $score_override, $class, $relation_type, $maxRows)
 {
     $intScore = 0;
     $maxScore = floatval($result['response']['maxScore']);
     foreach ($result['response']['docs'] as $doc) {
         if (!in_array_r($doc, $suggestions)) {
             $doc['score'] = $doc['score'] / $maxScore * (1 - $intScore / $maxRows * $score_override);
             $intScore++;
             $doc['relation_type'] = $relation_type;
             $doc['class'] = $class;
             $doc['RDAUrl'] = portal_url($doc['slug'] . '/' . $doc['id']);
             $suggestions[] = $doc;
         }
     }
 }
function in_array_r($needle, $haystack, $strict = true)
{
    $override = apply_filters('pre_in_array_r', false, $needle, $haystack, $strict);
    if ($override !== false) {
        return $override;
    }
    foreach ($haystack as $item) {
        if (($strict ? $item === $needle : $item == $needle) || is_array($item) && in_array_r($needle, $item, $strict)) {
            return true;
        }
    }
    return false;
}
	<li class="ejo-feature ejo-feature-<?php 
echo $feature['name'];
?>
 <?php 
echo $featureActiveClass;
?>
">
		<div class="ejo-feature-header">
			<input type="checkbox" name="<?php 
echo $feature_form_namebase;
?>
[name]" value="<?php 
echo $feature['name'];
?>
" <?php 
checked(in_array_r($feature['name'], $active_features));
?>
 >
			<?php 
/*<input type="checkbox" name="<?php echo $feature_form_namebase; ?>[active]" value="<?php echo $feature['active']; ?>" <?php checked($feature['active']); ?> > */
?>
			<div class="ejo-feature-name"><?php 
echo $feature['name'];
?>
</div>
		</div>
		<div class="ejo-feature-content">
		
<?php 
switch ($feature['name']) {
    case 'image':
Example #28
0
<div class="container">
    <h1>Рекомендуемые товары</h1>
    <form action="/wp-admin/admin.php?page=recommend" method="post">
    <?php 
$myposts = get_posts(array('post_type' => 'product', 'pots_per_page' => -1));
foreach ($myposts as $mypost) {
    if (in_array_r($mypost->ID, $ids)) {
        echo '<p><input type="checkbox" name="recommended[]" checked value="' . $mypost->ID . '">' . $mypost->post_title . '</p>';
    } else {
        echo '<p><input type="checkbox" name="recommended[]" value="' . $mypost->ID . '">' . $mypost->post_title . ' </p>';
    }
}
?>
    <input type="submit" value="Сохранить">
    </form>
</div>
/**
 * Swaps the originating author for the targeted user when inserting actions into the db and updates the log.
 *
 * @since 1.0.2
 *
 * @param arr $data Required. An array containing the post data.
 * @param arr $postarr Required. An array containing the submitted data on $_POST.
 *
 * @return arr an array of default actions.
 */
function bbconnect_log_user_action_meta($data, $postarr)
{
    // FIRST, MAKE SURE THAT A SUBMISSION HAS OCCURRED
    if (isset($postarr['_bbc_post']['_bbc_author'])) {
        $bbconnect_user_actions = bbconnect_get_user_actions();
        // PROCESS THE REGISTERED ACTIONS TO RETRIEVE THE WP POST TYPE
        $bbconnect_user_action_types = array();
        foreach ($bbconnect_user_actions as $key => $value) {
            $bbconnect_user_action_types[] = $value['type'];
        }
        // CHECK TO SEE IF THIS IS A REGISTERED ACTION
        if (in_array_r($data['post_type'], $bbconnect_user_action_types)) {
            // IF THE POSTED _bbc_author CONVERSION !MATCHES THE POST_AUTHOR UPDATE IT
            if ($data['post_author'] != $postarr['_bbc_post']['_bbc_author']) {
                $data['post_author'] = $postarr['_bbc_post']['_bbc_author'];
            }
            // UPDATE THE LOG
            if (isset($postarr['_bbc_post']['_bbc_agent'])) {
                $cur_user_arr = array('id' => $postarr['_bbc_post']['_bbc_agent'], 'date' => time());
                $cur_log = get_post_meta($postarr['ID'], '_bbc_log', true);
                if (empty($cur_log)) {
                    $cur_log = array();
                }
                array_push($cur_log, $cur_user_arr);
                update_post_meta($postarr['ID'], '_bbc_log', $cur_log);
            }
        }
    }
    return $data;
}
Example #30
-1
 public function add()
 {
     $this->check_authority();
     if (isset($_POST['wid_id']) and isset($_POST['parent'])) {
         $wid_id = $_POST['wid_id'];
         $area = $_POST['parent'];
         $this->load->model('mwidget');
         $this->load->model('msettings');
         $gen_settings = $this->msettings->get_set_gen();
         $wid_areas = get_layout_wid_areas($gen_settings[0]->theme);
         $area_wids = get_widgets($area);
         $wid_list = $this->mwidget->get_widget_list();
         if (null != $this->mwidget->get_widget_list($wid_id) and in_array_r($area, $wid_areas)) {
             $wid_info = $this->mwidget->get_widget_list($wid_id);
             $title = $wid_info[0]->desc;
             $xtbl = $wid_info[0]->child_tbl;
             $pos = count($area_wids) + 1;
             $add = $this->mwidget->add_widget($wid_id, $title, $area, $pos, $xtbl);
             if (true == $add) {
                 $data['wid_list'] = $this->mwidget->get_widget_list();
                 $data['wid_area_wids'] = get_widgets($area);
                 $this->load->view($this->wid_dir . 'widgets_list', $data);
             }
         }
     }
 }