Ejemplo n.º 1
0
 public function upload()
 {
     @set_time_limit(300);
     $ret = ['jsonrpc' => '2.0', 'error' => ['code' => 101, 'message' => '上传出错'], 'id' => 'id'];
     $target_dir = 'uploads/tmp/' . date('Y/m/d/');
     if (!is_dir($target_dir)) {
         mkdir($target_dir, 0777, true);
     }
     $type = arr_get($_REQUEST, 'type', 'image/jpeg');
     $upfile = arr_get($_FILES, 'file|tmp_name', '');
     if (!$type || !$upfile || 'image' != substr($type, 0, 5)) {
         return $ret;
     }
     $ext = substr($type, 6);
     if ('jpeg' == $ext) {
         $ext = 'jpg';
     }
     $md5 = md5_file($upfile);
     $filename = $md5 . '.' . $ext;
     $tofile = $target_dir . $filename;
     if (file_exists($tofile) || move_uploaded_file($upfile, $tofile)) {
         unset($ret['error']);
         $ret['result'] = 'http://' . DOMAIN . '/' . $tofile;
         // resize($tofile, 1600, 900, $target_dir . $md5 . '_s.' . $ext);
         return $ret;
     } else {
         return $ret;
     }
 }
 /**
  * @param Rule $rule
  * @param $data
  * @param $nameData
  * @param $isValid
  */
 protected function ruleCheckValid(Rule $rule, $data, $nameData, &$isValid)
 {
     $rule->setData(arr_get($data, $nameData));
     if (!$rule->isValid()) {
         $this->initRuleErrorMessage($rule->getErrorMessage(), $nameData);
         $isValid = $isValid ? false : $isValid;
     }
 }
Ejemplo n.º 3
0
    static function handle_shortcode($atts)
    {
        self::$gallery_add_script = true;
        // actual shortcode handling here
        ?>

<div class="box">
  <div class="boxInner">
    <div class="player" data-vid="<?php 
        echo $atts["vid"];
        ?>
">
    </div>
  <div class="titleBox">
    <div class="titleBoxFlex">
      <div class="titleBoxFlexContainer">
        <div class="playbutton">

          <svg class="video-overlay-play-button" viewBox="0 0 200 200" alt="Play video">
                             <circle cx="100" cy="100" r="90" fill="none" stroke-width="15" stroke="#fff"/>
                             <polygon points="70, 55 70, 145 145, 100" fill="#fff"/>
                         </svg>

        </div>
      </div>

			<div class="titleBoxInfo" >
				<?php 
        echo arr_get($atts, "name");
        ?>
 <br />
				<?php 
        echo arr_get($atts, "title");
        ?>

				<?php 
        if (isset($atts["link"])) {
            ?>
				<a href="<?php 
            echo arr_get($atts, "link");
            ?>
">עוד</a>
				<?php 
        }
        ?>

			</div>


    </div>

  </div>
  </div>

</div>

<?php 
    }
Ejemplo n.º 4
0
function page_header($title, $params = array())
{
    header('Content-Type: text/html; charset=utf-8');
    if (arr_get('pingbacks', $params, FALSE)) {
        $pingback_url = OPTION_BASE_URL . "/pingback";
        header("X-Pingback: {$pingback_url}");
    }
    if ($title) {
        $title .= ' - ' . OPTION_WEB_DOMAIN;
    } else {
        $title = OPTION_WEB_DOMAIN;
    }
    $P = person_if_signed_on(true);
    /* Don't renew any login cookie. */
    $datestring = date('l d.m.Y');
    $mnpage = array_key_exists('menupage', $params) ? $params['menupage'] : '';
    $rss_feeds = array();
    if (array_key_exists('rss', $params)) {
        $rss_feeds = $params['rss'];
    }
    $canonical_url = null;
    if (array_key_exists('canonical_url', $params)) {
        $canonical_url = $params['canonical_url'];
    }
    $js_files = array("/jl.js");
    if (array_key_exists('js_extra', $params)) {
        $js_files = array_merge($js_files, $params['js_extra']);
    }
    $head_extra = '';
    if (array_key_exists('head_extra', $params)) {
        $head_extra .= $params['head_extra'];
    }
    if (array_key_exists('head_extra_fn', $params)) {
        ob_start();
        call_user_func($params['head_extra_fn']);
        $head_extra .= ob_get_contents();
        ob_end_clean();
    }
    $logged_in_user = null;
    $can_edit_profile = FALSE;
    if ($P) {
        if ($P->name_or_blank()) {
            $logged_in_user = $P->name;
        } else {
            $logged_in_user = $P->email;
        }
        if (db_getOne("SELECT * FROM person_permission WHERE person_id=? AND permission='edit'", $P->id())) {
            $can_edit_profile = TRUE;
        }
    }
    $search = array('q' => '', 'type' => 'journo');
    if (array_key_exists('search_params', $params)) {
        $search = $params['search_params'];
    }
    include "../templates/header.tpl.php";
}
Ejemplo n.º 5
0
 /**
  * Creates a PDO instance representing a connection to a database
  * @param string $dsn
  * @param $config
  * @return PDO
  */
 public function createConnection($dsn, $config)
 {
     $this->username = arr_get($config, "username");
     $this->password = arr_get($config, "password");
     $this->options = arr_get($config, "options", array());
     try {
         return new PDO($dsn, $this->username, $this->password, $this->options);
     } catch (Exception $exception) {
         return $this->tryAgainLostConnection($exception, $dsn);
     }
 }
Ejemplo n.º 6
0
function article_augment(&$a)
{
    $d = new datetime($a['pubdate']);
    $a['pretty_pubdate'] = pretty_date(strtotime($a['pubdate']));
    $a['iso_pubdate'] = $d->format('c');
    // fill in prettyname of publisher, if possible
    if (!array_key_exists('srcorgname', $a) && array_key_exists('srcorg', $a)) {
        $orgs = get_org_names();
        $a['srcorgname'] = arr_get($a['srcorg'], $orgs, '(unknown)');
    }
}
Ejemplo n.º 7
0
 public function getFlash($name = null)
 {
     if (is_null($name)) {
         return array_merge($this->flash, $this->flashNew);
     }
     $value = arr_get($this->flashNew, $name);
     if (!$value) {
         $value = arr_get($this->flash, $name);
     }
     return $value;
 }
Ejemplo n.º 8
0
 /**
  * @param $name
  * @param $default
  * @return mixed
  */
 public static function get($name, $default = null)
 {
     $configName = explode(".", $name);
     $configName = $configName[0];
     if (!isset(static::$dataConfig[$configName])) {
         static::$dataConfig[$configName] = static::load($configName . ".php");
     }
     if ($configName == $name && !is_array(static::$dataConfig[$configName])) {
         return static::$dataConfig[$configName];
     }
     return arr_get(static::$dataConfig, $name, $default);
 }
Ejemplo n.º 9
0
function journo_link($j)
{
    $a = '';
    if (arr_get('ref', $j)) {
        $a .= "<a href=\"/{$j['ref']}\" >{$j['prettyname']}</a>";
    } else {
        $a .= $j['prettyname'];
    }
    if (arr_get('oneliner', $j)) {
        $a .= " <em>({$j['oneliner']})</em>";
    }
    return $a;
}
Ejemplo n.º 10
0
Archivo: User.php Proyecto: nisnaker/tu
 public function check_token()
 {
     $token = arr_get($_COOKIE, 'token', '');
     $info = explode('.', $token);
     if (3 != count($info)) {
         return false;
     }
     list($userid, $time, $hash) = $info;
     if ($hash != hash_hmac('sha256', $userid . $time, CRYPT_KEY)) {
         return false;
     }
     return $userid;
 }
Ejemplo n.º 11
0
 /**
  * @param $config
  * @return string
  * @throws \Exception
  */
 public function getDsn($config)
 {
     $host = arr_get($config, "host");
     $port = arr_get($config, "port");
     $dbname = arr_get($config, "dbname");
     $charset = arr_get($config, "charset", "utf8");
     if (empty($host)) {
         throw new \Exception("\"host\" can not be blank.");
     }
     if (empty($dbname)) {
         throw new \Exception("\"dbname\" can not be blank.");
     }
     return $port ? sprintf('mysql:host=%s;port=%s;dbname=%s;charset=%s', $host, $port, $dbname, $charset) : sprintf('mysql:host=%s;dbname=%s;charset=%s', $host, $dbname, $charset);
 }
Ejemplo n.º 12
0
 function __construct($total, $per_page, $page_var = "p")
 {
     $this->page_var = $page_var;
     $this->total = $total;
     $this->per_page = $per_page;
     $this->num_pages = intval(($total + $per_page - 1) / $per_page);
     /* remember current page might not be valid :-) */
     $page = intval(arr_get($this->page_var, $_GET));
     /*        if($page < 0)
                 $page = 0;
             if($page > $this->num_pages-1)
                 $page = $this->num_pages-1;*/
     $this->page = $page;
 }
Ejemplo n.º 13
0
function view()
{
    $per_page = 100;
    $page = arr_get('p', $_GET, 0);
    $offset = $page * $per_page;
    $limit = $per_page;
    $widgets = array();
    $total = 0;
    $f = new FilterForm($_GET, array(), array());
    if ($f->is_valid()) {
        $total = SubmittedArticle::count($f->cleaned_data);
        foreach (SubmittedArticle::fetch($f->cleaned_data, $offset, $limit) as $err) {
            $widgets[] = new SubmittedArticleWidget($err);
        }
    }
    $paginator = new Paginator($total, $per_page, 'p');
    $v = array('filterform' => &$f, 'widgets' => &$widgets, 'paginator' => $paginator);
    template($v);
}
Ejemplo n.º 14
0
 function heading()
 {
     if ($this->opts['sortable']) {
         $params = $_GET;
         if (arr_get($this->orderfield, $params) == $this->name) {
             // this is the active column!
             $ot = arr_get($this->orderdir, $_GET, 'asc');
             $ot = $ot == 'asc' ? 'desc' : 'asc';
             // toggle
             $url = $this->gen_url($ot);
             // &#8595; downwards arrow
             // &#8593; upwards arrow
             $heading = sprintf('<em><a href="%s">%s %s</a></em>', $url, $this->name, $ot == 'asc' ? '&uarr;' : '&darr;');
         } else {
             $url = $this->gen_url('asc');
             $heading = sprintf('<a href="%s">%s</a>', $url, $this->name);
         }
     } else {
         $heading = $this->name;
     }
     return $heading;
 }
Ejemplo n.º 15
0
<div class="input-group form-group">
	<input type="text" class="form-control" name="name"  value="<?php 
echo arr_get($p, 'name');
?>
" >
	<div class="input-group-addon input-group-addon-width-110">Name</div>
</div>
<div class="input-group form-group">
	<input type="password" class="form-control" name="password">
	<div class="input-group-addon input-group-addon-width-110">Password</div>
</div>
Ejemplo n.º 16
0
 /**
  * @param $name
  * @return array
  */
 public function __get($name)
 {
     return arr_get($this->attributes, $name);
 }
Ejemplo n.º 17
0
 function testGet()
 {
     $input = [["name" => "Jakob", "age" => 37], ["name" => "Topher", "age" => 18]];
     $this->assertEquals("Topher", arr_get($input, "1.name"));
 }
Ejemplo n.º 18
0
<div class="input-group form-group">
	<input type="password" class="form-control" name="confirmation">
	<div class="input-group-addon input-group-addon-width-110">Confirmation</div>
</div>
<div class="input-group form-group">
	<input type="text" class="form-control" name="email"  value="<?php 
echo arr_get($p, 'email');
?>
" >
	<div class="input-group-addon input-group-addon-width-110">Email</div>
</div>
Ejemplo n.º 19
0
 /**
  * Inicio el manejo de usuarios.
  * Esto permite sincronizar la session según lo que dice la base de datos.
  */
 public static function start()
 {
     // Inicio y verifico las sessiones.
     self::start_session();
     if (!self::is_login() && isset($_SESSION['usuario_id'])) {
         unset($_SESSION['usuario_id']);
     }
     self::$usuario_id = arr_get($_SESSION, 'usuario_id', NULL);
 }
Ejemplo n.º 20
0
function view()
{
    $per_page = 100;
    $f = new FilterForm($_GET, array(), array());
    $arts = null;
    $pager = null;
    $total = null;
    if ($f->is_valid()) {
        $page = arr_get('p', $_GET, 0);
        $o = arr_get('o', $_GET, 'pubdate');
        $ot = arr_get('ot', $_GET, 'desc');
        $offset = $page * $per_page;
        $limit = $per_page;
        list($arts, $total) = grab_articles($f->cleaned_data, $o, $ot, $offset, $limit);
        $pager = new Paginator($total, $per_page, 'p');
    }
    $v = array('filter' => $f, 'arts' => $arts, 'paginator' => $pager);
    template($v);
}
Ejemplo n.º 21
0
    function emit_params_form($params)
    {
        ?>
<form method="get">
<input type="hidden" name="action" value="<?php 
        echo $this->ident;
        ?>
" />
<?php 
        foreach ($this->param_spec as $spec) {
            ?>
<label for="<?php 
            echo $spec['name'];
            ?>
"><?php 
            echo $spec['label'];
            ?>
</label>
<?php 
            if (array_key_exists('options', $spec)) {
                /* SELECT element */
                ?>
 <select name="<?php 
                echo $spec['name'];
                ?>
" id="<?php 
                echo $spec['name'];
                ?>
">
 <?php 
                foreach ($spec['options'] as $value => $desc) {
                    ?>
  <option <?php 
                    echo $params[$spec['name']] == $value ? 'selected' : '';
                    ?>
 value="<?php 
                    echo h($value);
                    ?>
"><?php 
                    echo $desc;
                    ?>
</option>
 <?php 
                }
                ?>
 </select>
<?php 
            } else {
                /* just use a generic text input element */
                ?>
 <?php 
                if (arr_get('type', $spec) == 'date') {
                    ?>
 <input type="text" name="<?php 
                    echo $spec['name'];
                    ?>
" id="<?php 
                    echo $spec['name'];
                    ?>
" value="<?php 
                    echo $params[$spec['name']]->format('Y-m-d');
                    ?>
"/>
 <?php 
                } else {
                    ?>
 <input type="text" name="<?php 
                    echo $spec['name'];
                    ?>
" id="<?php 
                    echo $spec['name'];
                    ?>
" value="<?php 
                    echo h($params[$spec['name']]);
                    ?>
"/>
 <?php 
                }
            }
            ?>
<br />
<?php 
        }
        ?>
<label for="fmt">Output format:</label>
<select name="fmt" id="fmt">
 <option value="html" selected>table</option>
 <option value="csv" >csv file</option>
</select>
<input type="submit" value="Go!" />

</form>
<?php 
    }
Ejemplo n.º 22
0
function glue_url($parsed)
{
    assert(is_array($parsed));
    $uri = arr_get('scheme', $parsed) ? $parsed['scheme'] . ':' . (strtolower($parsed['scheme']) == 'mailto' ? '' : '//') : '';
    $uri .= arr_get('user', $parsed) ? $parsed['user'] . (arr_get('pass', $parsed) ? ':' . $parsed['pass'] : '') . '@' : '';
    $uri .= arr_get('host', $parsed) ? $parsed['host'] : '';
    $uri .= arr_get('port', $parsed) ? ':' . $parsed['port'] : '';
    if (arr_get('path', $parsed)) {
        $uri .= substr($parsed['path'], 0, 1) == '/' ? $parsed['path'] : (!empty($uri) ? '/' : '') . $parsed['path'];
    }
    $uri .= arr_get('query', $parsed) ? '?' . $parsed['query'] : '';
    $uri .= arr_get('fragment', $parsed) ? '#' . $parsed['fragment'] : '';
    return $uri;
}
Ejemplo n.º 23
0
function formEmit($params, $errs = array())
{
    global $_keys;
    global $_journo;
    $resp_error = arr_get('recaptcha_error', $errs, '');
    unset($errs['recaptcha_error']);
    ?>
<h2>Email <?php 
    echo $_journo['prettyname'];
    ?>
's profile to a friend</h2>

<form action="/forward" method="post">
<?php 
    if ($errs) {
        ?>
  <div class="errormessage">
   There were errors:
   <ul>
  <?php 
        foreach ($errs as $k => $v) {
            ?>
    <li><?php 
            echo $v;
            ?>
</li>
  <?php 
        }
        ?>
   </ul>
  </div>
<?php 
    }
    ?>
  <dl>
  <dt><label for="email">Recipient</label></dt>
  <dd>
    <input id="email" name="email" value="<?php 
    echo h($params['email']);
    ?>
" />
    <span class="explain">eg: timmytestfish@example.com</span>
  </dd>

  <dt><label for="name">Your name</label></dt>
  <dd><input id="name" name="name" value="<?php 
    echo h($params['name']);
    ?>
" /></dd>

  <dt><label for="message">Message</label><br/> (optional)</dt>
  <dd><textarea name="message" id="message" cols="40" rows="7"><?php 
    echo h($params['message']);
    ?>
</textarea></dd>

  <dt><span class="faux-label">anti-spam test</span></dt>
  <dd>
  <?php 
    echo recaptcha_get_html($_keys['public'], $resp_error);
    ?>
  </dd>
  </dl>
  <input type="hidden" name="journo" value="<?php 
    echo $_journo['ref'];
    ?>
" />
  <input type="hidden" name="action" value="go" />
  <p>please note: your IP address may be logged</p>
  <input type="submit" value="submit" /> or <a href="/<?php 
    echo $_journo['ref'];
    ?>
">cancel</a>
</form>
<?php 
}
Ejemplo n.º 24
0
 /**
  * @param $name
  * @return array
  */
 public function __get($name)
 {
     return arr_get($this->data, $name);
 }
Ejemplo n.º 25
0
<div class="input-group form-group">
	<input type="text" class="form-control" name="title" value="<?php 
echo arr_get($p, 'title');
?>
">
	<div class="input-group-addon input-group-addon-width-110">Title</div>
</div>
<div class="input-group form-group">
	<textarea class="form-control" name="content" id="" rows=10><?php 
echo arr_get($p, 'content');
?>
</textarea>
	<div class="input-group-addon input-group-addon-width-110">Content</div>
</div>