PHP array_push Examples

PHP array_push - 30 examples found. These are the top rated real world PHP examples of array_push extracted from open source projects. You can rate examples to help us improve the quality of examples.
/**
 * Expand an IPv6 Address
 *
 * This will take an IPv6 address written in short form and expand it to include all zeros. 
 *
 * @param  string  $addr A valid IPv6 address
 * @return string  The expanded notation IPv6 address
 */
function inet6_expand($addr)
{
    /* Check if there are segments missing, insert if necessary */
    if (strpos($addr, '::') !== false) {
        $part = explode('::', $addr);
        $part[0] = explode(':', $part[0]);
        $part[1] = explode(':', $part[1]);
        $missing = array();
        for ($i = 0; $i < 8 - (count($part[0]) + count($part[1])); $i++) {
            array_push($missing, '0000');
        }
        $missing = array_merge($part[0], $missing);
        $part = array_merge($missing, $part[1]);
    } else {
        $part = explode(":", $addr);
    }
    // if .. else
    /* Pad each segment until it has 4 digits */
    foreach ($part as &$p) {
        while (strlen($p) < 4) {
            $p = '0' . $p;
        }
    }
    // foreach
    unset($p);
    /* Join segments */
    $result = implode(':', $part);
    /* Quick check to make sure the length is as expected */
    if (strlen($result) == 39) {
        return $result;
    } else {
        return false;
    }
    // if .. else
}
 /**
  * Create new form item for depending on specified file type.
  *
  * File extension determine on specified value of `$file_type`.
  * For twig-files generate:
  *  form.field(model, 'attribute').name(value, options)
  * Value and options are automatically converted into a Json-like string.
  * For php-files generate:
  *  form->field($model, 'attribute')->name(value, options)
  * Value and options are automatically converted into an array-like string.
  *
  * @param string $attribute form item attribute
  * @param array $value form item default value|values of attribute
  * @param int $file_tpe extension of the current file
  * @param null|string $name form item input type (if any)
  * @param array $options form item additional options
  * @return string new form item for specified file extension
  */
 public static function generateField($attribute, $value = [], $file_tpe = Generator::TEMPLATE_TYPE_PHP, $name = null, $options = [])
 {
     switch ($file_tpe) {
         case Generator::TEMPLATE_TYPE_TWIG:
             $delimiter = '.';
             $field_string = "form{$delimiter}field(model, '{$attribute}')";
             //$options_container = '{' . preg_replace('|\=>|', ':', $options) . '}';
             $string_formatter = new Json();
             $method = 'encode';
             break;
         default:
             $delimiter = '->';
             $field_string = "\$form{$delimiter}field(\$model, '{$attribute}')";
             //$options_container = "[{$options}]";
             $string_formatter = new VarDumper();
             $method = 'export';
     }
     if ($name) {
         $field_string = $field_string . $delimiter . "{$name}";
         $options_container = [];
         if ($value) {
             array_push($options_container, $string_formatter::$method($value));
         }
         if ($options) {
             array_push($options_container, $string_formatter::$method($options));
         }
         if ($options_container) {
             $options_container = preg_replace('|"|', "'", implode(', ', $options_container));
             $field_string = "{$field_string}({$options_container})";
         } else {
             $field_string = "{$field_string}()";
         }
     }
     return $field_string;
 }
Example #3
0
/**
 * Add a link to the backups page to the plugin action links.
 *
 * @param array $links
 * @param string $file
 *
 * @return array $links
 */
function plugin_action_link($links, $file)
{
    if (false !== strpos($file, HMBKP_PLUGIN_SLUG)) {
        array_push($links, '<a href="' . esc_url(HMBKP_ADMIN_URL) . '">' . __('Backups', 'backupwordpress') . '</a>');
    }
    return $links;
}
Example #4
0
 function getArticleData()
 {
     // create the array
     $ids = array();
     $idsK2 = array();
     // generate the content of the array
     if ($slide->type == 'article') {
         if ($slide->art_id) {
             array_push($ids, $slide->art_id);
         } else {
             array_push($ids, 0);
         }
     }
     if ($slide->type == 'k2') {
         if ($slide->artK2_id) {
             array_push($idsK2, $slide->artK2_id);
         } else {
             array_push($idsK2, 0);
         }
     }
     // get the data
     if (count($idsK2) > 0) {
         $this->articlesK2 = GKIS_gk_university_Model::getDataK2($idsK2);
     }
     if (count($ids) > 0) {
         $this->articles = GKIS_gk_university_Model::getData($ids);
     }
 }
Example #5
0
 /**
  * Convert SimpleXML object to stdClass object.
  *
  * @return object
  */
 public function toObject()
 {
     $attributes = $this->attributes();
     $children = $this->children();
     $textValue = trim((string) $this);
     if (count($attributes) === 0 and count($children) === 0) {
         return $textValue;
     } else {
         $object = new \StdClass();
         foreach ($attributes as $key => $value) {
             $object->{$key} = (string) $value;
         }
         if (!empty($textValue)) {
             $object->_ = $textValue;
         }
         foreach ($children as $value) {
             $name = $value->getName();
             if (isset($object->{$name})) {
                 if (is_array($object->{$name})) {
                     array_push($object->{$name}, $value->toObject());
                 } else {
                     $object->{$name} = [$object->{$name}, $value->toObject()];
                 }
             } else {
                 $object->{$name} = $value->toObject();
             }
         }
         return $object;
     }
 }
Example #6
0
function getLocation($str)
{
    $array_size = intval(substr($str, 0, 1));
    // 拆成的行数
    $code = substr($str, 1);
    // 加密后的串
    $len = strlen($code);
    $subline_size = $len % $array_size;
    // 满字符的行数
    $result = array();
    $deurl = "";
    for ($i = 0; $i < $array_size; $i += 1) {
        if ($i < $subline_size) {
            array_push($result, substr($code, 0, ceil($len / $array_size)));
            $code = substr($code, ceil($len / $array_size));
        } else {
            array_push($result, substr($code, 0, ceil($len / $array_size) - 1));
            $code = substr($code, ceil($len / $array_size) - 1);
        }
    }
    for ($i = 0; $i < ceil($len / $array_size); $i += 1) {
        for ($j = 0; $j < count($result); $j += 1) {
            $deurl = $deurl . "" . substr($result[$j], $i, 1);
        }
    }
    return str_replace("^", "0", urldecode($deurl));
}
 function execute($requests)
 {
     if (!OPENPNE_USE_ALBUM) {
         handle_kengen_error();
     }
     $v = array();
     $target_c_album_image_ids = $requests['target_c_album_image_ids'];
     // アルバム写真が選択されていない場合はエラー
     if (!$target_c_album_image_ids) {
         admin_client_redirect('edit_album_image_list', "アルバム写真が選択されていません");
     }
     $id_ary = split(":", $target_c_album_image_ids);
     $album_image_list = array();
     foreach ($id_ary as $id) {
         $album_image = db_album_image_get_c_album_image4id($id);
         if (!$album_image) {
             admin_client_redirect('edit_album_image_list', '指定されたアルバムは存在しません');
         }
         $member = db_member_c_member4c_member_id($album_image['c_member_id']);
         $album_image['c_member'] = $member;
         array_push($album_image_list, $album_image);
     }
     $this->set('album_image_list', $album_image_list);
     $this->set('target_c_album_image_ids', $target_c_album_image_ids);
     $this->set($v);
     return 'success';
 }
Example #8
0
 /**
  * @depends testEmpty
  */
 public function testPush(array $arr)
 {
     array_push($arr, 'foo');
     $this->assertEquals('foo', $arr[count($arr) - 1]);
     $this->assertFalse(empty($arr));
     return $arr;
 }
Example #9
0
 public function create()
 {
     $name = $_POST['name'];
     $code = $_POST['code'];
     $disc = $_POST['disc'];
     $maxdisc = $_POST['maxdisc'];
     $beginDate = $_POST['beginDate'];
     $endDate = $_POST['endDate'];
     try {
         $voucher = ['name' => $name, 'code' => $code, 'discount' => $disc, 'maxDiscount' => $maxdisc, 'beginDate' => $beginDate, 'endDate' => $endDate];
         if ($voc = Option::where('meta_key', 'voucher')->first()) {
             $unserialize = unserialize($voc->meta_value);
             $sum_array = array_push($unserialize, $voucher);
             $serialize = serialize($unserialize);
             $total = Option::where('meta_key', 'voucher')->update(['meta_value' => $serialize]);
             return redirect('master/setting/coupon')->with('success', 'Code Voucher berhasil ditambahkan');
         } else {
             $voc = new Option();
             $voc->meta_key = "voucher";
             $voc->meta_value = serialize(array($voucher));
             $voc->save();
             return redirect('master/setting/coupon')->with('success', 'Code Voucher berhasil ditambahkan');
         }
     } catch (Exception $e) {
         return 'error';
     }
 }
Example #10
0
 protected function getOptions()
 {
     // Initialize variables.
     $session = JFactory::getSession();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $db = JFactory::getDBO();
     // generating query
     $db->setQuery("SELECT c.title AS name, c.id AS id, c.parent_id AS parent FROM #__categories AS c WHERE published = 1 AND extension = 'com_solidres' ORDER BY c.title, c.parent_id ASC");
     // getting results
     $results = $db->loadObjectList();
     if (count($results)) {
         // iterating
         $temp_options = array();
         foreach ($results as $item) {
             array_push($temp_options, array($item->id, $item->name, $item->parent));
         }
         foreach ($temp_options as $option) {
             if ($option[2] == 1) {
                 $this->options[] = JHtml::_('select.option', $option[0], $option[1]);
                 $this->recursive_options($temp_options, 1, $option[0]);
             }
         }
     }
 }
Example #11
0
function getName($number, $pwd)
{
    $TRY_TIMES = 10;
    S(array('prefix' => 'verify', 'expire' => 3 * $TRY_TIMES));
    $verify_array = S('verify_array');
    if (!$verify_array) {
        $verify_array = array();
    }
    if (!in_array($number, $verify_array)) {
        array_push($verify_array, $number);
    } else {
        return false;
    }
    S('verify_' . $number, $pwd);
    S('verify_array', $verify_array);
    $i = 0;
    while ($i++ < $TRY_TIMES && S('verify_' . $number) == $pwd) {
        sleep(1);
    }
    $name = S('verify_' . $number);
    S(array('prefix' => ''));
    if ($i < $TRY_TIMES && $name != '0') {
        return $name;
    } else {
        return false;
    }
}
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     $sticky = get_option('sticky_posts');
     $number = empty($instance['number']) ? 1 : (int) $instance['number'];
     $cat = empty($instance['category']) ? 0 : (int) $instance['category'];
     if (is_single()) {
         array_push($sticky, get_the_ID());
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     } else {
         echo '<br />';
     }
     $featuredPosts = new WP_Query(array('posts_per_page' => $number, 'cat' => $cat, 'post__not_in' => $sticky, 'no_found_rows' => true));
     while ($featuredPosts->have_posts()) {
         $featuredPosts->the_post();
         global $mb_content_area, $more;
         $mb_content_area = 'sidebar';
         get_template_part('content', get_post_format());
     }
     wp_reset_postdata();
     echo $after_widget;
 }
Example #13
0
 /**
  *    Adds a successfully fetched page to the history.
  *    @param string $method    GET or POST.
  *    @param SimpleUrl $url    URL of fetch.
  *    @param array $parameters Any post data with the fetch.
  *    @access public
  */
 function recordEntry($method, $url, $parameters) {
     $this->_dropFuture();
     array_push(
             $this->_sequence,
             array('method' => $method, 'url' => $url, 'parameters' => $parameters));
     $this->_position++;
 }
Example #14
0
 /**
  * Parse the incoming request in a RESTful way
  *
  * @param \PASL\Web\Service\Request The request object
  */
 public function parseRequest($oRequest)
 {
     $oRequestData = array();
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             $oRequestHash = $_REQUEST;
             break;
         case 'POST':
             $oRequestHash = $_REQUEST;
             break;
         case 'PUT':
             parse_str(file_get_contents("php://input"), $oRequestHash);
             break;
     }
     foreach ($oRequestHash as $val) {
         if (trim($val) != "" && !is_null($val)) {
             array_push($oRequest->oRequestHash, $val);
         }
     }
     $oRequest->requestPayload = $oRequestData;
     $oRequest->method = $oRequest->oRequestHash[2];
     // Grab the method arguments
     $methodArgs = $oRequest->oRequestHash;
     array_shift($methodArgs);
     array_shift($methodArgs);
     array_shift($methodArgs);
     $oRequest->methodArgs = $methodArgs;
     return $oRequest;
 }
Example #15
0
 public function __construct()
 {
     global $cookie;
     $lang = strtoupper(Language::getIsoById($cookie->id_lang));
     $this->className = 'Configuration';
     $this->table = 'configuration';
     /* Collect all font files and build array for combo box */
     $fontFiles = scandir(_PS_FPDF_PATH_ . 'font');
     $fontList = array();
     $arr = array();
     foreach ($fontFiles as $file) {
         if (substr($file, -4) == '.php' and $file != 'index.php') {
             $arr['mode'] = substr($file, 0, -4);
             $arr['name'] = substr($file, 0, -4);
             array_push($fontList, $arr);
         }
     }
     /* Collect all encoding map files and build array for combo box */
     $encodingFiles = scandir(_PS_FPDF_PATH_ . 'font/makefont');
     $encodingList = array();
     $arr = array();
     foreach ($encodingFiles as $file) {
         if (substr($file, -4) == '.map') {
             $arr['mode'] = substr($file, 0, -4);
             $arr['name'] = substr($file, 0, -4);
             array_push($encodingList, $arr);
         }
     }
     $this->_fieldsPDF = array('PS_PDF_ENCODING_' . $lang => array('title' => $this->l('Encoding:'), 'desc' => $this->l('Encoding for PDF invoice'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $encodingList), 'PS_PDF_FONT_' . $lang => array('title' => $this->l('Font:'), 'desc' => $this->l('Font for PDF invoice'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $fontList));
     parent::__construct();
 }
Example #16
0
/**
 * Returns an array of found directories
 *
 * This function checks every found directory if they match either $uid or $gid, if they do
 * the found directory is valid. It uses recursive function calls to find subdirectories. Due
 * to the recursive behauviour this function may consume much memory.
 *
 * @param  string   path       The path to start searching in
 * @param  integer  uid        The uid which must match the found directories
 * @param  integer  gid        The gid which must match the found direcotries
 * @param  array    _fileList  recursive transport array !for internal use only!
 * @return array    Array of found valid pathes
 *
 * @author Martin Burchert  <martin.burchert@syscp.de>
 * @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
 */
function findDirs($path, $uid, $gid)
{
    $list = array($path);
    $_fileList = array();
    while (sizeof($list) > 0) {
        $path = array_pop($list);
        $path = makeCorrectDir($path);
        $dh = opendir($path);
        if ($dh === false) {
            standard_error('cannotreaddir', $path);
            return null;
        } else {
            while (false !== ($file = @readdir($dh))) {
                if ($file == '.' && (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid)) {
                    $_fileList[] = makeCorrectDir($path);
                }
                if (is_dir($path . '/' . $file) && $file != '..' && $file != '.') {
                    array_push($list, $path . '/' . $file);
                }
            }
            @closedir($dh);
        }
    }
    return $_fileList;
}
Example #17
0
 /** 
  * _struct_to_array($values, &$i) 
  * 
  * This is adds the contents of the return xml into the array for easier processing. 
  * Recursive, Static 
  * 
  * @access    private 
  * @param    array  $values this is the xml data in an array 
  * @param    int    $i  this is the current location in the array 
  * @return    Array 
  */
 function _struct_to_array($values, &$i)
 {
     $child = array();
     if (isset($values[$i]['value'])) {
         array_push($child, $values[$i]['value']);
     }
     while ($i++ < count($values)) {
         switch ($values[$i]['type']) {
             case 'cdata':
                 array_push($child, $values[$i]['value']);
                 break;
             case 'complete':
                 $name = $values[$i]['tag'];
                 if (!empty($name)) {
                     $child[$name] = is_null($values[$i]['value']) ? '' : $values[$i]['value'];
                     //$child[$name]= ($values[$i]['value'])?($values[$i]['value']):'';
                     if (isset($values[$i]['attributes'])) {
                         $child[$name] = $values[$i]['attributes'];
                     }
                 }
                 break;
             case 'open':
                 $name = $values[$i]['tag'];
                 $size = isset($child[$name]) ? sizeof($child[$name]) : 0;
                 $child[$name][$size] = $this->_struct_to_array($values, $i);
                 break;
             case 'close':
                 return $child;
                 break;
         }
     }
     return $child;
 }
Example #18
0
 public function retrieveDatasFromDB($videoId)
 {
     $query = "SELECT Records.userid, value, second FROM Records WHERE Records.videoid=" . $videoId . ' ORDER BY userid, second;';
     $result = $this->conn->query($query);
     $valueArray = array("user" => array());
     $userValues = array("id" => 0, "values" => array());
     $i = 0;
     if ($result->num_rows > 0) {
         //$allRows = $result -> fetch_all(MYSQLI_ASSOC);
         //print_r(var_dump($allRows));
         while ($row = $result->fetch_assoc()) {
             if ($i != 0) {
                 if (strcmp($previousUser, $row["userid"])) {
                     array_push($valueArray["user"], $userValues);
                     $userValues = array("id" => 0, "values" => array());
                 }
             }
             $previousUser = $row["userid"];
             $i++;
             $userValues["id"] = $previousUser;
             array_push($userValues["values"], $row["value"]);
         }
         array_push($valueArray["user"], $userValues);
     } else {
         echo "O rows";
     }
     //print_r(var_dump($valueArray));
     $this->conn->close();
     return $valueArray;
 }
Example #19
0
function query_operon_gene_percentage($species_id)
{
    $spe = array();
    $spe['name'] = '';
    $spe['ncs'] = array();
    $spe['total_gene'] = 0;
    $spe['in_operon'] = 0;
    $species_id = mysql_real_escape_string($species_id);
    $sql = "SELECT id, name FROM Species WHERE id={$species_id}";
    $result = mysql_query($sql) or die("Invalid query: " . mysql_error());
    $row = mysql_fetch_array($result);
    $spe['name'] = $row['name'];
    unset($result);
    $sql = "SELECT id,NC_id,protein_gene_number,rna_gene_number,operon_number FROM NC WHERE species_id={$species_id}";
    $result = mysql_query($sql) or die("Invalid query: " . mysql_error());
    $n = mysql_num_rows($result);
    for ($i = 0; $i < $n; $i++) {
        $row = mysql_fetch_array($result);
        $NC_id = $row['id'];
        $row['total_gene_num'] = $row['protein_gene_number'] + $row['rna_gene_number'];
        $sql2 = "SELECT sum(size) as total_genes FROM Operon WHERE size>=2 AND NC_id={$NC_id} ORDER BY id";
        $result2 = mysql_query($sql2) or die("Invalid query: " . mysql_error());
        $row2 = mysql_fetch_array($result2);
        $row['gene_in_operon'] = $row2['total_genes'];
        #$row['percent'] = round($row['gene_in_operon'] / $row['total_gene_num'],2);
        array_push($spe['ncs'], $row);
        $spe['total_gene'] += $row['total_gene_num'];
        $spe['in_operon'] += $row['gene_in_operon'];
    }
    $spe['percent'] = round(100 * $spe['in_operon'] / $spe['total_gene'], 2);
    return $spe;
}
Example #20
0
 public function process($args)
 {
     $this->output = "";
     if (strlen(trim($args)) > 0) {
         try {
             $url = "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=3&type=video&q=" . urlencode($args) . "&key=" . $this->apikey;
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
             $respuesta = curl_exec($ch);
             curl_close($ch);
             $resultados = json_decode($respuesta);
             if (isset($resultados->error)) {
                 $this->output = "Ocurrió un problema al realizar la busqueda: " . $resultados->error->errors[0]->reason;
             } else {
                 if (count($resultados->items) > 0) {
                     $videos = array();
                     foreach ($resultados->items as $video) {
                         array_push($videos, "http://www.youtube.com/watch?v=" . $video->id->videoId . " - " . $video->snippet->title);
                     }
                     $this->output = join("\n", $videos);
                 } else {
                     $this->output = "No se pudieron obtener resultados al realizar la busqueda indicada.";
                 }
             }
         } catch (Exception $e) {
             $this->output = "Ocurrió un problema al realizar la busqueda: " . $e->getMessage();
         }
     } else {
         $this->output = "Digame que buscar que no soy adivino.";
     }
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->info('Migrating modules');
     // Get all modules or 1 specific
     if ($moduleName = $this->input->getArgument('module')) {
         $modules = array(app('modules')->module($moduleName));
     } else {
         $modules = app('modules')->modules();
     }
     foreach ($modules as $module) {
         if ($module) {
             if ($this->app['files']->exists($module->path('migrations'))) {
                 // Prepare params
                 $path = ltrim(str_replace(app()->make('path.base'), '', $module->path()), "/") . "/migrations";
                 $_info = array('path' => $path);
                 // Add to migration list
                 array_push($this->migrationList, $_info);
                 $this->info("Added '" . $module->name() . "' to migration list.");
             } else {
                 $this->line("Module <info>'" . $module->name() . "'</info> has no migrations.");
             }
         } else {
             $this->error("Module '" . $moduleName . "' does not exist.");
         }
     }
     if (count($this->migrationList)) {
         $this->info("\n\t\t\t\tRunning Migrations...");
         // Process migration list
         $this->runPathsMigration();
     }
     if ($this->input->getOption('seed')) {
         $this->info("Running Seeding Command...");
         $this->call('modules:seed');
     }
 }
Example #22
0
 private function read($arg)
 {
     $sql = 'SELECT ';
     $fields = array();
     if ($arg == null) {
         $this->fields = array_values($this->modelInfo['fields']);
         foreach ($this->modelInfo['fields'] as $k => $v) {
             array_push($fields, $k . ' as ' . $v);
         }
     } else {
         $args = explode(',', $arg);
         $this->fields = $args;
         foreach ($args as $v) {
             array_push($fields, array_search($v, $this->modelInfo['fields']) . ' as ' . $v);
         }
     }
     $sql .= join(',', $fields);
     $sql .= ' FROM ' . join(',', $this->modelInfo['tables']);
     $sql .= ' WHERE ' . join(' and ', $this->modelInfo['links']);
     if ($this->where) {
         $sql .= ' and ' . $this->where;
     }
     if ($this->order) {
         $sql .= ' ORDER BY ' . $this->order;
     }
     if ($this->limit) {
         $sql .= ' LIMIT ' . $this->limit;
     }
     DEVE and debug::$sql[] = $sql;
     $mysqli = $this->mysqli->prepare($sql) or debug::error('没有查询到数据!', 113004);
     $mysqli->execute();
     $mysqli->store_result();
     return $mysqli;
 }
Example #23
0
 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit46390df264f3e25339b844dea17d85e4', 'loadClassLoader'), true, true);
     self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit46390df264f3e25339b844dea17d85e4', 'loadClassLoader'));
     $includePaths = (require __DIR__ . '/include_paths.php');
     array_push($includePaths, get_include_path());
     set_include_path(join(PATH_SEPARATOR, $includePaths));
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $map = (require __DIR__ . '/autoload_psr4.php');
     foreach ($map as $namespace => $path) {
         $loader->setPsr4($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     $includeFiles = (require __DIR__ . '/autoload_files.php');
     foreach ($includeFiles as $file) {
         composerRequire46390df264f3e25339b844dea17d85e4($file);
     }
     return $loader;
 }
 function process_start($process_name)
 {
     $this =& progress::instance();
     $this->current_process = $process_name;
     array_push($this->processes_stack, $process_name);
     $this->write('started', PROCESS_STARTED);
 }
 /**
  * Constructor
  *
  * @param User    $user    the user for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($user, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->user = $user;
     if (!empty($user)) {
         $profile = $user->getProfile();
         $ao = ActivityObject::fromProfile($profile);
         array_push($ao->extra, $profile->profileInfo($cur));
         // XXX: For users, we generate an author _AND_ an <activity:subject>
         // This is for backward compatibility with clients (especially
         // StatusNet's clients) that assume the Atom will conform to an
         // older version of the Activity Streams API. Subject should be
         // removed in future versions of StatusNet.
         $this->addAuthorRaw($ao->asString('author'));
         $depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
         $this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
     }
     // TRANS: Title in atom user notice feed. %s is a user name.
     $title = sprintf(_("%s timeline"), $user->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
     $logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
     $this->setLogo($logo);
     $this->setUpdated('now');
     $this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
     $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     $this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
 }
 /**
  * Get a list of journals from the sfx table by issn
  *
  * @param mixed $issn		[string or array] ISSN or multiple ISSNs
  * @return Fulltext[]
  */
 public function getFullText($issn)
 {
     $arrFull = array();
     $arrResults = array();
     $strSQL = "SELECT * FROM xerxes_sfx WHERE ";
     if (is_array($issn)) {
         if (count($issn) == 0) {
             throw new \Exception("issn query with no values");
         }
         $x = 1;
         $arrParams = array();
         foreach ($issn as $strIssn) {
             $strIssn = str_replace("-", "", $strIssn);
             if ($x == 1) {
                 $strSQL .= " issn = :issn{$x} ";
             } else {
                 $strSQL .= " OR issn = :issn{$x} ";
             }
             $arrParams["issn{$x}"] = $strIssn;
             $x++;
         }
         $arrResults = $this->select($strSQL, $arrParams);
     } else {
         $issn = str_replace("-", "", $issn);
         $strSQL .= " issn = :issn";
         $arrResults = $this->select($strSQL, array(":issn" => $issn));
     }
     foreach ($arrResults as $arrResult) {
         $objFull = new Fulltext();
         $objFull->load($arrResult);
         array_push($arrFull, $objFull);
     }
     return $arrFull;
 }
function smarty_function_link_list($params, &$smarty1)
{
    global $smarty;
    global $db;
    global $cfg;
    $tbl_link = $cfg['tbl_link'];
    if (empty($params['template'])) {
        $template = "link_list.html";
    }
    if (empty($params['count'])) {
        $count = 5;
    }
    if (empty($params['catalog_id'])) {
        print "function article_detail required catalog_id";
        return;
    }
    extract($params);
    if ($smarty->is_cached($template, $catalog_id)) {
        $smarty->display($template, $catalog_id);
        return;
    }
    $sql = "select name , url , descri ,logo ,sort_order from {$tbl_link} where catalog = {$catalog_id} order by sort_order desc limit {$count}";
    $rs = $db->Execute($sql);
    $links = array();
    while ($arr = $rs->FetchRow()) {
        array_push($links, $arr);
    }
    $rs->close();
    $smarty->assign("links", $links);
    $smarty->display($template, $catalog_id);
}
function wfRegexBlockCheck($current_user)
{
    global $wgMemc, $wgSharedDB;
    if (!wfSimplifiedRegexCheckSharedDB()) {
        return;
    }
    $ip_to_check = wfGetIP();
    $key = "{$wgSharedDB}:regexBlockCore:blockers";
    $cached = $wgMemc->get($key);
    if (!is_array($cached)) {
        /* get from database */
        $blockers_array = array();
        $dbr =& wfGetDB(DB_SLAVE);
        $query = "SELECT blckby_blocker FROM " . wfRegexBlockGetTable() . " GROUP BY blckby_blocker";
        $res = $dbr->query($query);
        while ($row = $dbr->fetchObject($res)) {
            wfGetRegexBlocked($row->blckby_blocker, $current_user, $ip_to_check);
            array_push($blockers_array, $row->blckby_blocker);
        }
        $dbr->freeResult($res);
        $wgMemc->set($key, $blockers_array, REGEXBLOCK_EXPIRE);
    } else {
        /* get from cache */
        foreach ($cached as $blocker) {
            wfGetRegexBlocked($blocker, $current_user, $ip_to_check);
        }
    }
    return true;
}
Example #29
0
 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoloaderInit1eb5cffb2cab52b785cc53528b1e13a2', 'loadClassLoader'), true, true);
     self::$loader = $loader = new \Composer\Autoload\ClassLoader();
     spl_autoload_unregister(array('ComposerAutoloaderInit1eb5cffb2cab52b785cc53528b1e13a2', 'loadClassLoader'));
     $includePaths = (require __DIR__ . '/include_paths.php');
     array_push($includePaths, get_include_path());
     set_include_path(join(PATH_SEPARATOR, $includePaths));
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $map = (require __DIR__ . '/autoload_psr4.php');
     foreach ($map as $namespace => $path) {
         $loader->setPsr4($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     return $loader;
 }
Example #30
0
 public function action_index($options = array("max" => 10, "current" => 1, "count" => 5))
 {
     $model = array();
     $pages = array();
     $max_page = $options["max"];
     // Максимальное количество страниц
     $current_page = $options["current"];
     // Текущая страница
     $pages_length = $options["count"];
     // Количество номеров страниц (нечётное число)
     $next_prev_pages = floor($pages_length / 2);
     // Количество доп. страниц
     $pages[] = array("href" => "#", "active" => "active", "num" => $current_page);
     // Создание доп. страниц
     for ($i = 1; $i <= $next_prev_pages; $i++) {
         if ($current_page - $i > 1) {
             array_unshift($pages, array("href" => URL::query(array("page" => $current_page - $i)), "num" => $current_page - $i));
         }
         if ($current_page + $i < $max_page) {
             array_push($pages, array("href" => URL::query(array("page" => $current_page + $i)), "num" => $current_page + $i));
         }
     }
     if ($current_page > 1) {
         $model["min_page"] = array("num" => 1, "href" => URL::query(array("page" => 1)));
         $model["prev_href"] = URL::query(array("page" => $current_page - 1));
     }
     if ($current_page < $max_page) {
         $model["max_page"] = array("num" => $max_page, "href" => URL::query(array("page" => $max_page)));
         $model["next_href"] = URL::query(array("page" => $current_page + 1));
     }
     $model["pages"] = $pages;
     $this->set_template("/widgets/twig_pagination.php", "twig")->render($model)->body();
 }