public function action_post_update_content($post, $old, $new) { $service = Options::get('lilliputian__service'); if ('internal' != $service) { include_once dirname(__FILE__) . '/' . $service . '.helper.php'; } $count = preg_match_all('/href=[\'"]([^\'"]+)[\'"]/', $new, $urls); if ($count) { $update = false; foreach ($urls[1] as $url) { // see if this URL is already stored if (isset($post->info->{$url})) { continue; } if ('internal' == $service) { $tiny = $this->internal_check($url); if (!$tiny) { $tiny = $this->internal_shrink($url); } } else { $tiny = shrink($url); } $post->info->{$url} = $tiny; $update = true; } // update the list of links as needed if ($update) { $post->info->url_list = $urls[1]; $post->info->commit(); } } }
public function detail($id_parameter) { $parameter = $this->parameter_m->find($id_parameter); if (!$parameter) { redirect('parameter'); } $this->load->model('metoda_m'); // initialize $metoda = $this->metoda_m->all(); $parameter->metoda_parameter = $this->metoda_m->by_parameter($id_parameter); $parameter->metoda_parameter_array = shrink($parameter->metoda_parameter, 'id_metoda'); $data = array('title' => 'Parameter', 'main_content' => 'parameter/detail_parameter_v', 'parameter' => $parameter, 'metoda' => $metoda); $this->load->view('template', $data); }
#!/usr/bin/php <?php $libs = ''; foreach (glob(dirname(__FILE__) . '/../lib/*.php') as $lib) { $libs .= implode('', array_slice(file($lib), 1)); } list($head, $tail) = preg_split('~/\\*\\s*LIBS\\s*\\*/.*/\\*\\s*ENDLIBS\\s*\\*/~s', file_get_contents(dirname(__FILE__) . '/../bin/pacc')); $output = shrink($head . $libs . $tail); if (!isset($_SERVER['argv'][1]) || in_array('-h', $_SERVER['argv'])) { die($_SERVER['argv'][0] . " [ -h ] <output>\n"); } if ($_SERVER['argv'][1] === '-') { $_SERVER['argv'][1] = 'php://stdout'; } file_put_contents($_SERVER['argv'][1], $output); /** * DGX's PHP shrinker * @copyright David Grudl * @author David Grudl */ function shrink($input) { if (!defined('T_DOC_COMMENT')) { define('T_DOC_COMMENT', -1); } if (!defined('T_ML_COMMENT')) { define('T_ML_COMMENT', -1); } $space = $output = ''; $set = '!"#$&\'()*+,-./:;<=>?@[\\]^`{|}'; $set = array_flip(preg_split('//', $set));