function function_add_name($num, $name) { global $funclist, $num_funcs; $funclist[$num]["function_name"] = $name; $funclist[$num]["function_name_fix"] = fix_name($name); return 1; }
public function __construct($legislator_id = 0) { $title_abbr = array('Senator' => 'Sen.', 'Assemblymember' => 'Asm.'); parent::__construct('legislator', $legislator_id); if ($legislator_id) { $dist_number = substr($this->district(), 2, 2); $this->id = $this->id(); $this->img_name = remove_accents(strtolower(fix_name($this->name_last()) . '_' . fix_name($this->name_first()))) . '.jpg'; $this->image = $this->get_image_src(); $this->level = $this->state() ? 'State' : ''; $this->title = $title_abbr[$this->name_title()]; $this->full_name = $this->name_first() . ' ' . $this->name_last(); $this->party = substr($this->party(), 0, 1); $this->district = $this->state() . '-' . $dist_number; $this->full_title = sprintf("%s %s - %s (%s)", $this->level, $this->title, $this->party, $this->district); $this->office = $this->name_title(); } }
private function remove_transients() { $transient_like = fix_name('images_'); $query = "SELECT option_id FROM " . $this->db->options . " WHERE option_name LIKE '%" . $transient_link . "%';"; $get_transients = $this->db->get_results($query); if ($get_transients) { foreach ($get_transients as $option_id) { $this->db->delete($this->db->options, array('option_id' => $option_id)); } } }
function process_upload() { /* Process the upload file */ global $CFG; $ret = array(); // Select the upload dir $upl_dir = $CFG->imgUploadDir; if (isset($_POST['dir']) && $_POST['dir'] !== '') { $upl_dir = realpath($CFG->imgUploadDir . $_POST['dir']); if ((file_exists($upl_dir) && is_dir($upl_dir) && is_subdir($CFG->imgUploadDir, $upl_dir) === true) === false) { $upl_dir = $CFG->imgUploadDir; } } $upl_dir = fix_path($upl_dir); // Create the list of uploaded files, support the one and couple files inputs as array (name like "file[1]") if (!is_array($_FILES['file']['name'])) { $upl_files[1] = $_FILES['file']; } else { $arr_len = count($_FILES['file']['name']); foreach ($_FILES['file'] as $key => $val) { $i = 1; foreach ($val as $v) { $upl_files[$i][$key] = $v; $i++; } } } // Process upload for all uploaded files foreach ($upl_files as $key => $upl_file) { // Allow process upload for new file in list $upload = true; // Fix the upload file name $upload_file = fix_name(strtolower(basename($upl_file['name']))); $file_ext = pathinfo($upload_file, PATHINFO_EXTENSION); // Get file name without the ext $name_wo_ext = empty($file_ext) ? $upload_file : substr($upload_file, 0, -(strlen($file_ext) + 1)); // Get the target upload file path if (!empty($CFG->uploadNameFormat)) { $upload_file_path = $upl_dir . str_replace('n', $name_wo_ext, date($CFG->uploadNameFormat)) . '.' . $file_ext; } else { $upload_file_path = $upl_dir . $upload_file; } // Check if tagret file exist and create owerwrite is disabled - then grenerate the new file name if (!$CFG->overwriteFile && file_exists($upload_file_path)) { $upload_file_path = get_free_file_name($upload_file_path); // If can't get free file name - stop upload if ($upload_file_path === false) { $upload = false; } } // Check file extension if (!in_array($file_ext, $CFG->uploadExt)) { $upload = false; } // Get max upload file size $phpmaxsize = trim(ini_get('upload_max_filesize')); $last = strtolower($phpmaxsize[strlen($phpmaxsize) - 1]); switch ($last) { case 'g': $phpmaxsize *= 1024; case 'm': $phpmaxsize *= 1024; case 'k': $phpmaxsize *= 1024; } $cfgmaxsize = trim($CFG->maxUploadFileSize); $last = strtolower($cfgmaxsize[strlen($cfgmaxsize) - 1]); switch ($last) { case 'g': $cfgmaxsize *= 1024; case 'm': $cfgmaxsize *= 1024; case 'k': $cfgmaxsize *= 1024; } $cfgmaxsize = (int) $cfgmaxsize; // Check upload file size if ($cfgmaxsize > 0 && $upl_file['size'] > $cfgmaxsize || $upl_file['size'] > $phpmaxsize) { $upload = false; } // Check upload dir is writable if (!is_writable($upl_dir)) { $upload = false; } // If all OK then move upload file if ($upload) { move_uploaded_file($upl_file['tmp_name'], $upload_file_path); $ret[] = $upload_file_path; // Resize section if (isset($_POST['resize'][$key]) && $_POST['resize'][$key] !== '') { $newsize = $_POST['resize'][$key]; settype($newsize, 'integer'); $newsize = $newsize < 0 ? $newsize * -1 : $newsize; if ($newsize > $CFG->maxImgResize) { $newsize = $CFG->maxImgResize; } if ($newsize > 0) { if (!function_exists('resize_img')) { require_once 'img_function.php'; } if (function_exists('resize_img')) { resize_img($upload_file_path, $upload_file_path, $newsize); } } } } else { } } return $ret; }