/** */ function botMosImage($published, &$row, &$params, $page = 0) { global $database, $_MAMBOTS; // simple performance check to determine whether bot should process further if (strpos($row->text, 'mosimage') === false) { return true; } // expression to search for $regex = '/{mosimage\\s*.*?}/i'; // check whether mosimage has been disabled for page // check whether mambot has been unpublished if (!$published || !$params->get('image')) { $row->text = preg_replace($regex, '', $row->text); return true; } //count how many {mosimage} are in introtext if it is set to hidden. $introCount = 0; if (!$params->get('introtext') & !$params->get('intro_only')) { preg_match_all($regex, $row->introtext, $matches); $introCount = count($matches[0]); } // find all instances of mambot and put in $matches preg_match_all($regex, $row->text, $matches); // Number of mambots $count = count($matches[0]); // mambot only processes if there are any instances of the mambot in the text if ($count) { // check if param query has previously been processed if (!isset($_MAMBOTS->_content_mambot_params['mosimage'])) { // load mambot params info $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosimage'" . "\n AND folder = 'content'"; $database->setQuery($query); $database->loadObject($mambot); // save query to class variable $_MAMBOTS->_content_mambot_params['mosimage'] = $mambot; } // pull query data from class variable $mambot = $_MAMBOTS->_content_mambot_params['mosimage']; $botParams = new mosParameters($mambot->params); $botParams->def('padding'); $botParams->def('margin'); $botParams->def('link', 0); $images = processImages($row, $botParams, $introCount); // store some vars in globals to access from the replacer $GLOBALS['botMosImageCount'] = 0; $GLOBALS['botMosImageParams'] =& $botParams; $GLOBALS['botMosImageArray'] =& $images; //$GLOBALS['botMosImageArray'] =& $combine; // perform the replacement $row->text = preg_replace_callback($regex, 'botMosImage_replacer', $row->text); // clean up globals unset($GLOBALS['botMosImageCount']); unset($GLOBALS['botMosImageMask']); unset($GLOBALS['botMosImageArray']); unset($GLOBALS['botJosIntroCount']); return true; } }
/** */ function botMosImage($published, &$row, &$cparams, $page = 0, $params) { global $database; // expression to search for $regex = '/{mosimage\\s*.*?}/i'; // find all instances of mambot and put in $matches if (is_callable(array($row, 'getText'))) { $localtext = $row->getText(); } else { $localtext = $row->text; } preg_match_all($regex, $localtext, $matches); // Number of mambots $count = count($matches[0]); // mambot only processes if there are any instances of the mambot in the text if ($count) { // load mambot params info /*$query = "SELECT id FROM #__mambots WHERE element = 'mosimage' AND folder = 'mosimage'"; $database->setQuery( $query ); $id = $database->loadResult(); $mambot = new mosMambot( $database ); $mambot->load( $id );*/ $mambots =& mosMambotHandler::getInstance(); $mambot = $mambots->getBot('mosimage', 'content'); $params =& new mosParameters(isset($mambot->params) ? $mambot->params : ''); $params->def('padding'); $params->def('margin'); $params->def('link', 0); $images = processImages($row, $params, $cparams); // store some vars in globals to access from the replacer $GLOBALS['botMosImageCount'] = 0; $GLOBALS['botMosImageParams'] =& $params; $GLOBALS['botMosImageArray'] =& $images; //$GLOBALS['botMosImageArray'] =& $combine; // perform the replacement $localtext = preg_replace_callback($regex, 'botMosImage_replacer', $localtext); if (is_callable(array($row, 'saveText'))) { $row->saveText($localtext); } else { $row->text = $localtext; } // clean up globals unset($GLOBALS['botMosImageCount']); unset($GLOBALS['botMosImageMask']); unset($GLOBALS['botMosImageArray']); return true; } }
// ZOL_Api::run("Open.Weixin.verification" , array('token'=>$TOKEN)); exit; } else { //接收信息 $data = API_Item_Open_Weixin::receiveMsg(array("subscribeCallback" => "welcomeNewMan", "unsubscribe" => "byebyeMan")); #var_dump($data); if ($data) { $openId = $data["FromUserName"]; $ourId = $data["ToUserName"]; switch ($data["MsgType"]) { case "image": #图片 $inMsgType = "image"; //var_dump($data); $content = $data["PicUrl"]; processImages(array("content" => $content)); break; case "text": #文本信息处理 $content = trim($data["Content"]); $inMsgType = "text"; processText(array("content" => $content)); break; case "link": #URL处理 $title = $data["Title"]; $desc = $data["Description"]; if ($title) { $title = mb_convert_encoding((string) $title, "GBK", "UTF-8"); } if ($desc) {
/** * Add or edit and entry. * * @param array $data * @param string $action * @return bool */ function processEntry($data, $action) { global $wpdb, $connections; $entry = new cnEntry(); //if ( isset($_GET['action']) ) $action = $_GET['action']; // The modification file date that image will be deleted. to maintain compatibility with 0.6.2.1 and older. $compatiblityDate = mktime(0, 0, 0, 6, 1, 2010); // If copying/editing an entry, the entry data is loaded into the class // properties and then properties are overwritten by the POST data as needed. if ( isset($_GET['id']) ) { $entry->set(esc_attr($_GET['id'])); } if ( isset($data['entry_type']) ) $entry->setEntryType($data['entry_type']); if ( isset($data['family_name']) ) $entry->setFamilyName($data['family_name']); if ( isset($data['family_member']) ) $entry->setFamilyMembers($data['family_member']); if ( isset($data['honorific_prefix']) ) $entry->setHonorificPrefix($data['honorific_prefix']); if ( isset($data['first_name']) ) $entry->setFirstName($data['first_name']); if ( isset($data['middle_name']) ) $entry->setMiddleName($data['middle_name']); if ( isset($data['last_name']) ) $entry->setLastName($data['last_name']); if ( isset($data['honorific_suffix']) ) $entry->setHonorificSuffix($data['honorific_suffix']); if ( isset($data['title']) ) $entry->setTitle($data['title']); if ( isset($data['organization']) ) $entry->setOrganization($data['organization']); if ( isset($data['department']) ) $entry->setDepartment($data['department']); if ( isset($data['contact_first_name']) ) $entry->setContactFirstName($data['contact_first_name']); if ( isset($data['contact_last_name']) ) $entry->setContactLastName($data['contact_last_name']); if ( isset($data['address']) ) $entry->setAddresses($data['address']); if ( isset($data['phone_numbers']) ) $entry->setPhoneNumbers($data['phone_numbers']); if ( isset($data['email']) ) $entry->setEmailAddresses($data['email']); if ( isset($data['im']) ) $entry->setIm($data['im']); if ( isset($data['social_media']) ) $entry->setSocialMedia($data['social_media']); if ( isset($data['website']) ) $entry->setWebsites($data['website']); if ( isset($data['birthday_day']) && isset($data['birthday_month']) ) $entry->setBirthday($data['birthday_day'], $data['birthday_month']); if ( isset($data['anniversary_day']) && isset($data['anniversary_month']) ) $entry->setAnniversary($data['anniversary_day'], $data['anniversary_month']); if ( isset($data['bio']) ) $entry->setBio($data['bio']); if ( isset($data['notes']) ) $entry->setNotes($data['notes']); if ( isset($data['visibility']) ) $entry->setVisibility($data['visibility']); /* * Process the logo upload --> START <-- */ if ($_FILES['original_logo']['error'] != 4) { // If an entry is being updated and a new logo is uploaded, the old logo needs to be deleted. if ($entry->getLogoName() != NULL) { unlink( CN_IMAGE_PATH . $entry->getLogoName() ); } // Process the newly uploaded logo. $logoProcessResults = processLogo(); // If there were no errors processing the logo, set the values. if ($logoProcessResults) { $entry->setLogoLinked(TRUE); $entry->setLogoDisplay(TRUE); $entry->setLogoName( $logoProcessResults['name'] ); } else { $entry->setLogoLinked(FALSE); $entry->setLogoDisplay(FALSE); } } else { // Don't do this if an entry is being updated. if ( $action !== 'update' ) { // If an entry is being copied and there is a logo, the logo will be duplicated for the new entry. // That way if an entry is deleted, only the entry specific logo will be deleted. if ($entry->getLogoName() != NULL) $entry->setLogoName( copyImage( $entry->getLogoName() ) ); } } /* * Process the logo upload --> END <-- */ /* * If copying an entry, the logo visibility property is set based on the user's choice. * NOTE: This must come after the logo processing. */ if (isset($data['logoOptions'])) { switch ($data['logoOptions']) { case 'remove': $entry->setLogoDisplay(FALSE); $entry->setLogoLinked(FALSE); /* * Delete logo assigned to the entry. */ if ( is_file( CN_IMAGE_PATH . $entry->getLogoName() ) ) { unlink( CN_IMAGE_PATH . $entry->getLogoName() ); } $entry->setLogoName(NULL); break; case 'hidden': $entry->setLogoDisplay(FALSE); break; case 'show': $entry->setLogoDisplay(TRUE); break; default: $entry->setLogoDisplay(FALSE); break; } } // Process the entry image upload. if ($_FILES['original_image']['error'] != 4) { // If an entry is being updated and a new image is uploaded, the old images need to be deleted. if ($entry->getImageNameOriginal() != NULL) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameOriginal() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameOriginal() ); } } if ($entry->getImageNameThumbnail() != NULL) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameThumbnail() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameThumbnail() ); } } if ($entry->getImageNameCard() != NULL) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameCard() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameCard() ); } } if ($entry->getImageNameProfile() != NULL) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameProfile() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameProfile() ); } } // Process the newly uploaded image. $image_proccess_results = processImages(); // If there were no errors processing the image, set the values. if ($image_proccess_results) { $entry->setImageLinked(true); $entry->setImageDisplay(true); $entry->setImageNameThumbnail($image_proccess_results['image_names']['thumbnail']); $entry->setImageNameCard($image_proccess_results['image_names']['entry']); $entry->setImageNameProfile($image_proccess_results['image_names']['profile']); $entry->setImageNameOriginal($image_proccess_results['image_names']['original']); } else { $entry->setImageLinked(false); $entry->setImageDisplay(false); } } else { // Don't do this if an entry is being updated. if ( $action !== 'update' ) { // If an entry is being copied and there is an image, the image will be duplicated for the new entry. // That way if an entry is deleted, only the entry specific images will be deleted. if ($entry->getImageNameOriginal() != NULL) $entry->setImageNameOriginal( copyImage( $entry->getImageNameOriginal() ) ); if ($entry->getImageNameThumbnail() != NULL) $entry->setImageNameThumbnail( copyImage( $entry->getImageNameThumbnail() ) ); if ($entry->getImageNameCard() != NULL) $entry->setImageNameCard( copyImage( $entry->getImageNameCard() ) ); if ($entry->getImageNameProfile() != NULL) $entry->setImageNameProfile( copyImage( $entry->getImageNameProfile() ) ); } } // If copying an entry, the image visibility property is set based on the user's choice. // NOTE: This must come after the image processing. if (isset($data['imgOptions'])) { switch ($data['imgOptions']) { case 'remove': $entry->setImageDisplay(false); $entry->setImageLinked(false); /* * Delete images assigned to the entry. * * Versions previous to 0.6.2.1 did not not make a duplicate copy of images when * copying an entry so it was possible multiple entries could share the same image. * Only images created after the date that version .0.7.0.0 was released will be deleted, * plus a couple weeks for good measure. */ if ( is_file( CN_IMAGE_PATH . $entry->getImageNameOriginal() ) ) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameOriginal() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameOriginal() ); } } if ( is_file( CN_IMAGE_PATH . $entry->getImageNameThumbnail() ) ) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameThumbnail() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameThumbnail() ); } } if ( is_file( CN_IMAGE_PATH . $entry->getImageNameCard() ) ) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameCard() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameCard() ); } } if ( is_file( CN_IMAGE_PATH . $entry->getImageNameProfile() ) ) { if ( $compatiblityDate < filemtime( CN_IMAGE_PATH . $entry->getImageNameProfile() ) ) { unlink( CN_IMAGE_PATH . $entry->getImageNameProfile() ); } } $entry->setImageNameOriginal(NULL); $entry->setImageNameThumbnail(NULL); $entry->setImageNameCard(NULL); $entry->setImageNameProfile(NULL); break; case 'hidden': $entry->setImageDisplay(false); break; case 'show': $entry->setImageDisplay(true); break; default: $entry->setImageDisplay(false); break; } } switch ($action) { case 'add': if ($entry->save() == FALSE) { $connections->setErrorMessage('entry_added_failed'); return FALSE; } else { $connections->setSuccessMessage('entry_added'); $entryID = (int) $connections->lastInsertID; } break; case 'update': if ($entry->update() == FALSE) { $connections->setErrorMessage('entry_updated_failed'); return FALSE; } else { $connections->setSuccessMessage('entry_updated'); $entryID = (int) $entry->getId(); } break; } /* * Save the entry category(ies). If none were checked, send an empty array * which will add the entry to the default category. */ if ( isset($data['entry_category']) ) { $connections->term->setTermRelationships($entryID, $data['entry_category'], 'category'); } else { $connections->term->setTermRelationships($entryID, array(), 'category'); } unset($entry); return TRUE; }
* This function is unique for each site * * 500px */ function getReputation($userLink) { $html = str_get_html(scraperwiki::scrape($userLink)); $affection = $html->find("div#showaffection h1", 0)->innertext; return $affection; } // Enter Search String $searchString = "paris"; $page = 1; require 'scraperwiki/simple_html_dom.php'; $html_content = scraperwiki::scrape(processSearchString($searchString)); processImages($html_content); /* * Function to turn the search string into a url. * This function is unique for each site * * 500px */ function processSearchString($search) { $page = 1; $s = $search; $s = str_replace(" ", "+", $s); $s = urlencode($s); $link = "http://500px.com/search?order=popularity&page=" . $page . "&q=" . $s . "&type=photos&utf8=%E2%9C%93"; return $link; }
Logger::i()->writeLog("Token to add product is missing", 'access'); die(Submission::createResult("Please refresh the page and try again")); } if (isset($_POST['product'])) { $product = (array) json_decode(base64_decode($_POST['product'])); if ($field = Submission::checkFields(array("name", "price", "description", "available"), $product)) { die(Submission::createResult(ucfirst($field) . " is missing or invalid")); } else { if (!isset($_FILES) || ($field = Submission::checkFields(array("bigimage", "productfile"), $_FILES))) { die(Submission::createResult(ucfirst($field) . " is missing or invalid")); } } $imagePath = null; $bigImagePath = null; $productPath = null; if (($res = processImages("bigimage", $imagePath, $bigImagePath)) || is_null($imagePath) || is_null($bigImagePath)) { die(Submission::createResult("Failed to process image -> " . $res)); } if (($res = processFile("productfile", $productPath)) || is_null($productPath)) { die(Submission::createResult("Failed to process Product File -> " . $res)); } if (floatval($product['price']) == 0) { die(Submission::createResult("Price can not be 0")); } $soldOut = intval($product['available']) == 0 ? 1 : 0; $insert = DbManager::i()->insert("sf_products", array("name", "price", "description", "available", "image", "bigimage", "file", "soldOut"), array($product['name'], floatval($product['price']), $product['description'], intval($product['available']), $imagePath, $bigImagePath, $productPath, $soldOut)); if ($insert) { Logger::i()->writeLog("Added Product successfully"); echo Submission::createResult("Product added successfully", true); } else { Logger::i()->writeLog("Could not add product. error = " . DbManager::i()->error, 'dev');
function processPage($pageHtml) { $pageDom = changeLayout($pageHtml); processImages($pageDom); processLinks($pageDom); removeNoscript($pageDom); removeNavigation($pageDom); removeComingSoon($pageDom); return $pageDom->saveHTML(); }