public static function updateTo($version) { /** * Stupidity protection * Throw an exception stating that i am idiot because i am trying to * overwrite my development files. */ if (Wpjb_Project::VERSION == "#" . "version" . "#") { throw new Exception("You are an idiot! You cannot upgrade development version."); } $id = Wpjb_Utility_Seal::id(); $ck = Wpjb_Utility_Seal::checksum(); $version = Wpjb_Project::getInstance()->conf("upgrade")->available->version; $url = self::URL . "download/id/" . $id . "/checksum/" . $ck . "/version/" . $version; $file = Wpjb_List_Path::getPath("tmp_images") . "/" . md5($url) . ".zip"; $data = self::_download($url); file_put_contents($file, $data); chmod($file, 0600); $baseDir = Wpjb_Project::getInstance()->getProjectBaseDir(); //self::unzip($file, dirname($baseDir)); $zip = new ZipArchive(); if (!@$zip->open($file)) { unlink($file); return self::ZIPERR_OPEN; } if (!@$zip->extractTo(dirname($baseDir))) { unlink($file); return self::ZIPERR_EXTRACT; } self::upgrade(); unlink($file); }
protected function _sql($version) { $file = Wpjb_List_Path::getPath("install") . "/install-" . $version . ".sql"; $queries = explode("; --", file_get_contents($file)); $db = Daq_Db::getInstance(); $wpdb = $db->getDb(); foreach ($queries as $query) { $wpdb->query($query); } }
public static function getAll() { if (!empty(self::$_list)) { return self::$_list; } $file = "country_list.ini"; $default = Wpjb_List_Path::getPath("app_config") . "/" . $file; $user = Wpjb_List_Path::getPath("user_config") . "/" . $file; if (is_file($user)) { self::$_list = Daq_Config::parseIni($user, null, true); } else { self::$_list = Daq_Config::parseIni($default, null, true); } return self::$_list; }
private static function _exists() { if (self::$_seal) { return true; } $file = Wpjb_List_Path::getPath("seal_file"); if (file_exists($file)) { $contents = file_get_contents($file); self::$_seal = unserialize(base64_decode($contents)); } if (is_array(self::$_seal) && count(self::$_seal) >= 4) { return true; } return false; }
protected static function _send($msg) { $path = Wpjb_List_Path::getPath("vendor"); require_once $path . "/TwitterOAuth/OAuth.php"; require_once $path . "/TwitterOAuth/TwitterOAuth.php"; //$user = Wpjb_Project::getInstance()->conf("api_twitter_username"); //$pass = Wpjb_Project::getInstance()->conf("api_twitter_password"); $ck = Wpjb_Project::getInstance()->conf("api_twitter_consumer_key"); $cs = Wpjb_Project::getInstance()->conf("api_twitter_consumer_secret"); $ot = Wpjb_Project::getInstance()->conf("api_twitter_oauth_token"); $os = Wpjb_Project::getInstance()->conf("api_twitter_oauth_secret"); $connection = new TwitterOAuth($ck, $cs, $ot, $os); $content = $connection->get('account/verify_credentials'); if (isset($content->error)) { throw new Exception($content->error); } $connection->post('statuses/update', array('status' => $msg)); return null; }
public function getFiles() { $path = Wpjb_List_Path::getPath("apply_file"); $path .= "/" . $this->id . "/"; $files = glob($path . "*"); if (!is_array($files)) { return array(); } $fArr = array(); foreach ($files as $file) { $f = new stdClass(); $f->basename = basename($file); $f->url = rtrim(site_url(), "/") . "/wp-content/plugins/wpjobboard"; $f->url .= Wpjb_List_Path::getRawPath("apply_file") . "/"; $f->url .= $this->getId() . "/" . $f->basename; $f->size = filesize($file); $f->ext = pathinfo($file, PATHINFO_EXTENSION); $f->dir = $file; $fArr[] = $f; } return $fArr; }
public function getImagePath() { if ($this->hasImage()) { $url = Wpjb_List_Path::getPath("company_logo"); $url .= "/logo_" . $this->getId() . "." . $this->company_logo_ext; return $url; } return null; }
public function save() { $file = $this->getElement("company_logo"); parent::save(); if ($file->fileSent()) { $file->setDestination(Wpjb_List_Path::getPath("company_logo")); $file->upload("logo_" . $this->getObject()->getId() . "." . $file->getExt()); } }
public function save() { $image = null; if ($this->hasElement("image")) { $image = $this->getElement("image"); } $file = null; if ($this->hasElement("file")) { $file = $this->getElement("file"); } $valueList = $this->getValues(); parent::save(); $this->_saveAdditionalFields($valueList); if ($image && $image->fileSent()) { $image->setDestination(Wpjb_List_Path::getPath("resume_photo")); $image->upload("photo_" . $this->getObject()->getId() . "." . $image->getExt()); } if ($file && $file->fileSent()) { $file->setDestination(Wpjb_List_Path::getPath("resume_photo")); $file->upload("file_" . $this->getObject()->getId() . "." . $file->getExt()); } apply_filters("wpja_form_save_resume", $this); $this->reinit(); }
protected function _saveFiles() { $file = array(); $application = $this->getObject(); if ($this->hasElement("resume_id")) { $resume_id = $this->getElement("resume_id")->getValue(); } $name = $this->getElement("applicant_name")->getValue(); $destination = Wpjb_List_Path::getPath("apply_file") . "/" . $application->id; if (!is_dir($destination)) { mkdir($destination); } foreach ($this->_getFiles() as $f) { if ($f->fileSent()) { /* @var $f Daq_Form_Element_File */ $f->setDestination($destination); $this->_files[] = $f->upload(); } } if (isset($resume_id) && is_numeric($resume_id)) { $filename = sanitize_file_name($name . ".html"); $resume = new Wpjb_Model_Resume($resume_id); $rendered = $resume->renderHTML(); file_put_contents($destination . "/" . $filename, $rendered); $this->_files[] = $destination . "/" . $filename; } }
public function getFilePath() { $path = Wpjb_List_Path::getPath("resume_photo"); $path .= "/file_" . $this->getId() . ".*"; $list = glob($path); if (!empty($list)) { return $list[0]; } else { return null; } }
public function saveAction() { if (!$this->_canPost()) { wp_redirect($this->_stepAdd); } $this->view->current_step = 3; $form = new Wpjb_Form_AddJob(); $request = $this->getRequest(); $id = $request->session("wpjb.job_id"); if ($id < 1) { if ($form->isValid($request->session("wpjb.job", array()))) { $paymentMethod = $form->getElement("payment_method")->getValue(); $form->save(); $job = $form->getObject(); if (strlen($request->session("wpjb.job_logo_ext")) > 0) { $ext = $request->session("wpjb.job_logo_ext"); $path1 = Wpjb_List_Path::getPath("tmp_images"); $path2 = Wpjb_List_Path::getPath("user_images"); $oldName = $path1 . "/temp_" . session_id() . "." . $ext; $newName = $path2 . "/job_" . $job->getId() . "." . $ext; $job->company_logo_ext = $ext; $job->save(); rename($oldName, $newName); } if ($job->payment_sum > 0) { $uid = null; if (wp_get_current_user()->ID > 0) { $uid = wp_get_current_user()->ID; } $payment = new Wpjb_Model_Payment(); $payment->user_id = $uid; $payment->object_id = $job->getId(); $payment->object_type = Wpjb_Model_Payment::FOR_JOB; $payment->engine = $paymentMethod; $payment->payment_currency = $job->payment_currency; $payment->payment_sum = $job->payment_sum; $payment->payment_paid = 0; $payment->save(); } $request->setSessionParam("wpjb.job", null); $request->setSessionParam("wpjb.job_logo_ext", null); $request->setSessionParam("wpjb.job_id", $job->getId()); } else { wp_redirect(Wpjb_Project::getInstance()->getUrl() . "/" . $this->_getRouter()->linkTo("step_add")); } } else { $job = new Wpjb_Model_Job($id); } if ($job->payment_sum > 0) { if ($job->payment_sum != $job->payment_paid) { $action = "payment_form"; } else { $action = "payment_already_sent"; } } else { $action = "job_online"; if ($job->is_active && $job->is_approved) { $online = true; } else { $online = false; } $this->view->online = $online; } if ($action == "payment_form") { $payment = Wpjb_Payment_Factory::factory($job->getPayment(true)); $this->view->payment = $payment->render(); } $this->view->action = $action; $this->view->job = $job; }